headerbar: Remove user-settable title

Use window title, or custom title widget if it's set. Remove 'title'
property.

Update demos and tests to set the title on the window instead of
headerbar.
This commit is contained in:
Alexander Mikhaylenko 2020-05-01 04:04:08 +05:00
parent 35d50f88c8
commit c2e4e1af73
28 changed files with 96 additions and 171 deletions

View File

@ -9,7 +9,6 @@
<property name="default-height">768</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<property name="title" translatable="yes">GTK Constraint Editor</property>
<property name="show-title-buttons">1</property>
<child type="start">
<object class="GtkButton">

View File

@ -257,9 +257,9 @@ do_constraints (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Constraints");
header = gtk_header_bar_new ();
gtk_header_bar_set_title (GTK_HEADER_BAR (header), "Constraints");
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), FALSE);
gtk_window_set_titlebar (GTK_WINDOW (window), header);
g_signal_connect (window, "destroy",

View File

@ -213,9 +213,9 @@ do_constraints2 (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Constraints");
header = gtk_header_bar_new ();
gtk_header_bar_set_title (GTK_HEADER_BAR (header), "Constraints");
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), FALSE);
gtk_window_set_titlebar (GTK_WINDOW (window), header);
g_signal_connect (window, "destroy",

View File

@ -133,9 +133,9 @@ do_constraints3 (GtkWidget *do_widget)
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Constraints");
header = gtk_header_bar_new ();
gtk_header_bar_set_title (GTK_HEADER_BAR (header), "Constraints");
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), FALSE);
gtk_window_set_titlebar (GTK_WINDOW (window), header);
g_signal_connect (window, "destroy",

View File

@ -194,7 +194,7 @@ static void
set_widget_type (GtkFishbowl *fishbowl,
int widget_type_index)
{
GtkWidget *window, *headerbar;
GtkWidget *window;
if (widget_type_index == selected_widget_type)
return;
@ -205,9 +205,8 @@ set_widget_type (GtkFishbowl *fishbowl,
widget_types[selected_widget_type].create_func);
window = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (fishbowl)));
headerbar = gtk_window_get_titlebar (GTK_WINDOW (window));
gtk_header_bar_set_title (GTK_HEADER_BAR (headerbar),
widget_types[selected_widget_type].name);
gtk_window_set_title (GTK_WINDOW (window),
widget_types[selected_widget_type].name);
}
void

View File

@ -4,10 +4,10 @@
<object class="GtkWindow" id="window">
<property name="default-width">600</property>
<property name="default-height">500</property>
<property name="title">Font Explorer</property>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="show-title-buttons">1</property>
<property name="title">Font Explorer</property>
<child>
<object class="GtkButton" id="reset">
<property name="receives-default">1</property>

View File

@ -24,13 +24,13 @@ do_headerbar (GtkWidget *do_widget)
{
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Welcome to Facebook - Log in, sign up or learn more");
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
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");
button = gtk_button_new ();
icon = g_themed_icon_new ("mail-send-receive-symbolic");

View File

@ -17,7 +17,7 @@ static gchar *current_file = NULL;
static GtkWidget *notebook;
static GtkWidget *treeview;
static GtkWidget *headerbar;
static GtkWidget *toplevel;
enum {
NAME_COLUMN,
@ -915,7 +915,7 @@ selection_cb (GtkTreeSelection *selection,
if (filename)
load_file (name, filename);
gtk_header_bar_set_title (GTK_HEADER_BAR (headerbar), title);
gtk_window_set_title (GTK_WINDOW (toplevel), title);
g_free (name);
g_free (title);
@ -1030,9 +1030,9 @@ activate (GApplication *app)
info_view = (GtkWidget *)gtk_builder_get_object (builder, "info-textview");
source_view = (GtkWidget *)gtk_builder_get_object (builder, "source-textview");
headerbar = (GtkWidget *)gtk_builder_get_object (builder, "headerbar");
treeview = (GtkWidget *)gtk_builder_get_object (builder, "treeview");
model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
toplevel = GTK_WIDGET (window);
load_file (gtk_demos[0].name, gtk_demos[0].filename);

View File

@ -31,7 +31,6 @@
</style>
<property name="default-width">800</property>
<property name="default-height">600</property>
<property name="title">GTK Demo</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerbar">
<property name="show-title-buttons">1</property>

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="window1">
<property name="title" translatable="yes">Model Button</property>
<property name="resizable">0</property>
<child type="titlebar">
<object class="GtkHeaderBar">
<property name="show-title-buttons">1</property>
<property name="title" translatable="yes">Model Button</property>
</object>
</child>
<child>

View File

@ -392,7 +392,6 @@ do_paint (GtkWidget *toplevel)
gtk_container_add (GTK_CONTAINER (window), draw_area);
headerbar = gtk_header_bar_new ();
gtk_header_bar_set_title (GTK_HEADER_BAR (headerbar), "Paint");
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (headerbar), TRUE);
colorbutton = gtk_color_button_new ();
@ -405,6 +404,7 @@ do_paint (GtkWidget *toplevel)
gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), colorbutton);
gtk_window_set_titlebar (GTK_WINDOW (window), headerbar);
gtk_window_set_title (GTK_WINDOW (window), "Paint");
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);

