From ad8b3dd9b8d29d067d9b2f4babe7aaa70be58c3d Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Tue, 21 Jan 2020 02:12:30 +0100 Subject: Download progress tab --- downloads.c | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 downloads.c (limited to 'downloads.c') diff --git a/downloads.c b/downloads.c new file mode 100644 index 0000000..0c1ee3d --- /dev/null +++ b/downloads.c @@ -0,0 +1,160 @@ +// BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser +// Copyright © 2019 Haelwenn (lanodan) Monnier +// SPDX-License-Identifier: BSD-3-Clause + +#include "downloads.h" + +#include "badwolf.h" +#include "config.h" + +#include /* _() and other internationalization/localization helpers */ + +static void +download_stop_iconCb_clicked(GtkButton *stop_icon, gpointer user_data) +{ + (void)stop_icon; + WebKitDownload *webkit_download = (WebKitDownload *)user_data; + + webkit_download_cancel(webkit_download); +} + +void +download_new_entry(WebKitDownload *webkit_download, struct Download *download) +{ + download->error = 0; + download->container = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, BADWOLF_DOWNLOAD_PADDING); + download->progress = gtk_progress_bar_new(); + download->file_path = gtk_label_new(NULL); + download->status = gtk_label_new(_("Download starting…")); + download->icon = + 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); + + g_signal_connect( + download->stop_icon, "clicked", G_CALLBACK(download_stop_iconCb_clicked), webkit_download); + + gtk_box_pack_start(GTK_BOX(download->container), download->icon, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(download->container), download->progress, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(download->container), download->stop_icon, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(download->container), download->status, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(download->container), download->file_path, FALSE, FALSE, 0); + + gtk_box_pack_start( + GTK_BOX(download->window->downloads_tab), download->container, FALSE, FALSE, 0); + + gtk_widget_show_all(download->container); +} + +void +downloadCb_created_destination(WebKitDownload *webkit_download, + gchar *destination, + gpointer user_data) +{ + (void)webkit_download; + struct Download *download = (struct Download *)user_data; + + gtk_label_set_text(GTK_LABEL(download->file_path), destination); +} + +gboolean +downloadCb_decide_destination(WebKitDownload *webkit_download, + gchar *suggested_filename, + gpointer user_data) +{ + struct Client *browser = (struct Client *)user_data; + gint chooser_response; + GtkWindow *parent_window = GTK_WINDOW(browser->window->main_window); + + GtkFileChooserNative *file_dialog = + gtk_file_chooser_native_new(NULL, parent_window, GTK_FILE_CHOOSER_ACTION_SAVE, NULL, NULL); + GtkFileChooser *file_chooser = GTK_FILE_CHOOSER(file_dialog); + + gtk_file_chooser_set_current_name(file_chooser, suggested_filename); + gtk_file_chooser_set_do_overwrite_confirmation(file_chooser, TRUE); + webkit_download_set_allow_overwrite(webkit_download, TRUE); + + chooser_response = gtk_native_dialog_run(GTK_NATIVE_DIALOG(file_dialog)); + + if(chooser_response == GTK_RESPONSE_ACCEPT) + webkit_download_set_destination(webkit_download, gtk_file_chooser_get_uri(file_chooser)); + else + webkit_download_cancel(webkit_download); + + g_object_unref(file_dialog); + + return FALSE; /* Let it propagate */ +} + +void +downloadCb_failed(WebKitDownload *webkit_download, GError *error, gpointer user_data) +{ + (void)webkit_download; + (void)error; + struct Download *download = (struct Download *)user_data; + + 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")); + else + gtk_label_set_text(GTK_LABEL(download->status), _("Download error")); + + gtk_image_set_from_icon_name( + GTK_IMAGE(download->icon), "network-error-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR); +} + +void +downloadCb_finished(WebKitDownload *webkit_download, gpointer user_data) +{ + (void)webkit_download; + struct Download *download = (struct Download *)user_data; + + // 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_image_set_from_icon_name( + GTK_IMAGE(download->icon), "network-idle-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR); + } + + // TODO: Send notification +} + +void +downloadCb_received_data(WebKitDownload *webkit_download, guint64 data_lenght, gpointer user_data) +{ + (void)data_lenght; + struct Download *download = (struct Download *)user_data; + gchar *format_size = g_format_size(data_lenght); + + 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_progress_bar_set_fraction(GTK_PROGRESS_BAR(download->progress), + webkit_download_get_estimated_progress(webkit_download)); + + g_free(format_size); +} + +GtkWidget * +badwolf_downloads_tab_new() +{ + return gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); +} + +void +badwolf_downloads_tab_attach(struct Window *window) +{ + gtk_notebook_insert_page(GTK_NOTEBOOK(window->notebook), window->downloads_tab, NULL, 0); + gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(window->notebook), window->downloads_tab, FALSE); + GtkWidget *downloads_tab_label = + gtk_image_new_from_icon_name("emblem-downloads", GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_widget_set_tooltip_text(downloads_tab_label, _("Badwolf Downloads")); + gtk_notebook_set_tab_label( + GTK_NOTEBOOK(window->notebook), window->downloads_tab, downloads_tab_label); + gtk_notebook_set_menu_label_text( + GTK_NOTEBOOK(window->notebook), window->downloads_tab, _("Badwolf Downloads")); +} -- cgit v1.3.1-26-gb76a From 00e6ddaee5b24b98ce1082985ef48dc6f6f52319 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Mon, 4 May 2020 00:54:08 +0200 Subject: Downloads: Make it an hyperlink --- README.md | 2 +- badwolf.c | 2 +- downloads.c | 6 +++++- po/messages.pot | 28 ++++++++++++++-------------- 4 files changed, 21 insertions(+), 17 deletions(-) (limited to 'downloads.c') diff --git a/README.md b/README.md index f502988..22846e1 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Comparing from other small WebKit browsers for unixes found in the wild: - not queryabe by WebKit (so the web can't use it) - done in a standard format (like XBEL for bookmarks) - Static UI, no element should be added at runtime, this is to avoid potential tracking via viewport changes -- Small codebase, right now we are under 1 500 lines total +- Small codebase, should be possible to read and understand it completely over an afternoon. - Does not use modal editing (from vi) as that was designed for editing, not browsing - UTF-8 encoding by default diff --git a/badwolf.c b/badwolf.c index 84d2577..842a1e0 100644 --- a/badwolf.c +++ b/badwolf.c @@ -747,7 +747,7 @@ badwolf_get_tab_position(GtkContainer *notebook, GtkWidget *child) int main(int argc, char *argv[]) { - struct Window *window = &(struct Window){NULL, NULL, NULL}; + struct Window *window = &(struct Window){NULL, NULL, NULL, NULL}; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, DATADIR "/locale"); bind_textdomain_codeset(PACKAGE, "UTF-8"); diff --git a/downloads.c b/downloads.c index 0c1ee3d..2443a3e 100644 --- a/downloads.c +++ b/downloads.c @@ -51,9 +51,13 @@ downloadCb_created_destination(WebKitDownload *webkit_download, gpointer user_data) { (void)webkit_download; + char *markup; struct Download *download = (struct Download *)user_data; - gtk_label_set_text(GTK_LABEL(download->file_path), destination); + markup = g_markup_printf_escaped("%s", destination, destination); + + gtk_label_set_markup(GTK_LABEL(download->file_path), markup); + g_free(markup); } gboolean diff --git a/po/messages.pot b/po/messages.pot index 360178f..ff7c89b 100644 --- a/po/messages.pot +++ b/po/messages.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Badwolf 0.5.1+gb1ff239.download-progress\n" +"Project-Id-Version: Badwolf 0.5.1+g76b542b.develop\n" "Report-Msgid-Bugs-To: contact+badwolf-msgid@hacktivis.me\n" -"POT-Creation-Date: 2020-05-01 00:20+0200\n" +"POT-Creation-Date: 2020-05-04 00:50+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,11 +17,11 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: downloads.c:155 downloads.c:159 +#: downloads.c:159 downloads.c:163 msgid "Badwolf Downloads" msgstr "" -#: badwolf.c:760 +#: badwolf.c:770 #, c-format msgid "Buildtime WebKit version: %d.%d.%d\n" msgstr "" @@ -41,15 +41,15 @@ msgstr "" msgid "Crashed" msgstr "" -#: downloads.c:98 +#: downloads.c:102 msgid "Download cancelled" msgstr "" -#: downloads.c:100 +#: downloads.c:104 msgid "Download error" msgstr "" -#: downloads.c:118 +#: downloads.c:122 msgid "Download finished" msgstr "" @@ -92,11 +92,11 @@ msgid "" "Runtime WebKit version: %d.%d.%d" msgstr "" -#: badwolf.c:689 +#: badwolf.c:699 msgid "New tab" msgstr "" -#: badwolf.c:808 +#: badwolf.c:819 msgid "Open new tab" msgstr "" @@ -104,12 +104,12 @@ msgstr "" msgid "Out of Memory" msgstr "" -#: badwolf.c:758 +#: badwolf.c:768 #, c-format msgid "Running Badwolf version: %s\n" msgstr "" -#: badwolf.c:765 +#: badwolf.c:775 #, c-format msgid "Runtime WebKit version: %d.%d.%d\n" msgstr "" @@ -131,7 +131,7 @@ msgstr "" msgid "Unknown Crash" msgstr "" -#: badwolf.c:615 +#: badwolf.c:625 msgid "search in current page" msgstr "" @@ -147,12 +147,12 @@ msgstr "" msgid "the web process terminated for an unknown reason.\n" msgstr "" -#: badwolf.c:772 +#: badwolf.c:782 #, c-format msgid "webkit-web-extension directory set to: %s\n" msgstr "" #. TRANSLATOR Ignore this entry. Done for forcing Unicode in xgettext. -#: badwolf.c:842 +#: badwolf.c:853 msgid "ø" msgstr "" -- cgit v1.3.1-26-gb76a From 3695453a9d0d9efaf808f84f08a682e884f75eae Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Mon, 4 May 2020 02:32:41 +0200 Subject: Downloads: show elapsed time --- downloads.c | 53 +++++++++++++++++++++++++++++++++++++++++++---------- po/fr.po | 54 +++++++++++++++++++++++++++++++----------------------- po/messages.pot | 56 ++++++++++++++++++++++++++++++++------------------------ 3 files changed, 106 insertions(+), 57 deletions(-) (limited to 'downloads.c') diff --git a/downloads.c b/downloads.c index 2443a3e..81a5dfc 100644 --- a/downloads.c +++ b/downloads.c @@ -18,6 +18,17 @@ download_stop_iconCb_clicked(GtkButton *stop_icon, gpointer user_data) webkit_download_cancel(webkit_download); } +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) { @@ -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("%s", destination, destination); + markup = g_markup_printf_escaped( + "%s", 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 index 214b382..8164e1c 100644 --- 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 \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 index ff7c89b..273280a 100644 --- 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 \n" "Language-Team: LANGUAGE \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 "" -- cgit v1.3.1-26-gb76a From 07d0381569633d0391a7dc098f3b468cf29330c1 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Mon, 11 May 2020 00:18:07 +0200 Subject: downloads: Make tab look & behave like a real tab --- downloads.c | 33 +++++++++++++++++++++++++++------ po/fr.po | 8 ++++---- po/messages.pot | 10 +++++----- 3 files changed, 36 insertions(+), 15 deletions(-) (limited to 'downloads.c') diff --git a/downloads.c b/downloads.c index 81a5dfc..1a21ada 100644 --- a/downloads.c +++ b/downloads.c @@ -186,12 +186,33 @@ void badwolf_downloads_tab_attach(struct Window *window) { gtk_notebook_insert_page(GTK_NOTEBOOK(window->notebook), window->downloads_tab, NULL, 0); - gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(window->notebook), window->downloads_tab, FALSE); - GtkWidget *downloads_tab_label = - gtk_image_new_from_icon_name("emblem-downloads", GTK_ICON_SIZE_SMALL_TOOLBAR); - gtk_widget_set_tooltip_text(downloads_tab_label, _("Badwolf Downloads")); - gtk_notebook_set_tab_label( - GTK_NOTEBOOK(window->notebook), window->downloads_tab, downloads_tab_label); + gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(window->notebook), window->downloads_tab, TRUE); + + GtkWidget *tab_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_widget_set_name(tab_box, "browser__tabbox"); + GtkWidget *icon = gtk_image_new_from_icon_name("emblem-downloads", GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_widget_set_name(icon, "browser__tabbox__icon"); + GtkWidget *label = gtk_label_new(_("Badwolf Downloads")); + gtk_widget_set_name(label, "browser__tabbox__label"); + +#ifdef BADWOLF_TAB_BOX_WIDTH + gtk_widget_set_size_request(label, BADWOLF_TAB_BOX_WIDTH, -1); +#endif +#ifdef BADWOLF_TAB_LABEL_CHARWIDTH + gtk_label_set_width_chars(GTK_LABEL(label), BADWOLF_TAB_LABEL_CHARWIDTH); +#endif + gtk_widget_set_hexpand(tab_box, BADWOLF_TAB_HEXPAND); + + gtk_label_set_ellipsize(GTK_LABEL(label), BADWOLF_TAB_LABEL_ELLIPSIZE); + gtk_label_set_single_line_mode(GTK_LABEL(label), TRUE); + + gtk_box_pack_start(GTK_BOX(tab_box), icon, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(tab_box), label, TRUE, TRUE, 0); + + gtk_widget_set_tooltip_text(tab_box, _("Badwolf Downloads")); + gtk_notebook_set_tab_label(GTK_NOTEBOOK(window->notebook), window->downloads_tab, tab_box); gtk_notebook_set_menu_label_text( GTK_NOTEBOOK(window->notebook), window->downloads_tab, _("Badwolf Downloads")); + + gtk_widget_show_all(tab_box); } diff --git a/po/fr.po b/po/fr.po index 8164e1c..cc361e1 100644 --- 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 02:40+0200\n" +"POT-Creation-Date: 2020-05-11 00:19+0200\n" "PO-Revision-Date: 2019-12-22 00:57+0100\n" "Last-Translator: Haelwenn (lanodan) Monnier \n" "Language-Team: French\n" @@ -27,17 +27,17 @@ msgstr "%02i:%02i:%02i Téléchargement annulé" msgid "%02i:%02i:%02i Download error" msgstr "%02i:%02i:%02i Erreur du téléchargement" -#: downloads.c:140 +#: downloads.c:141 #, fuzzy, c-format msgid "%02i:%02i:%02i Download finished" msgstr "%02i:%02i:%02i Téléchargement finit" -#: downloads.c:166 +#: downloads.c:167 #, c-format msgid "%02i:%02i:%02i Downloading…" msgstr "%02i:%02i:%02i Téléchargement en cours…" -#: downloads.c:191 downloads.c:195 +#: downloads.c:195 downloads.c:212 downloads.c:215 msgid "Badwolf Downloads" msgstr "Téléchargements Badwolf" diff --git a/po/messages.pot b/po/messages.pot index 273280a..ce401ef 100644 --- a/po/messages.pot +++ b/po/messages.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Badwolf 0.5.1+g73e576e.develop\n" +"Project-Id-Version: Badwolf 0.5.1+g226ed40.develop\n" "Report-Msgid-Bugs-To: contact+badwolf-msgid@hacktivis.me\n" -"POT-Creation-Date: 2020-05-04 02:40+0200\n" +"POT-Creation-Date: 2020-05-11 00:19+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -27,17 +27,17 @@ msgstr "" msgid "%02i:%02i:%02i Download error" msgstr "" -#: downloads.c:140 +#: downloads.c:141 #, c-format msgid "%02i:%02i:%02i Download finished" msgstr "" -#: downloads.c:166 +#: downloads.c:167 #, c-format msgid "%02i:%02i:%02i Downloading…" msgstr "" -#: downloads.c:191 downloads.c:195 +#: downloads.c:195 downloads.c:212 downloads.c:215 msgid "Badwolf Downloads" msgstr "" -- cgit v1.3.1-26-gb76a