gdm r6380 - in trunk: . daemon gui/simple-greeter po



Author: mccann
Date: Thu Aug 14 21:32:53 2008
New Revision: 6380
URL: http://svn.gnome.org/viewvc/gdm?rev=6380&view=rev

Log:
2008-08-14  William Jon McCann  <jmccann redhat com>

	* configure.ac:
	* daemon/gdm-greeter-session.c (gdm_greeter_session_new):
	* gui/simple-greeter/Makefile.am:
	* gui/simple-greeter/at-spi-registryd-wrapper.desktop.in.in:
	* gui/simple-greeter/gdm-greeter-session.c (toggle_panel),
	(toggle_login_window), (gdm_greeter_session_start),
	(gdm_greeter_session_stop), (gdm_greeter_session_event_handler),
	(gdm_greeter_session_init):
	* gui/simple-greeter/gdm-session-client.c:
	* gui/simple-greeter/gdm-session-client.h:
	* gui/simple-greeter/gdm-session-manager.c:
	* gui/simple-greeter/gdm-session-manager.h:
	* gui/simple-greeter/gdm-simple-greeter.desktop.in.in:
	* gui/simple-greeter/greeter-main.c (session_manager_connect),
	(register_client), (main):
	Switch to using gnome-session 2.23.6+ for session management.
	The actual greeter that will be shown will be determined by
	autostart.  This means that we'll share a common SM framework
	and it will be easier to change greeter frontends.



Added:
   trunk/gui/simple-greeter/at-spi-registryd-wrapper.desktop.in.in
   trunk/gui/simple-greeter/gdm-simple-greeter.desktop.in.in
Removed:
   trunk/gui/simple-greeter/gdm-session-client.c
   trunk/gui/simple-greeter/gdm-session-client.h
   trunk/gui/simple-greeter/gdm-session-manager.c
   trunk/gui/simple-greeter/gdm-session-manager.h
Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/daemon/gdm-greeter-session.c
   trunk/gui/simple-greeter/Makefile.am
   trunk/gui/simple-greeter/gdm-greeter-session.c
   trunk/gui/simple-greeter/greeter-main.c
   trunk/po/ChangeLog
   trunk/po/POTFILES.in
   trunk/po/POTFILES.skip

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Thu Aug 14 21:32:53 2008
@@ -1359,6 +1359,8 @@
 Makefile
 daemon/Makefile
 gui/Makefile
+gui/simple-greeter/gdm-simple-greeter.desktop.in
+gui/simple-greeter/at-spi-registryd-wrapper.desktop.in
 gui/simple-greeter/Makefile
 gui/simple-greeter/libnotificationarea/Makefile
 gui/simple-chooser/Makefile