View File

@ -40,9 +40,9 @@ do_password_entry (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
header = gtk_header_bar_new ();
gtk_header_bar_set_title (GTK_HEADER_BAR (header), "Choose a Password");
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), FALSE);
gtk_window_set_titlebar (GTK_WINDOW (window), header);
gtk_window_set_title (GTK_WINDOW (window), "Choose a Password");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_window_set_deletable (GTK_WINDOW (window), FALSE);
g_signal_connect (window, "destroy",

View File

@ -276,13 +276,12 @@ do_peg_solitaire (GtkWidget *do_widget)
g_signal_connect (restart, "clicked", G_CALLBACK (restart), NULL);
header = gtk_header_bar_new ();
gtk_header_bar_set_title (GTK_HEADER_BAR (header), "Peg Solitaire");
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), restart);
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "Sliding Puzzle");
gtk_window_set_title (GTK_WINDOW (window), "Peg Solitaire");
gtk_window_set_titlebar (GTK_WINDOW (window), header);
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
g_signal_connect (window, "destroy",

View File

@ -67,9 +67,9 @@ do_tagged_entry (GtkWidget *do_widget)
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
header = gtk_header_bar_new ();
gtk_header_bar_set_title (GTK_HEADER_BAR (header), "A tagged entry");
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), FALSE);
gtk_window_set_titlebar (GTK_WINDOW (window), header);
gtk_window_set_title (GTK_WINDOW (window), "A tagged entry");
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
gtk_window_set_deletable (GTK_WINDOW (window), FALSE);
g_signal_connect (window, "destroy",

View File

@ -97,7 +97,6 @@ change_theme (GtkWidget *widget,
gpointer data)
{
GtkBuilder *builder = data;
GtkWidget *header;
GtkWidget *label;
Theme next = themes[theme++ % G_N_ELEMENTS (themes)];
char *name;
@ -107,9 +106,8 @@ change_theme (GtkWidget *widget,
"gtk-application-prefer-dark-theme", next.dark,
NULL);
header = GTK_WIDGET (gtk_builder_get_object (builder, "header"));
name = g_strconcat (next.name, next.dark ? " (dark)" : NULL, NULL);
gtk_header_bar_set_title (GTK_HEADER_BAR (header), name);
gtk_window_set_title (GTK_WINDOW (widget), name);
g_free (name);
label = GTK_WIDGET (gtk_builder_get_object (builder, "fps"));

View File

@ -75,7 +75,6 @@ do_video_player (GtkWidget *do_widget)
title = gtk_header_bar_new ();
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (title), TRUE);
gtk_header_bar_set_title (GTK_HEADER_BAR (title), "Video Player");
gtk_window_set_titlebar (GTK_WINDOW (window), title);
open_button = gtk_button_new_with_mnemonic ("_Open");

View File

@ -25,7 +25,6 @@
<property name="default-height">768</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<property name="title" translatable="yes">Icon Browser</property>
<property name="show-title-buttons">1</property>
<child type="title">
<object class="GtkBox">

View File

@ -86,7 +86,6 @@
<property name="focus-widget">text_view</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header">
<property name="title" translatable="yes">GTK Node Editor</property>
<property name="show-title-buttons">1</property>
<child type="start">
<object class="GtkButton">
@ -120,11 +119,6 @@
<property name="popover">testcase_popover</property>
</object>
</child>
<child type="title">
<object class="GtkLabel">
<property name="label" translatable="yes">GTK Node Editor</property>
</object>
</child>
</object>
</child>
<child>

View File

@ -5579,8 +5579,6 @@ gtk_action_bar_get_type
<TITLE>GtkHeaderBar</TITLE>
GtkHeaderBar
gtk_header_bar_new
gtk_header_bar_set_title
gtk_header_bar_get_title
gtk_header_bar_set_custom_title
gtk_header_bar_get_custom_title
gtk_header_bar_pack_start

View File

@ -1122,12 +1122,12 @@ create_headerbar (void)
GtkWidget *button;
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (bar), "Header Bar");
view = gtk_text_view_new ();
gtk_widget_show (view);
gtk_widget_set_size_request (window, 220, 150);
gtk_container_add (GTK_CONTAINER (window), view);
bar = gtk_header_bar_new ();
gtk_header_bar_set_title (GTK_HEADER_BAR (bar), "Header Bar");
gtk_window_set_titlebar (GTK_WINDOW (window), bar);
button = gtk_button_new ();
gtk_container_add (GTK_CONTAINER (button), gtk_image_new_from_icon_name ("bookmark-new-symbolic"));

