GtkHeaderBar: treat "" as 'no subtitle'

This is one of the few cases where it makes some sense to blur
the line between and empty string and NULL: without this, it is
hard to reset the subtitle e.g. from a builder file. And we
have the has-subtitle property now to enforce subtitle size
allocation independently.
This commit is contained in:
Matthias Clasen 2013-12-12 19:24:56 -05:00
parent 70eb35d569
commit d8401c5f0a

View File

@ -148,7 +148,7 @@ init_sizing_box (GtkHeaderBar *bar)
gtk_label_set_line_wrap (GTK_LABEL (w), FALSE);
gtk_label_set_single_line_mode (GTK_LABEL (w), TRUE);
gtk_label_set_ellipsize (GTK_LABEL (w), PANGO_ELLIPSIZE_END);
gtk_widget_set_visible (w, priv->has_subtitle || priv->subtitle);
gtk_widget_set_visible (w, priv->has_subtitle || (priv->subtitle && priv->subtitle[0]));
priv->subtitle_sizing_label = w;
}
@ -1170,11 +1170,11 @@ gtk_header_bar_set_subtitle (GtkHeaderBar *bar,
if (priv->subtitle_label != NULL)
{
gtk_label_set_label (GTK_LABEL (priv->subtitle_label), priv->subtitle);
gtk_widget_set_visible (priv->subtitle_label, priv->subtitle != NULL);
gtk_widget_set_visible (priv->subtitle_label, priv->subtitle && priv->subtitle[0]);
gtk_widget_queue_resize (GTK_WIDGET (bar));
}
gtk_widget_set_visible (priv->subtitle_sizing_label, priv->has_subtitle || priv->subtitle);
gtk_widget_set_visible (priv->subtitle_sizing_label, priv->has_subtitle || (priv->subtitle && priv->subtitle[0]));
g_object_notify (G_OBJECT (bar), "subtitle");
}
@ -2014,7 +2014,7 @@ gtk_header_bar_set_has_subtitle (GtkHeaderBar *bar,
return;
priv->has_subtitle = setting;
gtk_widget_set_visible (priv->subtitle_sizing_label, setting || priv->subtitle);
gtk_widget_set_visible (priv->subtitle_sizing_label, setting || (priv->subtitle && priv->subtitle[0]));
gtk_widget_queue_resize (GTK_WIDGET (bar));