rhythmbox r5979 - in trunk: . sources
- From: jmatthew svn gnome org
- To: svn-commits-list gnome org
- Subject: rhythmbox r5979 - in trunk: . sources
- Date: Mon, 13 Oct 2008 22:39:29 +0000 (UTC)
Author: jmatthew
Date: Mon Oct 13 22:39:29 2008
New Revision: 5979
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=5979&view=rev
Log:
2008-10-14 Jonathan Matthew <jonathan d14n org>
* sources/rb-browser-source.c: (rb_browser_source_class_init),
(rb_browser_source_constructor), (rb_browser_source_set_property),
(rb_browser_source_get_property), (cached_all_query_complete_cb),
(rb_browser_source_populate),
(rb_browser_source_query_complete_cb),
(rb_browser_source_do_query):
Add a property controlling when the query model is populated. When
populating the base query model or running other queries, only attach
the query model to the browser when the query is complete.
* sources/rb-auto-playlist-source.c:
(rb_auto_playlist_source_query_complete_cb),
(rb_auto_playlist_source_do_query), (cached_all_query_complete_cb),
(rb_auto_playlist_source_set_query):
When running queries, only attach the query model to the browser when
the query is complete.
* sources/rb-library-source.c: (db_load_complete_cb),
(rb_library_source_constructor), (rb_library_source_new):
Only populate the base query model for the library when the database
is fully loaded.
From #419383. The main point of this is to avoid adding lots of rows
to tree models that are already visible, as when accessibility is
enabled, each row added triggers a synchronous IPC request.
This makes it possible to start rhythmbox with a fairly large library
when a11y is enabled. Probably makes loading a bit faster otherwise.
Modified:
trunk/ChangeLog
trunk/sources/rb-auto-playlist-source.c
trunk/sources/rb-browser-source.c
trunk/sources/rb-library-source.c
Modified: trunk/sources/rb-auto-playlist-source.c
==============================================================================
--- trunk/sources/rb-auto-playlist-source.c (original)
+++ trunk/sources/rb-auto-playlist-source.c Mon Oct 13 22:39:29 2008
@@ -723,6 +723,8 @@
{
RBAutoPlaylistSourcePrivate *priv = RB_AUTO_PLAYLIST_SOURCE_GET_PRIVATE (source);
+ rb_library_browser_set_model (priv->browser, model, TRUE);
+
priv->query_active = FALSE;
if (priv->search_on_completion) {
priv->search_on_completion = FALSE;
@@ -772,7 +774,6 @@
"limit-value", priv->limit_value,
NULL);
rhythmdb_query_model_chain (query_model, priv->cached_all_query, FALSE);
- rb_library_browser_set_model (priv->browser, query_model, TRUE);
priv->query_active = TRUE;
priv->search_on_completion = FALSE;
@@ -788,6 +789,14 @@
rhythmdb_query_free (query);
}
+static void
+cached_all_query_complete_cb (RhythmDBQueryModel *model,
+ RBAutoPlaylistSource *source)
+{
+ RBAutoPlaylistSourcePrivate *priv = RB_AUTO_PLAYLIST_SOURCE_GET_PRIVATE (source);
+ rb_library_browser_set_model (priv->browser, model, TRUE);
+}
+
/**
* rb_auto_playlist_source_set_query:
* @source: the #RBAutoPlaylistSource
@@ -838,7 +847,10 @@
"limit-type", priv->limit_type,
"limit-value", priv->limit_value,
NULL);
- rb_library_browser_set_model (priv->browser, priv->cached_all_query, TRUE);
+ g_signal_connect_object (priv->cached_all_query,
+ "complete",
+ G_CALLBACK (cached_all_query_complete_cb),
+ source, 0);
rhythmdb_do_full_query_async_parsed (db,
RHYTHMDB_QUERY_RESULTS (priv->cached_all_query),
priv->query);
Modified: trunk/sources/rb-browser-source.c
==============================================================================
--- trunk/sources/rb-browser-source.c (original)
+++ trunk/sources/rb-browser-source.c Mon Oct 13 22:39:29 2008
@@ -124,6 +124,7 @@
RBBrowserSource *source);
static void rb_browser_source_do_query (RBBrowserSource *source,
gboolean subset);
+static void rb_browser_source_populate (RBBrowserSource *source);
struct RBBrowserSourcePrivate
{
@@ -137,7 +138,7 @@
char *search_text;
RhythmDBQueryModel *cached_all_query;
RhythmDBPropType search_prop;
- gboolean initialized;
+ gboolean populate;
gboolean query_active;
gboolean search_on_completion;
@@ -184,7 +185,8 @@
{
PROP_0,
PROP_SORTING_KEY,
- PROP_BASE_QUERY_MODEL
+ PROP_BASE_QUERY_MODEL,
+ PROP_POPULATE
};
G_DEFINE_ABSTRACT_TYPE (RBBrowserSource, rb_browser_source, RB_TYPE_SOURCE)
@@ -235,6 +237,14 @@
g_object_class_override_property (object_class,
PROP_BASE_QUERY_MODEL,
"base-query-model");
+
+ g_object_class_install_property (object_class,
+ PROP_POPULATE,
+ g_param_spec_boolean ("populate",
+ "populate",
+ "whether to populate the source",
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_type_class_add_private (klass, sizeof (RBBrowserSourcePrivate));
}
@@ -509,12 +519,14 @@
gtk_widget_show_all (GTK_WIDGET (source));
+ /* use a throwaway model until the real one is ready */
+ rb_library_browser_set_model (source->priv->browser,
+ rhythmdb_query_model_new_empty (source->priv->db),
+ TRUE);
+
source->priv->cached_all_query = rhythmdb_query_model_new_empty (source->priv->db);
- rb_library_browser_set_model (source->priv->browser, source->priv->cached_all_query, TRUE);
- rhythmdb_do_full_query_async (source->priv->db,
- RHYTHMDB_QUERY_RESULTS (source->priv->cached_all_query),
- RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TYPE, entry_type,
- RHYTHMDB_QUERY_END);
+ rb_browser_source_populate (source);
+
g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type);
return G_OBJECT (source);
@@ -533,6 +545,14 @@
g_free (source->priv->sorting_key);
source->priv->sorting_key = g_strdup (g_value_get_string (value));
break;
+ case PROP_POPULATE:
+ source->priv->populate = g_value_get_boolean (value);
+
+ /* if being set after construction, run the query now. otherwise the constructor will do it. */
+ if (source->priv->songs != NULL) {
+ rb_browser_source_populate (source);
+ }
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -554,6 +574,9 @@
case PROP_BASE_QUERY_MODEL:
g_value_set_object (value, source->priv->cached_all_query);
break;
+ case PROP_POPULATE:
+ g_value_set_boolean (value, source->priv->populate);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -561,6 +584,39 @@
}
static void
+cached_all_query_complete_cb (RhythmDBQueryModel *model, RBBrowserSource *source)
+{
+ rb_library_browser_set_model (source->priv->browser,
+ source->priv->cached_all_query,
+ TRUE);
+}
+
+static void
+rb_browser_source_populate (RBBrowserSource *source)
+{
+ RhythmDBEntryType *entry_type;
+
+ if (source->priv->populate == FALSE)
+ return;
+
+ /* only connect the model to the browser when it's complete. this avoids
+ * thousands of row-added signals, which is ridiculously slow with a11y enabled.
+ */
+ g_signal_connect_object (source->priv->cached_all_query,
+ "complete",
+ G_CALLBACK (cached_all_query_complete_cb),
+ source, 0);
+
+ g_object_get (source, "entry-type", &entry_type, NULL);
+ rhythmdb_do_full_query_async (source->priv->db,
+ RHYTHMDB_QUERY_RESULTS (source->priv->cached_all_query),
+ RHYTHMDB_QUERY_PROP_EQUALS, RHYTHMDB_PROP_TYPE, entry_type,
+ RHYTHMDB_QUERY_END);
+ g_boxed_free (RHYTHMDB_TYPE_ENTRY_TYPE, entry_type);
+}
+
+
+static void
rb_browser_source_cmd_choose_genre (GtkAction *action,
RBShell *shell)
{
@@ -879,8 +935,10 @@
static void
rb_browser_source_query_complete_cb (RhythmDBQueryModel *query_model,
- RBBrowserSource *source)
+ RBBrowserSource *source)
{
+ rb_library_browser_set_model (source->priv->browser, query_model, TRUE);
+
source->priv->query_active = FALSE;
if (source->priv->search_on_completion) {
rb_debug ("performing deferred search");
@@ -933,9 +991,10 @@
g_object_unref (query_model);
} else {
- /* otherwise build a query based on the search text and feed it to the browser */
+ /* otherwise build a query based on the search text, and feed it to the browser
+ * when the query finishes.
+ */
query_model = rhythmdb_query_model_new_empty (source->priv->db);
- rb_library_browser_set_model (source->priv->browser, query_model, TRUE);
source->priv->query_active = TRUE;
source->priv->search_on_completion = FALSE;
g_signal_connect_object (query_model,
Modified: trunk/sources/rb-library-source.c
==============================================================================
--- trunk/sources/rb-library-source.c (original)
+++ trunk/sources/rb-library-source.c Mon Oct 13 22:39:29 2008
@@ -298,6 +298,13 @@
return FALSE;
}
+static void
+db_load_complete_cb (RhythmDB *db, RBLibrarySource *source)
+{
+ /* once the database is loaded, we can run the query to populate the library source */
+ g_object_set (source, "populate", TRUE, NULL);
+}
+
static GObject *
rb_library_source_constructor (GType type,
guint n_construct_properties,
@@ -314,6 +321,8 @@
g_object_get (source, "shell", &shell, NULL);
g_object_get (shell, "db", &source->priv->db, NULL);
+ g_signal_connect_object (source->priv->db, "load-complete", G_CALLBACK (db_load_complete_cb), source, 0);
+
rb_library_source_ui_prefs_sync (source);
/* Set up the default library location if there's no library location set */
@@ -380,6 +389,7 @@
"sorting-key", CONF_STATE_LIBRARY_SORTING,
"shell", shell,
"icon", icon,
+ "populate", FALSE, /* wait until the database is loaded */
NULL));
if (icon != NULL) {
g_object_unref (icon);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]