Skip to content
This repository has been archived by the owner on Mar 10, 2019. It is now read-only.

Commit

Permalink
move default playlists file into GResources
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Matthew committed Aug 10, 2016
1 parent 6a85e2c commit ca9209b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions data/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 13 additions & 19 deletions shell/rb-playlist-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions shell/rhythmbox.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit ca9209b

Please sign in to comment.