Package: mousepad / 0.4.0-4

01_prevent-a-g_settings-cycle.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
From 320deb1ec28ddb5e9647b154f2c08f358ba2c4cb Mon Sep 17 00:00:00 2001
From: Alistair Buxton <a.j.buxton@gmail.com>
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(-)

--- a/mousepad/mousepad-action-group.c
+++ b/mousepad/mousepad-action-group.c
@@ -302,11 +302,6 @@ mousepad_action_group_set_active_style_s
   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");
 }
 
@@ -473,6 +468,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 &&
@@ -481,7 +478,14 @@ mousepad_action_group_style_scheme_actio
       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;
     }
 }