[gnome-session/wip/flashback] don't use org.gnome.Shell for end session dialog



commit a3133bd131ccc3c42c94c76ca301617137ffd23b
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sat Dec 13 14:14:34 2014 +0200

    don't use org.gnome.Shell for end session dialog
    
    https://bugzilla.gnome.org/show_bug.cgi?id=738264

 gnome-session/Makefile.am              |    2 +
 gnome-session/gsm-end-session-dialog.c |  431 ++++++++++++++++++++++++++++++++
 gnome-session/gsm-end-session-dialog.h |   82 ++++++
 gnome-session/gsm-manager.c            |  159 ++++++------
 gnome-session/gsm-shell.c              |  352 --------------------------
 gnome-session/gsm-shell.h              |   21 --
 6 files changed, 596 insertions(+), 451 deletions(-)
---
diff --git a/gnome-session/Makefile.am b/gnome-session/Makefile.am
index c70c542..3f3f87b 100644
--- a/gnome-session/Makefile.am
+++ b/gnome-session/Makefile.am
@@ -54,6 +54,8 @@ gnome_session_SOURCES =                               \
        gsm-session-fill.h                      \
        gsm-session-save.c                      \
        gsm-session-save.h                      \
+       gsm-end-session-dialog.c                \
+       gsm-end-session-dialog.h                \
        gsm-shell-extensions.c                  \
        gsm-shell-extensions.h                  \
        gsm-shell.c                             \
