aboutsummaryrefslogtreecommitdiff
path: root/src/session-service.c
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-07-22 12:48:41 -0500
committerTed Gould <ted@canonical.com>2009-07-22 12:48:41 -0500
commit3852caea472d3a95891ae5b58463f417877472a3 (patch)
treef2e34e75ccf7d9c0f87aebb2a29cbf5ce9294632 /src/session-service.c
parent49a4fd2bd3e8539fb6faf717dd4016ffcfd58c52 (diff)
parentc9cfcc8a9aefd2122e80e3674c0da96ffe849a34 (diff)
downloadayatana-indicator-session-3852caea472d3a95891ae5b58463f417877472a3.tar.gz
ayatana-indicator-session-3852caea472d3a95891ae5b58463f417877472a3.tar.bz2
ayatana-indicator-session-3852caea472d3a95891ae5b58463f417877472a3.zip
Adding a helper for the logout window. And setting things
up to call it.
Diffstat (limited to 'src/session-service.c')
-rw-r--r--src/session-service.c47
1 files changed, 16 insertions, 31 deletions
diff --git a/src/session-service.c b/src/session-service.c
index 80d4172..b301baf 100644
--- a/src/session-service.c
+++ b/src/session-service.c
@@ -13,37 +13,22 @@ static DbusmenuMenuitem * root_menuitem = NULL;
static GMainLoop * mainloop = NULL;
static void
-log_out (DbusmenuMenuitem * mi, gpointer userdata)
+show_dialog (DbusmenuMenuitem * mi, gchar * type)
{
- g_debug("Log Out");
- return;
-}
+ gchar * helper = g_build_path(LIBEXECDIR, "gtk-logout-helper", NULL);
+ gchar * dialog_line = g_strdup_printf("%s --%s", helper, type);
+ g_free(helper);
-static void
-suspend (DbusmenuMenuitem * mi, gpointer userdata)
-{
- g_debug("Suspend");
- return;
-}
+ g_debug("Showing dialog '%s'", dialog_line);
-static void
-hibernate (DbusmenuMenuitem * mi, gpointer userdata)
-{
- g_debug("Hibernate");
- return;
-}
+ GError * error = NULL;
+ if (!g_spawn_command_line_async(dialog_line, &error)) {
+ g_warning("Unable to show dialog: %s", error->message);
+ g_error_free(error);
+ }
-static void
-restart (DbusmenuMenuitem * mi, gpointer userdata)
-{
- g_debug("Restart");
- return;
-}
+ g_free(dialog_line);
-static void
-shutdown (DbusmenuMenuitem * mi, gpointer userdata)
-{
- g_debug("Shutdown");
return;
}
@@ -54,27 +39,27 @@ create_items (DbusmenuMenuitem * root) {
mi = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set(mi, "label", _("Log Out"));
dbusmenu_menuitem_child_append(root, mi);
- g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(log_out), NULL);
+ g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "logout");
mi = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set(mi, "label", _("Suspend"));
dbusmenu_menuitem_child_append(root, mi);
- g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(suspend), NULL);
+ g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "suspend");
mi = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set(mi, "label", _("Hibernate"));
dbusmenu_menuitem_child_append(root, mi);
- g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(hibernate), NULL);
+ g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "hibernate");
mi = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set(mi, "label", _("Restart"));
dbusmenu_menuitem_child_append(root, mi);
- g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(restart), NULL);
+ g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "restart");
mi = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set(mi, "label", _("Shutdown"));
dbusmenu_menuitem_child_append(root, mi);
- g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(shutdown), NULL);
+ g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(show_dialog), "shutdown");
return;
}