Commit 507fd2754e24fd040d12f9691a8a5f8b2c4dd3ee
1 parent
821655b8
Exists in
master
and in
4 other branches
Fixing header bar buttons.
Showing
4 changed files
with
90 additions
and
6 deletions
Show diff stats
pw3270.cbp
@@ -61,6 +61,9 @@ | @@ -61,6 +61,9 @@ | ||
61 | <Unit filename="src/objects/actions/abstract.c"> | 61 | <Unit filename="src/objects/actions/abstract.c"> |
62 | <Option compilerVar="CC" /> | 62 | <Option compilerVar="CC" /> |
63 | </Unit> | 63 | </Unit> |
64 | + <Unit filename="src/objects/actions/button.c"> | ||
65 | + <Option compilerVar="CC" /> | ||
66 | + </Unit> | ||
64 | <Unit filename="src/objects/actions/clipboard.c"> | 67 | <Unit filename="src/objects/actions/clipboard.c"> |
65 | <Option compilerVar="CC" /> | 68 | <Option compilerVar="CC" /> |
66 | </Unit> | 69 | </Unit> |
src/include/pw3270/actions.h
@@ -116,6 +116,9 @@ | @@ -116,6 +116,9 @@ | ||
116 | /// @brief Get the action tooltip. | 116 | /// @brief Get the action tooltip. |
117 | const gchar * pw3270_action_get_tooltip(GAction *action); | 117 | const gchar * pw3270_action_get_tooltip(GAction *action); |
118 | 118 | ||
119 | + /// @brief Create a button associated with the action. | ||
120 | + GtkWidget * pw3270_action_button_new(GAction *action, const gchar *action_name); | ||
121 | + | ||
119 | /// @brief Associate action with the terminal widget. | 122 | /// @brief Associate action with the terminal widget. |
120 | void pw3270_action_set_terminal_widget(GAction *action, GtkWidget *terminal); | 123 | void pw3270_action_set_terminal_widget(GAction *action, GtkWidget *terminal); |
121 | 124 |
@@ -0,0 +1,81 @@ | @@ -0,0 +1,81 @@ | ||
1 | +/* | ||
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | ||
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | ||
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | ||
5 | + * | ||
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | ||
7 | + * | ||
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | ||
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | ||
10 | + * Free Software Foundation. | ||
11 | + * | ||
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | ||
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | ||
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | ||
15 | + * obter mais detalhes. | ||
16 | + * | ||
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | ||
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | ||
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | + * | ||
21 | + * Este programa está nomeado como - e possui - linhas de código. | ||
22 | + * | ||
23 | + * Contatos: | ||
24 | + * | ||
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | ||
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | ||
27 | + * | ||
28 | + */ | ||
29 | + | ||
30 | + /** | ||
31 | + * @brief Implement PW3270 action button. | ||
32 | + * | ||
33 | + */ | ||
34 | + | ||
35 | + #include "private.h" | ||
36 | + #include <pw3270/actions.h> | ||
37 | + | ||
38 | + /// @brief Create a button associated with the action. | ||
39 | + GtkWidget * pw3270_action_button_new(GAction *action, const gchar *action_name) { | ||
40 | + | ||
41 | + g_return_val_if_fail(PW3270_IS_ACTION(action),NULL); | ||
42 | + | ||
43 | + const gchar * icon_name = pw3270_action_get_icon_name(action); | ||
44 | + | ||
45 | + GtkWidget *image; | ||
46 | + if(g_str_has_prefix(icon_name,"gtk-")) { | ||
47 | + image = gtk_image_new_from_icon_name(icon_name,GTK_ICON_SIZE_BUTTON); | ||
48 | + } else { | ||
49 | + g_autofree gchar * symbolic_name = g_strconcat(icon_name,"-symbolic",NULL); | ||
50 | + image = gtk_image_new_from_icon_name(symbolic_name,GTK_ICON_SIZE_BUTTON); | ||
51 | + } | ||
52 | + | ||
53 | + | ||
54 | + // If fails, use the regular icon. | ||
55 | + if(!image) { | ||
56 | + debug("***************** %s",icon_name); | ||
57 | + } | ||
58 | + | ||
59 | + if(!image) { | ||
60 | + g_warning("Can't create button for icon \"%s\"",icon_name); | ||
61 | + return NULL; | ||
62 | + } | ||
63 | + | ||
64 | + GtkWidget * button = gtk_button_new(); | ||
65 | + gtk_button_set_image(GTK_BUTTON(button), image); | ||
66 | + | ||
67 | + gtk_actionable_set_action_name(GTK_ACTIONABLE(button),action_name ? action_name : g_action_get_name(action)); | ||
68 | + gtk_widget_set_visible(button,g_action_get_enabled(action)); | ||
69 | + | ||
70 | + gtk_widget_set_can_focus(button,FALSE); | ||
71 | + gtk_widget_set_can_default(button,FALSE); | ||
72 | + gtk_widget_set_focus_on_click(button,FALSE); | ||
73 | + | ||
74 | + const gchar * tooltip = pw3270_action_get_tooltip(action); | ||
75 | + if(tooltip) | ||
76 | + gtk_widget_set_tooltip_markup(button,tooltip); | ||
77 | + | ||
78 | + return button; | ||
79 | + | ||
80 | + } | ||
81 | + |
src/objects/window/header.c
@@ -77,12 +77,9 @@ | @@ -77,12 +77,9 @@ | ||
77 | 77 | ||
78 | // It's a window action. | 78 | // It's a window action. |
79 | GAction * action = g_action_map_lookup_action(G_ACTION_MAP(widget),action_name+4); | 79 | GAction * action = g_action_map_lookup_action(G_ACTION_MAP(widget),action_name+4); |
80 | - const gchar * icon_name = pw3270_action_get_icon_name(action); | ||
81 | - if(action && icon_name) { | ||
82 | - button = pw3270_setup_image_button(gtk_menu_button_new(),icon_name); | ||
83 | - gtk_actionable_set_action_name(GTK_ACTIONABLE(button),action_name); | ||
84 | - gtk_widget_set_visible(button,g_action_get_enabled(action)); | ||
85 | - } | 80 | + |
81 | + if(action) | ||
82 | + button = pw3270_action_button_new(action,action_name); | ||
86 | 83 | ||
87 | } | 84 | } |
88 | 85 |