aboutsummaryrefslogtreecommitdiff
path: root/src/session-service.c
diff options
context:
space:
mode:
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;
}