summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tab-label.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/tab-label.c b/src/tab-label.c
index fd4b7b4..cd9f00d 100644
--- a/src/tab-label.c
+++ b/src/tab-label.c
@@ -30,6 +30,8 @@
#include "tab-page.h"
#include "web-view.h"
+#define SCROLLED_TITLE_FMT "<span font_family=\"monospace\">%s</span>"
+
struct _MqTabLabel {
GtkEventBox parent_instance;
MqTabPage *tab_page;
@@ -40,6 +42,7 @@ struct _MqTabLabel {
gchar *title;
gboolean scrolling;
gchar *scrolled_title;
+ gchar *scrolled_markup;
GtkWidget *popover;
};
@@ -163,14 +166,17 @@ set_image(MqTabLabel *tab_label, GdkPixbuf *favicon)
static void
update_label(MqTabLabel *tab_label)
{
- const gchar *title;
- gchar *label;
-
- title = tab_label->scrolling ? tab_label->scrolled_title :
- tab_label->title;
- label = g_strdup_printf("%u. %s", tab_label->position, title);
- gtk_label_set_text(GTK_LABEL(tab_label->label), label);
- gtk_widget_set_tooltip_text(GTK_WIDGET(tab_label), label);
+ gchar *label;
+
+ if (tab_label->scrolling) {
+ label = g_strdup_printf("%u. %s", tab_label->position,
+ tab_label->scrolled_markup);
+ gtk_label_set_markup(GTK_LABEL(tab_label->label), label);
+ } else {
+ label = g_strdup_printf("%u. %s", tab_label->position,
+ tab_label->title);
+ gtk_label_set_text(GTK_LABEL(tab_label->label), label);
+ }
g_free(label);
}
@@ -181,8 +187,12 @@ set_title(MqTabLabel *tab_label, const gchar *title)
tab_label->title = g_strdup(title);
if (tab_label->scrolling) {
tab_label->scrolled_title = g_strdup_printf("%s ", title);
+ tab_label->scrolled_markup =
+ g_markup_printf_escaped(SCROLLED_TITLE_FMT,
+ tab_label->scrolled_title);
}
update_label(tab_label);
+ gtk_widget_set_tooltip_text(GTK_WIDGET(tab_label), tab_label->title);
}
static void
@@ -388,17 +398,10 @@ mq_tab_label_set_position(MqTabLabel *tab_label, guint position)
void
mq_tab_label_begin_scrolling(MqTabLabel *tab_label)
{
- static PangoFontDescription *font_desc = NULL;
-
- if (!font_desc) {
- font_desc = pango_font_description_new();
- pango_font_description_set_family_static(font_desc,
- "monospace");
- }
-
tab_label->scrolling = TRUE;
tab_label->scrolled_title = g_strdup_printf("%s ", tab_label->title);
- gtk_widget_override_font(tab_label->label, font_desc);
+ tab_label->scrolled_markup = g_markup_printf_escaped(SCROLLED_TITLE_FMT,
+ tab_label->scrolled_title);
}
void
@@ -406,8 +409,6 @@ mq_tab_label_end_scrolling(MqTabLabel *tab_label)
{
tab_label->scrolling = FALSE;
- gtk_widget_override_font(tab_label->label, NULL);
-
update_label(tab_label);
}
@@ -435,5 +436,7 @@ mq_tab_label_scroll(MqTabLabel *tab_label)
tab_label->scrolled_title[j] = c[i];
}
+ tab_label->scrolled_markup = g_markup_printf_escaped(SCROLLED_TITLE_FMT,
+ tab_label->scrolled_title);
update_label(tab_label);
}