[rhythmbox] podcast: set status busy flag when we're updating feeds
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] podcast: set status busy flag when we're updating feeds
- Date: Mon, 23 Oct 2017 10:42:46 +0000 (UTC)
commit 7f88a0ae0eed1251328e10b92175e35c0deb645d
Author: Jonathan Matthew <jonathan d14n org>
Date: Mon Oct 23 20:31:50 2017 +1000
podcast: set status busy flag when we're updating feeds
podcast/rb-podcast-manager.c | 58 +++++++++++++++++++++++++++--------------
podcast/rb-podcast-source.c | 10 +++++++
2 files changed, 48 insertions(+), 20 deletions(-)
---
diff --git a/podcast/rb-podcast-manager.c b/podcast/rb-podcast-manager.c
index 08558b5..9c36e68 100644
--- a/podcast/rb-podcast-manager.c
+++ b/podcast/rb-podcast-manager.c
@@ -55,7 +55,8 @@
enum
{
PROP_0,
- PROP_DB
+ PROP_DB,
+ PROP_UPDATING
};
enum
@@ -111,6 +112,7 @@ struct RBPodcastManagerPrivate
RBPodcastManagerInfo *active_download;
guint source_sync;
guint next_file_id;
+ int updating;
gboolean shutdown;
RBExtDB *art_store;
@@ -191,6 +193,13 @@ rb_podcast_manager_class_init (RBPodcastManagerClass *klass)
"database",
RHYTHMDB_TYPE,
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_UPDATING,
+ g_param_spec_boolean ("updating",
+ "updating",
+ "updating",
+ FALSE,
+ G_PARAM_READABLE));
rb_podcast_manager_signals[START_DOWNLOAD] =
g_signal_new ("start_download",
@@ -402,6 +411,9 @@ rb_podcast_manager_get_property (GObject *object,
case PROP_DB:
g_value_set_object (value, pd->priv->db);
break;
+ case PROP_UPDATING:
+ g_value_set_boolean (value, (pd->priv->updating > 0));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -1063,6 +1075,10 @@ rb_podcast_manager_subscribe_feed (RBPodcastManager *pd, const char *url, gboole
info->url = feed_url;
info->automatic = automatic;
info->existing_feed = existing_feed;
+ pd->priv->updating++;
+ if (pd->priv->updating == 1) {
+ g_object_notify (G_OBJECT (pd), "updating");
+ }
g_thread_new ("podcast-parse",
(GThreadFunc) rb_podcast_manager_thread_parse_feed,
@@ -1092,9 +1108,23 @@ rb_podcast_manager_parse_complete_cb (RBPodcastManagerParseResult *result)
(char *)result->channel->url,
result->error,
(result->automatic == FALSE));
+ } else if (result->channel->is_opml) {
+ GList *l;
+
+ rb_debug ("Loading OPML feeds from %s", result->channel->url);
+
+ for (l = result->channel->posts; l != NULL; l = l->next) {
+ RBPodcastItem *item = l->data;
+ /* assume the feeds don't already exist */
+ rb_podcast_manager_subscribe_feed (result->pd, item->url, FALSE);
+ }
} else {
rb_podcast_manager_add_parsed_feed (result->pd, result->channel);
}
+ if (--result->pd->priv->updating == 0) {
+ g_object_notify (G_OBJECT (result->pd), "updating");
+ }
+
return FALSE;
}
@@ -1110,6 +1140,9 @@ confirm_bad_mime_type_response_cb (GtkDialog *dialog, int response, RBPodcastThr
} else {
g_free (info->url);
g_free (info);
+ if (--info->pd->priv->updating == 0) {
+ g_object_notify (G_OBJECT (info->pd), "updating");
+ }
}
gtk_widget_destroy (GTK_WIDGET (dialog));
@@ -1154,25 +1187,10 @@ rb_podcast_manager_thread_parse_feed (RBPodcastThreadInfo *info)
}
}
- if (feed->is_opml) {
- GList *l;
-
- rb_debug ("Loading OPML feeds from %s", info->url);
-
- for (l = feed->posts; l != NULL; l = l->next) {
- RBPodcastItem *item = l->data;
- /* assume the feeds don't already exist */
- rb_podcast_manager_subscribe_feed (info->pd, item->url, FALSE);
- }
-
- rb_podcast_manager_free_parse_result (result);
- } else {
- g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
- (GSourceFunc) rb_podcast_manager_parse_complete_cb,
- result,
- (GDestroyNotify) rb_podcast_manager_free_parse_result);
- }
-
+ g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+ (GSourceFunc) rb_podcast_manager_parse_complete_cb,
+ result,
+ (GDestroyNotify) rb_podcast_manager_free_parse_result);
g_free (info->url);
g_free (info);
return NULL;
diff --git a/podcast/rb-podcast-source.c b/podcast/rb-podcast-source.c
index b77255d..ec06805 100644
--- a/podcast/rb-podcast-source.c
+++ b/podcast/rb-podcast-source.c
@@ -1206,6 +1206,7 @@ impl_song_properties (RBSource *asource)
static void
impl_get_status (RBDisplayPage *page, char **text, gboolean *busy)
{
+ RBPodcastSource *source = RB_PODCAST_SOURCE (page);
RhythmDBQueryModel *query_model;
/* hack to get these strings marked for translation */
@@ -1220,8 +1221,15 @@ impl_get_status (RBDisplayPage *page, char **text, gboolean *busy)
"%d episodes");
g_object_unref (query_model);
}
+
+ g_object_get (source->priv->podcast_mgr, "updating", busy, NULL);
}
+static void
+podcast_manager_updating_cb (GObject *obj, GParamSpec *pspec, gpointer data)
+{
+ rb_display_page_notify_status_changed (RB_DISPLAY_PAGE (data));
+}
static char *
impl_get_delete_label (RBSource *source)
@@ -1575,6 +1583,8 @@ impl_constructed (GObject *object)
g_object_unref (accel_group);
g_object_unref (shell);
+ g_signal_connect (source->priv->podcast_mgr, "notify::updating", G_CALLBACK
(podcast_manager_updating_cb), source);
+
rb_podcast_source_do_query (source, TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]