From bcfccef094eed30c35bee4fc4f85f2a1e2f98d2a Mon Sep 17 00:00:00 2001 From: Alistair Buxton Date: Mon, 21 Mar 2016 21:49:04 +0000 Subject: [PATCH 1/3] Revert "Prevent a weird cycle in GSettings use" This reverts commit f07cc75f2aa77d14f16b5506321ac6a2413706ba. --- mousepad/mousepad-view.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/mousepad/mousepad-view.c b/mousepad/mousepad-view.c index 03f46094f..bd0e37c34 100644 --- a/mousepad/mousepad-view.c +++ b/mousepad/mousepad-view.c @@ -324,16 +324,10 @@ mousepad_view_init (MousepadView *view) BIND_ (SHOW_RIGHT_MARGIN, "show-right-margin"); BIND_ (SMART_HOME_END, "smart-home-end"); BIND_ (TAB_WIDTH, "tab-width"); + BIND_ (COLOR_SCHEME, "color-scheme"); BIND_ (WORD_WRAP, "word-wrap"); BIND_ (MATCH_BRACES, "match-braces"); - /* for color-scheme, use G_SETTINGS_BIND_GET_NO_CHANGES to stop - * a cycle that was causing DBus thrashing. See: - * https://bugzilla.xfce.org/show_bug.cgi?id=12134 */ - MOUSEPAD_SETTING_BIND (COLOR_SCHEME, view, "color-scheme", - G_SETTINGS_BIND_DEFAULT | - G_SETTINGS_BIND_GET_NO_CHANGES); - /* override with default font when the setting is enabled */ MOUSEPAD_SETTING_CONNECT_OBJECT (USE_DEFAULT_FONT, G_CALLBACK (mousepad_view_use_default_font_setting_changed), From 3c2bc00a684e45df4f5c56bf37d047a5f785cb8d 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 | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/mousepad/mousepad-action-group.c b/mousepad/mousepad-action-group.c index acea13272..f9a7fa103 100644 --- a/mousepad/mousepad-action-group.c +++ b/mousepad/mousepad-action-group.c @@ -284,8 +284,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)) @@ -303,14 +301,6 @@ 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 */ - 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 +467,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 +477,14 @@ 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); + + /* 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; } } From dce63e6bd1bdad1238640c30e970d563c233dd26 Mon Sep 17 00:00:00 2001 From: Alistair Buxton Date: Mon, 21 Mar 2016 23:36:05 +0000 Subject: [PATCH 3/3] Do not manually update the view theme. The view property is bound directly to the g_setting, so it will be updated autoatically whenever that changes. The action group updates the g_setting so we don't need to manually propagate the setting. --- mousepad/mousepad-window.c | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/mousepad/mousepad-window.c b/mousepad/mousepad-window.c index adae7cd12..a3fda7a02 100644 --- a/mousepad/mousepad-window.c +++ b/mousepad/mousepad-window.c @@ -711,33 +711,6 @@ mousepad_window_create_languages_menu (MousepadWindow *window) -static void -mousepad_window_action_group_style_scheme_changed (MousepadWindow *window, - GParamSpec *pspec, - MousepadActionGroup *group) -{ - GtkSourceStyleScheme *scheme; - const gchar *scheme_id = NULL; - gint npages, i; - - /* get the new active language */ - scheme = mousepad_action_group_get_active_style_scheme (group); - if (scheme != NULL) - scheme_id = gtk_source_style_scheme_get_id (scheme); - - /* update the color scheme on all the documents */ - npages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook)); - for (i = 0; i < npages; i++) - { - MousepadDocument *document; - - document = MOUSEPAD_DOCUMENT (gtk_notebook_get_nth_page (GTK_NOTEBOOK (window->notebook), i)); - mousepad_view_set_color_scheme (document->textview, scheme_id); - } -} - - - static void mousepad_window_create_style_schemes_menu (MousepadWindow *window) { @@ -752,13 +725,6 @@ mousepad_window_create_style_schemes_menu (MousepadWindow *window) gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu); gtk_widget_show_all (menu); gtk_widget_show (item); - - /* watch for activations of the style schemes actions */ - g_signal_connect_object (window->action_group, - "notify::active-style-scheme", - G_CALLBACK (mousepad_window_action_group_style_scheme_changed), - window, - G_CONNECT_SWAPPED); }