[rhythmbox/gobject-introspection: 15/41] remove function pointers from RhythmDBEntryType, g-i hates them



commit 81fff4359a1c8e2c3d41f9e086068e862cf2cfbb
Author: Jonathan Matthew <jonathan d14n org>
Date:   Mon Nov 29 10:32:59 2010 +1000

    remove function pointers from RhythmDBEntryType, g-i hates them

 plugins/audiocd/rb-audiocd-source.c                |   27 ++++++-
 .../rb-audioscrobbler-radio-track-entry-type.c     |   24 +++++-
 plugins/daap/rb-daap-source.c                      |   26 +++++-
 plugins/fmradio/rb-fm-radio-source.c               |   39 +++++++--
 plugins/iradio/rb-iradio-source.c                  |   27 ++++++-
 podcast/rb-podcast-entry-types.c                   |   69 +++++++++++++---
 rhythmdb/rhythmdb-entry-type.c                     |   24 ++----
 rhythmdb/rhythmdb-entry-type.h                     |   10 --
 rhythmdb/rhythmdb-song-entry-types.c               |   87 +++++++++++++++++---
 tests/test-utils.c                                 |   14 ++--
 10 files changed, 267 insertions(+), 80 deletions(-)
---
diff --git a/plugins/audiocd/rb-audiocd-source.c b/plugins/audiocd/rb-audiocd-source.c
index f425c8d..287535b 100644
--- a/plugins/audiocd/rb-audiocd-source.c
+++ b/plugins/audiocd/rb-audiocd-source.c
@@ -143,6 +143,16 @@ typedef struct
 RB_PLUGIN_DEFINE_TYPE (RBAudioCdSource, rb_audiocd_source, RB_TYPE_REMOVABLE_MEDIA_SOURCE)
 #define AUDIOCD_SOURCE_GET_PRIVATE(o)   (G_TYPE_INSTANCE_GET_PRIVATE ((o), RB_TYPE_AUDIOCD_SOURCE, RBAudioCdSourcePrivate))
 
+/* entry type */
+typedef struct _RhythmDBEntryType RBAudioCdEntryType;
+typedef struct _RhythmDBEntryTypeClass RBAudioCdEntryTypeClass;
+
+static void rb_audiocd_entry_type_class_init (RBAudioCdEntryTypeClass *klass);
+static void rb_audiocd_entry_type_init (RBAudioCdEntryType *etype);
+GType rb_audiocd_entry_type_get_type (void);
+
+G_DEFINE_TYPE (RBAudioCdEntryType, rb_audiocd_entry_type, RHYTHMDB_TYPE_ENTRY_TYPE);
+
 #ifdef HAVE_SJ_METADATA_GETTER
 static AlbumDetails* multiple_album_dialog (GList *albums, RBAudioCdSource *source);
 #endif
@@ -158,6 +168,19 @@ static GtkActionEntry rb_audiocd_source_actions[] = {
 #endif
 };
 
