commit: 1a7efbf367f2476f5214da011fefe290c0c06079
parent cb24140774805c6133d352d52a325bcd21b79b28
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sat, 6 Apr 2019 03:26:22 +0200
badwolf.c: Add get_tab_position
Diffstat:
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/badwolf.c b/badwolf.c
@@ -63,6 +63,7 @@ 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);
+gint get_tab_position(GtkContainer *notebook, GtkWidget *child);
int main(int argc, char *argv[]);
static gboolean WebViewCb_close(WebKitWebView *webView, gpointer user_data)
@@ -70,12 +71,8 @@ static gboolean WebViewCb_close(WebKitWebView *webView, gpointer user_data)
(void)webView;
struct Client *browser = (struct Client *)user_data;
GtkNotebook *notebook = GTK_NOTEBOOK(browser->window->notebook);
- GValue position = G_VALUE_INIT;
- g_value_init(&position, G_TYPE_INT);
-
- gtk_container_child_get_property(GTK_CONTAINER(notebook), browser->box, "position", &position);
- gtk_notebook_remove_page(notebook, g_value_get_int(&position));
+ gtk_notebook_remove_page(notebook, get_tab_position(GTK_CONTAINER(notebook), browser->box));
gtk_widget_destroy(browser->box);
@@ -467,6 +464,16 @@ 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)
+{
+ 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[])
{
struct Window *window = g_malloc(sizeof(struct Client));