gnome-session r4704 - in trunk: . splash



Author: lucasr
Date: Sun May 25 19:08:00 2008
New Revision: 4704
URL: http://svn.gnome.org/viewvc/gnome-session?rev=4704&view=rev

Log:
2008-05-25  Lucas Rocha  <lucasr gnome org>

	Make splash listen to "SessionRunning" to know when to go away on
	session startup. #529602, Karsten BrÃckelmann.

	* splash/Makefile.am: add D-Bus bits on INCLUDES and LDADD.
	* splash/README: remove obsolete note about gnome-session-splash.
	* splash/gnome-session-splash.c (get_session_bus,
	set_session_running_handler, on_session_running, main): listen to
	"SessionRunning" D-Bus signal to know when go away.
	* splash/gnome-session-splash.desktop.in: move splash to Panel phase
	as it's the phase just after window manager is started.


Modified:
   trunk/ChangeLog
   trunk/splash/Makefile.am
   trunk/splash/README
   trunk/splash/gnome-session-splash.c
   trunk/splash/gnome-session-splash.desktop.in

Modified: trunk/splash/Makefile.am
==============================================================================
--- trunk/splash/Makefile.am	(original)
+++ trunk/splash/Makefile.am	Sun May 25 19:08:00 2008
@@ -1,5 +1,6 @@
 INCLUDES =					\
 	-I$(top_srcdir)/egg			\
+	$(DBUS_GLIB_CFLAGS)			\
 	$(LIBGNOMEUI_CFLAGS)			\
 	$(STARTUP_NOTIFICATION_CFLAGS)
 
@@ -27,6 +28,7 @@
 	splash-window.h
 gnome_session_splash_LDADD =			\
 	$(STARTUP_NOTIFICATION_LIBS)		\
+	$(DBUS_GLIB_LIBS)			\
 	$(LDADD)
 
 gnome_login_sound_SOURCES =			\

Modified: trunk/splash/README
==============================================================================
--- trunk/splash/README	(original)
+++ trunk/splash/README	Sun May 25 19:08:00 2008
@@ -9,15 +9,6 @@
     then looking those binary names up in a hardcoded list in hopes of
     finding localized names and icons.
 
-    At the moment, there is no way for gnome-session to tell the
-    splash screen to go away. My original plan was for it to just use
-    Startup Notification again, and send a "remove: ID=splash" message
-    when it wanted the splash to disappear. It turns out that this
-    doesn't work though, because libstartup-notification filters out
-    the remove: message if it never saw a corresponding new: message.
-    I haven't yet gotten around to coming up with Plan B. At any rate,
-    it exits immediately if you click on it.
-
   * gnome-login-sound: This plays the login sound. If invoked with the
     "--logout" flag, it plays the logout sound instead.
 

Modified: trunk/splash/gnome-session-splash.c
==============================================================================
--- trunk/splash/gnome-session-splash.c	(original)
+++ trunk/splash/gnome-session-splash.c	Sun May 25 19:08:00 2008
@@ -24,11 +24,19 @@
 #include <string.h>
 
 #include <gtk/gtkmain.h>
+
 #include <gdk/gdkx.h>
+
 #include <gconf/gconf-client.h>
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
 #include <libgnome/gnome-program.h>
 #include <libgnomeui/gnome-ui-init.h>
+
 #include <glib/gi18n.h>
+
 #include "eggsmclient-libgnomeui.h"
 
 #define SN_API_NOT_YET_FROZEN
@@ -36,6 +44,77 @@
 
 #include "splash-window.h"
 
+#define GNOME_SESSION_DBUS_NAME      "org.gnome.SessionManager"
+#define GNOME_SESSION_DBUS_OBJECT    "/org/gnome/SessionManager"
+#define GNOME_SESSION_DBUS_INTERFACE "org.gnome.SessionManager"
+
+static DBusGConnection *
+get_session_bus (void)
+{
+  GError *error;
+  DBusGConnection *bus;
+  DBusConnection *connection;
+
+  error = NULL;
+  bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+  if (bus == NULL)
+    {
+      g_warning ("Couldn't connect to session bus: %s",
+                 error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  connection = dbus_g_connection_get_connection (bus);
+  dbus_connection_set_exit_on_disconnect (connection, TRUE);
+
+out:
+  return bus;
+}
+
+static void
+on_session_running (DBusGProxy *proxy, gpointer data)
+{
+  gtk_main_quit ();
+}
+
+static void
+set_session_running_handler ()
+{
+  DBusGConnection *bus;
+  DBusGProxy *session_proxy;
+
+  bus = get_session_bus ();
+  if (bus == NULL) 
+    {
+      g_warning ("Could not get a connection to the bus");
+      return;
+    }
+
+  session_proxy =
+           dbus_g_proxy_new_for_name (bus,
+                                      GNOME_SESSION_DBUS_NAME,
+                                      GNOME_SESSION_DBUS_OBJECT,
+                                      GNOME_SESSION_DBUS_INTERFACE);
+
+  dbus_g_object_register_marshaller (
+          g_cclosure_marshal_VOID__VOID,
+          G_TYPE_NONE,
+          G_TYPE_INVALID);
+
+  dbus_g_proxy_add_signal (session_proxy,
+                           "SessionRunning",
+                           G_TYPE_INVALID);
+
+  dbus_g_proxy_connect_signal (session_proxy,
+                               "SessionRunning",
+                               G_CALLBACK (on_session_running),
+                               NULL,
+                               NULL);
+
+  dbus_g_connection_unref (bus);
+}
+
 static void
 event_func (SnMonitorEvent *event, void *user_data)
 {
@@ -212,6 +291,8 @@
   g_signal_connect (egg_sm_client_get (), "quit",
 		    G_CALLBACK (quit), NULL);
 
+  set_session_running_handler ();
+
   setup_splash_window ();
   gtk_main ();
 

Modified: trunk/splash/gnome-session-splash.desktop.in
==============================================================================
--- trunk/splash/gnome-session-splash.desktop.in	(original)
+++ trunk/splash/gnome-session-splash.desktop.in	Sun May 25 19:08:00 2008
@@ -4,6 +4,6 @@
 Exec= helperdir@/gnome-session-splash
 OnlyShowIn=GNOME;
 AutostartCondition=GNOME /apps/gnome-session/options/show_splash_screen
-X-GNOME-Autostart-Phase=Desktop
+X-GNOME-Autostart-Phase=Panel
 X-GNOME-Provides=splash
 X-GNOME-Autostart-Notify=true



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