aboutsummaryrefslogtreecommitdiffstats
path: root/embed/downloader-view.c
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2003-11-29 01:22:05 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2003-11-29 01:22:05 +0800
commit5ac9195bc7837a26aa5069b3c66934ea54ffee98 (patch)
tree16f2d76cfc21a82fe8fa18f654992ebc3147e6f1 /embed/downloader-view.c
parentd0b9b0af497369eb6b2625057f456971a0ccf05a (diff)
downloadgsoc2013-epiphany-5ac9195bc7837a26aa5069b3c66934ea54ffee98.tar
gsoc2013-epiphany-5ac9195bc7837a26aa5069b3c66934ea54ffee98.tar.gz
gsoc2013-epiphany-5ac9195bc7837a26aa5069b3c66934ea54ffee98.tar.bz2
gsoc2013-epiphany-5ac9195bc7837a26aa5069b3c66934ea54ffee98.tar.lz
gsoc2013-epiphany-5ac9195bc7837a26aa5069b3c66934ea54ffee98.tar.xz
gsoc2013-epiphany-5ac9195bc7837a26aa5069b3c66934ea54ffee98.tar.zst
gsoc2013-epiphany-5ac9195bc7837a26aa5069b3c66934ea54ffee98.zip
Show total downloads and time in the tray icon tooltip
2003-11-28 Marco Pesenti Gritti <marco@gnome.org> * embed/downloader-view.c: (status_icon_activated), (seconds_remaining_total), (update_status_icon), (download_changed_cb), (downloader_view_add_download): Show total downloads and time in the tray icon tooltip
Diffstat (limited to 'embed/downloader-view.c')
-rw-r--r--embed/downloader-view.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/embed/downloader-view.c b/embed/downloader-view.c
index 8bbeafc85..4682b9c76 100644
--- a/embed/downloader-view.c
+++ b/embed/downloader-view.c
@@ -62,6 +62,8 @@ struct DownloaderViewPrivate
GtkWidget *abort_button;
EggStatusIcon *status_icon;
+
+ long remaining_secs;
};
typedef struct
@@ -153,7 +155,7 @@ downloader_view_class_init (DownloaderViewClass *klass)
static void
status_icon_activated (EggStatusIcon *icon, DownloaderView *dv)
{
- gtk_widget_show (dv->priv->window);
+ gtk_window_present (GTK_WINDOW (dv->priv->window));
}
static void
@@ -313,9 +315,45 @@ update_download_row (DownloaderView *dv, EphyDownload *download)
}
static void
+seconds_remaining_total (EphyDownload *download, gpointer data, DownloaderView *dv)
+{
+ long secs;
+
+ secs = ephy_download_get_remaining_time (download);
+ if (secs > 0)
+ {
+ dv->priv->remaining_secs += secs;
+ }
+}
+
+static void
+update_status_icon (DownloaderView *dv)
+{
+ char *tooltip, *remaining;
+ int downloads;
+
+ dv->priv->remaining_secs = 0;
+ g_hash_table_foreach (dv->priv->downloads_hash,
+ (GHFunc) seconds_remaining_total, dv);
+
+ remaining = format_interval (dv->priv->remaining_secs);
+ downloads = g_hash_table_size (dv->priv->downloads_hash);
+ tooltip = g_strdup_printf ("%d downloads, with a total of "
+ "%s minutes remaining",
+ downloads, remaining);
+
+ egg_status_icon_set_tooltip (dv->priv->status_icon,
+ tooltip, NULL);
+
+ g_free (tooltip);
+ g_free (remaining);
+}
+
+static void
download_changed_cb (EphyDownload *download, DownloaderView *dv)
{
update_download_row (dv, download);
+ update_status_icon (dv);
}
void
@@ -341,6 +379,7 @@ downloader_view_add_download (DownloaderView *dv,
row_ref);
update_download_row (dv, download);
+ update_status_icon (dv);
selection = gtk_tree_view_get_selection
(GTK_TREE_VIEW(dv->priv->treeview));