diff --git a/gnome-session/gsm-end-session-dialog.c b/gnome-session/gsm-end-session-dialog.c
new file mode 100644
index 0000000..9fae166
--- /dev/null
+++ b/gnome-session/gsm-end-session-dialog.c
@@ -0,0 +1,431 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Red Hat, Inc
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <glib.h>
+#include <glib-object.h>
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+
+#include "gsm-inhibitor.h"
+#include "gsm-end-session-dialog.h"
+
+#define END_SESSION_DIALOG_NAME      "org.gnome.SessionManager.EndSessionDialog"
+#define END_SESSION_DIALOG_PATH      "/org/gnome/SessionManager/EndSessionDialog"
+#define END_SESSION_DIALOG_INTERFACE "org.gnome.SessionManager.EndSessionDialog"
+
+#define AUTOMATIC_ACTION_TIMEOUT 60
+
+struct _GsmEndSessionDialogPrivate
+{
+        GDBusProxy              *end_session_dialog_proxy;
+        GsmStore                *inhibitors;
+
+        gboolean                 dialog_is_open;
+        GsmEndSessionDialogType  end_session_dialog_type;
+
+        guint                    update_idle_id;
+        guint                    watch_id;
+};
+
+enum {
+        END_SESSION_DIALOG_OPENED = 0,
+        END_SESSION_DIALOG_OPEN_FAILED,
+        END_SESSION_DIALOG_CLOSED,
+        END_SESSION_DIALOG_CANCELED,
+        END_SESSION_DIALOG_CONFIRMED_LOGOUT,
+        END_SESSION_DIALOG_CONFIRMED_SHUTDOWN,
+        END_SESSION_DIALOG_CONFIRMED_REBOOT,
+        NUMBER_OF_SIGNALS
+};
+
+static guint signals[NUMBER_OF_SIGNALS] = { 0 };
+
+static void gsm_end_session_dialog_finalize (GObject             *object);
+static void queue_end_session_dialog_update (GsmEndSessionDialog *dialog);
+
+G_DEFINE_TYPE_WITH_PRIVATE (GsmEndSessionDialog, gsm_end_session_dialog, G_TYPE_OBJECT);
+
+static void
+gsm_end_session_dialog_class_init (GsmEndSessionDialogClass *class)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+        object_class->finalize = gsm_end_session_dialog_finalize;
+
+        signals [END_SESSION_DIALOG_OPENED] =
+                g_signal_new ("end-session-dialog-opened",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmEndSessionDialogClass, end_session_dialog_opened),
+                              NULL, NULL, NULL,
+                              G_TYPE_NONE, 0);
+
+        signals [END_SESSION_DIALOG_OPEN_FAILED] =
+                g_signal_new ("end-session-dialog-open-failed",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmEndSessionDialogClass, end_session_dialog_open_failed),
+                              NULL, NULL, NULL,
+                              G_TYPE_NONE, 0);
+
+        signals [END_SESSION_DIALOG_CLOSED] =
+                g_signal_new ("end-session-dialog-closed",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmEndSessionDialogClass, end_session_dialog_closed),
+                              NULL, NULL, NULL,
+                              G_TYPE_NONE, 0);
+
+        signals [END_SESSION_DIALOG_CANCELED] =
+                g_signal_new ("end-session-dialog-canceled",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmEndSessionDialogClass, end_session_dialog_canceled),
+                              NULL, NULL, NULL,
+                              G_TYPE_NONE, 0);
+
+        signals [END_SESSION_DIALOG_CONFIRMED_LOGOUT] =
+                g_signal_new ("end-session-dialog-confirmed-logout",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmEndSessionDialogClass, 
end_session_dialog_confirmed_logout),
+                              NULL, NULL, NULL,
+                              G_TYPE_NONE, 0);
+
+        signals [END_SESSION_DIALOG_CONFIRMED_SHUTDOWN] =
+                g_signal_new ("end-session-dialog-confirmed-shutdown",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmEndSessionDialogClass, 
end_session_dialog_confirmed_shutdown),
+                              NULL, NULL, NULL,
+                              G_TYPE_NONE, 0);
+
+        signals [END_SESSION_DIALOG_CONFIRMED_REBOOT] =
+                g_signal_new ("end-session-dialog-confirmed-reboot",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmEndSessionDialogClass, 
end_session_dialog_confirmed_reboot),
+                              NULL, NULL, NULL,
+                              G_TYPE_NONE, 0);
+}
+
+static void
+gsm_end_session_dialog_init (GsmEndSessionDialog *dialog)
+{
+        dialog->priv = gsm_end_session_dialog_get_instance_private (dialog);
+
+        dialog->priv->watch_id = g_bus_watch_name (G_BUS_TYPE_SESSION,
+                                                   END_SESSION_DIALOG_NAME,
+                                                   G_BUS_NAME_WATCHER_FLAGS_NONE,
+                                                   NULL,
+                                                   NULL,
+                                                   dialog,
+                                                   NULL);
+}
+
+static void
+gsm_end_session_dialog_finalize (GObject *object)
+{
+        GsmEndSessionDialog *dialog = GSM_END_SESSION_DIALOG (object);
+
+        g_object_unref (dialog->priv->inhibitors);
+
+        if (dialog->priv->watch_id != 0) {
+                g_bus_unwatch_name (dialog->priv->watch_id);
+                dialog->priv->watch_id = 0;
+        }
+
+        G_OBJECT_CLASS (gsm_end_session_dialog_parent_class)->finalize (object);
+}
+
+GsmEndSessionDialog *
+gsm_end_session_dialog_new (void)
+{
+        GsmEndSessionDialog *dialog;
+
+        dialog = g_object_new (GSM_TYPE_END_SESSION_DIALOG, NULL);
+
+        return dialog;
+}
+
+static gboolean
+add_inhibitor_to_array (const char      *id,
+                        GsmInhibitor    *inhibitor,
+                        GVariantBuilder *builder)
+{
+        g_variant_builder_add (builder, "o", gsm_inhibitor_peek_id (inhibitor));
+        return FALSE;
+}
+
+static GVariant *
+get_array_from_store (GsmStore *inhibitors)
+{
+        GVariantBuilder builder;
+
+        g_variant_builder_init (&builder, G_VARIANT_TYPE ("ao"));
+        gsm_store_foreach (inhibitors,
+                           (GsmStoreFunc) add_inhibitor_to_array,
+                           &builder);
+
+        return g_variant_builder_end (&builder);
+}
+
+static void
+remove_update_idle_source (GsmEndSessionDialog *dialog)
+{
+        if (dialog->priv->update_idle_id != 0) {
+                g_source_remove (dialog->priv->update_idle_id);
+                dialog->priv->update_idle_id = 0;
+        }
+}
+
+static void
+on_open_finished (GObject      *source,
+                  GAsyncResult *result,
+                  gpointer      user_data)
+{
+        GsmEndSessionDialog *dialog;
+        GError *error;
+
+        dialog = GSM_END_SESSION_DIALOG (user_data);
+
+        remove_update_idle_source (dialog);
+
+        dialog->priv->dialog_is_open = FALSE;
+
+        error = NULL;
+        g_dbus_proxy_call_finish (G_DBUS_PROXY (source), result, &error);
+
+        if (error != NULL) {
+                g_warning ("Unable to open end session dialog: %s", error->message);
+                g_error_free (error);
+
+                g_signal_emit (dialog, signals[END_SESSION_DIALOG_OPEN_FAILED], 0);
+                return;
+        }
+
+        g_signal_emit (dialog, signals[END_SESSION_DIALOG_OPENED], 0);
+}
+
+static void
+on_end_session_dialog_closed (GsmEndSessionDialog *dialog)
+{
+        remove_update_idle_source (dialog);
+
+        g_signal_handlers_disconnect_by_func (dialog->priv->inhibitors,
+                                              G_CALLBACK (queue_end_session_dialog_update),
+                                              dialog);
+
+        g_signal_emit (G_OBJECT (dialog), signals[END_SESSION_DIALOG_CLOSED], 0);
+}
+
+static void
+on_end_session_dialog_canceled (GsmEndSessionDialog *dialog)
+{
+        remove_update_idle_source (dialog);
+
+        g_signal_handlers_disconnect_by_func (dialog->priv->inhibitors,
+                                              G_CALLBACK (queue_end_session_dialog_update),
+                                              dialog);
+
+        g_signal_emit (G_OBJECT (dialog), signals[END_SESSION_DIALOG_CANCELED], 0);
+}
+
+static void
+on_end_session_dialog_confirmed_logout (GsmEndSessionDialog *dialog)
+{
+        remove_update_idle_source (dialog);
+
+        g_signal_emit (G_OBJECT (dialog), signals[END_SESSION_DIALOG_CONFIRMED_LOGOUT], 0);
+}
+
+static void
+on_end_session_dialog_confirmed_shutdown (GsmEndSessionDialog *dialog)
+{
+        remove_update_idle_source (dialog);
+
+        g_signal_emit (G_OBJECT (dialog), signals[END_SESSION_DIALOG_CONFIRMED_SHUTDOWN], 0);
+}
+
+static void
+on_end_session_dialog_confirmed_reboot (GsmEndSessionDialog *dialog)
+{
+        remove_update_idle_source (dialog);
+
+        g_signal_emit (G_OBJECT (dialog), signals[END_SESSION_DIALOG_CONFIRMED_REBOOT], 0);
+}
+
+static void
+on_end_session_dialog_dbus_signal (GDBusProxy          *proxy,
+                                   gchar               *sender_name,
+                                   gchar               *signal_name,
+                                   GVariant            *parameters,
+                                   GsmEndSessionDialog *dialog)
+{
+        if (g_strcmp0 (signal_name, "Closed") == 0) {
+                on_end_session_dialog_closed (dialog);
+        } else if (g_strcmp0 (signal_name, "Canceled") == 0) {
+                on_end_session_dialog_canceled (dialog);
+        } else if (g_strcmp0 (signal_name ,"ConfirmedLogout") == 0) {
+                on_end_session_dialog_confirmed_logout (dialog);
+        } else if (g_strcmp0 (signal_name ,"ConfirmedReboot") == 0) {
+                on_end_session_dialog_confirmed_reboot (dialog);
+        } else if (g_strcmp0 (signal_name ,"ConfirmedShutdown") == 0) {
+                on_end_session_dialog_confirmed_shutdown (dialog);
+        }
+}
+
+static void
+on_end_session_dialog_name_owner_changed (GDBusProxy          *proxy,
+                                          GParamSpec          *pspec,
+                                          GsmEndSessionDialog *dialog)
+{
+        gchar *name_owner;
+
+        name_owner = g_dbus_proxy_get_name_owner (proxy);
+        if (name_owner == NULL) {
+                g_clear_object (&dialog->priv->end_session_dialog_proxy);
+        }
+
+        g_free (name_owner);
+}
+
+static gboolean
+on_need_end_session_dialog_update (GsmEndSessionDialog *dialog)
+{
+        /* No longer need an update */
+        if (dialog->priv->update_idle_id == 0)
+                return FALSE;
+
+        dialog->priv->update_idle_id = 0;
+
+        gsm_end_session_dialog_open (dialog,
+                                     dialog->priv->end_session_dialog_type,
+                                     dialog->priv->inhibitors);
+        return FALSE;
+}
+
+static void
+queue_end_session_dialog_update (GsmEndSessionDialog *dialog)
+{
+        if (dialog->priv->update_idle_id != 0)
+                return;
+
+        dialog->priv->update_idle_id = g_idle_add ((GSourceFunc) on_need_end_session_dialog_update,
+                                                   dialog);
+}
+
+gboolean
+gsm_end_session_dialog_open (GsmEndSessionDialog     *dialog,
+                             GsmEndSessionDialogType  type,
+                             GsmStore                *inhibitors)
+{
+        GDBusProxy *proxy;
+        GError *error;
+
+        error = NULL;
+
+        if (dialog->priv->dialog_is_open) {
+                g_return_val_if_fail (dialog->priv->end_session_dialog_type == type,
+                                      FALSE);
+                return TRUE;
+        }
+
+        if (dialog->priv->end_session_dialog_proxy == NULL) {
+                proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                       G_DBUS_PROXY_FLAGS_NONE,
+                                                       NULL,
+                                                       END_SESSION_DIALOG_NAME,
+                                                       END_SESSION_DIALOG_PATH,
+                                                       END_SESSION_DIALOG_INTERFACE,
+                                                       NULL,
+                                                       &error);
+
+                if (error != NULL) {
+                        g_critical ("Could not connect to the end session dialog: %s",
+                                    error->message);
+                        g_error_free (error);
+                        return FALSE;
+                }
+
+                dialog->priv->end_session_dialog_proxy = proxy;
+
+                g_signal_connect (proxy, "notify::g-name-owner",
+                                  G_CALLBACK (on_end_session_dialog_name_owner_changed),
+                                  dialog);
+                g_signal_connect (proxy, "g-signal",
+                                  G_CALLBACK (on_end_session_dialog_dbus_signal),
+                                  dialog);
+        }
+
+        g_dbus_proxy_call (dialog->priv->end_session_dialog_proxy,
+                           "Open",
+                           g_variant_new ("(uuu ao)",
+                                          type,
+                                          0,
+                                          AUTOMATIC_ACTION_TIMEOUT,
+                                          get_array_from_store (inhibitors)),
+                           G_DBUS_CALL_FLAGS_NONE,
+                           G_MAXINT,
+                           NULL,
+                           on_open_finished,
+                           dialog);
+
+        g_object_ref (inhibitors);
+
+        if (dialog->priv->inhibitors != NULL) {
+                g_signal_handlers_disconnect_by_func (dialog->priv->inhibitors,
+                                                      G_CALLBACK (queue_end_session_dialog_update),
+                                                      dialog);
+                g_object_unref (dialog->priv->inhibitors);
+        }
+
+        dialog->priv->inhibitors = inhibitors;
+
+        g_signal_connect_swapped (inhibitors, "added",
+                                  G_CALLBACK (queue_end_session_dialog_update),
+                                  dialog);
+
+        g_signal_connect_swapped (inhibitors, "removed",
+                                  G_CALLBACK (queue_end_session_dialog_update),
+                                  dialog);
+
+        dialog->priv->dialog_is_open = TRUE;
+        dialog->priv->end_session_dialog_type = type;
+
+        return TRUE;
+}
+
+void
+gsm_end_session_dialog_close (GsmEndSessionDialog *dialog)
+{
+        if (!dialog->priv->end_session_dialog_proxy)
+                return;
+
+        g_dbus_proxy_call (dialog->priv->end_session_dialog_proxy,
+                           "Close",
+                           NULL,
+                           G_DBUS_CALL_FLAGS_NONE,
+                           -1, NULL, NULL, NULL);
+}
diff --git a/gnome-session/gsm-end-session-dialog.h b/gnome-session/gsm-end-session-dialog.h
new file mode 100644
index 0000000..25fb8d7
--- /dev/null
+++ b/gnome-session/gsm-end-session-dialog.h
@@ -0,0 +1,82 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *    Ray Strode <rstrode redhat com>
+ */
+
+#ifndef __GSM_END_SESSION_DIALOG_H__
+#define __GSM_END_SESSION_DIALOG_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "gsm-store.h"
+
+G_BEGIN_DECLS
+
+#define GSM_TYPE_END_SESSION_DIALOG            (gsm_end_session_dialog_get_type ())
+#define GSM_END_SESSION_DIALOG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GSM_TYPE_END_SESSION_DIALOG, GsmEndSessionDialog))
+#define GSM_END_SESSION_DIALOG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), 
GSM_TYPE_END_SESSION_DIALOG, GsmEndSessionDialogClass))
+#define GSM_IS_END_SESSION_DIALOG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
GSM_TYPE_END_SESSION_DIALOG))
+#define GSM_IS_END_SESSION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), 
GSM_TYPE_END_SESSION_DIALOG))
+#define GSM_END_SESSION_DIALOG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), 
GSM_TYPE_END_SESSION_DIALOG, GsmEndSessionDialogClass))
+
+typedef struct _GsmEndSessionDialog        GsmEndSessionDialog;
+typedef struct _GsmEndSessionDialogClass   GsmEndSessionDialogClass;
+typedef struct _GsmEndSessionDialogPrivate GsmEndSessionDialogPrivate;
+
+typedef enum
+{
+    GSM_END_SESSION_DIALOG_TYPE_LOGOUT = 0,
+    GSM_END_SESSION_DIALOG_TYPE_SHUTDOWN,
+    GSM_END_SESSION_DIALOG_TYPE_RESTART
+} GsmEndSessionDialogType;
+
+struct _GsmEndSessionDialog
+{
+        GObject                     parent;
+
+        GsmEndSessionDialogPrivate *priv;
+};
+
+struct _GsmEndSessionDialogClass
+{
+        GObjectClass parent_class;
+
+        void (* end_session_dialog_opened)             (GsmEndSessionDialog *dialog);
+        void (* end_session_dialog_open_failed)        (GsmEndSessionDialog *dialog);
+        void (* end_session_dialog_closed)             (GsmEndSessionDialog *dialog);
+        void (* end_session_dialog_canceled)           (GsmEndSessionDialog *dialog);
+
+        void (* end_session_dialog_confirmed_logout)   (GsmEndSessionDialog *dialog);
+        void (* end_session_dialog_confirmed_shutdown) (GsmEndSessionDialog *dialog);
+        void (* end_session_dialog_confirmed_reboot)   (GsmEndSessionDialog *dialog);
+};
+
+GType                gsm_end_session_dialog_get_type (void);
+
+GsmEndSessionDialog *gsm_end_session_dialog_new      (void);
+
+gboolean             gsm_end_session_dialog_open     (GsmEndSessionDialog     *dialog,
+                                                      GsmEndSessionDialogType  type,
+                                                      GsmStore                *inhibitors);
+void                 gsm_end_session_dialog_close    (GsmEndSessionDialog     *dialog);
+
+G_END_DECLS
+
+#endif /* __GSM_END_SESSION_DIALOG_H__ */
diff --git a/gnome-session/gsm-manager.c b/gnome-session/gsm-manager.c
index 1e6841e..c40110f 100644
--- a/gnome-session/gsm-manager.c
+++ b/gnome-session/gsm-manager.c
@@ -48,6 +48,7 @@
 #include "gsm-inhibitor.h"
 #include "gsm-presence.h"
 #include "gsm-shell.h"
