summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-09-22 01:19:22 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-09-22 01:19:22 (EDT)
commit06795d8cd18df331305f4874213591ff2cf4ee4c (patch)
tree40d8d9d7cb5abad179e415762c0f4e94c03b7f54 /src
parentd0f1011e869717484e94cda4e922071b5f82ec32 (diff)
downloadmarquee-06795d8cd18df331305f4874213591ff2cf4ee4c.zip
marquee-06795d8cd18df331305f4874213591ff2cf4ee4c.tar.gz
marquee-06795d8cd18df331305f4874213591ff2cf4ee4c.tar.bz2
Move tab population code from MqWindow to MqTab
Diffstat (limited to 'src')
-rw-r--r--src/tab.c35
-rw-r--r--src/tab.h6
-rw-r--r--src/window.c26
3 files changed, 40 insertions, 27 deletions
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;
diff --git a/src/tab.h b/src/tab.h
index 19c0d36..b125cd9 100644
--- a/src/tab.h
+++ b/src/tab.h
@@ -31,6 +31,7 @@ typedef struct {
GtkWidget *container;
MqTabChrome *chrome;
MqTabBody *body;
+ GtkWidget *tab;
GtkWidget *tab_image;
GtkWidget *tab_label;
guint tab_position;
@@ -38,7 +39,10 @@ typedef struct {
} MqTab;
MqTab *
-mq_tab_new(gchar *uri, GtkWidget *tab_image, GtkWidget *tab_label);
+mq_tab_new(gchar *uri);
+
+GtkWidget *
+mq_tab_get_tab(MqTab *tab);
GtkWidget *
mq_tab_get_container(MqTab *tab);
diff --git a/src/window.c b/src/window.c
index 21717e0..013ed80 100644
--- a/src/window.c
+++ b/src/window.c
@@ -120,39 +120,19 @@ tab_label_button_press_cb(GtkWidget *widget, GdkEvent *event, MqTab *tab)
static void
add_tab(MqWindow *window, gchar *uri, gint position)
{
- GtkWidget *tab_label_image;
- GtkWidget *tab_label_label;
- GtkWidget *tab_label;
MqTab *tab;
GtkWidget *tab_label_event_box;
GtkWidget *tab_widget;
- tab_label_image = gtk_image_new_from_icon_name("text-x-generic",
- GTK_ICON_SIZE_BUTTON);
-
- tab_label_label = gtk_label_new("New tab");
- gtk_label_set_ellipsize(GTK_LABEL(tab_label_label),
- PANGO_ELLIPSIZE_END);
- gtk_widget_set_hexpand(tab_label_label, TRUE);
- gtk_widget_set_size_request(tab_label_label, 50, 1);
-
- tab_label = gtk_grid_new();
- gtk_grid_attach(GTK_GRID(tab_label), tab_label_image,
- 0, 0, 1, 1);
- gtk_grid_attach(GTK_GRID(tab_label), tab_label_label,
- 1, 0, 1, 1);
- gtk_grid_attach(GTK_GRID(tab_label), gtk_button_new_from_icon_name(
- "window-close", GTK_ICON_SIZE_BUTTON), 2, 0, 1, 1);
- gtk_widget_show_all(tab_label);
-
- tab = mq_tab_new(uri, tab_label_image, tab_label_label);
+ tab = mq_tab_new(uri);
tab_label_event_box = gtk_event_box_new();
g_signal_connect(tab_label_event_box, "button-press-event",
G_CALLBACK(tab_label_button_press_cb), tab);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(tab_label_event_box),
FALSE);
- gtk_container_add(GTK_CONTAINER(tab_label_event_box), tab_label);
+ gtk_container_add(GTK_CONTAINER(tab_label_event_box),
+ mq_tab_get_tab(tab));
tab_widget = mq_tab_get_container(tab);
position = gtk_notebook_insert_page(GTK_NOTEBOOK(window->notebook),