[gnome-panel] Add support for user switch with LightDM
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] Add support for user switch with LightDM
- Date: Tue, 28 Oct 2014 18:49:40 +0000 (UTC)
commit 140a7393cc74fd773db865223eff5e8ae7f003d2
Author: Balló György <ballogyor gmail com>
Date: Fri Oct 17 19:06:53 2014 +0200
Add support for user switch with LightDM
gnome-panel/panel-menu-items.c | 69 +++++++++++++++++++++++++++++-----------
1 files changed, 50 insertions(+), 19 deletions(-)
---
diff --git a/gnome-panel/panel-menu-items.c b/gnome-panel/panel-menu-items.c
index 6340a87..1421c29 100644
--- a/gnome-panel/panel-menu-items.c
+++ b/gnome-panel/panel-menu-items.c
@@ -441,32 +441,63 @@ static void
panel_menu_item_activate_switch_user (GtkWidget *menuitem,
gpointer user_data)
{
- GdkScreen *screen;
- GAppInfo *app_info;
-
if (panel_lockdown_get_disable_switch_user_s ())
return;
- screen = gtk_widget_get_screen (GTK_WIDGET (menuitem));
- app_info = g_app_info_create_from_commandline (GDM_FLEXISERVER_COMMAND " " GDM_FLEXISERVER_ARGS,
- GDM_FLEXISERVER_COMMAND,
- G_APP_INFO_CREATE_NONE,
- NULL);
+ /* If running under LightDM switch to the greeter using dbus */
+ if (g_getenv("XDG_SEAT_PATH")) {
+ GDBusConnection *bus;
+ GError *error = NULL;
+ GVariant *result = NULL;
+
+ bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (error)
+ g_warning ("Failed to get system bus: %s", error->message);
+ g_clear_error (&error);
+
+ if (bus)
+ result = g_dbus_connection_call_sync (bus,
+ "org.freedesktop.DisplayManager",
+ g_getenv ("XDG_SEAT_PATH"),
+ "org.freedesktop.DisplayManager.Seat",
+ "SwitchToGreeter",
+ g_variant_new ("()"),
+ G_VARIANT_TYPE ("()"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (error)
+ g_warning ("Failed to switch to greeter: %s", error->message);
+ g_clear_error (&error);
+
+ if (result)
+ g_variant_unref (result);
+ } else {
+ GdkScreen *screen;
+ GAppInfo *app_info;
- if (app_info) {
- GdkAppLaunchContext *launch_context;
- GdkDisplay *display;
+ screen = gtk_widget_get_screen (GTK_WIDGET (menuitem));
+ app_info = g_app_info_create_from_commandline (GDM_FLEXISERVER_COMMAND " "
GDM_FLEXISERVER_ARGS,
+ GDM_FLEXISERVER_COMMAND,
+ G_APP_INFO_CREATE_NONE,
+ NULL);
- display = gdk_screen_get_display (screen);
- launch_context = gdk_display_get_app_launch_context (display);
- gdk_app_launch_context_set_screen (launch_context, screen);
+ if (app_info) {
+ GdkAppLaunchContext *launch_context;
+ GdkDisplay *display;
- g_app_info_launch (app_info, NULL,
- G_APP_LAUNCH_CONTEXT (launch_context),
- NULL);
+ display = gdk_screen_get_display (screen);
+ launch_context = gdk_display_get_app_launch_context (display);
+ gdk_app_launch_context_set_screen (launch_context, screen);
- g_object_unref (launch_context);
- g_object_unref (app_info);
+ g_app_info_launch (app_info, NULL,
+ G_APP_LAUNCH_CONTEXT (launch_context),
+ NULL);
+
+ g_object_unref (launch_context);
+ g_object_unref (app_info);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]