Modified: trunk/daemon/gdm-greeter-session.c
==============================================================================
--- trunk/daemon/gdm-greeter-session.c	(original)
+++ trunk/daemon/gdm-greeter-session.c	Thu Aug 14 21:32:53 2008
@@ -147,7 +147,7 @@
         GObject *object;
 
         object = g_object_new (GDM_TYPE_GREETER_SESSION,
-                               "command", LIBEXECDIR "/gdm-simple-greeter",
+                               "command", BINDIR "/gnome-session --autostart="DATADIR"/gdm/autostart/LoginWindow/",
                                "server-dbus-path", GDM_GREETER_SERVER_DBUS_PATH,
                                "server-dbus-interface", GDM_GREETER_SERVER_DBUS_INTERFACE,
                                "server-env-var-name", "GDM_GREETER_DBUS_ADDRESS",

Modified: trunk/gui/simple-greeter/Makefile.am
==============================================================================
--- trunk/gui/simple-greeter/Makefile.am	(original)
+++ trunk/gui/simple-greeter/Makefile.am	Thu Aug 14 21:32:53 2008
@@ -22,6 +22,14 @@
 	$(POLKIT_GNOME_CFLAGS)				\
 	$(NULL)
 
+ INTLTOOL_DESKTOP_RULE@
+desktopdir = $(pkgdatadir)/autostart/LoginWindow
+desktop_in_files = 	\
+	at-spi-registryd-wrapper.desktop.in	\
+	gdm-simple-greeter.desktop.in		\
+	$(NULL)
+desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
+
 @INTLTOOL_SCHEMAS_RULE@
 
 schemasdir   = @GCONF_SCHEMA_FILE_DIR@
@@ -260,10 +268,6 @@
 	gdm-greeter-client.c		\
 	gdm-greeter-session.h		\
 	gdm-greeter-session.c		\
-	gdm-session-manager.h		\
-	gdm-session-manager.c		\
-	gdm-session-client.h		\
-	gdm-session-client.c		\
 	gdm-greeter-login-window.c	\
 	gdm-greeter-login-window.h	\
 	gdm-remote-login-window.c	\
@@ -318,6 +322,7 @@
 	$(NULL)
 
 EXTRA_DIST = 			\
+	$(desktop_in_files)	\
 	$(schemas_in_files)	\
 	$(glade_DATA)		\
 	$(NULL)

Added: trunk/gui/simple-greeter/at-spi-registryd-wrapper.desktop.in.in
==============================================================================
--- (empty file)
+++ trunk/gui/simple-greeter/at-spi-registryd-wrapper.desktop.in.in	Thu Aug 14 21:32:53 2008
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Type=Application
+_Name=AT SPI Registry Wrapper
+Exec= LIBDIR@/gnome-session/helpers/at-spi-registryd-wrapper
+OnlyShowIn=GNOME;
+AutostartCondition=GNOME /desktop/gnome/interface/accessibility
+X-GNOME-Autostart-Phase=Initialization
+X-GNOME-AutoRestart=true
\ No newline at end of file

Modified: trunk/gui/simple-greeter/gdm-greeter-session.c
==============================================================================
--- trunk/gui/simple-greeter/gdm-greeter-session.c	(original)
+++ trunk/gui/simple-greeter/gdm-greeter-session.c	Thu Aug 14 21:32:53 2008
@@ -38,32 +38,13 @@
 #include "gdm-greeter-panel.h"
 #include "gdm-greeter-login-window.h"
 
-#include "gdm-session-manager.h"
-#include "gdm-session-client.h"
 #include "gdm-profile.h"
 
 #define GDM_GREETER_SESSION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_GREETER_SESSION, GdmGreeterSessionPrivate))
 
-#define GSD_DBUS_NAME      "org.gnome.SettingsDaemon"
-#define GSD_DBUS_PATH      "/org/gnome/SettingsDaemon"
-#define GSD_DBUS_INTERFACE "org.gnome.SettingsDaemon"
-
-#define KEY_GDM_DIR                 "/apps/gdm/simple-greeter"
-#define KEY_GDM_A11Y_DIR             KEY_GDM_DIR "/accessibility"
-#define KEY_SCREEN_KEYBOARD_ENABLED  KEY_GDM_A11Y_DIR "/screen_keyboard_enabled"
-#define KEY_SCREEN_MAGNIFIER_ENABLED KEY_GDM_A11Y_DIR "/screen_magnifier_enabled"
-#define KEY_SCREEN_READER_ENABLED    KEY_GDM_A11Y_DIR "/screen_reader_enabled"
-
-#define KEY_WM_USE_COMPIZ            KEY_GDM_DIR "/wm_use_compiz"
-
 struct GdmGreeterSessionPrivate
 {
         GdmGreeterClient      *client;
-        GdmSessionManager     *manager;
-
-        GdmSessionClient      *screen_reader_client;
-        GdmSessionClient      *screen_keyboard_client;
-        GdmSessionClient      *screen_magnifier_client;
 
         GtkWidget             *login_window;
         GtkWidget             *panel;
@@ -287,9 +268,8 @@
 }
 
 static void
-toggle_panel (GdmSessionManager *manager,
-              gboolean           enabled,
-              GdmGreeterSession *session)
+toggle_panel (GdmGreeterSession *session,
+              gboolean           enabled)
 {
         gdm_profile_start (NULL);
 
@@ -321,9 +301,8 @@
 }
 
 static void
-toggle_login_window (GdmSessionManager *manager,
-                     gboolean           enabled,
-                     GdmGreeterSession *session)
+toggle_login_window (GdmGreeterSession *session,
+                     gboolean           enabled)
 {
         gdm_profile_start (NULL);
 
@@ -374,359 +353,6 @@
         gdm_profile_end (NULL);
 }
 
-static gboolean
-launch_compiz (GdmGreeterSession *session)
-{
-        GError  *error;
-        gboolean ret;
-
-        gdm_profile_start (NULL);
-        g_debug ("GdmGreeterSession: Launching compiz");
-
-        ret = FALSE;
-
-        g_setenv ("LIBGL_ALWAYS_INDIRECT", "1", TRUE);
-
-        error = NULL;
-        g_spawn_command_line_async ("gtk-window-decorator", &error);
-        if (error != NULL) {
-                g_warning ("Error starting WM: %s", error->message);
-                g_error_free (error);
-                goto out;
-        }
-
-        error = NULL;
-        g_spawn_command_line_async ("compiz --replace glib gconf", &error);
-        if (error != NULL) {
-                g_warning ("Error starting WM: %s", error->message);
-                g_error_free (error);
-                goto out;
-        }
-
-        ret = TRUE;
-
-        /* FIXME: should try to detect if it actually works */
-
- out:
-        gdm_profile_end (NULL);
-        return ret;
-}
-
-static gboolean
-launch_metacity (GdmGreeterSession *session)
-{
-        GError  *error;
-        gboolean ret;
-
-        gdm_profile_start (NULL);
-
-        g_debug ("GdmGreeterSession: Launching metacity");
-
-        ret = FALSE;
-
-        error = NULL;
-        g_spawn_command_line_async ("metacity --replace", &error);
-        if (error != NULL) {
-                g_warning ("Error starting WM: %s", error->message);
-                g_error_free (error);
-                goto out;
-        }
-
-        ret = TRUE;
-
- out:
-        gdm_profile_end (NULL);
-        return ret;
-}
-
-static void
-start_window_manager (GdmGreeterSession *session)
-{
-        gboolean     use_compiz;
-        GConfClient *client;
-
-        client = gconf_client_get_default ();
-        use_compiz = gconf_client_get_bool (client, KEY_WM_USE_COMPIZ, NULL);
-        g_object_unref (client);
-        if (use_compiz) {
-                if (launch_compiz (session)) {
-                        return;
-                }
-        }
-
-        launch_metacity (session);
-}
-
-static void
-toggle_screen_reader (GdmGreeterSession *session,
-                      gboolean           enabled)
-{
-        g_debug ("GdmGreeterSession: screen reader toggled: %d", enabled);
-        gdm_session_client_set_enabled (session->priv->screen_reader_client, enabled);
-}
-
-static void
-toggle_screen_magnifier (GdmGreeterSession *session,
-                         gboolean           enabled)
-{
-        g_debug ("GdmGreeterSession: screen magnifier toggled: %d", enabled);
-        gdm_session_client_set_enabled (session->priv->screen_magnifier_client, enabled);
-}
-
-static void
-toggle_screen_keyboard (GdmGreeterSession *session,
-                        gboolean           enabled)
-{
-        g_debug ("GdmGreeterSession: screen keyboard toggled: %d", enabled);
-        gdm_session_client_set_enabled (session->priv->screen_keyboard_client, enabled);
-}
-
-static void
-on_a11y_key_changed (GConfClient       *client,
-                     guint              cnxn_id,
-                     GConfEntry        *entry,
-                     GdmGreeterSession *session)
-{
-        const char *key;
-        GConfValue *value;
-
-        key = gconf_entry_get_key (entry);
-        value = gconf_entry_get_value (entry);
-
-        if (strcmp (key, KEY_SCREEN_READER_ENABLED) == 0) {
-                if (value->type == GCONF_VALUE_BOOL) {
-                        gboolean enabled;
-
-                        enabled = gconf_value_get_bool (value);
-                        g_debug ("setting key %s = %d", key, enabled);
-                        toggle_screen_reader (session, enabled);
-                } else {
-                        g_warning ("Error retrieving configuration key '%s': Invalid type",
-                                   key);
-                }
-
-        } else if (strcmp (key, KEY_SCREEN_MAGNIFIER_ENABLED) == 0) {
-                if (value->type == GCONF_VALUE_BOOL) {
-                        gboolean enabled;
-
-                        enabled = gconf_value_get_bool (value);
-                        g_debug ("setting key %s = %d", key, enabled);
-                        toggle_screen_magnifier (session, enabled);
-                } else {
-                        g_warning ("Error retrieving configuration key '%s': Invalid type",
-                                   key);
-                }
-
-        } else if (strcmp (key, KEY_SCREEN_KEYBOARD_ENABLED) == 0) {
-                if (value->type == GCONF_VALUE_BOOL) {
-                        gboolean enabled;
-
-                        enabled = gconf_value_get_bool (value);
-                        g_debug ("setting key %s = %d", key, enabled);
-                        toggle_screen_keyboard (session, enabled);
-                } else {
-                        g_warning ("Error retrieving configuration key '%s': Invalid type",
-                                   key);
-                }
-
-        } else {
-        }
-}
-
-static void
-setup_at_tools (GdmGreeterSession *session)
-{
-        GConfClient *client;
-        gboolean     enabled;
-
-        client = gconf_client_get_default ();
-        gconf_client_add_dir (client,
-                              KEY_GDM_A11Y_DIR,
-                              GCONF_CLIENT_PRELOAD_ONELEVEL,
-                              NULL);
-        gconf_client_notify_add (client,
-                                 KEY_GDM_A11Y_DIR,
-                                 (GConfClientNotifyFunc)on_a11y_key_changed,
-                                 session,
-                                 NULL,
-                                 NULL);
-
-        session->priv->screen_keyboard_client = gdm_session_client_new ();
-        gdm_session_client_set_name (session->priv->screen_keyboard_client,
-                                     "On-screen Keyboard");
-        gdm_session_client_set_try_exec (session->priv->screen_keyboard_client,
-                                         "gok");
-        gdm_session_client_set_command (session->priv->screen_keyboard_client,
-                                        "gok --login");
-        enabled = gconf_client_get_bool (client, KEY_SCREEN_KEYBOARD_ENABLED, NULL);
-        gdm_session_client_set_enabled (session->priv->screen_keyboard_client,
-                                        enabled);
-
-
-        session->priv->screen_reader_client = gdm_session_client_new ();
-        gdm_session_client_set_name (session->priv->screen_reader_client,
-                                     "Screen Reader");
-        gdm_session_client_set_try_exec (session->priv->screen_reader_client,
-                                         "orca");
-        gdm_session_client_set_command (session->priv->screen_reader_client,
-                                        "orca -n -d main-window -d magnifier");
-        enabled = gconf_client_get_bool (client, KEY_SCREEN_READER_ENABLED, NULL);
-        gdm_session_client_set_enabled (session->priv->screen_reader_client,
-                                        enabled);
-
-
-        session->priv->screen_magnifier_client = gdm_session_client_new ();
-        gdm_session_client_set_name (session->priv->screen_magnifier_client,
-                                     "Screen Magnifier");
-        gdm_session_client_set_try_exec (session->priv->screen_magnifier_client,
-                                         "magnifier");
-        gdm_session_client_set_command (session->priv->screen_magnifier_client,
-                                        "magnifier -v -m");
-        enabled = gconf_client_get_bool (client, KEY_SCREEN_MAGNIFIER_ENABLED, NULL);
-        gdm_session_client_set_enabled (session->priv->screen_magnifier_client,
-                                        enabled);
-
-        gdm_session_manager_add_client (session->priv->manager,
-                                        session->priv->screen_reader_client,
-                                        GDM_SESSION_LEVEL_LOGIN_WINDOW);
-        gdm_session_manager_add_client (session->priv->manager,
-                                        session->priv->screen_keyboard_client,
-                                        GDM_SESSION_LEVEL_LOGIN_WINDOW);
-        gdm_session_manager_add_client (session->priv->manager,
-                                        session->priv->screen_magnifier_client,
-                                        GDM_SESSION_LEVEL_LOGIN_WINDOW);
-
-        g_object_unref (client);
-}
-
-static gboolean
-send_dbus_string_method (DBusConnection *connection,
-                         const char     *method,
-                         const char     *payload)
-{
-        DBusError       error;
-        DBusMessage    *message;
-        DBusMessage    *reply;
-        DBusMessageIter iter;
-        const char     *str;
-
-        if (payload != NULL) {
-                str = payload;
-        } else {
-                str = "";
-        }
-
-        g_debug ("GdmGreeterSession: Calling %s", method);
-        message = dbus_message_new_method_call (GSD_DBUS_NAME,
-                                                GSD_DBUS_PATH,
-                                                GSD_DBUS_INTERFACE,
-                                                method);
-        if (message == NULL) {
-                g_warning ("Couldn't allocate the D-Bus message");
-                return FALSE;
-        }
-
-        dbus_message_iter_init_append (message, &iter);
-        dbus_message_iter_append_basic (&iter,
-                                        DBUS_TYPE_STRING,
-                                        &str);
-
-        dbus_error_init (&error);
-        reply = dbus_connection_send_with_reply_and_block (connection,
-                                                           message,
-                                                           -1,
-                                                           &error);
-
-        dbus_message_unref (message);
-
-        if (dbus_error_is_set (&error)) {
-                g_warning ("%s %s raised: %s\n",
-                           method,
-                           error.name,
-                           error.message);
-                return FALSE;
-        }
-        if (reply != NULL) {
-                dbus_message_unref (reply);
-        }
-        dbus_connection_flush (connection);
-
-        return TRUE;
-}
-
-static gboolean
-activate_settings_daemon (GdmGreeterSession *session)
-{
-        gboolean         ret;
-        gboolean         res;
-        DBusError        local_error;
-        DBusConnection  *connection;
-
-        gdm_profile_start (NULL);
-
-        ret = FALSE;
-
-        g_debug ("GdmGreeterLoginWindow: activating settings daemon");
-
-        dbus_error_init (&local_error);
-        connection = dbus_bus_get (DBUS_BUS_SESSION, &local_error);
-        if (connection == NULL) {
-                g_debug ("Failed to connect to the D-Bus daemon: %s", local_error.message);
-                dbus_error_free (&local_error);
-                goto out;
-        }
-
-        res = send_dbus_string_method (connection,
-                                       "StartWithSettingsPrefix",
-                                       "/apps/gdm/simple-greeter/settings-manager-plugins");
-        if (! res) {
-                g_warning ("Couldn't start settings daemon");
-                goto out;
-        }
-        ret = TRUE;
-        g_debug ("GdmGreeterLoginWindow: settings daemon started");
- out:
-        gdm_profile_end (NULL);
-
-        return ret;
-}
-
-static gboolean
-start_settings_daemon (GdmGreeterSession *session)
-{
-        GError  *error;
-        gboolean ret;
-
-        g_debug ("GdmGreeterSession: Launching settings daemon");
-
-        ret = FALSE;
-
-        error = NULL;
-        g_spawn_command_line_async (LIBEXECDIR "/gnome-settings-daemon --gconf-prefix=/apps/gdm/simple-greeter/settings-manager-plugins", &error);
-        if (error != NULL) {
-                g_warning ("Error starting settings daemon: %s", error->message);
-                g_error_free (error);
-                goto out;
-        }
-
-        ret = TRUE;
-
- out:
-        return ret;
-}
-
-static void
-toggle_all_levels (GdmSessionManager *manager,
-                   gboolean           enabled,
-                   GdmGreeterSession *session)
-{
-        if (enabled) {
-                start_settings_daemon (session);
-                start_window_manager (session);
-        } else {
-        }
-}
-
 gboolean
 gdm_greeter_session_start (GdmGreeterSession *session,
                            GError           **error)
@@ -739,7 +365,8 @@
 
         res = gdm_greeter_client_start (session->priv->client, error);
 
-        gdm_session_manager_set_level (session->priv->manager, GDM_SESSION_LEVEL_LOGIN_WINDOW);
+        toggle_panel (session, TRUE);
+        toggle_login_window (session, TRUE);
 
         gdm_profile_end (NULL);
 
@@ -751,6 +378,8 @@
 {
         g_return_if_fail (GDM_IS_GREETER_SESSION (session));
 
+        toggle_panel (session, FALSE);
+        toggle_login_window (session, FALSE);
 }
 
 static void
@@ -816,8 +445,8 @@
 }
 
 static void
