[epiphany] Add download finished notification



commit 954a14df5b00fcd32742c4115ea463e77435d88c
Author: Juraj Fiala <jurf riseup net>
Date:   Sat Jan 6 14:04:08 2018 +0100

    Add download finished notification
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722142

 embed/ephy-download.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/embed/ephy-download.c b/embed/ephy-download.c
index d274350..13e4364 100644
--- a/embed/ephy-download.c
+++ b/embed/ephy-download.c
@@ -683,6 +683,36 @@ download_created_destination_cb (WebKitDownload *wk_download,
 }
 
 static void
+display_download_finished_notification (WebKitDownload *download)
+{
+  GApplication *application;
+  GtkWindow *toplevel;
+  const char *dest;
+
+  application = G_APPLICATION (ephy_embed_shell_get_default ());
+  toplevel = gtk_application_get_active_window (GTK_APPLICATION (application));
+  dest = webkit_download_get_destination (download);
+
+  if (!gtk_window_is_active (toplevel) && dest != NULL) {
+    char *filename;
+    char *message;
+    GNotification *notification;
+
+    filename = g_filename_display_basename (dest);
+    /* Translators: a desktop notification when a download finishes. */
+    message = g_strdup_printf (_("Finished downloading %s"), filename);
+    /* Translators: the title of the notification. */
+    notification = g_notification_new (_("Download finished"));
+    g_notification_set_body (notification, message);
+    g_application_send_notification (application, "download-finished", notification);
+
+    g_free (filename);
+    g_free (message);
+    g_object_unref (notification);
+  }
+}
+
+static void
 download_finished_cb (WebKitDownload *wk_download,
                       EphyDownload   *download)
 {
@@ -694,6 +724,7 @@ download_finished_cb (WebKitDownload *wk_download,
   else
     ephy_download_do_download_action (download, download->action, download->start_time);
 
+  display_download_finished_notification (wk_download);
   g_signal_emit (download, signals[COMPLETED], 0);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]