[rhythmbox] podcast: display an icon in the feed browser when updating the feed
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] podcast: display an icon in the feed browser when updating the feed
- Date: Sun, 4 Nov 2012 07:57:21 +0000 (UTC)
commit 70ec22f15cba85883a29183e13e151e833787e09
Author: Jonathan Matthew <jonathan d14n org>
Date: Wed Oct 31 22:47:08 2012 +1000
podcast: display an icon in the feed browser when updating the feed
podcast/rb-podcast-manager.c | 30 +++++++++++++++++++++++-------
podcast/rb-podcast-source.c | 36 +++++++++++++++++++++++++++---------
rhythmdb/rhythmdb.h | 4 ++++
3 files changed, 54 insertions(+), 16 deletions(-)
---
diff --git a/podcast/rb-podcast-manager.c b/podcast/rb-podcast-manager.c
index 2a841de..9e0e49f 100644
--- a/podcast/rb-podcast-manager.c
+++ b/podcast/rb-podcast-manager.c
@@ -611,7 +611,7 @@ rb_podcast_manager_head_query_cb (GtkTreeModel *query_model,
uri = get_remote_location (entry);
status = rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_STATUS);
- if (status == 1)
+ if (status == RHYTHMDB_PODCAST_FEED_STATUS_NORMAL)
rb_podcast_manager_subscribe_feed (manager, uri, TRUE);
rhythmdb_entry_unref (entry);
@@ -1005,6 +1005,7 @@ gboolean
rb_podcast_manager_subscribe_feed (RBPodcastManager *pd, const char *url, gboolean automatic)
{
RBPodcastThreadInfo *info;
+ RhythmDBEntry *entry;
GFile *feed;
char *feed_url;
gboolean existing_feed;
@@ -1029,8 +1030,9 @@ rb_podcast_manager_subscribe_feed (RBPodcastManager *pd, const char *url, gboole
#endif
feed_url = g_file_get_uri (feed); /* not sure this buys us anything at all */
- RhythmDBEntry *entry = rhythmdb_entry_lookup_by_location (pd->priv->db, feed_url);
+ entry = rhythmdb_entry_lookup_by_location (pd->priv->db, feed_url);
if (entry) {
+ GValue v = {0,};
if (rhythmdb_entry_get_entry_type (entry) != RHYTHMDB_ENTRY_TYPE_PODCAST_FEED) {
/* added as something else, probably iradio */
rb_error_dialog (NULL, _("URL already added"),
@@ -1039,6 +1041,12 @@ rb_podcast_manager_subscribe_feed (RBPodcastManager *pd, const char *url, gboole
return FALSE;
}
existing_feed = TRUE;
+
+ g_value_init (&v, G_TYPE_ULONG);
+ g_value_set_ulong (&v, RHYTHMDB_PODCAST_FEED_STATUS_UPDATING);
+ rhythmdb_entry_set (pd->priv->db, entry, RHYTHMDB_PROP_STATUS, &v);
+ rhythmdb_commit (pd->priv->db);
+ g_value_unset (&v);
} else {
existing_feed = FALSE;
}
@@ -1707,11 +1715,10 @@ rb_podcast_manager_unsubscribe_feed (RhythmDB *db, const char *url)
if (entry) {
GValue val = {0, };
g_value_init (&val, G_TYPE_ULONG);
- g_value_set_ulong (&val, 0);
+ g_value_set_ulong (&val, RHYTHMDB_PODCAST_FEED_STATUS_HIDDEN);
rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_STATUS, &val);
g_value_unset (&val);
}
-
}
gboolean
@@ -1877,6 +1884,10 @@ rb_podcast_manager_insert_feed_url (RBPodcastManager *pd, const char *url)
entry = rhythmdb_entry_lookup_by_location (pd->priv->db, url);
if (entry) {
rb_debug ("podcast feed entry for %s found", url);
+ g_value_init (&status_val, G_TYPE_ULONG);
+ g_value_set_ulong (&status_val, RHYTHMDB_PODCAST_FEED_STATUS_NORMAL);
+ rhythmdb_entry_set (pd->priv->db, entry, RHYTHMDB_PROP_STATUS, &status_val);
+ g_value_unset (&status_val);
return;
}
rb_debug ("adding podcast feed %s with no entries", url);
@@ -1887,7 +1898,7 @@ rb_podcast_manager_insert_feed_url (RBPodcastManager *pd, const char *url)
return;
g_value_init (&status_val, G_TYPE_ULONG);
- g_value_set_ulong (&status_val, 1);
+ g_value_set_ulong (&status_val, RHYTHMDB_PODCAST_FEED_STATUS_NORMAL);
rhythmdb_entry_set (pd->priv->db, entry, RHYTHMDB_PROP_STATUS, &status_val);
g_value_unset (&status_val);
@@ -1942,7 +1953,7 @@ rb_podcast_manager_add_parsed_feed (RBPodcastManager *pd, RBPodcastChannel *data
rb_debug ("Podcast feed entry for %s found", data->url);
g_value_init (&status_val, G_TYPE_ULONG);
- g_value_set_ulong (&status_val, 1);
+ g_value_set_ulong (&status_val, RHYTHMDB_PODCAST_FEED_STATUS_NORMAL);
rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_STATUS, &status_val);
g_value_unset (&status_val);
last_post = rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_POST_TIME);
@@ -1970,7 +1981,7 @@ rb_podcast_manager_add_parsed_feed (RBPodcastManager *pd, RBPodcastChannel *data
return;
g_value_init (&status_val, G_TYPE_ULONG);
- g_value_set_ulong (&status_val, 1);
+ g_value_set_ulong (&status_val, RHYTHMDB_PODCAST_FEED_STATUS_NORMAL);
rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_STATUS, &status_val);
g_value_unset (&status_val);
}
@@ -2175,6 +2186,11 @@ rb_podcast_manager_handle_feed_error (RBPodcastManager *mgr,
rhythmdb_entry_set (mgr->priv->db, entry, RHYTHMDB_PROP_PLAYBACK_ERROR, &v);
g_value_unset (&v);
+ g_value_init (&v, G_TYPE_ULONG);
+ g_value_set_ulong (&v, RHYTHMDB_PODCAST_FEED_STATUS_NORMAL);
+ rhythmdb_entry_set (mgr->priv->db, entry, RHYTHMDB_PROP_STATUS, &v);
+ g_value_unset (&v);
+
rhythmdb_commit (mgr->priv->db);
existing = TRUE;
}
diff --git a/podcast/rb-podcast-source.c b/podcast/rb-podcast-source.c
index d7879d8..168ae52 100644
--- a/podcast/rb-podcast-source.c
+++ b/podcast/rb-podcast-source.c
@@ -107,6 +107,7 @@ struct _RBPodcastSourcePrivate
RBPodcastManager *podcast_mgr;
GdkPixbuf *error_pixbuf;
+ GdkPixbuf *refresh_pixbuf;
};
@@ -744,11 +745,11 @@ podcast_feed_title_cell_data_func (GtkTreeViewColumn *column,
}
static void
-podcast_feed_error_cell_data_func (GtkTreeViewColumn *column,
- GtkCellRenderer *renderer,
- GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- RBPodcastSource *source)
+podcast_feed_pixbuf_cell_data_func (GtkTreeViewColumn *column,
+ GtkCellRenderer *renderer,
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ RBPodcastSource *source)
{
char *title;
RhythmDBEntry *entry = NULL;
@@ -762,7 +763,10 @@ podcast_feed_error_cell_data_func (GtkTreeViewColumn *column,
g_free (title);
if (entry != NULL) {
- if (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_PLAYBACK_ERROR)) {
+ gulong status = rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_STATUS);
+ if (status == RHYTHMDB_PODCAST_FEED_STATUS_UPDATING) {
+ pixbuf = source->priv->refresh_pixbuf;
+ } else if (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_PLAYBACK_ERROR)) {
pixbuf = source->priv->error_pixbuf;
}
}
@@ -913,9 +917,13 @@ podcast_entry_changed_cb (RhythmDB *db,
GValue *v = &g_array_index (changes, GValue, i);
RhythmDBEntryChange *change = g_value_get_boxed (v);
- if (change->prop == RHYTHMDB_PROP_PLAYBACK_ERROR) {
+ switch (change->prop) {
+ case RHYTHMDB_PROP_PLAYBACK_ERROR:
+ case RHYTHMDB_PROP_STATUS:
feed_changed = TRUE;
break;
+ default:
+ break;
}
}
@@ -1514,7 +1522,7 @@ impl_constructed (GObject *object)
renderer = rb_cell_renderer_pixbuf_new ();
gtk_tree_view_column_pack_start (column, renderer, TRUE);
gtk_tree_view_column_set_cell_data_func (column, renderer,
- (GtkTreeCellDataFunc) podcast_feed_error_cell_data_func,
+ (GtkTreeCellDataFunc) podcast_feed_pixbuf_cell_data_func,
source, NULL);
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_fixed_width (column, gdk_pixbuf_get_width (source->priv->error_pixbuf) + 5);
@@ -1664,6 +1672,11 @@ impl_dispose (GObject *object)
source->priv->error_pixbuf = NULL;
}
+ if (source->priv->refresh_pixbuf != NULL) {
+ g_object_unref (source->priv->refresh_pixbuf);
+ source->priv->refresh_pixbuf = NULL;
+ }
+
G_OBJECT_CLASS (rb_podcast_source_parent_class)->dispose (object);
}
@@ -1699,10 +1712,15 @@ rb_podcast_source_init (RBPodcastSource *source)
icon_theme = gtk_icon_theme_get_default ();
source->priv->error_pixbuf = gtk_icon_theme_load_icon (icon_theme,
- "dialog-error",
+ "dialog-error-symbolic",
16,
0,
NULL);
+ source->priv->refresh_pixbuf = gtk_icon_theme_load_icon (icon_theme,
+ "view-refresh-symbolic",
+ 16,
+ 0,
+ NULL);
}
static void
diff --git a/rhythmdb/rhythmdb.h b/rhythmdb/rhythmdb.h
index c92060e..308d523 100644
--- a/rhythmdb/rhythmdb.h
+++ b/rhythmdb/rhythmdb.h
@@ -171,6 +171,10 @@ typedef enum
} RhythmDBPropType;
enum {
+ RHYTHMDB_PODCAST_FEED_STATUS_HIDDEN = 0,
+ RHYTHMDB_PODCAST_FEED_STATUS_NORMAL = 1,
+ RHYTHMDB_PODCAST_FEED_STATUS_UPDATING = 2,
+
RHYTHMDB_PODCAST_STATUS_COMPLETE = 100,
RHYTHMDB_PODCAST_STATUS_ERROR = 101,
RHYTHMDB_PODCAST_STATUS_WAITING = 102,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]