+#include "gsm-end-session-dialog.h"
 
 #include "gsm-xsmp-server.h"
 #include "gsm-xsmp-client.h"
@@ -161,11 +162,13 @@ struct GsmManagerPrivate
         guint                   name_owner_id;
 
         GsmShell               *shell;
-        guint                   shell_end_session_dialog_canceled_id;
-        guint                   shell_end_session_dialog_open_failed_id;
-        guint                   shell_end_session_dialog_confirmed_logout_id;
-        guint                   shell_end_session_dialog_confirmed_shutdown_id;
-        guint                   shell_end_session_dialog_confirmed_reboot_id;
+
+        GsmEndSessionDialog    *end_session_dialog;
+        guint                   end_session_dialog_canceled_id;
+        guint                   end_session_dialog_open_failed_id;
+        guint                   end_session_dialog_confirmed_logout_id;
+        guint                   end_session_dialog_confirmed_shutdown_id;
+        guint                   end_session_dialog_confirmed_reboot_id;
 };
 
 enum {
@@ -196,8 +199,8 @@ static void     _handle_client_end_session_response (GsmManager *manager,
                                                      gboolean    do_last,
                                                      gboolean    cancel,
                                                      const char *reason);
-static void     show_shell_end_session_dialog (GsmManager                   *manager,
-                                               GsmShellEndSessionDialogType  type);
+static void     show_end_session_dialog (GsmManager              *manager,
+                                         GsmEndSessionDialogType  type);
 static gpointer manager_object = NULL;
 
 G_DEFINE_TYPE (GsmManager, gsm_manager, G_TYPE_OBJECT)
@@ -1106,28 +1109,28 @@ cancel_end_session (GsmManager *manager)
 }
 
 static void
