Summary Files Commits Branches @commit @diff @stats
path: root / badwolf.c
diff options
context:
space:
mode:
Commitacde5dfc614ee549b5c1f0119c7e3c8c777c4a82 (patch)
Author
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2020-07-08 07:42:06 +0200
Committer
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2020-07-08 07:42:06 +0200
Files7a84d999ef7e84a8dc40293f7affb068ba01a2b6 /badwolf.c
goodwolf-1.0.1.tar
goodwolf-1.0.1.tar.gz
goodwolf-1.0.1.zip
Parenta49df8ad9869a47a10138738b38fd0ffdb95e402 (diff)
Parentdf18b8d0a3a0634e18b518e9cfc21fd8f4ea7908 (diff)
Merge branch 'release-1.0' into missy for 1.0.1 v1.0.1
Fixes ------- - Support for relative paths as command line arguments - Downloads tab: no longer resizes the main window - Manpage: Syntax is now correct, unbreaking GNU groff formatting. Changes ------- - When an user requests as new tab (ctrl-t, new tab button), switch to it - Downloads tab: A scrollable list view is used instead of a stack of labels
1 files changed, 14 insertions, 20 deletions
-rw-r--r--badwolf.c34
diff --git a/badwolf.c b/badwolf.c
index 54dcf53..184c4a3 100644
--- a/badwolf.c
+++ b/badwolf.c
@@ -74,8 +74,7 @@ WebViewCb_close(WebKitWebView *webView, gpointer user_data)
struct Client *browser = (struct Client *)user_data;
GtkNotebook *notebook = GTK_NOTEBOOK(browser->window->notebook);
- gtk_notebook_remove_page(notebook,
- badwolf_get_tab_position(GTK_CONTAINER(notebook), browser->box));
+ gtk_notebook_remove_page(notebook, gtk_notebook_page_num(GTK_NOTEBOOK(notebook), browser->box));
gtk_widget_destroy(browser->box);
@@ -212,7 +211,7 @@ webView_tab_label_change(struct Client *browser, const gchar *title)
gtk_notebook_set_menu_label_text(GTK_NOTEBOOK(notebook), browser->box, title);
// Set the window title if the title change was on the current tab
- if(badwolf_get_tab_position(GTK_CONTAINER(notebook), browser->box) ==
+ if(gtk_notebook_page_num(GTK_NOTEBOOK(notebook), browser->box) ==
gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)))
gtk_window_set_title(GTK_WINDOW(browser->window->main_window), title);
}
@@ -287,7 +286,7 @@ WebViewCb_create(WebKitWebView *related_web_view,
struct Window *window = (struct Window *)user_data;
struct Client *browser = new_browser(window, NULL, related_web_view);
- if(badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser) < 0)
+ if(badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser, FALSE) < 0)
return NULL;
else
return browser->webView;
@@ -825,7 +824,8 @@ new_browser(struct Window *window, const gchar *target_url, WebKitWebView *relat
return browser;
}
-/* badwolf_new_tab: Inserts struct Client *browser in GtkNotebook *notebook
+/* badwolf_new_tab: Inserts struct Client *browser in GtkNotebook *notebook
+ * and optionally switches selected tab to it.
*
* returns:
* 0 : Ran successfully
@@ -833,7 +833,7 @@ new_browser(struct Window *window, const gchar *target_url, WebKitWebView *relat
* -2 : browser is NULL
*/
int
-badwolf_new_tab(GtkNotebook *notebook, struct Client *browser)
+badwolf_new_tab(GtkNotebook *notebook, struct Client *browser, bool auto_switch)
{
gint current_page = gtk_notebook_get_current_page(notebook);
gchar *title = _("New tab");
@@ -850,6 +850,11 @@ badwolf_new_tab(GtkNotebook *notebook, struct Client *browser)
gtk_widget_queue_draw(GTK_WIDGET(notebook));
+ if(auto_switch)
+ {
+ gtk_notebook_set_current_page(notebook, gtk_notebook_page_num(notebook, browser->box));
+ }
+
return 0;
}
@@ -860,7 +865,7 @@ new_tabCb_clicked(GtkButton *new_tab, gpointer user_data)
struct Window *window = (struct Window *)user_data;
struct Client *browser = new_browser(window, NULL, NULL);
- badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser);
+ badwolf_new_tab(GTK_NOTEBOOK(window->notebook), browser, TRUE);
}
static void
@@ -883,17 +888,6 @@ 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
-badwolf_get_tab_position(GtkContainer *notebook, GtkWidget *child)
-{
- GValue position = G_VALUE_INIT;
- g_value_init(&position, G_TYPE_INT);
-
- gtk_container_child_get_property(notebook, child, "position", &position);
-
- return g_value_get_int(&position);
-}
-
int
main(int argc, char *argv[])
{
@@ -979,10 +973,10 @@ main(int argc, char *argv[])
gtk_widget_show_all(window->main_window);
if(argc == 1)
- badwolf_new_tab(GTK_NOTEBOOK(window->notebook), new_browser(window, NULL, NULL));
+ badwolf_new_tab(GTK_NOTEBOOK(window->notebook), new_browser(window, NULL, NULL), FALSE);
else
for(int i = 1; i < argc; ++i)
- badwolf_new_tab(GTK_NOTEBOOK(window->notebook), new_browser(window, argv[i], NULL));
+ badwolf_new_tab(GTK_NOTEBOOK(window->notebook), new_browser(window, argv[i], NULL), FALSE);
gtk_notebook_set_current_page(GTK_NOTEBOOK(window->notebook), 1);