Use ::has-subtitle when constructing CSD titlebars

GtkWindow was constructing a custom title label to
avoid the size reservation for a subtitle. This is
now easier with the ::has-subtitle property.
This commit is contained in:
Matthias Clasen 2013-12-10 22:58:57 -05:00
parent 1a6a86a867
commit 05d34f9a5b

View File

@ -5377,31 +5377,19 @@ static GtkWidget *
create_titlebar (GtkWindow *window) create_titlebar (GtkWindow *window)
{ {
GtkWindowPrivate *priv = window->priv; GtkWindowPrivate *priv = window->priv;
GtkWidget *label;
GtkWidget *titlebar; GtkWidget *titlebar;
GtkStyleContext *context; GtkStyleContext *context;
gchar *title;
titlebar = gtk_header_bar_new (); titlebar = gtk_header_bar_new ();
g_object_set (titlebar, g_object_set (titlebar,
"spacing", 0, "spacing", 0,
"title", priv->title ? priv->title : get_default_title (),
"has-subtitle", FALSE,
NULL); NULL);
context = gtk_widget_get_style_context (titlebar); context = gtk_widget_get_style_context (titlebar);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_TITLEBAR); gtk_style_context_add_class (context, GTK_STYLE_CLASS_TITLEBAR);
gtk_style_context_add_class (context, "default-decoration"); gtk_style_context_add_class (context, "default-decoration");
title = g_markup_printf_escaped ("<b>%s</b>",
priv->title ? priv->title : get_default_title ());
label = gtk_label_new (title);
g_free (title);
g_object_set (label,
"use-markup", TRUE,
"ellipsize", PANGO_ELLIPSIZE_END,
"margin", 6,
NULL);
gtk_header_bar_set_custom_title (GTK_HEADER_BAR (titlebar), label);
return titlebar; return titlebar;
} }