[gitg] Make sure to unbind from settings when closing preferences
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Make sure to unbind from settings when closing preferences
- Date: Sun, 14 Dec 2014 09:06:03 +0000 (UTC)
commit 5023d3304e480c64faa7663f7d9a51117176b4c4
Author: Jesse van den Kieboom <jessevdk gmail com>
Date: Sun Dec 14 10:05:23 2014 +0100
Make sure to unbind from settings when closing preferences
gitg/preferences/gitg-preferences-interface.vala | 33 ++++++++++++++++------
1 files changed, 24 insertions(+), 9 deletions(-)
---
diff --git a/gitg/preferences/gitg-preferences-interface.vala
b/gitg/preferences/gitg-preferences-interface.vala
index a1287a2..69f36ad 100644
--- a/gitg/preferences/gitg-preferences-interface.vala
+++ b/gitg/preferences/gitg-preferences-interface.vala
@@ -26,15 +26,16 @@ public class PreferencesInterface : Gtk.Grid, GitgExt.Preferences
// Do this to pull in config.h before glib.h (for gettext...)
private const string version = Gitg.Config.VERSION;
private bool d_block;
+ private Settings? d_settings;
[GtkChild (name = "horizontal_layout_enabled")]
private Gtk.CheckButton d_horizontal_layout_enabled;
construct
{
- var settings = new Settings("org.gnome.gitg.preferences.interface");
+ d_settings = new Settings("org.gnome.gitg.preferences.interface");
- d_horizontal_layout_enabled.active = settings.get_enum("orientation") == 0;
+ d_horizontal_layout_enabled.active = d_settings.get_enum("orientation") == 0;
d_horizontal_layout_enabled.notify["active"].connect((obj, spec)=> {
if (d_block)
@@ -42,17 +43,31 @@ public class PreferencesInterface : Gtk.Grid, GitgExt.Preferences
return;
}
- if (!settings.set_enum("orientation", d_horizontal_layout_enabled.active ? 0 : 1))
+ if (!d_settings.set_enum("orientation", d_horizontal_layout_enabled.active ? 0 : 1))
{
- d_horizontal_layout_enabled.active = settings.get_enum("orientation") == 0;
+ d_horizontal_layout_enabled.active = d_settings.get_enum("orientation") == 0;
}
});
- settings.changed["orientation"].connect((s, k) => {
- d_block = true;
- d_horizontal_layout_enabled.active = settings.get_enum("orientation") == 0;
- d_block = false;
- });
+ d_settings.changed["orientation"].connect(orientation_changed);
+ }
+
+ public override void dispose()
+ {
+ if (d_settings != null)
+ {
+ d_settings.changed["orientation"].disconnect(orientation_changed);
+ d_settings = null;
+ }
+
+ base.dispose();
+ }
+
+ private void orientation_changed(Settings settings, string key)
+ {
+ d_block = true;
+ d_horizontal_layout_enabled.active = settings.get_enum(key) == 0;
+ d_block = false;
}
public Gtk.Widget widget
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]