[rhythmbox: 1/2] podcast: handle podcast download notifications better
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox: 1/2] podcast: handle podcast download notifications better
- Date: Sun, 26 Sep 2021 11:41:05 +0000 (UTC)
commit 1a5bb85a31338121eae84c6799d6b7edd3ee4d0b
Author: crvi <crvisqr gmail com>
Date: Sun Nov 8 15:41:01 2020 +0530
podcast: handle podcast download notifications better
We now notify the user on podcast downloads which succeed or fail, not
notifying on cancelled downloads.
Closes #1781
podcast/rb-podcast-main-source.c | 14 +++++++++++++-
podcast/rb-podcast-manager.c | 16 ++++++++++++----
2 files changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/podcast/rb-podcast-main-source.c b/podcast/rb-podcast-main-source.c
index 45a54558c..28ffbc0a4 100644
--- a/podcast/rb-podcast-main-source.c
+++ b/podcast/rb-podcast-main-source.c
@@ -170,18 +170,30 @@ start_download_cb (RBPodcastManager *pd,
static void
finish_download_cb (RBPodcastManager *pd,
RhythmDBEntry *entry,
+ GError *error,
RBPodcastMainSource *source)
{
RBShell *shell;
char *podcast_name;
+ char *primary, *secondary;
podcast_name = g_markup_escape_text (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_TITLE), -1);
g_object_get (source, "shell", &shell, NULL);
- rb_shell_notify_custom (shell, 4000, _("Finished downloading podcast"), podcast_name, NULL, FALSE);
+
+ if (error) {
+ primary = _("Error downloading podcast");
+ secondary = g_strdup_printf ("%s\n\n%s", podcast_name, error->message);
+ } else {
+ primary = _("Finished downloading podcast");
+ secondary = g_strdup_printf ("%s", podcast_name);
+ }
+
+ rb_shell_notify_custom (shell, 4000, primary, secondary, NULL, FALSE);
g_object_unref (shell);
g_free (podcast_name);
+ g_free (secondary);
}
static void
diff --git a/podcast/rb-podcast-manager.c b/podcast/rb-podcast-manager.c
index 635db0b27..50e4fbe60 100644
--- a/podcast/rb-podcast-manager.c
+++ b/podcast/rb-podcast-manager.c
@@ -204,8 +204,9 @@ rb_podcast_manager_class_init (RBPodcastManagerClass *klass)
NULL, NULL,
NULL,
G_TYPE_NONE,
- 1,
- RHYTHMDB_TYPE_ENTRY);
+ 2,
+ RHYTHMDB_TYPE_ENTRY,
+ G_TYPE_ERROR);
rb_podcast_manager_signals[FEED_UPDATES_AVAILABLE] =
g_signal_new ("feed_updates_available",
@@ -1715,6 +1716,7 @@ podcast_download_cb (GObject *source_object, GAsyncResult *res, gpointer data)
GError *error = NULL;
GTask *task = G_TASK (res);
GValue val = {0,};
+ gboolean notify_user = TRUE;
download = g_task_get_task_data (task);
rb_debug ("cleaning up download of %s",
@@ -1742,6 +1744,9 @@ podcast_download_cb (GObject *source_object, GAsyncResult *res, gpointer data)
rhythmdb_entry_set (pd->priv->db, download->entry, RHYTHMDB_PROP_PLAYBACK_ERROR,
&val);
g_value_unset (&val);
} else {
+ /* no need to notify for cancellations */
+ notify_user = FALSE;
+
rb_debug ("download of %s was cancelled", get_remote_location (download->entry));
g_value_init (&val, G_TYPE_ULONG);
g_value_set_ulong (&val, RHYTHMDB_PODCAST_STATUS_PAUSED);
@@ -1752,11 +1757,14 @@ podcast_download_cb (GObject *source_object, GAsyncResult *res, gpointer data)
unset_download_location (pd->priv->db, download->entry);
rhythmdb_commit (pd->priv->db);
- g_clear_error (&error);
}
- g_signal_emit (pd, rb_podcast_manager_signals[FINISH_DOWNLOAD], 0, download->entry);
+ if (notify_user) {
+ g_signal_emit (pd, rb_podcast_manager_signals[FINISH_DOWNLOAD],
+ 0, download->entry, error);
+ }
+ g_clear_error (&error);
download_info_free (download);
g_object_unref (task);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]