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.
This commit is contained in:
Robert Fewell 2018-07-15 16:36:56 +01:00 committed by John Ralls
parent 3e37b87997
commit 3b09313107
5 changed files with 194 additions and 2 deletions

View File

@ -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"));

View File

@ -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);

View File

@ -205,6 +205,16 @@
<summary>Display the notebook tabs at the right of the window.</summary>
<description>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".</description>
</key>
<key name="toolbar-style" type="i">
<default>3</default>
<summary>Toolbar Style choice</summary>
<description>This setting controls how the toolbar icons are displayed.</description>
</key>
<key name="toolbar-icon-size" type="i">
<default>1</default>
<summary>Toolbar Icon Size</summary>
<description>This setting controls the size of the toolbar icons.</description>
</key>
<key name="summarybar-position-top" type="b">
<default>false</default>
<summary>Display the summary bar at the top of the page.</summary>
@ -336,7 +346,7 @@
<description>This sets the number of characters before auto complete starts for description, notes and memo fields.</description>
</key>
</schema>
<schema id="org.gnucash.general.report" path="/org/gnucash/general/report/">
<key name="use-new-window" type="b">
<default>false</default>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.2 -->
<!-- Generated with glade 3.20.4 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkAdjustment" id="auto_decimal_places_adj">
@ -97,6 +97,40 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkListStore" id="toolbar-icon-sizes">
<columns>
<!-- column-name sizes-text -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Small Icons</col>
</row>
<row>
<col id="0" translatable="yes">Large Icons</col>
</row>
</data>
</object>
<object class="GtkListStore" id="toolbar-styles">
<columns>
<!-- column-name styles-text -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Icons</col>
</row>
<row>
<col id="0" translatable="yes">Text</col>
</row>
<row>
<col id="0" translatable="yes">Icons and Text</col>
</row>
<row>
<col id="0" translatable="yes">Icons and Important Text</col>
</row>
</data>
</object>
<object class="GtkDialog" id="gnucash_preferences_dialog">
<property name="can_focus">False</property>
<property name="title" translatable="yes">GnuCash Preferences</property>
@ -3221,6 +3255,114 @@ many months before the current month:</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="pref/general/toolbar-icon-size">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup">Specify the icon size for the toolbars.</property>
<property name="tooltip_text" translatable="yes">Specify the icon size for the toolbars.</property>
<property name="halign">start</property>
<property name="margin_left">12</property>
<property name="model">toolbar-icon-sizes</property>
<property name="active">1</property>
<property name="id_column">0</property>
<child>
<object class="GtkCellRendererText" id="toolbar-icon-renderer"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">15</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="pref/general/toolbar-style">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup">Change the way the toolbar items are displayed.</property>
<property name="tooltip_text" translatable="yes">Change the way the toolbar items are displayed.</property>
<property name="halign">start</property>
<property name="margin_left">12</property>
<property name="model">toolbar-styles</property>
<property name="active">3</property>
<property name="id_column">0</property>
<child>
<object class="GtkCellRendererText" id="toolbar-style-renderer"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">18</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label22">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">&lt;b&gt;Toolbar Icon Size&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">14</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label23">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">&lt;b&gt;Toolbar Style&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">17</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label24">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">13</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label25">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">16</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>

View File

@ -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"