logo

badwolf

Minimalist and privacy-oriented WebKitGTK+ browser
commit: 3695453a9d0d9efaf808f84f08a682e884f75eae
parent: cbd54fd0f204d02435a34464057ca6d1fb96d534
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon,  4 May 2020 02:32:41 +0200

Downloads: show elapsed time

Diffstat:

Mdownloads.c53+++++++++++++++++++++++++++++++++++++++++++----------
Mpo/fr.po54+++++++++++++++++++++++++++++++-----------------------
Mpo/messages.pot56++++++++++++++++++++++++++++++++------------------------
3 files changed, 106 insertions(+), 57 deletions(-)

diff --git a/downloads.c b/downloads.c @@ -19,6 +19,17 @@ download_stop_iconCb_clicked(GtkButton *stop_icon, gpointer user_data) } void +download_format_elapsed(char *formatted, size_t formatted_size, char *format, int total) +{ + snprintf(formatted, + formatted_size, + format, + total / 3600, /* hours */ + (total % 3600) / 60, /* minutes */ + total % 60); /* seconds */ +} + +void download_new_entry(WebKitDownload *webkit_download, struct Download *download) { download->error = 0; @@ -30,6 +41,8 @@ download_new_entry(WebKitDownload *webkit_download, struct Download *download) gtk_image_new_from_icon_name("network-idle-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR); download->stop_icon = gtk_button_new_from_icon_name("process-stop", GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_progress_bar_set_show_text(GTK_PROGRESS_BAR(download->progress), TRUE); + g_signal_connect( download->stop_icon, "clicked", G_CALLBACK(download_stop_iconCb_clicked), webkit_download); @@ -54,7 +67,8 @@ downloadCb_created_destination(WebKitDownload *webkit_download, char *markup; struct Download *download = (struct Download *)user_data; - markup = g_markup_printf_escaped("<a href=\"%s\">%s</a>", destination, destination); + markup = g_markup_printf_escaped( + "<a href=\"%s\">%s</a>", destination, webkit_uri_for_display(destination)); gtk_label_set_markup(GTK_LABEL(download->file_path), markup); g_free(markup); @@ -92,16 +106,23 @@ downloadCb_decide_destination(WebKitDownload *webkit_download, void downloadCb_failed(WebKitDownload *webkit_download, GError *error, gpointer user_data) { - (void)webkit_download; - (void)error; struct Download *download = (struct Download *)user_data; + char formatted[BUFSIZ]; + int total = (int)webkit_download_get_elapsed_time(webkit_download); + char *format; download->error = error; if(g_error_matches(error, WEBKIT_DOWNLOAD_ERROR, WEBKIT_DOWNLOAD_ERROR_CANCELLED_BY_USER)) - gtk_label_set_text(GTK_LABEL(download->status), _("Download cancelled")); + format = _("%02i:%02i:%02i Download cancelled"); else - gtk_label_set_text(GTK_LABEL(download->status), _("Download error")); + format = _("%02i:%02i:%02i Download error"); + + download_format_elapsed(formatted, sizeof(formatted), format, total); + + gtk_label_set_text(GTK_LABEL(download->status), formatted); + + gtk_widget_destroy(download->stop_icon); gtk_image_set_from_icon_name( GTK_IMAGE(download->icon), "network-error-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR); @@ -110,16 +131,22 @@ downloadCb_failed(WebKitDownload *webkit_download, GError *error, gpointer user_ void downloadCb_finished(WebKitDownload *webkit_download, gpointer user_data) { - (void)webkit_download; struct Download *download = (struct Download *)user_data; + char formatted[BUFSIZ]; + int total = (int)webkit_download_get_elapsed_time(webkit_download); + + gchar *format_size = g_format_size(webkit_download_get_received_data_length(webkit_download)); + + download_format_elapsed( + formatted, sizeof(formatted), _("%02i:%02i:%02i Download finished"), total); - // gtk_button_set_image(GTK_BUTTON(download->stop_icon), NULL); gtk_widget_destroy(download->stop_icon); if(download->error == 0) { gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(download->progress), 1); - gtk_label_set_text(GTK_LABEL(download->status), _("Download finished")); + gtk_progress_bar_set_text(GTK_PROGRESS_BAR(download->progress), format_size); + gtk_label_set_text(GTK_LABEL(download->status), formatted); gtk_image_set_from_icon_name( GTK_IMAGE(download->icon), "network-idle-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR); } @@ -132,13 +159,19 @@ downloadCb_received_data(WebKitDownload *webkit_download, guint64 data_lenght, g { (void)data_lenght; struct Download *download = (struct Download *)user_data; - gchar *format_size = g_format_size(data_lenght); + char formatted[BUFSIZ]; + int total = (int)webkit_download_get_elapsed_time(webkit_download); + + gchar *format_size = g_format_size(webkit_download_get_received_data_length(webkit_download)); + + download_format_elapsed(formatted, sizeof(formatted), _("%02i:%02i:%02i Downloading…"), total); gtk_image_set_from_icon_name( GTK_IMAGE(download->icon), "network-receive-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR); - gtk_label_set_text(GTK_LABEL(download->status), format_size); + gtk_label_set_text(GTK_LABEL(download->status), formatted); gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(download->progress), webkit_download_get_estimated_progress(webkit_download)); + gtk_progress_bar_set_text(GTK_PROGRESS_BAR(download->progress), format_size); g_free(format_size); } diff --git a/po/fr.po b/po/fr.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Badwolf 0.3.0+gd88f2e7\n" "Report-Msgid-Bugs-To: contact+badwolf-msgid@hacktivis.me\n" -"POT-Creation-Date: 2020-05-04 00:50+0200\n" +"POT-Creation-Date: 2020-05-04 02:40+0200\n" "PO-Revision-Date: 2019-12-22 00:57+0100\n" "Last-Translator: Haelwenn (lanodan) Monnier <contact@hacktivis.me>\n" "Language-Team: French\n" @@ -17,11 +17,31 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: downloads.c:159 downloads.c:163 +#: downloads.c:117 +#, fuzzy, c-format +msgid "%02i:%02i:%02i Download cancelled" +msgstr "%02i:%02i:%02i Téléchargement annulé" + +#: downloads.c:119 +#, fuzzy, c-format +msgid "%02i:%02i:%02i Download error" +msgstr "%02i:%02i:%02i Erreur du téléchargement" + +#: downloads.c:140 +#, fuzzy, c-format +msgid "%02i:%02i:%02i Download finished" +msgstr "%02i:%02i:%02i Téléchargement finit" + +#: downloads.c:166 +#, c-format +msgid "%02i:%02i:%02i Downloading…" +msgstr "%02i:%02i:%02i Téléchargement en cours…" + +#: downloads.c:191 downloads.c:195 msgid "Badwolf Downloads" msgstr "Téléchargements Badwolf" -#: badwolf.c:770 +#: badwolf.c:760 #, c-format msgid "Buildtime WebKit version: %d.%d.%d\n" msgstr "Version WebKit à la compilation: %d.%d.%d\n" @@ -45,19 +65,7 @@ msgstr "" msgid "Crashed" msgstr "Crash" -#: downloads.c:102 -msgid "Download cancelled" -msgstr "Téléchargement annulé" - -#: downloads.c:104 -msgid "Download error" -msgstr "Erreur du téléchargement" - -#: downloads.c:122 -msgid "Download finished" -msgstr "Téléchargement finit" - -#: downloads.c:28 +#: downloads.c:39 msgid "Download starting…" msgstr "Démarrage du téléchargement" @@ -100,11 +108,11 @@ msgstr "" "Navigateur WebKitGTK+ minimaliste et orienté vie privée\n" "Version WebKit au lancement: %d.%d.%d" -#: badwolf.c:699 +#: badwolf.c:689 msgid "New tab" msgstr "Nouvel onglet" -#: badwolf.c:819 +#: badwolf.c:809 msgid "Open new tab" msgstr "Ouvrir un nouvel onglet" @@ -112,12 +120,12 @@ msgstr "Ouvrir un nouvel onglet" msgid "Out of Memory" msgstr "Dépassement Mémoire" -#: badwolf.c:768 +#: badwolf.c:758 #, c-format msgid "Running Badwolf version: %s\n" msgstr "Version de Badwolf: %s\n" -#: badwolf.c:775 +#: badwolf.c:765 #, c-format msgid "Runtime WebKit version: %d.%d.%d\n" msgstr "Version WebKit au lancement: %d.%d.%d\n" @@ -139,7 +147,7 @@ msgstr "Activer/Désactiver javascript" msgid "Unknown Crash" msgstr "Crash inconnu" -#: badwolf.c:625 +#: badwolf.c:615 msgid "search in current page" msgstr "recherche dans la page courante" @@ -155,12 +163,12 @@ msgstr "le processus web a dépassé la limitation de mémoire.\n" msgid "the web process terminated for an unknown reason.\n" msgstr "le processus web s’est interrompu pour une raison inconnue.\n" -#: badwolf.c:782 +#: badwolf.c:772 #, c-format msgid "webkit-web-extension directory set to: %s\n" msgstr "Répertoire webkit-web-extension configuré à %s\n" #. TRANSLATOR Ignore this entry. Done for forcing Unicode in xgettext. -#: badwolf.c:853 +#: badwolf.c:843 msgid "ø" msgstr "" diff --git a/po/messages.pot b/po/messages.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Badwolf 0.5.1+g76b542b.develop\n" +"Project-Id-Version: Badwolf 0.5.1+g73e576e.develop\n" "Report-Msgid-Bugs-To: contact+badwolf-msgid@hacktivis.me\n" -"POT-Creation-Date: 2020-05-04 00:50+0200\n" +"POT-Creation-Date: 2020-05-04 02:40+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -17,11 +17,31 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: downloads.c:159 downloads.c:163 +#: downloads.c:117 +#, c-format +msgid "%02i:%02i:%02i Download cancelled" +msgstr "" + +#: downloads.c:119 +#, c-format +msgid "%02i:%02i:%02i Download error" +msgstr "" + +#: downloads.c:140 +#, c-format +msgid "%02i:%02i:%02i Download finished" +msgstr "" + +#: downloads.c:166 +#, c-format +msgid "%02i:%02i:%02i Downloading…" +msgstr "" + +#: downloads.c:191 downloads.c:195 msgid "Badwolf Downloads" msgstr "" -#: badwolf.c:770 +#: badwolf.c:760 #, c-format msgid "Buildtime WebKit version: %d.%d.%d\n" msgstr "" @@ -41,19 +61,7 @@ msgstr "" msgid "Crashed" msgstr "" -#: downloads.c:102 -msgid "Download cancelled" -msgstr "" - -#: downloads.c:104 -msgid "Download error" -msgstr "" - -#: downloads.c:122 -msgid "Download finished" -msgstr "" - -#: downloads.c:28 +#: downloads.c:39 msgid "Download starting…" msgstr "" @@ -92,11 +100,11 @@ msgid "" "Runtime WebKit version: %d.%d.%d" msgstr "" -#: badwolf.c:699 +#: badwolf.c:689 msgid "New tab" msgstr "" -#: badwolf.c:819 +#: badwolf.c:809 msgid "Open new tab" msgstr "" @@ -104,12 +112,12 @@ msgstr "" msgid "Out of Memory" msgstr "" -#: badwolf.c:768 +#: badwolf.c:758 #, c-format msgid "Running Badwolf version: %s\n" msgstr "" -#: badwolf.c:775 +#: badwolf.c:765 #, c-format msgid "Runtime WebKit version: %d.%d.%d\n" msgstr "" @@ -131,7 +139,7 @@ msgstr "" msgid "Unknown Crash" msgstr "" -#: badwolf.c:625 +#: badwolf.c:615 msgid "search in current page" msgstr "" @@ -147,12 +155,12 @@ msgstr "" msgid "the web process terminated for an unknown reason.\n" msgstr "" -#: badwolf.c:782 +#: badwolf.c:772 #, c-format msgid "webkit-web-extension directory set to: %s\n" msgstr "" #. TRANSLATOR Ignore this entry. Done for forcing Unicode in xgettext. -#: badwolf.c:853 +#: badwolf.c:843 msgid "ø" msgstr ""