Merge branch 'wip/otte/titlebar' into 'master'
window: Add a titlebar property See merge request GNOME/gtk!3982
This commit is contained in:
@@ -282,6 +282,7 @@ enum {
|
||||
PROP_DEFAULT_WIDGET,
|
||||
PROP_FOCUS_WIDGET,
|
||||
PROP_CHILD,
|
||||
PROP_TITLEBAR,
|
||||
PROP_HANDLE_MENUBAR_ACCEL,
|
||||
|
||||
/* Readonly properties */
|
||||
@@ -1036,6 +1037,20 @@ gtk_window_class_init (GtkWindowClass *klass)
|
||||
GTK_TYPE_WIDGET,
|
||||
GTK_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkWindow:titlebar: (attributes org.gtk.Property.get=gtk_window_get_titlebar org.gtk.Property.set=gtk_window_set_titlebar)
|
||||
*
|
||||
* The titlebar widget.
|
||||
*
|
||||
* Since: 4.6
|
||||
*/
|
||||
window_props[PROP_TITLEBAR] =
|
||||
g_param_spec_object ("titlebar",
|
||||
P_("Titlebar"),
|
||||
P_("The titlebar widget"),
|
||||
GTK_TYPE_WIDGET,
|
||||
GTK_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkWindow:handle-menubar-accel: (attributes org.gtk.Property.get=gtk_window_get_handle_menubar_accel org.gtk.Property.set=gtk_window_set_handle_menubar_accel)
|
||||
*
|
||||
@@ -1815,6 +1830,9 @@ gtk_window_set_property (GObject *object,
|
||||
case PROP_CHILD:
|
||||
gtk_window_set_child (window, g_value_get_object (value));
|
||||
break;
|
||||
case PROP_TITLEBAR:
|
||||
gtk_window_set_titlebar (window, g_value_get_object (value));
|
||||
break;
|
||||
case PROP_HANDLE_MENUBAR_ACCEL:
|
||||
gtk_window_set_handle_menubar_accel (window, g_value_get_boolean (value));
|
||||
break;
|
||||
@@ -1898,6 +1916,9 @@ gtk_window_get_property (GObject *object,
|
||||
case PROP_CHILD:
|
||||
g_value_set_object (value, gtk_window_get_child (window));
|
||||
break;
|
||||
case PROP_TITLEBAR:
|
||||
g_value_set_object (value, gtk_window_get_titlebar (window));
|
||||
break;
|
||||
case PROP_HANDLE_MENUBAR_ACCEL:
|
||||
g_value_set_boolean (value, gtk_window_get_handle_menubar_accel (window));
|
||||
break;
|
||||
@@ -2974,7 +2995,7 @@ gtk_window_enable_csd (GtkWindow *window)
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_window_set_titlebar:
|
||||
* gtk_window_set_titlebar: (attributes org.gtk.Method.set_property=titlebar)
|
||||
* @window: a `GtkWindow`
|
||||
* @titlebar: (nullable): the widget to use as titlebar
|
||||
*
|
||||
@@ -3000,6 +3021,9 @@ gtk_window_set_titlebar (GtkWindow *window,
|
||||
|
||||
g_return_if_fail (GTK_IS_WINDOW (window));
|
||||
|
||||
if (priv->titlebar == titlebar)
|
||||
return;
|
||||
|
||||
if ((!priv->title_box && titlebar) || (priv->title_box && !titlebar))
|
||||
{
|
||||
was_mapped = _gtk_widget_get_mapped (widget);
|
||||
@@ -3020,25 +3044,27 @@ gtk_window_set_titlebar (GtkWindow *window,
|
||||
priv->client_decorated = FALSE;
|
||||
gtk_widget_remove_css_class (widget, "csd");
|
||||
gtk_widget_remove_css_class (widget, "solid-csd");
|
||||
}
|
||||
else
|
||||
{
|
||||
priv->use_client_shadow = gtk_window_supports_client_shadow (window);
|
||||
|
||||
goto out;
|
||||
gtk_window_enable_csd (window);
|
||||
priv->titlebar = titlebar;
|
||||
priv->title_box = titlebar;
|
||||
gtk_widget_insert_before (priv->title_box, widget, NULL);
|
||||
|
||||
gtk_widget_add_css_class (titlebar, "titlebar");
|
||||
}
|
||||
|
||||
priv->use_client_shadow = gtk_window_supports_client_shadow (window);
|
||||
|
||||
gtk_window_enable_csd (window);
|
||||
priv->title_box = titlebar;
|
||||
gtk_widget_insert_before (priv->title_box, widget, NULL);
|
||||
|
||||
gtk_widget_add_css_class (titlebar, "titlebar");
|
||||
|
||||
out:
|
||||
if (was_mapped)
|
||||
gtk_widget_map (widget);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_TITLEBAR]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_window_get_titlebar:
|
||||
* gtk_window_get_titlebar: (attributes org.gtk.Method.get_property=titlebar)
|
||||
* @window: a `GtkWindow`
|
||||
*
|
||||
* Returns the custom titlebar that has been set with
|
||||
@@ -3053,11 +3079,7 @@ gtk_window_get_titlebar (GtkWindow *window)
|
||||
|
||||
g_return_val_if_fail (GTK_IS_WINDOW (window), NULL);
|
||||
|
||||
/* Don't return the internal titlebar */
|
||||
if (priv->title_box == priv->titlebar)
|
||||
return NULL;
|
||||
|
||||
return priv->title_box;
|
||||
return priv->titlebar;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4282,12 +4304,11 @@ gtk_window_realize (GtkWidget *widget)
|
||||
|
||||
if (priv->title_box == NULL)
|
||||
{
|
||||
priv->titlebar = gtk_header_bar_new ();
|
||||
gtk_widget_add_css_class (priv->titlebar, "titlebar");
|
||||
gtk_widget_add_css_class (priv->titlebar, "default-decoration");
|
||||
priv->title_box = gtk_header_bar_new ();
|
||||
gtk_widget_add_css_class (priv->title_box, "titlebar");
|
||||
gtk_widget_add_css_class (priv->title_box, "default-decoration");
|
||||
|
||||
gtk_widget_insert_before (priv->titlebar, widget, NULL);
|
||||
priv->title_box = priv->titlebar;
|
||||
gtk_widget_insert_before (priv->title_box, widget, NULL);
|
||||
}
|
||||
|
||||
update_window_actions (window);
|
||||
|
||||
52
testsuite/reftests/default-size-undecorated.ref.ui
Normal file
52
testsuite/reftests/default-size-undecorated.ref.ui
Normal file
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="width_request">600</property>
|
||||
<property name="height_request">400</property>
|
||||
<property name="decorated">0</property>
|
||||
<property name="child">
|
||||
<object class="GtkGrid">
|
||||
<property name="valign">center</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="column-spacing">10</property>
|
||||
<property name="row-spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">default width:</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">600</property>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">default height:</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">400</property>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
||||
56
testsuite/reftests/default-size-undecorated.ui
Normal file
56
testsuite/reftests/default-size-undecorated.ui
Normal file
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="width_request">600</property>
|
||||
<property name="height_request">400</property>
|
||||
<property name="decorated">0</property>
|
||||
<property name="child">
|
||||
<object class="GtkGrid">
|
||||
<property name="valign">center</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="column-spacing">10</property>
|
||||
<property name="row-spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">default width:</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<!-- This binding should never do anything because the text is set to
|
||||
the correct value from the start, all we do is make sure it doesn't change -->
|
||||
<property name="label" bind-source="window" bind-property="default-width">600</property>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">default height:</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<!-- This binding should never do anything because the text is set to
|
||||
the correct value from the start, all we do is make sure it doesn't change -->
|
||||
<property name="label" bind-source="window" bind-property="default-height">400</property>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
||||
55
testsuite/reftests/default-size-with-titlebar.ref.ui
Normal file
55
testsuite/reftests/default-size-with-titlebar.ref.ui
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="width_request">600</property>
|
||||
<property name="height_request">400</property>
|
||||
<property name="title">size?</property>
|
||||
<property name="titlebar">
|
||||
<object class="GtkHeaderBar" />
|
||||
</property>
|
||||
<property name="child">
|
||||
<object class="GtkGrid">
|
||||
<property name="valign">center</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="column-spacing">10</property>
|
||||
<property name="row-spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">default width:</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">600</property>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">default height:</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">400</property>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
||||
59
testsuite/reftests/default-size-with-titlebar.ui
Normal file
59
testsuite/reftests/default-size-with-titlebar.ui
Normal file
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="width_request">600</property>
|
||||
<property name="height_request">400</property>
|
||||
<property name="title">size?</property>
|
||||
<property name="titlebar">
|
||||
<object class="GtkHeaderBar" />
|
||||
</property>
|
||||
<property name="child">
|
||||
<object class="GtkGrid">
|
||||
<property name="valign">center</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="column-spacing">10</property>
|
||||
<property name="row-spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">default width:</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<!-- This binding should never do anything because the text is set to
|
||||
the correct value from the start, all we do is make sure it doesn't change -->
|
||||
<property name="label" bind-source="window" bind-property="default-width">600</property>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">default height:</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<!-- This binding should never do anything because the text is set to
|
||||
the correct value from the start, all we do is make sure it doesn't change -->
|
||||
<property name="label" bind-source="window" bind-property="default-height">400</property>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
||||
52
testsuite/reftests/default-size-without-titlebar.ref.ui
Normal file
52
testsuite/reftests/default-size-without-titlebar.ref.ui
Normal file
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="width_request">600</property>
|
||||
<property name="height_request">400</property>
|
||||
<property name="title">size?</property>
|
||||
<property name="child">
|
||||
<object class="GtkGrid">
|
||||
<property name="valign">center</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="column-spacing">10</property>
|
||||
<property name="row-spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">default width:</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">600</property>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">default height:</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">400</property>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
||||
56
testsuite/reftests/default-size-without-titlebar.ui
Normal file
56
testsuite/reftests/default-size-without-titlebar.ui
Normal file
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<object class="GtkWindow" id="window">
|
||||
<property name="width_request">600</property>
|
||||
<property name="height_request">400</property>
|
||||
<property name="title">size?</property>
|
||||
<property name="child">
|
||||
<object class="GtkGrid">
|
||||
<property name="valign">center</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="column-spacing">10</property>
|
||||
<property name="row-spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">default width:</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<!-- This binding should never do anything because the text is set to
|
||||
the correct value from the start, all we do is make sure it doesn't change -->
|
||||
<property name="label" bind-source="window" bind-property="default-width">600</property>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label">default height:</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<!-- This binding should never do anything because the text is set to
|
||||
the correct value from the start, all we do is make sure it doesn't change -->
|
||||
<property name="label" bind-source="window" bind-property="default-height">400</property>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
||||
@@ -225,6 +225,12 @@ testdata = [
|
||||
'data-url.css',
|
||||
'data-url.ref.ui',
|
||||
'data-url.ui',
|
||||
'default-size-undecorated.ui',
|
||||
'default-size-undecorated.ref.ui',
|
||||
'default-size-with-titlebar.ui',
|
||||
'default-size-with-titlebar.ref.ui',
|
||||
'default-size-without-titlebar.ui',
|
||||
'default-size-without-titlebar.ref.ui',
|
||||
'fixed-widget-stacking.ref.ui',
|
||||
'fixed-widget-stacking.ui',
|
||||
'flipping-icons.ref.ui',
|
||||
|
||||
Reference in New Issue
Block a user