diff options
author | Juraj Fiala <jurf@riseup.net> | 2018-01-06 14:04:08 +0100 |
---|---|---|
committer | Michael Catanzaro <mcatanzaro@igalia.com> | 2018-01-06 12:37:06 -0600 |
commit | 954a14df5b00fcd32742c4115ea463e77435d88c (patch) | |
tree | 1431526d8a5d816897c5d312a2d65ef0361d6927 | |
parent | e5051738393947c85b3fd1af583e5ef568e0bcaf (diff) | |
download | epiphany-954a14df5b00fcd32742c4115ea463e77435d88c.tar.gz |
Add download finished notification
https://bugzilla.gnome.org/show_bug.cgi?id=722142
-rw-r--r-- | 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 d274350b7..13e4364f8 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); } |