View File

@ -15,8 +15,6 @@ new_window (GApplication *app,
gtk_window_set_icon_name (GTK_WINDOW (window), "sunny");
header = gtk_header_bar_new ();
gtk_widget_show (header);
gtk_header_bar_set_title (GTK_HEADER_BAR (header), "Sunny");
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
gtk_window_set_titlebar (GTK_WINDOW (window), header);

View File

@ -45,10 +45,10 @@
* @See_also: #GtkBox, #GtkActionBar
*
* GtkHeaderBar is similar to a horizontal #GtkBox. It allows children to
* be placed at the start or the end. In addition, it allows a title 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.
* be placed at the start or the end. In addition, it allows the window
* title 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.
*
* GtkHeaderBar can add typical window frame controls, such as minimize,
* maximize and close buttons, or the window icon.
@ -98,7 +98,6 @@ struct _GtkHeaderBarPrivate
GtkWidget *start_box;
GtkWidget *end_box;
gchar *title;
GtkWidget *title_label;
GtkWidget *custom_title;
@ -114,7 +113,6 @@ struct _GtkHeaderBarPrivate
enum {
PROP_0,
PROP_TITLE,
PROP_CUSTOM_TITLE,
PROP_SHOW_TITLE_BUTTONS,
PROP_DECORATION_LAYOUT,
@ -213,6 +211,30 @@ _gtk_header_bar_track_default_decoration (GtkHeaderBar *bar)
update_default_decoration (bar);
}
static void
update_title (GtkHeaderBar *bar)
{
GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
GtkRoot *root;
const gchar *title = NULL;
if (!priv->title_label)
return;
root = gtk_widget_get_root (GTK_WIDGET (bar));
if (GTK_IS_WINDOW (root))
title = gtk_window_get_title (GTK_WINDOW (root));
if (!title)
title = g_get_application_name ();
if (!title)
title = g_get_prgname ();
gtk_label_set_text (GTK_LABEL (priv->title_label), title);
}
static void
construct_title_label (GtkHeaderBar *bar)
{
@ -222,7 +244,7 @@ construct_title_label (GtkHeaderBar *bar)
g_assert (priv->title_label == NULL);
label = gtk_label_new (priv->title);
label = gtk_label_new (NULL);
gtk_widget_add_css_class (label, GTK_STYLE_CLASS_TITLE);
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
gtk_label_set_wrap (GTK_LABEL (label), FALSE);
@ -234,57 +256,8 @@ construct_title_label (GtkHeaderBar *bar)
gtk_center_layout_set_center_widget (GTK_CENTER_LAYOUT (layout), label);
priv->title_label = label;
}
/**
* gtk_header_bar_set_title:
* @bar: a #GtkHeaderBar
* @title: (allow-none): a title, or %NULL
*
* Sets the title of the #GtkHeaderBar. The title should help a user
* identify the current view. A good title should not include the
* application name.
*/
void
gtk_header_bar_set_title (GtkHeaderBar *bar,
const gchar *title)
{
GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
gchar *new_title;
g_return_if_fail (GTK_IS_HEADER_BAR (bar));
new_title = g_strdup (title);
g_free (priv->title);
priv->title = new_title;
if (priv->title_label != NULL)
{
gtk_label_set_label (GTK_LABEL (priv->title_label), priv->title);
gtk_widget_queue_resize (GTK_WIDGET (bar));
}
g_object_notify_by_pspec (G_OBJECT (bar), header_bar_props[PROP_TITLE]);
}
/**
* gtk_header_bar_get_title:
* @bar: a #GtkHeaderBar
*
* Retrieves the title of the header. See gtk_header_bar_set_title().
*
* Returns: (nullable): the title of the header, or %NULL if none has
* been set explicitly. The returned string is owned by the widget
* and must not be modified or freed.
*/
const gchar *
gtk_header_bar_get_title (GtkHeaderBar *bar)
{
GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
g_return_val_if_fail (GTK_IS_HEADER_BAR (bar), NULL);
return priv->title;
update_title (bar);
}
/**
@ -295,11 +268,10 @@ gtk_header_bar_get_title (GtkHeaderBar *bar)
* Sets a custom title for the #GtkHeaderBar.
*
* The title should help a user identify the current view. This
* supersedes any title set by gtk_header_bar_set_title(). To
* achieve the same style as the builtin title, use the title
* style class.
* supersedes the window title label. To achieve the same style as
* the builtin title, use the title style class.
*
* You should set the custom title to %NULL, for the header title
* You should set the custom title to %NULL, for the window title
* label to be visible again.
*/
void
@ -363,6 +335,31 @@ gtk_header_bar_get_custom_title (GtkHeaderBar *bar)
return priv->custom_title;
}
static void
gtk_header_bar_root (GtkWidget *widget)
{
GtkWidget *root;
GTK_WIDGET_CLASS (gtk_header_bar_parent_class)->root (widget);
root = GTK_WIDGET (gtk_widget_get_root (widget));
if (GTK_IS_WINDOW (root))
g_signal_connect_swapped (root, "notify::title",
G_CALLBACK (update_title), widget);
update_title (GTK_HEADER_BAR (widget));
}
static void
gtk_header_bar_unroot (GtkWidget *widget)
{
g_signal_handlers_disconnect_by_func (gtk_widget_get_root (widget),
update_title, widget);
GTK_WIDGET_CLASS (gtk_header_bar_parent_class)->unroot (widget);
}
static void
gtk_header_bar_dispose (GObject *object)
{
@ -382,7 +379,6 @@ gtk_header_bar_finalize (GObject *object)
{
GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (GTK_HEADER_BAR (object));
g_free (priv->title);
g_free (priv->decoration_layout);
G_OBJECT_CLASS (gtk_header_bar_parent_class)->finalize (object);
@ -399,10 +395,6 @@ gtk_header_bar_get_property (GObject *object,
switch (prop_id)
{
case PROP_TITLE:
g_value_set_string (value, priv->title);
break;
case PROP_CUSTOM_TITLE:
g_value_set_object (value, priv->custom_title);
break;
@ -431,10 +423,6 @@ gtk_header_bar_set_property (GObject *object,
switch (prop_id)
{
case PROP_TITLE:
gtk_header_bar_set_title (bar, g_value_get_string (value));
break;
case PROP_CUSTOM_TITLE:
gtk_header_bar_set_custom_title (bar, g_value_get_object (value));
break;
@ -575,18 +563,14 @@ gtk_header_bar_class_init (GtkHeaderBarClass *class)
object_class->get_property = gtk_header_bar_get_property;
object_class->set_property = gtk_header_bar_set_property;
widget_class->root = gtk_header_bar_root;
widget_class->unroot = gtk_header_bar_unroot;
container_class->add = gtk_header_bar_add;
container_class->remove = gtk_header_bar_remove;
container_class->forall = gtk_header_bar_forall;
container_class->child_type = gtk_header_bar_child_type;
header_bar_props[PROP_TITLE] =
g_param_spec_string ("title",
P_("Title"),
P_("The title to display"),
NULL,
G_PARAM_READWRITE);
header_bar_props[PROP_CUSTOM_TITLE] =
g_param_spec_object ("custom-title",
P_("Custom Title"),
@ -641,7 +625,6 @@ gtk_header_bar_init (GtkHeaderBar *bar)
GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
GtkLayoutManager *layout;
priv->title = NULL;
priv->custom_title = NULL;
priv->decoration_layout = NULL;
priv->state = GDK_SURFACE_STATE_WITHDRAWN;

View File

@ -38,11 +38,6 @@ GDK_AVAILABLE_IN_ALL
GType gtk_header_bar_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkWidget *gtk_header_bar_new (void);
GDK_AVAILABLE_IN_ALL
void gtk_header_bar_set_title (GtkHeaderBar *bar,
const gchar *title);
GDK_AVAILABLE_IN_ALL
const gchar *gtk_header_bar_get_title (GtkHeaderBar *bar);
GDK_AVAILABLE_IN_ALL
void gtk_header_bar_set_custom_title (GtkHeaderBar *bar,

View File

@ -2214,29 +2214,6 @@ gtk_window_new (void)
return g_object_new (GTK_TYPE_WINDOW, NULL);
}
static void
gtk_window_set_title_internal (GtkWindow *window,
const gchar *title,
gboolean update_titlebar)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
char *new_title;
g_return_if_fail (GTK_IS_WINDOW (window));
new_title = g_strdup (title);
g_free (priv->title);
priv->title = new_title;
if (_gtk_widget_get_realized (GTK_WIDGET (window)))
gdk_toplevel_set_title (GDK_TOPLEVEL (priv->surface), new_title != NULL ? new_title : "");
if (update_titlebar && GTK_IS_HEADER_BAR (priv->title_box))
gtk_header_bar_set_title (GTK_HEADER_BAR (priv->title_box), new_title != NULL ? new_title : "");
g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_TITLE]);
}
/**
* gtk_window_set_title:
* @window: a #GtkWindow
@ -2254,11 +2231,21 @@ gtk_window_set_title_internal (GtkWindow *window,
**/
void
gtk_window_set_title (GtkWindow *window,
const gchar *title)
const gchar *title)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
char *new_title;
g_return_if_fail (GTK_IS_WINDOW (window));
gtk_window_set_title_internal (window, title, TRUE);
new_title = g_strdup (title);
g_free (priv->title);
priv->title = new_title;
if (_gtk_widget_get_realized (GTK_WIDGET (window)))
gdk_toplevel_set_title (GDK_TOPLEVEL (priv->surface), new_title != NULL ? new_title : "");
g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_TITLE]);
}
/**
@ -4100,21 +4087,6 @@ gtk_window_finalize (GObject *object)
G_OBJECT_CLASS (gtk_window_parent_class)->finalize (object);
}
/* copied from gdksurface-x11.c */
static const gchar *
get_default_title (void)
{
const gchar *title;
title = g_get_application_name ();
if (!title)
title = g_get_prgname ();
if (!title)
title = "";
return title;
}
static gboolean
update_csd_visibility (GtkWindow *window)
{
@ -4151,14 +4123,8 @@ update_window_actions (GtkWindow *window)
static GtkWidget *
create_titlebar (GtkWindow *window)
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
GtkWidget *titlebar;
titlebar = gtk_header_bar_new ();
g_object_set (titlebar,
"title", priv->title ? priv->title : get_default_title (),
"show-title-buttons", TRUE,
NULL);
GtkWidget *titlebar = gtk_header_bar_new ();
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (titlebar), TRUE);
gtk_widget_add_css_class (titlebar, GTK_STYLE_CLASS_TITLEBAR);
gtk_widget_add_css_class (titlebar, "default-decoration");

