From c3fc023aacb7f265a215c8bb5a3d5487512cbc1c Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Wed, 29 Jan 2025 17:43:34 +0000 Subject: [PATCH] Add a preference option for the selection of the toolbar style --- gramps/gen/config.py | 2 +- gramps/gui/configure.py | 25 +++++++++++++++++++++++++ gramps/gui/uimanager.py | 7 ++++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/gramps/gen/config.py b/gramps/gen/config.py index 7d045ce5bbc..18e71c70efd 100644 --- a/gramps/gen/config.py +++ b/gramps/gen/config.py @@ -265,7 +265,7 @@ def emit(key): register("interface.size-checked", False) register("interface.statusbar", 1) register("interface.toolbar-on", True) -register("interface.toolbar-text", False) +register("interface.toolbar-style", 0) register("interface.hide-lds", False) register("interface.toolbar-clipboard", True) register("interface.toolbar-addons", True) diff --git a/gramps/gui/configure.py b/gramps/gui/configure.py index af305120165..ff93a088bc7 100644 --- a/gramps/gui/configure.py +++ b/gramps/gui/configure.py @@ -1395,6 +1395,13 @@ def cb_toolbar_changed(self, obj): """ self.uistate.emit("toolbar-changed") + def cb_toolbar_style_changed(self, obj): + """ + Called when the toolbar style is changed. + """ + config.set("interface.toolbar-style", obj.get_active()) + self.uistate.uimanager.update_menu() + def add_data_panel(self, configdialog): """ Config tab with user Appearance and format settings. @@ -2110,6 +2117,24 @@ def add_general_panel(self, configdialog): extra_callback=self.cb_toolbar_changed, ) + row += 1 + # Toolbar styles: + obox = Gtk.ComboBoxText() + formats = [ + _("Use default preference"), + _("Text only"), + _("Icons only"), + _("Both text and icons"), + ] + list(map(obox.append_text, formats)) + active = config.get("interface.toolbar-style") + obox.set_active(active) + obox.set_tooltip_text(_("Display text, icons or both on the toolbar buttons.")) + obox.connect("changed", self.cb_toolbar_style_changed) + lwidget = BasicLabel(_("%s: ") % _("Toolbar Style")) + grid.attach(lwidget, 1, row, 1, 1) + grid.attach(obox, 2, row, 1, 1) + row += 1 # Gramplet bar close buttons: self.add_checkbox( diff --git a/gramps/gui/uimanager.py b/gramps/gui/uimanager.py index 5d73c394de2..18007f9c336 100644 --- a/gramps/gui/uimanager.py +++ b/gramps/gui/uimanager.py @@ -261,7 +261,12 @@ def iterator(parents): tb_show = toolbar.get_visible() toolbar_parent.remove(toolbar) toolbar = self.builder.get_object("ToolBar") # new toolbar - if config.get("interface.toolbar-text"): + toolbar_style = config.get("interface.toolbar-style") + if toolbar_style == 1: + toolbar.set_style(Gtk.ToolbarStyle.TEXT) + elif toolbar_style == 2: + toolbar.set_style(Gtk.ToolbarStyle.ICONS) + elif toolbar_style == 3: toolbar.set_style(Gtk.ToolbarStyle.BOTH) toolbar_parent.pack_start(toolbar, False, True, 0) if tb_show: