[rhythmbox] audioscrobbler: use new RhythmDBEntryType system
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] audioscrobbler: use new RhythmDBEntryType system
- Date: Tue, 21 Sep 2010 10:54:12 +0000 (UTC)
commit e22cd019dbcfed88a6e24af463bbec2cc9c58891
Author: Jamie Nicol <jamie thenicols net>
Date: Tue Aug 3 22:11:58 2010 +0100
audioscrobbler: use new RhythmDBEntryType system
plugins/audioscrobbler/Makefile.am | 4 +-
plugins/audioscrobbler/rb-audioscrobbler-entry.c | 2 +-
.../rb-audioscrobbler-profile-source.c | 1 -
.../rb-audioscrobbler-radio-source.c | 10 +++--
... => rb-audioscrobbler-radio-track-entry-type.c} | 37 +++++++++++---------
... => rb-audioscrobbler-radio-track-entry-type.h} | 14 +++++---
tests/Makefile.am | 2 +-
7 files changed, 39 insertions(+), 31 deletions(-)
---
diff --git a/plugins/audioscrobbler/Makefile.am b/plugins/audioscrobbler/Makefile.am
index bb83e5b..e22268d 100644
--- a/plugins/audioscrobbler/Makefile.am
+++ b/plugins/audioscrobbler/Makefile.am
@@ -19,8 +19,8 @@ libaudioscrobbler_la_SOURCES = \
rb-audioscrobbler.h \
rb-audioscrobbler-radio-source.c \
rb-audioscrobbler-radio-source.h \
- rb-audioscrobbler-radio-track-entry.h \
- rb-audioscrobbler-radio-track-entry.c \
+ rb-audioscrobbler-radio-track-entry-type.h \
+ rb-audioscrobbler-radio-track-entry-type.c \
rb-lastfm-play-order.c \
rb-lastfm-play-order.h
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-entry.c b/plugins/audioscrobbler/rb-audioscrobbler-entry.c
index 15a5854..3e6d28f 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-entry.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-entry.c
@@ -41,7 +41,7 @@
#include <libsoup/soup.h>
#include "rb-audioscrobbler-entry.h"
-#include "rb-audioscrobbler-radio-track-entry.h"
+#include "rb-audioscrobbler-radio-track-entry-type.h"
void
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c b/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
index 81ca424..57a46d3 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
@@ -266,7 +266,6 @@ rb_audioscrobbler_profile_source_new (RBShell *shell, RBPlugin *plugin, RBAudios
"plugin", plugin,
"name", name,
"source-group", RB_SOURCE_GROUP_LIBRARY,
- "entry-type", RHYTHMDB_ENTRY_TYPE_INVALID,
"icon", icon_pixbuf,
"service", service,
NULL));
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
index 877c049..7ab2570 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
@@ -42,7 +42,7 @@
#include <totem-pl-parser.h>
#include "rb-audioscrobbler-radio-source.h"
-#include "rb-audioscrobbler-radio-track-entry.h"
+#include "rb-audioscrobbler-radio-track-entry-type.h"
#include "rb-lastfm-play-order.h"
#include "rb-debug.h"
#include "rb-sourcelist.h"
@@ -263,7 +263,9 @@ rb_audioscrobbler_radio_source_new (RBAudioscrobblerProfileSource *parent,
g_object_get (parent, "shell", &shell, "plugin", &plugin, NULL);
g_object_get (shell, "db", &db, NULL);
- rb_audioscrobbler_radio_track_register_entry_type (db);
+ if (RHYTHMDB_ENTRY_TYPE_AUDIOSCROBBLER_RADIO_TRACK == NULL) {
+ rb_audioscrobbler_radio_track_register_entry_type (db);
+ }
source = g_object_new (RB_TYPE_AUDIOSCROBBLER_RADIO_SOURCE,
"shell", shell,
@@ -904,7 +906,7 @@ xspf_entry_parsed (TotemPlParser *parser,
RBAudioscrobblerRadioSource *source)
{
RBShell *shell;
- RhythmDBEntryType entry_type;
+ RhythmDBEntryType *entry_type;
RhythmDB *db;
RhythmDBEntry *entry;
@@ -1281,7 +1283,7 @@ static const char *
get_image_url_for_entry (RBAudioscrobblerRadioSource *source, RhythmDBEntry *entry)
{
RBAudioscrobblerRadioTrackData *data;
- RhythmDBEntryType entry_type;
+ RhythmDBEntryType *entry_type;
if (entry == NULL) {
return NULL;
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry.c b/plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry-type.c
similarity index 63%
rename from plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry.c
rename to plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry-type.c
index a2c045c..e062a9a 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry-type.c
@@ -26,12 +26,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "rb-audioscrobbler-radio-track-entry.h"
+#include "rb-audioscrobbler-radio-track-entry-type.h"
-static RhythmDBEntryType type = RHYTHMDB_ENTRY_TYPE_INVALID;
+static RhythmDBEntryType *radio_track_entry_type = NULL;
static void
-destroy_track_data (RhythmDBEntry *entry, gpointer meh)
+track_data_destroy (RhythmDBEntryType *entry_type, RhythmDBEntry *entry)
{
RBAudioscrobblerRadioTrackData *data;
data = RHYTHMDB_ENTRY_GET_TYPE_DATA (entry, RBAudioscrobblerRadioTrackData);
@@ -41,22 +41,25 @@ destroy_track_data (RhythmDBEntry *entry, gpointer meh)
g_free (data->download_url);
}
-void
-rb_audioscrobbler_radio_track_register_entry_type (RhythmDB *db)
+RhythmDBEntryType *
+rb_audioscrobbler_radio_track_get_entry_type (void)
{
- type = rhythmdb_entry_type_get_by_name (db, "audioscrobbler-radio-track");
- if (type == RHYTHMDB_ENTRY_TYPE_INVALID) {
- type = rhythmdb_entry_register_type (db, "audioscrobbler-radio-track");
- type->save_to_disk = FALSE;
- type->category = RHYTHMDB_ENTRY_NORMAL;
-
- type->entry_type_data_size = sizeof (RBAudioscrobblerRadioTrackData);
- type->pre_entry_destroy = destroy_track_data;
- }
+ return radio_track_entry_type;
}
-RhythmDBEntryType
-rhythmdb_entry_audioscrobbler_radio_track_get_type (void)
+void
+rb_audioscrobbler_radio_track_register_entry_type (RhythmDB *db)
{
- return type;
+ g_assert (radio_track_entry_type == NULL);
+
+ radio_track_entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE,
+ "db", db,
+ "name", "audioscrobbler-radio-track",
+ "save-to-disk", FALSE,
+ "category", RHYTHMDB_ENTRY_NORMAL,
+ "type-data-size", sizeof (RBAudioscrobblerRadioTrackData),
+ NULL);
+
+ radio_track_entry_type->destroy_entry = track_data_destroy;
+ rhythmdb_register_entry_type (db, radio_track_entry_type);
}
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry.h b/plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry-type.h
similarity index 79%
rename from plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry.h
rename to plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry-type.h
index f3b14b9..3c8e758 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry.h
+++ b/plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry-type.h
@@ -26,13 +26,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef __RB_AUDIOSCROBBLER_RADIO_TRACK_ENTRY_H
-#define __RB_AUDIOSCROBBLER_RADIO_TRACK_ENTRY_H
+#ifndef __RB_AUDIOSCROBBLER_RADIO_TRACK_ENTRY_TYPE_H
+#define __RB_AUDIOSCROBBLER_RADIO_TRACK_ENTRY_TYPE_H
+#include "rhythmdb-entry-type.h"
#include "rhythmdb.h"
#include "rb-audioscrobbler-service.h"
-#define RHYTHMDB_ENTRY_TYPE_AUDIOSCROBBLER_RADIO_TRACK (rhythmdb_entry_audioscrobbler_radio_track_get_type ())
+G_BEGIN_DECLS
typedef struct
{
@@ -42,8 +43,11 @@ typedef struct
RBAudioscrobblerService *service;
} RBAudioscrobblerRadioTrackData;
+#define RHYTHMDB_ENTRY_TYPE_AUDIOSCROBBLER_RADIO_TRACK (rb_audioscrobbler_radio_track_get_entry_type ())
+RhythmDBEntryType *rb_audioscrobbler_radio_track_get_entry_type (void);
+
void rb_audioscrobbler_radio_track_register_entry_type (RhythmDB *db);
-RhythmDBEntryType rhythmdb_entry_audioscrobbler_radio_track_get_type (void);
+G_END_DECLS
-#endif /* #ifndef __RB_AUDIOSCROBBLER_RADIO_TRACK_ENTRY_H */
+#endif /* #ifndef __RB_AUDIOSCROBBLER_RADIO_TRACK_ENTRY_TYPE_H */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 77df821..bf7bc01 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -38,7 +38,7 @@ test_rb_lib_SOURCES = \
test_audioscrobbler_SOURCES = \
test-audioscrobbler.c \
$(top_srcdir)/plugins/audioscrobbler/rb-audioscrobbler-entry.c \
- $(top_srcdir)/plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry.c \
+ $(top_srcdir)/plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry-type.c \
$(test_utils)
test_widgets_SOURCES = \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]