[Rhythmbox-devel] Session manager integration



Here is a simple patch that registers callbacks so that rhythmbox knows 
when a session is ending, so that it can save it's playlists etc.

-- 
  Matt Hughes
   + mhughe@uvic.ca
   + http://spacemonkeys.ca/
--- orig/shell/rb-shell.c
+++ mod/shell/rb-shell.c
@@ -38,6 +38,7 @@
 #include <libgnome/gnome-program.h>
 #include <libgnomeui/gnome-window-icon.h>
 #include <libgnomeui/gnome-about.h>
+#include <libgnomeui/gnome-client.h>
 #include <libgnomevfs/gnome-vfs.h>
 #include <libgnomevfs/gnome-vfs-mime-utils.h>
 #include <string.h>
@@ -224,6 +225,17 @@
 					RBShell *shell);
 static void tray_deleted_cb (GtkWidget *win, GdkEventAny *event, RBShell *shell);
 
+static gboolean save_yourself_cb (GnomeClient *client, 
+                                  gint phase,
+                                  GnomeSaveStyle save_style,
+                                  gboolean shutdown,
+                                  GnomeInteractStyle interact_style,
+                                  gboolean fast,
+                                  RBShell *shell);
+
+static void session_die_cb (GnomeClient *client,
+                            RBShell *shell);
+
 static const GtkTargetEntry target_table[] = { { "text/uri-list", 0,0 } };
 
 #define CMD_PATH_VIEW_SMALLDISPLAY "/commands/ToggleSmallDisplay"
@@ -382,6 +394,8 @@
 	gnome_window_icon_set_default_from_file (file);
 	g_free (file);
 	
+        rb_shell_session_init(shell);
+
 	eel_gconf_monitor_add (CONF_PREFIX);
 
 }
@@ -2091,3 +2105,43 @@
 	g_signal_connect (G_OBJECT (shell->priv->tray_icon), "delete_event",
 			  G_CALLBACK (tray_deleted_cb), shell);
 }
+
+static void 
+session_die_cb (GnomeClient *client, 
+                RBShell *shell)
+{
+        rb_debug ("session die");
+        rb_shell_quit(shell);
+}
+
+static gboolean
+save_yourself_cb (GnomeClient *client, 
+                  gint phase,
+                  GnomeSaveStyle save_style,
+                  gboolean shutdown,
+                  GnomeInteractStyle interact_style,
+                  gboolean fast,
+                  RBShell *shell)
+{
+        rb_debug ("session save yourself");
+        rb_shell_sync_state(shell);
+        return TRUE;
+}
+
+static
+void rb_shell_session_init (RBShell *shell)
+{
+        GnomeClient *client;
+
+        client = gnome_master_client ();
+
+        g_signal_connect (G_OBJECT (client), 
+                          "save_yourself",
+                          G_CALLBACK (save_yourself_cb),
+                          shell);
+
+        g_signal_connect (G_OBJECT (client),
+                          "die",
+                          G_CALLBACK (session_die_cb),
+                          shell);
+}





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