[rhythmbox] build in 'stores' source group so plugins don't have to create it



commit 676f9a31cfa4170bd448a2e32a95a5dcb574906c
Author: Jonathan Matthew <jonathan d14n org>
Date:   Sun Jan 3 19:45:07 2010 +1000

    build in 'stores' source group so plugins don't have to create it
    
    Anyone creating a 'store' plugin ends up copying the same five or so
    lines from the magnatune plugin, so we might as well cut it down to one.

 plugins/jamendo/jamendo/__init__.py     |    7 +------
 plugins/magnatune/magnatune/__init__.py |    7 +------
 sources/rb-source-group.c               |   13 +++++++++++++
 sources/rb-source-group.h               |    2 ++
 4 files changed, 17 insertions(+), 12 deletions(-)
---
diff --git a/plugins/jamendo/jamendo/__init__.py b/plugins/jamendo/jamendo/__init__.py
index 2dacf48..eea0f75 100644
--- a/plugins/jamendo/jamendo/__init__.py
+++ b/plugins/jamendo/jamendo/__init__.py
@@ -69,18 +69,13 @@ class Jamendo(rb.Plugin):
 		self.entry_type.can_sync_metadata = True
 		self.entry_type.sync_metadata = None
 
-		group = rb.rb_source_group_get_by_name ("stores")
- 		if not group:
- 			group = rb.rb_source_group_register ("stores",
- 							     _("Stores"),
- 							     rb.SOURCE_GROUP_CATEGORY_FIXED)
-
 		theme = gtk.icon_theme_get_default()
 		rb.append_plugin_source_path(theme, "/icons/")
 
 		width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR)
 		icon = rb.try_load_icon(theme, "jamendo", width, 0)
 
+		group = rb.rb_source_group_get_by_name ("stores")
 		self.source = gobject.new (JamendoSource,
 					   shell=shell,
 					   entry_type=self.entry_type,
diff --git a/plugins/magnatune/magnatune/__init__.py b/plugins/magnatune/magnatune/__init__.py
index 2b804cb..1d50978 100644
--- a/plugins/magnatune/magnatune/__init__.py
+++ b/plugins/magnatune/magnatune/__init__.py
@@ -90,12 +90,6 @@ class Magnatune(rb.Plugin):
 		self.db = shell.get_property("db")
 		self.keyring = None
 
-		group = rb.rb_source_group_get_by_name ("stores")
- 		if not group:
- 			group = rb.rb_source_group_register ("stores",
- 							     _("Stores"),
- 							     rb.SOURCE_GROUP_CATEGORY_FIXED)
-
 		self.entry_type = self.db.entry_register_type("MagnatuneEntryType")
 		# allow changes which don't do anything
 		self.entry_type.can_sync_metadata = True
@@ -107,6 +101,7 @@ class Magnatune(rb.Plugin):
 		width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_LARGE_TOOLBAR)
 		icon = rb.try_load_icon(theme, "magnatune", width, 0)
 
+		group = rb.rb_source_group_get_by_name ("stores")
 		self.source = gobject.new (MagnatuneSource,
  					   shell=shell,
  					   entry_type=self.entry_type,
diff --git a/sources/rb-source-group.c b/sources/rb-source-group.c
index 207b825..ce5f833 100644
--- a/sources/rb-source-group.c
+++ b/sources/rb-source-group.c
@@ -52,6 +52,7 @@ G_LOCK_DEFINE_STATIC (source_groups);
 static GHashTable *source_groups_map;
 
 static RBSourceGroup *library_group = NULL;
+static RBSourceGroup *stores_group = NULL;
 static RBSourceGroup *playlists_group = NULL;
 static RBSourceGroup *devices_group = NULL;
 static RBSourceGroup *shared_group = NULL;
@@ -60,6 +61,7 @@ static void
 register_core_source_groups (void)
 {
 	library_group = rb_source_group_register ("library", _("Library"), RB_SOURCE_GROUP_CATEGORY_FIXED);
+	stores_group = rb_source_group_register ("stores", _("Stores"), RB_SOURCE_GROUP_CATEGORY_FIXED);
 	playlists_group = rb_source_group_register ("playlists", _("Playlists"), RB_SOURCE_GROUP_CATEGORY_PERSISTENT);
 	devices_group = rb_source_group_register ("devices", _("Devices"), RB_SOURCE_GROUP_CATEGORY_REMOVABLE);
 	shared_group = rb_source_group_register ("shared", _("Shared"), RB_SOURCE_GROUP_CATEGORY_TRANSIENT);
@@ -229,3 +231,14 @@ rb_source_group_shared_get_type (void)
 {
 	return shared_group;
 }
+
+/**
+ * rb_source_group_stores_get_type:
+ *
+ * Return value: the predefined stores source group
+ */
+RBSourceGroup *
+rb_source_group_stores_get_type (void)
+{
+	return stores_group;
+}
diff --git a/sources/rb-source-group.h b/sources/rb-source-group.h
index f736354..9e9c7c0 100644
--- a/sources/rb-source-group.h
+++ b/sources/rb-source-group.h
@@ -65,6 +65,7 @@ GType          rb_source_group_get_type    (void);
 #define RB_SOURCE_GROUP_PLAYLISTS         (rb_source_group_playlists_get_type ())
 #define RB_SOURCE_GROUP_DEVICES           (rb_source_group_devices_get_type ())
 #define RB_SOURCE_GROUP_SHARED            (rb_source_group_shared_get_type ())
+#define RB_SOURCE_GROUP_STORES            (rb_source_group_stores_get_type ())
 
 void                  rb_source_group_init             (void);
 
@@ -77,6 +78,7 @@ RBSourceGroup        *rb_source_group_library_get_type   (void);
 RBSourceGroup        *rb_source_group_playlists_get_type (void);
 RBSourceGroup        *rb_source_group_devices_get_type   (void);
 RBSourceGroup        *rb_source_group_shared_get_type    (void);
+RBSourceGroup        *rb_source_group_stores_get_type    (void);
 
 G_END_DECLS
 



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