rhythmbox r6018 - in trunk: . shell sources
- From: jmatthew svn gnome org
- To: svn-commits-list gnome org
- Subject: rhythmbox r6018 - in trunk: . shell sources
- Date: Sat, 8 Nov 2008 08:31:27 +0000 (UTC)
Author: jmatthew
Date: Sat Nov 8 08:31:27 2008
New Revision: 6018
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=6018&view=rev
Log:
2008-11-08 Jonathan Matthew <jonathan d14n org>
patch partly by: Lasse Bigum <zenith zenith dk>
patch also partly by: Martin Franco <mfranco gmx com>
* shell/rb-playlist-manager.c:
(rb_playlist_manager_cmd_load_playlist),
(save_playlist_response_cb), (export_set_extension_cb),
(setup_format_menu):
* shell/rb-playlist-manager.h:
Add mimetype to playlist format information, add XSPF format, and use
the playlist information to set up filters for the import dialog.
Fixes #551217.
* sources/rb-playlist-source.c: (rb_playlist_source_save_playlist):
* sources/rb-playlist-source.h:
Add XSPF export. From #375665.
Modified:
trunk/ChangeLog
trunk/shell/rb-playlist-manager.c
trunk/shell/rb-playlist-manager.h
trunk/sources/rb-playlist-source.c
trunk/sources/rb-playlist-source.h
Modified: trunk/shell/rb-playlist-manager.c
==============================================================================
--- trunk/shell/rb-playlist-manager.c (original)
+++ trunk/shell/rb-playlist-manager.c Sat Nov 8 08:31:27 2008
@@ -142,6 +142,26 @@
static guint rb_playlist_manager_signals[LAST_SIGNAL] = { 0 };
+typedef struct {
+ const gchar *description;
+ /* NULL terminated array of extensions for this file format. The first
+ * one is the prefered extension for files of this type. */
+ const gchar **extensions;
+ const char *mimetype;
+ const RBPlaylistExportType type;
+} RBPlaylistExportFilter;
+
+static const char *m3u_extensions [] = {"m3u", NULL};
+static const char *pls_extensions [] = {"pls", NULL};
+static const char *xspf_extensions[] = {"xspf", NULL};
+
+static RBPlaylistExportFilter playlist_formats[] = {
+ {N_("MPEG Version 3.0 URL"), m3u_extensions, "audio/x-mpegurl", RB_PLAYLIST_EXPORT_TYPE_M3U},
+ {N_("Shoutcast playlist"), pls_extensions, "audio/x-scpls", RB_PLAYLIST_EXPORT_TYPE_PLS},
+ {N_("XML Shareable Playlist Format"), xspf_extensions, "application/xspf+xml", RB_PLAYLIST_EXPORT_TYPE_XSPF},
+};
+
+
static GtkActionEntry rb_playlist_manager_actions [] =
{
/* Submenu of Music */
@@ -1366,32 +1386,33 @@
RBPlaylistManager *mgr)
{
GtkWidget *dialog;
+ GtkFileFilter *filter;
+ GtkFileFilter *filter_all;
+ int i;
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("Playlists"));
+ for (i = 0; i < G_N_ELEMENTS (playlist_formats); i++) {
+ gtk_file_filter_add_mime_type (filter, playlist_formats[i].mimetype);
+ }
+
+ filter_all = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter_all, _("All Files"));
+ gtk_file_filter_add_pattern (filter_all, "*");
+
dialog = rb_file_chooser_new (_("Load Playlist"),
GTK_WINDOW (mgr->priv->window),
GTK_FILE_CHOOSER_ACTION_OPEN,
FALSE);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter_all);
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
g_signal_connect_object (dialog, "response",
G_CALLBACK (load_playlist_response_cb), mgr, 0);
}
-typedef struct {
- const gchar *description;
- /* NULL terminated array of extensions for this file format. The first
- * one is the prefered extension for files of this type. */
- const gchar **extensions;
- const RBPlaylistExportType type;
-} RBPlaylistExportFilter;
-
-static const char *m3u_extensions [] = {"m3u", NULL};
-static const char *pls_extensions [] = {"pls", NULL};
-
-static RBPlaylistExportFilter playlist_export_formats[] = {
- {N_("MPEG Version 3.0 URL"), m3u_extensions, RB_PLAYLIST_EXPORT_TYPE_M3U},
- {N_("Shoutcast playlist"), pls_extensions, RB_PLAYLIST_EXPORT_TYPE_PLS},
-};
-
static void
save_playlist_response_cb (GtkDialog *dialog,
int response_id,
@@ -1418,26 +1439,26 @@
if (index <= 0) {
int i;
- for (i = 0; i < G_N_ELEMENTS (playlist_export_formats); i++) {
+ for (i = 0; i < G_N_ELEMENTS (playlist_formats); i++) {
int j;
/* determine the playlist type from the extension */
- for (j = 0; playlist_export_formats[i].extensions[j] != NULL; j++) {
- if (g_str_has_suffix (file, playlist_export_formats[i].extensions[j])) {
- export_type = playlist_export_formats[i].type;
+ for (j = 0; playlist_formats[i].extensions[j] != NULL; j++) {
+ if (g_str_has_suffix (file, playlist_formats[i].extensions[j])) {
+ export_type = playlist_formats[i].type;
break;
}
}
}
} else {
- export_type = playlist_export_formats[index-1].type;
+ export_type = playlist_formats[index-1].type;
}
if (export_type == RB_PLAYLIST_EXPORT_TYPE_UNKNOWN) {
- rb_error_dialog (NULL, _("Couldn't save playlist"), _("Unsupported file extension given."));
+ rb_error_dialog (NULL, _("Couldn't save playlist"), _("Unsupported file extension given."));
} else {
rb_playlist_source_save_playlist (RB_PLAYLIST_SOURCE (mgr->priv->selected_source),
- file, (export_type == RB_PLAYLIST_EXPORT_TYPE_M3U));
+ file, export_type);
gtk_widget_destroy (GTK_WIDGET (dialog));
}
@@ -1458,7 +1479,7 @@
if (index <= 0)
return;
- extension = playlist_export_formats[index-1].extensions[0];
+ extension = playlist_formats[index-1].extensions[0];
if (extension == NULL)
return;
@@ -1512,11 +1533,11 @@
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (menu), rb_combo_box_hyphen_separator_func,
NULL, NULL);
- for (i = 0; i < G_N_ELEMENTS (playlist_export_formats); i++) {
+ for (i = 0; i < G_N_ELEMENTS (playlist_formats); i++) {
gchar *filter_label;
GtkTreeIter iter;
- filter_label = filter_get_export_filter_label (&playlist_export_formats[i]);
+ filter_label = filter_get_export_filter_label (&playlist_formats[i]);
gtk_list_store_insert_with_values (GTK_LIST_STORE (model), &iter, -1,
0, filter_label, -1);
Modified: trunk/shell/rb-playlist-manager.h
==============================================================================
--- trunk/shell/rb-playlist-manager.h (original)
+++ trunk/shell/rb-playlist-manager.h Sat Nov 8 08:31:27 2008
@@ -82,6 +82,7 @@
RB_PLAYLIST_EXPORT_TYPE_UNKNOWN,
RB_PLAYLIST_EXPORT_TYPE_M3U,
RB_PLAYLIST_EXPORT_TYPE_PLS,
+ RB_PLAYLIST_EXPORT_TYPE_XSPF,
} RBPlaylistExportType;
GType rb_playlist_manager_get_type (void);
Modified: trunk/sources/rb-playlist-source.c
==============================================================================
--- trunk/sources/rb-playlist-source.c (original)
+++ trunk/sources/rb-playlist-source.c Sat Nov 8 08:31:27 2008
@@ -54,6 +54,8 @@
#include "rb-static-playlist-source.h"
#include "rb-auto-playlist-source.h"
+#include "rb-playlist-manager.h"
+
/**
* SECTION:rb-playlist-source
* @short_description: Base class for playlist sources
@@ -584,19 +586,20 @@
* rb_playlist_source_save_playlist:
* @source: a #RBPlaylistSource
* @uri: destination URI
- * @m3u_format: if TRUE, save as .m3u, otherwise .pls
+ * @export_type: format to save in
*
* Saves the playlist to an external file in a standard
- * format (M3U or PLS).
+ * format (M3U, PLS, or XSPF).
*/
void
rb_playlist_source_save_playlist (RBPlaylistSource *source,
const char *uri,
- gboolean m3u_format)
+ RBPlaylistExportType export_type)
{
TotemPlParser *playlist;
GError *error = NULL;
char *name;
+ gint totem_format;
g_return_if_fail (RB_IS_PLAYLIST_SOURCE (source));
@@ -605,9 +608,22 @@
g_object_get (source, "name", &name, NULL);
+ switch (export_type) {
+ case RB_PLAYLIST_EXPORT_TYPE_XSPF:
+ totem_format = TOTEM_PL_PARSER_XSPF;
+ break;
+ case RB_PLAYLIST_EXPORT_TYPE_M3U:
+ totem_format = TOTEM_PL_PARSER_M3U;
+ break;
+ case RB_PLAYLIST_EXPORT_TYPE_PLS:
+ default:
+ totem_format = TOTEM_PL_PARSER_PLS;
+ break;
+ }
+
totem_pl_parser_write_with_title (playlist, GTK_TREE_MODEL (source->priv->model),
playlist_iter_func, uri, name,
- m3u_format ? TOTEM_PL_PARSER_M3U : TOTEM_PL_PARSER_PLS,
+ totem_format,
NULL, &error);
g_object_unref (playlist);
g_free (name);
Modified: trunk/sources/rb-playlist-source.h
==============================================================================
--- trunk/sources/rb-playlist-source.h (original)
+++ trunk/sources/rb-playlist-source.h Sat Nov 8 08:31:27 2008
@@ -37,6 +37,7 @@
#include "rb-source.h"
#include "rhythmdb.h"
#include "rhythmdb-query-model.h"
+#include "rb-playlist-manager.h"
G_BEGIN_DECLS
@@ -76,7 +77,7 @@
void rb_playlist_source_save_playlist(RBPlaylistSource *source,
const char *uri,
- gboolean m3u_format);
+ RBPlaylistExportType export_type);
void rb_playlist_source_save_to_xml (RBPlaylistSource *source,
xmlNodePtr parent_node);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]