From 1f82848e4aca29abd70dd8f248d922c5f9268e11 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Thu, 11 Apr 2019 01:21:49 +0200 Subject: Formatting: Break after the return type for definitions --- .clang-format | 1 + badwolf.c | 72 +++++++++++++++++++++++++++++++++++++---------------------- 2 files changed, 46 insertions(+), 27 deletions(-) diff --git a/.clang-format b/.clang-format index 0fc9f1a..c3077cb 100644 --- a/.clang-format +++ b/.clang-format @@ -5,6 +5,7 @@ AlignTrailingComments: true AllowShortCaseLabelsOnASingleLine: true AllowShortFunctionsOnASingleLine: true AllowShortIfStatementsOnASingleLine: true +AlwaysBreakAfterReturnType: AllDefinitions BinPackArguments: false BinPackParameters: false BreakBeforeBraces: Allman diff --git a/badwolf.c b/badwolf.c index 098f5c7..7a8a97f 100644 --- a/badwolf.c +++ b/badwolf.c @@ -66,7 +66,8 @@ GtkWidget *badwolf_new_tab_box(const gchar *title, struct Client *browser); gint get_tab_position(GtkContainer *notebook, GtkWidget *child); int main(int argc, char *argv[]); -static gboolean WebViewCb_close(WebKitWebView *webView, gpointer user_data) +static gboolean +WebViewCb_close(WebKitWebView *webView, gpointer user_data) { (void)webView; struct Client *browser = (struct Client *)user_data; @@ -81,8 +82,8 @@ static gboolean WebViewCb_close(WebKitWebView *webView, gpointer user_data) return TRUE; } -static gboolean WebViewCb_web_process_terminated(WebKitWebView *webView, - WebKitWebProcessTerminationReason reason) +static gboolean +WebViewCb_web_process_terminated(WebKitWebView *webView, WebKitWebProcessTerminationReason reason) { (void)webView; char *str_reason; @@ -101,7 +102,8 @@ static gboolean WebViewCb_web_process_terminated(WebKitWebView *webView, return FALSE; } -static gboolean WebViewCb_notify__uri(WebKitWebView *webView, GParamSpec *pspec, gpointer user_data) +static gboolean +WebViewCb_notify__uri(WebKitWebView *webView, GParamSpec *pspec, gpointer user_data) { (void)webView; (void)pspec; @@ -115,7 +117,8 @@ static gboolean WebViewCb_notify__uri(WebKitWebView *webView, GParamSpec *pspec, return TRUE; } -GtkWidget *badwolf_new_tab_box(const gchar *title, struct Client *browser) +GtkWidget * +badwolf_new_tab_box(const gchar *title, struct Client *browser) { (void)browser; GtkWidget *tab_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); @@ -169,7 +172,8 @@ WebViewCb_notify__is__playing__audio(WebKitWebView *webView, GParamSpec *pspec, return TRUE; } -void webView_tab_label_change(struct Client *browser) +void +webView_tab_label_change(struct Client *browser) { const gchar *title; GtkWidget *notebook = browser->window->notebook; @@ -188,9 +192,10 @@ void webView_tab_label_change(struct Client *browser) gtk_window_set_title(GTK_WINDOW(browser->window->main_window), title); } -static gboolean WebViewCb_notify__estimated_load_progress(WebKitWebView *webView, - GParamSpec *pspec, - gpointer user_data) +static gboolean +WebViewCb_notify__estimated_load_progress(WebKitWebView *webView, + GParamSpec *pspec, + gpointer user_data) { (void)webView; (void)pspec; @@ -207,10 +212,11 @@ static gboolean WebViewCb_notify__estimated_load_progress(WebKitWebView *webView return TRUE; } -static gboolean WebViewCb_mouse_target_changed(WebKitWebView *webView, - WebKitHitTestResult *hit, - guint modifiers, - gpointer user_data) +static gboolean +WebViewCb_mouse_target_changed(WebKitWebView *webView, + WebKitHitTestResult *hit, + guint modifiers, + gpointer user_data) { (void)webView; (void)modifiers; @@ -222,9 +228,10 @@ static gboolean WebViewCb_mouse_target_changed(WebKitWebView *webView, return TRUE; } -static WebKitWebView *WebViewCb_create(WebKitWebView *related_web_view, - WebKitNavigationAction *navigation_action, - gpointer user_data) +static WebKitWebView * +WebViewCb_create(WebKitWebView *related_web_view, + WebKitNavigationAction *navigation_action, + gpointer user_data) { (void)navigation_action; struct Window *window = (struct Window *)user_data; @@ -240,7 +247,8 @@ static WebKitWebView *WebViewCb_create(WebKitWebView *related_web_view, } } -static gboolean locationCb_activate(GtkEntry *location, gpointer user_data) +static gboolean +locationCb_activate(GtkEntry *location, gpointer user_data) { const char *target_url; struct Client *browser = (struct Client *)user_data; @@ -252,7 +260,8 @@ static gboolean locationCb_activate(GtkEntry *location, gpointer user_data) return TRUE; } -static gboolean javascriptCb_toggled(GtkButton *javascript, gpointer user_data) +static gboolean +javascriptCb_toggled(GtkButton *javascript, gpointer user_data) { struct Client *browser = (struct Client *)user_data; @@ -266,7 +275,8 @@ static gboolean javascriptCb_toggled(GtkButton *javascript, gpointer user_data) return TRUE; } -static gboolean SearchEntryCb_next__match(GtkSearchEntry *search, gpointer user_data) +static gboolean +SearchEntryCb_next__match(GtkSearchEntry *search, gpointer user_data) { (void)search; struct Client *browser = (struct Client *)user_data; @@ -277,7 +287,8 @@ static gboolean SearchEntryCb_next__match(GtkSearchEntry *search, gpointer user_ return TRUE; } -static gboolean SearchEntryCb_previous__match(GtkSearchEntry *search, gpointer user_data) +static gboolean +SearchEntryCb_previous__match(GtkSearchEntry *search, gpointer user_data) { (void)search; struct Client *browser = (struct Client *)user_data; @@ -288,7 +299,8 @@ static gboolean SearchEntryCb_previous__match(GtkSearchEntry *search, gpointer u return TRUE; } -static gboolean SearchEntryCb_search__changed(GtkSearchEntry *search, gpointer user_data) +static gboolean +SearchEntryCb_search__changed(GtkSearchEntry *search, gpointer user_data) { struct Client *browser = (struct Client *)user_data; WebKitFindController *findController = webkit_web_view_get_find_controller(browser->webView); @@ -299,7 +311,8 @@ static gboolean SearchEntryCb_search__changed(GtkSearchEntry *search, gpointer u return TRUE; } -static gboolean SearchEntryCb_stop__search(GtkSearchEntry *search, gpointer user_data) +static gboolean +SearchEntryCb_stop__search(GtkSearchEntry *search, gpointer user_data) { (void)search; struct Client *browser = (struct Client *)user_data; @@ -421,7 +434,8 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web return browser; } -int badwolf_new_tab(GtkNotebook *notebook, struct Client *browser) +int +badwolf_new_tab(GtkNotebook *notebook, struct Client *browser) { gint current_page = gtk_notebook_get_current_page(notebook); gchar *title = "New tab"; @@ -441,7 +455,8 @@ int badwolf_new_tab(GtkNotebook *notebook, struct Client *browser) return 0; } -void new_tabCb_clicked(GtkButton *new_tab, gpointer user_data) +void +new_tabCb_clicked(GtkButton *new_tab, gpointer user_data) { (void)new_tab; struct Window *window = (struct Window *)user_data; @@ -450,7 +465,8 @@ void new_tabCb_clicked(GtkButton *new_tab, gpointer user_data) badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser); } -void closeCb_clicked(GtkButton *close, gpointer user_data) +void +closeCb_clicked(GtkButton *close, gpointer user_data) { (void)close; struct Client *browser = (struct Client *)user_data; @@ -469,7 +485,8 @@ notebookCb_switch__page(GtkNotebook *notebook, GtkWidget *page, guint page_num, gtk_window_set_title(GTK_WINDOW(window->main_window), gtk_widget_get_tooltip_text(label)); } -gint get_tab_position(GtkContainer *notebook, GtkWidget *child) +gint +get_tab_position(GtkContainer *notebook, GtkWidget *child) { GValue position = G_VALUE_INIT; g_value_init(&position, G_TYPE_INT); @@ -479,7 +496,8 @@ gint get_tab_position(GtkContainer *notebook, GtkWidget *child) return g_value_get_int(&position); } -int main(int argc, char *argv[]) +int +main(int argc, char *argv[]) { struct Window *window = g_malloc(sizeof(struct Client)); gchar *target_url = NULL; -- cgit v1.3.1-23-gd82d From a59a8246ef335ece888c8f5183133fb428c6933a Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Thu, 11 Apr 2019 01:48:15 +0200 Subject: badwolf.c: Fix function statements --- badwolf.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/badwolf.c b/badwolf.c index 7a8a97f..40257ef 100644 --- a/badwolf.c +++ b/badwolf.c @@ -36,6 +36,7 @@ static gboolean WebViewCb_web_process_terminated(WebKitWebView *webView, WebKitWebProcessTerminationReason reason); static gboolean WebViewCb_notify__uri(WebKitWebView *webView, GParamSpec *pspec, gpointer user_data); +GtkWidget *badwolf_new_tab_box(const gchar *title, struct Client *browser); static gboolean WebViewCb_notify__title(WebKitWebView *webView, GParamSpec *pspec, gpointer user_data); static gboolean @@ -48,7 +49,7 @@ static gboolean WebViewCb_mouse_target_changed(WebKitWebView *webView, WebKitHitTestResult *hit, guint modifiers, gpointer user_data); -static WebKitWebView *WebViewCb_create(WebKitWebView *webView, +static WebKitWebView *WebViewCb_create(WebKitWebView *related_web_view, WebKitNavigationAction *navigation_action, gpointer user_data); static gboolean locationCb_activate(GtkEntry *location, gpointer user_data); @@ -59,12 +60,12 @@ static gboolean SearchEntryCb_search__changed(GtkSearchEntry *search, gpointer u static gboolean SearchEntryCb_stop__search(GtkSearchEntry *search, gpointer user_data); struct Client * new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web_view); -void new_tabCb_clicked(GtkButton *new_tab, gpointer user_data); -void closeCb_clicked(GtkButton *close, gpointer user_data); int badwolf_new_tab(GtkNotebook *notebook, struct Client *browser); -GtkWidget *badwolf_new_tab_box(const gchar *title, struct Client *browser); +static void new_tabCb_clicked(GtkButton *new_tab, gpointer user_data); +static void closeCb_clicked(GtkButton *close, gpointer user_data); +static void +notebookCb_switch__page(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer user_data); gint get_tab_position(GtkContainer *notebook, GtkWidget *child); -int main(int argc, char *argv[]); static gboolean WebViewCb_close(WebKitWebView *webView, gpointer user_data) @@ -455,7 +456,7 @@ badwolf_new_tab(GtkNotebook *notebook, struct Client *browser) return 0; } -void +static void new_tabCb_clicked(GtkButton *new_tab, gpointer user_data) { (void)new_tab; @@ -465,7 +466,7 @@ new_tabCb_clicked(GtkButton *new_tab, gpointer user_data) badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser); } -void +static void closeCb_clicked(GtkButton *close, gpointer user_data) { (void)close; -- cgit v1.3.1-23-gd82d From 07ed78f42a78934e213b367cf82ba55cd331637e Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 13 Apr 2019 17:32:55 +0200 Subject: Makefile: Add BINDIR preference --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b631eee..92605f8 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ .POSIX: PREFIX = /usr/local +BINDIR = $(PREFIX)/bin DEPS = gtk+-3.0 webkit2gtk-4.0 OBJS = badwolf @@ -16,8 +17,8 @@ all: $(OBJS) $(CC) -std=c11 $(CFLAGS) $(CDEPS) -o $@ $< $(LDFLAGS) $(LIBS) install: badwolf - mkdir -p $(DESTDIR)$(PREFIX)/bin - cp -p badwolf $(DESTDIR)$(PREFIX)/bin/badwolf + mkdir -p $(DESTDIR)$(BINDIR) + cp -p badwolf $(DESTDIR)$(BINDIR)/badwolf clean: rm $(OBJS) -- cgit v1.3.1-23-gd82d From 7dc84b19ba98cc3f44c5fed97a4913af51546230 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 13 Apr 2019 17:33:51 +0200 Subject: Makefile: Add badwolf.1 to install --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 92605f8..fb4ed31 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ PREFIX = /usr/local BINDIR = $(PREFIX)/bin +MANDIR = $(PREFIX)/share/man DEPS = gtk+-3.0 webkit2gtk-4.0 OBJS = badwolf @@ -19,6 +20,8 @@ all: $(OBJS) install: badwolf mkdir -p $(DESTDIR)$(BINDIR) cp -p badwolf $(DESTDIR)$(BINDIR)/badwolf + mkdir -p $(DESTDIR)$(MANDIR)/man1 + cp -p badwolf.1 $(DESTDIR)$(MANDIR)/man1 clean: rm $(OBJS) -- cgit v1.3.1-23-gd82d From 0728f8a127f4dc14e438b9912feefc2799aa8ba2 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 13 Apr 2019 20:28:51 +0200 Subject: webView_tab_label_change: Add title argument (nullable) --- badwolf.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/badwolf.c b/badwolf.c index 40257ef..7c24ae0 100644 --- a/badwolf.c +++ b/badwolf.c @@ -41,7 +41,7 @@ static gboolean WebViewCb_notify__title(WebKitWebView *webView, GParamSpec *pspec, gpointer user_data); static gboolean WebViewCb_notify__is__playing__audio(WebKitWebView *webView, GParamSpec *pspec, gpointer user_data); -void webView_tab_label_change(struct Client *browser); +void webView_tab_label_change(struct Client *browser, const gchar *title); static gboolean WebViewCb_notify__estimated_load_progress(WebKitWebView *webView, GParamSpec *pspec, gpointer user_data); @@ -156,7 +156,7 @@ WebViewCb_notify__title(WebKitWebView *webView, GParamSpec *pspec, gpointer user (void)pspec; struct Client *browser = (struct Client *)user_data; - webView_tab_label_change(browser); + webView_tab_label_change(browser, NULL); return TRUE; } @@ -168,22 +168,21 @@ WebViewCb_notify__is__playing__audio(WebKitWebView *webView, GParamSpec *pspec, (void)pspec; struct Client *browser = (struct Client *)user_data; - webView_tab_label_change(browser); + webView_tab_label_change(browser, NULL); return TRUE; } void -webView_tab_label_change(struct Client *browser) +webView_tab_label_change(struct Client *browser, const gchar *title) { - const gchar *title; GtkWidget *notebook = browser->window->notebook; - title = webkit_web_view_get_title(browser->webView); + if(title == NULL || title == "") title = webkit_web_view_get_title(browser->webView); - if(title == NULL) title = webkit_web_view_get_uri(browser->webView); + if(title == NULL || title == "") title = webkit_web_view_get_uri(browser->webView); - if(title == NULL) title = "BadWolf"; + if(title == NULL || title == "") title = "BadWolf"; gtk_notebook_set_tab_label( GTK_NOTEBOOK(notebook), browser->box, badwolf_new_tab_box(title, browser)); @@ -405,7 +404,7 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web g_signal_connect(browser->webView, "web-process-terminated", G_CALLBACK(WebViewCb_web_process_terminated), - NULL); + browser); g_signal_connect(browser->webView, "notify::uri", G_CALLBACK(WebViewCb_notify__uri), browser); g_signal_connect(browser->webView, "notify::title", G_CALLBACK(WebViewCb_notify__title), browser); g_signal_connect(browser->webView, -- cgit v1.3.1-23-gd82d From c14d50f1da273620944f2f60a3af43d3d9f35c57 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 13 Apr 2019 20:29:34 +0200 Subject: WebViewCb_web_process_terminated: Change tab’s title with the reason MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- badwolf.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/badwolf.c b/badwolf.c index 7c24ae0..502dfce 100644 --- a/badwolf.c +++ b/badwolf.c @@ -87,19 +87,18 @@ static gboolean WebViewCb_web_process_terminated(WebKitWebView *webView, WebKitWebProcessTerminationReason reason) { (void)webView; - char *str_reason; switch(reason) { - case WEBKIT_WEB_PROCESS_CRASHED: str_reason = "the web process crashed."; break; + case WEBKIT_WEB_PROCESS_CRASHED: g_fprintf(stderr, "the web process crashed."; webView_tab_label_change(browser, "Crashed"); break; case WEBKIT_WEB_PROCESS_EXCEEDED_MEMORY_LIMIT: - str_reason = "the web process exceeded the memory limit."; + g_fprintf(stderr, "the web process exceeded the memory limit."; + webView_tab_label_change(browser, "Out of Memory"); break; - default: str_reason = "the web process terminated for an unknown reason."; + default: g_fprintf(stderr, "the web process terminated for an unknown reason."); + webView_tab_label_change(browser, "Unknown Crash"); } - g_fprintf(stderr, "BadWolf [signal: web-process-terminated]: %s\n", str_reason); - return FALSE; } -- cgit v1.3.1-23-gd82d From e2b66bcb48a0170481966d23d371f2e4cbc3423f Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 13 Apr 2019 21:06:13 +0200 Subject: hotfix WebViewCb_web_process_terminated changes --- badwolf.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/badwolf.c b/badwolf.c index 502dfce..e4ce45e 100644 --- a/badwolf.c +++ b/badwolf.c @@ -33,7 +33,8 @@ struct Client static gboolean WebViewCb_close(WebKitWebView *webView, gpointer user_data); static gboolean WebViewCb_web_process_terminated(WebKitWebView *webView, - WebKitWebProcessTerminationReason reason); + WebKitWebProcessTerminationReason reason, + gpointer user_data); static gboolean WebViewCb_notify__uri(WebKitWebView *webView, GParamSpec *pspec, gpointer user_data); GtkWidget *badwolf_new_tab_box(const gchar *title, struct Client *browser); @@ -84,15 +85,16 @@ WebViewCb_close(WebKitWebView *webView, gpointer user_data) } static gboolean -WebViewCb_web_process_terminated(WebKitWebView *webView, WebKitWebProcessTerminationReason reason) +WebViewCb_web_process_terminated(WebKitWebView *webView, WebKitWebProcessTerminationReason reason, gpointer user_data) { (void)webView; + struct Client *browser = (struct Client *)user_data; switch(reason) { - case WEBKIT_WEB_PROCESS_CRASHED: g_fprintf(stderr, "the web process crashed."; webView_tab_label_change(browser, "Crashed"); break; + case WEBKIT_WEB_PROCESS_CRASHED: g_fprintf(stderr, "the web process crashed."); webView_tab_label_change(browser, "Crashed"); break; case WEBKIT_WEB_PROCESS_EXCEEDED_MEMORY_LIMIT: - g_fprintf(stderr, "the web process exceeded the memory limit."; + g_fprintf(stderr, "the web process exceeded the memory limit."); webView_tab_label_change(browser, "Out of Memory"); break; default: g_fprintf(stderr, "the web process terminated for an unknown reason."); @@ -177,11 +179,11 @@ webView_tab_label_change(struct Client *browser, const gchar *title) { GtkWidget *notebook = browser->window->notebook; - if(title == NULL || title == "") title = webkit_web_view_get_title(browser->webView); - - if(title == NULL || title == "") title = webkit_web_view_get_uri(browser->webView); +#define title_IS_EMPTY (title == NULL) || (title == "") - if(title == NULL || title == "") title = "BadWolf"; + if(title_IS_EMPTY) title = webkit_web_view_get_title(browser->webView); + if(title_IS_EMPTY) title = webkit_web_view_get_uri(browser->webView); + if(title_IS_EMPTY) title = "BadWolf"; gtk_notebook_set_tab_label( GTK_NOTEBOOK(notebook), browser->box, badwolf_new_tab_box(title, browser)); -- cgit v1.3.1-23-gd82d From 617e6b2a2e7e7c0668e3374f99542ccb506a3099 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sat, 13 Apr 2019 21:07:24 +0200 Subject: make format --- badwolf.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/badwolf.c b/badwolf.c index e4ce45e..612397c 100644 --- a/badwolf.c +++ b/badwolf.c @@ -85,19 +85,25 @@ WebViewCb_close(WebKitWebView *webView, gpointer user_data) } static gboolean -WebViewCb_web_process_terminated(WebKitWebView *webView, WebKitWebProcessTerminationReason reason, gpointer user_data) +WebViewCb_web_process_terminated(WebKitWebView *webView, + WebKitWebProcessTerminationReason reason, + gpointer user_data) { (void)webView; struct Client *browser = (struct Client *)user_data; switch(reason) { - case WEBKIT_WEB_PROCESS_CRASHED: g_fprintf(stderr, "the web process crashed."); webView_tab_label_change(browser, "Crashed"); break; + case WEBKIT_WEB_PROCESS_CRASHED: + g_fprintf(stderr, "the web process crashed."); + webView_tab_label_change(browser, "Crashed"); + break; case WEBKIT_WEB_PROCESS_EXCEEDED_MEMORY_LIMIT: g_fprintf(stderr, "the web process exceeded the memory limit."); webView_tab_label_change(browser, "Out of Memory"); break; - default: g_fprintf(stderr, "the web process terminated for an unknown reason."); + default: + g_fprintf(stderr, "the web process terminated for an unknown reason."); webView_tab_label_change(browser, "Unknown Crash"); } -- cgit v1.3.1-23-gd82d From fd6724c522448a6ee0b8a3a30f869fc141903bcf Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sun, 14 Apr 2019 06:20:59 +0200 Subject: badwolf.c: Fix gcc warning on string comparison (gchar vs. char) --- badwolf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/badwolf.c b/badwolf.c index 612397c..fce2f2e 100644 --- a/badwolf.c +++ b/badwolf.c @@ -185,7 +185,7 @@ webView_tab_label_change(struct Client *browser, const gchar *title) { GtkWidget *notebook = browser->window->notebook; -#define title_IS_EMPTY (title == NULL) || (title == "") +#define title_IS_EMPTY (title == NULL) || (title == (const gchar *)"") if(title_IS_EMPTY) title = webkit_web_view_get_title(browser->webView); if(title_IS_EMPTY) title = webkit_web_view_get_uri(browser->webView); -- cgit v1.3.1-23-gd82d From 2f2c09c5962b2aeadd115fa2f0330c56002d2a61 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sun, 14 Apr 2019 06:40:57 +0200 Subject: Expand the tabs to fill the whole space --- badwolf.c | 4 +++- config.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/badwolf.c b/badwolf.c index fce2f2e..9a5ff83 100644 --- a/badwolf.c +++ b/badwolf.c @@ -137,12 +137,14 @@ badwolf_new_tab_box(const gchar *title, struct Client *browser) gtk_image_new_from_icon_name("audio-volume-high-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_label_set_width_chars(GTK_LABEL(label), BADWOLF_TAB_LABEL_CHARWIDTH); + 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), playing, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(tab_box), label, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(tab_box), close, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(tab_box), close, FALSE, FALSE, 0); gtk_button_set_relief(GTK_BUTTON(close), GTK_RELIEF_NONE); diff --git a/config.h b/config.h index e41472f..3ba085a 100644 --- a/config.h +++ b/config.h @@ -11,6 +11,9 @@ // BADWOLF_TAB_LABEL_CHARWIDTH: Amount of characters the tab label text fits #define BADWOLF_TAB_LABEL_CHARWIDTH 26 +// BADWOLF_TAB_HEXPAND: Should the tab try to fill the available horizontal space? +#define BADWOLF_TAB_HEXPAND TRUE + /* BADWOLF_TAB_LABEL_ELLIPSIZE: pango ellipsize mode of the tab label text, can be one of: * - PANGO_ELLIPSIZE_NONE * - PANGO_ELLIPSIZE_START -- cgit v1.3.1-23-gd82d From f2f9b3cf2c130c0f165cdb6a604bc2be24c45eae Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sun, 14 Apr 2019 06:42:14 +0200 Subject: Allow to set the tab min-width in pixels --- badwolf.c | 5 +++++ config.h | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/badwolf.c b/badwolf.c index 9a5ff83..668e0eb 100644 --- a/badwolf.c +++ b/badwolf.c @@ -136,7 +136,12 @@ badwolf_new_tab_box(const gchar *title, struct Client *browser) GtkWidget *playing = gtk_image_new_from_icon_name("audio-volume-high-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR); +#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); diff --git a/config.h b/config.h index 3ba085a..3011648 100644 --- a/config.h +++ b/config.h @@ -8,9 +8,16 @@ */ #define BADWOLF_TAB_POSITION GTK_POS_TOP -// BADWOLF_TAB_LABEL_CHARWIDTH: Amount of characters the tab label text fits +/* BADWOLF_TAB_LABEL_CHARWIDTH: Amount of characters the tab label text fits + * Quite conflicts with BADWOLF_TAB_BOX_WIDTH, recommended to only define one + */ #define BADWOLF_TAB_LABEL_CHARWIDTH 26 +/* BADWOLF_TAB_BOX_WIDTH: Requested width (in pixels) for the whole tab + * Quite conflicts with BADWOLF_TAB_LABEL_CHARWIDTH, recommended to only define one + */ +//#define BADWOLF_TAB_BOX_WIDTH 120 + // BADWOLF_TAB_HEXPAND: Should the tab try to fill the available horizontal space? #define BADWOLF_TAB_HEXPAND TRUE -- cgit v1.3.1-23-gd82d From 8c0525b56e6ad402eeff18af58eb1ce4d9e8be47 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Thu, 18 Apr 2019 12:37:29 +0200 Subject: config.h: Keep tab expansion off by default --- config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.h b/config.h index 3011648..07ff0f8 100644 --- a/config.h +++ b/config.h @@ -19,7 +19,7 @@ //#define BADWOLF_TAB_BOX_WIDTH 120 // BADWOLF_TAB_HEXPAND: Should the tab try to fill the available horizontal space? -#define BADWOLF_TAB_HEXPAND TRUE +#define BADWOLF_TAB_HEXPAND FALSE /* BADWOLF_TAB_LABEL_ELLIPSIZE: pango ellipsize mode of the tab label text, can be one of: * - PANGO_ELLIPSIZE_NONE -- cgit v1.3.1-23-gd82d From fef0bed45c212140f371e55839516458c7e2f5e0 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Sun, 14 Apr 2019 06:18:52 +0200 Subject: badwolf.c: Add newlines to WebViewCb_web_process_terminated --- badwolf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/badwolf.c b/badwolf.c index 668e0eb..4ab9ae9 100644 --- a/badwolf.c +++ b/badwolf.c @@ -95,15 +95,15 @@ WebViewCb_web_process_terminated(WebKitWebView *webView, switch(reason) { case WEBKIT_WEB_PROCESS_CRASHED: - g_fprintf(stderr, "the web process crashed."); + g_fprintf(stderr, "the web process crashed.\n"); webView_tab_label_change(browser, "Crashed"); break; case WEBKIT_WEB_PROCESS_EXCEEDED_MEMORY_LIMIT: - g_fprintf(stderr, "the web process exceeded the memory limit."); + g_fprintf(stderr, "the web process exceeded the memory limit.\n"); webView_tab_label_change(browser, "Out of Memory"); break; default: - g_fprintf(stderr, "the web process terminated for an unknown reason."); + g_fprintf(stderr, "the web process terminated for an unknown reason.\n"); webView_tab_label_change(browser, "Unknown Crash"); } -- cgit v1.3.1-23-gd82d From 5d8d10d0849e4d42d23bb92e5bc3c8ec194f4983 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Thu, 11 Apr 2019 08:46:42 +0200 Subject: badwolf.c: Add gettext --- badwolf.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/badwolf.c b/badwolf.c index 4ab9ae9..475cc28 100644 --- a/badwolf.c +++ b/badwolf.c @@ -4,8 +4,10 @@ #include "config.h" +#include /* _() and other internationalization/localization helpers */ #include /* g_fprintf() */ #include +#include /* LC_* */ #include struct Window @@ -95,16 +97,16 @@ WebViewCb_web_process_terminated(WebKitWebView *webView, switch(reason) { case WEBKIT_WEB_PROCESS_CRASHED: - g_fprintf(stderr, "the web process crashed.\n"); - webView_tab_label_change(browser, "Crashed"); + g_fprintf(stderr, _("the web process crashed.\n")); + webView_tab_label_change(browser, _("title|Crashed")); break; case WEBKIT_WEB_PROCESS_EXCEEDED_MEMORY_LIMIT: - g_fprintf(stderr, "the web process exceeded the memory limit.\n"); - webView_tab_label_change(browser, "Out of Memory"); + g_fprintf(stderr, _("the web process exceeded the memory limit.\n")); + webView_tab_label_change(browser, _("title|Out of Memory")); break; default: - g_fprintf(stderr, "the web process terminated for an unknown reason.\n"); - webView_tab_label_change(browser, "Unknown Crash"); + g_fprintf(stderr, _("the web process terminated for an unknown reason.\n")); + webView_tab_label_change(browser, _("title|Unknown Crash")); } return FALSE; @@ -368,7 +370,7 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web settings, NULL)); - gtk_widget_set_tooltip_text(browser->javascript, "Toggle javascript"); + gtk_widget_set_tooltip_text(browser->javascript, _("Toggle javascript")); gtk_box_pack_start(GTK_BOX(browser->toolbar), GTK_WIDGET(browser->javascript), @@ -408,7 +410,7 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web gtk_entry_set_has_frame(GTK_ENTRY(browser->location), FALSE); gtk_entry_set_input_purpose(GTK_ENTRY(browser->location), GTK_INPUT_PURPOSE_URL); - gtk_entry_set_placeholder_text(GTK_ENTRY(browser->search), "search in current page"); + gtk_entry_set_placeholder_text(GTK_ENTRY(browser->search), _("search in current page")); gtk_entry_set_has_frame(GTK_ENTRY(browser->search), FALSE); g_signal_connect(browser->location, "activate", G_CALLBACK(locationCb_activate), browser); @@ -452,7 +454,7 @@ int badwolf_new_tab(GtkNotebook *notebook, struct Client *browser) { gint current_page = gtk_notebook_get_current_page(notebook); - gchar *title = "New tab"; + gchar *title = _("New tab"); gtk_widget_show_all(browser->box); @@ -516,13 +518,18 @@ main(int argc, char *argv[]) struct Window *window = g_malloc(sizeof(struct Client)); gchar *target_url = NULL; + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, DATADIR "/locale"); + bind_textdomain_codeset(PACKAGE, "UTF-8"); + textdomain(PACKAGE); + g_fprintf(stderr, - "Buildtime WebKit version: %d.%d.%d\n", + _("Buildtime WebKit version: %d.%d.%d\n"), WEBKIT_MAJOR_VERSION, WEBKIT_MINOR_VERSION, WEBKIT_MICRO_VERSION); g_fprintf(stderr, - "Runtime WebKit version: %d.%d.%d\n", + _("Runtime WebKit version: %d.%d.%d\n"), webkit_get_major_version(), webkit_get_minor_version(), webkit_get_micro_version()); @@ -539,7 +546,7 @@ main(int argc, char *argv[]) GTK_WINDOW(window->main_window), BADWOLF_DEFAULT_WIDTH, BADWOLF_DEFAULT_HEIGHT); gtk_window_set_role(GTK_WINDOW(window->main_window), "browser"); - gtk_widget_set_tooltip_text(window->new_tab, "Open new tab"); + gtk_widget_set_tooltip_text(window->new_tab, _("Open new tab")); gtk_notebook_set_action_widget(GTK_NOTEBOOK(window->notebook), window->new_tab, GTK_PACK_END); gtk_notebook_set_scrollable(GTK_NOTEBOOK(window->notebook), TRUE); -- cgit v1.3.1-23-gd82d From 98ce7fb52862813833a8e3ad8db1d6a3b70ba375 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Thu, 11 Apr 2019 09:17:47 +0200 Subject: po/messages.pot: init xgettext --keyword=_ --language=C -o po/messages.pot --add-comments --sort-output badwolf.c --- po/messages.pot | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 po/messages.pot diff --git a/po/messages.pot b/po/messages.pot new file mode 100644 index 0000000..ca6c9dc --- /dev/null +++ b/po/messages.pot @@ -0,0 +1,66 @@ +# BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser +# Copyright (C) 2019 Haelwenn (lanodan) Monnier +# This file is distributed under the same license as the Badwolf package. +# Haelwenn (lanodan) Monnier , 2019 +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Badwolf 0.1.0\n" +"POT-Creation-Date: 2019-04-18 13:16+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: \"Haelwenn (lanodan) Monnier \"\n" +"Language: en\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: badwolf.c:527 +#, c-format +msgid "Buildtime WebKit version: %d.%d.%d\n" +msgstr "" + +#: badwolf.c:457 +msgid "New tab" +msgstr "" + +#: badwolf.c:549 +msgid "Open new tab" +msgstr "" + +#: badwolf.c:532 +#, c-format +msgid "Runtime WebKit version: %d.%d.%d\n" +msgstr "" + +#: badwolf.c:373 +msgid "Toggle javascript" +msgstr "" + +#: badwolf.c:413 +msgid "search in current page" +msgstr "" + +#: badwolf.c:100 +msgid "the web process crashed.\n" +msgstr "" + +#: badwolf.c:104 +msgid "the web process exceeded the memory limit.\n" +msgstr "" + +#: badwolf.c:108 +msgid "the web process terminated for an unknown reason.\n" +msgstr "" + +#: badwolf.c:101 +msgid "title|Crashed" +msgstr "" + +#: badwolf.c:105 +msgid "title|Out of Memory" +msgstr "" + +#: badwolf.c:109 +msgid "title|Unknown Crash" +msgstr "" -- cgit v1.3.1-23-gd82d From 8d8f8aad8ec4cbfd4f6119452fde2aa5c37f8242 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Thu, 11 Apr 2019 09:39:28 +0200 Subject: po/fr.po: New translation --- po/fr.po | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 po/fr.po diff --git a/po/fr.po b/po/fr.po new file mode 100644 index 0000000..bfc9aac --- /dev/null +++ b/po/fr.po @@ -0,0 +1,70 @@ +# BadWolf: Minimalist and privacy-oriented WebKitGTK+ browser +# Copyright (C) 2019 Haelwenn (lanodan) Monnier +# This file is distributed under the same license as the Badwolf package. +# Haelwenn (lanodan) Monnier , 2019 +# +msgid "" +msgstr "" +"Project-Id-Version: Badwolf 0.1.0\n" +"POT-Creation-Date: 2019-04-18 13:16+0200\n" +"PO-Revision-Date: 2019-04-11 09:28+0200\n" +"Last-Translator: \n" +"Language-Team: French\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: badwolf.c:527 +#, c-format +msgid "Buildtime WebKit version: %d.%d.%d\n" +msgstr "Version WebKit à la compilation: %d.%d.%d\n" + +#: badwolf.c:457 +msgid "New tab" +msgstr "Nouvel onglet" + +#: badwolf.c:549 +msgid "Open new tab" +msgstr "Ouvrir un nouvel onglet" + +#: badwolf.c:532 +#, c-format +msgid "Runtime WebKit version: %d.%d.%d\n" +msgstr "Version WebKit au lancement: %d.%d.%d\n" + +#: badwolf.c:373 +msgid "Toggle javascript" +msgstr "Activer/Désactiver javascript" + +#: badwolf.c:413 +msgid "search in current page" +msgstr "recherche dans la page courante" + +#: badwolf.c:100 +#, fuzzy +msgid "the web process crashed.\n" +msgstr "le processus web à cessé de fonctionner.\n" + +#: badwolf.c:104 +#, fuzzy +msgid "the web process exceeded the memory limit.\n" +msgstr "le processus web à dépassé la limitation de mémoire.\n" + +#: badwolf.c:108 +#, fuzzy +msgid "the web process terminated for an unknown reason.\n" +msgstr "le processus web s’est interrompu pour une raison inconnue.\n" + +#: badwolf.c:101 +msgid "title|Crashed" +msgstr "title|Crash" + +#: badwolf.c:105 +msgid "title|Out of Memory" +msgstr "title|Dépassement Mémoire" + +#: badwolf.c:109 +msgid "title|Unknown Crash" +msgstr "title|Crash inconnu" -- cgit v1.3.1-23-gd82d From 6dae2b34423f5c00971cc243c97697644c2da143 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 12 Apr 2019 02:12:30 +0200 Subject: Makefile: Add building *.mo on compilation --- Makefile | 33 +++++++++++++++++++++------------ mo/.keep | 0 2 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 mo/.keep diff --git a/Makefile b/Makefile index fb4ed31..6b2d20f 100644 --- a/Makefile +++ b/Makefile @@ -1,30 +1,39 @@ .POSIX: -PREFIX = /usr/local -BINDIR = $(PREFIX)/bin -MANDIR = $(PREFIX)/share/man +PREFIX = /usr/local +BINDIR = $(PREFIX)/bin +MANDIR = $(PREFIX)/share/man +DATADIR = $(PREFIX)/share/badwolf +PACKAGE = Badwolf -DEPS = gtk+-3.0 webkit2gtk-4.0 -OBJS = badwolf +DEPS = gtk+-3.0 webkit2gtk-4.0 +OBJS = badwolf +TRANS = fr.mo -CC = cc -CFLAGS = -g -Wall -Wextra -CDEPS = `pkg-config --cflags $(DEPS)` -LIBS = `pkg-config --libs $(DEPS)` +CC = cc +CFLAGS = -g -Wall -Wextra +CDEPS = `pkg-config --cflags $(DEPS)` -DDATADIR=\"$(DATADIR)\" -DPACKAGE=\"$(PACKAGE)\" +LIBS = `pkg-config --libs $(DEPS)` -all: $(OBJS) +all: $(OBJS) $(TRANS) + +%.mo: + mkdir -p locale/$*/LC_MESSAGES + msgfmt -o locale/$*/LC_MESSAGES/$(PACKAGE).mo po/$*.po .c: $(CC) -std=c11 $(CFLAGS) $(CDEPS) -o $@ $< $(LDFLAGS) $(LIBS) -install: badwolf +install: all mkdir -p $(DESTDIR)$(BINDIR) cp -p badwolf $(DESTDIR)$(BINDIR)/badwolf mkdir -p $(DESTDIR)$(MANDIR)/man1 cp -p badwolf.1 $(DESTDIR)$(MANDIR)/man1 + mkdir -p $(DESTDIR)$(DATADIR)/locale + cp -r locale/ $(DESTDIR)$(DATADIR) clean: - rm $(OBJS) + rm -fr locale $(OBJS) format: *.c *.h clang-format -style=file -assume-filename=.clang-format -i *.c *.h diff --git a/mo/.keep b/mo/.keep new file mode 100644 index 0000000..e69de29 -- cgit v1.3.1-23-gd82d From 0d4fcf141a67221748881ad0a4be26ad4227a235 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 26 Apr 2019 14:32:45 +0200 Subject: Makefile: Add po/ targets --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 6b2d20f..2635716 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,12 @@ all: $(OBJS) $(TRANS) mkdir -p locale/$*/LC_MESSAGES msgfmt -o locale/$*/LC_MESSAGES/$(PACKAGE).mo po/$*.po +po/messages.pot: + xgettext --keyword=_ --language=C -o $@ --add-comments --sort-output -j badwolf.c + +po/%.po: po/messages.pot + msgmerge --update $@ $< + .c: $(CC) -std=c11 $(CFLAGS) $(CDEPS) -o $@ $< $(LDFLAGS) $(LIBS) -- cgit v1.3.1-23-gd82d