diff --git a/src/include/pw3270.h b/src/include/pw3270.h index 30d6aaf..5c02c43 100644 --- a/src/include/pw3270.h +++ b/src/include/pw3270.h @@ -52,7 +52,7 @@ #define I_(string) g_intern_static_string (string) - void pw3270_load_placeholders(GtkBuilder * builder); + void pw3270_load_placeholders(GApplication *application, GtkBuilder * builder); // GtkWidget * pw3270_frame_new(GtkWidget * child, const gchar *title); // Application settings widget diff --git a/src/include/pw3270/application.h b/src/include/pw3270/application.h index a9c2dc0..134ba17 100644 --- a/src/include/pw3270/application.h +++ b/src/include/pw3270/application.h @@ -77,6 +77,7 @@ // Tools GtkBuilder * pw3270_application_get_builder(const gchar *name); + void gtk_container_remove_all(GtkContainer *container); // Actions diff --git a/src/include/pw3270/keypad.h b/src/include/pw3270/keypad.h index a2579a7..294a1d9 100644 --- a/src/include/pw3270/keypad.h +++ b/src/include/pw3270/keypad.h @@ -54,7 +54,7 @@ GList * pw3270_keypad_model_new_from_xml(GList *keypads, const gchar *filename); GtkWidget * pw3270_keypad_get_from_model(GObject *model); - const gchar * pw3270_keypad_model_get_action_name(GObject *model); + const gchar * pw3270_keypad_model_get_name(GObject *model); const gchar * pw3270_keypad_model_get_label(GObject *model); typedef enum _keypad_position { diff --git a/src/main/placeholders.c b/src/main/placeholders.c index d2822d2..0a71079 100644 --- a/src/main/placeholders.c +++ b/src/main/placeholders.c @@ -35,14 +35,42 @@ #include "private.h" #include + #include #include #include /*---[ Implement ]----------------------------------------------------------------------------------*/ - void pw3270_load_placeholders(GtkBuilder * builder) { + static GMenu * get_keypad_menu(GApplication *application) { - GObject * placeholder = gtk_builder_get_object(builder, "font-select-placeholder"); + GList * keypads = pw3270_application_get_keypad_models(application); + + if(!keypads) + return NULL; + + GMenu * menu = g_menu_new(); + + // Create keypad items. + GList *item; + for(item = keypads;item;item = g_list_next(item)) { + GObject * model = G_OBJECT(item->data); + g_autofree gchar * action_name = g_strconcat("win.keypad.",pw3270_keypad_model_get_name(model),NULL); + g_menu_append(menu,pw3270_keypad_model_get_label(model),action_name); + } + + return menu; + + } + + void pw3270_load_placeholders(GApplication *application, GtkBuilder * builder) { + + GObject * placeholder; + size_t ix; + + // + // Load fonts + // + placeholder = gtk_builder_get_object(builder, "font-select-placeholder"); if(placeholder && G_IS_MENU(placeholder)) { @@ -52,7 +80,6 @@ PangoFontFamily **families; pango_context_list_families(gdk_pango_context_get_for_screen(gdk_screen_get_default()),&families, &n_families); - size_t ix; for(ix=0; ix < (size_t) n_families; ix++) { if(!pango_font_family_is_monospace(families[ix])) @@ -66,5 +93,30 @@ } + // + // View options + // + GMenu * keypad_menu = get_keypad_menu(application); + + if(keypad_menu) { + + static const gchar * placeholders[] = { + "view-menu-placeholder", + "view-when-offline-placeholder", + "view-when-online-placeholder" + }; + + for(ix = 0; ix < G_N_ELEMENTS(placeholders); ix++) { + + placeholder = gtk_builder_get_object(builder, placeholders[ix]); + + if(placeholder) { + g_menu_append_item(G_MENU(placeholder), g_menu_item_new_submenu(_("Keypads"),G_MENU_MODEL(keypad_menu))); + } + + } + + g_object_unref(keypad_menu); + } } diff --git a/src/objects/application/application.c b/src/objects/application/application.c index 4f0227c..9cb29ad 100644 --- a/src/objects/application/application.c +++ b/src/objects/application/application.c @@ -415,7 +415,7 @@ gtk_application_set_menubar(GTK_APPLICATION (application), G_MENU_MODEL(gtk_builder_get_object (builder, "menubar"))); - pw3270_load_placeholders(builder); + pw3270_load_placeholders(application, builder); g_object_unref(builder); diff --git a/src/objects/keypad/model.c b/src/objects/keypad/model.c index 93dab2d..ae4fbd1 100644 --- a/src/objects/keypad/model.c +++ b/src/objects/keypad/model.c @@ -351,7 +351,7 @@ return (KEYPAD_POSITION) PW_KEYPAD_MODEL(model)->position; } - const gchar * pw3270_keypad_model_get_action_name(GObject *model) { + const gchar * pw3270_keypad_model_get_name(GObject *model) { g_return_val_if_fail(PW_IS_KEYPAD_MODEL(model), NULL); return PW_KEYPAD_MODEL(model)->name; } diff --git a/src/objects/window/window.c b/src/objects/window/window.c index 410dfa3..d0902ef 100644 --- a/src/objects/window/window.c +++ b/src/objects/window/window.c @@ -194,9 +194,11 @@ g_signal_connect(widget,"hide",G_CALLBACK(keypad_hide),model); g_signal_connect(widget,"show",G_CALLBACK(keypad_show),model); + g_autofree gchar * action_name = g_strconcat("keypad.",pw3270_keypad_model_get_name(model),NULL); + GPropertyAction * action = g_property_action_new( - pw3270_keypad_model_get_action_name(model), + action_name, widget, "visible" ); @@ -243,7 +245,7 @@ gtk_notebook_set_action_widget(widget->notebook,new_tab,GTK_PACK_START); } - widget->toolbar = GTK_TOOLBAR(pw3270_toolbar_new()); + widget->toolbar = GTK_TOOLBAR(pw3270_toolbar_new()); gtk_box_pack_start(container,GTK_WIDGET(widget->toolbar),FALSE,TRUE,0); // @@ -447,6 +449,7 @@ // Get builder // g_autoptr(GtkBuilder) builder = pw3270_application_get_builder("window.xml"); + pw3270_load_placeholders(G_APPLICATION(application), builder); // Load popup menus. const gchar * popup_menus[PW3270_APP_WINDOW_POPUP_COUNT] = { diff --git a/ui/application.xml b/ui/application.xml index 826d4bc..3652cf2 100644 --- a/ui/application.xml +++ b/ui/application.xml @@ -79,7 +79,6 @@ - Application preferences app.preferences diff --git a/ui/window.xml b/ui/window.xml index 43f80db..d90d957 100644 --- a/ui/window.xml +++ b/ui/window.xml @@ -274,181 +274,191 @@ - - - _Edit - -
- - - Paste from clipboard - win.paste - - - - Paste next - win.paste-next - - - - Paste from text file - win.paste-file - - -
- -
- - - Select all - win.select-all - - - - Select Field - win.select-field - - - - Reselect - win.reselect - - -
- -
+ - - Clear - win.clear - + _Edit - - Erase input - win.erase_input - +
- Delete Field - win.delete_field + Paste from clipboard + win.paste - Erase to end of field - win.erase_eof + Paste next + win.paste-next - Erase to end of line - win.erase_eol + Paste from text file + win.paste-file -
- -
+
- - Save screen - win.save.screen - +
- - Print screen - win.print.screen - + + Select all + win.select-all + - - Send/Receive files - win.file.transfer - + + Select Field + win.select-field + - + + Reselect + win.reselect + - Options +
-
+
- Cross hair cursor - win.crosshair + Clear + win.clear - Resize on alternate screen - win.altscreen + Erase input + win.erase_input - Alert sound - win.beep + Delete Field + win.delete_field -
- - Monocase - win.monocase + Erase to end of field + win.erase_eof - Dynamic font spacing - win.dynamic-font-spacing + Erase to end of line + win.erase_eol + +
+ +
+ + + + Options + +
+ + + Cross hair cursor + win.crosshair + + + + Resize on alternate screen + win.altscreen + + + + Alert sound + win.beep + + +
+ + + Monocase + win.monocase + + + + Dynamic font spacing + win.dynamic-font-spacing + -
+
-
+ + Smart paste + win.smartpaste + -
+ + Paste with left margin + win.marginedpaste + - - Smart paste - win.smartpaste - + + Blank Fill + win.blankfill + - - Paste with left margin - win.marginedpaste - +
+ +
- Blank Fill - win.blankfill + Full screen + win.fullscreen -
+
-
+ + + + + View - Show toolbar + Toolbar win.toolbar - Show menu + Top menu win.menubar + + +
+ - Full screen - win.fullscreen + Save screen + win.save.screen + + + + Print screen + win.print.screen + + + + Send/Receive files + win.file.transfer
- +
- - Disconnect - win.disconnect - + + Disconnect + win.disconnect + - - Close window - win.close - + + Close window + win.close + +
+
@@ -472,73 +482,84 @@ - - _Connect - win.connect - - - - Session properties - win.session.properties - - - Screen size + Options - Model 2 - 80x24 - win.model-number - 2 - - - Model 3 - 80x32 - win.model-number - 3 - - - Model 4 - 80x43 - win.model-number - 4 + Dynamic font spacing + win.dynamic-font-spacing + - Model 5 - 132x27 - win.model-number - 5 + Full screen + win.fullscreen + + + Screen size + + + Model 2 - 80x24 + win.model-number + 2 + + + Model 3 - 80x32 + win.model-number + 3 + + + Model 4 - 80x43 + win.model-number + 4 + + + Model 5 - 132x27 + win.model-number + 5 + + + + - + - Options + View - Dynamic font spacing - win.dynamic-font-spacing + Toolbar + win.toolbar - Show toolbar - win.toolbar + Main menu + win.menubar + + +
+ - Show menu - win.menubar + _Connect + win.connect - Full screen - win.fullscreen + Session properties + win.session.properties - - - Close window - win.close - + + Close window + win.close + + +
-- libgit2 0.21.2