Commit a3c50bce40d934c75ffad420df639ce66f575134
1 parent
5e9730a4
Exists in
master
and in
2 other branches
Implementing standard models for menus & comboboxes.
Showing
5 changed files
with
257 additions
and
191 deletions
Show diff stats
pw3270.cbp
| ... | ... | @@ -149,6 +149,9 @@ |
| 149 | 149 | <Unit filename="src/objects/toolbar/actions.c"> |
| 150 | 150 | <Option compilerVar="CC" /> |
| 151 | 151 | </Unit> |
| 152 | + <Unit filename="src/objects/toolbar/models.c"> | |
| 153 | + <Option compilerVar="CC" /> | |
| 154 | + </Unit> | |
| 152 | 155 | <Unit filename="src/objects/toolbar/private.h" /> |
| 153 | 156 | <Unit filename="src/objects/toolbar/settings.c"> |
| 154 | 157 | <Option compilerVar="CC" /> | ... | ... |
| ... | ... | @@ -0,0 +1,214 @@ |
| 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 | + #include <pw3270/application.h> | |
| 32 | + #include <pw3270/settings.h> | |
| 33 | + | |
| 34 | + #define GTK_TOOLBAR_DEFAULT_STYLE ((GtkToolbarStyle) -1) | |
| 35 | + | |
| 36 | + static const struct _models { | |
| 37 | + const gchar *name; | |
| 38 | + const gchar *label; | |
| 39 | + const struct _contents { | |
| 40 | + const gchar * label; | |
| 41 | + guint value; | |
| 42 | + } *contents; | |
| 43 | + } models[] = { | |
| 44 | + | |
| 45 | + { | |
| 46 | + "toolbar-icon-size", | |
| 47 | + N_("Icon _size"), | |
| 48 | + (const struct _contents[]) { | |
| 49 | + { | |
| 50 | + .label = N_( "System default" ), | |
| 51 | + .value = GTK_ICON_SIZE_INVALID | |
| 52 | + | |
| 53 | + }, | |
| 54 | + | |
| 55 | + { | |
| 56 | + .label = N_( "Small" ), | |
| 57 | + .value = GTK_ICON_SIZE_SMALL_TOOLBAR | |
| 58 | + }, | |
| 59 | + | |
| 60 | + { | |
| 61 | + .label = N_( "Large" ), | |
| 62 | + .value = GTK_ICON_SIZE_LARGE_TOOLBAR | |
| 63 | + }, | |
| 64 | + | |
| 65 | + { | |
| 66 | + .label = NULL | |
| 67 | + } | |
| 68 | + } | |
| 69 | + }, | |
| 70 | + | |
| 71 | + { | |
| 72 | + "toolbar-style", | |
| 73 | + N_("Toolbar s_tyle"), | |
| 74 | + (const struct _contents[]) { | |
| 75 | + { | |
| 76 | + .label = N_( "System default" ), | |
| 77 | + .value = GTK_TOOLBAR_DEFAULT_STYLE | |
| 78 | + }, | |
| 79 | + | |
| 80 | + { | |
| 81 | + .label = N_( "Icons only" ), | |
| 82 | + .value = GTK_TOOLBAR_ICONS | |
| 83 | + }, | |
| 84 | + | |
| 85 | + { | |
| 86 | + .label = N_( "Text only" ), | |
| 87 | + .value = GTK_TOOLBAR_TEXT | |
| 88 | + }, | |
| 89 | + | |
| 90 | + { | |
| 91 | + .label = N_( "Icons & text" ), | |
| 92 | + .value = GTK_TOOLBAR_BOTH | |
| 93 | + }, | |
| 94 | + { | |
| 95 | + .label = NULL | |
| 96 | + } | |
| 97 | + } | |
| 98 | + }, | |
| 99 | + { | |
| 100 | + "toolbar-icon-type", | |
| 101 | + N_("Icon type"), | |
| 102 | + (const struct _contents[]) { | |
| 103 | + { | |
| 104 | + .label = N_( "System default" ), | |
| 105 | + .value = 0 | |
| 106 | + }, | |
| 107 | + { | |
| 108 | + .label = N_( "Symbolic" ), | |
| 109 | + .value = 1 | |
| 110 | + }, | |
| 111 | + { | |
| 112 | + .label = NULL | |
| 113 | + } | |
| 114 | + } | |
| 115 | + } | |
| 116 | + | |
| 117 | + }; | |
| 118 | + | |
| 119 | + GtkTreeModel * pw3270_model_from_name(const gchar *name) { | |
| 120 | + | |
| 121 | + size_t model; | |
| 122 | + | |
| 123 | + for(model = 0; model < G_N_ELEMENTS(models); model++) { | |
| 124 | + | |
| 125 | + if(g_ascii_strcasecmp(models[model].name,name)) | |
| 126 | + continue; | |
| 127 | + | |
| 128 | + // Create model | |
| 129 | + size_t row; | |
| 130 | + GtkTreeIter iter; | |
| 131 | + GtkListStore * store = gtk_list_store_new(2, G_TYPE_STRING,G_TYPE_UINT); | |
| 132 | + | |
| 133 | + for(row = 0; models[model].contents[row].label; row++) { | |
| 134 | + gtk_list_store_append(store,&iter); | |
| 135 | + gtk_list_store_set( store, | |
| 136 | + &iter, | |
| 137 | + 0, gettext(models[model].contents[row].label), | |
| 138 | + 1, models[model].contents[row].value, | |
| 139 | + -1); | |
| 140 | + } | |
| 141 | + | |
| 142 | + return GTK_TREE_MODEL(store); | |
| 143 | + | |
| 144 | + } | |
| 145 | + | |
| 146 | + return NULL; | |
| 147 | + } | |
| 148 | + | |
| 149 | + void pw3270_model_get_iter_from_value(GtkTreeModel * model, GtkTreeIter *iter, guint value) { | |
| 150 | + | |
| 151 | + if(gtk_tree_model_get_iter_first(model,iter)) { | |
| 152 | + | |
| 153 | + do { | |
| 154 | + | |
| 155 | + GValue gVal = { 0, }; | |
| 156 | + gtk_tree_model_get_value(model,iter,1,&gVal); | |
| 157 | + guint iVal = g_value_get_uint(&gVal); | |
| 158 | + g_value_unset(&gVal); | |
| 159 | + | |
| 160 | + if(iVal == value) { | |
| 161 | + return; | |
| 162 | + } | |
| 163 | + | |
| 164 | + } while(gtk_tree_model_iter_next(model,iter)); | |
| 165 | + | |
| 166 | + } | |
| 167 | + | |
| 168 | + } | |
| 169 | + | |
| 170 | + guint pw3270_model_get_value_from_iter(GtkTreeModel * model, GtkTreeIter *iter) { | |
| 171 | + GValue gVal = { 0, }; | |
| 172 | + gtk_tree_model_get_value(model,iter,1,&gVal); | |
| 173 | + guint iVal = g_value_get_uint(&gVal); | |
| 174 | + g_value_unset(&gVal); | |
| 175 | + return iVal; | |
| 176 | + } | |
| 177 | + | |
| 178 | + GtkWidget * pw3270_menu_item_from_name(const gchar *name) { | |
| 179 | + | |
| 180 | + size_t model; | |
| 181 | + | |
| 182 | + for(model = 0; model < G_N_ELEMENTS(models); model++) { | |
| 183 | + | |
| 184 | + if(g_ascii_strcasecmp(models[model].name,name)) | |
| 185 | + continue; | |
| 186 | + | |
| 187 | + // Create submenu | |
| 188 | + size_t row; | |
| 189 | + GtkWidget * item; | |
| 190 | + GtkWidget * menu = gtk_menu_item_new_with_mnemonic(gettext(models[model].label)); | |
| 191 | + | |
| 192 | + GtkWidget * submenu = gtk_menu_new(); | |
| 193 | + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu),submenu); | |
| 194 | + | |
| 195 | + g_object_set_data(G_OBJECT(submenu),"model-data",(gpointer) &models[model]); | |
| 196 | + | |
| 197 | + for(row = 0; models[model].contents[row].label; row++) { | |
| 198 | + | |
| 199 | + item = gtk_check_menu_item_new_with_mnemonic(gettext(models[model].contents[row].label)); | |
| 200 | + gtk_check_menu_item_set_draw_as_radio(GTK_CHECK_MENU_ITEM(item),TRUE); | |
| 201 | + | |
| 202 | + //g_signal_connect(item, "toggled", G_CALLBACK(set_icon_size), menu); | |
| 203 | + | |
| 204 | + gtk_menu_shell_append(GTK_MENU_SHELL(submenu),item); | |
| 205 | + | |
| 206 | + } | |
| 207 | + | |
| 208 | + gtk_widget_show_all(menu); | |
| 209 | + | |
| 210 | + return menu; | |
| 211 | + } | |
| 212 | + | |
| 213 | + return NULL; | |
| 214 | + } | ... | ... |
src/objects/toolbar/private.h
| ... | ... | @@ -50,8 +50,8 @@ |
| 50 | 50 | G_GNUC_INTERNAL GtkWidget * pw3270_tool_button_new(GAction *action); |
| 51 | 51 | G_GNUC_INTERNAL GtkWidget * pw3270_tool_button_new_from_action_name(const gchar * action_name); |
| 52 | 52 | |
| 53 | - G_GNUC_INTERNAL GtkTreeModel * pw3270_toolbar_style_model_new(); | |
| 54 | - G_GNUC_INTERNAL GtkTreeModel * pw3270_toolbar_icon_size_model_new(); | |
| 53 | + GtkTreeModel * pw3270_model_from_name(const gchar *name); | |
| 54 | + GtkWidget * pw3270_menu_item_from_name(const gchar *name); | |
| 55 | 55 | |
| 56 | 56 | G_GNUC_INTERNAL void pw3270_model_get_iter_from_value(GtkTreeModel * model, GtkTreeIter *iter, guint value); |
| 57 | 57 | G_GNUC_INTERNAL guint pw3270_model_get_value_from_iter(GtkTreeModel * model, GtkTreeIter *iter); | ... | ... |
src/objects/toolbar/settings.c
| ... | ... | @@ -41,16 +41,22 @@ |
| 41 | 41 | /*--[ Constants ]------------------------------------------------------------------------------------*/ |
| 42 | 42 | |
| 43 | 43 | static const struct _comboboxes { |
| 44 | - const gchar * name; | |
| 45 | - const gchar * label; | |
| 44 | + const gchar * name; ///< @brief The gsettings name. | |
| 45 | + const gchar * label; ///< @brief The combo name. | |
| 46 | + guint left; | |
| 47 | + guint top; | |
| 46 | 48 | } comboboxes[] = { |
| 47 | 49 | |
| 48 | 50 | { |
| 51 | + .left = 0, | |
| 52 | + .top = 0, | |
| 49 | 53 | .name = "toolbar-icon-size", |
| 50 | 54 | .label = N_("Icon Size"), |
| 51 | 55 | }, |
| 52 | 56 | |
| 53 | 57 | { |
| 58 | + .left = 3, | |
| 59 | + .top = 0, | |
| 54 | 60 | .name = "toolbar-style", |
| 55 | 61 | .label = N_("Style") |
| 56 | 62 | } |
| ... | ... | @@ -170,17 +176,16 @@ |
| 170 | 176 | gtk_grid_set_column_spacing(grid,12); |
| 171 | 177 | gtk_widget_set_hexpand(GTK_WIDGET(grid),TRUE); |
| 172 | 178 | |
| 173 | - page->models[0] = pw3270_toolbar_icon_size_model_new(); | |
| 174 | - page->models[1] = pw3270_toolbar_style_model_new(); | |
| 175 | - | |
| 176 | 179 | GtkCellRenderer * renderer = gtk_cell_renderer_text_new(); |
| 177 | 180 | |
| 178 | 181 | for(ix = 0; ix < G_N_ELEMENTS(page->models); ix++) { |
| 179 | 182 | |
| 183 | + page->models[ix] = pw3270_model_from_name(comboboxes[ix].name); | |
| 184 | + | |
| 180 | 185 | GtkWidget * label = gtk_label_new(gettext(comboboxes[ix].label)); |
| 181 | 186 | gtk_label_set_xalign(GTK_LABEL(label),1); |
| 182 | 187 | |
| 183 | - gtk_grid_attach(grid,label,(ix*3),0,1,1); | |
| 188 | + gtk_grid_attach(grid,label,comboboxes[ix].left,comboboxes[ix].top,1,1); | |
| 184 | 189 | |
| 185 | 190 | page->combos[ix] = gtk_combo_box_new_with_model(page->models[ix]); |
| 186 | 191 | gtk_widget_set_hexpand(page->combos[ix],TRUE); |
| ... | ... | @@ -188,7 +193,7 @@ |
| 188 | 193 | gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(page->combos[ix]), renderer, TRUE); |
| 189 | 194 | gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(page->combos[ix]), renderer, "text", 0, NULL); |
| 190 | 195 | |
| 191 | - gtk_grid_attach(grid,page->combos[ix],(ix*3)+1,0,2,1); | |
| 196 | + gtk_grid_attach(grid,page->combos[ix],comboboxes[ix].left+1,comboboxes[ix].top,2,1); | |
| 192 | 197 | |
| 193 | 198 | } |
| 194 | 199 | ... | ... |
src/objects/toolbar/toolbar.c
| ... | ... | @@ -38,54 +38,6 @@ |
| 38 | 38 | static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); |
| 39 | 39 | static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); |
| 40 | 40 | |
| 41 | - const struct icon_size { | |
| 42 | - const gchar * label; | |
| 43 | - GtkIconSize icon_size; | |
| 44 | - } icon_sizes[] = { | |
| 45 | - | |
| 46 | - { | |
| 47 | - .label = N_( "System default" ), | |
| 48 | - .icon_size = GTK_ICON_SIZE_INVALID | |
| 49 | - | |
| 50 | - }, | |
| 51 | - | |
| 52 | - { | |
| 53 | - .label = N_( "Small" ), | |
| 54 | - .icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR | |
| 55 | - }, | |
| 56 | - | |
| 57 | - { | |
| 58 | - .label = N_( "Large" ), | |
| 59 | - .icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR | |
| 60 | - }, | |
| 61 | - }; | |
| 62 | - | |
| 63 | - static const struct style { | |
| 64 | - const gchar * label; | |
| 65 | - GtkToolbarStyle style; | |
| 66 | - } styles[] = { | |
| 67 | - | |
| 68 | - { | |
| 69 | - .label = N_( "System default" ), | |
| 70 | - .style = GTK_TOOLBAR_DEFAULT_STYLE | |
| 71 | - }, | |
| 72 | - | |
| 73 | - { | |
| 74 | - .label = N_( "Icons only" ), | |
| 75 | - .style = GTK_TOOLBAR_ICONS | |
| 76 | - }, | |
| 77 | - | |
| 78 | - { | |
| 79 | - .label = N_( "Text only" ), | |
| 80 | - .style = GTK_TOOLBAR_TEXT | |
| 81 | - }, | |
| 82 | - | |
| 83 | - { | |
| 84 | - .label = N_( "Icons & text" ), | |
| 85 | - .style = GTK_TOOLBAR_BOTH | |
| 86 | - }, | |
| 87 | - }; | |
| 88 | - | |
| 89 | 41 | enum { |
| 90 | 42 | PROP_NONE, |
| 91 | 43 | PROP_ACTION_NAMES, |
| ... | ... | @@ -94,17 +46,19 @@ |
| 94 | 46 | PROP_STYLE |
| 95 | 47 | }; |
| 96 | 48 | |
| 49 | + | |
| 97 | 50 | struct _pw3270ToolBar { |
| 98 | 51 | GtkToolbar parent; |
| 99 | 52 | GtkToolbarStyle style; |
| 53 | + GtkWidget *menu; | |
| 100 | 54 | int icon_type; |
| 101 | 55 | |
| 102 | 56 | /// @brief Popup Menu |
| 103 | - struct { | |
| 104 | - GtkWidget * menu; | |
| 105 | - GtkWidget * styles[G_N_ELEMENTS(styles)]; | |
| 106 | - GtkWidget * icon_sizes[G_N_ELEMENTS(icon_sizes)]; | |
| 107 | - } popup; | |
| 57 | +// struct { | |
| 58 | +// GtkWidget * menu; | |
| 59 | +// GtkWidget * styles[G_N_ELEMENTS(styles)]; | |
| 60 | +// GtkWidget * icon_sizes[G_N_ELEMENTS(icon_sizes)]; | |
| 61 | +// } popup; | |
| 108 | 62 | |
| 109 | 63 | }; |
| 110 | 64 | |
| ... | ... | @@ -235,10 +189,11 @@ |
| 235 | 189 | static void detacher(GtkWidget *attach_widget, GtkMenu G_GNUC_UNUSED(*menu)) { |
| 236 | 190 | |
| 237 | 191 | pw3270ToolBar * toolbar = PW3270_TOOLBAR(attach_widget); |
| 238 | - toolbar->popup.menu = NULL; | |
| 192 | + toolbar->menu = NULL; | |
| 239 | 193 | |
| 240 | 194 | } |
| 241 | 195 | |
| 196 | + /* | |
| 242 | 197 | static void set_icon_size(GtkCheckMenuItem *menuitem, GtkWidget *toolbar) { |
| 243 | 198 | |
| 244 | 199 | if(gtk_check_menu_item_get_active(menuitem)) { |
| ... | ... | @@ -256,6 +211,7 @@ |
| 256 | 211 | } |
| 257 | 212 | |
| 258 | 213 | } |
| 214 | + */ | |
| 259 | 215 | |
| 260 | 216 | static void open_preferences(GtkMenuItem G_GNUC_UNUSED(*menuitem), GtkWidget *toolbar) { |
| 261 | 217 | |
| ... | ... | @@ -277,66 +233,21 @@ |
| 277 | 233 | |
| 278 | 234 | static void pw3270ToolBar_init(pw3270ToolBar *widget) { |
| 279 | 235 | |
| 280 | - widget->popup.menu = gtk_menu_new(); | |
| 281 | - | |
| 282 | - // Size options | |
| 283 | - { | |
| 284 | - size_t ix; | |
| 285 | - | |
| 286 | - GtkWidget * item = gtk_menu_item_new_with_mnemonic( _("Icon _size") ); | |
| 287 | - gtk_menu_shell_append(GTK_MENU_SHELL(widget->popup.menu),item); | |
| 288 | - | |
| 289 | - GtkWidget * submenu = gtk_menu_new(); | |
| 290 | - gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),submenu); | |
| 291 | - | |
| 292 | - for(ix = 0; ix < G_N_ELEMENTS(icon_sizes); ix++) { | |
| 293 | - | |
| 294 | - widget->popup.icon_sizes[ix] = item = gtk_check_menu_item_new_with_mnemonic(gettext(icon_sizes[ix].label)); | |
| 295 | - gtk_check_menu_item_set_draw_as_radio(GTK_CHECK_MENU_ITEM(item),TRUE); | |
| 296 | - | |
| 297 | - g_object_set_data(G_OBJECT(item),"icon_size", (gpointer) &icon_sizes[ix]); | |
| 298 | - g_signal_connect(item, "toggled", G_CALLBACK(set_icon_size), widget); | |
| 299 | - | |
| 300 | - gtk_menu_shell_append(GTK_MENU_SHELL(submenu),item); | |
| 301 | - | |
| 302 | - } | |
| 303 | - | |
| 304 | - } | |
| 305 | - | |
| 306 | - // Style option | |
| 307 | - { | |
| 308 | - size_t ix; | |
| 309 | - | |
| 310 | - GtkWidget * item = gtk_menu_item_new_with_mnemonic( _("S_tyle") ); | |
| 311 | - gtk_menu_shell_append(GTK_MENU_SHELL(widget->popup.menu),item); | |
| 312 | - | |
| 313 | - GtkWidget * submenu = gtk_menu_new(); | |
| 314 | - gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),submenu); | |
| 315 | - | |
| 316 | - for(ix = 0; ix < G_N_ELEMENTS(styles); ix++) { | |
| 317 | - | |
| 318 | - widget->popup.styles[ix] = item = gtk_check_menu_item_new_with_mnemonic(gettext(styles[ix].label)); | |
| 319 | - gtk_check_menu_item_set_draw_as_radio(GTK_CHECK_MENU_ITEM(item),TRUE); | |
| 236 | + widget->menu = gtk_menu_new(); | |
| 320 | 237 | |
| 321 | - g_object_set_data(G_OBJECT(item),"toolbar_style", (gpointer) &styles[ix]); | |
| 322 | - g_signal_connect(item, "toggled", G_CALLBACK(set_style), widget); | |
| 323 | - | |
| 324 | - gtk_menu_shell_append(GTK_MENU_SHELL(submenu),item); | |
| 325 | - | |
| 326 | - } | |
| 327 | - | |
| 328 | - } | |
| 238 | + gtk_menu_shell_append(GTK_MENU_SHELL(widget->menu),pw3270_menu_item_from_name("toolbar-style")); | |
| 239 | + gtk_menu_shell_append(GTK_MENU_SHELL(widget->menu),pw3270_menu_item_from_name("toolbar-icon-size")); | |
| 240 | + gtk_menu_shell_append(GTK_MENU_SHELL(widget->menu),pw3270_menu_item_from_name("toolbar-icon-type")); | |
| 329 | 241 | |
| 330 | 242 | // Toolbar preferences. |
| 331 | 243 | { |
| 332 | 244 | GtkWidget * item = gtk_menu_item_new_with_mnemonic( _("_Preferences") ); |
| 333 | - gtk_menu_shell_append(GTK_MENU_SHELL(widget->popup.menu),item); | |
| 245 | + gtk_menu_shell_append(GTK_MENU_SHELL(widget->menu),item); | |
| 334 | 246 | g_signal_connect(item, "activate", G_CALLBACK(open_preferences), widget); |
| 335 | 247 | } |
| 336 | 248 | |
| 337 | - // gtk_container_set_border_width(GTK_CONTAINER(widget->popup_menu),6); | |
| 338 | - gtk_widget_show_all(widget->popup.menu); | |
| 339 | - gtk_menu_attach_to_widget(GTK_MENU(widget->popup.menu),GTK_WIDGET(widget),detacher); | |
| 249 | + gtk_widget_show_all(widget->menu); | |
| 250 | + gtk_menu_attach_to_widget(GTK_MENU(widget->menu),GTK_WIDGET(widget),detacher); | |
| 340 | 251 | |
| 341 | 252 | } |
| 342 | 253 | |
| ... | ... | @@ -356,11 +267,11 @@ |
| 356 | 267 | |
| 357 | 268 | debug("%s button_number=%d",__FUNCTION__,button_number); |
| 358 | 269 | |
| 359 | - if(toolbar->popup.menu) { | |
| 270 | + if(toolbar->menu) { | |
| 360 | 271 | #if GTK_CHECK_VERSION(3,22,0) |
| 361 | - gtk_menu_popup_at_pointer(GTK_MENU(toolbar->popup.menu),NULL); | |
| 272 | + gtk_menu_popup_at_pointer(GTK_MENU(toolbar->menu),NULL); | |
| 362 | 273 | #else |
| 363 | - gtk_menu_popup(GTK_MENU(toolbar->popup.menu), NULL, NULL, NULL, NULL, 0, 0); | |
| 274 | + gtk_menu_popup(GTK_MENU(toolbar->menu), NULL, NULL, NULL, NULL, 0, 0); | |
| 364 | 275 | #endif |
| 365 | 276 | } |
| 366 | 277 | |
| ... | ... | @@ -379,9 +290,10 @@ |
| 379 | 290 | else |
| 380 | 291 | gtk_toolbar_set_style(GTK_TOOLBAR(toolbar),style); |
| 381 | 292 | |
| 293 | + /* | |
| 382 | 294 | // Update menu |
| 383 | 295 | pw3270ToolBar * tb = PW3270_TOOLBAR(toolbar); |
| 384 | - if(tb && tb->popup.menu) { | |
| 296 | + if(tb && tb->menu) { | |
| 385 | 297 | size_t ix; |
| 386 | 298 | for(ix = 0; ix < G_N_ELEMENTS(styles); ix++) { |
| 387 | 299 | |
| ... | ... | @@ -391,9 +303,7 @@ |
| 391 | 303 | ); |
| 392 | 304 | } |
| 393 | 305 | } |
| 394 | - | |
| 395 | - // Store value | |
| 396 | -// pw3270_settings_set_int("toolbar-style",(int) style); | |
| 306 | + */ | |
| 397 | 307 | |
| 398 | 308 | g_object_notify(G_OBJECT(toolbar), "style"); |
| 399 | 309 | |
| ... | ... | @@ -422,8 +332,9 @@ |
| 422 | 332 | gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar),icon_size); |
| 423 | 333 | |
| 424 | 334 | // Update menu |
| 335 | + /* | |
| 425 | 336 | pw3270ToolBar * tb = PW3270_TOOLBAR(toolbar); |
| 426 | - if(tb && tb->popup.menu) { | |
| 337 | + if(tb && tb->menu) { | |
| 427 | 338 | size_t ix; |
| 428 | 339 | for(ix = 0; ix < G_N_ELEMENTS(icon_sizes); ix++) { |
| 429 | 340 | |
| ... | ... | @@ -433,6 +344,7 @@ |
| 433 | 344 | ); |
| 434 | 345 | } |
| 435 | 346 | } |
| 347 | + */ | |
| 436 | 348 | |
| 437 | 349 | // Store value |
| 438 | 350 | g_object_notify(G_OBJECT(toolbar), "icon-size"); |
| ... | ... | @@ -527,71 +439,3 @@ |
| 527 | 439 | return g_string_free(str,FALSE); |
| 528 | 440 | } |
| 529 | 441 | |
| 530 | - GtkTreeModel * pw3270_toolbar_style_model_new() { | |
| 531 | - | |
| 532 | - size_t ix; | |
| 533 | - GtkTreeIter iter; | |
| 534 | - GtkListStore * model = gtk_list_store_new(2, G_TYPE_STRING,G_TYPE_UINT); | |
| 535 | - | |
| 536 | - for(ix = 0; ix < G_N_ELEMENTS(icon_sizes); ix++) { | |
| 537 | - gtk_list_store_append(model,&iter); | |
| 538 | - gtk_list_store_set( model, | |
| 539 | - &iter, | |
| 540 | - 0, gettext(styles[ix].label), | |
| 541 | - 1, (guint) styles[ix].style, | |
| 542 | - -1); | |
| 543 | - | |
| 544 | - } | |
| 545 | - | |
| 546 | - return GTK_TREE_MODEL(model); | |
| 547 | - | |
| 548 | - } | |
| 549 | - | |
| 550 | - GtkTreeModel * pw3270_toolbar_icon_size_model_new() { | |
| 551 | - | |
| 552 | - size_t ix; | |
| 553 | - GtkTreeIter iter; | |
| 554 | - GtkListStore * model = gtk_list_store_new(2, G_TYPE_STRING,G_TYPE_UINT); | |
| 555 | - | |
| 556 | - for(ix = 0; ix < G_N_ELEMENTS(icon_sizes); ix++) { | |
| 557 | - gtk_list_store_append(model,&iter); | |
| 558 | - gtk_list_store_set( model, | |
| 559 | - &iter, | |
| 560 | - 0, gettext(icon_sizes[ix].label), | |
| 561 | - 1, (guint) icon_sizes[ix].icon_size, | |
| 562 | - -1); | |
| 563 | - | |
| 564 | - } | |
| 565 | - | |
| 566 | - return GTK_TREE_MODEL(model); | |
| 567 | - } | |
| 568 | - | |
| 569 | - void pw3270_model_get_iter_from_value(GtkTreeModel * model, GtkTreeIter *iter, guint value) { | |
| 570 | - | |
| 571 | - if(gtk_tree_model_get_iter_first(model,iter)) { | |
| 572 | - | |
| 573 | - do { | |
| 574 | - | |
| 575 | - GValue gVal = { 0, }; | |
| 576 | - gtk_tree_model_get_value(model,iter,1,&gVal); | |
| 577 | - guint iVal = g_value_get_uint(&gVal); | |
| 578 | - g_value_unset(&gVal); | |
| 579 | - | |
| 580 | - if(iVal == value) { | |
| 581 | - return; | |
| 582 | - } | |
| 583 | - | |
| 584 | - } while(gtk_tree_model_iter_next(model,iter)); | |
| 585 | - | |
| 586 | - } | |
| 587 | - | |
| 588 | - } | |
| 589 | - | |
| 590 | - guint pw3270_model_get_value_from_iter(GtkTreeModel * model, GtkTreeIter *iter) { | |
| 591 | - GValue gVal = { 0, }; | |
| 592 | - gtk_tree_model_get_value(model,iter,1,&gVal); | |
| 593 | - guint iVal = g_value_get_uint(&gVal); | |
| 594 | - g_value_unset(&gVal); | |
| 595 | - return iVal; | |
| 596 | -} | |
| 597 | - | ... | ... |