[Xfce4-commits] [apps/mousepad] 04/06: Hookup the style scheme actions to the setting
noreply at xfce.org
noreply at xfce.org
Mon Jul 14 13:35:48 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 5adffadb5c1bc4028b9cd70eca85d039ede0cde3
Author: Matthew Brush <mbrush at codebrainz.ca>
Date: Mon Jul 14 04:13:41 2014 -0700
Hookup the style scheme actions to the setting
---
mousepad/mousepad-action-group.c | 49 +++++++++++++++++++++++++++++++++++++-
1 file changed, 48 insertions(+), 1 deletion(-)
diff --git a/mousepad/mousepad-action-group.c b/mousepad/mousepad-action-group.c
index e90c6c8..d34fb9c 100644
--- a/mousepad/mousepad-action-group.c
+++ b/mousepad/mousepad-action-group.c
@@ -5,6 +5,7 @@
#include <mousepad/mousepad-action-group.h>
#include <mousepad/mousepad-language-action.h>
#include <mousepad/mousepad-style-scheme-action.h>
+#include <mousepad/mousepad-settings.h>
#include <glib/gi18n.h>
#include <gtksourceview/gtksourcelanguagemanager.h>
#include <gtksourceview/gtksourcestyleschememanager.h>
@@ -65,6 +66,9 @@ static gint mousepad_action_group_style_schemes_name_compare (gconst
gconstpointer b);
static GSList *mousepad_action_group_get_style_schemes (void);
static GSList *mousepad_action_group_style_schemes_get_sorted (void);
+static void mousepad_action_group_color_scheme_setting_changed (MousepadActionGroup *self,
+ gchar *key,
+ GSettings *settings);
@@ -175,13 +179,28 @@ mousepad_action_group_get_property (GObject *object,
static void
mousepad_action_group_init (MousepadActionGroup *self)
{
+ gchar *scheme_id;
+ GtkSourceStyleScheme *scheme;
+
self->active_language = NULL;
mousepad_action_group_add_language_actions (self);
mousepad_action_group_set_active_language (self, NULL);
self->active_scheme = NULL;
mousepad_action_group_add_style_scheme_actions (self);
- mousepad_action_group_set_active_style_scheme (self, NULL);
+
+ /* set the initial style scheme from the setting */
+ scheme_id = MOUSEPAD_SETTING_GET_STRING (COLOR_SCHEME);
+ scheme = gtk_source_style_scheme_manager_get_scheme (
+ gtk_source_style_scheme_manager_get_default (), scheme_id);
+ g_free (scheme_id);
+ mousepad_action_group_set_active_style_scheme (self, scheme);
+
+ /* update the colour scheme when the setting changes */
+ MOUSEPAD_SETTING_CONNECT_OBJECT (COLOR_SCHEME,
+ G_CALLBACK (mousepad_action_group_color_scheme_setting_changed),
+ self,
+ G_CONNECT_SWAPPED);
}
@@ -261,6 +280,11 @@ mousepad_action_group_set_active_style_scheme (MousepadActionGroup *self,
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
self->locked = FALSE;
+ /* update the setting when the active action is changed */
+ self->locked = TRUE;
+ MOUSEPAD_SETTING_SET_STRING (COLOR_SCHEME, gtk_source_style_scheme_get_id (scheme));
+ self->locked = FALSE;
+
g_object_notify (G_OBJECT (self), "active-style-scheme");
}
@@ -438,6 +462,29 @@ mousepad_action_group_style_scheme_action_activate (MousepadActionGroup *s
+static void
+mousepad_action_group_color_scheme_setting_changed (MousepadActionGroup *self,
+ gchar *key,
+ GSettings *settings)
+{
+ GtkSourceStyleScheme *scheme;
+ gchar *scheme_id;
+
+ /* prevent recursion since the active style scheme setter updates the setting */
+ if (self->locked)
+ return;
+
+ /* set the style scheme from the setting */
+ scheme_id = MOUSEPAD_SETTING_GET_STRING (COLOR_SCHEME);
+ scheme = gtk_source_style_scheme_manager_get_scheme (
+ gtk_source_style_scheme_manager_get_default (), scheme_id);
+ g_free (scheme_id);
+
+ mousepad_action_group_set_active_style_scheme (self, scheme);
+}
+
+
+
/**
* Helper functions
**/
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list