2017-06-02 00:56:32 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Timm Bäder <mail@baedert.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
* License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
* Author: Timm Bäder <mail@baedert.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2021-02-26 04:17:04 +00:00
|
|
|
* GtkCenterBox:
|
2017-06-02 00:56:32 +00:00
|
|
|
*
|
2021-02-26 04:17:04 +00:00
|
|
|
* `GtkCenterBox` arranges three children in a row, keeping the middle child
|
|
|
|
* centered as well as possible.
|
2017-06-02 00:56:32 +00:00
|
|
|
*
|
2021-02-26 04:17:04 +00:00
|
|
|
* ![An example GtkCenterBox](centerbox.png)
|
|
|
|
*
|
|
|
|
* To add children to `GtkCenterBox`, use [method@Gtk.CenterBox.set_start_widget],
|
|
|
|
* [method@Gtk.CenterBox.set_center_widget] and
|
|
|
|
* [method@Gtk.CenterBox.set_end_widget].
|
2017-06-02 00:56:32 +00:00
|
|
|
*
|
2017-06-05 01:48:41 +00:00
|
|
|
* The sizing and positioning of children can be influenced with the
|
|
|
|
* align and expand properties of the children.
|
|
|
|
*
|
|
|
|
* # GtkCenterBox as GtkBuildable
|
|
|
|
*
|
2021-02-28 00:44:35 +00:00
|
|
|
* The `GtkCenterBox` implementation of the `GtkBuildable` interface
|
2021-02-26 04:17:04 +00:00
|
|
|
* supports placing children in the 3 positions by specifying “start”, “center”
|
|
|
|
* or “end” as the “type” attribute of a <child> element.
|
2017-06-05 01:48:41 +00:00
|
|
|
*
|
2017-06-02 00:56:32 +00:00
|
|
|
* # CSS nodes
|
|
|
|
*
|
2021-02-26 04:17:04 +00:00
|
|
|
* `GtkCenterBox` uses a single CSS node with the name “box”,
|
2017-06-02 00:56:32 +00:00
|
|
|
*
|
2021-02-26 04:17:04 +00:00
|
|
|
* The first child of the `GtkCenterBox` will be allocated depending on the
|
2018-06-10 19:35:19 +00:00
|
|
|
* text direction, i.e. in left-to-right layouts it will be allocated on the
|
|
|
|
* left and in right-to-left layouts on the right.
|
2017-06-02 00:56:32 +00:00
|
|
|
*
|
2017-08-05 17:57:08 +00:00
|
|
|
* In vertical orientation, the nodes of the children are arranged from top to
|
|
|
|
* bottom.
|
2020-11-12 00:36:32 +00:00
|
|
|
*
|
|
|
|
* # Accessibility
|
|
|
|
*
|
2021-02-26 04:17:04 +00:00
|
|
|
* `GtkCenterBox` uses the %GTK_ACCESSIBLE_ROLE_GROUP role.
|
2017-06-02 00:56:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "gtkcenterbox.h"
|
2019-09-11 11:11:02 +00:00
|
|
|
#include "gtkcenterlayout.h"
|
2017-06-02 00:56:32 +00:00
|
|
|
#include "gtkwidgetprivate.h"
|
2017-06-04 02:44:19 +00:00
|
|
|
#include "gtkorientable.h"
|
2017-06-03 20:04:57 +00:00
|
|
|
#include "gtkbuildable.h"
|
2017-06-04 14:11:42 +00:00
|
|
|
#include "gtksizerequest.h"
|
2017-06-10 13:14:16 +00:00
|
|
|
#include "gtktypebuiltins.h"
|
|
|
|
#include "gtkprivate.h"
|
|
|
|
#include "gtkintl.h"
|
2017-06-02 00:56:32 +00:00
|
|
|
|
|
|
|
struct _GtkCenterBox
|
|
|
|
{
|
|
|
|
GtkWidget parent_instance;
|
|
|
|
|
|
|
|
GtkWidget *start_widget;
|
|
|
|
GtkWidget *center_widget;
|
|
|
|
GtkWidget *end_widget;
|
2017-06-04 17:28:43 +00:00
|
|
|
};
|
2017-06-02 00:56:32 +00:00
|
|
|
|
|
|
|
struct _GtkCenterBoxClass
|
|
|
|
{
|
|
|
|
GtkWidgetClass parent_class;
|
|
|
|
};
|
2017-04-22 18:18:17 +00:00
|
|
|
|
|
|
|
|
2017-06-04 17:28:43 +00:00
|
|
|
enum {
|
|
|
|
PROP_0,
|
2017-06-10 13:14:16 +00:00
|
|
|
PROP_BASELINE_POSITION,
|
2017-06-04 17:28:43 +00:00
|
|
|
PROP_ORIENTATION
|
|
|
|
};
|
|
|
|
|
2018-03-08 02:13:57 +00:00
|
|
|
static GtkBuildableIface *parent_buildable_iface;
|
|
|
|
|
2017-06-03 20:04:57 +00:00
|
|
|
static void gtk_center_box_buildable_init (GtkBuildableIface *iface);
|
2017-04-22 18:18:17 +00:00
|
|
|
|
2017-06-03 20:04:57 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkCenterBox, gtk_center_box, GTK_TYPE_WIDGET,
|
2017-06-04 17:28:43 +00:00
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_center_box_buildable_init))
|
2017-06-03 20:04:57 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_center_box_buildable_add_child (GtkBuildable *buildable,
|
|
|
|
GtkBuilder *builder,
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *type)
|
2017-06-03 20:04:57 +00:00
|
|
|
{
|
|
|
|
if (g_strcmp0 (type, "start") == 0)
|
|
|
|
gtk_center_box_set_start_widget (GTK_CENTER_BOX (buildable), GTK_WIDGET (child));
|
|
|
|
else if (g_strcmp0 (type, "center") == 0)
|
|
|
|
gtk_center_box_set_center_widget (GTK_CENTER_BOX (buildable), GTK_WIDGET (child));
|
|
|
|
else if (g_strcmp0 (type, "end") == 0)
|
|
|
|
gtk_center_box_set_end_widget (GTK_CENTER_BOX (buildable), GTK_WIDGET (child));
|
|
|
|
else
|
2018-03-08 02:13:57 +00:00
|
|
|
parent_buildable_iface->add_child (buildable, builder, child, type);
|
2017-06-03 20:04:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_center_box_buildable_init (GtkBuildableIface *iface)
|
|
|
|
{
|
2018-03-08 02:13:57 +00:00
|
|
|
parent_buildable_iface = g_type_interface_peek_parent (iface);
|
|
|
|
|
2017-06-03 20:04:57 +00:00
|
|
|
iface->add_child = gtk_center_box_buildable_add_child;
|
|
|
|
}
|
2017-04-22 18:18:17 +00:00
|
|
|
|
2017-06-04 17:28:43 +00:00
|
|
|
static void
|
|
|
|
gtk_center_box_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkCenterBox *self = GTK_CENTER_BOX (object);
|
2019-09-11 11:11:02 +00:00
|
|
|
GtkLayoutManager *layout = gtk_widget_get_layout_manager (GTK_WIDGET (object));
|
2017-06-04 17:28:43 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2017-06-10 13:14:16 +00:00
|
|
|
case PROP_BASELINE_POSITION:
|
|
|
|
gtk_center_box_set_baseline_position (self, g_value_get_enum (value));
|
|
|
|
break;
|
|
|
|
|
2017-06-04 17:28:43 +00:00
|
|
|
case PROP_ORIENTATION:
|
|
|
|
{
|
|
|
|
GtkOrientation orientation = g_value_get_enum (value);
|
2019-09-11 11:11:02 +00:00
|
|
|
GtkOrientation current = gtk_center_layout_get_orientation (GTK_CENTER_LAYOUT (layout));
|
|
|
|
if (current != orientation)
|
2017-06-04 17:28:43 +00:00
|
|
|
{
|
2019-09-11 11:11:02 +00:00
|
|
|
gtk_center_layout_set_orientation (GTK_CENTER_LAYOUT (layout), orientation);
|
2020-04-23 16:48:29 +00:00
|
|
|
gtk_widget_update_orientation (GTK_WIDGET (self), orientation);
|
2017-06-04 17:28:43 +00:00
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (self));
|
|
|
|
g_object_notify (object, "orientation");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_center_box_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2019-09-11 11:11:02 +00:00
|
|
|
GtkLayoutManager *layout = gtk_widget_get_layout_manager (GTK_WIDGET (object));
|
2017-06-04 17:28:43 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2017-06-10 13:14:16 +00:00
|
|
|
case PROP_BASELINE_POSITION:
|
2019-09-11 11:11:02 +00:00
|
|
|
g_value_set_enum (value, gtk_center_layout_get_baseline_position (GTK_CENTER_LAYOUT (layout)));
|
2017-06-10 13:14:16 +00:00
|
|
|
break;
|
|
|
|
|
2017-06-04 17:28:43 +00:00
|
|
|
case PROP_ORIENTATION:
|
2019-09-11 11:11:02 +00:00
|
|
|
g_value_set_enum (value, gtk_center_layout_get_orientation (GTK_CENTER_LAYOUT (layout)));
|
2017-06-04 17:28:43 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-01 12:09:44 +00:00
|
|
|
static void
|
|
|
|
gtk_center_box_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GtkCenterBox *self = GTK_CENTER_BOX (object);
|
|
|
|
|
2018-11-13 19:53:14 +00:00
|
|
|
g_clear_pointer (&self->start_widget, gtk_widget_unparent);
|
|
|
|
g_clear_pointer (&self->center_widget, gtk_widget_unparent);
|
|
|
|
g_clear_pointer (&self->end_widget, gtk_widget_unparent);
|
2017-09-01 12:09:44 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_center_box_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2017-04-22 18:18:17 +00:00
|
|
|
static void
|
|
|
|
gtk_center_box_class_init (GtkCenterBoxClass *klass)
|
|
|
|
{
|
2017-06-04 17:28:43 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2017-04-22 18:18:17 +00:00
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
2017-06-04 17:28:43 +00:00
|
|
|
object_class->set_property = gtk_center_box_set_property;
|
|
|
|
object_class->get_property = gtk_center_box_get_property;
|
2017-09-01 12:09:44 +00:00
|
|
|
object_class->dispose = gtk_center_box_dispose;
|
2017-06-04 17:28:43 +00:00
|
|
|
|
|
|
|
g_object_class_override_property (object_class, PROP_ORIENTATION, "orientation");
|
|
|
|
|
2021-02-26 04:17:04 +00:00
|
|
|
/**
|
|
|
|
* GtkCenterBox:baseline-position: (attributes org.gtk.Property.get=gtk_center_box_get_baseline_position org.gtk.Property.set=gtk_center_box_set_baseline_position)
|
|
|
|
*
|
|
|
|
* The position of the baseline aligned widget if extra space is available.
|
|
|
|
*/
|
2017-06-10 13:14:16 +00:00
|
|
|
g_object_class_install_property (object_class, PROP_BASELINE_POSITION,
|
|
|
|
g_param_spec_enum ("baseline-position",
|
|
|
|
P_("Baseline position"),
|
|
|
|
P_("The position of the baseline aligned widgets if extra space is available"),
|
|
|
|
GTK_TYPE_BASELINE_POSITION,
|
|
|
|
GTK_BASELINE_POSITION_CENTER,
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
|
|
|
|
|
|
|
|
2019-09-11 11:11:02 +00:00
|
|
|
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_CENTER_LAYOUT);
|
2017-11-18 03:49:57 +00:00
|
|
|
gtk_widget_class_set_css_name (widget_class, I_("box"));
|
2020-11-11 17:54:57 +00:00
|
|
|
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_GROUP);
|
2017-04-22 18:18:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_center_box_init (GtkCenterBox *self)
|
|
|
|
{
|
|
|
|
self->start_widget = NULL;
|
|
|
|
self->center_widget = NULL;
|
|
|
|
self->end_widget = NULL;
|
|
|
|
}
|
|
|
|
|
2017-06-02 00:56:32 +00:00
|
|
|
/**
|
|
|
|
* gtk_center_box_new:
|
|
|
|
*
|
2021-02-26 04:17:04 +00:00
|
|
|
* Creates a new `GtkCenterBox`.
|
2017-06-02 00:56:32 +00:00
|
|
|
*
|
2021-02-26 04:17:04 +00:00
|
|
|
* Returns: the new `GtkCenterBox`.
|
2017-06-02 00:56:32 +00:00
|
|
|
*/
|
2017-04-22 18:18:17 +00:00
|
|
|
GtkWidget *
|
|
|
|
gtk_center_box_new (void)
|
|
|
|
{
|
|
|
|
return GTK_WIDGET (g_object_new (GTK_TYPE_CENTER_BOX, NULL));
|
|
|
|
}
|
|
|
|
|
2017-06-02 00:56:32 +00:00
|
|
|
/**
|
|
|
|
* gtk_center_box_set_start_widget:
|
2021-02-26 04:17:04 +00:00
|
|
|
* @self: a `GtkCenterBox`
|
2021-05-21 00:45:06 +00:00
|
|
|
* @child: (nullable): the new start widget
|
2017-06-02 00:56:32 +00:00
|
|
|
*
|
2021-02-26 04:17:04 +00:00
|
|
|
* Sets the start widget.
|
|
|
|
*
|
|
|
|
* To remove the existing start widget, pass %NULL.
|
2017-06-02 00:56:32 +00:00
|
|
|
*/
|
2017-04-22 18:18:17 +00:00
|
|
|
void
|
|
|
|
gtk_center_box_set_start_widget (GtkCenterBox *self,
|
|
|
|
GtkWidget *child)
|
|
|
|
{
|
2019-09-11 11:11:02 +00:00
|
|
|
GtkLayoutManager *layout_manager;
|
|
|
|
|
2017-04-22 18:18:17 +00:00
|
|
|
if (self->start_widget)
|
|
|
|
gtk_widget_unparent (self->start_widget);
|
|
|
|
|
|
|
|
self->start_widget = child;
|
|
|
|
if (child)
|
2018-06-10 19:35:19 +00:00
|
|
|
gtk_widget_insert_after (child, GTK_WIDGET (self), NULL);
|
2019-09-11 11:11:02 +00:00
|
|
|
|
|
|
|
layout_manager = gtk_widget_get_layout_manager (GTK_WIDGET (self));
|
|
|
|
gtk_center_layout_set_start_widget (GTK_CENTER_LAYOUT (layout_manager), child);
|
2017-04-22 18:18:17 +00:00
|
|
|
}
|
|
|
|
|
2017-06-02 00:56:32 +00:00
|
|
|
/**
|
|
|
|
* gtk_center_box_set_center_widget:
|
2021-02-26 04:17:04 +00:00
|
|
|
* @self: a `GtkCenterBox`
|
2021-05-21 00:45:06 +00:00
|
|
|
* @child: (nullable): the new center widget
|
2017-06-02 00:56:32 +00:00
|
|
|
*
|
2021-02-26 04:17:04 +00:00
|
|
|
* Sets the center widget.
|
|
|
|
*
|
|
|
|
* To remove the existing center widget, pas %NULL.
|
2017-06-02 00:56:32 +00:00
|
|
|
*/
|
2017-04-22 18:18:17 +00:00
|
|
|
void
|
|
|
|
gtk_center_box_set_center_widget (GtkCenterBox *self,
|
2017-08-05 17:56:01 +00:00
|
|
|
GtkWidget *child)
|
2017-04-22 18:18:17 +00:00
|
|
|
{
|
2019-09-11 11:11:02 +00:00
|
|
|
GtkLayoutManager *layout_manager;
|
|
|
|
|
2017-04-22 18:18:17 +00:00
|
|
|
if (self->center_widget)
|
|
|
|
gtk_widget_unparent (self->center_widget);
|
|
|
|
|
|
|
|
self->center_widget = child;
|
|
|
|
if (child)
|
2018-06-10 19:35:19 +00:00
|
|
|
gtk_widget_insert_after (child, GTK_WIDGET (self), self->start_widget);
|
2019-09-11 11:11:02 +00:00
|
|
|
|
|
|
|
layout_manager = gtk_widget_get_layout_manager (GTK_WIDGET (self));
|
|
|
|
gtk_center_layout_set_center_widget (GTK_CENTER_LAYOUT (layout_manager), child);
|
2017-04-22 18:18:17 +00:00
|
|
|
}
|
|
|
|
|
2017-06-02 00:56:32 +00:00
|
|
|
/**
|
|
|
|
* gtk_center_box_set_end_widget:
|
2021-02-26 04:17:04 +00:00
|
|
|
* @self: a `GtkCenterBox`
|
2021-05-21 00:45:06 +00:00
|
|
|
* @child: (nullable): the new end widget
|
2017-06-02 00:56:32 +00:00
|
|
|
*
|
2021-02-26 04:17:04 +00:00
|
|
|
* Sets the end widget.
|
|
|
|
*
|
|
|
|
* To remove the existing end widget, pass %NULL.
|
2017-06-02 00:56:32 +00:00
|
|
|
*/
|
2017-04-22 18:18:17 +00:00
|
|
|
void
|
|
|
|
gtk_center_box_set_end_widget (GtkCenterBox *self,
|
|
|
|
GtkWidget *child)
|
|
|
|
{
|
2019-09-11 11:11:02 +00:00
|
|
|
GtkLayoutManager *layout_manager;
|
|
|
|
|
2017-04-22 18:18:17 +00:00
|
|
|
if (self->end_widget)
|
|
|
|
gtk_widget_unparent (self->end_widget);
|
|
|
|
|
|
|
|
self->end_widget = child;
|
|
|
|
if (child)
|
2018-06-10 19:35:19 +00:00
|
|
|
gtk_widget_insert_before (child, GTK_WIDGET (self), NULL);
|
2019-09-11 11:11:02 +00:00
|
|
|
|
|
|
|
layout_manager = gtk_widget_get_layout_manager (GTK_WIDGET (self));
|
|
|
|
gtk_center_layout_set_end_widget (GTK_CENTER_LAYOUT (layout_manager), child);
|
2017-04-22 18:18:17 +00:00
|
|
|
}
|
|
|
|
|
2017-06-02 00:56:32 +00:00
|
|
|
/**
|
|
|
|
* gtk_center_box_get_start_widget:
|
2021-02-26 04:17:04 +00:00
|
|
|
* @self: a `GtkCenterBox`
|
2017-06-02 00:56:32 +00:00
|
|
|
*
|
2017-08-05 17:56:01 +00:00
|
|
|
* Gets the start widget, or %NULL if there is none.
|
2017-06-02 00:56:32 +00:00
|
|
|
*
|
2017-08-05 17:56:01 +00:00
|
|
|
* Returns: (transfer none) (nullable): the start widget.
|
2017-06-02 00:56:32 +00:00
|
|
|
*/
|
2017-04-22 18:18:17 +00:00
|
|
|
GtkWidget *
|
|
|
|
gtk_center_box_get_start_widget (GtkCenterBox *self)
|
|
|
|
{
|
|
|
|
return self->start_widget;
|
|
|
|
}
|
|
|
|
|
2017-06-02 00:56:32 +00:00
|
|
|
/**
|
|
|
|
* gtk_center_box_get_center_widget:
|
2021-02-26 04:17:04 +00:00
|
|
|
* @self: a `GtkCenterBox`
|
2017-06-02 00:56:32 +00:00
|
|
|
*
|
2017-08-05 17:56:01 +00:00
|
|
|
* Gets the center widget, or %NULL if there is none.
|
2017-06-02 00:56:32 +00:00
|
|
|
*
|
2017-08-05 17:56:01 +00:00
|
|
|
* Returns: (transfer none) (nullable): the center widget.
|
2017-06-02 00:56:32 +00:00
|
|
|
*/
|
2017-04-22 18:18:17 +00:00
|
|
|
GtkWidget *
|
|
|
|
gtk_center_box_get_center_widget (GtkCenterBox *self)
|
|
|
|
{
|
|
|
|
return self->center_widget;
|
|
|
|
}
|
|
|
|
|
2017-06-02 00:56:32 +00:00
|
|
|
/**
|
|
|
|
* gtk_center_box_get_end_widget:
|
2021-02-26 04:17:04 +00:00
|
|
|
* @self: a `GtkCenterBox`
|
2017-06-02 00:56:32 +00:00
|
|
|
*
|
2017-08-05 17:56:01 +00:00
|
|
|
* Gets the end widget, or %NULL if there is none.
|
2017-06-02 00:56:32 +00:00
|
|
|
*
|
2017-08-05 17:56:01 +00:00
|
|
|
* Returns: (transfer none) (nullable): the end widget.
|
2017-06-02 00:56:32 +00:00
|
|
|
*/
|
2017-04-22 18:18:17 +00:00
|
|
|
GtkWidget *
|
|
|
|
gtk_center_box_get_end_widget (GtkCenterBox *self)
|
|
|
|
{
|
|
|
|
return self->end_widget;
|
|
|
|
}
|
2017-06-10 13:14:16 +00:00
|
|
|
|
|
|
|
/**
|
2021-02-26 04:17:04 +00:00
|
|
|
* gtk_center_box_set_baseline_position: (attributes org.gtk.Method.set_property=baseline-position)
|
|
|
|
* @self: a `GtkCenterBox`
|
|
|
|
* @position: a `GtkBaselinePosition`
|
2017-06-10 13:14:16 +00:00
|
|
|
*
|
|
|
|
* Sets the baseline position of a center box.
|
|
|
|
*
|
|
|
|
* This affects only horizontal boxes with at least one baseline
|
|
|
|
* aligned child. If there is more vertical space available than
|
|
|
|
* requested, and the baseline is not allocated by the parent then
|
|
|
|
* @position is used to allocate the baseline wrt. the extra space
|
|
|
|
* available.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_center_box_set_baseline_position (GtkCenterBox *self,
|
|
|
|
GtkBaselinePosition position)
|
|
|
|
{
|
2019-09-11 11:11:02 +00:00
|
|
|
GtkBaselinePosition current_position;
|
|
|
|
GtkLayoutManager *layout;
|
|
|
|
|
2017-06-10 13:14:16 +00:00
|
|
|
g_return_if_fail (GTK_IS_CENTER_BOX (self));
|
|
|
|
|
2019-09-11 11:11:02 +00:00
|
|
|
layout = gtk_widget_get_layout_manager (GTK_WIDGET (self));
|
|
|
|
current_position = gtk_center_layout_get_baseline_position (GTK_CENTER_LAYOUT (layout));
|
|
|
|
if (current_position != position)
|
2017-06-10 13:14:16 +00:00
|
|
|
{
|
2019-09-11 11:11:02 +00:00
|
|
|
gtk_center_layout_set_baseline_position (GTK_CENTER_LAYOUT (layout), position);
|
2017-06-10 13:14:16 +00:00
|
|
|
g_object_notify (G_OBJECT (self), "baseline-position");
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (self));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-26 04:17:04 +00:00
|
|
|
* gtk_center_box_get_baseline_position: (attributes org.gtk.Method.get_property=baseline-position)
|
|
|
|
* @self: a `GtkCenterBox`
|
2017-06-10 13:14:16 +00:00
|
|
|
*
|
|
|
|
* Gets the value set by gtk_center_box_set_baseline_position().
|
|
|
|
*
|
|
|
|
* Returns: the baseline position
|
|
|
|
*/
|
|
|
|
GtkBaselinePosition
|
|
|
|
gtk_center_box_get_baseline_position (GtkCenterBox *self)
|
|
|
|
{
|
2019-09-11 11:11:02 +00:00
|
|
|
GtkLayoutManager *layout;
|
|
|
|
|
2017-06-10 13:14:16 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_CENTER_BOX (self), GTK_BASELINE_POSITION_CENTER);
|
|
|
|
|
2019-09-11 11:11:02 +00:00
|
|
|
layout = gtk_widget_get_layout_manager (GTK_WIDGET (self));
|
|
|
|
|
|
|
|
return gtk_center_layout_get_baseline_position (GTK_CENTER_LAYOUT (layout));
|
2017-06-10 13:14:16 +00:00
|
|
|
}
|
|
|
|
|