[gnome-session] Stop connecting to the X11 server



commit 705699b2799a3434d1a8f35c9a92868a5057f73e
Author: Giovanni Campagna <gcampagn redhat com>
Date:   Tue Aug 20 11:10:52 2013 +0200

    Stop connecting to the X11 server
    
    Remove all GTK+ code from the main gnome-session binary (including
    the two fallback mode dialogs), so that gnome-session can run
    when X is not available.
    
    These dialogs are no longer used anymore, so it's not a UI freeze
    break.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=706420

 configure.ac                       |    1 -
 data/Makefile.am                   |    3 +-
 data/gsm-inhibit-dialog.ui         |   63 ---
 gnome-session/Makefile.am          |    7 +-
 gnome-session/gsm-inhibit-dialog.c |  981 ------------------------------------
 gnome-session/gsm-inhibit-dialog.h |   70 ---
 gnome-session/gsm-logout-dialog.c  |  475 -----------------
 gnome-session/gsm-logout-dialog.h  |   80 ---
 gnome-session/gsm-manager.c        |  525 +-------------------
 gnome-session/gsm-util.h           |    2 +
 gnome-session/main.c               |   51 ++-
 po/POTFILES.in                     |    3 -
 12 files changed, 50 insertions(+), 2211 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2396218..caa83fb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -63,7 +63,6 @@ PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= $GTK3_REQUIRED)
 PKG_CHECK_MODULES(GNOME_SESSION,
         glib-2.0 >= $GLIB_REQUIRED
         gio-2.0 >= $GLIB_REQUIRED
-        gtk+-3.0 >= $GTK3_REQUIRED
         dbus-glib-1 >= $DBUS_GLIB_REQUIRED
         upower-glib >= $UPOWER_REQUIRED
         json-glib-1.0 >= $JSON_GLIB_REQUIRED
diff --git a/data/Makefile.am b/data/Makefile.am
index 1f330cb..16926f9 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -2,8 +2,7 @@ SUBDIRS = icons
 
 uidir = $(pkgdatadir)
 ui_DATA = \
-       session-properties.ui   \
-       gsm-inhibit-dialog.ui
+       session-properties.ui
 
 if BUILD_SESSION_SELECTOR
 ui_DATA += session-selector.ui
diff --git a/gnome-session/Makefile.am b/gnome-session/Makefile.am
index 8d6835f..6392653 100644
--- a/gnome-session/Makefile.am
+++ b/gnome-session/Makefile.am
@@ -8,6 +8,7 @@ noinst_PROGRAMS =               \
        test-process-helper
 
 AM_CPPFLAGS =                                  \
+       $(GTK3_CFLAGS)                          \
        $(GNOME_SESSION_CFLAGS)                 \
        $(DISABLE_DEPRECATED_CFLAGS)
 
@@ -32,10 +33,6 @@ gnome_session_SOURCES =                              \
        gsm-consolekit.h                        \
        gsm-systemd.h                           \
        gsm-systemd.c                           \
-       gsm-logout-dialog.h                     \
-       gsm-logout-dialog.c                     \
-       gsm-inhibit-dialog.h                    \
-       gsm-inhibit-dialog.c                    \
        gsm-presence.h                          \
        gsm-presence-flag.h                     \
        gsm-presence.c                          \
@@ -118,7 +115,7 @@ gnome_session_failed_LDADD =   \
        $(GTK3_LIBS)
 
 test_inhibit_SOURCES = test-inhibit.c
-test_inhibit_LDADD = $(GNOME_SESSION_LIBS)
+test_inhibit_LDADD = $(GTK3_LIBS) $(GNOME_SESSION_LIBS)
 
 test_client_dbus_SOURCES = test-client-dbus.c
 test_client_dbus_LDADD = $(DBUS_GLIB_LIBS)
diff --git a/gnome-session/gsm-manager.c b/gnome-session/gsm-manager.c
index 5d36e1f..7854477 100644
--- a/gnome-session/gsm-manager.c
+++ b/gnome-session/gsm-manager.c
@@ -36,11 +36,10 @@
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
 #include <glib-object.h>
+#include <gio/gio.h>
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 
-#include <gtk/gtk.h> /* for logout dialog */
-
 #include "gsm-manager.h"
 #include "gsm-manager-glue.h"
 
@@ -60,9 +59,7 @@
 #include "gsm-autostart-app.h"
 
 #include "gsm-util.h"
-#include "gsm-logout-dialog.h"
 #include "gsm-icon-names.h"
-#include "gsm-inhibit-dialog.h"
 #include "gsm-system.h"
 #include "gsm-session-save.h"
 #include "gsm-shell-extensions.h"
@@ -147,8 +144,6 @@ struct GsmManagerPrivate
         /* This is the action that will be done just before we exit */
         GsmManagerLogoutType    logout_type;
 
-        GtkWidget              *inhibit_dialog;
-
         /* List of clients which were disconnected due to disabled condition
          * and shouldn't be automatically restarted */
         GSList                 *condition_clients;
@@ -204,7 +199,6 @@ static gboolean auto_save_is_enabled (GsmManager *manager);
 static void     maybe_save_session   (GsmManager *manager);
 
 static gboolean _log_out_is_locked_down     (GsmManager *manager);
-static gboolean _switch_user_is_locked_down (GsmManager *manager);
 
 static void     _handle_client_end_session_response (GsmManager *manager,
                                                      GsmClient  *client,
@@ -1074,13 +1068,6 @@ cancel_end_session (GsmManager *manager)
 
         g_cancellable_cancel (manager->priv->end_session_cancellable);
 
-        /* remove the dialog before we remove the inhibitors, else the dialog
-         * will activate itself automatically when the last inhibitor will be
-         * removed */
-        if (manager->priv->inhibit_dialog)
-                gtk_widget_destroy (GTK_WIDGET (manager->priv->inhibit_dialog));
-        manager->priv->inhibit_dialog = NULL;
-
         /* clear all JIT inhibitors */
         gsm_store_foreach_remove (manager->priv->inhibitors,
                                   (GsmStoreFunc)inhibitor_is_jit,
@@ -1098,214 +1085,6 @@ cancel_end_session (GsmManager *manager)
         start_phase (manager);
 }
 
-
-static void
-manager_switch_user (GdkDisplay *display,
-                     GsmManager *manager)
-{
-        GError  *error;
-        char    *command;
-        GAppLaunchContext *context;
-        GAppInfo *app;
-
-       /* We have to do this here and in request_switch_user() because this
-        * function can be called at a later time, not just directly after
-        * request_switch_user(). */
-       if (_switch_user_is_locked_down (manager)) {
-               g_warning ("Unable to switch user: User switching has been locked down");
-               return;
-       }
-
-        command = g_strdup_printf ("%s %s",
-                                   GDM_FLEXISERVER_COMMAND,
-                                   GDM_FLEXISERVER_ARGS);
-
-        error = NULL;
-        context = (GAppLaunchContext*) gdk_display_get_app_launch_context (display);
-        app = g_app_info_create_from_commandline (command, GDM_FLEXISERVER_COMMAND, 0, &error);
-
-        if (app) {
-                g_app_info_launch (app, NULL, context, &error);
-                g_object_unref (app);
-        }
-
-        g_free (command);
-        g_object_unref (context);
-
-        if (error) {
-                g_debug ("GsmManager: Unable to start GDM greeter: %s", error->message);
-                g_error_free (error);
-        }
-}
-
-static gboolean
-sleep_lock_is_enabled (GsmManager *manager)
-{
-        return g_settings_get_boolean (manager->priv->screensaver_settings,
-                                       KEY_SLEEP_LOCK);
-}
-
-static void
-manager_perhaps_lock (GsmManager *manager)
-{
-        GError   *error;
-        gboolean  ret;
-
-        /* only lock if gnome-screensaver is set to lock */
-        if (!sleep_lock_is_enabled (manager)) {
-                return;
-        }
-
-        /* do this sync to ensure it's on the screen when we start suspending */
-        error = NULL;
-        ret = g_spawn_command_line_sync ("gnome-screensaver-command --lock", NULL, NULL, NULL, &error);
-        if (!ret) {
-                g_warning ("Couldn't lock screen: %s", error->message);
-                g_error_free (error);
-        }
-}
-
-static void
-manager_attempt_hibernate (GsmManager *manager)
-{
-        if (gsm_system_can_hibernate (manager->priv->system)) {
-                /* lock the screen before we suspend */
-                manager_perhaps_lock (manager);
-                gsm_system_hibernate (manager->priv->system);
-        }
-}
-
-static void
-manager_attempt_suspend (GsmManager *manager)
-{
-        if (gsm_system_can_suspend (manager->priv->system)) {
-                /* lock the screen before we suspend */
-                manager_perhaps_lock (manager);
-                gsm_system_suspend (manager->priv->system);
-        }
-}
-
-static void
-do_inhibit_dialog_action (GdkDisplay *display,
-                          GsmManager *manager,
-                          int         action)
-{
-        switch (action) {
-        case GSM_LOGOUT_ACTION_SWITCH_USER:
-                manager_switch_user (display, manager);
-                break;
-        case GSM_LOGOUT_ACTION_HIBERNATE:
-                manager_attempt_hibernate (manager);
-                break;
-        case GSM_LOGOUT_ACTION_SLEEP:
-                manager_attempt_suspend (manager);
-                break;
-        case GSM_LOGOUT_ACTION_SHUTDOWN:
-        case GSM_LOGOUT_ACTION_REBOOT:
-        case GSM_LOGOUT_ACTION_LOGOUT:
-                manager->priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_FORCE;
-                end_phase (manager);
-                break;
-        default:
-                g_assert_not_reached ();
-                break;
-        }
-}
-
-static void
-inhibit_dialog_response (GsmInhibitDialog *dialog,
-                         guint             response_id,
-                         GsmManager       *manager)
-{
-        GdkDisplay *display;
-        int action;
-
-        g_debug ("GsmManager: Inhibit dialog response: %d", response_id);
-
-        display = gtk_widget_get_display (GTK_WIDGET (dialog));
-
-        /* must destroy dialog before cancelling since we'll
-           remove JIT inhibitors and we don't want to trigger
-           action. */
-        g_object_get (dialog, "action", &action, NULL);
-        gtk_widget_destroy (GTK_WIDGET (dialog));
-        manager->priv->inhibit_dialog = NULL;
-
-        /* In case of dialog cancel, switch user, hibernate and
-         * suspend, we just perform the respective action and return,
-         * without shutting down the session. */
-        switch (response_id) {
-        case GTK_RESPONSE_CANCEL:
-        case GTK_RESPONSE_NONE:
-        case GTK_RESPONSE_DELETE_EVENT:
-                if (action == GSM_LOGOUT_ACTION_LOGOUT
-                    || action == GSM_LOGOUT_ACTION_SHUTDOWN
-                    || action == GSM_LOGOUT_ACTION_REBOOT) {
-                        cancel_end_session (manager);
-                }
-                break;
-        case GTK_RESPONSE_ACCEPT:
-                g_debug ("GsmManager: doing action %d", action);
-                do_inhibit_dialog_action (display, manager, action);
-                break;
-        default:
-                g_assert_not_reached ();
-                break;
-        }
-}
-
-static void
-end_session_or_show_fallback_dialog (GsmManager *manager)
-{
-        GsmLogoutAction action;
-
-        if (! gsm_manager_is_logout_inhibited (manager)) {
-                end_phase (manager);
-                return;
-        }
-
-        if (manager->priv->inhibit_dialog != NULL) {
-                g_debug ("GsmManager: inhibit dialog already up");
-                gtk_window_present (GTK_WINDOW (manager->priv->inhibit_dialog));
-                return;
-        }
-
-        switch (manager->priv->logout_type) {
-        case GSM_MANAGER_LOGOUT_LOGOUT:
-                action = GSM_LOGOUT_ACTION_LOGOUT;
-                break;
-        case GSM_MANAGER_LOGOUT_REBOOT:
-        case GSM_MANAGER_LOGOUT_REBOOT_INTERACT:
-        case GSM_MANAGER_LOGOUT_REBOOT_GDM:
-                action = GSM_LOGOUT_ACTION_REBOOT;
-                break;
-        case GSM_MANAGER_LOGOUT_SHUTDOWN:
-        case GSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT:
-        case GSM_MANAGER_LOGOUT_SHUTDOWN_GDM:
-                action = GSM_LOGOUT_ACTION_SHUTDOWN;
-                break;
-        default:
-                g_warning ("Unexpected logout type %d when creating inhibit dialog",
-                           manager->priv->logout_type);
-                action = GSM_LOGOUT_ACTION_LOGOUT;
-                break;
-        }
-
-        /* Note: GSM_LOGOUT_ACTION_SHUTDOWN and GSM_LOGOUT_ACTION_REBOOT are
-         * actually handled the same way as GSM_LOGOUT_ACTION_LOGOUT in the
-         * inhibit dialog; the action, if the button is clicked, will be to
-         * simply go to the next phase. */
-        manager->priv->inhibit_dialog = gsm_inhibit_dialog_new (manager->priv->inhibitors,
-                                                                manager->priv->clients,
-                                                                action);
-
-        g_signal_connect (manager->priv->inhibit_dialog,
-                          "response",
-                          G_CALLBACK (inhibit_dialog_response),
-                          manager);
-        gtk_widget_show (manager->priv->inhibit_dialog);
-}
-
 static void
 end_session_or_show_shell_dialog (GsmManager *manager)
 {
@@ -1376,12 +1155,7 @@ query_end_session_complete (GsmManager *manager)
                 manager->priv->query_timeout_id = 0;
         }
 
-        if (gsm_shell_is_running (manager->priv->shell)) {
-                end_session_or_show_shell_dialog (manager);
-        } else {
-                end_session_or_show_fallback_dialog (manager);
-        }
-
+        end_session_or_show_shell_dialog (manager);
 }
 
 static guint32
@@ -1942,11 +1716,7 @@ remove_inhibitors_for_connection (GsmManager *manager,
                                           &data);
         if (count > 0 &&
             manager->priv->phase == GSM_MANAGER_PHASE_QUERY_END_SESSION) {
-                if (gsm_shell_is_running (manager->priv->shell)) {
-                        end_session_or_show_shell_dialog (manager);
-                } else {
-                        end_session_or_show_fallback_dialog (manager);
-                }
+                end_session_or_show_shell_dialog (manager);
         }
 }
 
