region: Use a GDBusProxy to access org.gnome.SessionManager
We'll use this interface beyond just calling Logout() so lets keep a proxy around. https://bugzilla.gnome.org/show_bug.cgi?id=695534
This commit is contained in:
parent
3efb71bab7
commit
50ea2c11ce
1 changed files with 39 additions and 10 deletions
|
@ -83,6 +83,7 @@ struct _CcRegionPanelPrivate {
|
|||
GPermission *permission;
|
||||
SystemOp op;
|
||||
GDBusProxy *localed;
|
||||
GDBusProxy *session;
|
||||
GCancellable *cancellable;
|
||||
|
||||
GtkWidget *overlay;
|
||||
|
@ -143,6 +144,7 @@ cc_region_panel_finalize (GObject *object)
|
|||
|
||||
g_clear_object (&priv->permission);
|
||||
g_clear_object (&priv->localed);
|
||||
g_clear_object (&priv->session);
|
||||
g_clear_object (&priv->builder);
|
||||
g_clear_object (&priv->locale_settings);
|
||||
g_clear_object (&priv->input_settings);
|
||||
|
@ -197,19 +199,15 @@ cc_region_panel_class_init (CcRegionPanelClass * klass)
|
|||
static void
|
||||
restart_now (CcRegionPanel *self)
|
||||
{
|
||||
GDBusConnection *bus;
|
||||
CcRegionPanelPrivate *priv = self->priv;
|
||||
|
||||
gd_notification_dismiss (GD_NOTIFICATION (self->priv->notification));
|
||||
|
||||
bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
|
||||
g_dbus_connection_call (bus,
|
||||
"org.gnome.SessionManager",
|
||||
"/org/gnome/SessionManager",
|
||||
"org.gnome.SessionManager",
|
||||
"Logout",
|
||||
g_variant_new ("(u)", 0),
|
||||
NULL, 0, G_MAXINT,
|
||||
NULL, NULL, NULL);
|
||||
g_dbus_proxy_call (priv->session,
|
||||
"Logout",
|
||||
g_variant_new ("(u)", 0),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1596,6 +1594,27 @@ setup_login_button (CcRegionPanel *self)
|
|||
G_CALLBACK (login_changed), self);
|
||||
}
|
||||
|
||||
static void
|
||||
session_proxy_ready (GObject *source,
|
||||
GAsyncResult *res,
|
||||
gpointer data)
|
||||
{
|
||||
CcRegionPanel *self = data;
|
||||
GDBusProxy *proxy;
|
||||
GError *error = NULL;
|
||||
|
||||
proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
|
||||
|
||||
if (!proxy) {
|
||||
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
g_warning ("Failed to contact gnome-session: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
self->priv->session = proxy;
|
||||
}
|
||||
|
||||
static void
|
||||
cc_region_panel_init (CcRegionPanel *self)
|
||||
{
|
||||
|
@ -1620,6 +1639,16 @@ cc_region_panel_init (CcRegionPanel *self)
|
|||
|
||||
priv->cancellable = g_cancellable_new ();
|
||||
|
||||
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
|
||||
G_DBUS_PROXY_FLAGS_NONE,
|
||||
NULL,
|
||||
"org.gnome.SessionManager",
|
||||
"/org/gnome/SessionManager",
|
||||
"org.gnome.SessionManager",
|
||||
priv->cancellable,
|
||||
session_proxy_ready,
|
||||
self);
|
||||
|
||||
setup_login_button (self);
|
||||
setup_language_section (self);
|
||||
setup_input_section (self);
|
||||
|
|
Loading…
Add table
Reference in a new issue