aboutsummaryrefslogtreecommitdiff
path: root/src/device-menu-mgr.c
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-06-05 14:18:35 -0500
committerCharles Kerr <charles.kerr@canonical.com>2012-06-05 14:18:35 -0500
commitd767fd18038684dff290581d6b77ddfdf421a341 (patch)
treeb5b663780a11ee245871f2c7600126ebd48a775d /src/device-menu-mgr.c
parent470d4c03379c4d45b848b8078f93ab9cadd07c54 (diff)
downloadayatana-indicator-session-d767fd18038684dff290581d6b77ddfdf421a341.tar.gz
ayatana-indicator-session-d767fd18038684dff290581d6b77ddfdf421a341.tar.bz2
ayatana-indicator-session-d767fd18038684dff290581d6b77ddfdf421a341.zip
make lockdown_settings an instance variable rather than a global one, so that it will get disposed properly and not persist between test sessions
Diffstat (limited to 'src/device-menu-mgr.c')
-rw-r--r--src/device-menu-mgr.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/src/device-menu-mgr.c b/src/device-menu-mgr.c
index 57738db..043ec0f 100644
--- a/src/device-menu-mgr.c
+++ b/src/device-menu-mgr.c
@@ -43,9 +43,9 @@ struct _DeviceMenuMgr
GObject parent_instance;
DbusmenuMenuitem* root_item;
SessionDbus* session_dbus_interface;
+ GSettings *lockdown_settings;
};
-static GSettings *lockdown_settings = NULL;
static GSettings *keybinding_settings = NULL;
static DbusmenuMenuitem *lock_menuitem = NULL;
static DbusmenuMenuitem *system_settings_menuitem = NULL;
@@ -89,24 +89,42 @@ static void
device_menu_mgr_init (DeviceMenuMgr *self)
{
self->root_item = dbusmenu_menuitem_new ();
- setup_up(self);
- g_idle_add(lock_screen_setup, NULL);
+
+ self->lockdown_settings = g_settings_new (LOCKDOWN_SCHEMA);
+ g_signal_connect_swapped (self->lockdown_settings, "changed::" LOCKDOWN_KEY_USER, G_CALLBACK(device_menu_mgr_rebuild_items), self);
+ g_signal_connect_swapped (self->lockdown_settings, "changed::" LOCKDOWN_KEY_SCREENSAVER, G_CALLBACK(device_menu_mgr_rebuild_items), self);
+
+ setup_up(self);
+ g_idle_add(lock_screen_setup, NULL);
+}
+
+static void
+device_menu_mgr_dispose (GObject *object)
+{
+ DeviceMenuMgr * self = DEVICE_MENU_MGR (object);
+ g_clear_object (&self->lockdown_settings);
+
+ G_OBJECT_CLASS (device_menu_mgr_parent_class)->finalize (object);
}
static void
device_menu_mgr_finalize (GObject *object)
{
- G_OBJECT_CLASS (device_menu_mgr_parent_class)->finalize (object);
+ G_OBJECT_CLASS (device_menu_mgr_parent_class)->finalize (object);
}
-// TODO refactor into one helper method for both menu mgrs.
static void
device_menu_mgr_class_init (DeviceMenuMgrClass *klass)
{
- GObjectClass* object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = device_menu_mgr_finalize;
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+ object_class->dispose = device_menu_mgr_dispose;
+ object_class->finalize = device_menu_mgr_finalize;
}
+/***
+****
+***/
+
static void
update_screensaver_shortcut (DbusmenuMenuitem * menuitem, GSettings * settings)
{
@@ -447,7 +465,7 @@ device_menu_mgr_build_static_items (DeviceMenuMgr* self, gboolean greeter_mode)
/* Make sure we have a valid GConf client, and build one
if needed */
device_menu_mgr_ensure_settings_client (self);
- can_lockscreen = !g_settings_get_boolean (lockdown_settings,
+ can_lockscreen = !g_settings_get_boolean (self->lockdown_settings,
LOCKDOWN_KEY_SCREENSAVER);
/* Lock screen item */
if (can_lockscreen) {
@@ -555,11 +573,6 @@ device_menu_mgr_rebuild_items (DeviceMenuMgr* self)
static void
device_menu_mgr_ensure_settings_client (DeviceMenuMgr* self)
{
- if (!lockdown_settings) {
- lockdown_settings = g_settings_new (LOCKDOWN_SCHEMA);
- g_signal_connect_swapped (lockdown_settings, "changed::" LOCKDOWN_KEY_USER, G_CALLBACK(device_menu_mgr_rebuild_items), self);
- g_signal_connect_swapped (lockdown_settings, "changed::" LOCKDOWN_KEY_SCREENSAVER, G_CALLBACK(device_menu_mgr_rebuild_items), self);
- }
if (!keybinding_settings) {
keybinding_settings = g_settings_new (KEYBINDING_SCHEMA);
g_signal_connect (keybinding_settings, "changed::" KEY_LOCK_SCREEN, G_CALLBACK(screensaver_keybinding_changed), self);