-gdm_greeter_session_event_handler(GdkEvent          *event,
-                                  GdmGreeterSession *session)
+gdm_greeter_session_event_handler (GdkEvent          *event,
+                                   GdmGreeterSession *session)
 {
         g_assert (GDM_IS_GREETER_SESSION (session));
 
@@ -854,22 +483,6 @@
 
         session->priv = GDM_GREETER_SESSION_GET_PRIVATE (session);
 
-        session->priv->manager = gdm_session_manager_new ();
-        gdm_session_manager_load_system_dirs (session->priv->manager);
-
-        gdm_session_manager_add_notify (session->priv->manager,
-                                        GDM_SESSION_LEVEL_LOGIN_WINDOW,
-                                        (GdmSessionLevelNotifyFunc)toggle_login_window,
-                                        session);
-        gdm_session_manager_add_notify (session->priv->manager,
-                                        GDM_SESSION_LEVEL_LOGIN_WINDOW,
-                                        (GdmSessionLevelNotifyFunc)toggle_panel,
-                                        session);
-        gdm_session_manager_add_notify (session->priv->manager,
-                                        GDM_SESSION_ALL_LEVELS,
-                                        (GdmSessionLevelNotifyFunc)toggle_all_levels,
-                                        session);
-
         session->priv->client = gdm_greeter_client_new ();
         g_signal_connect (session->priv->client,
                           "info-query",
@@ -926,9 +539,6 @@
         gdk_event_handler_set ((GdkEventFunc) gdm_greeter_session_event_handler,
                                session, NULL);
 
-        /* FIXME: we should really do this in settings daemon */
-        setup_at_tools (session);
-
         gdm_profile_end (NULL);
 }
 

Added: trunk/gui/simple-greeter/gdm-simple-greeter.desktop.in.in
==============================================================================
--- (empty file)
+++ trunk/gui/simple-greeter/gdm-simple-greeter.desktop.in.in	Thu Aug 14 21:32:53 2008
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Type=Application
+_Name=Login Window
+Exec= LIBEXECDIR@/gdm-simple-greeter
+OnlyShowIn=GNOME;
+X-GNOME-Autostart-Phase=Panel
+X-GNOME-Autostart-Notify=true
+X-GNOME-AutoRestart=true
\ No newline at end of file

Modified: trunk/gui/simple-greeter/greeter-main.c
==============================================================================
--- trunk/gui/simple-greeter/greeter-main.c	(original)
+++ trunk/gui/simple-greeter/greeter-main.c	Thu Aug 14 21:32:53 2008
@@ -31,6 +31,8 @@
 #include <gtk/gtk.h>
 #include <gconf/gconf-client.h>
 
+#include <dbus/dbus-glib.h>
+
 #include "gdm-log.h"
 #include "gdm-common.h"
 #include "gdm-signal-handler.h"
@@ -40,222 +42,18 @@
 
 #include "gdm-greeter-session.h"
 
-#define ACCESSIBILITY_KEY         "/desktop/gnome/interface/accessibility"
 #define DEBUG_KEY                 "/apps/gdm/simple-greeter/debug"
 
-static Atom AT_SPI_IOR;
-
-static gboolean
-assistive_registry_launch (void)
-{
-        GPid        pid;
-        GError     *error;
-        const char *command;
-        char      **argv;
-        gboolean    res;
-        gboolean    ret;
-
-        ret = FALSE;
-
-        gdm_profile_start (NULL);
-
-        command = AT_SPI_REGISTRYD_DIR "/at-spi-registryd";
-
-        argv = NULL;
-        error = NULL;
-        res = g_shell_parse_argv (command, NULL, &argv, &error);
-        if (! res) {
-                g_warning ("Unable to parse command: %s", error->message);
-                goto out;
-        }
-
-        error = NULL;
-        res = g_spawn_async (NULL,
-                             argv,
-                             NULL,
-                             G_SPAWN_SEARCH_PATH
-                             | G_SPAWN_STDOUT_TO_DEV_NULL
-                             | G_SPAWN_STDERR_TO_DEV_NULL,
-                             NULL,
-                             NULL,
-                             &pid,
-                             &error);
-        g_strfreev (argv);
-
-        if (! res) {
-                g_warning ("Unable to run command %s: %s", command, error->message);
-                goto out;
-        }
-
-        if (kill (pid, 0) < 0) {
-                g_warning ("at-spi-registryd not running");
-                goto out;
-        }
-
-        ret = TRUE;
- out:
-        gdm_profile_end (NULL);
-
-        return ret;
-}
-
-static GdkFilterReturn
-filter_watch (GdkXEvent *xevent,
-              GdkEvent  *event,
-              GMainLoop *loop)
-{
-        XEvent *xev = (XEvent *)xevent;
-
-        if (xev->xany.type == PropertyNotify
-            && xev->xproperty.atom == AT_SPI_IOR) {
-                g_debug ("a11y registry started");
-                g_main_loop_quit (loop);
-
-                return GDK_FILTER_REMOVE;
-        }
-
-        return GDK_FILTER_CONTINUE;
-}
-
-static gboolean
-filter_timeout (GMainLoop *loop)
-{
-        g_warning ("The accessibility registry was not found.");
-
-        g_main_loop_quit (loop);
-
-        return FALSE;
-}
-
-static void
-assistive_registry_start (void)
-{
-        GdkWindow *root;
-        guint      tid;
-        GMainLoop *loop;
-
-        gdm_profile_start (NULL);
-
-        g_debug ("Starting a11y registry");
-
-        root = gdk_get_default_root_window ();
-
-        if ( ! AT_SPI_IOR) {
-                AT_SPI_IOR = XInternAtom (GDK_DISPLAY (), "AT_SPI_IOR", False);
-        }
-
-        gdk_window_set_events (root, GDK_PROPERTY_CHANGE_MASK);
-
-        if ( ! assistive_registry_launch ()) {
-                g_warning ("The accessibility registry could not be started.");
-                return;
-        }
-
-        loop = g_main_loop_new (NULL, FALSE);
-        gdk_window_add_filter (root, (GdkFilterFunc)filter_watch, loop);
-        tid = g_timeout_add_seconds (5, (GSourceFunc)filter_timeout, loop);
-
-        g_main_loop_run (loop);
-
-        gdk_window_remove_filter (root, (GdkFilterFunc)filter_watch, loop);
-        g_source_remove (tid);
-
-        g_main_loop_unref (loop);
-
-        gdm_profile_end (NULL);
-}
-
-static void
-at_set_gtk_modules (void)
-{
-        GSList     *modules_list;
-        GSList     *l;
-        const char *old;
-        char      **modules;
-        gboolean    found_gail;
-        gboolean    found_atk_bridge;
-        int         n;
-
-        gdm_profile_start (NULL);
-
-        n = 0;
-        modules_list = NULL;
-        found_gail = FALSE;
-        found_atk_bridge = FALSE;
-
-        if ((old = g_getenv ("GTK_MODULES")) != NULL) {
-                modules = g_strsplit (old, ":", -1);
-                for (n = 0; modules[n]; n++) {
-                        if (strcmp (modules[n], "gail") == 0) {
-                                found_gail = TRUE;
-                        } else if (strcmp (modules[n], "atk-bridge") == 0) {
-                                found_atk_bridge = TRUE;
-                        }
-
-                        modules_list = g_slist_prepend (modules_list, modules[n]);
-                        modules[n] = NULL;
-                }
-                g_free (modules);
-        }
-
-        if (!found_gail) {
-                modules_list = g_slist_prepend (modules_list, "gail");
-                ++n;
-        }
-
-        if (!found_atk_bridge) {
-                modules_list = g_slist_prepend (modules_list, "atk-bridge");
-                ++n;
-        }
-
-        modules = g_new (char *, n + 1);
-        modules[n--] = NULL;
-        for (l = modules_list; l; l = l->next) {
-                modules[n--] = g_strdup (l->data);
-        }
-
-        g_setenv ("GTK_MODULES", g_strjoinv (":", modules), TRUE);
-        g_strfreev (modules);
-        g_slist_free (modules_list);
-
-        gdm_profile_end (NULL);
-}
-
-static void
-load_a11y (void)
-{
-        const char        *env_a_t_support;
-        gboolean           a_t_support;
-        GConfClient       *gconf_client;
-
-        gdm_profile_start (NULL);
-
-        gconf_client = gconf_client_get_default ();
-
-        env_a_t_support = g_getenv ("GNOME_ACCESSIBILITY");
-        if (env_a_t_support) {
-                a_t_support = atoi (env_a_t_support);
-        } else {
-                GConfValue *val;
-
-                a_t_support = TRUE;
-
-                val = gconf_client_get_without_default (gconf_client, ACCESSIBILITY_KEY, NULL);
-                if (val != NULL) {
-                        a_t_support = gconf_value_get_bool (val);
-                        gconf_value_free (val);
-                }
-        }
-
-        if (a_t_support) {
-                assistive_registry_start ();
-                at_set_gtk_modules ();
-        }
-
-        g_object_unref (gconf_client);
-
-        gdm_profile_end (NULL);
-}
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+static DBusGConnection *bus_connection = NULL;
+static DBusGProxy      *sm_proxy = NULL;
+static char            *client_id = NULL;
+static DBusGProxy      *client_proxy = NULL;
 
 static gboolean
 is_debug_set (void)
@@ -333,6 +131,66 @@
         return ret;
 }
 
