[rhythmbox] stop using rb_shell_get_player and rb_shell_get_playlist_manager



commit 386a397b8181d272341f938e72610e091f4f3889
Author: Jonathan Matthew <jonathan d14n org>
Date:   Sat Apr 2 13:45:23 2011 +1000

    stop using rb_shell_get_player and rb_shell_get_playlist_manager

 plugins/audiocd/rb-audiocd-plugin.c                |    3 +-
 .../rb-audioscrobbler-profile-page.c               |   32 +++++++++++++++----
 .../rb-audioscrobbler-radio-source.c               |   22 ++++++++++----
 plugins/mtpdevice/rb-mtp-source.c                  |    3 +-
 podcast/rb-podcast-source.c                        |   10 +++++-
 sources/rb-browser-source.c                        |    7 +++-
 sources/rb-import-errors-source.c                  |    7 +++-
 sources/rb-missing-files-source.c                  |    7 +++-
 sources/rb-play-queue-source.c                     |    3 +-
 sources/rb-playlist-source.c                       |    7 +++-
 sources/sync/rb-sync-state.c                       |    5 ++-
 11 files changed, 79 insertions(+), 27 deletions(-)
---
diff --git a/plugins/audiocd/rb-audiocd-plugin.c b/plugins/audiocd/rb-audiocd-plugin.c
index 1839faa..2297506 100644
--- a/plugins/audiocd/rb-audiocd-plugin.c
+++ b/plugins/audiocd/rb-audiocd-plugin.c
@@ -325,7 +325,7 @@ impl_activate (RBPlugin *plugin,
 	 * in source elements, and when changing between tracks on the same CD, just seek
 	 * between them, rather than closing and reopening the device.
 	 */
-	shell_player = rb_shell_get_player (shell);
+	g_object_get (shell, "shell-player", &shell_player, NULL);
 	g_object_get (shell_player, "player", &player_backend, NULL);
 	if (player_backend) {
 		GObjectClass *klass = G_OBJECT_GET_CLASS (player_backend);
@@ -346,6 +346,7 @@ impl_activate (RBPlugin *plugin,
 						 plugin, 0);
 		}
 	}
+	g_object_unref (shell_player);
 
 	/* encoder hooks: specify the device and set the paranoia level (if available) on
 	 * source elements.
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-profile-page.c b/plugins/audioscrobbler/rb-audioscrobbler-profile-page.c
index b9d9e7a..eec7c1c 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-profile-page.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-profile-page.c
@@ -339,6 +339,7 @@ rb_audioscrobbler_profile_page_constructed (GObject *object)
 {
 	RBAudioscrobblerProfilePage *page;
 	RBShell *shell;
+	RBShellPlayer *shell_player;
 	char *scrobbling_enabled_conf_key;
 
 	RB_CHAIN_GOBJECT_METHOD (rb_audioscrobbler_profile_page_parent_class, constructed, object);
@@ -348,10 +349,12 @@ rb_audioscrobbler_profile_page_constructed (GObject *object)
 
 	rb_shell_append_display_page (shell, RB_DISPLAY_PAGE (page), RB_DISPLAY_PAGE_GROUP_LIBRARY);
 
-	g_signal_connect_object (rb_shell_get_player (shell),
+	g_object_get (shell, "shell-player", &shell_player, NULL);
+	g_signal_connect_object (shell_player,
 				 "playing-song-changed",
 				 G_CALLBACK (playing_song_changed_cb),
 				 page, 0);
+	g_object_unref (shell_player);
 
 	/* create the UI */
 	page->priv->main_vbox = gtk_vbox_new (FALSE, 4);
