From e8b181622cb271610d5d270b0459aed687002bda Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Wed, 24 Jan 2024 14:56:10 +0000 Subject: [PATCH] Option to select menu style User option to select a "hamburger" style menu icon or the classic text style. The option is in Edit/Preferences/General. --- doc/docbook/GuideOptionsGeneral.xml | 11 +- src/layout-util.cc | 58 ++++-- src/layout.cc | 36 +++- src/options.cc | 1 + src/options.h | 1 + src/preferences.cc | 13 +- src/rcfile.cc | 2 + src/ui/menu-classic.ui | 280 ++++++++++++++++++++++++++ src/ui/{menu.ui => menu-hamburger.ui} | 0 src/ui/ui.gresource.xml | 3 +- 10 files changed, 375 insertions(+), 30 deletions(-) create mode 100644 src/ui/menu-classic.ui rename src/ui/{menu.ui => menu-hamburger.ui} (100%) diff --git a/doc/docbook/GuideOptionsGeneral.xml b/doc/docbook/GuideOptionsGeneral.xml index d401cc7e..1fcc82f7 100644 --- a/doc/docbook/GuideOptionsGeneral.xml +++ b/doc/docbook/GuideOptionsGeneral.xml @@ -239,9 +239,16 @@ +
- Expand toolbar - Expand the toolbar to the full width of the window. + Expand menu/toolbar + Expand the menu/toolbar to the full width of the window. Geeqie must be restarted for changes to take effect. diff --git a/src/layout-util.cc b/src/layout-util.cc index 38a9a036..6b018fe4 100644 --- a/src/layout-util.cc +++ b/src/layout-util.cc @@ -2036,7 +2036,7 @@ static void layout_menu_collection_recent_update(LayoutWindow *lw) menu_item_add(menu, _("Empty"), nullptr, nullptr); } - recent = gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu/OpenMenu/FileMenu/OpenRecent"); + recent = gtk_ui_manager_get_widget(lw->ui_manager, options->hamburger_menu ? "/MainMenu/OpenMenu/FileMenu/OpenRecent" : "/MainMenu/FileMenu/OpenRecent"); gtk_menu_item_set_submenu(GTK_MENU_ITEM(recent), menu); gtk_widget_set_sensitive(recent, (n != 0)); } @@ -2092,7 +2092,7 @@ static void layout_menu_collection_open_update(LayoutWindow *lw) menu_item_add(menu, _("Empty"), nullptr, nullptr); } - recent = gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu/OpenMenu/FileMenu/OpenCollection"); + recent = gtk_ui_manager_get_widget(lw->ui_manager, options->hamburger_menu ? "/MainMenu/OpenMenu/FileMenu/OpenCollection" : "/MainMenu/FileMenu/OpenCollection"); gtk_menu_item_set_submenu(GTK_MENU_ITEM(recent), menu); gtk_widget_set_sensitive(recent, (n != 0)); } @@ -2251,7 +2251,7 @@ static void layout_menu_new_window_update(LayoutWindow *lw) list = layout_window_menu_list(list); - menu = gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu/OpenMenu/WindowsMenu/NewWindow"); + menu = gtk_ui_manager_get_widget(lw->ui_manager, options->hamburger_menu ? "/MainMenu/OpenMenu/WindowsMenu/NewWindow" : "/MainMenu/WindowsMenu/NewWindow"); sub_menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menu)); children = gtk_container_get_children(GTK_CONTAINER(sub_menu)); @@ -2396,7 +2396,8 @@ static void layout_menu_windows_menu_cb(GtkWidget *, gpointer data) GList *children, *iter; gint i; - menu = gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu/OpenMenu/WindowsMenu/"); + menu = gtk_ui_manager_get_widget(lw->ui_manager, options->hamburger_menu ? "/MainMenu/OpenMenu/WindowsMenu/" : "/MainMenu/WindowsMenu/"); + sub_menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menu)); /* disable Delete for temporary windows */ @@ -2427,7 +2428,7 @@ static void layout_menu_view_menu_cb(GtkWidget *, gpointer data) gint i; FileData *fd; - menu = gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu/OpenMenu/ViewMenu/"); + menu = gtk_ui_manager_get_widget(lw->ui_manager, options->hamburger_menu ? "/MainMenu/OpenMenu/ViewMenu/" : "/MainMenu/ViewMenu/"); sub_menu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menu)); fd = layout_image_get_fd(lw); @@ -2881,9 +2882,13 @@ static void layout_actions_setup_marks(LayoutWindow *lw) GError *error; GString *desc = g_string_new( "" - " " - " " - " "); + " "); + + if (options->hamburger_menu) + { + g_string_append(desc, " "); + } + g_string_append(desc, " "); for (mark = 1; mark <= FILEDATA_MARKS_SIZE; mark++) { @@ -2918,9 +2923,13 @@ static void layout_actions_setup_marks(LayoutWindow *lw) } g_string_append(desc, - " " - " " - " "); + " "); + if (options->hamburger_menu) + { + g_string_append(desc, " "); + } + g_string_append(desc, " "); + for (mark = 1; mark <= FILEDATA_MARKS_SIZE; mark++) { gint i = (mark < 10 ? mark : 0); @@ -3048,8 +3057,12 @@ static void layout_actions_setup_editors(LayoutWindow *lw) /* lw->action_group_editors contains translated entries, no translate func is required */ desc = g_string_new( "" - " " - " "); + " "); + + if (options->hamburger_menu) + { + g_string_append(desc, " "); + } editors_list = editor_list_get(); @@ -3083,8 +3096,12 @@ static void layout_actions_setup_editors(LayoutWindow *lw) layout_actions_editor_add(desc, nullptr, old_path); g_list_free_full(old_path, g_free); - g_string_append(desc, "" - " " + if (options->hamburger_menu) + { + g_string_append(desc, ""); + } + + g_string_append(desc," " "" ); error = nullptr; @@ -3144,7 +3161,8 @@ void layout_actions_setup(LayoutWindow *lw) DEBUG_1("%s layout_actions_setup: add menu", get_exec_time()); error = nullptr; - if (!gtk_ui_manager_add_ui_from_resource(lw->ui_manager, GQ_RESOURCE_PATH_UI "/menu.ui", &error)) + + if (!gtk_ui_manager_add_ui_from_resource(lw->ui_manager, options->hamburger_menu ? GQ_RESOURCE_PATH_UI "/menu-hamburger.ui" : GQ_RESOURCE_PATH_UI "/menu-classic.ui" , &error)) { g_message("building menus failed: %s", error->message); g_error_free(error); @@ -3273,6 +3291,7 @@ GtkWidget *layout_actions_toolbar(LayoutWindow *lw, ToolbarType type) GtkWidget *layout_actions_menu_tool_bar(LayoutWindow *lw) { + GtkWidget *menu_bar; GtkWidget *toolbar; if (lw->menu_tool_bar) return lw->menu_tool_bar; @@ -3281,6 +3300,13 @@ GtkWidget *layout_actions_menu_tool_bar(LayoutWindow *lw) DEBUG_NAME(toolbar); lw->menu_tool_bar = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + if (!options->hamburger_menu) + { + menu_bar = layout_actions_menu_bar(lw); + DEBUG_NAME(menu_bar); + gq_gtk_box_pack_start(GTK_BOX(lw->menu_tool_bar), menu_bar, FALSE, FALSE, 0); + } + gq_gtk_box_pack_start(GTK_BOX(lw->menu_tool_bar), toolbar, FALSE, FALSE, 0); g_object_ref(lw->menu_tool_bar); diff --git a/src/layout.cc b/src/layout.cc index 2245f94e..8108aabf 100644 --- a/src/layout.cc +++ b/src/layout.cc @@ -324,6 +324,7 @@ static GtkWidget *layout_tool_setup(LayoutWindow *lw) GtkWidget *box; GtkWidget *box_folders; GtkWidget *box_menu_tabcomp; + GtkWidget *menu_bar; GtkWidget *menu_tool_bar; GtkWidget *open_menu; GtkWidget *scd; @@ -334,6 +335,15 @@ static GtkWidget *layout_tool_setup(LayoutWindow *lw) if (!options->expand_menu_toolbar) { + if (!options->hamburger_menu) + { + menu_bar = layout_actions_menu_bar(lw); + + gtk_widget_show(menu_bar); + + gq_gtk_box_pack_start(GTK_BOX(box), menu_bar, FALSE, FALSE, 0); + } + toolbar = layout_actions_toolbar(lw, TOOLBAR_MAIN); gq_gtk_box_pack_start(GTK_BOX(box), toolbar, FALSE, FALSE, 0); } @@ -345,19 +355,27 @@ static GtkWidget *layout_tool_setup(LayoutWindow *lw) gq_gtk_box_pack_start(GTK_BOX(lw->main_box), lw->menu_tool_bar, FALSE, FALSE, 0); } - box_menu_tabcomp = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); - gtk_widget_show(box_menu_tabcomp); - - open_menu = layout_actions_menu_bar(lw); - gtk_widget_set_tooltip_text(open_menu, "Open application menu"); - tabcomp = tab_completion_new_with_history(&lw->path_entry, nullptr, "path_list", -1, layout_path_entry_cb, lw); DEBUG_NAME(tabcomp); tab_completion_add_tab_func(lw->path_entry, layout_path_entry_tab_cb, lw); tab_completion_add_append_func(lw->path_entry, layout_path_entry_tab_append_cb, lw); - gq_gtk_box_pack_start(GTK_BOX(box_menu_tabcomp), open_menu, FALSE, FALSE, 0); - gq_gtk_box_pack_start(GTK_BOX(box_menu_tabcomp), tabcomp, TRUE, TRUE, 0); - gq_gtk_box_pack_start(GTK_BOX(box), box_menu_tabcomp, FALSE, FALSE, 0); + + if (options->hamburger_menu) + { + box_menu_tabcomp = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_widget_show(box_menu_tabcomp); + + open_menu = layout_actions_menu_bar(lw); + gtk_widget_set_tooltip_text(open_menu, "Open application menu"); + gq_gtk_box_pack_start(GTK_BOX(box_menu_tabcomp), open_menu, FALSE, FALSE, 0); + gq_gtk_box_pack_start(GTK_BOX(box_menu_tabcomp), tabcomp, TRUE, TRUE, 0); + gq_gtk_box_pack_start(GTK_BOX(box), box_menu_tabcomp, FALSE, FALSE, 0); + } + else + { + gq_gtk_box_pack_start(GTK_BOX(box), tabcomp, FALSE, FALSE, 0); + } + gtk_widget_show(tabcomp); gtk_widget_set_has_tooltip(GTK_WIDGET(tabcomp), TRUE); g_signal_connect(G_OBJECT(tabcomp), "query_tooltip", G_CALLBACK(path_entry_tooltip_cb), lw); diff --git a/src/options.cc b/src/options.cc index e16a553b..eea71b0a 100644 --- a/src/options.cc +++ b/src/options.cc @@ -170,6 +170,7 @@ ConfOptions *init_options(ConfOptions *options) options->show_star_rating = FALSE; options->show_predefined_keyword_tree = TRUE; options->expand_menu_toolbar = FALSE; + options->hamburger_menu = FALSE; options->slideshow.delay = 50; options->slideshow.random = FALSE; diff --git a/src/options.h b/src/options.h index b38feac1..2b333207 100644 --- a/src/options.h +++ b/src/options.h @@ -55,6 +55,7 @@ struct ConfOptions gboolean show_predefined_keyword_tree; gboolean overunderexposed; gboolean expand_menu_toolbar; + gboolean hamburger_menu; /* various */ gboolean tree_descend_subdirs; diff --git a/src/preferences.cc b/src/preferences.cc index 0ef13c94..8dd98fef 100644 --- a/src/preferences.cc +++ b/src/preferences.cc @@ -444,6 +444,7 @@ static void config_window_apply() options->show_predefined_keyword_tree = c_options->show_predefined_keyword_tree; options->expand_menu_toolbar = c_options->expand_menu_toolbar; + options->hamburger_menu = c_options->hamburger_menu; options->selectable_bars.menu_bar = c_options->selectable_bars.menu_bar; options->selectable_bars.tool_bar = c_options->selectable_bars.tool_bar; @@ -2141,13 +2142,21 @@ static void config_tab_general(GtkWidget *notebook) options->update_on_time_change, &c_options->update_on_time_change); + pref_spacer(group, PREF_PAD_GROUP); + + group = pref_group_new(vbox, FALSE, _("Menu style"), GTK_ORIENTATION_VERTICAL); + + pref_checkbox_new_int(group, _("☰ style menu button (NOTE! Geeqie must be restarted for change to take effect)"), + options->hamburger_menu, &c_options->hamburger_menu); + gtk_widget_set_tooltip_text(group, _("Use a ☰ style menu button instead of the classic style across the top of the frame")); + pref_spacer(group, PREF_PAD_GROUP); group = pref_group_new(vbox, FALSE, _("Expand toolbar"), GTK_ORIENTATION_VERTICAL); - pref_checkbox_new_int(group, _("Expand toolbar (NOTE! Geeqie must be restarted for change to take effect)"), + pref_checkbox_new_int(group, _("Expand menu/toolbar (NOTE! Geeqie must be restarted for change to take effect)"), options->expand_menu_toolbar, &c_options->expand_menu_toolbar); - gtk_widget_set_tooltip_text(group, _("Expand the toolbar to the full width of the window")); + gtk_widget_set_tooltip_text(group, _("Expand the menu/toolbar to the full width of the window")); pref_spacer(group, PREF_PAD_GROUP); diff --git a/src/rcfile.cc b/src/rcfile.cc index 2073a0eb..05efe868 100644 --- a/src/rcfile.cc +++ b/src/rcfile.cc @@ -367,6 +367,7 @@ static void write_global_attributes(GString *outstr, gint indent) WRITE_NL(); WRITE_BOOL(*options, save_dialog_window_positions); WRITE_NL(); WRITE_BOOL(*options, show_window_ids); WRITE_NL(); WRITE_BOOL(*options, expand_menu_toolbar); + WRITE_NL(); WRITE_BOOL(*options, hamburger_menu); WRITE_NL(); WRITE_UINT(*options, log_window_lines); WRITE_NL(); WRITE_BOOL(*options, log_window.timer_data); @@ -872,6 +873,7 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar ** if (READ_BOOL(*options, save_dialog_window_positions)) continue; if (READ_BOOL(*options, show_window_ids)) continue; if (READ_BOOL(*options, expand_menu_toolbar)) continue; + if (READ_BOOL(*options, hamburger_menu)) continue; if (READ_INT(*options, log_window_lines)) continue; if (READ_BOOL(*options, log_window.timer_data)) continue; diff --git a/src/ui/menu-classic.ui b/src/ui/menu-classic.ui new file mode 100644 index 00000000..286183db --- /dev/null +++ b/src/ui/menu-classic.ui @@ -0,0 +1,280 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ui/menu.ui b/src/ui/menu-hamburger.ui similarity index 100% rename from src/ui/menu.ui rename to src/ui/menu-hamburger.ui diff --git a/src/ui/ui.gresource.xml b/src/ui/ui.gresource.xml index 6736ad68..f688180c 100644 --- a/src/ui/ui.gresource.xml +++ b/src/ui/ui.gresource.xml @@ -25,7 +25,8 @@ appimage-notification.ui custom.css - menu.ui + menu-classic.ui + menu-hamburger.ui search-and-run.ui -- 2.20.1