+static gboolean
+session_manager_connect (void)
+{
+
+        if (bus_connection == NULL) {
+                GError *error;
+
+                error = NULL;
+                bus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+                if (bus_connection == NULL) {
+                        g_message ("Failed to connect to the session bus: %s",
+                                   error->message);
+                        g_error_free (error);
+                        exit (1);
+                }
+        }
+
+        sm_proxy = dbus_g_proxy_new_for_name (bus_connection,
+                                              SM_DBUS_NAME,
+                                              SM_DBUS_PATH,
+                                              SM_DBUS_INTERFACE);
+        return (sm_proxy != NULL);
+}
+
+static gboolean
+register_client (void)
+{
+        GError     *error;
+        gboolean    res;
+        const char *startup_id;
+        const char *app_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "gdm-simple-greeter.desktop";
+
+        error = NULL;
+        res = dbus_g_proxy_call (sm_proxy,
+                                 "RegisterClient",
+                                 &error,
+                                 G_TYPE_STRING, app_id,
+                                 G_TYPE_STRING, startup_id,
+                                 G_TYPE_INVALID,
+                                 DBUS_TYPE_G_OBJECT_PATH, &client_id,
+                                 G_TYPE_INVALID);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_debug ("Client registered with session manager: %s", client_id);
+        client_proxy = dbus_g_proxy_new_for_name (bus_connection,
+                                                  SM_DBUS_NAME,
+                                                  client_id,
+                                                  SM_CLIENT_DBUS_INTERFACE);
+        g_unsetenv ("DESKTOP_AUTOSTART_ID");
+
+        return TRUE;
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -369,10 +227,6 @@
         gdm_log_init ();
         gdm_log_set_debug (is_debug_set ());
 
-        gdk_init (&argc, &argv);
-
-        load_a11y ();
-
         gtk_init (&argc, &argv);
 
         signal_handler = gdm_signal_handler_new ();
@@ -399,6 +253,17 @@
                 exit (1);
         }
 
