[epiphany/wip/fixes: 14/15] Activate downloads popover when download is completed



commit 00c91988aa652484a40b2aa681a7dcd803cd69a1
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Sat Mar 5 11:25:21 2016 -0600

    Activate downloads popover when download is completed
    
    When a download is nearly finished, I find myself watching the download
    button, guessing whether the very tip of the download arrow has been
    filled in or not, opening the popover to check if it's ready... and
    repeating if I guessed wrong. Activate when a download completes to
    avoid this.
    
    Not a great final design, it'd be better for the button to glow or
    something, but it's a cheap way to tell the user that the download has
    finished.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763141

 embed/ephy-downloads-manager.c |   10 ++++++++++
 src/ephy-toolbar.c             |   11 +++++++++++
 2 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/embed/ephy-downloads-manager.c b/embed/ephy-downloads-manager.c
index 4a7c3af..0ad8d46 100644
--- a/embed/ephy-downloads-manager.c
+++ b/embed/ephy-downloads-manager.c
@@ -25,6 +25,7 @@
 
 enum {
   DOWNLOAD_ADDED,
+  DOWNLOAD_COMPLETED,
   DOWNLOAD_REMOVED,
 
   ESTIMATED_PROGRESS_CHANGED,
@@ -105,6 +106,14 @@ ephy_downloads_manager_class_init (EphyDownloadsManagerClass *klass)
                   G_TYPE_NONE, 1,
                   EPHY_TYPE_DOWNLOAD);
 
+  signals[DOWNLOAD_COMPLETED] =
+    g_signal_new ("download-completed",
+                  EPHY_TYPE_DOWNLOADS_MANAGER,
+                  G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL, NULL,
+                  G_TYPE_NONE, 1,
+                  EPHY_TYPE_DOWNLOAD);
+
   signals[DOWNLOAD_REMOVED] =
     g_signal_new ("download-removed",
                   EPHY_TYPE_DOWNLOADS_MANAGER,
@@ -126,6 +135,7 @@ download_completed_cb (EphyDownload         *download,
                        EphyDownloadsManager *manager)
 {
   g_signal_emit (manager, signals[ESTIMATED_PROGRESS_CHANGED], 0);
+  g_signal_emit (manager, signals[DOWNLOAD_COMPLETED], 0, download);
   ephy_downloads_manager_release_session_inhibitor (manager);
 }
 
diff --git a/src/ephy-toolbar.c b/src/ephy-toolbar.c
index 09548bb..d0530e9 100644
--- a/src/ephy-toolbar.c
+++ b/src/ephy-toolbar.c
@@ -66,6 +66,14 @@ download_added_cb (EphyDownloadsManager *manager,
 }
 
 static void
+download_completed_cb (EphyDownloadsManager *manager,
+                       EphyDownload *download,
+                       EphyToolbar *toolbar)
+{
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toolbar->downloads_button), TRUE);
+}
+
+static void
 download_removed_cb (EphyDownloadsManager *manager,
                      EphyDownload *download,
                      EphyToolbar *toolbar)
@@ -246,6 +254,9 @@ ephy_toolbar_constructed (GObject *object)
   g_signal_connect_object (downloads_manager, "download-added",
                            G_CALLBACK (download_added_cb),
                            object, 0);
+  g_signal_connect_object (downloads_manager, "download-completed",
+                           G_CALLBACK (download_completed_cb),
+                           object, 0);
   g_signal_connect_object (downloads_manager, "download-removed",
                            G_CALLBACK (download_removed_cb),
                            object, 0);


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