From dd099b91e3b72e34afa5630fae5bccfa38623e72 Mon Sep 17 00:00:00 2001 From: Alistair Buxton Date: Mon, 21 Mar 2016 23:34:12 +0000 Subject: [PATCH 2/3] Prevent a g_settings cycle. When the selected menu item changes, only update the g_setting. When the g_setting changes, only update the selected menu item. This prevents g_setting changes from bouncing between windows endlessly. --- mousepad/mousepad-action-group.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/mousepad/mousepad-action-group.c b/mousepad/mousepad-action-group.c index acea132..598e9fc 100644 --- a/mousepad/mousepad-action-group.c +++ b/mousepad/mousepad-action-group.c @@ -263,8 +263,6 @@ mousepad_action_group_set_active_language (MousepadActionGroup *self, self->locked = TRUE; gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); self->locked = FALSE; - - g_object_notify (G_OBJECT (self), "active-language"); } @@ -284,8 +282,6 @@ mousepad_action_group_set_active_style_scheme (MousepadActionGroup *self, GtkSourceStyleScheme *scheme) { GtkAction *action; - const gchar *scheme_name = NULL; - g_return_if_fail (MOUSEPAD_IS_ACTION_GROUP (self)); if (GTK_SOURCE_IS_STYLE_SCHEME (self->active_scheme)) @@ -302,16 +298,6 @@ mousepad_action_group_set_active_style_scheme (MousepadActionGroup *self, self->locked = TRUE; gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); self->locked = FALSE; - - /* update the setting when the active action is changed */ - if (scheme != NULL) - scheme_name = gtk_source_style_scheme_get_id(scheme); - - self->locked = TRUE; - MOUSEPAD_SETTING_SET_STRING (COLOR_SCHEME, scheme_name); - self->locked = FALSE; - - g_object_notify (G_OBJECT (self), "active-style-scheme"); } @@ -477,6 +463,8 @@ static void mousepad_action_group_style_scheme_action_activate (MousepadActionGroup *self, MousepadStyleSchemeAction *action) { + const gchar *scheme_name = NULL; + /* only update the active action if we're not already in the process of * setting it and the sender action is actually active */ if (! self->locked && @@ -485,7 +473,16 @@ mousepad_action_group_style_scheme_action_activate (MousepadActionGroup *s GtkSourceStyleScheme *scheme; scheme = mousepad_style_scheme_action_get_style_scheme (action); - mousepad_action_group_set_active_style_scheme (self, scheme); + //mousepad_action_group_set_active_style_scheme (self, scheme); + + /* update the setting when the active action is changed */ + if (scheme != NULL) + scheme_name = gtk_source_style_scheme_get_id(scheme); + + self->locked = TRUE; + MOUSEPAD_SETTING_SET_STRING (COLOR_SCHEME, scheme_name); + self->locked = FALSE; + } } -- 2.5.0