+        res = session_manager_connect ();
+        if (! res) {
+                g_warning ("Unable to connect to session manager");
+                exit (1);
+        }
+
+        res = register_client ();
+        if (! res) {
+                g_warning ("Unable to register client with session manager");
+        }
+
         gtk_main ();
 
         if (session != NULL) {

Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in	(original)
+++ trunk/po/POTFILES.in	Thu Aug 14 21:32:53 2008
@@ -50,6 +50,7 @@
 daemon/test-session.c
 daemon/xdmcp-chooser-slave-main.c
 data/gdm.schemas.in.in
+gui/simple-greeter/at-spi-registryd-wrapper.desktop.in.in
 gui/simple-chooser/gdm-host-chooser-dialog.c
 gui/simple-chooser/gdm-host-chooser-widget.c
 gui/simple-greeter/gdm-cell-renderer-timer.c
@@ -71,6 +72,7 @@
 gui/simple-greeter/gdm-recent-option-widget.c
 gui/simple-greeter/gdm-remote-login-window.c
 gui/simple-greeter/gdm-session-option-widget.c
+gui/simple-greeter/gdm-simple-greeter.desktop.in.in
 gui/simple-greeter/gdm-simple-greeter.schemas.in
 gui/simple-greeter/gdm-timer.c
 gui/simple-greeter/gdm-user.c

Modified: trunk/po/POTFILES.skip
==============================================================================
--- trunk/po/POTFILES.skip	(original)
+++ trunk/po/POTFILES.skip	Thu Aug 14 21:32:53 2008
@@ -8,3 +8,5 @@
 #
 data/gdm.schemas.in
 gui/user-switch-applet/GNOME_FastUserSwitchApplet.server.in
+gui/simple-greeter/at-spi-registryd-wrapper.desktop.in
+gui/simple-greeter/gdm-simple-greeter.desktop.in
\ No newline at end of file



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