Commit 093014ccca1811b15c3b63ea5003fc7bb75d017a
1 parent
9b41602e
Exists in
master
and in
4 other branches
Adjustments for integration.
Showing
4 changed files
with
313 additions
and
261 deletions
Show diff stats
pw3270.cbp
| @@ -14,7 +14,6 @@ | @@ -14,7 +14,6 @@ | ||
| 14 | <Option type="1" /> | 14 | <Option type="1" /> |
| 15 | <Option compiler="gcc" /> | 15 | <Option compiler="gcc" /> |
| 16 | <Option use_console_runner="0" /> | 16 | <Option use_console_runner="0" /> |
| 17 | - <Option parameters="--remap=./charsets/bracket.xml" /> | ||
| 18 | <Compiler> | 17 | <Compiler> |
| 19 | <Add option="-g" /> | 18 | <Add option="-g" /> |
| 20 | <Add option="-DDEBUG=1" /> | 19 | <Add option="-DDEBUG=1" /> |
| @@ -43,6 +42,7 @@ | @@ -43,6 +42,7 @@ | ||
| 43 | </Linker> | 42 | </Linker> |
| 44 | <Unit filename="Makefile.in" /> | 43 | <Unit filename="Makefile.in" /> |
| 45 | <Unit filename="configure.ac" /> | 44 | <Unit filename="configure.ac" /> |
| 45 | + <Unit filename="src/include/pw3270.h" /> | ||
| 46 | <Unit filename="src/include/pw3270/actions.h" /> | 46 | <Unit filename="src/include/pw3270/actions.h" /> |
| 47 | <Unit filename="src/include/pw3270/application.h" /> | 47 | <Unit filename="src/include/pw3270/application.h" /> |
| 48 | <Unit filename="src/include/pw3270/toolbar.h" /> | 48 | <Unit filename="src/include/pw3270/toolbar.h" /> |
| @@ -70,10 +70,10 @@ | @@ -70,10 +70,10 @@ | ||
| 70 | <Unit filename="src/objects/actions/window.c"> | 70 | <Unit filename="src/objects/actions/window.c"> |
| 71 | <Option compilerVar="CC" /> | 71 | <Option compilerVar="CC" /> |
| 72 | </Unit> | 72 | </Unit> |
| 73 | - <Unit filename="src/objects/toolbar/core.c"> | 73 | + <Unit filename="src/objects/toolbar/private.h" /> |
| 74 | + <Unit filename="src/objects/toolbar/toolbar.c"> | ||
| 74 | <Option compilerVar="CC" /> | 75 | <Option compilerVar="CC" /> |
| 75 | </Unit> | 76 | </Unit> |
| 76 | - <Unit filename="src/objects/toolbar/private.h" /> | ||
| 77 | <Unit filename="src/objects/window/actions.c"> | 77 | <Unit filename="src/objects/window/actions.c"> |
| 78 | <Option compilerVar="CC" /> | 78 | <Option compilerVar="CC" /> |
| 79 | </Unit> | 79 | </Unit> |
| @@ -0,0 +1,52 @@ | @@ -0,0 +1,52 @@ | ||
| 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 Declares the pw3270 Action objects. | ||
| 32 | + * | ||
| 33 | + */ | ||
| 34 | + | ||
| 35 | +#ifndef PW3270_H_INCLUDED | ||
| 36 | + | ||
| 37 | + #define PW3270_H_INCLUDED | ||
| 38 | + | ||
| 39 | + #include <config.h> | ||
| 40 | + | ||
| 41 | + #ifndef GETTEXT_PACKAGE | ||
| 42 | + #define GETTEXT_PACKAGE PACKAGE_NAME | ||
| 43 | + #endif | ||
| 44 | + | ||
| 45 | + #include <libintl.h> | ||
| 46 | + #include <glib/gi18n.h> | ||
| 47 | + #include <gtk/gtk.h> | ||
| 48 | + | ||
| 49 | + /* not really I18N-related, but also a string marker macro */ | ||
| 50 | + #define I_(string) g_intern_static_string (string) | ||
| 51 | + | ||
| 52 | +#endif // PW3270_H_INCLUDED |
src/objects/toolbar/core.c
| @@ -1,258 +0,0 @@ | @@ -1,258 +0,0 @@ | ||
| 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 | - #include "private.h" | ||
| 31 | - | ||
| 32 | - static gboolean popup_context_menu(GtkToolbar *toolbar, gint x, gint y, gint button_number); | ||
| 33 | - static void finalize(GObject *object); | ||
| 34 | - | ||
| 35 | - | ||
| 36 | - struct _pw3270ToolBar { | ||
| 37 | - GtkToolbar parent; | ||
| 38 | - | ||
| 39 | - /// @brief Popup Menu | ||
| 40 | - GtkWidget * popup_menu; | ||
| 41 | - | ||
| 42 | - }; | ||
| 43 | - | ||
| 44 | - struct _pw3270ToolBarClass { | ||
| 45 | - | ||
| 46 | - GtkToolbarClass parent_class; | ||
| 47 | - | ||
| 48 | - | ||
| 49 | - }; | ||
| 50 | - | ||
| 51 | - G_DEFINE_TYPE(pw3270ToolBar, pw3270ToolBar, GTK_TYPE_TOOLBAR); | ||
| 52 | - | ||
| 53 | - static void pw3270ToolBar_class_init(pw3270ToolBarClass *klass) { | ||
| 54 | - | ||
| 55 | - GtkToolbarClass * toolbar = GTK_TOOLBAR_CLASS(klass); | ||
| 56 | - | ||
| 57 | - toolbar->popup_context_menu = popup_context_menu; | ||
| 58 | - | ||
| 59 | - G_OBJECT_CLASS(klass)->finalize = finalize; | ||
| 60 | - | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - static void detacher(GtkWidget *attach_widget, GtkMenu *menu) { | ||
| 64 | - | ||
| 65 | - pw3270ToolBar * toolbar = PW3270_TOOLBAR(attach_widget); | ||
| 66 | - toolbar->popup_menu = NULL; | ||
| 67 | - | ||
| 68 | - } | ||
| 69 | - | ||
| 70 | - static void set_icon_size(GtkMenuItem *menuitem, GtkWidget *toolbar) { | ||
| 71 | - | ||
| 72 | - GtkIconSize * icon_size = g_object_get_data(G_OBJECT(menuitem),"icon_size"); | ||
| 73 | - | ||
| 74 | - if(icon_size) | ||
| 75 | - gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar),*icon_size); | ||
| 76 | - else | ||
| 77 | - gtk_toolbar_unset_icon_size(GTK_TOOLBAR(toolbar)); | ||
| 78 | - | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - static void set_style(GtkMenuItem *menuitem, GtkWidget *toolbar) { | ||
| 82 | - | ||
| 83 | - GtkToolbarStyle * style = g_object_get_data(G_OBJECT(menuitem),"toolbar_style"); | ||
| 84 | - | ||
| 85 | - if(style) | ||
| 86 | - gtk_toolbar_set_style(GTK_TOOLBAR(toolbar),*style); | ||
| 87 | - else | ||
| 88 | - gtk_toolbar_unset_style(GTK_TOOLBAR(toolbar)); | ||
| 89 | - | ||
| 90 | - } | ||
| 91 | - | ||
| 92 | - static void pw3270ToolBar_init(pw3270ToolBar *widget) { | ||
| 93 | - | ||
| 94 | - widget->popup_menu = gtk_menu_new(); | ||
| 95 | - | ||
| 96 | - // Size options | ||
| 97 | - { | ||
| 98 | - static const struct { | ||
| 99 | - const gchar * label; | ||
| 100 | - GtkIconSize icon_size; | ||
| 101 | - } itens[] = { | ||
| 102 | - | ||
| 103 | - { | ||
| 104 | - .label = N_( "System default" ) | ||
| 105 | - | ||
| 106 | - }, | ||
| 107 | - | ||
| 108 | - { | ||
| 109 | - .label = N_( "Small" ), | ||
| 110 | - .icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR | ||
| 111 | - }, | ||
| 112 | - | ||
| 113 | - { | ||
| 114 | - .label = N_( "Large" ), | ||
| 115 | - .icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR | ||
| 116 | - }, | ||
| 117 | - }; | ||
| 118 | - | ||
| 119 | - size_t ix; | ||
| 120 | - | ||
| 121 | - GtkWidget * item = gtk_menu_item_new_with_mnemonic( _("Icon _size") ); | ||
| 122 | - gtk_menu_shell_append(GTK_MENU_SHELL(widget->popup_menu),item); | ||
| 123 | - | ||
| 124 | - GtkWidget * submenu = gtk_menu_new(); | ||
| 125 | - gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),submenu); | ||
| 126 | - | ||
| 127 | - for(ix = 0; ix < G_N_ELEMENTS(itens); ix++) { | ||
| 128 | - | ||
| 129 | - item = gtk_menu_item_new_with_mnemonic(gettext(itens[ix].label)); | ||
| 130 | - | ||
| 131 | - if(ix > 0) | ||
| 132 | - g_object_set_data(G_OBJECT(item),"icon_size", (gpointer) &itens[ix].icon_size); | ||
| 133 | - | ||
| 134 | - g_signal_connect(item, "activate", G_CALLBACK(set_icon_size), widget); | ||
| 135 | - | ||
| 136 | - gtk_menu_shell_append(GTK_MENU_SHELL(submenu),item); | ||
| 137 | - | ||
| 138 | - } | ||
| 139 | - | ||
| 140 | - } | ||
| 141 | - | ||
| 142 | - // Style option | ||
| 143 | - { | ||
| 144 | - static const struct { | ||
| 145 | - const gchar * label; | ||
| 146 | - GtkToolbarStyle style; | ||
| 147 | - } itens[] = { | ||
| 148 | - | ||
| 149 | - { | ||
| 150 | - .label = N_( "System default" ) | ||
| 151 | - }, | ||
| 152 | - | ||
| 153 | - { | ||
| 154 | - .label = N_( "Icons only" ), | ||
| 155 | - .style = GTK_TOOLBAR_ICONS | ||
| 156 | - }, | ||
| 157 | - | ||
| 158 | - { | ||
| 159 | - .label = N_( "Text only" ), | ||
| 160 | - .style = GTK_TOOLBAR_TEXT | ||
| 161 | - }, | ||
| 162 | - | ||
| 163 | - { | ||
| 164 | - .label = N_( "Icons & text" ), | ||
| 165 | - .style = GTK_TOOLBAR_BOTH | ||
| 166 | - }, | ||
| 167 | - }; | ||
| 168 | - | ||
| 169 | - size_t ix; | ||
| 170 | - | ||
| 171 | - GtkWidget * item = gtk_menu_item_new_with_mnemonic( _("S_tyle") ); | ||
| 172 | - gtk_menu_shell_append(GTK_MENU_SHELL(widget->popup_menu),item); | ||
| 173 | - | ||
| 174 | - GtkWidget * submenu = gtk_menu_new(); | ||
| 175 | - gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),submenu); | ||
| 176 | - | ||
| 177 | - for(ix = 0; ix < G_N_ELEMENTS(itens); ix++) { | ||
| 178 | - | ||
| 179 | - item = gtk_menu_item_new_with_mnemonic(gettext(itens[ix].label)); | ||
| 180 | - | ||
| 181 | - if(ix > 0) | ||
| 182 | - g_object_set_data(G_OBJECT(item),"toolbar_style", (gpointer) &itens[ix].style); | ||
| 183 | - | ||
| 184 | - g_signal_connect(item, "activate", G_CALLBACK(set_style), widget); | ||
| 185 | - | ||
| 186 | - gtk_menu_shell_append(GTK_MENU_SHELL(submenu),item); | ||
| 187 | - | ||
| 188 | - } | ||
| 189 | - | ||
| 190 | - } | ||
| 191 | - | ||
| 192 | - // gtk_container_set_border_width(GTK_CONTAINER(widget->popup_menu),6); | ||
| 193 | - gtk_widget_show_all(widget->popup_menu); | ||
| 194 | - gtk_menu_attach_to_widget(GTK_MENU(widget->popup_menu),GTK_WIDGET(widget),detacher); | ||
| 195 | - | ||
| 196 | - } | ||
| 197 | - | ||
| 198 | - static void finalize(GObject *object) { | ||
| 199 | - | ||
| 200 | -// pw3270ToolBar * toolbar = PW3270_TOOLBAR(object); | ||
| 201 | - | ||
| 202 | - | ||
| 203 | - G_OBJECT_CLASS(pw3270ToolBar_parent_class)->finalize(object); | ||
| 204 | - | ||
| 205 | - } | ||
| 206 | - | ||
| 207 | - GtkWidget * pw3270_toolbar_new(void) { | ||
| 208 | - return g_object_new(PW3270_TYPE_TOOLBAR, NULL); | ||
| 209 | - } | ||
| 210 | - | ||
| 211 | - GtkWidget * pw3270_toolbar_insert_lib3270_action(GtkWidget *toolbar, const LIB3270_ACTION *action, gint pos) { | ||
| 212 | - | ||
| 213 | - g_return_val_if_fail(GTK_IS_TOOLBAR(toolbar),NULL); | ||
| 214 | - | ||
| 215 | - if(!action) { | ||
| 216 | - g_message(_("Invalid action identifier")); | ||
| 217 | - return NULL; | ||
| 218 | - } | ||
| 219 | - | ||
| 220 | - if(!action->icon) { | ||
| 221 | - g_message(_("Action \"%s\" doesn't have an icon"), action->name); | ||
| 222 | - return NULL; | ||
| 223 | - } | ||
| 224 | - | ||
| 225 | - if(!action->label) { | ||
| 226 | - g_message(_("Action \"%s\" doesn't have a label"), action->name); | ||
| 227 | - return NULL; | ||
| 228 | - } | ||
| 229 | - | ||
| 230 | - debug("Action: %s icon: %s", action->name, action->icon); | ||
| 231 | - | ||
| 232 | - GtkToolItem * item = gtk_tool_button_new(gtk_image_new_from_icon_name(action->icon,GTK_ICON_SIZE_LARGE_TOOLBAR),gettext(action->label)); | ||
| 233 | - gtk_tool_button_set_use_underline(GTK_TOOL_BUTTON(item),TRUE); | ||
| 234 | - | ||
| 235 | - gtk_widget_set_name(GTK_WIDGET(item), action->name); | ||
| 236 | - | ||
| 237 | - if(action->summary) | ||
| 238 | - gtk_tool_item_set_tooltip_text(item,gettext(action->summary)); | ||
| 239 | - | ||
| 240 | - gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, pos); | ||
| 241 | - | ||
| 242 | - return GTK_WIDGET(item); | ||
| 243 | - } | ||
| 244 | - | ||
| 245 | - gboolean popup_context_menu(GtkToolbar *widget, gint x, gint y, gint button_number) { | ||
| 246 | - | ||
| 247 | - pw3270ToolBar * toolbar = PW3270_TOOLBAR(widget); | ||
| 248 | - | ||
| 249 | - debug("%s button_number=%d",__FUNCTION__,button_number); | ||
| 250 | - | ||
| 251 | - if(toolbar->popup_menu) { | ||
| 252 | - gtk_menu_popup_at_pointer(GTK_MENU(toolbar->popup_menu),NULL); | ||
| 253 | - } | ||
| 254 | - | ||
| 255 | - | ||
| 256 | - return TRUE; | ||
| 257 | - | ||
| 258 | - } |
| @@ -0,0 +1,258 @@ | @@ -0,0 +1,258 @@ | ||
| 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 | + #include "private.h" | ||
| 31 | + | ||
| 32 | + static gboolean popup_context_menu(GtkToolbar *toolbar, gint x, gint y, gint button_number); | ||
| 33 | + static void finalize(GObject *object); | ||
| 34 | + | ||
| 35 | + | ||
| 36 | + struct _pw3270ToolBar { | ||
| 37 | + GtkToolbar parent; | ||
| 38 | + | ||
| 39 | + /// @brief Popup Menu | ||
| 40 | + GtkWidget * popup_menu; | ||
| 41 | + | ||
| 42 | + }; | ||
| 43 | + | ||
| 44 | + struct _pw3270ToolBarClass { | ||
| 45 | + | ||
| 46 | + GtkToolbarClass parent_class; | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + }; | ||
| 50 | + | ||
| 51 | + G_DEFINE_TYPE(pw3270ToolBar, pw3270ToolBar, GTK_TYPE_TOOLBAR); | ||
| 52 | + | ||
| 53 | + static void pw3270ToolBar_class_init(pw3270ToolBarClass *klass) { | ||
| 54 | + | ||
| 55 | + GtkToolbarClass * toolbar = GTK_TOOLBAR_CLASS(klass); | ||
| 56 | + | ||
| 57 | + toolbar->popup_context_menu = popup_context_menu; | ||
| 58 | + | ||
| 59 | + G_OBJECT_CLASS(klass)->finalize = finalize; | ||
| 60 | + | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + static void detacher(GtkWidget *attach_widget, GtkMenu *menu) { | ||
| 64 | + | ||
| 65 | + pw3270ToolBar * toolbar = PW3270_TOOLBAR(attach_widget); | ||
| 66 | + toolbar->popup_menu = NULL; | ||
| 67 | + | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + static void set_icon_size(GtkMenuItem *menuitem, GtkWidget *toolbar) { | ||
| 71 | + | ||
| 72 | + GtkIconSize * icon_size = g_object_get_data(G_OBJECT(menuitem),"icon_size"); | ||
| 73 | + | ||
| 74 | + if(icon_size) | ||
| 75 | + gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar),*icon_size); | ||
| 76 | + else | ||
| 77 | + gtk_toolbar_unset_icon_size(GTK_TOOLBAR(toolbar)); | ||
| 78 | + | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + static void set_style(GtkMenuItem *menuitem, GtkWidget *toolbar) { | ||
| 82 | + | ||
| 83 | + GtkToolbarStyle * style = g_object_get_data(G_OBJECT(menuitem),"toolbar_style"); | ||
| 84 | + | ||
| 85 | + if(style) | ||
| 86 | + gtk_toolbar_set_style(GTK_TOOLBAR(toolbar),*style); | ||
| 87 | + else | ||
| 88 | + gtk_toolbar_unset_style(GTK_TOOLBAR(toolbar)); | ||
| 89 | + | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + static void pw3270ToolBar_init(pw3270ToolBar *widget) { | ||
| 93 | + | ||
| 94 | + widget->popup_menu = gtk_menu_new(); | ||
| 95 | + | ||
| 96 | + // Size options | ||
| 97 | + { | ||
| 98 | + static const struct { | ||
| 99 | + const gchar * label; | ||
| 100 | + GtkIconSize icon_size; | ||
| 101 | + } itens[] = { | ||
| 102 | + | ||
| 103 | + { | ||
| 104 | + .label = N_( "System default" ) | ||
| 105 | + | ||
| 106 | + }, | ||
| 107 | + | ||
| 108 | + { | ||
| 109 | + .label = N_( "Small" ), | ||
| 110 | + .icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR | ||
| 111 | + }, | ||
| 112 | + | ||
| 113 | + { | ||
| 114 | + .label = N_( "Large" ), | ||
| 115 | + .icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR | ||
| 116 | + }, | ||
| 117 | + }; | ||
| 118 | + | ||
| 119 | + size_t ix; | ||
| 120 | + | ||
| 121 | + GtkWidget * item = gtk_menu_item_new_with_mnemonic( _("Icon _size") ); | ||
| 122 | + gtk_menu_shell_append(GTK_MENU_SHELL(widget->popup_menu),item); | ||
| 123 | + | ||
| 124 | + GtkWidget * submenu = gtk_menu_new(); | ||
| 125 | + gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),submenu); | ||
| 126 | + | ||
| 127 | + for(ix = 0; ix < G_N_ELEMENTS(itens); ix++) { | ||
| 128 | + | ||
| 129 | + item = gtk_menu_item_new_with_mnemonic(gettext(itens[ix].label)); | ||
| 130 | + | ||
| 131 | + if(ix > 0) | ||
| 132 | + g_object_set_data(G_OBJECT(item),"icon_size", (gpointer) &itens[ix].icon_size); | ||
| 133 | + | ||
| 134 | + g_signal_connect(item, "activate", G_CALLBACK(set_icon_size), widget); | ||
| 135 | + | ||
| 136 | + gtk_menu_shell_append(GTK_MENU_SHELL(submenu),item); | ||
| 137 | + | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + // Style option | ||
| 143 | + { | ||
| 144 | + static const struct { | ||
| 145 | + const gchar * label; | ||
| 146 | + GtkToolbarStyle style; | ||
| 147 | + } itens[] = { | ||
| 148 | + | ||
| 149 | + { | ||
| 150 | + .label = N_( "System default" ) | ||
| 151 | + }, | ||
| 152 | + | ||
| 153 | + { | ||
| 154 | + .label = N_( "Icons only" ), | ||
| 155 | + .style = GTK_TOOLBAR_ICONS | ||
| 156 | + }, | ||
| 157 | + | ||
| 158 | + { | ||
| 159 | + .label = N_( "Text only" ), | ||
| 160 | + .style = GTK_TOOLBAR_TEXT | ||
| 161 | + }, | ||
| 162 | + | ||
| 163 | + { | ||
| 164 | + .label = N_( "Icons & text" ), | ||
| 165 | + .style = GTK_TOOLBAR_BOTH | ||
| 166 | + }, | ||
| 167 | + }; | ||
| 168 | + | ||
| 169 | + size_t ix; | ||
| 170 | + | ||
| 171 | + GtkWidget * item = gtk_menu_item_new_with_mnemonic( _("S_tyle") ); | ||
| 172 | + gtk_menu_shell_append(GTK_MENU_SHELL(widget->popup_menu),item); | ||
| 173 | + | ||
| 174 | + GtkWidget * submenu = gtk_menu_new(); | ||
| 175 | + gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),submenu); | ||
| 176 | + | ||
| 177 | + for(ix = 0; ix < G_N_ELEMENTS(itens); ix++) { | ||
| 178 | + | ||
| 179 | + item = gtk_menu_item_new_with_mnemonic(gettext(itens[ix].label)); | ||
| 180 | + | ||
| 181 | + if(ix > 0) | ||
| 182 | + g_object_set_data(G_OBJECT(item),"toolbar_style", (gpointer) &itens[ix].style); | ||
| 183 | + | ||
| 184 | + g_signal_connect(item, "activate", G_CALLBACK(set_style), widget); | ||
| 185 | + | ||
| 186 | + gtk_menu_shell_append(GTK_MENU_SHELL(submenu),item); | ||
| 187 | + | ||
| 188 | + } | ||
| 189 | + | ||
| 190 | + } | ||
| 191 | + | ||
| 192 | + // gtk_container_set_border_width(GTK_CONTAINER(widget->popup_menu),6); | ||
| 193 | + gtk_widget_show_all(widget->popup_menu); | ||
| 194 | + gtk_menu_attach_to_widget(GTK_MENU(widget->popup_menu),GTK_WIDGET(widget),detacher); | ||
| 195 | + | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + static void finalize(GObject *object) { | ||
| 199 | + | ||
| 200 | +// pw3270ToolBar * toolbar = PW3270_TOOLBAR(object); | ||
| 201 | + | ||
| 202 | + | ||
| 203 | + G_OBJECT_CLASS(pw3270ToolBar_parent_class)->finalize(object); | ||
| 204 | + | ||
| 205 | + } | ||
| 206 | + | ||
| 207 | + GtkWidget * pw3270_toolbar_new(void) { | ||
| 208 | + return g_object_new(PW3270_TYPE_TOOLBAR, NULL); | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + GtkWidget * pw3270_toolbar_insert_lib3270_action(GtkWidget *toolbar, const LIB3270_ACTION *action, gint pos) { | ||
| 212 | + | ||
| 213 | + g_return_val_if_fail(GTK_IS_TOOLBAR(toolbar),NULL); | ||
| 214 | + | ||
| 215 | + if(!action) { | ||
| 216 | + g_message(_("Invalid action identifier")); | ||
| 217 | + return NULL; | ||
| 218 | + } | ||
| 219 | + | ||
| 220 | + if(!action->icon) { | ||
| 221 | + g_message(_("Action \"%s\" doesn't have an icon"), action->name); | ||
| 222 | + return NULL; | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + if(!action->label) { | ||
| 226 | + g_message(_("Action \"%s\" doesn't have a label"), action->name); | ||
| 227 | + return NULL; | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + debug("Action: %s icon: %s", action->name, action->icon); | ||
| 231 | + | ||
| 232 | + GtkToolItem * item = gtk_tool_button_new(gtk_image_new_from_icon_name(action->icon,GTK_ICON_SIZE_LARGE_TOOLBAR),gettext(action->label)); | ||
| 233 | + gtk_tool_button_set_use_underline(GTK_TOOL_BUTTON(item),TRUE); | ||
| 234 | + | ||
| 235 | + gtk_widget_set_name(GTK_WIDGET(item), action->name); | ||
| 236 | + | ||
| 237 | + if(action->summary) | ||
| 238 | + gtk_tool_item_set_tooltip_text(item,gettext(action->summary)); | ||
| 239 | + | ||
| 240 | + gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, pos); | ||
| 241 | + | ||
| 242 | + return GTK_WIDGET(item); | ||
| 243 | + } | ||
| 244 | + | ||
| 245 | + gboolean popup_context_menu(GtkToolbar *widget, gint x, gint y, gint button_number) { | ||
| 246 | + | ||
| 247 | + pw3270ToolBar * toolbar = PW3270_TOOLBAR(widget); | ||
| 248 | + | ||
| 249 | + debug("%s button_number=%d",__FUNCTION__,button_number); | ||
| 250 | + | ||
| 251 | + if(toolbar->popup_menu) { | ||
| 252 | + gtk_menu_popup_at_pointer(GTK_MENU(toolbar->popup_menu),NULL); | ||
| 253 | + } | ||
| 254 | + | ||
| 255 | + | ||
| 256 | + return TRUE; | ||
| 257 | + | ||
| 258 | + } |