From 59a9aac09adc7e92ecf478927391314555643ccf Mon Sep 17 00:00:00 2001 From: Reed Wade Date: Tue, 30 Mar 2021 14:47:45 +0200 Subject: [PATCH 1/2] Add search engine widget --- badwolf.c | 29 ++++++++++++++++++++++ badwolf.h | 1 + config.h | 3 +++ po/messages.pot | 66 ++++++++++++++++++++++++++----------------------- 4 files changed, 68 insertions(+), 31 deletions(-) diff --git a/badwolf.c b/badwolf.c index 977f2140..5bd15d5f 100644 --- a/badwolf.c +++ b/badwolf.c @@ -57,6 +57,7 @@ static void web_contextCb_download_started(WebKitWebContext *web_context, WebKitDownload *download, gpointer user_data); static gboolean locationCb_activate(GtkEntry *location, gpointer user_data); +static gboolean searchCb_activate(GtkEntry *search, gpointer user_data); static gboolean javascriptCb_toggled(GtkButton *javascript, gpointer user_data); static gboolean auto_load_imagesCb_toggled(GtkButton *auto_load_images, gpointer user_data); static void backCb_clicked(GtkButton *back, gpointer user_data); @@ -499,6 +500,20 @@ locationCb_activate(GtkEntry *location, gpointer user_data) return TRUE; } +static gboolean +searchCb_activate(GtkEntry *search, gpointer user_data) +{ + struct Client *browser = (struct Client *)user_data; + + char uri[1024]; + + snprintf(uri, 1024, BADWOLF_SEARCH_ENGINE_URI, gtk_entry_get_text(search)); + + webkit_web_view_load_uri(browser->webView, uri); + + return TRUE; +} + static gboolean javascriptCb_toggled(GtkButton *javascript, gpointer user_data) { @@ -655,6 +670,9 @@ new_browser(struct Window *window, const gchar *target_url, struct Client *old_b browser->location = gtk_entry_new(); gtk_widget_set_name(browser->location, "browser__location"); + browser->search_engine = gtk_entry_new(); + gtk_widget_set_name(browser->search_engine, "browser__search_engine"); + GtkWidget *print = gtk_button_new_from_icon_name("document-print-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_widget_set_name(browser->back, "browser__print"); @@ -733,6 +751,11 @@ new_browser(struct Window *window, const gchar *target_url, struct Client *old_b TRUE, TRUE, BADWOLF_TOOLBAR_PADDING); + gtk_box_pack_start(GTK_BOX(browser->toolbar), + GTK_WIDGET(browser->search_engine), + FALSE, + FALSE, + BADWOLF_TOOLBAR_PADDING); gtk_box_pack_start(GTK_BOX(browser->toolbar), print, FALSE, FALSE, BADWOLF_TOOLBAR_PADDING); gtk_container_set_focus_child(GTK_CONTAINER(browser->box), browser->toolbar); @@ -774,6 +797,9 @@ new_browser(struct Window *window, const gchar *target_url, struct Client *old_b gtk_entry_set_text(GTK_ENTRY(browser->location), target_url); gtk_entry_set_input_purpose(GTK_ENTRY(browser->location), GTK_INPUT_PURPOSE_URL); + gtk_entry_set_input_purpose(GTK_ENTRY(browser->search_engine), GTK_INPUT_PURPOSE_FREE_FORM); + gtk_entry_set_placeholder_text(GTK_ENTRY(browser->search_engine), _("Web search")); + gtk_entry_set_placeholder_text(GTK_ENTRY(browser->search), _("search in current page")); /* signals for back/forward buttons */ @@ -813,6 +839,9 @@ new_browser(struct Window *window, const gchar *target_url, struct Client *old_b /* signals for location entry widget */ g_signal_connect(browser->location, "activate", G_CALLBACK(locationCb_activate), browser); + /* signals for search entry widget */ + g_signal_connect(browser->search_engine, "activate", G_CALLBACK(searchCb_activate), browser); + /* signals for print button */ g_signal_connect(print, "clicked", G_CALLBACK(printCb_clicked), browser); /* prevents GtkNotebook from spawning it's context-menu */ diff --git a/badwolf.h b/badwolf.h index e5b33f09..016b9929 100644 --- a/badwolf.h +++ b/badwolf.h @@ -26,6 +26,7 @@ struct Client GtkWidget *javascript; GtkWidget *auto_load_images; GtkWidget *location; + GtkWidget *search_engine; uint64_t context_id; WebKitWebView *webView; diff --git a/config.h b/config.h index 6bd76df4..4e251fd9 100644 --- a/config.h +++ b/config.h @@ -107,4 +107,7 @@ // BADWOLF_LOCATION_INLINE_SELECTION: show selected completion as a selection in location entry #define BADWOLF_LOCATION_INLINE_SELECTION TRUE +// BADWOLF_SEARCH_ENGINE_URI: the search engine uri to query with the web search widget +#define BADWOLF_SEARCH_ENGINE_URI "https://html.duckduckgo.com/html?kd=-1&q=%s" + #endif /* CONFIG_H_INCLUDED */ diff --git a/po/messages.pot b/po/messages.pot index c5a821cd..ef4a8364 100644 --- a/po/messages.pot +++ b/po/messages.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: Badwolf 1.0.3+g1b10b339.develop\n" +"Project-Id-Version: Badwolf 1.0.3+g014062a7.search-entry\n" "Report-Msgid-Bugs-To: contact+badwolf-msgid@hacktivis.me\n" -"POT-Creation-Date: 2021-03-30 14:25+0200\n" +"POT-Creation-Date: 2021-03-30 14:46+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -74,23 +74,23 @@ msgstr "" msgid "Bookmarks: unable to parse file \"%s\"\n" msgstr "" -#: badwolf.c:954 +#: badwolf.c:983 #, c-format msgid "Buildtime WebKit version: %d.%d.%d\n" msgstr "" -#: badwolf.c:439 +#: badwolf.c:440 msgid "Continue" msgstr "" -#: badwolf.c:389 +#: badwolf.c:390 msgid "" "Couldn't verify the TLS certificate to ensure a better security of the " "connection. You might want to verify your machine and network.\n" "\n" msgstr "" -#: badwolf.c:99 +#: badwolf.c:100 msgid "Crashed" msgstr "" @@ -98,31 +98,31 @@ msgstr "" msgid "Download starting…" msgstr "" -#: badwolf.c:412 +#: badwolf.c:413 msgid "Error: Some unknown error occurred validating the certificate.\n" msgstr "" -#: badwolf.c:393 +#: badwolf.c:394 msgid "Error: The X509 Certificate Authority is unknown.\n" msgstr "" -#: badwolf.c:406 +#: badwolf.c:407 msgid "Error: The certificate has been revoked.\n" msgstr "" -#: badwolf.c:403 +#: badwolf.c:404 msgid "Error: The certificate has expired. Check your system's clock.\n" msgstr "" -#: badwolf.c:409 +#: badwolf.c:410 msgid "Error: The certificate is considered to be insecure.\n" msgstr "" -#: badwolf.c:400 +#: badwolf.c:401 msgid "Error: The certificate isn't valid yet. Check your system's clock.\n" msgstr "" -#: badwolf.c:396 +#: badwolf.c:397 msgid "Error: The given identity doesn't match the expected one.\n" msgstr "" @@ -133,79 +133,83 @@ msgid "" "Runtime WebKit version: %d.%d.%d" msgstr "" -#: badwolf.c:889 +#: badwolf.c:918 msgid "New tab" msgstr "" -#: badwolf.c:1006 +#: badwolf.c:1035 msgid "Open new tab" msgstr "" -#: badwolf.c:103 +#: badwolf.c:104 msgid "Out of Memory" msgstr "" -#: badwolf.c:952 +#: badwolf.c:981 #, c-format msgid "Running Badwolf version: %s\n" msgstr "" -#: badwolf.c:959 +#: badwolf.c:988 #, c-format msgid "Runtime WebKit version: %d.%d.%d\n" msgstr "" -#: badwolf.c:436 +#: badwolf.c:437 #, c-format msgid "TLS Error for %s." msgstr "" -#: badwolf.c:439 +#: badwolf.c:440 msgid "Temporarily Add Exception" msgstr "" -#: badwolf.c:647 +#: badwolf.c:662 msgid "Toggle javascript" msgstr "" -#: badwolf.c:652 +#: badwolf.c:667 msgid "Toggle loading images automatically" msgstr "" -#: badwolf.c:107 +#: badwolf.c:108 msgid "Unknown Crash" msgstr "" -#: badwolf.c:650 +#: badwolf.c:801 +msgid "Web search" +msgstr "" + +#: badwolf.c:665 msgid "_IMG" msgstr "" -#: badwolf.c:645 +#: badwolf.c:660 msgid "_JS" msgstr "" -#: badwolf.c:777 +#: badwolf.c:803 msgid "search in current page" msgstr "" -#: badwolf.c:98 +#: badwolf.c:99 msgid "the web process crashed.\n" msgstr "" -#: badwolf.c:102 +#: badwolf.c:103 msgid "the web process exceeded the memory limit.\n" msgstr "" -#: badwolf.c:106 +#: badwolf.c:107 msgid "the web process terminated for an unknown reason.\n" msgstr "" -#: badwolf.c:966 +#: badwolf.c:995 #, c-format msgid "webkit-web-extension directory set to: %s\n" msgstr "" #. TRANSLATOR Ignore this entry. Done for forcing Unicode in xgettext. -#: badwolf.c:1042 +#: badwolf.c:1071 msgid "ø" msgstr "" -- 2.26.3 From 791b32f7d5a405d6255614ffc0b8599c3c1785ad Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Tue, 30 Mar 2021 14:53:27 +0200 Subject: [PATCH 2/2] Update french translation --- po/fr.po | 64 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/po/fr.po b/po/fr.po index ba42e682..dc980f46 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: 2021-03-30 14:25+0200\n" +"POT-Creation-Date: 2021-03-30 14:46+0200\n" "PO-Revision-Date: 2021-03-30 14:52+0200\n" "Last-Translator: Haelwenn (lanodan) Monnier \n" "Language-Team: French\n" @@ -74,16 +74,16 @@ msgstr "Marques-Pages: Échec à l'évaluation de l'expression XPath « %s »\ msgid "Bookmarks: unable to parse file \"%s\"\n" msgstr "Marques-Pages: Ëchec au parsage du fichier « %s »\n" -#: badwolf.c:954 +#: badwolf.c:983 #, c-format msgid "Buildtime WebKit version: %d.%d.%d\n" msgstr "Version WebKit à la compilation: %d.%d.%d\n" -#: badwolf.c:439 +#: badwolf.c:440 msgid "Continue" msgstr "Continuer" -#: badwolf.c:389 +#: badwolf.c:390 msgid "" "Couldn't verify the TLS certificate to ensure a better security of the " "connection. You might want to verify your machine and network.\n" @@ -94,7 +94,7 @@ msgstr "" "et son réseau.\n" "\n" -#: badwolf.c:99 +#: badwolf.c:100 msgid "Crashed" msgstr "Crash" @@ -102,33 +102,33 @@ msgstr "Crash" msgid "Download starting…" msgstr "Démarrage du téléchargement" -#: badwolf.c:412 +#: badwolf.c:413 msgid "Error: Some unknown error occurred validating the certificate.\n" msgstr "" "Erreur : Une erreur inconnue est apparue pendant la validation du " "certificat.\n" -#: badwolf.c:393 +#: badwolf.c:394 msgid "Error: The X509 Certificate Authority is unknown.\n" msgstr "Erreur : L'autorité de certification (CA X509) est inconnue.\n" -#: badwolf.c:406 +#: badwolf.c:407 msgid "Error: The certificate has been revoked.\n" msgstr "Erreur : Le certificat à été révoqué.\n" -#: badwolf.c:403 +#: badwolf.c:404 msgid "Error: The certificate has expired. Check your system's clock.\n" msgstr "Erreur : Le certificat a expiré.\n" -#: badwolf.c:409 +#: badwolf.c:410 msgid "Error: The certificate is considered to be insecure.\n" msgstr "Erreur : Le certificat est considéré comme non-sécurisé.\n" -#: badwolf.c:400 +#: badwolf.c:401 msgid "Error: The certificate isn't valid yet. Check your system's clock.\n" msgstr "Erreur : Le certificat n'est pas encore valide.\n" -#: badwolf.c:396 +#: badwolf.c:397 msgid "Error: The given identity doesn't match the expected one.\n" msgstr "Erreur : L'identité ne correspond pas à celle attendue.\n" @@ -141,79 +141,83 @@ msgstr "" "Navigateur WebKitGTK+ minimaliste et orienté vie privée\n" "Version WebKit au lancement: %d.%d.%d" -#: badwolf.c:889 +#: badwolf.c:918 msgid "New tab" msgstr "Nouvel onglet" -#: badwolf.c:1006 +#: badwolf.c:1035 msgid "Open new tab" msgstr "Ouvrir un nouvel onglet" -#: badwolf.c:103 +#: badwolf.c:104 msgid "Out of Memory" msgstr "Dépassement Mémoire" -#: badwolf.c:952 +#: badwolf.c:981 #, c-format msgid "Running Badwolf version: %s\n" msgstr "Version de Badwolf: %s\n" -#: badwolf.c:959 +#: badwolf.c:988 #, c-format msgid "Runtime WebKit version: %d.%d.%d\n" msgstr "Version WebKit au lancement: %d.%d.%d\n" -#: badwolf.c:436 +#: badwolf.c:437 #, c-format msgid "TLS Error for %s." msgstr "Erreur TLS pour %s." -#: badwolf.c:439 +#: badwolf.c:440 msgid "Temporarily Add Exception" msgstr "Ajouter Temporairement une Exception" -#: badwolf.c:647 +#: badwolf.c:662 msgid "Toggle javascript" msgstr "(Dés)activer javascript" -#: badwolf.c:652 +#: badwolf.c:667 msgid "Toggle loading images automatically" msgstr "(Dés)activer le chargement automatique des images" -#: badwolf.c:107 +#: badwolf.c:108 msgid "Unknown Crash" msgstr "Crash inconnu" -#: badwolf.c:650 +#: badwolf.c:801 +msgid "Web search" +msgstr "Recherche web" + +#: badwolf.c:665 msgid "_IMG" msgstr "_IMG" -#: badwolf.c:645 +#: badwolf.c:660 msgid "_JS" msgstr "_JS" -#: badwolf.c:777 +#: badwolf.c:803 msgid "search in current page" msgstr "recherche dans la page courante" -#: badwolf.c:98 +#: badwolf.c:99 msgid "the web process crashed.\n" msgstr "le processus web a cessé de fonctionner.\n" -#: badwolf.c:102 +#: badwolf.c:103 msgid "the web process exceeded the memory limit.\n" msgstr "le processus web a dépassé la limitation de mémoire.\n" -#: badwolf.c:106 +#: badwolf.c:107 msgid "the web process terminated for an unknown reason.\n" msgstr "le processus web s’est interrompu pour une raison inconnue.\n" -#: badwolf.c:966 +#: badwolf.c:995 #, 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:1042 +#: badwolf.c:1071 msgid "ø" msgstr "" -- 2.26.3