From 3b0931310730a4ae5d028a1e2120d2a619ae975a Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Sun, 15 Jul 2018 16:36:56 +0100 Subject: [PATCH] Add preference to control toolbar appearance Add preferences to select icon size and item layout on the toolbar. Fixes Bug 796739 - Toolbar buttons have no labels, part 1 of 3. --- gnucash/gnome-utils/dialog-preferences.c | 2 + gnucash/gnome-utils/gnc-main-window.c | 36 +++++ gnucash/gschemas/org.gnucash.gschema.xml.in | 12 +- gnucash/gtkbuilder/dialog-preferences.glade | 144 +++++++++++++++++++- libgnucash/core-utils/gnc-prefs.h | 2 + 5 files changed, 194 insertions(+), 2 deletions(-) diff --git a/gnucash/gnome-utils/dialog-preferences.c b/gnucash/gnome-utils/dialog-preferences.c index 815587e407..f17b2d9b18 100644 --- a/gnucash/gnome-utils/dialog-preferences.c +++ b/gnucash/gnome-utils/dialog-preferences.c @@ -1229,6 +1229,8 @@ gnc_preferences_dialog_create(GtkWindow *parent) gnc_builder_add_from_file (builder, "dialog-preferences.glade", "retain_days_adj"); gnc_builder_add_from_file (builder, "dialog-preferences.glade", "tab_width_adj"); gnc_builder_add_from_file (builder, "dialog-preferences.glade", "date_formats"); + gnc_builder_add_from_file (builder, "dialog-preferences.glade", "toolbar-styles"); + gnc_builder_add_from_file (builder, "dialog-preferences.glade", "toolbar-icon-sizes"); gnc_builder_add_from_file (builder, "dialog-preferences.glade", "gnucash_preferences_dialog"); dialog = GTK_WIDGET(gtk_builder_get_object (builder, "gnucash_preferences_dialog")); diff --git a/gnucash/gnome-utils/gnc-main-window.c b/gnucash/gnome-utils/gnc-main-window.c index 51a0f4944f..f5b2b58c72 100644 --- a/gnucash/gnome-utils/gnc-main-window.c +++ b/gnucash/gnome-utils/gnc-main-window.c @@ -3341,6 +3341,28 @@ gnc_main_window_update_tab_position (gpointer prefs, gchar *pref, gpointer user_ LEAVE (""); } +static void +gnc_main_window_update_toolbar (gpointer prefs, gchar *pref, gpointer user_data) +{ + GncMainWindow *window; + GtkToolbar *tb; + GncMainWindowPrivate *priv; + gint selection; + + window = GNC_MAIN_WINDOW(user_data); + priv = GNC_MAIN_WINDOW_GET_PRIVATE (window); + tb = GTK_TOOLBAR(priv->toolbar); + + selection = gnc_prefs_get_int (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TOOLBAR_STYLE); + if (gtk_toolbar_get_style (tb) != selection) + gtk_toolbar_set_style (tb, selection); + + selection = gnc_prefs_get_int (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TOOLBAR_ICON_SIZE); + // prefs has only small and large icons so add 2 to get right enum + if (gtk_toolbar_get_icon_size (tb) != selection + 2) + gtk_toolbar_set_icon_size (tb, selection + 2); +} + /* * Based on code from Epiphany (src/ephy-window.c) */ @@ -3707,6 +3729,13 @@ gnc_main_window_setup_window (GncMainWindow *window) GNC_PREF_TAB_POSITION_RIGHT, gnc_main_window_update_tab_position, window); + + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TOOLBAR_STYLE, + gnc_main_window_update_toolbar, window); + + gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TOOLBAR_ICON_SIZE, + gnc_main_window_update_toolbar, window); + gnc_main_window_update_tab_position(NULL, NULL, window); gnc_main_window_init_menu_updaters(window); @@ -3839,6 +3868,13 @@ gnc_main_window_add_widget (GtkUIManager *merge, if (GTK_IS_TOOLBAR (widget)) { priv->toolbar = widget; + + gtk_toolbar_set_style (GTK_TOOLBAR(priv->toolbar), + gnc_prefs_get_int (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TOOLBAR_STYLE)); + + // prefs has only small and large icons so add 2 to get right enum + gtk_toolbar_set_icon_size (GTK_TOOLBAR(priv->toolbar), + (gnc_prefs_get_int (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TOOLBAR_ICON_SIZE)) + 2); } gtk_box_pack_start (GTK_BOX (priv->menu_dock), widget, FALSE, FALSE, 0); diff --git a/gnucash/gschemas/org.gnucash.gschema.xml.in b/gnucash/gschemas/org.gnucash.gschema.xml.in index f2b21ac5cc..44d312632a 100644 --- a/gnucash/gschemas/org.gnucash.gschema.xml.in +++ b/gnucash/gschemas/org.gnucash.gschema.xml.in @@ -205,6 +205,16 @@ Display the notebook tabs at the right of the window. This setting determines the edge at which the tabs for switching pages in notebooks are drawn. Possible values are "top", "left", "bottom" and "right". It defaults to "top". + + 3 + Toolbar Style choice + This setting controls how the toolbar icons are displayed. + + + 1 + Toolbar Icon Size + This setting controls the size of the toolbar icons. + false Display the summary bar at the top of the page. @@ -336,7 +346,7 @@ This sets the number of characters before auto complete starts for description, notes and memo fields. - + false diff --git a/gnucash/gtkbuilder/dialog-preferences.glade b/gnucash/gtkbuilder/dialog-preferences.glade index 092f822635..3a6631d1f9 100644 --- a/gnucash/gtkbuilder/dialog-preferences.glade +++ b/gnucash/gtkbuilder/dialog-preferences.glade @@ -1,5 +1,5 @@ - + @@ -97,6 +97,40 @@ 1 10 + + + + + + + + Small Icons + + + Large Icons + + + + + + + + + + + Icons + + + Text + + + Icons and Text + + + Icons and Important Text + + + False GnuCash Preferences @@ -3221,6 +3255,114 @@ many months before the current month: 6 + + + True + False + True + Specify the icon size for the toolbars. + Specify the icon size for the toolbars. + start + 12 + toolbar-icon-sizes + 1 + 0 + + + + 0 + + + + + 0 + 15 + 2 + + + + + True + False + True + Change the way the toolbar items are displayed. + Change the way the toolbar items are displayed. + start + 12 + toolbar-styles + 3 + 0 + + + + 0 + + + + + 0 + 18 + 2 + + + + + True + False + start + <b>Toolbar Icon Size</b> + True + + + 0 + 14 + + + + + True + False + start + <b>Toolbar Style</b> + True + + + 0 + 17 + + + + + True + False + + + 0 + 13 + + + + + True + False + + + 0 + 16 + + + + + + + + + + + + + + diff --git a/libgnucash/core-utils/gnc-prefs.h b/libgnucash/core-utils/gnc-prefs.h index 41c241d461..4c9137c9c1 100644 --- a/libgnucash/core-utils/gnc-prefs.h +++ b/libgnucash/core-utils/gnc-prefs.h @@ -71,6 +71,8 @@ #define GNC_PREF_DATE_BACKMONTHS "date-backmonths" #define GNC_PREF_SHOW_LEAF_ACCT_NAMES "show-leaf-account-names" #define GNC_PREF_ENTER_MOVES_TO_END "enter-moves-to-end" +#define GNC_PREF_TOOLBAR_STYLE "toolbar-style" +#define GNC_PREF_TOOLBAR_ICON_SIZE "toolbar-icon-size" /* Register preferences */ #define GNC_PREF_DRAW_HOR_LINES "draw-horizontal-lines" #define GNC_PREF_DRAW_VERT_LINES "draw-vertical-lines"