[rhythmbox] create playlist search actions before loading UI (bug #666894)
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] create playlist search actions before loading UI (bug #666894)
- Date: Tue, 10 Jan 2012 10:36:35 +0000 (UTC)
commit 8a41eee2388eb4652671d19339bfe3d593fe12a2
Author: Jonathan Matthew <jonathan d14n org>
Date: Tue Jan 10 20:32:19 2012 +1000
create playlist search actions before loading UI (bug #666894)
This silences some GTK warnings that may or may not appear depending
on configuration.
shell/rb-shell.c | 4 +++
sources/rb-auto-playlist-source.c | 52 ++++++++++++++++++-----------------
sources/rb-auto-playlist-source.h | 4 +++
sources/rb-static-playlist-source.c | 49 +++++++++++++++++---------------
sources/rb-static-playlist-source.h | 4 +++
5 files changed, 65 insertions(+), 48 deletions(-)
---
diff --git a/shell/rb-shell.c b/shell/rb-shell.c
index bd26651..2ef24c4 100644
--- a/shell/rb-shell.c
+++ b/shell/rb-shell.c
@@ -96,6 +96,7 @@
#include "rb-podcast-main-source.h"
#include "rb-podcast-entry-types.h"
#include "rb-ext-db.h"
+#include "rb-auto-playlist-source.h"
#include "eggsmclient.h"
@@ -799,6 +800,9 @@ construct_sources (RBShell *shell)
rb_shell_append_display_page (shell, RB_DISPLAY_PAGE (shell->priv->missing_files_source), page_group);
rb_shell_append_display_page (shell, RB_DISPLAY_PAGE (shell->priv->import_errors_source), page_group);
+ rb_auto_playlist_source_create_actions (shell);
+ rb_static_playlist_source_create_actions (shell);
+
rb_podcast_main_source_add_subsources (RB_PODCAST_MAIN_SOURCE (shell->priv->podcast_source));
/* Find the playlist name if none supplied */
diff --git a/sources/rb-auto-playlist-source.c b/sources/rb-auto-playlist-source.c
index 28b2424..eac629c 100644
--- a/sources/rb-auto-playlist-source.c
+++ b/sources/rb-auto-playlist-source.c
@@ -134,8 +134,6 @@ struct _RBAutoPlaylistSourcePrivate
RBSourceSearch *default_search;
RhythmDBQuery *search_query;
-
- GtkActionGroup *action_group;
};
static gpointer playlist_pixbuf = NULL;
@@ -203,11 +201,6 @@ rb_auto_playlist_source_dispose (GObject *object)
{
RBAutoPlaylistSourcePrivate *priv = GET_PRIVATE (object);
- if (priv->action_group != NULL) {
- g_object_unref (priv->action_group);
- priv->action_group = NULL;
- }
-
if (priv->cached_all_query != NULL) {
g_object_unref (priv->cached_all_query);
priv->cached_all_query = NULL;
@@ -241,6 +234,32 @@ rb_auto_playlist_source_finalize (GObject *object)
G_OBJECT_CLASS (rb_auto_playlist_source_parent_class)->finalize (object);
}
+void
+rb_auto_playlist_source_create_actions (RBShell *shell)
+{
+ RBAutoPlaylistSourceClass *klass;
+ GtkUIManager *uimanager;
+
+ klass = RB_AUTO_PLAYLIST_SOURCE_CLASS (g_type_class_peek (RB_TYPE_AUTO_PLAYLIST_SOURCE));
+
+ klass->action_group = gtk_action_group_new ("AutoPlaylistActions");
+ gtk_action_group_set_translation_domain (klass->action_group, GETTEXT_PACKAGE);
+
+ g_object_get (shell, "ui-manager", &uimanager, NULL);
+ gtk_ui_manager_insert_action_group (uimanager, klass->action_group, 0);
+ g_object_unref (uimanager);
+
+ gtk_action_group_add_radio_actions (klass->action_group,
+ rb_auto_playlist_source_radio_actions,
+ G_N_ELEMENTS (rb_auto_playlist_source_radio_actions),
+ 0,
+ NULL,
+ NULL);
+ rb_source_search_basic_create_for_actions (klass->action_group,
+ rb_auto_playlist_source_radio_actions,
+ G_N_ELEMENTS (rb_auto_playlist_source_radio_actions));
+}
+
static void
rb_auto_playlist_source_constructed (GObject *object)
{
@@ -273,27 +292,10 @@ rb_auto_playlist_source_constructed (GObject *object)
G_CALLBACK (rb_auto_playlist_source_songs_sort_order_changed_cb),
source, 0);
- g_object_get (source, "shell", &shell, NULL);
- priv->action_group = _rb_display_page_register_action_group (RB_DISPLAY_PAGE (source),
- "AutoPlaylistActions",
- NULL, 0,
- shell);
- if (gtk_action_group_get_action (priv->action_group,
- rb_auto_playlist_source_radio_actions[0].name) == NULL) {
- gtk_action_group_add_radio_actions (priv->action_group,
- rb_auto_playlist_source_radio_actions,
- G_N_ELEMENTS (rb_auto_playlist_source_radio_actions),
- 0,
- NULL,
- NULL);
- rb_source_search_basic_create_for_actions (priv->action_group,
- rb_auto_playlist_source_radio_actions,
- G_N_ELEMENTS (rb_auto_playlist_source_radio_actions));
- }
priv->default_search = rb_source_search_basic_new (RHYTHMDB_PROP_SEARCH_MATCH);
-
/* set up toolbar */
+ g_object_get (source, "shell", &shell, NULL);
g_object_get (shell, "ui-manager", &ui_manager, NULL);
priv->toolbar = rb_source_toolbar_new (RB_SOURCE (source), ui_manager);
rb_source_toolbar_add_search_entry (priv->toolbar, "/AutoPlaylistSourceSearchMenu", NULL);
diff --git a/sources/rb-auto-playlist-source.h b/sources/rb-auto-playlist-source.h
index c1cdfd0..9188749 100644
--- a/sources/rb-auto-playlist-source.h
+++ b/sources/rb-auto-playlist-source.h
@@ -55,10 +55,14 @@ struct _RBAutoPlaylistSource
struct _RBAutoPlaylistSourceClass
{
RBPlaylistSourceClass parent;
+
+ GtkActionGroup *action_group;
};
GType rb_auto_playlist_source_get_type (void);
+void rb_auto_playlist_source_create_actions (RBShell *shell);
+
RBSource * rb_auto_playlist_source_new (RBShell *shell,
const char *name,
gboolean local);
diff --git a/sources/rb-static-playlist-source.c b/sources/rb-static-playlist-source.c
index 0e772ce..b71170f 100644
--- a/sources/rb-static-playlist-source.c
+++ b/sources/rb-static-playlist-source.c
@@ -149,7 +149,6 @@ typedef struct
RBSourceSearch *default_search;
RhythmDBQuery *search_query;
- GtkActionGroup *action_group;
gboolean dispose_has_run;
} RBStaticPlaylistSourcePrivate;
@@ -194,6 +193,31 @@ rb_static_playlist_source_class_init (RBStaticPlaylistSourceClass *klass)
g_type_class_add_private (klass, sizeof (RBStaticPlaylistSourcePrivate));
}
+void
+rb_static_playlist_source_create_actions (RBShell *shell)
+{
+ RBStaticPlaylistSourceClass *klass;
+ GtkUIManager *uimanager;
+
+ klass = RB_STATIC_PLAYLIST_SOURCE_CLASS (g_type_class_peek (RB_TYPE_STATIC_PLAYLIST_SOURCE));
+
+ klass->action_group = gtk_action_group_new ("StaticPlaylistActions");
+ gtk_action_group_set_translation_domain (klass->action_group, GETTEXT_PACKAGE);
+
+ g_object_get (shell, "ui-manager", &uimanager, NULL);
+ gtk_ui_manager_insert_action_group (uimanager, klass->action_group, 0);
+ g_object_unref (uimanager);
+
+ gtk_action_group_add_radio_actions (klass->action_group,
+ rb_static_playlist_source_radio_actions,
+ G_N_ELEMENTS (rb_static_playlist_source_radio_actions),
+ 0,
+ NULL,
+ NULL);
+ rb_source_search_basic_create_for_actions (klass->action_group,
+ rb_static_playlist_source_radio_actions,
+ G_N_ELEMENTS (rb_static_playlist_source_radio_actions));
+}
static void
rb_static_playlist_source_init (RBStaticPlaylistSource *source)
{
@@ -243,11 +267,6 @@ rb_static_playlist_source_dispose (GObject *object)
priv->filter_model = NULL;
}
- if (priv->action_group != NULL) {
- g_object_unref (priv->action_group);
- priv->action_group = NULL;
- }
-
if (priv->default_search != NULL) {
g_object_unref (priv->default_search);
priv->default_search = NULL;
@@ -302,25 +321,9 @@ rb_static_playlist_source_constructed (GObject *object)
gtk_widget_set_hexpand (paned, TRUE);
gtk_widget_set_vexpand (paned, TRUE);
- g_object_get (source, "shell", &shell, NULL);
- priv->action_group = _rb_display_page_register_action_group (RB_DISPLAY_PAGE (source),
- "StaticPlaylistActions",
- NULL, 0,
- shell);
- if (gtk_action_group_get_action (priv->action_group,
- rb_static_playlist_source_radio_actions[0].name) == NULL) {
- gtk_action_group_add_radio_actions (priv->action_group,
- rb_static_playlist_source_radio_actions,
- G_N_ELEMENTS (rb_static_playlist_source_radio_actions),
- 0,
- NULL,
- NULL);
- rb_source_search_basic_create_for_actions (priv->action_group,
- rb_static_playlist_source_radio_actions,
- G_N_ELEMENTS (rb_static_playlist_source_radio_actions));
- }
priv->default_search = rb_source_search_basic_new (RHYTHMDB_PROP_SEARCH_MATCH);
+ g_object_get (source, "shell", &shell, NULL);
g_object_get (shell, "ui-manager", &ui_manager, NULL);
g_object_unref (shell);
diff --git a/sources/rb-static-playlist-source.h b/sources/rb-static-playlist-source.h
index 4a2c80f..64f97c5 100644
--- a/sources/rb-static-playlist-source.h
+++ b/sources/rb-static-playlist-source.h
@@ -56,10 +56,14 @@ struct _RBStaticPlaylistSource
struct _RBStaticPlaylistSourceClass
{
RBPlaylistSourceClass parent;
+
+ GtkActionGroup *action_group;
};
GType rb_static_playlist_source_get_type (void);
+void rb_static_playlist_source_create_actions (RBShell *shell);
+
RBSource * rb_static_playlist_source_new (RBShell *shell,
const char *name,
const char *settings_name,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]