@@ -3035,42 +2805,6 @@ gsm_manager_initialization_error (GsmManager  *manager,
         return TRUE;
 }
 
-static gboolean
-gsm_manager_is_switch_user_inhibited (GsmManager *manager)
-{
-        GsmInhibitor *inhibitor;
-
-        if (manager->priv->inhibitors == NULL) {
-                return FALSE;
-        }
-
-        inhibitor = (GsmInhibitor *)gsm_store_find (manager->priv->inhibitors,
-                                                    (GsmStoreFunc)inhibitor_has_flag,
-                                                    GUINT_TO_POINTER (GSM_INHIBITOR_FLAG_SWITCH_USER));
-        if (inhibitor == NULL) {
-                return FALSE;
-        }
-        return TRUE;
-}
-
-static gboolean
-gsm_manager_is_suspend_inhibited (GsmManager *manager)
-{
-        GsmInhibitor *inhibitor;
-
-        if (manager->priv->inhibitors == NULL) {
-                return FALSE;
-        }
-
-        inhibitor = (GsmInhibitor *)gsm_store_find (manager->priv->inhibitors,
-                                                    (GsmStoreFunc)inhibitor_has_flag,
-                                                    GUINT_TO_POINTER (GSM_INHIBITOR_FLAG_SUSPEND));
-        if (inhibitor == NULL) {
-                return FALSE;
-        }
-        return TRUE;
-}
-
 static void
 request_reboot (GsmManager *manager)
 {
@@ -3097,62 +2831,6 @@ request_shutdown (GsmManager *manager)
 }
 
 static void