-end_session_or_show_shell_dialog (GsmManager *manager)
+end_session_or_show_end_session_dialog (GsmManager *manager)
 {
         gboolean logout_prompt;
-        GsmShellEndSessionDialogType type;
+        GsmEndSessionDialogType type;
         gboolean logout_inhibited;
 
         switch (manager->priv->logout_type) {
         case GSM_MANAGER_LOGOUT_LOGOUT:
-                type = GSM_SHELL_END_SESSION_DIALOG_TYPE_LOGOUT;
+                type = GSM_END_SESSION_DIALOG_TYPE_LOGOUT;
                 break;
         case GSM_MANAGER_LOGOUT_REBOOT:
         case GSM_MANAGER_LOGOUT_REBOOT_INTERACT:
-                type = GSM_SHELL_END_SESSION_DIALOG_TYPE_RESTART;
+                type = GSM_END_SESSION_DIALOG_TYPE_RESTART;
                 break;
         case GSM_MANAGER_LOGOUT_SHUTDOWN:
         case GSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT:
-                type = GSM_SHELL_END_SESSION_DIALOG_TYPE_SHUTDOWN;
+                type = GSM_END_SESSION_DIALOG_TYPE_SHUTDOWN;
                 break;
         default:
                 g_warning ("Unexpected logout type %d when creating end session dialog",
                            manager->priv->logout_type);
-                type = GSM_SHELL_END_SESSION_DIALOG_TYPE_LOGOUT;
+                type = GSM_END_SESSION_DIALOG_TYPE_LOGOUT;
                 break;
         }
 
@@ -1138,7 +1141,7 @@ end_session_or_show_shell_dialog (GsmManager *manager)
         switch (manager->priv->logout_mode) {
         case GSM_MANAGER_LOGOUT_MODE_NORMAL:
                 if (logout_inhibited || logout_prompt) {
-                        show_shell_end_session_dialog (manager, type);
+                        show_end_session_dialog (manager, type);
                 } else {
                         end_phase (manager);
                 }
@@ -1146,7 +1149,7 @@ end_session_or_show_shell_dialog (GsmManager *manager)
 
         case GSM_MANAGER_LOGOUT_MODE_NO_CONFIRMATION:
                 if (logout_inhibited) {
-                        show_shell_end_session_dialog (manager, type);
+                        show_end_session_dialog (manager, type);
                 } else {
                         end_phase (manager);
                 }
@@ -1175,7 +1178,7 @@ query_end_session_complete (GsmManager *manager)
                 manager->priv->query_timeout_id = 0;
         }
 
-        end_session_or_show_shell_dialog (manager);
+        end_session_or_show_end_session_dialog (manager);
 }
 
 static guint32
@@ -2241,6 +2244,7 @@ gsm_manager_dispose (GObject *object)
         g_clear_object (&manager->priv->lockdown_settings);
         g_clear_object (&manager->priv->system);
         g_clear_object (&manager->priv->shell);
+        g_clear_object (&manager->priv->end_session_dialog);
 
         if (manager->priv->name_owner_id != 0) {
                 g_dbus_connection_signal_unsubscribe (manager->priv->connection, 
manager->priv->name_owner_id);;
@@ -3077,7 +3081,7 @@ remove_inhibitors_for_connection (GsmManager *manager,
                                           &data);
         if (count > 0 &&
             manager->priv->phase == GSM_MANAGER_PHASE_QUERY_END_SESSION) {
-                end_session_or_show_shell_dialog (manager);
+                end_session_or_show_end_session_dialog (manager);
         }
 }
 
@@ -3246,6 +3250,8 @@ gsm_manager_init (GsmManager *manager)
                           G_CALLBACK (on_gsm_system_active_changed), manager);
 
         manager->priv->shell = gsm_get_shell ();
+
+        manager->priv->end_session_dialog = gsm_end_session_dialog_new ();
         manager->priv->end_session_cancellable = g_cancellable_new ();
 }
 
@@ -3282,45 +3288,45 @@ gsm_manager_new (GsmStore *client_store,
 }
 
 static void
