[rhythmbox] display-page: change get_status to return status text and a busy flag
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] display-page: change get_status to return status text and a busy flag
- Date: Mon, 23 Oct 2017 10:42:20 +0000 (UTC)
commit b0e44a6a7da34457a29fa86a129bf56486d645c6
Author: Jonathan Matthew <jonathan d14n org>
Date: Mon Oct 23 20:18:20 2017 +1000
display-page: change get_status to return status text and a busy flag
The progress details haven't been used for ages, but with the floating
bar we have the option to show a spinner, which seems useful enough.
To start with, in the default implementation, set the busy flag if the
source hasn't finished loading yet.
.../rb-audioscrobbler-radio-source.c | 15 -------------
plugins/iradio/rb-iradio-source.c | 6 +---
podcast/rb-podcast-source.c | 7 +-----
sources/rb-display-page.c | 13 +++-------
sources/rb-display-page.h | 4 +-
sources/rb-import-errors-source.c | 4 +-
sources/rb-library-source.c | 6 ++++-
sources/rb-missing-files-source.c | 4 +-
sources/rb-source.c | 23 +++++++++++++-------
9 files changed, 33 insertions(+), 49 deletions(-)
---
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
index 42eacc0..477f5e6 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-radio-source.c
@@ -216,7 +216,6 @@ static void display_error_info_bar (RBAudioscrobblerRadioSource *source,
/* RBDisplayPage implementations */
static void impl_selected (RBDisplayPage *page);
-static void impl_get_status (RBDisplayPage *page, char **text, char **progress_text, float *progress);
static void impl_delete_thyself (RBDisplayPage *page);
static gboolean impl_can_remove (RBDisplayPage *page);
static void impl_remove (RBDisplayPage *page);
@@ -298,7 +297,6 @@ rb_audioscrobbler_radio_source_class_init (RBAudioscrobblerRadioSourceClass *kla
page_class = RB_DISPLAY_PAGE_CLASS (klass);
page_class->selected = impl_selected;
- page_class->get_status = impl_get_status;
page_class->delete_thyself = impl_delete_thyself;
page_class->can_remove = impl_can_remove;
page_class->remove = impl_remove;
@@ -1014,19 +1012,6 @@ impl_get_entry_view (RBSource *asource)
}
static void
-impl_get_status (RBDisplayPage *page, char **text, char **progress_text, float *progress)
-{
- RBAudioscrobblerRadioSource *source = RB_AUDIOSCROBBLER_RADIO_SOURCE (page);
- if (source->priv->is_busy) {
- /* We could be calling either radio.tune or radio.getPlaylist methods.
- * "Tuning station" seems like a user friendly message to display for both cases.
- */
- *progress_text = g_strdup (_("Tuning station"));
- *progress = -1.0f;
- }
-}
-
-static void
impl_get_playback_status (RBSource *source, char **text, float *progress)
{
rb_streaming_source_get_progress (RB_STREAMING_SOURCE (source), text, progress);
diff --git a/plugins/iradio/rb-iradio-source.c b/plugins/iradio/rb-iradio-source.c
index 898bc9a..71d0e6e 100644
--- a/plugins/iradio/rb-iradio-source.c
+++ b/plugins/iradio/rb-iradio-source.c
@@ -86,7 +86,7 @@ static void rb_iradio_entry_type_init (RBIRadioEntryType *etype);
GType rb_iradio_entry_type_get_type (void);
/* page methods */
-static void impl_get_status (RBDisplayPage *page, char **text, char **progress_text, float *progress);
+static void impl_get_status (RBDisplayPage *page, char **text, gboolean *busy);
/* source methods */
static RBEntryView *impl_get_entry_view (RBSource *source);
@@ -575,8 +575,7 @@ impl_get_entry_view (RBSource *asource)
static void
impl_get_status (RBDisplayPage *page,
char **text,
- char **progress_text,
- float *progress)
+ gboolean *busy)
{
RhythmDBQueryModel *model;
guint num_entries;
@@ -588,7 +587,6 @@ impl_get_status (RBDisplayPage *page,
*text = g_strdup_printf (ngettext ("%d station", "%d stations", num_entries),
num_entries);
-
}
static void
diff --git a/podcast/rb-podcast-source.c b/podcast/rb-podcast-source.c
index 16a0769..b77255d 100644
--- a/podcast/rb-podcast-source.c
+++ b/podcast/rb-podcast-source.c
@@ -1204,7 +1204,7 @@ impl_song_properties (RBSource *asource)
}
static void
-impl_get_status (RBDisplayPage *page, char **text, char **progress_text, float *progress)
+impl_get_status (RBDisplayPage *page, char **text, gboolean *busy)
{
RhythmDBQueryModel *query_model;
@@ -1218,12 +1218,7 @@ impl_get_status (RBDisplayPage *page, char **text, char **progress_text, float *
*text = rhythmdb_query_model_compute_status_normal (query_model,
"%d episode",
"%d episodes");
- if (rhythmdb_query_model_has_pending_changes (query_model))
- *progress = -1.0f;
-
g_object_unref (query_model);
- } else {
- *text = g_strdup ("");
}
}
diff --git a/sources/rb-display-page.c b/sources/rb-display-page.c
index c2f5b6f..ebc7f8f 100644
--- a/sources/rb-display-page.c
+++ b/sources/rb-display-page.c
@@ -283,24 +283,19 @@ rb_display_page_get_config_widget (RBDisplayPage *page,
* rb_display_page_get_status:
* @page: a #RBDisplayPage
* @text: (inout) (allow-none) (transfer full): holds the returned status text
- * @progress_text: (inout) (allow-none) (transfer full): holds the returned text for the progress bar
- * @progress: (inout) (allow-none): holds the progress value
+ * @busy: (inout) (allow-none): holds the busy status
*
- * Retrieves the details to display in the status bar for the page.
- * If the progress value returned is less than zero, the progress bar
- * will pulse. If the progress value is greater than or equal to 1,
- * the progress bar will be hidden.
+ * Retrieves status details for the page.
**/
void
rb_display_page_get_status (RBDisplayPage *page,
char **text,
- char **progress_text,
- float *progress)
+ gboolean *busy)
{
RBDisplayPageClass *klass = RB_DISPLAY_PAGE_GET_CLASS (page);
if (klass->get_status)
- klass->get_status (page, text, progress_text, progress);
+ klass->get_status (page, text, busy);
}
/**
diff --git a/sources/rb-display-page.h b/sources/rb-display-page.h
index f626bda..89c8437 100644
--- a/sources/rb-display-page.h
+++ b/sources/rb-display-page.h
@@ -70,7 +70,7 @@ struct _RBDisplayPageClass
GtkWidget *(*get_config_widget) (RBDisplayPage *page, RBShellPreferences *prefs);
- void (*get_status) (RBDisplayPage *page, char **text, char **progress_text, float
*progress);
+ void (*get_status) (RBDisplayPage *page, char **text, gboolean *busy);
gboolean (*receive_drag) (RBDisplayPage *page, GtkSelectionData *data);
void (*delete_thyself) (RBDisplayPage *page);
@@ -88,7 +88,7 @@ void rb_display_page_deselected (RBDisplayPage *page);
void rb_display_page_activate (RBDisplayPage *page);
GtkWidget * rb_display_page_get_config_widget (RBDisplayPage *page, RBShellPreferences *prefs);
-void rb_display_page_get_status (RBDisplayPage *page, char **text, char
**progress_text, float *progress);
+void rb_display_page_get_status (RBDisplayPage *page, char **text, gboolean *busy);
void rb_display_page_delete_thyself (RBDisplayPage *page);
diff --git a/sources/rb-import-errors-source.c b/sources/rb-import-errors-source.c
index 60c04cb..d778ece 100644
--- a/sources/rb-import-errors-source.c
+++ b/sources/rb-import-errors-source.c
@@ -47,7 +47,7 @@ static void impl_set_property (GObject *object, guint prop_id, const GValue *val
static RBEntryView *impl_get_entry_view (RBSource *source);
static void impl_delete_selected (RBSource *source);
-static void impl_get_status (RBDisplayPage *page, char **text, char **progress_text, float *progress);
+static void impl_get_status (RBDisplayPage *page, char **text, gboolean *busy);
static void rb_import_errors_source_songs_show_popup_cb (RBEntryView *view,
gboolean over_entry,
@@ -371,7 +371,7 @@ impl_delete_selected (RBSource *asource)
}
static void
-impl_get_status (RBDisplayPage *page, char **text, char **progress_text, float *progress)
+impl_get_status (RBDisplayPage *page, char **text, gboolean *busy)
{
RhythmDBQueryModel *model;
gint count;
diff --git a/sources/rb-library-source.c b/sources/rb-library-source.c
index 15ba523..5b25e99 100644
--- a/sources/rb-library-source.c
+++ b/sources/rb-library-source.c
@@ -279,7 +279,10 @@ db_load_complete_cb (RhythmDB *db, RBLibrarySource *source)
RhythmDBImportJob *job;
/* once the database is loaded, we can run the query to populate the library source */
- g_object_set (source, "populate", TRUE, NULL);
+ g_object_set (source,
+ "populate", TRUE,
+ "load-status", RB_SOURCE_LOAD_STATUS_LOADED,
+ NULL);
if (source->priv->do_initial_import) {
const char *music_dir;
@@ -415,6 +418,7 @@ rb_library_source_new (RBShell *shell)
"name", _("Music"),
"entry-type", RHYTHMDB_ENTRY_TYPE_SONG,
"shell", shell,
+ "load-status", RB_SOURCE_LOAD_STATUS_LOADING,
"populate", FALSE, /* wait until the database is loaded
*/
"toolbar-menu", toolbar,
"settings", g_settings_get_child (settings, "source"),
diff --git a/sources/rb-missing-files-source.c b/sources/rb-missing-files-source.c
index 95b1309..88e7999 100644
--- a/sources/rb-missing-files-source.c
+++ b/sources/rb-missing-files-source.c
@@ -68,7 +68,7 @@ static void rb_missing_files_source_get_property (GObject *object,
static RBEntryView *impl_get_entry_view (RBSource *source);
static void impl_song_properties (RBSource *source);
static void impl_delete_selected (RBSource *source);
-static void impl_get_status (RBDisplayPage *page, char **text, char **progress_text, float *progress);
+static void impl_get_status (RBDisplayPage *page, char **text, gboolean *busy);
static void rb_missing_files_source_songs_show_popup_cb (RBEntryView *view,
gboolean over_entry,
@@ -350,7 +350,7 @@ rb_missing_files_source_songs_sort_order_changed_cb (GObject *object,
}
static void
-impl_get_status (RBDisplayPage *page, char **text, char **progress_text, float *progress)
+impl_get_status (RBDisplayPage *page, char **text, gboolean *busy)
{
RhythmDBQueryModel *model;
gint count;
diff --git a/sources/rb-source.c b/sources/rb-source.c
index b52c4a4..9bd9b22 100644
--- a/sources/rb-source.c
+++ b/sources/rb-source.c
@@ -58,7 +58,7 @@ static void rb_source_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
-static void default_get_status (RBDisplayPage *page, char **text, char **progress_text, float *progress);
+static void default_get_status (RBDisplayPage *page, char **text, gboolean *busy);
static void default_activate (RBDisplayPage *page);
static GList *default_get_property_views (RBSource *source);
static gboolean default_can_rename (RBSource *source);
@@ -513,6 +513,7 @@ rb_source_set_property (GObject *object,
break;
case PROP_LOAD_STATUS:
source->priv->load_status = g_value_get_enum (value);
+ rb_display_page_notify_status_changed (RB_DISPLAY_PAGE (source));
break;
case PROP_TOOLBAR_MENU:
source->priv->toolbar_menu = g_value_dup_object (value);
@@ -586,10 +587,11 @@ default_activate (RBDisplayPage *page)
static void
default_get_status (RBDisplayPage *page,
char **text,
- char **progress_text,
- float *progress)
+ gboolean *busy)
{
RBSource *source = RB_SOURCE (page);
+ RBSourceLoadStatus status;
+
/* hack to get these strings marked for translation */
if (0) {
ngettext ("%d song", "%d songs", 0);
@@ -599,11 +601,16 @@ default_get_status (RBDisplayPage *page,
*text = rhythmdb_query_model_compute_status_normal (source->priv->query_model,
"%d song",
"%d songs");
- if (rhythmdb_query_model_has_pending_changes (source->priv->query_model)) {
- *progress = -1.0f;
- }
- } else {
- *text = g_strdup ("");
+ }
+
+ g_object_get (source, "load-status", &status, NULL);
+ switch (status) {
+ case RB_SOURCE_LOAD_STATUS_WAITING:
+ case RB_SOURCE_LOAD_STATUS_LOADING:
+ *busy = TRUE;
+ break;
+ default:
+ break;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]