From 06795d8cd18df331305f4874213591ff2cf4ee4c Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Fri, 22 Sep 2017 01:19:22 -0400 Subject: Move tab population code from MqWindow to MqTab --- (limited to 'src/tab.c') diff --git a/src/tab.c b/src/tab.c index b8a7b52..a29231b 100644 --- a/src/tab.c +++ b/src/tab.c @@ -28,6 +28,28 @@ #include "tab-body.h" static void +mq_tab_populate_tab(MqTab *tab) +{ + tab->tab_image = gtk_image_new_from_icon_name("text-x-generic", + GTK_ICON_SIZE_BUTTON); + + tab->tab_label = gtk_label_new("New tab"); + gtk_label_set_ellipsize(GTK_LABEL(tab->tab_label), + PANGO_ELLIPSIZE_END); + gtk_widget_set_hexpand(tab->tab_label, TRUE); + gtk_widget_set_size_request(tab->tab_label, 50, 1); + + tab->tab = gtk_grid_new(); + gtk_grid_attach(GTK_GRID(tab->tab), tab->tab_image, + 0, 0, 1, 1); + gtk_grid_attach(GTK_GRID(tab->tab), tab->tab_label, + 1, 0, 1, 1); + gtk_grid_attach(GTK_GRID(tab->tab), gtk_button_new_from_icon_name( + "window-close", GTK_ICON_SIZE_BUTTON), 2, 0, 1, 1); + gtk_widget_show_all(tab->tab); +} + +static void update_tab_image(MqTab *tab) { gtk_image_set_from_surface(GTK_IMAGE(tab->tab_image), @@ -57,13 +79,14 @@ title_cb(WebKitWebView __attribute__((unused)) *web_view, } MqTab * -mq_tab_new(gchar *uri, GtkWidget *tab_image, GtkWidget *tab_label) +mq_tab_new(gchar *uri) { MqTab *tab; tab = malloc(sizeof(*tab)); - tab->tab_image = tab_image; - tab->tab_label = tab_label; + + mq_tab_populate_tab(tab); + tab->chrome = mq_tab_chrome_new(uri); tab->body = mq_tab_body_new(uri); tab->web_view = mq_tab_body_get_web_view(tab->body); @@ -86,6 +109,12 @@ mq_tab_new(gchar *uri, GtkWidget *tab_image, GtkWidget *tab_label) } GtkWidget * +mq_tab_get_tab(MqTab *tab) +{ + return tab->tab; +} + +GtkWidget * mq_tab_get_container(MqTab *tab) { return tab->container; -- cgit v0.9.1