[rhythmbox] move default playlists file into GResources
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] move default playlists file into GResources
- Date: Wed, 10 Aug 2016 04:39:07 +0000 (UTC)
commit ca9209b6c7a9b1d419bbf4b0961baa7f08203089
Author: Jonathan Matthew <jonathan d14n org>
Date: Wed Jun 22 20:49:27 2016 +1000
move default playlists file into GResources
Makefile.am | 4 ++--
data/Makefile.am | 3 +--
shell/rb-playlist-manager.c | 32 +++++++++++++-------------------
shell/rhythmbox.gresource.xml | 2 ++
4 files changed, 18 insertions(+), 23 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index c97392c..fa51586 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,8 +3,8 @@ ACLOCAL_AMFLAGS = --install -I m4 ${ACLOCAL_FLAGS}
DISTCHECK_CONFIGURE_FLAGS = --disable-schemas-install --enable-gtk-doc --disable-scrollkeeper
distuninstallcheck_listfiles = find . -type f -print | grep -v '^\./var/scrollkeeper'
-SUBDIRS = lib metadata rhythmdb widgets sources podcast \
- backends shell bindings sample-plugins plugins remote data po help tests doc
+SUBDIRS = data lib metadata rhythmdb widgets sources podcast \
+ backends shell bindings sample-plugins plugins remote po help tests doc
# what?
#INCLUDES = rhythmbox.h
diff --git a/data/Makefile.am b/data/Makefile.am
index 50fba49..9cda00e 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -8,8 +8,7 @@ Multimedia_in_files = rhythmbox.desktop.in rhythmbox-device.desktop.in
Multimedia_DATA = $(Multimedia_in_files:.desktop.in=.desktop)
playlists_in_files = playlists.xml.in
-playlists_DATA = playlists.xml
-playlistsdir = $(datadir)/rhythmbox
+noinst_DATA = playlists.xml
man_MANS = rhythmbox.1 rhythmbox-client.1
diff --git a/shell/rb-playlist-manager.c b/shell/rb-playlist-manager.c
index 2c6608e..9d4178b 100644
--- a/shell/rb-playlist-manager.c
+++ b/shell/rb-playlist-manager.c
@@ -354,34 +354,29 @@ append_new_playlist_source (RBPlaylistManager *mgr, RBPlaylistSource *source)
void
rb_playlist_manager_load_playlists (RBPlaylistManager *mgr)
{
- char *file;
+ GBytes *data = NULL;
xmlDocPtr doc;
xmlNodePtr root;
xmlNodePtr child;
- gboolean exists;
-
- exists = FALSE;
- file = g_strdup (mgr->priv->playlists_file);
/* block saves until the playlists have loaded */
g_mutex_lock (&mgr->priv->saving_mutex);
- exists = g_file_test (file, G_FILE_TEST_EXISTS);
- if (! exists) {
+ if (g_file_test (mgr->priv->playlists_file, G_FILE_TEST_EXISTS) == FALSE) {
rb_debug ("personal playlists not found, loading defaults");
-
- /* try global playlists */
- g_free (file);
- file = g_strdup (rb_file ("playlists.xml"));
- exists = g_file_test (file, G_FILE_TEST_EXISTS);
- }
-
- if (! exists) {
- rb_debug ("default playlists file not found");
- goto out;
+ data = g_resources_lookup_data ("/org/gnome/Rhythmbox/playlists.xml",
+ G_RESOURCE_LOOKUP_FLAGS_NONE,
+ NULL);
+ if (data == NULL) {
+ rb_debug ("couldn't find default playlists resource");
+ goto out;
+ }
}
- doc = xmlParseFile (file);
+ if (data != NULL)
+ doc = xmlParseMemory (g_bytes_get_data (data, NULL), g_bytes_get_size (data));
+ else
+ doc = xmlParseFile (mgr->priv->playlists_file);
if (doc == NULL)
goto out;
@@ -402,7 +397,6 @@ rb_playlist_manager_load_playlists (RBPlaylistManager *mgr)
xmlFreeDoc (doc);
out:
g_mutex_unlock (&mgr->priv->saving_mutex);
- g_free (file);
}
static void
diff --git a/shell/rhythmbox.gresource.xml b/shell/rhythmbox.gresource.xml
index 751c61b..5ce4c66 100644
--- a/shell/rhythmbox.gresource.xml
+++ b/shell/rhythmbox.gresource.xml
@@ -40,5 +40,7 @@
<file preprocess="xml-stripblanks">ui/sync-dialog.ui</file>
<file preprocess="xml-stripblanks">ui/sync-state.ui</file>
<file preprocess="xml-stripblanks">ui/uri-new.ui</file>
+
+ <file preprocess="xml-stripblanks">playlists.xml</file>
</gresource>
</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]