summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-09-22 02:14:13 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-09-22 02:21:44 (EDT)
commitbbb8adf7d081ded3d95cdb00213d3cd129b20018 (patch)
tree58a6cf3854846972a7477d238c60a1b64c56ab9c
parenta25251d553f0f20bb1dda949d7bd87e50da18b84 (diff)
downloadmarquee-bbb8adf7d081ded3d95cdb00213d3cd129b20018.zip
marquee-bbb8adf7d081ded3d95cdb00213d3cd129b20018.tar.gz
marquee-bbb8adf7d081ded3d95cdb00213d3cd129b20018.tar.bz2
MqTab: Save tab favicon and title in struct
This allows the "New tab" title to remain, rather than getting overwritten with NULL from webkit_web_view_get_title().
-rw-r--r--src/tab.c11
-rw-r--r--src/tab.h18
2 files changed, 16 insertions, 13 deletions
diff --git a/src/tab.c b/src/tab.c
index b580b41..b24315e 100644
--- a/src/tab.c
+++ b/src/tab.c
@@ -140,10 +140,11 @@ mq_tab_populate_tab(MqTab *tab)
{
GtkWidget *box;
+ tab->title = "New 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");
+ tab->tab_label = gtk_label_new(NULL);
gtk_label_set_ellipsize(GTK_LABEL(tab->tab_label),
PANGO_ELLIPSIZE_END);
gtk_widget_set_hexpand(tab->tab_label, TRUE);
@@ -167,22 +168,21 @@ mq_tab_populate_tab(MqTab *tab)
static void
update_tab_image(MqTab *tab)
{
- gtk_image_set_from_surface(GTK_IMAGE(tab->tab_image),
- webkit_web_view_get_favicon(tab->web_view));
+ gtk_image_set_from_surface(GTK_IMAGE(tab->tab_image), tab->favicon);
}
static void
update_tab_label(MqTab *tab)
{
gtk_label_set_text(GTK_LABEL(tab->tab_label),
- g_strdup_printf("%d. %s", tab->tab_position + 1,
- webkit_web_view_get_title(tab->web_view)));
+ g_strdup_printf("%d. %s", tab->tab_position + 1, tab->title));
}
static void
favicon_cb(WebKitWebView __attribute__((unused)) *web_view,
GParamSpec __attribute__((unused)) *paramspec, MqTab *tab)
{
+ tab->favicon = webkit_web_view_get_favicon(tab->web_view);
update_tab_image(tab);
}
@@ -190,6 +190,7 @@ static void
title_cb(WebKitWebView __attribute__((unused)) *web_view,
GParamSpec __attribute__((unused)) *paramspec, MqTab *tab)
{
+ tab->title = webkit_web_view_get_title(tab->web_view);
update_tab_label(tab);
}
diff --git a/src/tab.h b/src/tab.h
index b125cd9..3361acc 100644
--- a/src/tab.h
+++ b/src/tab.h
@@ -28,14 +28,16 @@
#include "tab-body.h"
typedef struct {
- GtkWidget *container;
- MqTabChrome *chrome;
- MqTabBody *body;
- GtkWidget *tab;
- GtkWidget *tab_image;
- GtkWidget *tab_label;
- guint tab_position;
- WebKitWebView *web_view;
+ GtkWidget *container;
+ MqTabChrome *chrome;
+ MqTabBody *body;
+ GtkWidget *tab;
+ GtkWidget *tab_image;
+ GtkWidget *tab_label;
+ cairo_surface_t *favicon;
+ const gchar *title;
+ guint tab_position;
+ WebKitWebView *web_view;
} MqTab;
MqTab *