View File

@ -16,9 +16,9 @@
<property name="type_hint">dialog</property>
<property name="default_width">500</property>
<property name="use_header_bar">1</property>
<property name="title" translatable="yes">Join Chat Room</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="titlebar">
<property name="title" translatable="yes">Join Chat Room</property>
<child>
<object class="GtkButton" id="back_button">
<property name="visible">0</property>

View File

@ -130,7 +130,8 @@ main (int argc, char *argv[])
gtk_init ();
window = gtk_window_new ();
gtk_window_set_titlebar (GTK_WINDOW (window), g_object_new (GTK_TYPE_HEADER_BAR, "visible", TRUE, "title", "GdkGears", NULL));
gtk_window_set_titlebar (GTK_WINDOW (window), gtk_header_bar_new ());
gtk_window_set_title (GTK_WINDOW (window), "GdkGears");
gtk_window_set_default_size (GTK_WINDOW (window), 640, 640);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);

View File

@ -95,7 +95,6 @@ change_header (GtkButton *button, gpointer data)
{
header = gtk_header_bar_new ();
gtk_widget_add_css_class (header, "titlebar");
gtk_header_bar_set_title (GTK_HEADER_BAR (header), "Example header");
widget = gtk_button_new_with_label ("_Close");
gtk_button_set_use_underline (GTK_BUTTON (widget), TRUE);

View File

@ -2,7 +2,6 @@
<object class="GtkWindow" id="window1">
<child>
<object class="GtkHeaderBar" id="headerbar1">
<property name="title">Title</property>
<child type="start">
<object class="GtkButton" id="button1">
<property name="label" translatable="yes">Yes</property>