[Xfce4-commits] [apps/mousepad] 42/45: Improve toolbar preferences
noreply at xfce.org
noreply at xfce.org
Fri Jul 11 13:03:47 CEST 2014
This is an automated email from the git hooks/post-receive script.
mbrush pushed a commit to branch master
in repository apps/mousepad.
commit 3321a67c255d91120ec7ddd96bcb48f66c117a52
Author: Matthew Brush <mbrush at codebrainz.ca>
Date: Fri Jul 11 02:12:07 2014 -0700
Improve toolbar preferences
---
mousepad/mousepad-prefs-dialog.c | 146 ++++++++++++++++++++++++-
mousepad/mousepad-prefs-dialog.glade | 183 +++++++++++++++++++++++++++++++-
mousepad/mousepad-settings.h | 2 +
mousepad/mousepad-window.c | 44 ++++++--
mousepad/org.xfce.mousepad.gschema.xml | 31 ++++++
5 files changed, 397 insertions(+), 9 deletions(-)
diff --git a/mousepad/mousepad-prefs-dialog.c b/mousepad/mousepad-prefs-dialog.c
index 47b6fd2..8ea7a10 100644
--- a/mousepad/mousepad-prefs-dialog.c
+++ b/mousepad/mousepad-prefs-dialog.c
@@ -34,6 +34,11 @@
#define WID_REMEMBER_GEOMETRY_CHECK "/prefs/window/general/remember-window-size-check"
#define WID_ALWAYS_SHOW_TABS_CHECK "/prefs/window/notebook/always-show-tabs-check"
#define WID_CYCLE_TABS_CHECK "/prefs/window/notebook/cycle-tabs-check"
+#define WID_TOOLBAR_VISIBLE_CHECK "/prefs/window/toolbar/visible-check"
+#define WID_TOOLBAR_STYLE_COMBO "/prefs/window/toolbar/style-combo"
+#define WID_TOOLBAR_STYLE_LABEL "/prefs/window/toolbar/style-label"
+#define WID_TOOLBAR_ICON_SIZE_COMBO "/prefs/window/toolbar/icon-size-combo"
+#define WID_TOOLBAR_ICON_SIZE_LABEL "/prefs/window/toolbar/icon-size-label"
@@ -53,6 +58,8 @@ struct MousepadPrefsDialog_
gulong color_scheme_signal;
gulong tab_mode_signal;
gulong home_end_signal;
+ gulong toolbar_style_signal;
+ gulong toolbar_icon_size_signal;
};
struct MousepadPrefsDialogClass_
@@ -98,6 +105,10 @@ mousepad_prefs_dialog_finalize (GObject *object)
MOUSEPAD_SETTING_DISCONNECT (INSERT_SPACES, self->tab_mode_signal);
if (self->home_end_signal > 0)
MOUSEPAD_SETTING_DISCONNECT (SMART_HOME_END, self->home_end_signal);
+ if (self->toolbar_style_signal > 0)
+ MOUSEPAD_SETTING_DISCONNECT (TOOLBAR_STYLE, self->toolbar_style_signal);
+ if (self->toolbar_icon_size_signal > 0)
+ MOUSEPAD_SETTING_DISCONNECT (TOOLBAR_ICON_SIZE, self->toolbar_icon_size_signal);
/* destroy the GtkBuilder instance */
if (G_IS_OBJECT (self->builder))
@@ -289,6 +300,97 @@ mousepad_prefs_dialog_home_end_setting_changed (MousepadPrefsDialog *self,
+/* update toolbar style setting when combo changes */
+static void
+mousepad_prefs_dialog_toolbar_style_changed (MousepadPrefsDialog *self,
+ GtkComboBox *combo)
+{
+ self->blocked = TRUE;
+ MOUSEPAD_SETTING_SET_ENUM (TOOLBAR_STYLE, gtk_combo_box_get_active (combo));
+ self->blocked = FALSE;
+}
+
+
+
+/* update the combo when the setting changes */
+static void
+mousepad_prefs_dialog_toolbar_style_setting_changed (MousepadPrefsDialog *self,
+ gchar *key,
+ GSettings *settings)
+{
+ GtkComboBox *combo;
+
+ /* don't do anything when the combo box is itself updating the setting */
+ if (self->blocked)
+ return;
+
+ combo = GTK_COMBO_BOX (gtk_builder_get_object (self->builder, WID_TOOLBAR_STYLE_COMBO));
+
+ gtk_combo_box_set_active (combo, MOUSEPAD_SETTING_GET_ENUM (TOOLBAR_STYLE));
+}
+
+
+
+/* update toolbar icon size setting when combo changes */
+static void
+mousepad_prefs_dialog_toolbar_icon_size_changed (MousepadPrefsDialog *self,
+ GtkComboBox *combo)
+{
+ GtkTreeIter iter;
+
+ if (gtk_combo_box_get_active_iter (combo, &iter))
+ {
+ GtkTreeModel *model;
+ gint icon_size = 0;
+
+ model = gtk_combo_box_get_model (combo);
+
+ gtk_tree_model_get (model, &iter, 0, &icon_size, -1);
+
+ self->blocked = TRUE;
+ MOUSEPAD_SETTING_SET_ENUM (TOOLBAR_ICON_SIZE, icon_size);
+ self->blocked = FALSE;
+ }
+}
+
+
+
+/* update the combo when the setting changes */
+static void
+mousepad_prefs_dialog_toolbar_icon_size_setting_changed (MousepadPrefsDialog *self,
+ gchar *key,
+ GSettings *settings)
+{
+ GtkComboBox *combo;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gint icon_size;
+ gboolean valid;
+
+ /* don't do anything when the combo box is itself updating the setting */
+ if (self->blocked)
+ return;
+
+ icon_size = MOUSEPAD_SETTING_GET_ENUM (TOOLBAR_ICON_SIZE);
+ combo = GTK_COMBO_BOX (gtk_builder_get_object (self->builder, WID_TOOLBAR_ICON_SIZE_COMBO));
+ model = gtk_combo_box_get_model (combo);
+ valid = gtk_tree_model_get_iter_first (model, &iter);
+
+ while (valid)
+ {
+ gint size = 0;
+ gtk_tree_model_get (model, &iter, 0, &size, -1);
+ if (size == icon_size)
+ {
+ gtk_combo_box_set_active_iter (combo, &iter);
+ break;
+ }
+ valid = gtk_tree_model_iter_next (model, &iter);
+ }
+}
+
+
+
#define mousepad_builder_get_widget(builder, name) \
GTK_WIDGET (gtk_builder_get_object (builder, name))
@@ -338,13 +440,28 @@ mousepad_prefs_dialog_init (MousepadPrefsDialog *self)
widget = mousepad_builder_get_widget (self->builder, WID_FONT_BUTTON);
g_object_bind_property (check, "active", widget, "sensitive", G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
+ /* enable/disable toolbar-related widgets when checkbox changes */
+ check = mousepad_builder_get_widget (self->builder, WID_TOOLBAR_VISIBLE_CHECK);
+
+ widget = mousepad_builder_get_widget (self->builder, WID_TOOLBAR_STYLE_LABEL);
+ g_object_bind_property (check, "active", widget, "sensitive", G_BINDING_SYNC_CREATE);
+ widget = mousepad_builder_get_widget (self->builder, WID_TOOLBAR_STYLE_COMBO);
+ g_object_bind_property (check, "active", widget, "sensitive", G_BINDING_SYNC_CREATE);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), MOUSEPAD_SETTING_GET_ENUM (TOOLBAR_STYLE));
+
+ widget = mousepad_builder_get_widget (self->builder, WID_TOOLBAR_ICON_SIZE_LABEL);
+ g_object_bind_property (check, "active", widget, "sensitive", G_BINDING_SYNC_CREATE);
+ widget = mousepad_builder_get_widget (self->builder, WID_TOOLBAR_ICON_SIZE_COMBO);
+ g_object_bind_property (check, "active", widget, "sensitive", G_BINDING_SYNC_CREATE);
+ mousepad_prefs_dialog_toolbar_icon_size_setting_changed (self, NULL, NULL);
+
/* bind checkboxes to settings */
#define BIND_CHECKBOX(setting) \
MOUSEPAD_SETTING_BIND (setting, \
gtk_builder_get_object (self->builder, \
WID_##setting##_CHECK), \
"active", \
- G_BINDING_DEFAULT)
+ G_SETTINGS_BIND_DEFAULT)
/* View */
BIND_CHECKBOX (SHOW_LINE_NUMBERS);
@@ -365,6 +482,7 @@ mousepad_prefs_dialog_init (MousepadPrefsDialog *self)
BIND_CHECKBOX (REMEMBER_GEOMETRY);
BIND_CHECKBOX (ALWAYS_SHOW_TABS);
BIND_CHECKBOX (CYCLE_TABS);
+ BIND_CHECKBOX (TOOLBAR_VISIBLE);
#undef BIND_CHECKBOX
@@ -415,7 +533,31 @@ mousepad_prefs_dialog_init (MousepadPrefsDialog *self)
self,
G_CONNECT_SWAPPED);
- /* TODO: match-braces */
+ /* update toolbar style when changed */
+ g_signal_connect_swapped (gtk_builder_get_object (self->builder, WID_TOOLBAR_STYLE_COMBO),
+ "changed",
+ G_CALLBACK (mousepad_prefs_dialog_toolbar_style_changed),
+ self);
+
+ /* update toolbar style combo when the setting changes */
+ self->toolbar_style_signal =
+ MOUSEPAD_SETTING_CONNECT (TOOLBAR_STYLE,
+ G_CALLBACK (mousepad_prefs_dialog_toolbar_style_setting_changed),
+ self,
+ G_CONNECT_SWAPPED);
+
+ /* update toolbar icon size when changed */
+ g_signal_connect_swapped (gtk_builder_get_object (self->builder, WID_TOOLBAR_ICON_SIZE_COMBO),
+ "changed",
+ G_CALLBACK (mousepad_prefs_dialog_toolbar_icon_size_changed),
+ self);
+
+ /* update toolbar icon size combo when setting changes */
+ self->toolbar_icon_size_signal =
+ MOUSEPAD_SETTING_CONNECT (TOOLBAR_ICON_SIZE,
+ G_CALLBACK (mousepad_prefs_dialog_toolbar_icon_size_setting_changed),
+ self,
+ G_CONNECT_SWAPPED);
}
diff --git a/mousepad/mousepad-prefs-dialog.glade b/mousepad/mousepad-prefs-dialog.glade
index ff6dd8c..2f952ee 100644
--- a/mousepad/mousepad-prefs-dialog.glade
+++ b/mousepad/mousepad-prefs-dialog.glade
@@ -679,6 +679,127 @@
</packing>
</child>
<child>
+ <object class="GtkFrame" id="/prefs/window/toolbar/frame">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="/prefs/window/toolbar/alignment1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="top_padding">6</property>
+ <property name="bottom_padding">6</property>
+ <property name="left_padding">12</property>
+ <property name="right_padding">6</property>
+ <child>
+ <object class="GtkTable" id="/prefs/window/toolbar/table">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkCheckButton" id="/prefs/window/toolbar/visible-check">
+ <property name="label" translatable="yes">Show toolbar</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="/prefs/window/toolbar/style-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Style:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="/prefs/window/toolbar/icon-size-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Icon Size:</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="/prefs/window/toolbar/style-combo">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="model">/prefs/window/toolbar/style-model</property>
+ <property name="active">0</property>
+ <child>
+ <object class="GtkCellRendererText" id="/prefs/window/toolbar/style/cellrenderer"/>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="/prefs/window/toolbar/icon-size-combo">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="model">/prefs/window/toolbar/icon-size-model</property>
+ <property name="active">0</property>
+ <child>
+ <object class="GtkCellRendererText" id="/prefs/window/toolbar/icon-size/cellrenderer1"/>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="/prefs/window/toolbar/label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>Toolbar</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkFrame" id="/prefs/window/notebook/frame">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -742,7 +863,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
@@ -762,4 +883,64 @@
</packing>
</child>
</object>
+ <object class="GtkListStore" id="/prefs/window/toolbar/icon-size-model">
+ <columns>
+ <!-- column-name size -->
+ <column type="GtkIconSize"/>
+ <!-- column-name name -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0">menu</col>
+ <col id="1" translatable="yes">Menu</col>
+ </row>
+ <row>
+ <col id="0">small-toolbar</col>
+ <col id="1" translatable="yes">Small Toolbar</col>
+ </row>
+ <row>
+ <col id="0">large-toolbar</col>
+ <col id="1" translatable="yes">Large Toolbar</col>
+ </row>
+ <row>
+ <col id="0">button</col>
+ <col id="1" translatable="yes">Button</col>
+ </row>
+ <row>
+ <col id="0">dnd</col>
+ <col id="1" translatable="yes">Drag & Drop</col>
+ </row>
+ <row>
+ <col id="0">dialog</col>
+ <col id="1" translatable="yes">Dialog</col>
+ </row>
+ </data>
+ </object>
+ <object class="GtkListStore" id="/prefs/window/toolbar/style-model">
+ <columns>
+ <!-- column-name style -->
+ <column type="GtkToolbarStyle"/>
+ <!-- column-name name -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0">icons</col>
+ <col id="1" translatable="yes">Icons Only</col>
+ </row>
+ <row>
+ <col id="0">text</col>
+ <col id="1" translatable="yes">Text Only</col>
+ </row>
+ <row>
+ <col id="0">both</col>
+ <col id="1" translatable="yes">Text Below Icons</col>
+ </row>
+ <row>
+ <col id="0">both-horiz</col>
+ <col id="1" translatable="yes">Text Beside Icons</col>
+ </row>
+ </data>
+ </object>
</interface>
diff --git a/mousepad/mousepad-settings.h b/mousepad/mousepad-settings.h
index 3acf2c7..c919a66 100644
--- a/mousepad/mousepad-settings.h
+++ b/mousepad/mousepad-settings.h
@@ -26,6 +26,8 @@ G_BEGIN_DECLS
#define MOUSEPAD_SETTING_MATCH_BRACES "/preferences/view/match-braces"
#define MOUSEPAD_SETTING_COLOR_SCHEME "/preferences/view/color-scheme"
#define MOUSEPAD_SETTING_TOOLBAR_VISIBLE "/preferences/window/toolbar-visible"
+#define MOUSEPAD_SETTING_TOOLBAR_STYLE "/preferences/window/toolbar-style"
+#define MOUSEPAD_SETTING_TOOLBAR_ICON_SIZE "/preferences/window/toolbar-icon-size"
#define MOUSEPAD_SETTING_STATUSBAR_VISIBLE "/preferences/window/statusbar-visible"
#define MOUSEPAD_SETTING_ALWAYS_SHOW_TABS "/preferences/window/always-show-tabs"
#define MOUSEPAD_SETTING_CYCLE_TABS "/preferences/window/cycle-tabs"
diff --git a/mousepad/mousepad-window.c b/mousepad/mousepad-window.c
index 783f7dc..1acc390 100644
--- a/mousepad/mousepad-window.c
+++ b/mousepad/mousepad-window.c
@@ -393,6 +393,7 @@ struct _MousepadWindow
GtkWidget *search_bar;
GtkWidget *statusbar;
GtkWidget *replace_dialog;
+ GtkWidget *toolbar;
/* support to remember window geometry */
guint save_geometry_timer_id;
@@ -602,12 +603,31 @@ mousepad_window_update_recent_menu (MousepadWindow *window,
}
+
+static void
+mousepad_window_update_toolbar (MousepadWindow *window,
+ gchar *key,
+ GSettings *settings)
+{
+ gboolean visible;
+ GtkIconSize size;
+ GtkToolbarStyle style;
+
+ visible = MOUSEPAD_SETTING_GET_BOOLEAN (TOOLBAR_VISIBLE);
+ size = MOUSEPAD_SETTING_GET_ENUM (TOOLBAR_ICON_SIZE);
+ style = MOUSEPAD_SETTING_GET_ENUM (TOOLBAR_STYLE);
+
+ gtk_widget_set_visible (window->toolbar, visible);
+ gtk_toolbar_set_icon_size (GTK_TOOLBAR (window->toolbar), size);
+ gtk_toolbar_set_style (GTK_TOOLBAR (window->toolbar), style);
+}
+
+
static void
mousepad_window_init (MousepadWindow *window)
{
GtkAccelGroup *accel_group;
GtkWidget *menubar;
- GtkWidget *toolbar;
GtkWidget *label;
GtkWidget *separator;
GtkWidget *ebox;
@@ -691,17 +711,29 @@ mousepad_window_init (MousepadWindow *window)
menubar = gtk_ui_manager_get_widget (window->ui_manager, "/main-menu");
gtk_box_pack_start (GTK_BOX (window->box), menubar, FALSE, FALSE, 0);
gtk_widget_show (menubar);
-
- toolbar = gtk_ui_manager_get_widget (window->ui_manager, "/main-toolbar");
- gtk_box_pack_start (GTK_BOX (window->box), toolbar, FALSE, FALSE, 0);
+
+ window->toolbar = gtk_ui_manager_get_widget (window->ui_manager, "/main-toolbar");
+ gtk_box_pack_start (GTK_BOX (window->box), window->toolbar, FALSE, FALSE, 0);
/* sync the toolbar visibility and action state to the setting */
action = gtk_action_group_get_action (window->action_group, "toolbar");
active = MOUSEPAD_SETTING_GET_BOOLEAN (TOOLBAR_VISIBLE);
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), active);
- /* update the toolbar visibility with the setting */
- MOUSEPAD_SETTING_BIND (TOOLBAR_VISIBLE, toolbar, "visible", G_SETTINGS_BIND_DEFAULT);
+ /* update the toolbar with the settings */
+ mousepad_window_update_toolbar (window, NULL, NULL);
+ MOUSEPAD_SETTING_CONNECT (TOOLBAR_VISIBLE,
+ G_CALLBACK (mousepad_window_update_toolbar),
+ window,
+ G_CONNECT_SWAPPED);
+ MOUSEPAD_SETTING_CONNECT (TOOLBAR_STYLE,
+ G_CALLBACK (mousepad_window_update_toolbar),
+ window,
+ G_CONNECT_SWAPPED);
+ MOUSEPAD_SETTING_CONNECT (TOOLBAR_ICON_SIZE,
+ G_CALLBACK (mousepad_window_update_toolbar),
+ window,
+ G_CONNECT_SWAPPED);
/* update the window fullscreen state when setting changes */
action = gtk_action_group_get_action (window->action_group, "fullscreen");
diff --git a/mousepad/org.xfce.mousepad.gschema.xml b/mousepad/org.xfce.mousepad.gschema.xml
index cf8685b..2275b40 100644
--- a/mousepad/org.xfce.mousepad.gschema.xml
+++ b/mousepad/org.xfce.mousepad.gschema.xml
@@ -9,6 +9,22 @@
<value nick="always" value="3"/>
</enum>
+ <enum id="org.xfce.mousepad.ToolbarStyle">
+ <value nick="icons" value="0"/>
+ <value nick="text" value="1"/>
+ <value nick="both" value="2"/>
+ <value nick="both-horiz" value="3"/>
+ </enum>
+
+ <enum id="org.xfce.mousepad.IconSize">
+ <value nick="menu" value="1"/>
+ <value nick="small-toolbar" value="2"/>
+ <value nick="large-toolbar" value="3"/>
+ <value nick="button" value="4"/>
+ <value nick="dnd" value="5"/>
+ <value nick="dialog" value="6"/>
+ </enum>
+
<schema id="org.xfce.mousepad" path="/org/xfce/mousepad/" gettext-domain="mousepad">
<child name="preferences" schema="org.xfce.mousepad.preferences"/>
<child name="state" schema="org.xfce.mousepad.state"/>
@@ -176,6 +192,21 @@
When true the toolbar is visible, when false it is not visible.
</description>
</key>
+ <key name="toolbar-style" enum="org.xfce.mousepad.ToolbarStyle">
+ <default>'icons'</default>
+ <summary>Toolbar style</summary>
+ <description>
+ Controls how the toolbar items will be drawn with respect to text
+ labels and icons (if visible).
+ </description>
+ </key>
+ <key name="toolbar-icon-size" enum="org.xfce.mousepad.IconSize">
+ <default>'small-toolbar'</default>
+ <summary>Toolbar icon size</summary>
+ <description>
+ Controls the size of the toolbar icons (if visible).
+ </description>
+ </key>
<key name="statusbar-visible" type="b">
<default>false</default>
<summary>Statusbar visible</summary>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list