-request_suspend (GsmManager *manager)
-{
-        g_debug ("GsmManager: requesting suspend");
-
-        if (! gsm_manager_is_suspend_inhibited (manager)) {
-                manager_attempt_suspend (manager);
-                return;
-        }
-
-        if (manager->priv->inhibit_dialog != NULL) {
-                g_debug ("GsmManager: inhibit dialog already up");
-                gtk_window_present (GTK_WINDOW (manager->priv->inhibit_dialog));
-                return;
-        }
-
-        manager->priv->inhibit_dialog = gsm_inhibit_dialog_new (manager->priv->inhibitors,
-                                                                manager->priv->clients,
-                                                                GSM_LOGOUT_ACTION_SLEEP);
-
-        g_signal_connect (manager->priv->inhibit_dialog,
-                          "response",
-                          G_CALLBACK (inhibit_dialog_response),
-                          manager);
-        gtk_widget_show (manager->priv->inhibit_dialog);
-}
-
-static void
-request_hibernate (GsmManager *manager)
-{
-        g_debug ("GsmManager: requesting hibernate");
-
-        /* hibernate uses suspend inhibit */
-        if (! gsm_manager_is_suspend_inhibited (manager)) {
-                manager_attempt_hibernate (manager);
-                return;
-        }
-
-        if (manager->priv->inhibit_dialog != NULL) {
-                g_debug ("GsmManager: inhibit dialog already up");
-                gtk_window_present (GTK_WINDOW (manager->priv->inhibit_dialog));
-                return;
-        }
-
-        manager->priv->inhibit_dialog = gsm_inhibit_dialog_new (manager->priv->inhibitors,
-                                                                manager->priv->clients,
-                                                                GSM_LOGOUT_ACTION_HIBERNATE);
-
-        g_signal_connect (manager->priv->inhibit_dialog,
-                          "response",
-                          G_CALLBACK (inhibit_dialog_response),
-                          manager);
-        gtk_widget_show (manager->priv->inhibit_dialog);
-}
-
-
-static void
 request_logout (GsmManager           *manager,
                 GsmManagerLogoutMode  mode)
 {
@@ -3165,146 +2843,6 @@ request_logout (GsmManager           *manager,
 }
 
 static void
-request_switch_user (GdkDisplay *display,
-                     GsmManager *manager)
-{
-        g_debug ("GsmManager: requesting user switch");
-
-       /* See comment in manager_switch_user() to understand why we do this in
-        * both functions. */
-       if (_switch_user_is_locked_down (manager)) {
-               g_warning ("Unable to switch user: User switching has been locked down");
-               return;
-       }
-
-        if (! gsm_manager_is_switch_user_inhibited (manager)) {
-                manager_switch_user (display, manager);
-                return;
-        }
-
-        if (manager->priv->inhibit_dialog != NULL) {
-                g_debug ("GsmManager: inhibit dialog already up");
-                gtk_window_present (GTK_WINDOW (manager->priv->inhibit_dialog));
-                return;
-        }
-
-        manager->priv->inhibit_dialog = gsm_inhibit_dialog_new (manager->priv->inhibitors,
-                                                                manager->priv->clients,
-                                                                GSM_LOGOUT_ACTION_SWITCH_USER);
-
-        g_signal_connect (manager->priv->inhibit_dialog,
-                          "response",
-                          G_CALLBACK (inhibit_dialog_response),
-                          manager);
-        gtk_widget_show (manager->priv->inhibit_dialog);
-}
-
-static void
-logout_dialog_response (GsmLogoutDialog *logout_dialog,
-                        guint            response_id,
-                        GsmManager      *manager)
-{
-        GdkDisplay *display;
-
-        /* We should only be here if mode has already have been set from
-         * show_fallback_shutdown/logout_dialog
-         */
-        g_assert (manager->priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_NORMAL);
-
-        g_debug ("GsmManager: Logout dialog response: %d", response_id);
-
-        display = gtk_widget_get_display (GTK_WIDGET (logout_dialog));
-
-        gtk_widget_destroy (GTK_WIDGET (logout_dialog));
-
-        /* In case of dialog cancel, switch user, hibernate and
-         * suspend, we just perform the respective action and return,
-         * without shutting down the session. */
-        switch (response_id) {
-        case GTK_RESPONSE_CANCEL:
-        case GTK_RESPONSE_NONE:
-        case GTK_RESPONSE_DELETE_EVENT:
-                break;
-        case GSM_LOGOUT_RESPONSE_SWITCH_USER:
-                request_switch_user (display, manager);
-                break;
-        case GSM_LOGOUT_RESPONSE_HIBERNATE:
-                request_hibernate (manager);
-                break;
-        case GSM_LOGOUT_RESPONSE_SLEEP:
-                request_suspend (manager);
-                break;
-        case GSM_LOGOUT_RESPONSE_SHUTDOWN:
-                request_shutdown (manager);
-                break;
-        case GSM_LOGOUT_RESPONSE_REBOOT:
-                request_reboot (manager);
-                break;
-        case GSM_LOGOUT_RESPONSE_LOGOUT:
-                /* We've already gotten confirmation from the user so
-                 * initiate the logout in NO_CONFIRMATION mode.
-                 *
-                 * (it shouldn't matter whether we use NO_CONFIRMATION or stay
-                 * with NORMAL, unless the shell happens to start after the
-                 * user confirmed)
-                 */
-                request_logout (manager, GSM_MANAGER_LOGOUT_MODE_NO_CONFIRMATION);
-                break;
-        default:
-                g_assert_not_reached ();
-                break;
-        }
-}
-
-static void
-show_fallback_shutdown_dialog (GsmManager *manager,
-                               gboolean    is_reboot)
-{
-        GtkWidget *dialog;
-
-        if (manager->priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) {
-                /* Already shutting down, nothing more to do */
-                return;
-        }
-
-        manager->priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_NORMAL;
-
-        dialog = gsm_get_shutdown_dialog (gdk_screen_get_default (),
-                                          gtk_get_current_event_time (),
-                                          is_reboot ?
-                                          GSM_DIALOG_LOGOUT_TYPE_REBOOT :
-                                          GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN);
-
-        g_signal_connect (dialog,
-                          "response",
-                          G_CALLBACK (logout_dialog_response),
-                          manager);
-        gtk_widget_show (dialog);
-}
-
-static void
-show_fallback_logout_dialog (GsmManager *manager)
-{
-        GtkWidget *dialog;
-
-        if (manager->priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) {
-                /* Already shutting down, nothing more to do */
-                return;
-        }
-
-        manager->priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_NORMAL;
-
-        dialog = gsm_get_logout_dialog (gdk_screen_get_default (),
-                                        gtk_get_current_event_time ());
-
-        g_signal_connect (dialog,
-                          "response",
-                          G_CALLBACK (logout_dialog_response),
-                          manager);
-        gtk_widget_show (dialog);
-}
-
-static void
 disconnect_shell_dialog_signals (GsmManager *manager)
 {
         if (manager->priv->shell_end_session_dialog_canceled_id != 0) {
@@ -3447,30 +2985,12 @@ static void
 user_logout (GsmManager           *manager,
              GsmManagerLogoutMode  mode)
 {
-        gboolean logout_prompt;
-        gboolean shell_running;
-
         if (manager->priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) {
                 /* Already shutting down, nothing more to do */
                 return;
         }
 
-        shell_running = gsm_shell_is_running (manager->priv->shell);
-        logout_prompt = g_settings_get_boolean (manager->priv->settings,
-                                                KEY_LOGOUT_PROMPT);
-
-        /* If the shell isn't running, and this isn't a non-interative logout request,
-         * and the user has their settings configured to show a confirmation dialog for
-         * logout, then go ahead and show the fallback confirmation dialog now.
-         *
-         * If the shell is running, then the confirmation dialog and inhibitor dialog are
-         * combined, so we'll show it at a later stage in the logout process.
-         */
-        if (!shell_running && mode == GSM_MANAGER_LOGOUT_MODE_NORMAL && logout_prompt) {
-                show_fallback_logout_dialog (manager);
-        } else {
-                request_logout (manager, mode);
-        }
+        request_logout (manager, mode);
 }
 
 /*
@@ -3496,13 +3016,6 @@ _log_out_is_locked_down (GsmManager *manager)
                                        KEY_DISABLE_LOG_OUT);
 }
 
-static gboolean
-_switch_user_is_locked_down (GsmManager *manager)
-{
-        return g_settings_get_boolean (manager->priv->lockdown_settings,
-                                       KEY_DISABLE_USER_SWITCHING);
-}
-
 static void
 complete_end_session_task (GsmManager            *manager,
                            GAsyncResult          *result,
@@ -3521,7 +3034,6 @@ gsm_manager_shutdown (GsmManager            *manager,
                       DBusGMethodInvocation *context)
 {
         GTask *task;
-        gboolean shell_running;
         GError *error = NULL;
 
         g_debug ("GsmManager: Shutdown called");
@@ -3551,12 +3063,7 @@ gsm_manager_shutdown (GsmManager            *manager,
         manager->priv->pending_end_session_tasks = g_slist_prepend (manager->priv->pending_end_session_tasks,
                                                                     task);
 
-        shell_running = gsm_shell_is_running (manager->priv->shell);
-
-        if (!shell_running)
-                show_fallback_shutdown_dialog (manager, FALSE);
-        else
-                request_shutdown (manager);
+        request_shutdown (manager);
 
         return TRUE;
 }
@@ -3566,7 +3073,6 @@ gsm_manager_reboot (GsmManager            *manager,
                     DBusGMethodInvocation *context)
 {
         GTask *task;
-        gboolean shell_running;
         GError *error = NULL;
 
         g_debug ("GsmManager: Reboot called");
@@ -3596,12 +3102,7 @@ gsm_manager_reboot (GsmManager            *manager,
         manager->priv->pending_end_session_tasks = g_slist_prepend (manager->priv->pending_end_session_tasks,
                                                                     task);
 
-        shell_running = gsm_shell_is_running (manager->priv->shell);
-
-        if (!shell_running)
-                show_fallback_shutdown_dialog (manager, TRUE);
-        else
-                request_reboot (manager);
+        request_reboot (manager);
 
         return TRUE;
 }
@@ -4285,32 +3786,30 @@ on_shutdown_prepared (GsmSystem  *system,
 static gboolean
 do_query_end_session_exit (GsmManager *manager)
 {
-        int action;
+        gboolean reboot = FALSE;
+        gboolean shutdown = FALSE;
 
         switch (manager->priv->logout_type) {
         case GSM_MANAGER_LOGOUT_LOGOUT:
-                action = GSM_LOGOUT_ACTION_LOGOUT;
                 break;
         case GSM_MANAGER_LOGOUT_REBOOT:
         case GSM_MANAGER_LOGOUT_REBOOT_INTERACT:
-                action = GSM_LOGOUT_ACTION_REBOOT;
+                reboot = TRUE;
                 break;
         case GSM_MANAGER_LOGOUT_SHUTDOWN:
         case GSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT:
-                action = GSM_LOGOUT_ACTION_SHUTDOWN;
+                shutdown = TRUE;
                 break;
         default:
                 g_warning ("Unexpected logout type %d in do_query_end_session_exit()",
                            manager->priv->logout_type);
-                action = GSM_LOGOUT_ACTION_LOGOUT;
                 break;
         }
 
-        if (action == GSM_LOGOUT_ACTION_REBOOT ||
-            action == GSM_LOGOUT_ACTION_SHUTDOWN) {
+        if (reboot || shutdown) {
                 g_signal_connect (manager->priv->system, "shutdown-prepared",
                                   G_CALLBACK (on_shutdown_prepared), manager);
-                gsm_system_prepare_shutdown (manager->priv->system, action == GSM_LOGOUT_ACTION_REBOOT);
+                gsm_system_prepare_shutdown (manager->priv->system, reboot);
                 return FALSE; /* don't leave query end session yet */
         }
 
diff --git a/gnome-session/gsm-util.h b/gnome-session/gsm-util.h
index b139890..38dbe7b 100644
--- a/gnome-session/gsm-util.h
+++ b/gnome-session/gsm-util.h
@@ -54,6 +54,8 @@ char *      gsm_util_generate_startup_id            (void);
 void        gsm_util_setenv                         (const char *variable,
                                                      const char *value);
 
+void        gsm_quit                                (void);
+
 G_END_DECLS
 
 #endif /* __GSM_UTIL_H__ */
diff --git a/gnome-session/main.c b/gnome-session/main.c
index dc6db5f..cb84f78 100644
--- a/gnome-session/main.c
+++ b/gnome-session/main.c
@@ -30,7 +30,6 @@
 
 #include <glib/gi18n.h>
 #include <glib.h>
-#include <gtk/gtk.h>
 
 #include <glib-unix.h>
 
@@ -61,8 +60,25 @@ static gboolean please_fail = FALSE;
 
 static DBusGProxy *bus_proxy = NULL;
 
+static GMainLoop *loop;
+
 static void shutdown_cb (gpointer data);
 
+void
+gsm_quit (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static void
+gsm_main (void)
+{
+        if (loop == NULL)
+                loop = g_main_loop_new (NULL, TRUE);
+
+        g_main_loop_run (loop);
+}
+
 static void
 on_bus_name_lost (DBusGProxy *bus_proxy,
                   const char *name,
@@ -212,7 +228,7 @@ shutdown_cb (gpointer data)
          */
         gsm_manager_set_phase (manager, GSM_MANAGER_PHASE_EXIT);
 
-        gtk_main_quit ();
+        gsm_quit ();
 }
 
 static gboolean
@@ -261,6 +277,11 @@ check_gl (GError **error)
         int status;
         char *argv[] = { LIBEXECDIR "/gnome-session-check-accelerated", NULL };
 
+        if (getenv ("DISPLAY") == NULL) {
+                /* Not connected to X11, someone else will take care of checking GL */
+                return TRUE;
+        }
+
         if (!g_spawn_sync (NULL, (char **) argv, NULL, 0, NULL, NULL, NULL, NULL,
                            &status, error)) {
                 return FALSE;
@@ -273,13 +294,13 @@ int
 main (int argc, char **argv)
 {
         GError           *error = NULL;
-        char             *display_str;
         GsmManager       *manager;
         GsmStore         *client_store;
         static char     **override_autostart_dirs = NULL;
         static char      *opt_session_name = NULL;
         const char       *session_name;
         gboolean          gl_failed = FALSE;
+        GOptionContext   *options;
         static GOptionEntry entries[] = {
                 { "autostart", 'a', 0, G_OPTION_ARG_STRING_ARRAY, &override_autostart_dirs, N_("Override 
standard autostart directories"), N_("AUTOSTART_DIR") },
                 { "session", 0, 0, G_OPTION_ARG_STRING, &opt_session_name, N_("Session to use"), 
N_("SESSION_NAME") },
@@ -320,15 +341,16 @@ main (int argc, char **argv)
         textdomain (GETTEXT_PACKAGE);
 
         error = NULL;
-        gtk_init_with_args (&argc, &argv,
-                            (char *) _(" - the GNOME session manager"),
-                            entries, GETTEXT_PACKAGE,
-                            &error);
+        options = g_option_context_new (_(" - the GNOME session manager"));
+        g_option_context_add_main_entries (options, entries, GETTEXT_PACKAGE);
+        g_option_context_parse (options, &argc, &argv, &error);
         if (error != NULL) {
                 g_warning ("%s", error->message);
                 exit (1);
         }
 
+        g_option_context_free (options);
+
         if (show_version) {
                 g_print ("%s %s\n", argv [0], VERSION);
                 exit (0);
@@ -352,26 +374,19 @@ main (int argc, char **argv)
 
         if (gl_failed) {
                 gsm_fail_whale_dialog_we_failed (FALSE, TRUE, NULL);
-                gtk_main ();
+                gsm_main ();
                 exit (1);
         }
 
         if (please_fail) {
                 gsm_fail_whale_dialog_we_failed (TRUE, TRUE, NULL);
-                gtk_main ();
+                gsm_main ();
                 exit (1);
         }
 
         gdm_log_init ();
         gdm_log_set_debug (debug);
 
-        /* Set DISPLAY explicitly for all our children, in case --display
-         * was specified on the command line.
-         */
-        display_str = gdk_get_display ();
-        gsm_util_setenv ("DISPLAY", display_str);
-        g_free (display_str);
-
         /* Some third-party programs rely on GNOME_DESKTOP_SESSION_ID to
          * detect if GNOME is running. We keep this for compatibility reasons.
          */
@@ -392,7 +407,7 @@ main (int argc, char **argv)
 
         if (!acquire_name ()) {
                 gsm_fail_whale_dialog_we_failed (TRUE, TRUE, NULL);
-                gtk_main ();
+                gsm_main ();
                 exit (1);
         }
 
@@ -422,7 +437,7 @@ main (int argc, char **argv)
 
         gsm_manager_start (manager);
 
-        gtk_main ();
+        gsm_main ();
 
         g_clear_object (&manager);
         g_clear_object (&client_store);
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ff8d03b..34d5beb 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -10,13 +10,10 @@ data/gnome-dummy.session.desktop.in.in
 data/gnome-session-properties.desktop.in.in
 data/gnome.session.desktop.in.in
 [type: gettext/glade]data/session-selector.ui
-[type: gettext/glade]data/gsm-inhibit-dialog.ui
 [type: gettext/glade]data/session-properties.ui
 egg/eggdesktopfile.c
 egg/eggsmclient.c
 gnome-session/gsm-fail-whale-dialog.c
-gnome-session/gsm-inhibit-dialog.c
-gnome-session/gsm-logout-dialog.c
 gnome-session/gsm-manager.c
 gnome-session/gsm-process-helper.c
 gnome-session/gsm-util.c


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