mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 22:10:08 +00:00
headerbar: Remove has-subtitle property
Subtitle will go too in the next commit, but has-subtitle goes first as it's broken right now anyway.
This commit is contained in:
parent
850549ba83
commit
43a453e465
@ -32,7 +32,6 @@ do_headerbar (GtkWidget *do_widget)
|
||||
header = gtk_header_bar_new ();
|
||||
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
|
||||
gtk_header_bar_set_title (GTK_HEADER_BAR (header), "Welcome to Facebook - Log in, sign up or learn more");
|
||||
gtk_header_bar_set_has_subtitle (GTK_HEADER_BAR (header), FALSE);
|
||||
|
||||
button = gtk_button_new ();
|
||||
icon = g_themed_icon_new ("mail-send-receive-symbolic");
|
||||
|
@ -5583,8 +5583,6 @@ gtk_header_bar_set_title
|
||||
gtk_header_bar_get_title
|
||||
gtk_header_bar_set_subtitle
|
||||
gtk_header_bar_get_subtitle
|
||||
gtk_header_bar_set_has_subtitle
|
||||
gtk_header_bar_get_has_subtitle
|
||||
gtk_header_bar_set_custom_title
|
||||
gtk_header_bar_get_custom_title
|
||||
gtk_header_bar_pack_start
|
||||
|
@ -48,10 +48,7 @@
|
||||
* be placed at the start or the end. In addition, it allows a title and
|
||||
* subtitle to be displayed. The title will be centered with respect to
|
||||
* the width of the box, even if the children at either side take up
|
||||
* different amounts of space. The height of the titlebar will be
|
||||
* set to provide sufficient space for the subtitle, even if none is
|
||||
* currently set. If a subtitle is not needed, the space reservation
|
||||
* can be turned off with gtk_header_bar_set_has_subtitle().
|
||||
* different amounts of space.
|
||||
*
|
||||
* GtkHeaderBar can add typical window frame controls, such as minimize,
|
||||
* maximize and close buttons, or the window icon.
|
||||
@ -106,10 +103,7 @@ struct _GtkHeaderBarPrivate
|
||||
GtkWidget *title_label;
|
||||
GtkWidget *subtitle_label;
|
||||
GtkWidget *label_box;
|
||||
GtkWidget *label_sizing_box;
|
||||
GtkWidget *subtitle_sizing_label;
|
||||
GtkWidget *custom_title;
|
||||
gboolean has_subtitle;
|
||||
|
||||
gboolean show_title_buttons;
|
||||
gchar *decoration_layout;
|
||||
@ -125,7 +119,6 @@ enum {
|
||||
PROP_0,
|
||||
PROP_TITLE,
|
||||
PROP_SUBTITLE,
|
||||
PROP_HAS_SUBTITLE,
|
||||
PROP_CUSTOM_TITLE,
|
||||
PROP_SHOW_TITLE_BUTTONS,
|
||||
PROP_DECORATION_LAYOUT,
|
||||
@ -141,38 +134,6 @@ G_DEFINE_TYPE_WITH_CODE (GtkHeaderBar, gtk_header_bar, GTK_TYPE_CONTAINER,
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
||||
gtk_header_bar_buildable_init));
|
||||
|
||||
static void
|
||||
init_sizing_box (GtkHeaderBar *bar)
|
||||
{
|
||||
GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
|
||||
GtkWidget *w;
|
||||
|
||||
/* We use this box to always request size for the two labels (title
|
||||
* and subtitle) as if they were always visible, but then allocate
|
||||
* the real label box with its actual size, to keep it center-aligned
|
||||
* in case we have only the title.
|
||||
*/
|
||||
w = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
priv->label_sizing_box = g_object_ref_sink (w);
|
||||
|
||||
w = gtk_label_new (NULL);
|
||||
gtk_widget_add_css_class (w, GTK_STYLE_CLASS_TITLE);
|
||||
gtk_container_add (GTK_CONTAINER (priv->label_sizing_box), w);
|
||||
gtk_label_set_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_label_set_width_chars (GTK_LABEL (w), MIN_TITLE_CHARS);
|
||||
|
||||
w = gtk_label_new (NULL);
|
||||
gtk_widget_add_css_class (w, GTK_STYLE_CLASS_SUBTITLE);
|
||||
gtk_container_add (GTK_CONTAINER (priv->label_sizing_box), w);
|
||||
gtk_label_set_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 && priv->subtitle[0]));
|
||||
priv->subtitle_sizing_label = w;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
create_title_box (const char *title,
|
||||
const char *subtitle,
|
||||
@ -367,10 +328,6 @@ gtk_header_bar_get_title (GtkHeaderBar *bar)
|
||||
*
|
||||
* Sets the subtitle of the #GtkHeaderBar. The title should give a user
|
||||
* an additional detail to help him identify the current view.
|
||||
*
|
||||
* Note that GtkHeaderBar by default reserves room for the subtitle,
|
||||
* even if none is currently set. If this is not desired, set the
|
||||
* #GtkHeaderBar:has-subtitle property to %FALSE.
|
||||
*/
|
||||
void
|
||||
gtk_header_bar_set_subtitle (GtkHeaderBar *bar,
|
||||
@ -392,8 +349,6 @@ gtk_header_bar_set_subtitle (GtkHeaderBar *bar,
|
||||
gtk_widget_queue_resize (GTK_WIDGET (bar));
|
||||
}
|
||||
|
||||
gtk_widget_set_visible (priv->subtitle_sizing_label, priv->has_subtitle || (priv->subtitle && priv->subtitle[0]));
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (bar), header_bar_props[PROP_SUBTITLE]);
|
||||
}
|
||||
|
||||
@ -508,12 +463,6 @@ gtk_header_bar_dispose (GObject *object)
|
||||
{
|
||||
GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (GTK_HEADER_BAR (object));
|
||||
|
||||
if (priv->label_sizing_box)
|
||||
{
|
||||
g_object_ref_sink (priv->label_sizing_box);
|
||||
g_clear_object (&priv->label_sizing_box);
|
||||
}
|
||||
|
||||
g_clear_pointer (&priv->custom_title, gtk_widget_unparent);
|
||||
g_clear_pointer (&priv->label_box, gtk_widget_unparent);
|
||||
|
||||
@ -562,10 +511,6 @@ gtk_header_bar_get_property (GObject *object,
|
||||
g_value_set_boolean (value, gtk_header_bar_get_show_title_buttons (bar));
|
||||
break;
|
||||
|
||||
case PROP_HAS_SUBTITLE:
|
||||
g_value_set_boolean (value, gtk_header_bar_get_has_subtitle (bar));
|
||||
break;
|
||||
|
||||
case PROP_DECORATION_LAYOUT:
|
||||
g_value_set_string (value, gtk_header_bar_get_decoration_layout (bar));
|
||||
break;
|
||||
@ -602,10 +547,6 @@ gtk_header_bar_set_property (GObject *object,
|
||||
gtk_header_bar_set_show_title_buttons (bar, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
case PROP_HAS_SUBTITLE:
|
||||
gtk_header_bar_set_has_subtitle (bar, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
case PROP_DECORATION_LAYOUT:
|
||||
gtk_header_bar_set_decoration_layout (bar, g_value_get_string (value));
|
||||
break;
|
||||
@ -798,19 +739,6 @@ gtk_header_bar_class_init (GtkHeaderBarClass *class)
|
||||
NULL,
|
||||
GTK_PARAM_READWRITE);
|
||||
|
||||
/**
|
||||
* GtkHeaderBar:has-subtitle:
|
||||
*
|
||||
* If %TRUE, reserve space for a subtitle, even if none
|
||||
* is currently set.
|
||||
*/
|
||||
header_bar_props[PROP_HAS_SUBTITLE] =
|
||||
g_param_spec_boolean ("has-subtitle",
|
||||
P_("Has Subtitle"),
|
||||
P_("Whether to reserve space for a subtitle"),
|
||||
TRUE,
|
||||
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
g_object_class_install_properties (object_class, LAST_PROP, header_bar_props);
|
||||
|
||||
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_PANEL);
|
||||
@ -827,7 +755,6 @@ gtk_header_bar_init (GtkHeaderBar *bar)
|
||||
priv->title = NULL;
|
||||
priv->subtitle = NULL;
|
||||
priv->custom_title = NULL;
|
||||
priv->has_subtitle = TRUE;
|
||||
priv->decoration_layout = NULL;
|
||||
priv->state = GDK_SURFACE_STATE_WITHDRAWN;
|
||||
|
||||
@ -841,7 +768,6 @@ gtk_header_bar_init (GtkHeaderBar *bar)
|
||||
gtk_widget_set_parent (priv->end_box, GTK_WIDGET (bar));
|
||||
gtk_center_layout_set_end_widget (GTK_CENTER_LAYOUT (layout), priv->end_box);
|
||||
|
||||
init_sizing_box (bar);
|
||||
construct_label_box (bar);
|
||||
}
|
||||
|
||||
@ -971,59 +897,6 @@ gtk_header_bar_set_show_title_buttons (GtkHeaderBar *bar,
|
||||
g_object_notify_by_pspec (G_OBJECT (bar), header_bar_props[PROP_SHOW_TITLE_BUTTONS]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_header_bar_set_has_subtitle:
|
||||
* @bar: a #GtkHeaderBar
|
||||
* @setting: %TRUE to reserve space for a subtitle
|
||||
*
|
||||
* Sets whether the header bar should reserve space
|
||||
* for a subtitle, even if none is currently set.
|
||||
*/
|
||||
void
|
||||
gtk_header_bar_set_has_subtitle (GtkHeaderBar *bar,
|
||||
gboolean setting)
|
||||
{
|
||||
GtkHeaderBarPrivate *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_HEADER_BAR (bar));
|
||||
|
||||
priv = gtk_header_bar_get_instance_private (bar);
|
||||
|
||||
setting = setting != FALSE;
|
||||
|
||||
if (priv->has_subtitle == setting)
|
||||
return;
|
||||
|
||||
priv->has_subtitle = setting;
|
||||
gtk_widget_set_visible (priv->subtitle_sizing_label, setting || (priv->subtitle && priv->subtitle[0]));
|
||||
|
||||
gtk_widget_queue_resize (GTK_WIDGET (bar));
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (bar), header_bar_props[PROP_HAS_SUBTITLE]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_header_bar_get_has_subtitle:
|
||||
* @bar: a #GtkHeaderBar
|
||||
*
|
||||
* Retrieves whether the header bar reserves space for
|
||||
* a subtitle, regardless if one is currently set or not.
|
||||
*
|
||||
* Returns: %TRUE if the header bar reserves space
|
||||
* for a subtitle
|
||||
*/
|
||||
gboolean
|
||||
gtk_header_bar_get_has_subtitle (GtkHeaderBar *bar)
|
||||
{
|
||||
GtkHeaderBarPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_HEADER_BAR (bar), FALSE);
|
||||
|
||||
priv = gtk_header_bar_get_instance_private (bar);
|
||||
|
||||
return priv->has_subtitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_header_bar_set_decoration_layout:
|
||||
* @bar: a #GtkHeaderBar
|
||||
|
@ -69,12 +69,6 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gtk_header_bar_set_show_title_buttons (GtkHeaderBar *bar,
|
||||
gboolean setting);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_header_bar_set_has_subtitle (GtkHeaderBar *bar,
|
||||
gboolean setting);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_header_bar_get_has_subtitle (GtkHeaderBar *bar);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_header_bar_set_decoration_layout (GtkHeaderBar *bar,
|
||||
const gchar *layout);
|
||||
|
@ -4157,7 +4157,6 @@ create_titlebar (GtkWindow *window)
|
||||
titlebar = gtk_header_bar_new ();
|
||||
g_object_set (titlebar,
|
||||
"title", priv->title ? priv->title : get_default_title (),
|
||||
"has-subtitle", FALSE,
|
||||
"show-title-buttons", TRUE,
|
||||
NULL);
|
||||
gtk_widget_add_css_class (titlebar, GTK_STYLE_CLASS_TITLEBAR);
|
||||
|
@ -4,7 +4,6 @@
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar" id="headerbar">
|
||||
<property name="show-title-buttons">1</property>
|
||||
<property name="has-subtitle">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
Loading…
Reference in New Issue
Block a user