+static void
+rb_audiocd_entry_type_class_init (RBAudioCdEntryTypeClass *klass)
+{
+	RhythmDBEntryTypeClass *etype_class = RHYTHMDB_ENTRY_TYPE_CLASS (klass);
+	etype_class->can_sync_metadata = (RhythmDBEntryTypeBooleanFunc) rb_true_function;
+	etype_class->sync_metadata = (RhythmDBEntryTypeSyncFunc) rb_null_function;
+}
+
+static void
+rb_audiocd_entry_type_init (RBAudioCdEntryType *etype)
+{
+}
+
 static RhythmDB *
 get_db_for_source (RBAudioCdSource *source)
 {
@@ -437,15 +460,13 @@ rb_audiocd_source_new (RBPlugin *plugin,
 	g_free (path);
 
 	g_object_get (shell, "db", &db, NULL);
-	entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE,
+	entry_type = g_object_new (rb_audiocd_entry_type_get_type (),
 				   "db", db,
 				   "name", name,
 				   "save-to-disk", FALSE,
 				   "category", RHYTHMDB_ENTRY_NORMAL,
 				   "type-data-size", sizeof(RBAudioCDEntryData),
 				   NULL);
-	entry_type->can_sync_metadata = (RhythmDBEntryTypeBooleanFunc) rb_true_function;
-	entry_type->sync_metadata = (RhythmDBEntryTypeSyncFunc) rb_null_function;
 	rhythmdb_register_entry_type (db, entry_type);
 	g_object_unref (db);
 	g_free (name);
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry-type.c b/plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry-type.c
index e062a9a..5201588 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry-type.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry-type.c
@@ -28,6 +28,15 @@
 
 #include "rb-audioscrobbler-radio-track-entry-type.h"
 
+typedef struct _RhythmDBEntryType RBAudioscrobblerRadioEntryType;
+typedef struct _RhythmDBEntryTypeClass RBAudioscrobblerRadioEntryTypeClass;
+
+static void rb_audioscrobbler_radio_entry_type_class_init (RBAudioscrobblerRadioEntryTypeClass *klass);
+static void rb_audioscrobbler_radio_entry_type_init (RBAudioscrobblerRadioEntryType *etype);
+GType rb_audioscrobbler_radio_entry_type_get_type (void);
+
+G_DEFINE_TYPE (RBAudioscrobblerRadioEntryType, rb_audioscrobbler_radio_entry_type, RHYTHMDB_TYPE_ENTRY_TYPE);
+
 static RhythmDBEntryType *radio_track_entry_type = NULL;
 
 static void
@@ -41,6 +50,18 @@ track_data_destroy (RhythmDBEntryType *entry_type, RhythmDBEntry *entry)
 	g_free (data->download_url);
 }
 
+static void
+rb_audioscrobbler_radio_entry_type_class_init (RBAudioscrobblerRadioEntryTypeClass *klass)
+{
+	RhythmDBEntryTypeClass *etype_class = RHYTHMDB_ENTRY_TYPE_CLASS (klass);
+	etype_class->destroy_entry = track_data_destroy;
+}
+
+static void
+rb_audioscrobbler_radio_entry_type_init (RBAudioscrobblerRadioEntryType *etype)
+{
+}
+
 RhythmDBEntryType *
 rb_audioscrobbler_radio_track_get_entry_type (void)
 {
@@ -52,7 +73,7 @@ rb_audioscrobbler_radio_track_register_entry_type (RhythmDB *db)
 {
 	g_assert (radio_track_entry_type == NULL);
 
-	radio_track_entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE,
+	radio_track_entry_type = g_object_new (rb_audioscrobbler_radio_entry_type_get_type (),
 	                                       "db", db,
 	                                       "name", "audioscrobbler-radio-track",
 	                                       "save-to-disk", FALSE,
@@ -60,6 +81,5 @@ rb_audioscrobbler_radio_track_register_entry_type (RhythmDB *db)
 	                                       "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/daap/rb-daap-source.c b/plugins/daap/rb-daap-source.c
index 47e1ac3..c531428 100644
--- a/plugins/daap/rb-daap-source.c
+++ b/plugins/daap/rb-daap-source.c
@@ -61,6 +61,9 @@
 
 #include <libdmapsharing/dmap.h>
 
+typedef struct _RhythmDBEntryType RBDAAPEntryType;
+typedef struct _RhythmDBEntryTypeClass RBDAAPEntryTypeClass;
+
 static void rb_daap_source_dispose (GObject *object);
 static void rb_daap_source_set_property  (GObject *object,
 					  guint prop_id,
@@ -78,6 +81,10 @@ static void rb_daap_source_get_status (RBDisplayPage *page, char **text, char **
 static char * rb_daap_source_get_browser_key (RBSource *source);
 static char * rb_daap_source_get_paned_key (RBBrowserSource *source);
 
+static void rb_daap_entry_type_class_init (RBDAAPEntryTypeClass *klass);
+static void rb_daap_entry_type_init (RBDAAPEntryType *etype);
+GType rb_daap_entry_type_get_type (void);
+
 #define CONF_STATE_SORTING CONF_PREFIX "/state/daap/sorting"
 #define CONF_STATE_PANED_POSITION CONF_PREFIX "/state/daap/paned_position"
 #define CONF_STATE_SHOW_BROWSER CONF_PREFIX "/state/daap/show_browser"
@@ -112,7 +119,9 @@ enum {
 	PROP_PASSWORD_PROTECTED
 };
 
-G_DEFINE_TYPE (RBDAAPSource, rb_daap_source, RB_TYPE_BROWSER_SOURCE)
+G_DEFINE_TYPE (RBDAAPSource, rb_daap_source, RB_TYPE_BROWSER_SOURCE);
+
+G_DEFINE_TYPE (RBDAAPEntryType, rb_daap_entry_type, RHYTHMDB_TYPE_ENTRY_TYPE);
 
 static char *
 rb_daap_entry_type_get_playback_uri (RhythmDBEntryType *etype, RhythmDBEntry *entry)
@@ -128,6 +137,18 @@ rb_daap_entry_type_get_playback_uri (RhythmDBEntryType *etype, RhythmDBEntry *en
 }
 
 static void
+rb_daap_entry_type_class_init (RBDAAPEntryTypeClass *klass)
+{
+	RhythmDBEntryTypeClass *etype_class = RHYTHMDB_ENTRY_TYPE_CLASS (klass);
+	etype_class->get_playback_uri = rb_daap_entry_type_get_playback_uri;
+}
+
+static void
+rb_daap_entry_type_init (RBDAAPEntryType *etype)
+{
+}
+
+static void
 rb_daap_source_dispose (GObject *object)
 {
 	RBDAAPSource *source = RB_DAAP_SOURCE (object);
@@ -296,13 +317,12 @@ rb_daap_source_new (RBShell *shell,
 	g_object_get (shell, "db", &db, NULL);
 	entry_type_name = g_strdup_printf ("daap:%s:%s:%s", service_name, name, host);
 
-	entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE,
+	entry_type = g_object_new (rb_daap_entry_type_get_type (),
 				   "db", db,
 				   "name", entry_type_name,
 				   "save-to-disk", FALSE,
 				   "category", RHYTHMDB_ENTRY_NORMAL,
 				   NULL);
-	entry_type->get_playback_uri = rb_daap_entry_type_get_playback_uri;
 	rhythmdb_register_entry_type (db, entry_type);
 	g_object_unref (db);
 	g_free (entry_type_name);
diff --git a/plugins/fmradio/rb-fm-radio-source.c b/plugins/fmradio/rb-fm-radio-source.c
index f3c338f..1df9c8e 100644
--- a/plugins/fmradio/rb-fm-radio-source.c
+++ b/plugins/fmradio/rb-fm-radio-source.c
@@ -43,6 +43,9 @@
 #include "rb-fm-radio-source.h"
 #include "rb-radio-tuner.h"
 
+typedef struct _RhythmDBEntryType RBFMRadioEntryType;
+typedef struct _RhythmDBEntryTypeClass RBFMRadioEntryTypeClass;
+
 static void     rb_fm_radio_source_class_init  (RBFMRadioSourceClass *class);
 static void     rb_fm_radio_source_init        (RBFMRadioSource *self);
 static void	rb_fm_radio_source_constructed (GObject *object);
@@ -67,6 +70,9 @@ static gboolean     impl_show_popup     (RBDisplayPage *page);
 static GList       *impl_get_ui_actions (RBDisplayPage *page);
 static RBEntryView *impl_get_entry_view (RBSource *source);
 
+static void rb_fm_radio_entry_type_class_init (RBFMRadioEntryTypeClass *klass);
+static void rb_fm_radio_entry_type_init (RBFMRadioEntryType *etype);
+GType rb_fm_radio_entry_type_get_type (void);
 
 struct _RBFMRadioSourcePrivate {
 	RhythmDB *db;
@@ -89,6 +95,28 @@ static GtkActionEntry rb_fm_radio_source_actions[] = {
 
 RB_PLUGIN_DEFINE_TYPE (RBFMRadioSource, rb_fm_radio_source, RB_TYPE_SOURCE);
 
+G_DEFINE_TYPE (RBFMRadioEntryType, rb_fm_radio_entry_type, RHYTHMDB_TYPE_ENTRY_TYPE);
+
+static char *
+rb_fm_radio_source_get_playback_uri (RhythmDBEntryType *etype, RhythmDBEntry *entry)
+{
+	return g_strdup("xrbsilence:///");
+}
+
+static void
+rb_fm_radio_entry_type_class_init (RBFMRadioEntryTypeClass *klass)
+{
+	RhythmDBEntryTypeClass *etype_class = RHYTHMDB_ENTRY_TYPE_CLASS (klass);
+	etype_class->can_sync_metadata = (RhythmDBEntryTypeBooleanFunc) rb_true_function;
+	etype_class->sync_metadata = (RhythmDBEntryTypeSyncFunc) rb_null_function;
+	etype_class->get_playback_uri = rb_fm_radio_source_get_playback_uri;
+}
+
+static void
+rb_fm_radio_entry_type_init (RBFMRadioEntryType *etype)
+{
+}
+
 static void
 rb_fm_radio_source_class_init (RBFMRadioSourceClass *class)
 {
@@ -177,12 +205,6 @@ rb_fm_radio_source_constructed (GObject *object)
 				 self, 0);
 }
 
-static char *
-rb_fm_radio_source_get_playback_uri (RhythmDBEntryType *etype, RhythmDBEntry *entry)
-{
-	return g_strdup("xrbsilence:///");
-}
-
 RBSource *
 rb_fm_radio_source_new (RBShell *shell, RBRadioTuner *tuner)
 {
@@ -194,14 +216,11 @@ rb_fm_radio_source_new (RBShell *shell, RBRadioTuner *tuner)
 
 	entry_type = rhythmdb_entry_type_get_by_name (db, "fmradio-station");
 	if (entry_type == NULL) {
-		entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE,
+		entry_type = g_object_new (rb_fm_radio_entry_type_get_type (),
 					   "db", db,
 					   "name", "fmradio-station",
 					   "save-to-disk", TRUE,
 					   NULL);
-		entry_type->can_sync_metadata = (RhythmDBEntryTypeBooleanFunc) rb_true_function;
-		entry_type->sync_metadata = (RhythmDBEntryTypeSyncFunc) rb_null_function;
-		entry_type->get_playback_uri = rb_fm_radio_source_get_playback_uri;
 		rhythmdb_register_entry_type (db, entry_type);
 	}
 
diff --git a/plugins/iradio/rb-iradio-source.c b/plugins/iradio/rb-iradio-source.c
index 41e40cf..3802638 100644
--- a/plugins/iradio/rb-iradio-source.c
+++ b/plugins/iradio/rb-iradio-source.c
@@ -61,6 +61,9 @@
 #define IRADIO_SOURCE_ICON  "library-internet-radio"
 #define IRADIO_NEW_STATION_ICON "internet-radio-new"
 
+typedef struct _RhythmDBEntryType RBIRadioEntryType;
+typedef struct _RhythmDBEntryTypeClass RBIRadioEntryTypeClass;
+
 static void rb_iradio_source_class_init (RBIRadioSourceClass *klass);
 static void rb_iradio_source_init (RBIRadioSource *source);
 static void rb_iradio_source_constructed (GObject *object);
@@ -96,6 +99,11 @@ static void genre_selection_reset_cb (RBPropertyView *propview, RBIRadioSource *
 static void rb_iradio_source_songs_view_sort_order_changed_cb (RBEntryView *view, RBIRadioSource *source);
 static char *guess_uri_scheme (const char *uri);
 
+/* entry type */
+static void rb_iradio_entry_type_class_init (RBIRadioEntryTypeClass *klass);
+static void rb_iradio_entry_type_init (RBIRadioEntryType *etype);
+GType rb_iradio_entry_type_get_type (void);
+
 /* page methods */
 static gboolean impl_show_popup (RBDisplayPage *page);
 static GList *impl_get_ui_actions (RBDisplayPage *page);
@@ -185,7 +193,22 @@ static const GtkTargetEntry stations_view_drag_types[] = {
 	{  "_NETSCAPE_URL", 0, 1 },
 };
 
-G_DEFINE_TYPE (RBIRadioSource, rb_iradio_source, RB_TYPE_STREAMING_SOURCE)
+G_DEFINE_TYPE (RBIRadioSource, rb_iradio_source, RB_TYPE_STREAMING_SOURCE);
+
+G_DEFINE_TYPE (RBIRadioEntryType, rb_iradio_entry_type, RHYTHMDB_TYPE_ENTRY_TYPE);
+
+static void
+rb_iradio_entry_type_class_init (RBIRadioEntryTypeClass *klass)
+{
+	RhythmDBEntryTypeClass *etype_class = RHYTHMDB_ENTRY_TYPE_CLASS (klass);
+	etype_class->can_sync_metadata = (RhythmDBEntryTypeBooleanFunc) rb_true_function;
+	etype_class->sync_metadata = (RhythmDBEntryTypeSyncFunc) rb_null_function;
+}
+
+static void
+rb_iradio_entry_type_init (RBIRadioEntryType *etype)
+{
+}
 
 static void
 rb_iradio_source_class_init (RBIRadioSourceClass *klass)
@@ -449,8 +472,6 @@ rb_iradio_source_new (RBShell *shell, RBPlugin *plugin)
 					   "save-to-disk", TRUE,
 					   "category", RHYTHMDB_ENTRY_STREAM,
 					   NULL);
-		entry_type->can_sync_metadata = (RhythmDBEntryTypeBooleanFunc) rb_true_function;
-		entry_type->sync_metadata = (RhythmDBEntryTypeSyncFunc) rb_null_function;
 		rhythmdb_register_entry_type (db, entry_type);
 	}
 	g_object_unref (db);
diff --git a/podcast/rb-podcast-entry-types.c b/podcast/rb-podcast-entry-types.c
index 0bd5409..8fc0cc6 100644
--- a/podcast/rb-podcast-entry-types.c
+++ b/podcast/rb-podcast-entry-types.c
@@ -36,6 +36,28 @@
 static RhythmDBEntryType *podcast_post_entry_type = NULL;
 static RhythmDBEntryType *podcast_feed_entry_type = NULL;
 
+/* podcast post entry type class */
+
+typedef struct _RhythmDBEntryType RBPodcastPostEntryType;
+typedef struct _RhythmDBEntryTypeClass RBPodcastPostEntryTypeClass;
+
+static void rb_podcast_post_entry_type_class_init (RBPodcastPostEntryTypeClass *klass);
+static void rb_podcast_post_entry_type_init (RBPodcastPostEntryType *etype);
+GType rb_podcast_post_entry_type_get_type (void);
+
+G_DEFINE_TYPE (RBPodcastPostEntryType, rb_podcast_post_entry_type, RHYTHMDB_TYPE_ENTRY_TYPE);
+
+/* podcast feed entry type class */
+
+typedef struct _RhythmDBEntryType RBPodcastFeedEntryType;
+typedef struct _RhythmDBEntryTypeClass RBPodcastFeedEntryTypeClass;
+
+static void rb_podcast_feed_entry_type_class_init (RBPodcastFeedEntryTypeClass *klass);
+static void rb_podcast_feed_entry_type_init (RBPodcastFeedEntryType *etype);
+GType rb_podcast_feed_entry_type_get_type (void);
+
+G_DEFINE_TYPE (RBPodcastFeedEntryType, rb_podcast_feed_entry_type, RHYTHMDB_TYPE_ENTRY_TYPE);
+
 static char *
 podcast_get_playback_uri (RhythmDBEntryType *entry_type, RhythmDBEntry *entry)
 {
@@ -84,6 +106,23 @@ rb_podcast_get_post_entry_type (void)
 	return podcast_post_entry_type;
 }
 
+static void
+rb_podcast_post_entry_type_class_init (RBPodcastPostEntryTypeClass *klass)
+{
+	RhythmDBEntryTypeClass *etype_class = RHYTHMDB_ENTRY_TYPE_CLASS (klass);
+
+	etype_class->entry_created = podcast_post_create;
+	etype_class->destroy_entry = podcast_data_destroy;
+	etype_class->get_playback_uri = podcast_get_playback_uri;
+	etype_class->can_sync_metadata = (RhythmDBEntryTypeBooleanFunc) rb_true_function;
+	etype_class->sync_metadata = (RhythmDBEntryTypeSyncFunc) rb_null_function;
+}
+
+static void
+rb_podcast_post_entry_type_init (RBPodcastPostEntryType *etype)
+{
+}
+
 /**
  * rhythmdb_get_ignore_entry_type:
  *
@@ -97,6 +136,22 @@ rb_podcast_get_feed_entry_type (void)
 	return podcast_feed_entry_type;
 }
 
+static void
+rb_podcast_feed_entry_type_class_init (RBPodcastFeedEntryTypeClass *klass)
+{
+	RhythmDBEntryTypeClass *etype_class = RHYTHMDB_ENTRY_TYPE_CLASS (klass);
+
+	etype_class->entry_created = podcast_post_create;
+	etype_class->destroy_entry = podcast_data_destroy;
+	etype_class->get_playback_uri = (RhythmDBEntryTypeStringFunc) rb_null_function;
+	etype_class->can_sync_metadata = (RhythmDBEntryTypeBooleanFunc) rb_true_function;
+	etype_class->sync_metadata = (RhythmDBEntryTypeSyncFunc) rb_null_function;
+}
+
+static void
+rb_podcast_feed_entry_type_init (RBPodcastFeedEntryType *etype)
+{
+}
 
 
 void
@@ -105,31 +160,21 @@ rb_podcast_register_entry_types (RhythmDB *db)
 	g_assert (podcast_post_entry_type == NULL);
 	g_assert (podcast_feed_entry_type == NULL);
 
-	podcast_post_entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE,
+	podcast_post_entry_type = g_object_new (rb_podcast_post_entry_type_get_type (),
 						"db", db,
 						"name", "podcast-post",
 						"save-to-disk", TRUE,
 						"category", RHYTHMDB_ENTRY_NORMAL,
 						"type-data-size", sizeof (RhythmDBPodcastFields),
 						NULL);
-	podcast_post_entry_type->entry_created = podcast_post_create;
-	podcast_post_entry_type->destroy_entry = podcast_data_destroy;
-	podcast_post_entry_type->get_playback_uri = podcast_get_playback_uri;
-	podcast_post_entry_type->can_sync_metadata = (RhythmDBEntryTypeBooleanFunc) rb_true_function;
-	podcast_post_entry_type->sync_metadata = (RhythmDBEntryTypeSyncFunc) rb_null_function;
 	rhythmdb_register_entry_type (db, podcast_post_entry_type);
 
-	podcast_feed_entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE,
+	podcast_feed_entry_type = g_object_new (rb_podcast_feed_entry_type_get_type (),
 						"db", db,
 						"name", "podcast-feed",
 						"save-to-disk", TRUE,
 						"category", RHYTHMDB_ENTRY_CONTAINER,
 						"type-data-size", sizeof (RhythmDBPodcastFields),
 						NULL);
-	podcast_feed_entry_type->entry_created = podcast_post_create;
-	podcast_feed_entry_type->destroy_entry = podcast_data_destroy;
-	podcast_feed_entry_type->get_playback_uri = (RhythmDBEntryTypeStringFunc) rb_null_function;
-	podcast_feed_entry_type->can_sync_metadata = (RhythmDBEntryTypeBooleanFunc) rb_true_function;
-	podcast_feed_entry_type->sync_metadata = (RhythmDBEntryTypeSyncFunc) rb_null_function;
 	rhythmdb_register_entry_type (db, podcast_feed_entry_type);
 }
diff --git a/rhythmdb/rhythmdb-entry-type.c b/rhythmdb/rhythmdb-entry-type.c
index 8828d32..af8caa1 100644
--- a/rhythmdb/rhythmdb-entry-type.c
+++ b/rhythmdb/rhythmdb-entry-type.c
@@ -101,9 +101,7 @@ rhythmdb_entry_get_playback_uri (RhythmDBEntry *entry)
 	RhythmDBEntryType *etype = rhythmdb_entry_get_entry_type (entry);
 	RhythmDBEntryTypeClass *klass = RHYTHMDB_ENTRY_TYPE_GET_CLASS (etype);
 
-	if (etype->get_playback_uri) {
-		return (etype->get_playback_uri) (etype, entry);
-	} else if (klass->get_playback_uri) {
+	if (klass->get_playback_uri) {
 		return (klass->get_playback_uri) (etype, entry);
 	} else {
 		return rhythmdb_entry_dup_string (entry, RHYTHMDB_PROP_LOCATION);
@@ -123,9 +121,7 @@ rhythmdb_entry_update_availability (RhythmDBEntry *entry, RhythmDBEntryAvailabil
 	RhythmDBEntryType *etype = rhythmdb_entry_get_entry_type (entry);
 	RhythmDBEntryTypeClass *klass = RHYTHMDB_ENTRY_TYPE_GET_CLASS (etype);
 
-	if (etype->update_availability) {
-		(etype->update_availability) (etype, entry, avail);
-	} else if (klass->get_playback_uri) {
+	if (klass->get_playback_uri) {
 		(klass->update_availability) (etype, entry, avail);
 	} else {
 		/* do nothing? */
@@ -147,9 +143,7 @@ rhythmdb_entry_created (RhythmDBEntry *entry)
 	etype = rhythmdb_entry_get_entry_type (entry);
 	klass = RHYTHMDB_ENTRY_TYPE_GET_CLASS (etype);
 
-	if (etype->entry_created) {
-		etype->entry_created (etype, entry);
-	} else if (klass->entry_created) {
+	if (klass->entry_created) {
 		klass->entry_created (etype, entry);
 	}
 }
@@ -165,9 +159,7 @@ rhythmdb_entry_pre_destroy (RhythmDBEntry *entry)
 {
 	RhythmDBEntryType *etype = rhythmdb_entry_get_entry_type (entry);
 	RhythmDBEntryTypeClass *klass = RHYTHMDB_ENTRY_TYPE_GET_CLASS (etype);
-	if (etype->destroy_entry) {
-		etype->destroy_entry (etype, entry);
-	} else if (klass->destroy_entry) {
+	if (klass->destroy_entry) {
 		klass->destroy_entry (etype, entry);
 	}
 }
@@ -187,9 +179,7 @@ rhythmdb_entry_can_sync_metadata (RhythmDBEntry *entry)
 {
 	RhythmDBEntryType *etype = rhythmdb_entry_get_entry_type (entry);
 	RhythmDBEntryTypeClass *klass = RHYTHMDB_ENTRY_TYPE_GET_CLASS (etype);
-	if (etype->can_sync_metadata) {
-		return etype->can_sync_metadata (etype, entry);
-	} else if (klass->can_sync_metadata) {
+	if (klass->can_sync_metadata) {
 		return klass->can_sync_metadata (etype, entry);
 	} else {
 		return FALSE;
@@ -209,9 +199,7 @@ rhythmdb_entry_sync_metadata (RhythmDBEntry *entry, GSList *changes, GError **er
 {
 	RhythmDBEntryType *etype = rhythmdb_entry_get_entry_type (entry);
 	RhythmDBEntryTypeClass *klass = RHYTHMDB_ENTRY_TYPE_GET_CLASS (etype);
-	if (etype->sync_metadata) {
-		etype->sync_metadata (etype, entry, changes, error);
-	} else if (klass->sync_metadata) {
+	if (klass->sync_metadata) {
 		klass->sync_metadata (etype, entry, changes, error);
 	} else {
 		/* default implementation? */
diff --git a/rhythmdb/rhythmdb-entry-type.h b/rhythmdb/rhythmdb-entry-type.h
index e27e373..feac2f3 100644
--- a/rhythmdb/rhythmdb-entry-type.h
+++ b/rhythmdb/rhythmdb-entry-type.h
@@ -77,16 +77,6 @@ typedef void (*RhythmDBEntryTypeSyncFunc) (RhythmDBEntryType *entry_type, Rhythm
 struct _RhythmDBEntryType {
 	GObject parent;
 
-	/* function pointers for C users */
-	void		(*entry_created) (RhythmDBEntryType *etype, RhythmDBEntry *entry);
-	void		(*destroy_entry) (RhythmDBEntryType *etype, RhythmDBEntry *entry);
-
-	char *		(*get_playback_uri) (RhythmDBEntryType *etype, RhythmDBEntry *entry);
-	void		(*update_availability) (RhythmDBEntryType *etype, RhythmDBEntry *entry, RhythmDBEntryAvailability avail);
-
-	gboolean	(*can_sync_metadata) (RhythmDBEntryType *etype, RhythmDBEntry *entry);
-	void		(*sync_metadata) (RhythmDBEntryType *etype, RhythmDBEntry *entry, GSList *changes, GError **error);
-
 	RhythmDBEntryTypePrivate *priv;
 };
 
diff --git a/rhythmdb/rhythmdb-song-entry-types.c b/rhythmdb/rhythmdb-song-entry-types.c
index 9e83e07..a28dd58 100644
--- a/rhythmdb/rhythmdb-song-entry-types.c
+++ b/rhythmdb/rhythmdb-song-entry-types.c
@@ -40,6 +40,33 @@ static RhythmDBEntryType *song_entry_type = NULL;
 static RhythmDBEntryType *error_entry_type = NULL;
 static RhythmDBEntryType *ignore_entry_type = NULL;
 
+
+typedef struct _RhythmDBEntryType RhythmDBSongEntryType;
+typedef struct _RhythmDBEntryTypeClass RhythmDBSongEntryTypeClass;
+
+static void rhythmdb_song_entry_type_class_init (RhythmDBSongEntryTypeClass *klass);
+static void rhythmdb_song_entry_type_init (RhythmDBSongEntryType *etype);
+GType rhythmdb_song_entry_type_get_type (void);
+G_DEFINE_TYPE (RhythmDBSongEntryType, rhythmdb_song_entry_type, RHYTHMDB_TYPE_ENTRY_TYPE);
+
+
+typedef struct _RhythmDBEntryType RhythmDBErrorEntryType;
+typedef struct _RhythmDBEntryTypeClass RhythmDBErrorEntryTypeClass;
+
+static void rhythmdb_error_entry_type_class_init (RhythmDBErrorEntryTypeClass *klass);
+static void rhythmdb_error_entry_type_init (RhythmDBErrorEntryType *etype);
+GType rhythmdb_error_entry_type_get_type (void);
+G_DEFINE_TYPE (RhythmDBErrorEntryType, rhythmdb_error_entry_type, RHYTHMDB_TYPE_ENTRY_TYPE);
+
+
+typedef struct _RhythmDBEntryType RhythmDBIgnoreEntryType;
+typedef struct _RhythmDBEntryTypeClass RhythmDBIgnoreEntryTypeClass;
+
+static void rhythmdb_ignore_entry_type_class_init (RhythmDBIgnoreEntryTypeClass *klass);
+static void rhythmdb_ignore_entry_type_init (RhythmDBIgnoreEntryType *etype);
+GType rhythmdb_ignore_entry_type_get_type (void);
+G_DEFINE_TYPE (RhythmDBIgnoreEntryType, rhythmdb_ignore_entry_type, RHYTHMDB_TYPE_ENTRY_TYPE);
+
 static void
 update_entry_last_seen (RhythmDB *db, RhythmDBEntry *entry)
 {
@@ -229,6 +256,51 @@ rhythmdb_get_error_entry_type (void)
 }
 
 
+static void
+rhythmdb_song_entry_type_class_init (RhythmDBSongEntryTypeClass *klass)
+{
+	RhythmDBEntryTypeClass *etype_class = RHYTHMDB_ENTRY_TYPE_CLASS (klass);
+
+	etype_class->can_sync_metadata = song_can_sync_metadata;
+	etype_class->sync_metadata = song_sync_metadata;
+	etype_class->update_availability = song_update_availability;
+}
+
+static void
+rhythmdb_song_entry_type_init (RhythmDBSongEntryType *etype)
+{
+}
+
+static void
+rhythmdb_error_entry_type_class_init (RhythmDBErrorEntryTypeClass *klass)
+{
+	RhythmDBEntryTypeClass *etype_class = RHYTHMDB_ENTRY_TYPE_CLASS (klass);
+
+	etype_class->get_playback_uri = (RhythmDBEntryTypeStringFunc) rb_null_function;
+	etype_class->can_sync_metadata = (RhythmDBEntryTypeBooleanFunc) rb_true_function;
+	etype_class->sync_metadata = (RhythmDBEntryTypeSyncFunc) rb_null_function;
+	etype_class->update_availability = import_error_update_availability;
+}
+
+static void
+rhythmdb_error_entry_type_init (RhythmDBErrorEntryType *etype)
+{
+}
+
+static void
+rhythmdb_ignore_entry_type_class_init (RhythmDBIgnoreEntryTypeClass *klass)
+{
+	RhythmDBEntryTypeClass *etype_class = RHYTHMDB_ENTRY_TYPE_CLASS (klass);
+
+	etype_class->get_playback_uri = (RhythmDBEntryTypeStringFunc) rb_null_function;
+	etype_class->update_availability = song_update_availability;
+}
+
+static void
+rhythmdb_ignore_entry_type_init (RhythmDBIgnoreEntryType *etype)
+{
+}
+
 
 void
 rhythmdb_register_song_entry_types (RhythmDB *db)
@@ -237,34 +309,25 @@ rhythmdb_register_song_entry_types (RhythmDB *db)
 	g_assert (error_entry_type == NULL);
 	g_assert (ignore_entry_type == NULL);
 
-	song_entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE,
+	song_entry_type = g_object_new (rhythmdb_song_entry_type_get_type (),
 					"db", db,
 					"name", "song",
 					"save-to-disk", TRUE,
 					"has-playlists", TRUE,
 					NULL);
-	song_entry_type->can_sync_metadata = song_can_sync_metadata;
-	song_entry_type->sync_metadata = song_sync_metadata;
-	song_entry_type->update_availability = song_update_availability;
 
-	ignore_entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE,
+	ignore_entry_type = g_object_new (rhythmdb_ignore_entry_type_get_type (),
 					  "db", db,
 					  "name", "ignore",
 					  "save-to-disk", TRUE,
 					  "category", RHYTHMDB_ENTRY_VIRTUAL,
 					  NULL);
-	ignore_entry_type->get_playback_uri = (RhythmDBEntryTypeStringFunc) rb_null_function;
-	ignore_entry_type->update_availability = song_update_availability;
 
-	error_entry_type = g_object_new (RHYTHMDB_TYPE_ENTRY_TYPE,
+	error_entry_type = g_object_new (rhythmdb_error_entry_type_get_type (),
 					 "db", db,
 					 "name", "import-error",
 					 "category", RHYTHMDB_ENTRY_VIRTUAL,
 					 NULL);
-	error_entry_type->get_playback_uri = (RhythmDBEntryTypeStringFunc) rb_null_function;
-	error_entry_type->can_sync_metadata = (RhythmDBEntryTypeBooleanFunc) rb_true_function;
-	error_entry_type->sync_metadata = (RhythmDBEntryTypeSyncFunc) rb_null_function;
-	error_entry_type->update_availability = import_error_update_availability;
 
 	rhythmdb_register_entry_type (db, song_entry_type);
 	rhythmdb_register_entry_type (db, error_entry_type);
diff --git a/tests/test-utils.c b/tests/test-utils.c
index a0a8366..ac4afd0 100644
--- a/tests/test-utils.c
+++ b/tests/test-utils.c
@@ -133,7 +133,7 @@ gboolean waiting_db, finalised_db;
 void
 test_rhythmdb_setup (void)
 {
-	RhythmDBEntryType *entry_type;
+	RhythmDBEntryTypeClass *etype_class;
 
 	init_once (TRUE);
 
@@ -142,13 +142,13 @@ test_rhythmdb_setup (void)
 	rhythmdb_start_action_thread (db);
 
 	/* allow songs and ignored entries to be synced to for the tests */
-	entry_type = RHYTHMDB_ENTRY_TYPE_SONG;
-	entry_type->can_sync_metadata = (RhythmDBEntryTypeBooleanFunc)rb_true_function;
-	entry_type->sync_metadata = (RhythmDBEntryTypeSyncFunc)rb_null_function;
+	etype_class = RHYTHMDB_ENTRY_TYPE_GET_CLASS (RHYTHMDB_ENTRY_TYPE_SONG);
+	etype_class->can_sync_metadata = (RhythmDBEntryTypeBooleanFunc)rb_true_function;
+	etype_class->sync_metadata = (RhythmDBEntryTypeSyncFunc)rb_null_function;
 
-	entry_type = RHYTHMDB_ENTRY_TYPE_IGNORE;
-	entry_type->can_sync_metadata = (RhythmDBEntryTypeBooleanFunc)rb_true_function;
-	entry_type->sync_metadata = (RhythmDBEntryTypeSyncFunc)rb_null_function;
+	etype_class = RHYTHMDB_ENTRY_TYPE_GET_CLASS (RHYTHMDB_ENTRY_TYPE_IGNORE);
+	etype_class->can_sync_metadata = (RhythmDBEntryTypeBooleanFunc)rb_true_function;
+	etype_class->sync_metadata = (RhythmDBEntryTypeSyncFunc)rb_null_function;
 }
 
 void



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