[rhythmbox] shell: add 'autostarted' property



commit 3d6a5b50befcc6571f75bd74729deac931ea1ef1
Author: Jonathan Matthew <jonathan d14n org>
Date:   Thu Jun 24 16:26:50 2010 +1000

    shell: add 'autostarted' property
    
    This is set based on the DESKTOP_AUTOSTART_ID environment variable, which
    when set indicates that the app was started automatically by the session manager.

 shell/main.c     |    5 ++++-
 shell/rb-shell.c |   26 +++++++++++++++++++++++++-
 shell/rb-shell.h |    1 +
 3 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/shell/main.c b/shell/main.c
index a4dd50a..215141d 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -104,6 +104,7 @@ main (int argc, char **argv)
 	GError *error = NULL;
 	RBShell *rb_shell;
 	gboolean activated;
+	gboolean autostarted;
 	char *accel_map_file = NULL;
 	char *desktop_file_path;
 
@@ -125,6 +126,8 @@ main (int argc, char **argv)
 
 	rb_profile_start ("starting rhythmbox");
 
+	autostarted = (g_getenv ("DESKTOP_AUTOSTART_ID") != NULL);
+
 #ifdef USE_UNINSTALLED_DIRS
 	desktop_file_path = g_build_filename (SHARE_UNINSTALLED_BUILDDIR, "rhythmbox.desktop", NULL);
 #else
@@ -270,7 +273,7 @@ main (int argc, char **argv)
 
 		g_setenv ("PULSE_PROP_media.role", "music", TRUE);
 
-		rb_shell = rb_shell_new (no_registration, no_update, dry_run, rhythmdb_file, playlists_file);
+		rb_shell = rb_shell_new (no_registration, no_update, dry_run, autostarted, rhythmdb_file, playlists_file);
 		g_object_weak_ref (G_OBJECT (rb_shell), main_shell_weak_ref_cb, NULL);
 		if (!no_registration && session_bus != NULL) {
 			GObject *obj;
diff --git a/shell/rb-shell.c b/shell/rb-shell.c
index f58358c..bc0f4a4 100644
--- a/shell/rb-shell.c
+++ b/shell/rb-shell.c
@@ -260,6 +260,7 @@ enum
 	PROP_SOURCE_HEADER,
 	PROP_VISIBILITY,
 	PROP_TRACK_TRANSFER_QUEUE,
+	PROP_AUTOSTARTED
 };
 
 /* prefs */
@@ -325,6 +326,7 @@ struct _RBShellPrivate
 	gboolean no_registration;
 	gboolean no_update;
 	gboolean dry_run;
+	gboolean autostarted;
 	char *rhythmdb_file;
 	char *playlists_file;
 
@@ -720,6 +722,18 @@ rb_shell_class_init (RBShellClass *klass)
 							      "RBTrackTransferQueue object",
 							      RB_TYPE_TRACK_TRANSFER_QUEUE,
 							      G_PARAM_READABLE));
+	/**
+	 * RBShell:autostarted:
+	 *
+	 * Whether Rhythmbox was automatically started by the session manager
+	 */
+	g_object_class_install_property (object_class,
+					 PROP_AUTOSTARTED,
+					 g_param_spec_boolean ("autostarted",
+							       "autostarted",
+							       "TRUE if autostarted",
+							       FALSE,
+							       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 
 	/**
 	 * RBShell::visibility-changed:
@@ -887,6 +901,9 @@ rb_shell_set_property (GObject *object,
 	case PROP_VISIBILITY:
 		rb_shell_set_visibility (shell, FALSE, g_value_get_boolean (value));
 		break;
+	case PROP_AUTOSTARTED:
+		shell->priv->autostarted = g_value_get_boolean (value);
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -972,6 +989,9 @@ rb_shell_get_property (GObject *object,
 	case PROP_TRACK_TRANSFER_QUEUE:
 		g_value_set_object (value, shell->priv->track_transfer_queue);
 		break;
+	case PROP_AUTOSTARTED:
+		g_value_set_boolean (value, shell->priv->autostarted);
+		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -1112,6 +1132,7 @@ rb_shell_finalize (GObject *object)
  * @no_registration: if %TRUE, single-instance features are disabled
  * @no_update: if %TRUE, don't update the database file
  * @dry_run: if %TRUE, don't write back file metadata changes
+ * @autostarted: %TRUE if autostarted by the session manager
  * @rhythmdb: path to the database file
  * @playlists: path to the playlist file
  *
@@ -1124,6 +1145,7 @@ RBShell *
 rb_shell_new (gboolean no_registration,
 	      gboolean no_update,
 	      gboolean dry_run,
+	      gboolean autostarted,
 	      char *rhythmdb,
 	      char *playlists)
 {
@@ -1131,7 +1153,9 @@ rb_shell_new (gboolean no_registration,
 			  "no-registration", no_registration,
 			  "no-update", no_update,
 			  "dry-run", dry_run, "rhythmdb-file", rhythmdb, 
-			  "playlists-file", playlists, NULL);
+			  "playlists-file", playlists,
+			  "autostarted", autostarted,
+			  NULL);
 }
 
 static GMountOperation *
diff --git a/shell/rb-shell.h b/shell/rb-shell.h
index 945c9f4..60caa03 100644
--- a/shell/rb-shell.h
+++ b/shell/rb-shell.h
@@ -94,6 +94,7 @@ GType		rb_shell_get_type	(void);
 RBShell *	rb_shell_new		(gboolean no_registration,
 					 gboolean no_update,
 					 gboolean dry_run,
+					 gboolean autostarted,
 					 char *rhythmdb,
 					 char *playlists);
 



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