@@ -712,10 +715,12 @@ login_status_change_cb (RBAudioscrobblerAccount *account,
 	if (status == RB_AUDIOSCROBBLER_ACCOUNT_LOGIN_STATUS_LOGGED_IN &&
 	    eel_gconf_get_boolean (scrobbling_enabled_conf_key)) {
 		RBShell *shell;
+		RBShellPlayer *shell_player;
 		g_object_get (page, "shell", &shell, NULL);
+		g_object_get (shell, "shell-player", &shell_player, NULL);
 		page->priv->audioscrobbler =
 			rb_audioscrobbler_new (page->priv->service,
-				               RB_SHELL_PLAYER (rb_shell_get_player (shell)),
+				               shell_player,
                                                rb_audioscrobbler_account_get_username (page->priv->account),
 			                       rb_audioscrobbler_account_get_session_key (page->priv->account));
 		g_signal_connect (page->priv->audioscrobbler,
@@ -727,6 +732,7 @@ login_status_change_cb (RBAudioscrobblerAccount *account,
 			          G_CALLBACK (scrobbler_statistics_changed_cb),
 			          page);
 		rb_audioscrobbler_statistics_changed (page->priv->audioscrobbler);
+		g_object_unref (shell_player);
 		g_object_unref (shell);
 	}
 
@@ -828,10 +834,12 @@ scrobbling_enabled_changed_cb (GConfClient *client,
 		                     _("Disabled"));
 	} else if (page->priv->audioscrobbler == NULL && enabled == TRUE) {
 		RBShell *shell;
+		RBShellPlayer *shell_player;
 		g_object_get (page, "shell", &shell, NULL);
+		g_object_get (shell, "shell-player", &shell_player, NULL);
 		page->priv->audioscrobbler =
 			rb_audioscrobbler_new (page->priv->service,
-				               RB_SHELL_PLAYER (rb_shell_get_player (shell)),
+				               shell_player,
                                                rb_audioscrobbler_account_get_username (page->priv->account),
 			                       rb_audioscrobbler_account_get_session_key (page->priv->account));
 		g_signal_connect (page->priv->audioscrobbler,
@@ -843,6 +851,7 @@ scrobbling_enabled_changed_cb (GConfClient *client,
 			          G_CALLBACK (scrobbler_statistics_changed_cb),
 			          page);
 		rb_audioscrobbler_statistics_changed (page->priv->audioscrobbler);
+		g_object_unref (shell_player);
 		g_object_unref (shell);
 	}
 }
@@ -926,11 +935,13 @@ static void
 love_track_action_cb (GtkAction *action, RBAudioscrobblerProfilePage *page)
 {
 	RBShell *shell;
+	RBShellPlayer *shell_player;
 	RhythmDBEntry *playing;
 	GtkAction *ban_action;
 
 	g_object_get (page, "shell", &shell, NULL);
-	playing = rb_shell_player_get_playing_entry (RB_SHELL_PLAYER (rb_shell_get_player (shell)));
+	g_object_get (shell, "shell-player", &shell_player, NULL);
+	playing = rb_shell_player_get_playing_entry (shell_player);
 
 	if (playing != NULL) {
 		rb_audioscrobbler_user_love_track (page->priv->user,
@@ -944,6 +955,7 @@ love_track_action_cb (GtkAction *action, RBAudioscrobblerProfilePage *page)
 	ban_action = gtk_action_group_get_action (page->priv->service_action_group, page->priv->ban_action_name);
 	gtk_action_set_sensitive (ban_action, FALSE);
 
+	g_object_unref (shell_player);
 	g_object_unref (shell);
 }
 
@@ -951,10 +963,12 @@ static void
 ban_track_action_cb (GtkAction *action, RBAudioscrobblerProfilePage *page)
 {
 	RBShell *shell;
+	RBShellPlayer *shell_player;
 	RhythmDBEntry *playing;
 
 	g_object_get (page, "shell", &shell, NULL);
-	playing = rb_shell_player_get_playing_entry (RB_SHELL_PLAYER (rb_shell_get_player (shell)));
+	g_object_get (shell, "shell-player", &shell_player, NULL);
+	playing = rb_shell_player_get_playing_entry (shell_player);
 
 	if (playing != NULL) {
 		rb_audioscrobbler_user_ban_track (page->priv->user,
@@ -964,8 +978,9 @@ ban_track_action_cb (GtkAction *action, RBAudioscrobblerProfilePage *page)
 	}
 
 	/* skip to next track */
-	rb_shell_player_do_next (RB_SHELL_PLAYER (rb_shell_get_player (shell)), NULL);
+	rb_shell_player_do_next (shell_player, NULL);
 
+	g_object_unref (shell_player);
 	g_object_unref (shell);
 }
 
@@ -973,13 +988,15 @@ static void
 download_track_action_cb (GtkAction *action, RBAudioscrobblerProfilePage *page)
 {
 	RBShell *shell;
+	RBShellPlayer *shell_player;
 	RhythmDBEntry *playing;
 
 	/* disable the action */
 	gtk_action_set_sensitive (action, FALSE);
 
 	g_object_get (page, "shell", &shell, NULL);
-	playing = rb_shell_player_get_playing_entry (RB_SHELL_PLAYER (rb_shell_get_player (shell)));
+	g_object_get (shell, "shell-player", &shell_player, NULL);
+	playing = rb_shell_player_get_playing_entry (shell_player);
 
 	if (playing != NULL &&
 	    rhythmdb_entry_get_entry_type (playing) == RHYTHMDB_ENTRY_TYPE_AUDIOSCROBBLER_RADIO_TRACK) {
@@ -1040,6 +1057,7 @@ download_track_action_cb (GtkAction *action, RBAudioscrobblerProfilePage *page)
 		rb_debug ("cannot download: playing entry is not an audioscrobbler radio track");
 	}
 
+	g_object_unref (shell_player);
 	g_object_unref (shell);
 }
 
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
index b68bdea..6390f33 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
@@ -429,6 +429,7 @@ rb_audioscrobbler_radio_source_constructed (GObject *object)
 {
 	RBAudioscrobblerRadioSource *source;
 	RBShell *shell;
+	RBShellPlayer *shell_player;
 	RhythmDB *db;
 	GtkWidget *main_vbox;
 	GtkWidget *error_info_bar_content_area;
@@ -442,7 +443,10 @@ rb_audioscrobbler_radio_source_constructed (GObject *object)
 
 	source = RB_AUDIOSCROBBLER_RADIO_SOURCE (object);
 	g_object_get (source, "shell", &shell, NULL);
-	g_object_get (shell, "db", &db, NULL);
+	g_object_get (shell,
+		      "db", &db,
+		      "shell-player", &shell_player,
+		      NULL);
 
 	main_vbox = gtk_vbox_new (FALSE, 4);
 	gtk_widget_show (main_vbox);
@@ -473,7 +477,7 @@ rb_audioscrobbler_radio_source_constructed (GObject *object)
 	gtk_box_pack_start (GTK_BOX (main_vbox), source->priv->password_info_bar, FALSE, FALSE, 0);
 
 	/* entry view */
-	source->priv->track_view = rb_entry_view_new (db, rb_shell_get_player (shell), NULL, FALSE, FALSE);
+	source->priv->track_view = rb_entry_view_new (db, G_OBJECT (shell_player), NULL, FALSE, FALSE);
 	rb_entry_view_append_column (source->priv->track_view, RB_ENTRY_VIEW_COL_TITLE, TRUE);
 	rb_entry_view_append_column (source->priv->track_view, RB_ENTRY_VIEW_COL_ARTIST, FALSE);
 	rb_entry_view_append_column (source->priv->track_view, RB_ENTRY_VIEW_COL_ALBUM, FALSE);
@@ -489,10 +493,10 @@ rb_audioscrobbler_radio_source_constructed (GObject *object)
 	g_object_set (source, "query-model", source->priv->track_model, NULL);
 
 	/* play order */
-	source->priv->play_order = rb_audioscrobbler_play_order_new (RB_SHELL_PLAYER (rb_shell_get_player (shell)));
+	source->priv->play_order = rb_audioscrobbler_play_order_new (shell_player);
 
 	/* signals */
-	g_signal_connect_object (rb_shell_get_player (shell),
+	g_signal_connect_object (shell_player,
 				 "playing-song-changed",
 				 G_CALLBACK (playing_song_changed_cb),
 				 source, 0);
@@ -523,6 +527,7 @@ rb_audioscrobbler_radio_source_constructed (GObject *object)
 	rb_shell_append_display_page (shell, RB_DISPLAY_PAGE (source), RB_DISPLAY_PAGE (source->priv->parent));
 
 	g_object_unref (shell);
+	g_object_unref (shell_player);
 	g_object_unref (db);
 	g_object_unref (plugin);
 	g_object_unref (ui_manager);
@@ -1410,16 +1415,20 @@ static gboolean
 emit_coverart_uri_cb (RBAudioscrobblerRadioSource *source)
 {
 	RBShell *shell;
+	RBShellPlayer *shell_player;
 	RhythmDB *db;
 	RhythmDBEntry *entry;
 	const char *image_url;
 
 	g_object_get (source, "shell", &shell, NULL);
-	g_object_get (shell, "db", &db, NULL);
+	g_object_get (shell,
+		      "db", &db,
+		      "shell-player", &shell_player,
+		      NULL);
 
 	source->priv->emit_coverart_id = 0;
 
-	entry = rb_shell_player_get_playing_entry (RB_SHELL_PLAYER (rb_shell_get_player (shell)));
+	entry = rb_shell_player_get_playing_entry (shell_player);
 	image_url = get_image_url_for_entry (source, entry);
 	if (image_url != NULL) {
 		GValue v = {0,};
@@ -1432,6 +1441,7 @@ emit_coverart_uri_cb (RBAudioscrobblerRadioSource *source)
 		g_value_unset (&v);
 	}
 
+	g_object_unref (shell_player);
 	g_object_unref (shell);
 	g_object_unref (db);
 
diff --git a/plugins/mtpdevice/rb-mtp-source.c b/plugins/mtpdevice/rb-mtp-source.c
index 2782920..e854694 100644
--- a/plugins/mtpdevice/rb-mtp-source.c
+++ b/plugins/mtpdevice/rb-mtp-source.c
@@ -367,8 +367,9 @@ rb_mtp_source_constructed (GObject *object)
 
 	/* the source element needs our cooperation */
 	g_object_get (source, "shell", &shell, NULL);
-	shell_player = RB_SHELL_PLAYER (rb_shell_get_player (shell));
+	g_object_get (shell, "shell-player", &shell_player, NULL);
 	g_object_get (shell_player, "player", &player_backend, NULL);
+	g_object_unref (shell_player);
 
 	g_signal_connect_object (player_backend,
 				 "prepare-source",
diff --git a/podcast/rb-podcast-source.c b/podcast/rb-podcast-source.c
index 2e1933d..33c7c8a 100644
--- a/podcast/rb-podcast-source.c
+++ b/podcast/rb-podcast-source.c
@@ -46,6 +46,7 @@
 
 #include "rhythmdb.h"
 #include "rhythmdb-query-model.h"
+#include "rb-shell-player.h"
 #include "rb-stock-icons.h"
 #include "rb-entry-view.h"
 #include "rb-property-view.h"
@@ -1296,6 +1297,7 @@ impl_constructed (GObject *object)
 	GtkTreeViewColumn *column;
 	GtkCellRenderer *renderer;
 	RBShell *shell;
+	RBShellPlayer *shell_player;
 	RhythmDBQueryModel *query_model;
 	GtkAction *action;
 
@@ -1303,7 +1305,10 @@ impl_constructed (GObject *object)
 	source = RB_PODCAST_SOURCE (object);
 
 	g_object_get (source, "shell", &shell, NULL);
-	g_object_get (shell, "db", &source->priv->db, NULL);
+	g_object_get (shell,
+		      "db", &source->priv->db,
+		      "shell-player", &shell_player,
+		      NULL);
 
 	source->priv->action_group = _rb_display_page_register_action_group (RB_DISPLAY_PAGE (source),
 									     "PodcastActions",
@@ -1348,9 +1353,10 @@ impl_constructed (GObject *object)
 
 	/* set up posts view */
 	source->priv->posts = rb_entry_view_new (source->priv->db,
-						 rb_shell_get_player (shell),
+						 G_OBJECT (shell_player),
 						 CONF_STATE_PODCAST_SORTING_POSTS,
 						 TRUE, FALSE);
+	g_object_unref (shell_player);
 
 	g_signal_connect_object (source->priv->posts,
 				 "entry-activated",
diff --git a/sources/rb-browser-source.c b/sources/rb-browser-source.c
index b4e7a68..b96dba2 100644
--- a/sources/rb-browser-source.c
+++ b/sources/rb-browser-source.c
@@ -352,8 +352,10 @@ rb_browser_source_constructed (GObject *object)
 		      "shell", &shell,
 		      "entry-type", &entry_type,
 		      NULL);
-	g_object_get (shell, "db", &source->priv->db, NULL);
-	shell_player = rb_shell_get_player (shell);
+	g_object_get (shell,
+		      "db", &source->priv->db,
+		      "shell-player", &shell_player,
+		      NULL);
 
 	source->priv->action_group = _rb_display_page_register_action_group (RB_DISPLAY_PAGE (source),
 									     "BrowserSourceActions",
@@ -482,6 +484,7 @@ rb_browser_source_constructed (GObject *object)
 	rb_browser_source_populate (source);
 
 	g_object_unref (entry_type);
+	g_object_unref (shell_player);
 }
 
 static void
diff --git a/sources/rb-import-errors-source.c b/sources/rb-import-errors-source.c
index 2ec7c4b..1a18d0b 100644
--- a/sources/rb-import-errors-source.c
+++ b/sources/rb-import-errors-source.c
@@ -190,8 +190,10 @@ rb_import_errors_source_constructed (GObject *object)
 		      "shell", &shell,
 		      "entry-type", &entry_type,
 		      NULL);
-	g_object_get (shell, "db", &source->priv->db, NULL);
-	shell_player = rb_shell_get_player (shell);
+	g_object_get (shell,
+		      "db", &source->priv->db,
+		      "shell-player", &shell_player,
+		      NULL);
 	g_object_unref (shell);
 
 	/* construct real query */
@@ -209,6 +211,7 @@ rb_import_errors_source_constructed (GObject *object)
 	/* set up entry view */
 	source->priv->view = rb_entry_view_new (source->priv->db, shell_player,
 						NULL, FALSE, FALSE);
+	g_object_unref (shell_player);
 
 	rb_entry_view_set_model (source->priv->view, model);
 
diff --git a/sources/rb-missing-files-source.c b/sources/rb-missing-files-source.c
index f96ca33..d8fec4f 100644
--- a/sources/rb-missing-files-source.c
+++ b/sources/rb-missing-files-source.c
@@ -155,8 +155,10 @@ rb_missing_files_source_constructed (GObject *object)
 		      "shell", &shell,
 		      "entry-type", &entry_type,
 		      NULL);
-	g_object_get (shell, "db", &source->priv->db, NULL);
-	shell_player = rb_shell_get_player (shell);
+	g_object_get (shell,
+		      "db", &source->priv->db,
+		      "shell-player", &shell_player,
+		      NULL);
 	g_object_unref (shell);
 
 	/* construct real query */
@@ -180,6 +182,7 @@ rb_missing_files_source_constructed (GObject *object)
 	/* set up entry view */
 	source->priv->view = rb_entry_view_new (source->priv->db, shell_player,
 						NULL, FALSE, FALSE);
+	g_object_unref (shell_player);
 
 	rb_entry_view_set_model (source->priv->view, model);
 
diff --git a/sources/rb-play-queue-source.c b/sources/rb-play-queue-source.c
index 813e8a2..968fc27 100644
--- a/sources/rb-play-queue-source.c
+++ b/sources/rb-play-queue-source.c
@@ -270,7 +270,7 @@ rb_play_queue_source_constructed (GObject *object)
 	db = rb_playlist_source_get_db (RB_PLAYLIST_SOURCE (source));
 
 	g_object_get (source, "shell", &shell, NULL);
-	shell_player = rb_shell_get_player (shell);
+	g_object_get (shell, "shell-player", &shell_player, NULL);
 	g_object_unref (shell);
 
 	priv->queue_play_order = rb_queue_play_order_new (RB_SHELL_PLAYER (shell_player));
@@ -286,6 +286,7 @@ rb_play_queue_source_constructed (GObject *object)
 	g_object_set (G_OBJECT (action), "short-label", _("Clear"), NULL);
 
 	priv->sidebar = rb_entry_view_new (db, shell_player, NULL, TRUE, TRUE);
+	g_object_unref (shell_player);
 
 	g_object_set (G_OBJECT (priv->sidebar), "vscrollbar-policy", GTK_POLICY_AUTOMATIC, NULL);
 
diff --git a/sources/rb-playlist-source.c b/sources/rb-playlist-source.c
index 9c488bb..1090565 100644
--- a/sources/rb-playlist-source.c
+++ b/sources/rb-playlist-source.c
@@ -294,8 +294,10 @@ rb_playlist_source_constructed (GObject *object)
 	source = RB_PLAYLIST_SOURCE (object);
 
 	g_object_get (source, "shell", &shell, NULL);
-	g_object_get (shell, "db", &db, NULL);
-	shell_player = rb_shell_get_player (shell);
+	g_object_get (shell,
+		      "db", &db,
+		      "shell-player", &shell_player,
+		      NULL);
 	rb_playlist_source_set_db (source, db);
 	g_object_unref (db);
 
@@ -320,6 +322,7 @@ rb_playlist_source_constructed (GObject *object)
 						 shell_player,
 					 	 sorting_key, TRUE, TRUE);
 	g_free (sorting_key);
+	g_object_unref (shell_player);
 
 	g_signal_connect_object (source->priv->songs,
 				 "sort-order-changed",
diff --git a/sources/sync/rb-sync-state.c b/sources/sync/rb-sync-state.c
index 38c11e1..4c5f0c2 100644
--- a/sources/sync/rb-sync-state.c
+++ b/sources/sync/rb-sync-state.c
@@ -211,10 +211,13 @@ itinerary_insert_some_playlists (RBSyncState *state,
 {
 	GList *list_iter;
 	GList *playlists;
+	RBPlaylistManager *playlist_manager;
 	RBShell *shell;
 
 	g_object_get (state->priv->source, "shell", &shell, NULL);
-	playlists = rb_playlist_manager_get_playlists ((RBPlaylistManager *) rb_shell_get_playlist_manager (shell));
+	g_object_get (shell, "playlist-manager", &playlist_manager, NULL);
+	playlists = rb_playlist_manager_get_playlists (playlist_manager);
+	g_object_unref (playlist_manager);
 	g_object_unref (shell);
 
 	for (list_iter = playlists; list_iter; list_iter = list_iter->next) {



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