diff options
author | Ted Gould <ted@gould.cx> | 2010-08-12 11:37:15 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-08-12 11:37:15 -0500 |
commit | 5988e5b24d22184ce32beb9a16644f28fe8d4841 (patch) | |
tree | af60584f3ffb7176402a9a8e535335ef0c9f3e65 /src | |
parent | 906f7922bbf1875f3fd666ff1e40f1635c52af4c (diff) | |
parent | 3b5cc0042799d3d5796bb22f61aafc3837ffdd59 (diff) | |
download | ayatana-indicator-session-5988e5b24d22184ce32beb9a16644f28fe8d4841.tar.gz ayatana-indicator-session-5988e5b24d22184ce32beb9a16644f28fe8d4841.tar.bz2 ayatana-indicator-session-5988e5b24d22184ce32beb9a16644f28fe8d4841.zip |
Import upstream version 0.2.10
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.in | 7 | ||||
-rw-r--r-- | src/indicator-session.c | 3 | ||||
-rw-r--r-- | src/lock-helper.c | 85 | ||||
-rw-r--r-- | src/lock-helper.h | 2 | ||||
-rw-r--r-- | src/session-service.c | 48 |
5 files changed, 54 insertions, 91 deletions
diff --git a/src/Makefile.in b/src/Makefile.in index 9e4836b..2d25d3c 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -40,10 +40,7 @@ libexec_PROGRAMS = indicator-session-service$(EXEEXT) \ subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/m4/intltool.m4 \ - $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ - $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ - $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -230,6 +227,8 @@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POFILES = @POFILES@ POSUB = @POSUB@ PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ diff --git a/src/indicator-session.c b/src/indicator-session.c index dc23139..a1f1667 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -122,6 +122,9 @@ indicator_session_init (IndicatorSession *self) dbusmenu_client_add_type_handler(client, USER_ITEM_TYPE, new_user_item); dbusmenu_client_add_type_handler(client, RESTART_ITEM_TYPE, build_restart_item); + GtkAccelGroup * agroup = gtk_accel_group_new(); + dbusmenu_gtkclient_set_accel_group(DBUSMENU_GTKCLIENT(client), agroup); + DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); self->service_proxy = dbus_g_proxy_new_for_name(session_bus, INDICATOR_SESSION_DBUS_NAME, diff --git a/src/lock-helper.c b/src/lock-helper.c index ba6b182..9b15070 100644 --- a/src/lock-helper.c +++ b/src/lock-helper.c @@ -176,9 +176,11 @@ build_gss_proxy (void) static gboolean activate_timeout (gpointer data) { + /* Clear the ID for the timeout */ guint * address = (guint *)data; *address = 0; + /* Quit the mainloop */ if (gss_mainloop != NULL) { g_main_loop_quit(gss_mainloop); } @@ -186,22 +188,6 @@ activate_timeout (gpointer data) return FALSE; } -/* Handle errors from activating the screensaver */ -static void -active_cb (DBusGProxy * proxy, DBusGProxyCall * call, gpointer user_data) -{ - GError * error = NULL; - - dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_INVALID); - - if (error != NULL) { - g_warning("Unable to activate screensaver: %s", error->message); - g_error_free(error); - } - - return; -} - /* A fun little function to actually lock the screen. If, that's what you want, let's do it! */ void @@ -212,19 +198,10 @@ lock_screen (DbusmenuMenuitem * mi, guint timestamp, gpointer data) build_gss_proxy(); g_return_if_fail(gss_proxy != NULL); - if (will_lock_screen()) { - dbus_g_proxy_call_no_reply(gss_proxy, - "Lock", - G_TYPE_INVALID, - G_TYPE_INVALID); - } else { - dbus_g_proxy_begin_call(gss_proxy, - "SetActive", - active_cb, NULL, - NULL, - G_TYPE_BOOLEAN, TRUE, - G_TYPE_INVALID); - } + dbus_g_proxy_call_no_reply(gss_proxy, + "Lock", + G_TYPE_INVALID, + G_TYPE_INVALID); if (gss_mainloop == NULL) { gss_mainloop = g_main_loop_new(NULL, FALSE); @@ -253,53 +230,3 @@ lock_screen_setup (gpointer data) return FALSE; } -/* When the GConf key changes we need to adjust the text on - what we're going to do with the menu item */ -static void -lockscreen_update (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer data) { - DbusmenuMenuitem * mi = (DbusmenuMenuitem*) data; - const gchar * key = gconf_entry_get_key (entry); - - if(g_strcmp0 (key, GCONF_KEY) == 0) { - if (will_lock_screen()) { - dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen")); - } else { - dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Start Screensaver")); - } - } -} - -/* Notification handler for lock menuitems. */ -static guint lock_notify = 0; - -/* Sets the menu item to be updating. There can - only be one. So we clear and reset if we get - another. */ -void -lock_screen_update_item (DbusmenuMenuitem * mi) -{ - if (gconf_client == NULL) { - gconf_client = gconf_client_get_default(); - } - - if (lock_notify == 0) { - gconf_client_add_dir (gconf_client, - GCONF_DIR, - GCONF_CLIENT_PRELOAD_ONELEVEL, - NULL); - } - - if (lock_notify != 0) { - gconf_client_notify_remove(gconf_client, lock_notify); - lock_notify = 0; - } - - lock_notify = gconf_client_notify_add(gconf_client, - GCONF_KEY, - lockscreen_update, - mi, - NULL, - NULL); - - return; -} diff --git a/src/lock-helper.h b/src/lock-helper.h index 1d707d8..37f1448 100644 --- a/src/lock-helper.h +++ b/src/lock-helper.h @@ -31,6 +31,4 @@ gboolean will_lock_screen (void); void lock_screen (DbusmenuMenuitem * mi, guint timestamp, gpointer data); gboolean lock_screen_setup (gpointer data); -void lock_screen_update_item (DbusmenuMenuitem * mi); - #endif /* LOCK_HELPER_H__ */ diff --git a/src/session-service.c b/src/session-service.c index 5d2ca1c..1d8cd3a 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -36,6 +36,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <libdbusmenu-glib/server.h> #include <libdbusmenu-glib/menuitem.h> #include <libdbusmenu-glib/client.h> +#include <libdbusmenu-gtk/menuitem.h> #include <libindicator/indicator-service.h> @@ -61,6 +62,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #define LOCKDOWN_KEY_USER LOCKDOWN_DIR "/disable_user_switching" #define LOCKDOWN_KEY_SCREENSAVER LOCKDOWN_DIR "/disable_lock_screen" +#define KEYBINDING_DIR "/apps/gnome_settings_daemon/keybindings" +#define KEY_LOCK_SCREEN KEYBINDING_DIR "/screensaver" + typedef struct _ActivateData ActivateData; struct _ActivateData { @@ -119,6 +123,29 @@ lockdown_changed (GConfClient *client, return; } +static void +keybinding_changed (GConfClient *client, + guint cnxd_id, + GConfEntry *entry, + gpointer user_data) +{ + GConfValue *value = gconf_entry_get_value (entry); + const gchar *key = gconf_entry_get_key (entry); + + if (value == NULL || key == NULL) { + return; + } + + if (g_strcmp0 (key, KEY_LOCK_SCREEN) == 0) { + g_debug("Keybinding changed to: %s", gconf_value_get_string(value)); + if (lock_menuitem != NULL) { + dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, gconf_value_get_string(value)); + } + } + + return; +} + /* Ensures that we have a GConf client and if we build one set up the signal handler. */ static void @@ -126,8 +153,12 @@ ensure_gconf_client (void) { if (!gconf_client) { gconf_client = gconf_client_get_default (); + gconf_client_add_dir(gconf_client, LOCKDOWN_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); gconf_client_notify_add(gconf_client, LOCKDOWN_DIR, lockdown_changed, NULL, NULL, NULL); + + gconf_client_add_dir(gconf_client, KEYBINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + gconf_client_notify_add(gconf_client, KEYBINDING_DIR, keybinding_changed, NULL, NULL, NULL); } return; } @@ -516,14 +547,19 @@ rebuild_items (DbusmenuMenuitem *root, /* Lock screen item */ if (can_lockscreen) { lock_menuitem = dbusmenu_menuitem_new(); - if (will_lock_screen()) { - dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen")); + dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Lock Screen")); + + gchar * shortcut = gconf_client_get_string(gconf_client, KEY_LOCK_SCREEN, NULL); + if (shortcut != NULL) { + g_debug("Lock screen shortcut: %s", shortcut); + dbusmenu_menuitem_property_set_shortcut_string(lock_menuitem, shortcut); + g_free(shortcut); } else { - dbusmenu_menuitem_property_set(lock_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _("Start Screensaver")); + g_debug("Unable to get lock screen shortcut."); } + g_signal_connect(G_OBJECT(lock_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(lock_screen), NULL); dbusmenu_menuitem_child_append(root, lock_menuitem); - lock_screen_update_item(lock_menuitem); } /* Set to NULL just incase we don't end up building one */ @@ -728,9 +764,9 @@ restart_dir_changed (void) if (restart_required) { if (supress_confirmations()) { - dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart To Complete Update")); + dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart to Complete Update")); } else { - dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart To Complete Update\342\200\246")); + dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart to Complete Update\342\200\246")); } dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_ICON, "system-restart-panel"); if (session_dbus != NULL) { |