From dbbac7ef52ee1389a2c2cde4f257cdff4bcaafc3 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Sat, 19 Sep 2020 11:47:26 -0300 Subject: [PATCH] Toolbar visual adjustments. --- src/include/pw3270/settings.h | 2 +- src/objects/actions/save.c | 2 +- src/objects/application/actions/preferences.c | 3 ++- src/objects/application/open.c | 2 -- src/objects/settings/dialog.c | 8 +++++--- src/objects/toolbar/actions.c | 27 +++++++++++++++++++-------- src/objects/toolbar/toolbar.c | 12 +++++++----- src/objects/window/actions/sessionproperties.c | 3 ++- src/objects/window/keyfile.c | 4 ++-- ui/application.xml | 2 +- ui/window.xml | 10 +++++----- 11 files changed, 45 insertions(+), 30 deletions(-) diff --git a/src/include/pw3270/settings.h b/src/include/pw3270/settings.h index e3942b8..2c99ac3 100644 --- a/src/include/pw3270/settings.h +++ b/src/include/pw3270/settings.h @@ -87,7 +87,7 @@ typedef struct _PW3270SettingsDialogClass PW3270SettingsDialogClass; GType PW3270SettingsDialog_get_type(void); - GtkWidget * pw3270_settings_dialog_new(GAction *action); + GtkWidget * pw3270_settings_dialog_new(GAction *action, gboolean has_subtitle); G_END_DECLS diff --git a/src/objects/actions/save.c b/src/objects/actions/save.c index e647394..3ae1515 100644 --- a/src/objects/actions/save.c +++ b/src/objects/actions/save.c @@ -49,7 +49,7 @@ action->name = "save.session.as"; action->label = _("Save As"); action->icon_name = "document-save-as"; - action->tooltip = _("Save session properties"); + action->tooltip = _("Save session preferences"); return G_ACTION(action); diff --git a/src/objects/application/actions/preferences.c b/src/objects/application/actions/preferences.c index 82cdaa2..5916347 100644 --- a/src/objects/application/actions/preferences.c +++ b/src/objects/application/actions/preferences.c @@ -38,7 +38,7 @@ size_t ix; GtkWindow * window = gtk_application_get_active_window(application); - GtkWidget * dialog = pw3270_settings_dialog_new(G_ACTION(action)); + GtkWidget * dialog = pw3270_settings_dialog_new(G_ACTION(action),TRUE); gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); gtk_window_set_attached_to(GTK_WINDOW(dialog), GTK_WIDGET(window)); @@ -75,6 +75,7 @@ action->name = "preferences"; action->label = _("Application preferences"); action->icon_name = "preferences-system"; + action->tooltip = _("Change the application preferences"); return G_ACTION(action); } diff --git a/src/objects/application/open.c b/src/objects/application/open.c index abc8451..74a2ed2 100644 --- a/src/objects/application/open.c +++ b/src/objects/application/open.c @@ -118,8 +118,6 @@ if(filename) { - g_message("Using \"%s\" for session properties",filename); - if(!window) { window = pw3270_application_window_new(GTK_APPLICATION(application), filename); } else { diff --git a/src/objects/settings/dialog.c b/src/objects/settings/dialog.c index af5eef0..2a65971 100644 --- a/src/objects/settings/dialog.c +++ b/src/objects/settings/dialog.c @@ -97,7 +97,7 @@ static void PW3270SettingsDialog_init(PW3270SettingsDialog *dialog) } -GtkWidget * pw3270_settings_dialog_new(GAction *action) { +GtkWidget * pw3270_settings_dialog_new(GAction *action, gboolean has_subtitle) { #ifdef _WIN32 @@ -110,7 +110,7 @@ GtkWidget * pw3270_settings_dialog_new(GAction *action) { #elif GTK_CHECK_VERSION(3,12,0) - gboolean use_header; + gboolean use_header = FALSE; g_object_get(gtk_settings_get_default(), "gtk-dialogs-use-header", &use_header, NULL); GtkWidget * dialog = @@ -126,6 +126,8 @@ GtkWidget * pw3270_settings_dialog_new(GAction *action) { #endif // GTK 3.12 + GTK_PW3270_SETTINGS_DIALOG(dialog)->has_subtitle = has_subtitle; + if(action) { if(PW3270_IS_ACTION(action)) { @@ -214,7 +216,7 @@ void switch_page(GtkNotebook *notebook, PW3270Settings *page, guint G_GNUC_UNUSE GtkWidget * header_bar = gtk_dialog_get_header_bar(GTK_DIALOG(dialog)); - if(header_bar) { + if(header_bar && dialog->has_subtitle) { gtk_header_bar_set_subtitle(GTK_HEADER_BAR(header_bar),page->title); } diff --git a/src/objects/toolbar/actions.c b/src/objects/toolbar/actions.c index 0552858..0f29f4f 100644 --- a/src/objects/toolbar/actions.c +++ b/src/objects/toolbar/actions.c @@ -65,24 +65,35 @@ if(!action) { const gchar *ptr = strchr(name,'.'); - if(ptr) { action = g_action_map_lookup_action(G_ACTION_MAP(window), ptr+1); } + } + if(!action) { + action = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()),name); + } + + if(!action) { + const gchar *ptr = strchr(name,'.'); + if(ptr) { + action = g_action_map_lookup_action(G_ACTION_MAP(g_application_get_default()), ptr+1); + } } debug("%s(%s)=%p",__FUNCTION__,name,action); - if(action) { - debug("Creating button \"%s\" from action \"%s\"",name,g_action_get_name(G_ACTION(action))); - item = gtk_tool_button_new_from_action( - action, - GTK_ICON_SIZE_LARGE_TOOLBAR, - pw3270_toolbar_get_icon_type(GTK_TOOLBAR(toolbar)) == 1 - ); + if(!action) { + g_warning("Can't find action \"%s\"",name); + return NULL; } + item = gtk_tool_button_new_from_action( + action, + GTK_ICON_SIZE_LARGE_TOOLBAR, + pw3270_toolbar_get_icon_type(GTK_TOOLBAR(toolbar)) == 1 + ); + if(item) { gtk_widget_show_all(GTK_WIDGET(item)); diff --git a/src/objects/toolbar/toolbar.c b/src/objects/toolbar/toolbar.c index 779bd68..73b9439 100644 --- a/src/objects/toolbar/toolbar.c +++ b/src/objects/toolbar/toolbar.c @@ -257,10 +257,10 @@ } - static void open_properties(GtkMenuItem G_GNUC_UNUSED(*menuitem), GtkWidget *toolbar) { + static void open_preferences(GtkMenuItem G_GNUC_UNUSED(*menuitem), GtkWidget *toolbar) { GtkWidget * window = gtk_widget_get_toplevel(toolbar); - GtkWidget * dialog = pw3270_settings_dialog_new(NULL); + GtkWidget * dialog = pw3270_settings_dialog_new(NULL,FALSE); gtk_container_add(GTK_CONTAINER(dialog),pw3270_toolbar_settings_new()); @@ -269,6 +269,8 @@ gtk_window_set_attached_to(GTK_WINDOW(dialog), window); gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(window)); + gtk_window_set_title(GTK_WINDOW(dialog),_("Setup toolbar")); + gtk_widget_show_all(dialog); } @@ -325,11 +327,11 @@ } - // Toolbar properties. + // Toolbar preferences. { - GtkWidget * item = gtk_menu_item_new_with_mnemonic( _("_Properties") ); + GtkWidget * item = gtk_menu_item_new_with_mnemonic( _("_Preferences") ); gtk_menu_shell_append(GTK_MENU_SHELL(widget->popup.menu),item); - g_signal_connect(item, "activate", G_CALLBACK(open_properties), widget); + g_signal_connect(item, "activate", G_CALLBACK(open_preferences), widget); } // gtk_container_set_border_width(GTK_CONTAINER(widget->popup_menu),6); diff --git a/src/objects/window/actions/sessionproperties.c b/src/objects/window/actions/sessionproperties.c index 9b90f4d..4ecc3a6 100644 --- a/src/objects/window/actions/sessionproperties.c +++ b/src/objects/window/actions/sessionproperties.c @@ -43,7 +43,8 @@ action->name = "session.properties"; action->icon_name = "preferences-other"; - action->label = _("Session properties"); + action->label = _("Session preferences"); + action->tooltip = _("Change the preferences for the active session"); return G_ACTION(action); } diff --git a/src/objects/window/keyfile.c b/src/objects/window/keyfile.c index 74998a0..3b1c0e0 100644 --- a/src/objects/window/keyfile.c +++ b/src/objects/window/keyfile.c @@ -97,7 +97,7 @@ if(!g_key_file_load_from_file(new_session->key_file,new_session->filename,G_KEY_FILE_NONE,error)) { g_warning("Can't load \"%s\"",new_session->filename); } else { - g_message("Loading session properties from %s",new_session->filename); + g_message("Loading session preferences from %s",new_session->filename); } } else { @@ -109,7 +109,7 @@ if(!g_key_file_load_from_file(new_session->key_file,default_settings,G_KEY_FILE_NONE,error)) { g_warning("Can't load \"%s\"",default_settings); } else { - g_message("Loading session properties from %s",default_settings); + g_message("Loading session preferences from %s",default_settings); } } else { #ifdef DEBUG diff --git a/ui/application.xml b/ui/application.xml index 3652cf2..8e52be2 100644 --- a/ui/application.xml +++ b/ui/application.xml @@ -160,7 +160,7 @@ - Session properties + Session preferences win.save.session.as diff --git a/ui/window.xml b/ui/window.xml index baa1f4e..7441b65 100644 --- a/ui/window.xml +++ b/ui/window.xml @@ -95,7 +95,7 @@ - Session properties + Session preferences win.save.session.as @@ -381,7 +381,7 @@ Dynamic font spacing win.dynamic-font-spacing - +
@@ -460,7 +460,7 @@
- + @@ -527,7 +527,7 @@ - + View @@ -551,7 +551,7 @@ - Session properties + Session preferences win.session.properties -- libgit2 0.21.2