From fce5cd9176a15b7f42aa1707c2e2c25537d8fb1e Mon Sep 17 00:00:00 2001 From: Piers Cornwell Date: Wed, 21 Jan 2004 14:03:19 +0000 Subject: Use ngettext for number of downloads and remaining minutes display in the 2004-01-21 Piers Cornwell * embed/downloader-view.c: (update_status_icon), (downloader_view_remove_download): Use ngettext for number of downloads and remaining minutes display in the tooltip of the tray icon. --- ChangeLog | 8 ++++++++ embed/downloader-view.c | 37 ++++++++++++++++++++++++++++++------- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index e5fbcd131..be1642380 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-01-21 Piers Cornwell + + * embed/downloader-view.c: (update_status_icon), + (downloader_view_remove_download): + + Use ngettext for number of downloads and remaining + minutes display in the tooltip of the tray icon. + 2004-01-21 Christian Persch * embed/mozilla/EventContext.cpp: diff --git a/embed/downloader-view.c b/embed/downloader-view.c index 12aadde7b..b0c21fe1f 100644 --- a/embed/downloader-view.c +++ b/embed/downloader-view.c @@ -336,24 +336,45 @@ seconds_remaining_total (EphyDownload *download, gpointer data, DownloaderView * static void update_status_icon (DownloaderView *dv) { - char *tooltip, *remaining; - int downloads; + char *tooltip, *downloadstring, *remainingstring; + int downloads, remaining; 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); + remaining = (dv->priv->remaining_secs); + + if (remaining < 60) + { + remainingstring = g_strdup_printf (ngettext ("About %d second left", + "About %d seconds left", remaining), + remaining); + } + else + { + remaining /= 60; + + remainingstring = g_strdup_printf (ngettext ("About %d minute left", + "About %d minutes left", remaining), + remaining); + } + downloads = g_hash_table_size (dv->priv->downloads_hash); - tooltip = g_strdup_printf ("%d downloads, with a total of " - "%s minutes remaining", - downloads, remaining); + + downloadstring = g_strdup_printf (ngettext ("%d download", + "%d downloads", downloads), + downloads); + + tooltip = g_strdup_printf ("%s\n%s", + downloadstring, remainingstring); egg_status_icon_set_tooltip (dv->priv->status_icon, tooltip, NULL); g_free (tooltip); - g_free (remaining); + g_free (downloadstring); + g_free (remainingstring); } static void @@ -569,6 +590,8 @@ downloader_view_remove_download (DownloaderView *dv, EphyDownload *download) gtk_tree_row_reference_free (row_ref); } + update_status_icon (dv); + /* Close the dialog if there are no more downloads */ if (!g_hash_table_size (dv->priv->downloads_hash)) -- cgit v1.2.3