-disconnect_shell_dialog_signals (GsmManager *manager)
+disconnect_end_session_dialog_signals (GsmManager *manager)
 {
-        if (manager->priv->shell_end_session_dialog_canceled_id != 0) {
-                g_signal_handler_disconnect (manager->priv->shell,
-                                             manager->priv->shell_end_session_dialog_canceled_id);
-                manager->priv->shell_end_session_dialog_canceled_id = 0;
+        if (manager->priv->end_session_dialog_canceled_id != 0) {
+                g_signal_handler_disconnect (manager->priv->end_session_dialog,
+                                             manager->priv->end_session_dialog_canceled_id);
+                manager->priv->end_session_dialog_canceled_id = 0;
         }
 
-        if (manager->priv->shell_end_session_dialog_confirmed_logout_id != 0) {
-                g_signal_handler_disconnect (manager->priv->shell,
-                                             manager->priv->shell_end_session_dialog_confirmed_logout_id);
-                manager->priv->shell_end_session_dialog_confirmed_logout_id = 0;
+        if (manager->priv->end_session_dialog_confirmed_logout_id != 0) {
+                g_signal_handler_disconnect (manager->priv->end_session_dialog,
+                                             manager->priv->end_session_dialog_confirmed_logout_id);
+                manager->priv->end_session_dialog_confirmed_logout_id = 0;
         }
 
-        if (manager->priv->shell_end_session_dialog_confirmed_shutdown_id != 0) {
-                g_signal_handler_disconnect (manager->priv->shell,
-                                             manager->priv->shell_end_session_dialog_confirmed_shutdown_id);
-                manager->priv->shell_end_session_dialog_confirmed_shutdown_id = 0;
+        if (manager->priv->end_session_dialog_confirmed_shutdown_id != 0) {
+                g_signal_handler_disconnect (manager->priv->end_session_dialog,
+                                             manager->priv->end_session_dialog_confirmed_shutdown_id);
+                manager->priv->end_session_dialog_confirmed_shutdown_id = 0;
         }
 
-        if (manager->priv->shell_end_session_dialog_confirmed_reboot_id != 0) {
-                g_signal_handler_disconnect (manager->priv->shell,
-                                             manager->priv->shell_end_session_dialog_confirmed_reboot_id);
-                manager->priv->shell_end_session_dialog_confirmed_reboot_id = 0;
+        if (manager->priv->end_session_dialog_confirmed_reboot_id != 0) {
+                g_signal_handler_disconnect (manager->priv->end_session_dialog,
+                                             manager->priv->end_session_dialog_confirmed_reboot_id);
+                manager->priv->end_session_dialog_confirmed_reboot_id = 0;
         }
 
-        if (manager->priv->shell_end_session_dialog_open_failed_id != 0) {
-                g_signal_handler_disconnect (manager->priv->shell,
-                                             manager->priv->shell_end_session_dialog_open_failed_id);
-                manager->priv->shell_end_session_dialog_open_failed_id = 0;
+        if (manager->priv->end_session_dialog_open_failed_id != 0) {
+                g_signal_handler_disconnect (manager->priv->end_session_dialog,
+                                             manager->priv->end_session_dialog_open_failed_id);
+                manager->priv->end_session_dialog_open_failed_id = 0;
         }
 }
 
 static void
-on_shell_end_session_dialog_canceled (GsmShell   *shell,
-                                      GsmManager *manager)
+on_end_session_dialog_canceled (GsmEndSessionDialog *end_session_dialog,
+                                GsmManager          *manager)
 {
         cancel_end_session (manager);
-        disconnect_shell_dialog_signals (manager);
+        disconnect_end_session_dialog_signals (manager);
 }
 
 static void
@@ -3347,77 +3353,74 @@ _handle_end_session_dialog_response (GsmManager           *manager,
 }
 
 static void
-on_shell_end_session_dialog_confirmed_logout (GsmShell   *shell,
-                                              GsmManager *manager)
+on_end_session_dialog_confirmed_logout (GsmEndSessionDialog *end_session_dialog,
+                                        GsmManager          *manager)
 {
         _handle_end_session_dialog_response (manager, GSM_MANAGER_LOGOUT_LOGOUT);
-        disconnect_shell_dialog_signals (manager);
+        disconnect_end_session_dialog_signals (manager);
 }
 
 static void
-on_shell_end_session_dialog_confirmed_shutdown (GsmShell   *shell,
-                                                GsmManager *manager)
+on_end_session_dialog_confirmed_shutdown (GsmEndSessionDialog *end_session_dialog,
+                                          GsmManager          *manager)
 {
         _handle_end_session_dialog_response (manager, GSM_MANAGER_LOGOUT_SHUTDOWN);
-        disconnect_shell_dialog_signals (manager);
+        disconnect_end_session_dialog_signals (manager);
 }
 
 static void
-on_shell_end_session_dialog_confirmed_reboot (GsmShell   *shell,
-                                              GsmManager *manager)
+on_end_session_dialog_confirmed_reboot (GsmEndSessionDialog *end_session_dialog,
+                                        GsmManager          *manager)
 {
         _handle_end_session_dialog_response (manager, GSM_MANAGER_LOGOUT_REBOOT);
-        disconnect_shell_dialog_signals (manager);
+        disconnect_end_session_dialog_signals (manager);
 }
 
 static void
-connect_shell_dialog_signals (GsmManager *manager)
+connect_end_session_dialog_signals (GsmManager *manager)
 {
-        if (manager->priv->shell_end_session_dialog_canceled_id != 0)
+        if (manager->priv->end_session_dialog_canceled_id != 0)
                 return;
 
-        manager->priv->shell_end_session_dialog_canceled_id =
-                g_signal_connect (manager->priv->shell,
+        manager->priv->end_session_dialog_canceled_id =
+                g_signal_connect (manager->priv->end_session_dialog,
                                   "end-session-dialog-canceled",
-                                  G_CALLBACK (on_shell_end_session_dialog_canceled),
+                                  G_CALLBACK (on_end_session_dialog_canceled),
                                   manager);
 
-        manager->priv->shell_end_session_dialog_open_failed_id =
-                g_signal_connect (manager->priv->shell,
+        manager->priv->end_session_dialog_open_failed_id =
+                g_signal_connect (manager->priv->end_session_dialog,
                                   "end-session-dialog-open-failed",
-                                  G_CALLBACK (on_shell_end_session_dialog_canceled),
+                                  G_CALLBACK (on_end_session_dialog_canceled),
                                   manager);
 
-        manager->priv->shell_end_session_dialog_confirmed_logout_id =
-                g_signal_connect (manager->priv->shell,
+        manager->priv->end_session_dialog_confirmed_logout_id =
+                g_signal_connect (manager->priv->end_session_dialog,
                                   "end-session-dialog-confirmed-logout",
-                                  G_CALLBACK (on_shell_end_session_dialog_confirmed_logout),
+                                  G_CALLBACK (on_end_session_dialog_confirmed_logout),
                                   manager);
 
-        manager->priv->shell_end_session_dialog_confirmed_shutdown_id =
-                g_signal_connect (manager->priv->shell,
+        manager->priv->end_session_dialog_confirmed_shutdown_id =
+                g_signal_connect (manager->priv->end_session_dialog,
                                   "end-session-dialog-confirmed-shutdown",
-                                  G_CALLBACK (on_shell_end_session_dialog_confirmed_shutdown),
+                                  G_CALLBACK (on_end_session_dialog_confirmed_shutdown),
                                   manager);
 
-        manager->priv->shell_end_session_dialog_confirmed_reboot_id =
-                g_signal_connect (manager->priv->shell,
+        manager->priv->end_session_dialog_confirmed_reboot_id =
+                g_signal_connect (manager->priv->end_session_dialog,
                                   "end-session-dialog-confirmed-reboot",
-                                  G_CALLBACK (on_shell_end_session_dialog_confirmed_reboot),
+                                  G_CALLBACK (on_end_session_dialog_confirmed_reboot),
                                   manager);
 }
 
 static void
-show_shell_end_session_dialog (GsmManager                   *manager,
-                               GsmShellEndSessionDialogType  type)
+show_end_session_dialog (GsmManager              *manager,
+                         GsmEndSessionDialogType  type)
 {
-        if (!gsm_shell_is_running (manager->priv->shell))
-                return;
-
-        gsm_shell_open_end_session_dialog (manager->priv->shell,
-                                           type,
-                                           manager->priv->inhibitors);
-        connect_shell_dialog_signals (manager);
+        gsm_end_session_dialog_open (manager->priv->end_session_dialog,
+                                     type,
+                                     manager->priv->inhibitors);
+        connect_end_session_dialog_signals (manager);
 }
 
 /*
@@ -3658,8 +3661,8 @@ on_shutdown_prepared (GsmSystem  *system,
                 manager->priv->phase++;
                 start_phase (manager);
         } else {
-                disconnect_shell_dialog_signals (manager);
-                gsm_shell_close_end_session_dialog (manager->priv->shell);
+                disconnect_end_session_dialog_signals (manager);
+                gsm_end_session_dialog_close (manager->priv->end_session_dialog);
                 /* back to running phase */
                 cancel_end_session (manager);
         }
diff --git a/gnome-session/gsm-shell.c b/gnome-session/gsm-shell.c
index 854ad30..86193a2 100644
--- a/gnome-session/gsm-shell.c
+++ b/gnome-session/gsm-shell.c
@@ -27,32 +27,19 @@
 #include <glib/gi18n.h>
 #include <gio/gio.h>
 
-#include "gsm-inhibitor.h"
 #include "gsm-shell.h"
 
 #define SHELL_NAME      "org.gnome.Shell"
 #define SHELL_PATH      "/org/gnome/Shell"
 #define SHELL_INTERFACE "org.gnome.Shell"
 
-#define SHELL_END_SESSION_DIALOG_PATH      "/org/gnome/SessionManager/EndSessionDialog"
-#define SHELL_END_SESSION_DIALOG_INTERFACE "org.gnome.SessionManager.EndSessionDialog"
-
-#define AUTOMATIC_ACTION_TIMEOUT 60
-
 #define GSM_SHELL_GET_PRIVATE(o)                                   \
         (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_SHELL, GsmShellPrivate))
 
 struct _GsmShellPrivate
 {
-        GDBusProxy      *end_session_dialog_proxy;
-        GsmStore        *inhibitors;
-
         guint32          is_running : 1;
 
-        gboolean         dialog_is_open;
-        GsmShellEndSessionDialogType end_session_dialog_type;
-
-        guint            update_idle_id;
         guint            watch_id;
 };
 
@@ -61,25 +48,10 @@ enum {
         PROP_IS_RUNNING
 };
 
-enum {
-        END_SESSION_DIALOG_OPENED = 0,
-        END_SESSION_DIALOG_OPEN_FAILED,
-        END_SESSION_DIALOG_CLOSED,
-        END_SESSION_DIALOG_CANCELED,
-        END_SESSION_DIALOG_CONFIRMED_LOGOUT,
-        END_SESSION_DIALOG_CONFIRMED_SHUTDOWN,
-        END_SESSION_DIALOG_CONFIRMED_REBOOT,
-        NUMBER_OF_SIGNALS
-};
-
-static guint signals[NUMBER_OF_SIGNALS] = { 0 };
-
 static void     gsm_shell_class_init   (GsmShellClass *klass);
 static void     gsm_shell_init         (GsmShell      *ck);
 static void     gsm_shell_finalize     (GObject            *object);
 
-static void     queue_end_session_dialog_update (GsmShell *shell);
-
 G_DEFINE_TYPE (GsmShell, gsm_shell, G_TYPE_OBJECT);
 
 static void
@@ -123,62 +95,6 @@ gsm_shell_class_init (GsmShellClass *shell_class)
         g_object_class_install_property (object_class, PROP_IS_RUNNING,
                                          param_spec);
 
-        signals [END_SESSION_DIALOG_OPENED] =
-                g_signal_new ("end-session-dialog-opened",
-                              G_OBJECT_CLASS_TYPE (object_class),
-                              G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_opened),
-                              NULL, NULL, NULL,
-                              G_TYPE_NONE, 0);
-
-        signals [END_SESSION_DIALOG_OPEN_FAILED] =
-                g_signal_new ("end-session-dialog-open-failed",
-                              G_OBJECT_CLASS_TYPE (object_class),
-                              G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_open_failed),
-                              NULL, NULL, NULL,
-                              G_TYPE_NONE, 0);
-
-        signals [END_SESSION_DIALOG_CLOSED] =
-                g_signal_new ("end-session-dialog-closed",
-                              G_OBJECT_CLASS_TYPE (object_class),
-                              G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_closed),
-                              NULL, NULL, NULL,
-                              G_TYPE_NONE, 0);
-
-        signals [END_SESSION_DIALOG_CANCELED] =
-                g_signal_new ("end-session-dialog-canceled",
-                              G_OBJECT_CLASS_TYPE (object_class),
-                              G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_canceled),
-                              NULL, NULL, NULL,
-                              G_TYPE_NONE, 0);
-
-        signals [END_SESSION_DIALOG_CONFIRMED_LOGOUT] =
-                g_signal_new ("end-session-dialog-confirmed-logout",
-                              G_OBJECT_CLASS_TYPE (object_class),
-                              G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_confirmed_logout),
-                              NULL, NULL, NULL,
-                              G_TYPE_NONE, 0);
-
-        signals [END_SESSION_DIALOG_CONFIRMED_SHUTDOWN] =
-                g_signal_new ("end-session-dialog-confirmed-shutdown",
-                              G_OBJECT_CLASS_TYPE (object_class),
-                              G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_confirmed_shutdown),
-                              NULL, NULL, NULL,
-                              G_TYPE_NONE, 0);
-
-        signals [END_SESSION_DIALOG_CONFIRMED_REBOOT] =
-                g_signal_new ("end-session-dialog-confirmed-reboot",
-                              G_OBJECT_CLASS_TYPE (object_class),
-                              G_SIGNAL_RUN_LAST,
-                              G_STRUCT_OFFSET (GsmShellClass, end_session_dialog_confirmed_reboot),
-                              NULL, NULL, NULL,
-                              G_TYPE_NONE, 0);
-
         g_type_class_add_private (shell_class, sizeof (GsmShellPrivate));
 }
 
@@ -234,8 +150,6 @@ gsm_shell_finalize (GObject *object)
 
         parent_class = G_OBJECT_CLASS (gsm_shell_parent_class);
 
-        g_object_unref (shell->priv->inhibitors);
-
         if (shell->priv->watch_id != 0) {
                 g_bus_unwatch_name (shell->priv->watch_id);
                 shell->priv->watch_id = 0;
@@ -275,269 +189,3 @@ gsm_shell_is_running (GsmShell *shell)
 
         return shell->priv->is_running;
 }
-
-static gboolean
-add_inhibitor_to_array (const char      *id,
-                        GsmInhibitor    *inhibitor,
-                        GVariantBuilder *builder)
-{
-        g_variant_builder_add (builder, "o", gsm_inhibitor_peek_id (inhibitor));
-        return FALSE;
-}
-
-static GVariant *
-get_array_from_store (GsmStore *inhibitors)
-{
-        GVariantBuilder builder;
-
-        g_variant_builder_init (&builder, G_VARIANT_TYPE ("ao"));
-        gsm_store_foreach (inhibitors,
-                           (GsmStoreFunc) add_inhibitor_to_array,
-                           &builder);
-
-        return g_variant_builder_end (&builder);
-}
-
-static void
-on_open_finished (GObject *source,
-                  GAsyncResult *result,
-                  gpointer user_data)
-{
-        GsmShell *shell = user_data;
-        GError   *error;
-
-        if (shell->priv->update_idle_id != 0) {
-                g_source_remove (shell->priv->update_idle_id);
-                shell->priv->update_idle_id = 0;
-        }
-
-        shell->priv->dialog_is_open = FALSE;
-
-        error = NULL;
-        g_dbus_proxy_call_finish (G_DBUS_PROXY (source), result, &error);
-
-        if (error != NULL) {
-                g_warning ("Unable to open shell end session dialog: %s", error->message);
-                g_error_free (error);
-
-                g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_OPEN_FAILED], 0);
-                return;
-        }
-
-        g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_OPENED], 0);
-}
-
-static void
-on_end_session_dialog_closed (GsmShell *shell)
-{
-        if (shell->priv->update_idle_id != 0) {
-                g_source_remove (shell->priv->update_idle_id);
-                shell->priv->update_idle_id = 0;
-        }
-
-        g_signal_handlers_disconnect_by_func (shell->priv->inhibitors,
-                                              G_CALLBACK (queue_end_session_dialog_update),
-                                              shell);
-
-        g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_CLOSED], 0);
-}
-
-static void
-on_end_session_dialog_canceled (GsmShell *shell)
-{
-        if (shell->priv->update_idle_id != 0) {
-                g_source_remove (shell->priv->update_idle_id);
-                shell->priv->update_idle_id = 0;
-        }
-
-        g_signal_handlers_disconnect_by_func (shell->priv->inhibitors,
-                                              G_CALLBACK (queue_end_session_dialog_update),
-                                              shell);
-
-        g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_CANCELED], 0);
-}
-
-static void
-on_end_session_dialog_confirmed_logout (GsmShell *shell)
-{
-        if (shell->priv->update_idle_id != 0) {
-                g_source_remove (shell->priv->update_idle_id);
-                shell->priv->update_idle_id = 0;
-        }
-
-        g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_CONFIRMED_LOGOUT], 0);
-}
-
-static void
-on_end_session_dialog_confirmed_shutdown (GsmShell *shell)
-{
-        if (shell->priv->update_idle_id != 0) {
-                g_source_remove (shell->priv->update_idle_id);
-                shell->priv->update_idle_id = 0;
-        }
-
-        g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_CONFIRMED_SHUTDOWN], 0);
-}
-
-static void
-on_end_session_dialog_confirmed_reboot (GsmShell   *shell)
-{
-        if (shell->priv->update_idle_id != 0) {
-                g_source_remove (shell->priv->update_idle_id);
-                shell->priv->update_idle_id = 0;
-        }
-
-        g_signal_emit (G_OBJECT (shell), signals[END_SESSION_DIALOG_CONFIRMED_REBOOT], 0);
-}
-
-static void
-on_end_session_dialog_dbus_signal (GDBusProxy *proxy,
-                                   gchar      *sender_name,
-                                   gchar      *signal_name,
-                                   GVariant   *parameters,
-                                   GsmShell   *shell)
-{
-        if (g_strcmp0 (signal_name, "Closed") == 0) {
-                on_end_session_dialog_closed (shell);
-        } else if (g_strcmp0 (signal_name, "Canceled") == 0) {
-                on_end_session_dialog_canceled (shell);
-        } else if (g_strcmp0 (signal_name ,"ConfirmedLogout") == 0) {
-                on_end_session_dialog_confirmed_logout (shell);
-        } else if (g_strcmp0 (signal_name ,"ConfirmedReboot") == 0) {
-                on_end_session_dialog_confirmed_reboot (shell);
-        } else if (g_strcmp0 (signal_name ,"ConfirmedShutdown") == 0) {
-                on_end_session_dialog_confirmed_shutdown (shell);
-        }
-}
-
-static void
-on_end_session_dialog_name_owner_changed (GDBusProxy *proxy,
-                                          GParamSpec *pspec,
-                                          GsmShell   *shell)
-{
-        gchar *name_owner;
-
-        name_owner = g_dbus_proxy_get_name_owner (proxy);
-        if (name_owner == NULL) {
-                g_clear_object (&shell->priv->end_session_dialog_proxy);
-        }
-
-        g_free (name_owner);
-}
-
-static gboolean
-on_need_end_session_dialog_update (GsmShell *shell)
-{
-        /* No longer need an update */
-        if (shell->priv->update_idle_id == 0)
-                return FALSE;
-
-        shell->priv->update_idle_id = 0;
-
-        gsm_shell_open_end_session_dialog (shell,
-                                           shell->priv->end_session_dialog_type,
-                                           shell->priv->inhibitors);
-        return FALSE;
-}
-
-static void
-queue_end_session_dialog_update (GsmShell *shell)
-{
-        if (shell->priv->update_idle_id != 0)
-                return;
-
-        shell->priv->update_idle_id = g_idle_add ((GSourceFunc) on_need_end_session_dialog_update,
-                                                  shell);
-}
-
-gboolean
-gsm_shell_open_end_session_dialog (GsmShell *shell,
-                                   GsmShellEndSessionDialogType type,
-                                   GsmStore *inhibitors)
-{
-        GDBusProxy *proxy;
-        GError *error;
-
-        error = NULL;
-
-        if (shell->priv->dialog_is_open) {
-                g_return_val_if_fail (shell->priv->end_session_dialog_type == type,
-                                      FALSE);
-
-                return TRUE;
-        }
-
-        if (shell->priv->end_session_dialog_proxy == NULL) {
-                proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
-                                                       G_DBUS_PROXY_FLAGS_NONE,
-                                                       NULL,
-                                                       SHELL_NAME,
-                                                       SHELL_END_SESSION_DIALOG_PATH,
-                                                       SHELL_END_SESSION_DIALOG_INTERFACE,
-                                                       NULL, &error);
-
-                if (error != NULL) {
-                        g_critical ("Could not connect to the shell: %s",
-                                    error->message);
-                        g_error_free (error);
-                        return FALSE;
-                }
-
-                shell->priv->end_session_dialog_proxy = proxy;
-
-                g_signal_connect (proxy, "notify::g-name-owner",
-                                  G_CALLBACK (on_end_session_dialog_name_owner_changed),
-                                  shell);
-                g_signal_connect (proxy, "g-signal",
-                                  G_CALLBACK (on_end_session_dialog_dbus_signal),
-                                  shell);
-        }
-
-        g_dbus_proxy_call (shell->priv->end_session_dialog_proxy,
-                           "Open",
-                           g_variant_new ("(uuu ao)",
-                                          type,
-                                          0,
-                                          AUTOMATIC_ACTION_TIMEOUT,
-                                          get_array_from_store (inhibitors)),
-                           G_DBUS_CALL_FLAGS_NONE,
-                           G_MAXINT, NULL,
-                           on_open_finished, shell);
-
-        g_object_ref (inhibitors);
-
-        if (shell->priv->inhibitors != NULL) {
-                g_signal_handlers_disconnect_by_func (shell->priv->inhibitors,
-                                                      G_CALLBACK (queue_end_session_dialog_update),
-                                                      shell);
-                g_object_unref (shell->priv->inhibitors);
-        }
-
-        shell->priv->inhibitors = inhibitors;
-
-        g_signal_connect_swapped (inhibitors, "added",
-                                  G_CALLBACK (queue_end_session_dialog_update),
-                                  shell);
-
-        g_signal_connect_swapped (inhibitors, "removed",
-                                  G_CALLBACK (queue_end_session_dialog_update),
-                                  shell);
-
-        shell->priv->dialog_is_open = TRUE;
-        shell->priv->end_session_dialog_type = type;
-
-        return TRUE;
-}
-
-void
-gsm_shell_close_end_session_dialog (GsmShell *shell)
-{
-        if (!shell->priv->end_session_dialog_proxy)
-                return;
-
-        g_dbus_proxy_call (shell->priv->end_session_dialog_proxy,
-                           "Close",
-                           NULL,
-                           G_DBUS_CALL_FLAGS_NONE,
-                           -1, NULL, NULL, NULL);
-}
diff --git a/gnome-session/gsm-shell.h b/gnome-session/gsm-shell.h
index e236493..ef28f22 100644
--- a/gnome-session/gsm-shell.h
+++ b/gnome-session/gsm-shell.h
@@ -41,13 +41,6 @@ typedef struct _GsmShell        GsmShell;
 typedef struct _GsmShellClass   GsmShellClass;
 typedef struct _GsmShellPrivate GsmShellPrivate;
 
