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 --- badwolf.c | 72 +++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 27 deletions(-) (limited to 'badwolf.c') 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(-) (limited to 'badwolf.c') 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 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(-) (limited to 'badwolf.c') 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(-) (limited to 'badwolf.c') 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(-) (limited to 'badwolf.c') 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(-) (limited to 'badwolf.c') 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(-) (limited to 'badwolf.c') 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(-) (limited to 'badwolf.c') 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(-) (limited to 'badwolf.c') 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 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(-) (limited to 'badwolf.c') 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(-) (limited to 'badwolf.c') 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