[Rhythmbox-devel] Create playlist from library selection



Hi,

I'm quite fond of creating elaborate artist/album/filter combinations,
but when other people play different music I lose those selections, and
have to fuss around for another 5 minutes to get it as I please.

To sort this, I've created a menu item which makes a new automatic
playlist from the selection. This makes it a snap to create automatic
playlists (I always found the dialogue awkward, this WYSIWYG approach
works better) and flipping through favourite combinations is also very
easy too.

The menu item string is probably not the best, but I am of course here
for criticism ;).

Thanks
Ed Mack
Index: shell/rb-playlist-manager.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/shell/rb-playlist-manager.c,v
retrieving revision 1.48
diff -u -r1.48 rb-playlist-manager.c
--- shell/rb-playlist-manager.c	19 Jun 2005 16:38:12 -0000	1.48
+++ shell/rb-playlist-manager.c	27 Jul 2005 19:34:34 -0000
@@ -68,6 +68,8 @@
 						   RBPlaylistManager *mgr);
 static void rb_playlist_manager_cmd_new_playlist (GtkAction *action,
 						  RBPlaylistManager *mgr);
+static void rb_playlist_manager_cmd_new_reflection_playlist (GtkAction *action,
+							RBPlaylistManager *mgr);
 static void rb_playlist_manager_cmd_new_automatic_playlist (GtkAction *action,
 							    RBPlaylistManager *mgr);
 static void rb_playlist_manager_cmd_rename_playlist (GtkAction *action,
@@ -143,6 +145,9 @@
 	{ "MusicPlaylistNewPlaylist", GTK_STOCK_NEW, N_("_New Playlist..."), "<control>N",
 	  N_("Create a new playlist"),
 	  G_CALLBACK (rb_playlist_manager_cmd_new_playlist) },
+	{ "MusicPlaylistNewReflectionPlaylist", GTK_STOCK_NEW, N_("New Playlist from _selection"), NULL,
+	  N_("Create a new automatic playlist from the library selection"),
+	  G_CALLBACK (rb_playlist_manager_cmd_new_reflection_playlist) },
 	{ "MusicPlaylistNewAutomaticPlaylist", RB_STOCK_AUTOMATIC_PLAYLIST, N_("New _Automatic Playlist..."), NULL,
 	  N_("Create a new automatically updating playlist"),
 	  G_CALLBACK (rb_playlist_manager_cmd_new_automatic_playlist) },
@@ -735,6 +740,24 @@
 }
 
 static void
+rb_playlist_manager_cmd_new_reflection_playlist (GtkAction *action,
+						RBPlaylistManager *mgr)
+{
+	RBLibrarySource *source;
+	RBSource *playlist;
+
+	source = mgr->priv->libsource;
+	
+	playlist = rb_playlist_manager_new_playlist (mgr, NULL, TRUE);
+	
+	rb_playlist_source_set_query (RB_PLAYLIST_SOURCE (playlist),
+				                     rb_library_get_query (source),
+				                     0, 0);
+
+	rb_playlist_manager_set_dirty (mgr);
+}
+
+static void
 rb_playlist_manager_cmd_new_automatic_playlist (GtkAction *action,
 						RBPlaylistManager *mgr)
 {
Index: sources/rb-library-source.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/sources/rb-library-source.c,v
retrieving revision 1.108
diff -u -r1.108 rb-library-source.c
--- sources/rb-library-source.c	23 Jul 2005 12:41:07 -0000	1.108
+++ sources/rb-library-source.c	27 Jul 2005 19:34:37 -0000
@@ -1458,6 +1458,11 @@
 	return query;
 }
 
+GPtrArray * rb_library_get_query (RBLibrarySource *source)
+{
+	return construct_query_from_selection (source);
+}
+
 static void
 rb_library_source_do_query (RBLibrarySource *source, RBLibraryQueryType qtype)
 {
Index: sources/rb-library-source.h
===================================================================
RCS file: /cvs/gnome/rhythmbox/sources/rb-library-source.h,v
retrieving revision 1.12
diff -u -r1.12 rb-library-source.h
--- sources/rb-library-source.h	10 Sep 2004 05:12:59 -0000	1.12
+++ sources/rb-library-source.h	27 Jul 2005 19:34:37 -0000
@@ -64,6 +64,8 @@
 void            rb_library_source_class_add_actions (RBShell *shell, 
 						     GtkActionGroup *uimgr);
 
+GPtrArray * rb_library_get_query (RBLibrarySource *source);
+
 G_END_DECLS
 
 #endif /* __RB_LIBRARY_SOURCE_H */
Index: data/ui/rhythmbox-ui.xml
===================================================================
RCS file: /cvs/gnome/rhythmbox/data/ui/rhythmbox-ui.xml,v
retrieving revision 1.20
diff -u -r1.20 rhythmbox-ui.xml
--- data/ui/rhythmbox-ui.xml	26 Jul 2005 14:07:28 -0000	1.20
+++ data/ui/rhythmbox-ui.xml	27 Jul 2005 19:34:38 -0000
@@ -7,6 +7,7 @@
       <separator/>
       <menu name="PlaylistMenu" action="Playlist">
 	<menuitem name="MusicPlaylistNewPlaylistMenu" action="MusicPlaylistNewPlaylist"/>
+	<menuitem name="MusicPlaylistNewReflectionPlaylistMenu" action="MusicPlaylistNewReflectionPlaylist"/>
 	<menuitem name="MusicPlaylistNewAutomaticPlaylistMenu" action="MusicPlaylistNewAutomaticPlaylist"/>
 	<menuitem name="MusicPlaylistLoadPlaylistMenu" action="MusicPlaylistLoadPlaylist"/>
 	<menuitem name="MusicPlaylistSavePlaylistMenu" action="MusicPlaylistSavePlaylist"/>


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