-typedef enum
-{
-    GSM_SHELL_END_SESSION_DIALOG_TYPE_LOGOUT = 0,
-    GSM_SHELL_END_SESSION_DIALOG_TYPE_SHUTDOWN,
-    GSM_SHELL_END_SESSION_DIALOG_TYPE_RESTART,
-} GsmShellEndSessionDialogType;
-
 struct _GsmShell
 {
         GObject               parent;
@@ -59,15 +52,6 @@ struct _GsmShellClass
 {
         GObjectClass parent_class;
 
-        void (* end_session_dialog_opened)        (GsmShell *shell);
-        void (* end_session_dialog_open_failed)   (GsmShell *shell);
-        void (* end_session_dialog_closed)        (GsmShell *shell);
-        void (* end_session_dialog_canceled)      (GsmShell *shell);
-
-        void (* end_session_dialog_confirmed_logout)   (GsmShell *shell);
-        void (* end_session_dialog_confirmed_shutdown) (GsmShell *shell);
-        void (* end_session_dialog_confirmed_reboot)   (GsmShell *shell);
-
 };
 
 GType            gsm_shell_get_type           (void);
@@ -77,11 +61,6 @@ GsmShell        *gsm_shell_new                (void);
 GsmShell        *gsm_get_shell                (void);
 gboolean         gsm_shell_is_running         (GsmShell *shell);
 
-gboolean         gsm_shell_open_end_session_dialog (GsmShell *shell,
-                                                    GsmShellEndSessionDialogType type,
-                                                    GsmStore *inhibitors);
-void             gsm_shell_close_end_session_dialog (GsmShell *shell);
-
 G_END_DECLS
 
 #endif /* __GSM_SHELL_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]