[rhythmbox] audioscrobbler: radio source is responsible for merging its own UI
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] audioscrobbler: radio source is responsible for merging its own UI
- Date: Tue, 21 Sep 2010 10:53:42 +0000 (UTC)
commit 8354026481128d524ff1575fcfcc18204199e5ef
Author: Jamie Nicol <jamie thenicols net>
Date: Wed Jul 28 17:21:50 2010 +0100
audioscrobbler: radio source is responsible for merging its own UI
radio source merges ui from file instead of plugin. means if no radio
sources are created there are no warnings about missing actions
plugins/audioscrobbler/Makefile.am | 2 +-
...crobbler-ui.xml => audioscrobbler-radio-ui.xml} | 0
plugins/audioscrobbler/rb-audioscrobbler-plugin.c | 17 -----------------
.../rb-audioscrobbler-radio-source.c | 20 ++++++++++++++++++++
4 files changed, 21 insertions(+), 18 deletions(-)
---
diff --git a/plugins/audioscrobbler/Makefile.am b/plugins/audioscrobbler/Makefile.am
index 3c582de..f68acb8 100644
--- a/plugins/audioscrobbler/Makefile.am
+++ b/plugins/audioscrobbler/Makefile.am
@@ -56,7 +56,7 @@ gtkbuilderdir = $(plugindir)
gtkbuilder_DATA = audioscrobbler-profile.ui
uixmldir = $(plugindir)
-uixml_DATA = audioscrobbler-ui.xml
+uixml_DATA = audioscrobbler-radio-ui.xml
plugin_in_files = audioscrobbler.rb-plugin.in
diff --git a/plugins/audioscrobbler/audioscrobbler-ui.xml b/plugins/audioscrobbler/audioscrobbler-radio-ui.xml
similarity index 100%
rename from plugins/audioscrobbler/audioscrobbler-ui.xml
rename to plugins/audioscrobbler/audioscrobbler-radio-ui.xml
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-plugin.c b/plugins/audioscrobbler/rb-audioscrobbler-plugin.c
index 244d37c..4065367 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-plugin.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-plugin.c
@@ -56,7 +56,6 @@ typedef struct
{
RBPlugin parent;
- guint ui_merge_id;
RBSource *lastfm_source;
RBSource *librefm_source;
} RBAudioscrobblerPlugin;
@@ -111,27 +110,17 @@ impl_activate (RBPlugin *bplugin,
RBShell *shell)
{
RBAudioscrobblerPlugin *plugin;
- GtkUIManager *ui_manager;
- char *file;
RBAudioscrobblerService *lastfm;
RBAudioscrobblerService *librefm;
plugin = RB_AUDIOSCROBBLER_PLUGIN (bplugin);
- g_object_get (shell, "ui-manager", &ui_manager, NULL);
- file = rb_plugin_find_file (bplugin, "audioscrobbler-ui.xml");
- plugin->ui_merge_id = gtk_ui_manager_add_ui_from_file (ui_manager,
- file,
- NULL);
- g_free (file);
-
lastfm = rb_audioscrobbler_service_new_lastfm ();
plugin->lastfm_source = rb_audioscrobbler_profile_source_new (shell, bplugin, lastfm);
librefm = rb_audioscrobbler_service_new_librefm ();
plugin->librefm_source = rb_audioscrobbler_profile_source_new (shell, bplugin, librefm);
- g_object_unref (ui_manager);
g_object_unref (lastfm);
g_object_unref (librefm);
}
@@ -141,16 +130,10 @@ impl_deactivate (RBPlugin *bplugin,
RBShell *shell)
{
RBAudioscrobblerPlugin *plugin = RB_AUDIOSCROBBLER_PLUGIN (bplugin);
- GtkUIManager *ui_manager;
-
- g_object_get (shell, "ui-manager", &ui_manager, NULL);
- gtk_ui_manager_remove_ui (ui_manager, plugin->ui_merge_id);
rb_source_delete_thyself (plugin->lastfm_source);
plugin->lastfm_source = NULL;
rb_source_delete_thyself (plugin->librefm_source);
plugin->librefm_source = NULL;
-
- g_object_unref (ui_manager);
}
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
index d211dc4..815d7a5 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
@@ -152,6 +152,7 @@ struct _RBAudioscrobblerRadioSourcePrivate
guint emit_coverart_id;
+ guint ui_merge_id;
GtkActionGroup *action_group;
/* used when streaming radio using old api */
@@ -405,6 +406,9 @@ rb_audioscrobbler_radio_source_constructed (GObject *object)
GtkWidget *error_info_bar_content_area;
GtkWidget *password_info_bar_label;
GtkWidget *password_info_bar_content_area;
+ RBPlugin *plugin;
+ GtkUIManager *ui_manager;
+ char *ui_file;
RB_CHAIN_GOBJECT_METHOD (rb_audioscrobbler_radio_source_parent_class, constructed, object);
@@ -473,6 +477,11 @@ rb_audioscrobbler_radio_source_constructed (GObject *object)
G_CALLBACK (extra_metadata_gather_cb),
source, 0);
+ /* merge ui */
+ g_object_get (source, "plugin", &plugin, "ui-manager", &ui_manager, NULL);
+ ui_file = rb_plugin_find_file (plugin, "audioscrobbler-radio-ui.xml");
+ source->priv->ui_merge_id = gtk_ui_manager_add_ui_from_file (ui_manager, ui_file, NULL);
+
/* actions */
source->priv->action_group = _rb_source_register_action_group (RB_SOURCE (source),
"AudioscrobblerRadioActions",
@@ -487,6 +496,9 @@ rb_audioscrobbler_radio_source_constructed (GObject *object)
g_object_unref (shell);
g_object_unref (db);
+ g_object_unref (plugin);
+ g_object_unref (ui_manager);
+ g_free (ui_file);
}
static void
@@ -515,6 +527,14 @@ rb_audioscrobbler_radio_source_dispose (GObject *object)
source->priv->play_order = NULL;
}
+ if (source->priv->ui_merge_id != 0) {
+ GtkUIManager *ui_manager;
+ g_object_get (source, "ui-manager", &ui_manager, NULL);
+ gtk_ui_manager_remove_ui (ui_manager, source->priv->ui_merge_id);
+ source->priv->ui_merge_id = 0;
+ g_object_unref (ui_manager);
+ }
+
G_OBJECT_CLASS (rb_audioscrobbler_radio_source_parent_class)->dispose (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]