2010-09-27 14:44:31 +00:00
|
|
|
|
/* GTK - The GIMP Toolkit
|
|
|
|
|
* Copyright (C) 2010 Red Hat, Inc.
|
|
|
|
|
* Author: Matthias Clasen
|
|
|
|
|
*
|
|
|
|
|
* This library 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 library 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
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2010-09-27 14:44:31 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2011-02-17 16:51:16 +00:00
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2010-09-27 14:44:31 +00:00
|
|
|
|
#include "gtkgrid.h"
|
|
|
|
|
|
2020-05-07 18:56:37 +00:00
|
|
|
|
#include "gtkbuildable.h"
|
2016-12-10 03:32:19 +00:00
|
|
|
|
#include "gtkcsspositionvalueprivate.h"
|
2019-04-04 17:40:34 +00:00
|
|
|
|
#include "gtkgridlayout.h"
|
2010-09-27 14:44:31 +00:00
|
|
|
|
#include "gtkintl.h"
|
2020-04-23 16:48:29 +00:00
|
|
|
|
#include "gtkorientable.h"
|
2019-04-04 17:40:34 +00:00
|
|
|
|
#include "gtkprivate.h"
|
|
|
|
|
#include "gtksizerequest.h"
|
2021-01-28 04:07:55 +00:00
|
|
|
|
#include "gtkcssnodeprivate.h"
|
2019-04-04 17:40:34 +00:00
|
|
|
|
#include "gtkwidgetprivate.h"
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* GtkGrid:
|
2010-09-27 14:44:31 +00:00
|
|
|
|
*
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* `GtkGrid` is a container which arranges its child widgets in
|
|
|
|
|
* rows and columns.
|
2010-09-27 14:44:31 +00:00
|
|
|
|
*
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* ![An example GtkGrid](grid.png)
|
|
|
|
|
*
|
|
|
|
|
* It supports arbitrary positions and horizontal/vertical spans.
|
|
|
|
|
*
|
|
|
|
|
* Children are added using [method@Gtk.Grid.attach]. They can span multiple
|
|
|
|
|
* rows or columns. It is also possible to add a child next to an existing
|
|
|
|
|
* child, using [method@Gtk.Grid.attach_next_to]. To remove a child from the
|
|
|
|
|
* grid, use [method@Gtk.Grid.remove].
|
|
|
|
|
*
|
|
|
|
|
* The behaviour of `GtkGrid` when several children occupy the same grid
|
|
|
|
|
* cell is undefined.
|
2015-12-06 06:52:45 +00:00
|
|
|
|
*
|
2021-01-30 21:05:40 +00:00
|
|
|
|
* # GtkGrid as GtkBuildable
|
|
|
|
|
*
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* Every child in a `GtkGrid` has access to a custom [iface@Gtk.Buildable]
|
|
|
|
|
* element, called ´<layout>´. It can by used to specify a position in the
|
|
|
|
|
* grid and optionally spans. All properties that can be used in the ´<layout>´
|
|
|
|
|
* element are implemented by [class@Gtk.GridLayoutChild].
|
2021-01-30 21:05:40 +00:00
|
|
|
|
*
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* It is implemented by `GtkWidget` using [class@Gtk.LayoutManager].
|
2021-01-30 21:05:40 +00:00
|
|
|
|
*
|
|
|
|
|
* To showcase it, here is a simple example:
|
|
|
|
|
*
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* ```xml
|
2021-01-30 21:05:40 +00:00
|
|
|
|
* <object class="GtkGrid" id="my_grid">
|
|
|
|
|
* <child>
|
|
|
|
|
* <object class="GtkButton" id="button1">
|
|
|
|
|
* <property name="label">Button 1</property>
|
|
|
|
|
* <layout>
|
|
|
|
|
* <property name="column">0</property>
|
|
|
|
|
* <property name="row">0</property>
|
|
|
|
|
* </layout>
|
|
|
|
|
* </object>
|
|
|
|
|
* </child>
|
|
|
|
|
* <child>
|
|
|
|
|
* <object class="GtkButton" id="button2">
|
|
|
|
|
* <property name="label">Button 2</property>
|
|
|
|
|
* <layout>
|
|
|
|
|
* <property name="column">1</property>
|
|
|
|
|
* <property name="row">0</property>
|
|
|
|
|
* </layout>
|
|
|
|
|
* </object>
|
|
|
|
|
* </child>
|
|
|
|
|
* <child>
|
|
|
|
|
* <object class="GtkButton" id="button3">
|
|
|
|
|
* <property name="label">Button 3</property>
|
|
|
|
|
* <layout>
|
|
|
|
|
* <property name="column">2</property>
|
|
|
|
|
* <property name="row">0</property>
|
|
|
|
|
* <property name="row-span">2</property>
|
|
|
|
|
* </layout>
|
|
|
|
|
* </object>
|
|
|
|
|
* </child>
|
|
|
|
|
* <child>
|
|
|
|
|
* <object class="GtkButton" id="button4">
|
|
|
|
|
* <property name="label">Button 4</property>
|
|
|
|
|
* <layout>
|
|
|
|
|
* <property name="column">0</property>
|
|
|
|
|
* <property name="row">1</property>
|
|
|
|
|
* <property name="column-span">2</property>
|
|
|
|
|
* </layout>
|
|
|
|
|
* </object>
|
|
|
|
|
* </child>
|
|
|
|
|
* </object>
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* ```
|
2021-01-30 21:05:40 +00:00
|
|
|
|
*
|
|
|
|
|
* It organizes the first two buttons side-by-side in one cell each.
|
|
|
|
|
* The third button is in the last column but spans across two rows.
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* This is defined by the ´row-span´ property. The last button is
|
|
|
|
|
* located in the second row and spans across two columns, which is
|
|
|
|
|
* defined by the ´column-span´ property.
|
2021-01-30 21:05:40 +00:00
|
|
|
|
*
|
2015-12-06 06:52:45 +00:00
|
|
|
|
* # CSS nodes
|
|
|
|
|
*
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* `GtkGrid` uses a single CSS node with name `grid`.
|
2020-11-12 00:36:32 +00:00
|
|
|
|
*
|
|
|
|
|
* # Accessibility
|
|
|
|
|
*
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* `GtkGrid` uses the %GTK_ACCESSIBLE_ROLE_GROUP role.
|
2010-09-27 14:44:31 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
typedef struct
|
2010-09-27 14:44:31 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
GtkLayoutManager *layout_manager;
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
|
|
|
|
GtkOrientation orientation;
|
2019-04-04 17:40:34 +00:00
|
|
|
|
} GtkGridPrivate;
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_ROW_SPACING,
|
|
|
|
|
PROP_COLUMN_SPACING,
|
|
|
|
|
PROP_ROW_HOMOGENEOUS,
|
2013-03-21 10:09:43 +00:00
|
|
|
|
PROP_COLUMN_HOMOGENEOUS,
|
2010-11-14 02:49:26 +00:00
|
|
|
|
PROP_BASELINE_ROW,
|
2014-01-25 18:49:27 +00:00
|
|
|
|
N_PROPERTIES,
|
2019-04-04 17:40:34 +00:00
|
|
|
|
|
|
|
|
|
/* GtkOrientable */
|
2014-01-25 18:49:27 +00:00
|
|
|
|
PROP_ORIENTATION
|
2010-09-27 14:44:31 +00:00
|
|
|
|
};
|
|
|
|
|
|
2020-05-07 18:56:37 +00:00
|
|
|
|
static void gtk_grid_buildable_iface_init (GtkBuildableIface *iface);
|
|
|
|
|
|
2010-11-14 02:49:26 +00:00
|
|
|
|
static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, };
|
|
|
|
|
|
2020-05-07 18:56:37 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkGrid, gtk_grid, GTK_TYPE_WIDGET,
|
2013-06-27 19:02:52 +00:00
|
|
|
|
G_ADD_PRIVATE (GtkGrid)
|
2020-05-07 18:56:37 +00:00
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)
|
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
|
|
|
|
gtk_grid_buildable_iface_init))
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_grid_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GtkGrid *grid = GTK_GRID (object);
|
2017-10-08 08:40:48 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_ORIENTATION:
|
|
|
|
|
g_value_set_enum (value, priv->orientation);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_ROW_SPACING:
|
2019-04-04 17:40:34 +00:00
|
|
|
|
g_value_set_int (value, gtk_grid_layout_get_row_spacing (GTK_GRID_LAYOUT (priv->layout_manager)));
|
2010-09-27 14:44:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_COLUMN_SPACING:
|
2019-04-04 17:40:34 +00:00
|
|
|
|
g_value_set_int (value, gtk_grid_layout_get_column_spacing (GTK_GRID_LAYOUT (priv->layout_manager)));
|
2010-09-27 14:44:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_ROW_HOMOGENEOUS:
|
2019-04-04 17:40:34 +00:00
|
|
|
|
g_value_set_boolean (value, gtk_grid_layout_get_row_homogeneous (GTK_GRID_LAYOUT (priv->layout_manager)));
|
2010-09-27 14:44:31 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_COLUMN_HOMOGENEOUS:
|
2019-04-04 17:40:34 +00:00
|
|
|
|
g_value_set_boolean (value, gtk_grid_layout_get_column_homogeneous (GTK_GRID_LAYOUT (priv->layout_manager)));
|
2010-09-27 14:44:31 +00:00
|
|
|
|
break;
|
2011-09-03 00:04:06 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
case PROP_BASELINE_ROW:
|
|
|
|
|
g_value_set_int (value, gtk_grid_layout_get_baseline_row (GTK_GRID_LAYOUT (priv->layout_manager)));
|
|
|
|
|
break;
|
2013-03-21 10:09:43 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
2013-03-21 10:09:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-27 14:44:31 +00:00
|
|
|
|
static void
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gtk_grid_set_orientation (GtkGrid *grid,
|
|
|
|
|
GtkOrientation orientation)
|
2010-09-27 14:44:31 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
if (priv->orientation != orientation)
|
2010-09-27 14:44:31 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
priv->orientation = orientation;
|
2020-04-23 16:48:29 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_update_orientation (GTK_WIDGET (grid), priv->orientation);
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
g_object_notify (G_OBJECT (grid), "orientation");
|
2010-09-27 14:44:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gtk_grid_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
2010-09-27 14:44:31 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
GtkGrid *grid = GTK_GRID (object);
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_ORIENTATION:
|
|
|
|
|
gtk_grid_set_orientation (grid, g_value_get_enum (value));
|
|
|
|
|
break;
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
case PROP_ROW_SPACING:
|
|
|
|
|
gtk_grid_set_row_spacing (grid, g_value_get_int (value));
|
|
|
|
|
break;
|
2013-03-21 10:09:43 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
case PROP_COLUMN_SPACING:
|
|
|
|
|
gtk_grid_set_column_spacing (grid, g_value_get_int (value));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_ROW_HOMOGENEOUS:
|
|
|
|
|
gtk_grid_set_row_homogeneous (grid, g_value_get_boolean (value));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_COLUMN_HOMOGENEOUS:
|
|
|
|
|
gtk_grid_set_column_homogeneous (grid, g_value_get_boolean (value));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_BASELINE_ROW:
|
|
|
|
|
gtk_grid_set_baseline_row (grid, g_value_get_int (value));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
2010-09-27 14:44:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-04-04 17:40:34 +00:00
|
|
|
|
grid_attach (GtkGrid *grid,
|
|
|
|
|
GtkWidget *widget,
|
2020-08-02 18:13:14 +00:00
|
|
|
|
int column,
|
|
|
|
|
int row,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int width,
|
|
|
|
|
int height)
|
2010-09-27 14:44:31 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
|
|
|
|
GtkGridLayoutChild *grid_child;
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gtk_widget_set_parent (widget, GTK_WIDGET (grid));
|
2011-05-13 00:12:51 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
grid_child = GTK_GRID_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout_manager, widget));
|
2020-08-02 18:13:14 +00:00
|
|
|
|
gtk_grid_layout_child_set_column (grid_child, column);
|
|
|
|
|
gtk_grid_layout_child_set_row (grid_child, row);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gtk_grid_layout_child_set_column_span (grid_child, width);
|
|
|
|
|
gtk_grid_layout_child_set_row_span (grid_child, height);
|
|
|
|
|
}
|
2013-03-21 10:09:43 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
/* Find the position 'touching' existing
|
|
|
|
|
* children. @orientation and @max determine
|
|
|
|
|
* from which direction to approach (horizontal
|
|
|
|
|
* + max = right, vertical + !max = top, etc).
|
|
|
|
|
* @op_pos, @op_span determine the rows/columns
|
|
|
|
|
* in which the touching has to happen.
|
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
static int
|
2019-04-04 17:40:34 +00:00
|
|
|
|
find_attach_position (GtkGrid *grid,
|
|
|
|
|
GtkOrientation orientation,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int op_pos,
|
|
|
|
|
int op_span,
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gboolean max)
|
|
|
|
|
{
|
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
|
|
|
|
GtkWidget *child;
|
|
|
|
|
gboolean hit;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int pos;
|
2013-03-21 10:09:43 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
if (max)
|
|
|
|
|
pos = -G_MAXINT;
|
|
|
|
|
else
|
|
|
|
|
pos = G_MAXINT;
|
2011-05-13 00:12:51 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
hit = FALSE;
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
for (child = gtk_widget_get_first_child (GTK_WIDGET (grid));
|
|
|
|
|
child != NULL;
|
|
|
|
|
child = gtk_widget_get_next_sibling (child))
|
|
|
|
|
{
|
|
|
|
|
GtkGridLayoutChild *grid_child;
|
|
|
|
|
int attach_pos = 0, attach_span = 0;
|
|
|
|
|
int opposite_pos = 0, opposite_span = 0;
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
grid_child = GTK_GRID_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout_manager, child));
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
switch (orientation)
|
|
|
|
|
{
|
|
|
|
|
case GTK_ORIENTATION_HORIZONTAL:
|
2020-08-02 18:13:14 +00:00
|
|
|
|
attach_pos = gtk_grid_layout_child_get_column (grid_child);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
attach_span = gtk_grid_layout_child_get_column_span (grid_child);
|
2020-08-02 18:13:14 +00:00
|
|
|
|
opposite_pos = gtk_grid_layout_child_get_row (grid_child);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
opposite_span = gtk_grid_layout_child_get_row_span (grid_child);
|
|
|
|
|
break;
|
2011-05-13 00:12:51 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
case GTK_ORIENTATION_VERTICAL:
|
2020-08-02 18:13:14 +00:00
|
|
|
|
attach_pos = gtk_grid_layout_child_get_row (grid_child);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
attach_span = gtk_grid_layout_child_get_row_span (grid_child);
|
2020-08-02 18:13:14 +00:00
|
|
|
|
opposite_pos = gtk_grid_layout_child_get_column (grid_child);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
opposite_span = gtk_grid_layout_child_get_column_span (grid_child);
|
|
|
|
|
break;
|
2013-03-21 10:09:43 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-03-21 10:09:43 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
/* check if the ranges overlap */
|
|
|
|
|
if (opposite_pos <= op_pos + op_span && op_pos <= opposite_pos + opposite_span)
|
|
|
|
|
{
|
|
|
|
|
hit = TRUE;
|
2011-05-13 00:12:51 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
if (max)
|
|
|
|
|
pos = MAX (pos, attach_pos + attach_span);
|
|
|
|
|
else
|
|
|
|
|
pos = MIN (pos, attach_pos);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
if (!hit)
|
|
|
|
|
pos = 0;
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
return pos;
|
2010-09-27 14:44:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-05-07 18:56:37 +00:00
|
|
|
|
gtk_grid_compute_expand (GtkWidget *widget,
|
|
|
|
|
gboolean *hexpand_p,
|
|
|
|
|
gboolean *vexpand_p)
|
2013-03-21 10:09:43 +00:00
|
|
|
|
{
|
2020-05-07 18:56:37 +00:00
|
|
|
|
GtkWidget *w;
|
|
|
|
|
gboolean hexpand = FALSE;
|
|
|
|
|
gboolean vexpand = FALSE;
|
|
|
|
|
|
|
|
|
|
for (w = gtk_widget_get_first_child (widget);
|
|
|
|
|
w != NULL;
|
|
|
|
|
w = gtk_widget_get_next_sibling (w))
|
|
|
|
|
{
|
|
|
|
|
hexpand = hexpand || gtk_widget_compute_expand (w, GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
|
vexpand = vexpand || gtk_widget_compute_expand (w, GTK_ORIENTATION_VERTICAL);
|
|
|
|
|
}
|
2013-03-21 10:09:43 +00:00
|
|
|
|
|
2020-05-07 18:56:37 +00:00
|
|
|
|
*hexpand_p = hexpand;
|
|
|
|
|
*vexpand_p = vexpand;
|
2010-09-27 14:44:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-07 18:56:37 +00:00
|
|
|
|
static GtkSizeRequestMode
|
|
|
|
|
gtk_grid_get_request_mode (GtkWidget *widget)
|
2010-09-27 14:44:31 +00:00
|
|
|
|
{
|
2020-05-07 18:56:37 +00:00
|
|
|
|
GtkWidget *w;
|
|
|
|
|
int wfh = 0, hfw = 0;
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
2020-05-07 18:56:37 +00:00
|
|
|
|
for (w = gtk_widget_get_first_child (widget);
|
|
|
|
|
w != NULL;
|
|
|
|
|
w = gtk_widget_get_next_sibling (w))
|
|
|
|
|
{
|
|
|
|
|
GtkSizeRequestMode mode = gtk_widget_get_request_mode (w);
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
2020-05-07 18:56:37 +00:00
|
|
|
|
switch (mode)
|
|
|
|
|
{
|
|
|
|
|
case GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH:
|
|
|
|
|
hfw ++;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT:
|
|
|
|
|
wfh ++;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_SIZE_REQUEST_CONSTANT_SIZE:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hfw == 0 && wfh == 0)
|
|
|
|
|
return GTK_SIZE_REQUEST_CONSTANT_SIZE;
|
|
|
|
|
else
|
|
|
|
|
return wfh > hfw ?
|
|
|
|
|
GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT :
|
|
|
|
|
GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
|
2010-09-27 14:44:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-05-07 18:56:37 +00:00
|
|
|
|
gtk_grid_dispose (GObject *object)
|
2010-09-27 14:44:31 +00:00
|
|
|
|
{
|
2018-03-17 14:45:35 +00:00
|
|
|
|
GtkWidget *child;
|
|
|
|
|
|
2020-05-07 18:56:37 +00:00
|
|
|
|
while ((child = gtk_widget_get_first_child (GTK_WIDGET (object))))
|
|
|
|
|
gtk_grid_remove (GTK_GRID (object), child);
|
2011-03-30 06:24:00 +00:00
|
|
|
|
|
2020-05-07 18:56:37 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_grid_parent_class)->dispose (object);
|
2010-09-27 14:44:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_grid_class_init (GtkGridClass *class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
|
|
|
|
|
2020-05-07 18:56:37 +00:00
|
|
|
|
object_class->dispose = gtk_grid_dispose;
|
2010-09-27 14:44:31 +00:00
|
|
|
|
object_class->get_property = gtk_grid_get_property;
|
|
|
|
|
object_class->set_property = gtk_grid_set_property;
|
|
|
|
|
|
2020-05-07 18:56:37 +00:00
|
|
|
|
widget_class->compute_expand = gtk_grid_compute_expand;
|
|
|
|
|
widget_class->get_request_mode = gtk_grid_get_request_mode;
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
|
|
|
|
g_object_class_override_property (object_class, PROP_ORIENTATION, "orientation");
|
|
|
|
|
|
2021-02-26 04:18:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkGrid:row-spacing: (attributes org.gtk.Property.get=gtk_grid_get_row_spacing org.gtk.Property.set=gtk_grid_set_row_spacing)
|
|
|
|
|
*
|
|
|
|
|
* The amount of space between two consecutive rows.
|
|
|
|
|
*/
|
2014-01-25 18:49:27 +00:00
|
|
|
|
obj_properties[PROP_ROW_SPACING] =
|
2010-09-27 14:44:31 +00:00
|
|
|
|
g_param_spec_int ("row-spacing",
|
|
|
|
|
P_("Row spacing"),
|
|
|
|
|
P_("The amount of space between two consecutive rows"),
|
|
|
|
|
0, G_MAXINT16, 0,
|
2014-06-09 12:57:30 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
2021-02-26 04:18:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkGrid:column-spacing: (attributes org.gtk.Property.get=gtk_grid_get_column_spacing org.gtk.Property.set=gtk_grid_set_column_spacing)
|
|
|
|
|
*
|
|
|
|
|
* The amount of space between two consecutive columns.
|
|
|
|
|
*/
|
2014-01-25 18:49:27 +00:00
|
|
|
|
obj_properties[PROP_COLUMN_SPACING] =
|
2010-09-27 14:44:31 +00:00
|
|
|
|
g_param_spec_int ("column-spacing",
|
|
|
|
|
P_("Column spacing"),
|
|
|
|
|
P_("The amount of space between two consecutive columns"),
|
|
|
|
|
0, G_MAXINT16, 0,
|
2014-06-09 12:57:30 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
2021-02-26 04:18:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkGrid:row-homogeneous: (attributes org.gtk.Property.get=gtk_grid_get_row_homogeneous org.gtk.Property.set=gtk_grid_set_row_homogeneous)
|
|
|
|
|
*
|
|
|
|
|
* If %TRUE, the rows are all the same height.
|
|
|
|
|
*/
|
2014-01-25 18:49:27 +00:00
|
|
|
|
obj_properties[PROP_ROW_HOMOGENEOUS] =
|
2010-09-27 14:44:31 +00:00
|
|
|
|
g_param_spec_boolean ("row-homogeneous",
|
|
|
|
|
P_("Row Homogeneous"),
|
|
|
|
|
P_("If TRUE, the rows are all the same height"),
|
|
|
|
|
FALSE,
|
2014-06-09 12:57:30 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
2021-02-26 04:18:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkGrid:column-homogeneous: (attributes org.gtk.Property.get=gtk_grid_get_column_homogeneous org.gtk.Property.set=gtk_grid_set_column_homogeneous)
|
|
|
|
|
*
|
|
|
|
|
* If %TRUE, the columns are all the same width.
|
|
|
|
|
*/
|
2014-01-25 18:49:27 +00:00
|
|
|
|
obj_properties[PROP_COLUMN_HOMOGENEOUS] =
|
2010-09-27 14:44:31 +00:00
|
|
|
|
g_param_spec_boolean ("column-homogeneous",
|
|
|
|
|
P_("Column Homogeneous"),
|
|
|
|
|
P_("If TRUE, the columns are all the same width"),
|
|
|
|
|
FALSE,
|
2014-06-09 12:57:30 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2010-11-14 02:49:26 +00:00
|
|
|
|
|
2021-02-26 04:18:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkGrid:baseline-row: (attributes org.gtk.Property.get=gtk_grid_get_baseline_row org.gtk.Property.set=gtk_grid_set_baseline_row)
|
|
|
|
|
*
|
|
|
|
|
* The row to align to the baseline when valign is %GTK_ALIGN_BASELINE.
|
|
|
|
|
*/
|
2014-01-25 18:49:27 +00:00
|
|
|
|
obj_properties[PROP_BASELINE_ROW] =
|
2013-03-21 10:09:43 +00:00
|
|
|
|
g_param_spec_int ("baseline-row",
|
|
|
|
|
P_("Baseline Row"),
|
|
|
|
|
P_("The row to align the to the baseline when valign is GTK_ALIGN_BASELINE"),
|
|
|
|
|
0, G_MAXINT, 0,
|
2014-06-09 12:57:30 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
2014-01-25 18:49:27 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
g_object_class_install_properties (object_class, N_PROPERTIES, obj_properties);
|
|
|
|
|
|
2017-11-18 03:49:57 +00:00
|
|
|
|
gtk_widget_class_set_css_name (widget_class, I_("grid"));
|
2019-05-06 11:06:27 +00:00
|
|
|
|
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_GRID_LAYOUT);
|
2020-11-11 17:54:57 +00:00
|
|
|
|
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_GROUP);
|
2015-12-06 06:52:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-07 18:56:37 +00:00
|
|
|
|
static GtkBuildableIface *parent_buildable_iface;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_grid_buildable_add_child (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *type)
|
2020-05-07 18:56:37 +00:00
|
|
|
|
{
|
|
|
|
|
if (GTK_IS_WIDGET (child))
|
|
|
|
|
{
|
|
|
|
|
GtkGrid *grid = GTK_GRID ( buildable);
|
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
|
|
|
|
int pos[2] = { 0, 0 };
|
|
|
|
|
|
|
|
|
|
pos[priv->orientation] = find_attach_position (grid, priv->orientation, 0, 1, TRUE);
|
|
|
|
|
grid_attach (grid, GTK_WIDGET (child), pos[0], pos[1], 1, 1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
parent_buildable_iface->add_child (buildable, builder, child, type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_grid_buildable_iface_init (GtkBuildableIface *iface)
|
|
|
|
|
{
|
|
|
|
|
parent_buildable_iface = g_type_interface_peek_parent (iface);
|
|
|
|
|
|
|
|
|
|
iface->add_child = gtk_grid_buildable_add_child;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-06 06:52:45 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_grid_init (GtkGrid *grid)
|
|
|
|
|
{
|
2017-10-08 08:40:48 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2015-12-06 06:52:45 +00:00
|
|
|
|
|
2019-05-06 11:06:27 +00:00
|
|
|
|
priv->layout_manager = gtk_widget_get_layout_manager (GTK_WIDGET (grid));
|
2015-12-06 06:52:45 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
|
2020-04-23 16:48:29 +00:00
|
|
|
|
gtk_widget_update_orientation (GTK_WIDGET (grid), priv->orientation);
|
2010-09-27 14:44:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_grid_new:
|
|
|
|
|
*
|
|
|
|
|
* Creates a new grid widget.
|
|
|
|
|
*
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* Returns: the new `GtkGrid`
|
2010-09-27 14:44:31 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_grid_new (void)
|
|
|
|
|
{
|
|
|
|
|
return g_object_new (GTK_TYPE_GRID, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_grid_attach:
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* @grid: a `GtkGrid`
|
2010-09-27 14:44:31 +00:00
|
|
|
|
* @child: the widget to add
|
2020-08-02 18:13:14 +00:00
|
|
|
|
* @column: the column number to attach the left side of @child to
|
|
|
|
|
* @row: the row number to attach the top side of @child to
|
2010-09-27 14:44:31 +00:00
|
|
|
|
* @width: the number of columns that @child will span
|
|
|
|
|
* @height: the number of rows that @child will span
|
|
|
|
|
*
|
|
|
|
|
* Adds a widget to the grid.
|
|
|
|
|
*
|
2020-08-02 18:13:14 +00:00
|
|
|
|
* The position of @child is determined by @column and @row.
|
|
|
|
|
* The number of “cells” that @child will occupy is determined
|
|
|
|
|
* by @width and @height.
|
2010-09-27 14:44:31 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_grid_attach (GtkGrid *grid,
|
|
|
|
|
GtkWidget *child,
|
2020-08-02 18:13:14 +00:00
|
|
|
|
int column,
|
|
|
|
|
int row,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int width,
|
|
|
|
|
int height)
|
2010-09-27 14:44:31 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_GRID (grid));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (child));
|
2015-09-06 23:58:03 +00:00
|
|
|
|
g_return_if_fail (_gtk_widget_get_parent (child) == NULL);
|
2010-09-27 14:44:31 +00:00
|
|
|
|
g_return_if_fail (width > 0);
|
|
|
|
|
g_return_if_fail (height > 0);
|
|
|
|
|
|
2020-08-02 18:13:14 +00:00
|
|
|
|
grid_attach (grid, child, column, row, width, height);
|
2010-09-27 14:44:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_grid_attach_next_to:
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* @grid: a `GtkGrid`
|
2010-09-27 14:44:31 +00:00
|
|
|
|
* @child: the widget to add
|
2011-10-15 17:37:43 +00:00
|
|
|
|
* @sibling: (allow-none): the child of @grid that @child will be placed
|
2011-09-03 00:04:06 +00:00
|
|
|
|
* next to, or %NULL to place @child at the beginning or end
|
2010-09-27 14:44:31 +00:00
|
|
|
|
* @side: the side of @sibling that @child is positioned next to
|
|
|
|
|
* @width: the number of columns that @child will span
|
|
|
|
|
* @height: the number of rows that @child will span
|
|
|
|
|
*
|
|
|
|
|
* Adds a widget to the grid.
|
|
|
|
|
*
|
|
|
|
|
* The widget is placed next to @sibling, on the side determined by
|
2011-09-03 00:04:06 +00:00
|
|
|
|
* @side. When @sibling is %NULL, the widget is placed in row (for
|
|
|
|
|
* left or right placement) or column 0 (for top or bottom placement),
|
|
|
|
|
* at the end indicated by @side.
|
2011-10-26 03:18:21 +00:00
|
|
|
|
*
|
|
|
|
|
* Attaching widgets labeled [1], [2], [3] with @sibling == %NULL and
|
|
|
|
|
* @side == %GTK_POS_LEFT yields a layout of [3][2][1].
|
2010-09-27 14:44:31 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_grid_attach_next_to (GtkGrid *grid,
|
|
|
|
|
GtkWidget *child,
|
|
|
|
|
GtkWidget *sibling,
|
|
|
|
|
GtkPositionType side,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int width,
|
|
|
|
|
int height)
|
2010-09-27 14:44:31 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
|
|
|
|
GtkGridLayoutChild *grid_sibling;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int left, top;
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_GRID (grid));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (child));
|
2015-09-06 23:58:03 +00:00
|
|
|
|
g_return_if_fail (_gtk_widget_get_parent (child) == NULL);
|
|
|
|
|
g_return_if_fail (sibling == NULL || _gtk_widget_get_parent (sibling) == (GtkWidget*)grid);
|
2010-09-27 14:44:31 +00:00
|
|
|
|
g_return_if_fail (width > 0);
|
|
|
|
|
g_return_if_fail (height > 0);
|
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
if (sibling != NULL)
|
2011-09-03 00:04:06 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
grid_sibling = GTK_GRID_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout_manager, sibling));
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
2011-09-03 00:04:06 +00:00
|
|
|
|
switch (side)
|
|
|
|
|
{
|
|
|
|
|
case GTK_POS_LEFT:
|
2020-08-02 18:13:14 +00:00
|
|
|
|
left = gtk_grid_layout_child_get_column (grid_sibling) - width;
|
|
|
|
|
top = gtk_grid_layout_child_get_row (grid_sibling);
|
2011-09-03 00:04:06 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_POS_RIGHT:
|
2020-08-02 18:13:14 +00:00
|
|
|
|
left = gtk_grid_layout_child_get_column (grid_sibling) +
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gtk_grid_layout_child_get_column_span (grid_sibling);
|
2020-08-02 18:13:14 +00:00
|
|
|
|
top = gtk_grid_layout_child_get_row (grid_sibling);
|
2011-09-03 00:04:06 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_POS_TOP:
|
2020-08-02 18:13:14 +00:00
|
|
|
|
left = gtk_grid_layout_child_get_column (grid_sibling);
|
|
|
|
|
top = gtk_grid_layout_child_get_row (grid_sibling) - height;
|
2011-09-03 00:04:06 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_POS_BOTTOM:
|
2020-08-02 18:13:14 +00:00
|
|
|
|
left = gtk_grid_layout_child_get_column (grid_sibling);
|
|
|
|
|
top = gtk_grid_layout_child_get_row (grid_sibling) +
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gtk_grid_layout_child_get_row_span (grid_sibling);
|
2011-09-03 00:04:06 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2010-09-27 14:44:31 +00:00
|
|
|
|
{
|
2011-09-03 00:04:06 +00:00
|
|
|
|
switch (side)
|
|
|
|
|
{
|
|
|
|
|
case GTK_POS_LEFT:
|
2011-10-26 03:18:21 +00:00
|
|
|
|
left = find_attach_position (grid, GTK_ORIENTATION_HORIZONTAL, 0, height, FALSE);
|
|
|
|
|
left -= width;
|
2011-09-03 00:04:06 +00:00
|
|
|
|
top = 0;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_POS_RIGHT:
|
2011-10-26 03:18:21 +00:00
|
|
|
|
left = find_attach_position (grid, GTK_ORIENTATION_HORIZONTAL, 0, height, TRUE);
|
2011-09-03 00:04:06 +00:00
|
|
|
|
top = 0;
|
|
|
|
|
break;
|
|
|
|
|
case GTK_POS_TOP:
|
|
|
|
|
left = 0;
|
2011-10-26 03:18:21 +00:00
|
|
|
|
top = find_attach_position (grid, GTK_ORIENTATION_VERTICAL, 0, width, FALSE);
|
|
|
|
|
top -= height;
|
2011-09-03 00:04:06 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_POS_BOTTOM:
|
|
|
|
|
left = 0;
|
2011-10-26 03:18:21 +00:00
|
|
|
|
top = find_attach_position (grid, GTK_ORIENTATION_VERTICAL, 0, width, TRUE);
|
2011-09-03 00:04:06 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
2010-09-27 14:44:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
grid_attach (grid, child, left, top, width, height);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-29 01:20:53 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_grid_get_child_at:
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* @grid: a `GtkGrid`
|
2020-08-02 18:13:14 +00:00
|
|
|
|
* @column: the left edge of the cell
|
|
|
|
|
* @row: the top edge of the cell
|
2011-08-29 01:20:53 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the child of @grid whose area covers the grid
|
2020-08-02 18:13:14 +00:00
|
|
|
|
* cell at @column, @row.
|
2011-08-29 01:20:53 +00:00
|
|
|
|
*
|
2015-12-01 12:40:46 +00:00
|
|
|
|
* Returns: (transfer none) (nullable): the child at the given position, or %NULL
|
2011-08-29 01:20:53 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_grid_get_child_at (GtkGrid *grid,
|
2020-08-02 18:13:14 +00:00
|
|
|
|
int column,
|
|
|
|
|
int row)
|
2011-08-29 01:20:53 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2018-03-17 14:45:35 +00:00
|
|
|
|
GtkWidget *child;
|
2011-08-29 01:20:53 +00:00
|
|
|
|
|
2012-06-02 23:40:41 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_GRID (grid), NULL);
|
|
|
|
|
|
2018-03-17 14:45:35 +00:00
|
|
|
|
for (child = gtk_widget_get_first_child (GTK_WIDGET (grid));
|
|
|
|
|
child != NULL;
|
|
|
|
|
child = gtk_widget_get_next_sibling (child))
|
2011-08-29 01:20:53 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
GtkGridLayoutChild *grid_child;
|
2020-08-02 18:13:14 +00:00
|
|
|
|
int child_column, child_row, child_width, child_height;
|
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
grid_child = GTK_GRID_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout_manager, child));
|
2020-08-02 18:13:14 +00:00
|
|
|
|
child_column = gtk_grid_layout_child_get_column (grid_child);
|
|
|
|
|
child_row = gtk_grid_layout_child_get_row (grid_child);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
child_width = gtk_grid_layout_child_get_column_span (grid_child);
|
|
|
|
|
child_height = gtk_grid_layout_child_get_row_span (grid_child);
|
|
|
|
|
|
2020-08-02 18:13:14 +00:00
|
|
|
|
if (child_column <= column && child_column + child_width > column &&
|
|
|
|
|
child_row <= row && child_row + child_height > row)
|
2018-03-17 14:45:35 +00:00
|
|
|
|
return child;
|
2011-08-29 01:20:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-07 18:22:12 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_grid_remove:
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* @grid: a `GtkGrid`
|
2020-05-07 18:22:12 +00:00
|
|
|
|
* @child: the child widget to remove
|
|
|
|
|
*
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* Removes a child from @grid.
|
|
|
|
|
*
|
|
|
|
|
* The child must have been added with
|
|
|
|
|
* [method@Gtk.Grid.attach] or [method@Gtk.Grid.attach_next_to].
|
2020-05-07 18:22:12 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_grid_remove (GtkGrid *grid,
|
|
|
|
|
GtkWidget *child)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_GRID (grid));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (child));
|
2020-05-07 18:56:37 +00:00
|
|
|
|
g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (grid));
|
2020-05-07 18:22:12 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_unparent (child);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-08 10:06:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_grid_insert_row:
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* @grid: a `GtkGrid`
|
2011-08-08 10:06:59 +00:00
|
|
|
|
* @position: the position to insert the row at
|
|
|
|
|
*
|
|
|
|
|
* Inserts a row at the specified position.
|
|
|
|
|
*
|
|
|
|
|
* Children which are attached at or below this position
|
|
|
|
|
* are moved one row down. Children which span across this
|
|
|
|
|
* position are grown to span the new row.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_grid_insert_row (GtkGrid *grid,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int position)
|
2011-08-08 10:06:59 +00:00
|
|
|
|
{
|
2017-10-08 08:40:48 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2018-03-17 14:45:35 +00:00
|
|
|
|
GtkWidget *child;
|
|
|
|
|
int top, height;
|
2011-08-08 10:06:59 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_GRID (grid));
|
|
|
|
|
|
2018-03-17 14:45:35 +00:00
|
|
|
|
for (child = gtk_widget_get_first_child (GTK_WIDGET (grid));
|
|
|
|
|
child != NULL;
|
|
|
|
|
child = gtk_widget_get_next_sibling (child))
|
2011-08-08 10:06:59 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
GtkGridLayoutChild *grid_child;
|
|
|
|
|
|
|
|
|
|
grid_child = GTK_GRID_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout_manager, child));
|
2020-08-02 18:13:14 +00:00
|
|
|
|
top = gtk_grid_layout_child_get_row (grid_child);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
height = gtk_grid_layout_child_get_row_span (grid_child);
|
2011-08-08 10:06:59 +00:00
|
|
|
|
|
|
|
|
|
if (top >= position)
|
2020-08-02 18:13:14 +00:00
|
|
|
|
gtk_grid_layout_child_set_row (grid_child, top + 1);
|
2011-08-08 10:06:59 +00:00
|
|
|
|
else if (top + height > position)
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gtk_grid_layout_child_set_row_span (grid_child, height + 1);
|
2013-03-21 10:09:43 +00:00
|
|
|
|
}
|
2011-08-08 10:06:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-23 19:40:44 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_grid_remove_row:
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* @grid: a `GtkGrid`
|
2013-03-23 19:40:44 +00:00
|
|
|
|
* @position: the position of the row to remove
|
|
|
|
|
*
|
|
|
|
|
* Removes a row from the grid.
|
|
|
|
|
*
|
|
|
|
|
* Children that are placed in this row are removed,
|
|
|
|
|
* spanning children that overlap this row have their
|
|
|
|
|
* height reduced by one, and children below the row
|
|
|
|
|
* are moved up.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_grid_remove_row (GtkGrid *grid,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int position)
|
2013-03-23 19:40:44 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2018-03-17 14:45:35 +00:00
|
|
|
|
GtkWidget *child;
|
2013-03-23 19:40:44 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_GRID (grid));
|
|
|
|
|
|
2018-03-17 14:45:35 +00:00
|
|
|
|
child = gtk_widget_get_first_child (GTK_WIDGET (grid));
|
|
|
|
|
while (child)
|
2013-03-23 19:40:44 +00:00
|
|
|
|
{
|
2018-03-17 14:45:35 +00:00
|
|
|
|
GtkWidget *next = gtk_widget_get_next_sibling (child);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
GtkGridLayoutChild *grid_child;
|
|
|
|
|
int top, height;
|
2013-03-23 19:40:44 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
grid_child = GTK_GRID_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout_manager, child));
|
2020-08-02 18:13:14 +00:00
|
|
|
|
top = gtk_grid_layout_child_get_row (grid_child);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
height = gtk_grid_layout_child_get_row_span (grid_child);
|
2013-03-23 19:40:44 +00:00
|
|
|
|
|
|
|
|
|
if (top <= position && top + height > position)
|
|
|
|
|
height--;
|
|
|
|
|
if (top > position)
|
|
|
|
|
top--;
|
|
|
|
|
|
|
|
|
|
if (height <= 0)
|
2019-04-04 17:40:34 +00:00
|
|
|
|
{
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_grid_remove (grid, child);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
}
|
2013-03-23 19:40:44 +00:00
|
|
|
|
else
|
2019-04-04 17:40:34 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_grid_layout_child_set_row_span (grid_child, height);
|
2020-08-02 18:13:14 +00:00
|
|
|
|
gtk_grid_layout_child_set_row (grid_child, top);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-17 14:45:35 +00:00
|
|
|
|
child = next;
|
2013-03-23 19:40:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-08 10:06:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_grid_insert_column:
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* @grid: a `GtkGrid`
|
2011-08-08 10:06:59 +00:00
|
|
|
|
* @position: the position to insert the column at
|
|
|
|
|
*
|
|
|
|
|
* Inserts a column at the specified position.
|
|
|
|
|
*
|
|
|
|
|
* Children which are attached at or to the right of this position
|
|
|
|
|
* are moved one column to the right. Children which span across this
|
|
|
|
|
* position are grown to span the new column.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_grid_insert_column (GtkGrid *grid,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int position)
|
2011-08-08 10:06:59 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2018-03-17 14:45:35 +00:00
|
|
|
|
GtkWidget *child;
|
2011-08-08 10:06:59 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_GRID (grid));
|
|
|
|
|
|
2018-03-17 14:45:35 +00:00
|
|
|
|
for (child = gtk_widget_get_first_child (GTK_WIDGET (grid));
|
|
|
|
|
child != NULL;
|
|
|
|
|
child = gtk_widget_get_next_sibling (child))
|
2011-08-08 10:06:59 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
GtkGridLayoutChild *grid_child;
|
|
|
|
|
int left, width;
|
2011-08-08 10:06:59 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
grid_child = GTK_GRID_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout_manager, child));
|
2020-08-02 18:13:14 +00:00
|
|
|
|
left = gtk_grid_layout_child_get_column (grid_child);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
width = gtk_grid_layout_child_get_column_span (grid_child);
|
2011-08-08 10:06:59 +00:00
|
|
|
|
|
|
|
|
|
if (left >= position)
|
2020-08-02 18:13:14 +00:00
|
|
|
|
gtk_grid_layout_child_set_column (grid_child, left + 1);
|
2011-08-08 10:06:59 +00:00
|
|
|
|
else if (left + width > position)
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gtk_grid_layout_child_set_column_span (grid_child, width + 1);
|
2011-08-08 10:06:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-23 19:40:44 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_grid_remove_column:
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* @grid: a `GtkGrid`
|
2013-03-23 19:40:44 +00:00
|
|
|
|
* @position: the position of the column to remove
|
|
|
|
|
*
|
|
|
|
|
* Removes a column from the grid.
|
|
|
|
|
*
|
|
|
|
|
* Children that are placed in this column are removed,
|
|
|
|
|
* spanning children that overlap this column have their
|
|
|
|
|
* width reduced by one, and children after the column
|
|
|
|
|
* are moved to the left.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_grid_remove_column (GtkGrid *grid,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int position)
|
2013-03-23 19:40:44 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2018-03-17 14:45:35 +00:00
|
|
|
|
GtkWidget *child;
|
2013-03-23 19:40:44 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_GRID (grid));
|
|
|
|
|
|
2018-03-17 14:45:35 +00:00
|
|
|
|
child = gtk_widget_get_first_child (GTK_WIDGET (grid));
|
|
|
|
|
while (child)
|
2013-03-23 19:40:44 +00:00
|
|
|
|
{
|
2018-03-17 14:45:35 +00:00
|
|
|
|
GtkWidget *next = gtk_widget_get_next_sibling (child);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
GtkGridLayoutChild *grid_child;
|
|
|
|
|
int left, width;
|
2013-03-23 19:40:44 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
grid_child = GTK_GRID_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout_manager, child));
|
|
|
|
|
|
2020-08-02 18:13:14 +00:00
|
|
|
|
left = gtk_grid_layout_child_get_column (grid_child);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
width = gtk_grid_layout_child_get_column_span (grid_child);
|
2013-03-23 19:40:44 +00:00
|
|
|
|
|
|
|
|
|
if (left <= position && left + width > position)
|
|
|
|
|
width--;
|
|
|
|
|
if (left > position)
|
|
|
|
|
left--;
|
|
|
|
|
|
|
|
|
|
if (width <= 0)
|
2019-04-04 17:40:34 +00:00
|
|
|
|
{
|
2020-05-09 12:26:52 +00:00
|
|
|
|
gtk_grid_remove (grid, child);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
}
|
2013-03-23 19:40:44 +00:00
|
|
|
|
else
|
2019-04-04 17:40:34 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_grid_layout_child_set_column_span (grid_child, width);
|
2020-08-02 18:13:14 +00:00
|
|
|
|
gtk_grid_layout_child_set_column (grid_child, left);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
}
|
2018-03-17 14:45:35 +00:00
|
|
|
|
|
|
|
|
|
child = next;
|
2013-03-23 19:40:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-08 10:06:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_grid_insert_next_to:
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* @grid: a `GtkGrid`
|
2011-08-08 10:06:59 +00:00
|
|
|
|
* @sibling: the child of @grid that the new row or column will be
|
|
|
|
|
* placed next to
|
|
|
|
|
* @side: the side of @sibling that @child is positioned next to
|
|
|
|
|
*
|
|
|
|
|
* Inserts a row or column at the specified position.
|
|
|
|
|
*
|
|
|
|
|
* The new row or column is placed next to @sibling, on the side
|
|
|
|
|
* determined by @side. If @side is %GTK_POS_TOP or %GTK_POS_BOTTOM,
|
|
|
|
|
* a row is inserted. If @side is %GTK_POS_LEFT of %GTK_POS_RIGHT,
|
|
|
|
|
* a column is inserted.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_grid_insert_next_to (GtkGrid *grid,
|
|
|
|
|
GtkWidget *sibling,
|
|
|
|
|
GtkPositionType side)
|
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
|
|
|
|
GtkGridLayoutChild *child;
|
2011-08-08 10:06:59 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_GRID (grid));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (sibling));
|
2015-09-06 23:58:03 +00:00
|
|
|
|
g_return_if_fail (_gtk_widget_get_parent (sibling) == (GtkWidget*)grid);
|
2011-08-08 10:06:59 +00:00
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
child = GTK_GRID_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout_manager, sibling));
|
2011-08-08 10:06:59 +00:00
|
|
|
|
|
|
|
|
|
switch (side)
|
|
|
|
|
{
|
|
|
|
|
case GTK_POS_LEFT:
|
2020-08-02 18:13:14 +00:00
|
|
|
|
gtk_grid_insert_column (grid, gtk_grid_layout_child_get_column (child));
|
2011-08-08 10:06:59 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_POS_RIGHT:
|
2019-04-04 17:40:34 +00:00
|
|
|
|
{
|
2020-08-02 18:13:14 +00:00
|
|
|
|
int col = gtk_grid_layout_child_get_column (child) +
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gtk_grid_layout_child_get_column_span (child);
|
|
|
|
|
gtk_grid_insert_column (grid, col);
|
|
|
|
|
}
|
2011-08-08 10:06:59 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_POS_TOP:
|
2020-08-02 18:13:14 +00:00
|
|
|
|
gtk_grid_insert_row (grid, gtk_grid_layout_child_get_row (child));
|
2011-08-08 10:06:59 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_POS_BOTTOM:
|
2019-04-04 17:40:34 +00:00
|
|
|
|
{
|
2020-08-02 18:13:14 +00:00
|
|
|
|
int row = gtk_grid_layout_child_get_row (child) +
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gtk_grid_layout_child_get_row_span (child);
|
|
|
|
|
gtk_grid_insert_row (grid, row);
|
|
|
|
|
}
|
2011-08-08 10:06:59 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-27 14:44:31 +00:00
|
|
|
|
/**
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* gtk_grid_set_row_homogeneous: (attributes org.gtk.Method.set_property=row-homogeneous)
|
|
|
|
|
* @grid: a `GtkGrid`
|
2010-09-27 14:44:31 +00:00
|
|
|
|
* @homogeneous: %TRUE to make rows homogeneous
|
|
|
|
|
*
|
|
|
|
|
* Sets whether all rows of @grid will have the same height.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_grid_set_row_homogeneous (GtkGrid *grid,
|
|
|
|
|
gboolean homogeneous)
|
|
|
|
|
{
|
2017-10-08 08:40:48 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gboolean old_val;
|
|
|
|
|
|
2010-09-27 14:44:31 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_GRID (grid));
|
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
old_val = gtk_grid_layout_get_row_homogeneous (GTK_GRID_LAYOUT (priv->layout_manager));
|
|
|
|
|
if (old_val != !!homogeneous)
|
2010-09-27 14:44:31 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gtk_grid_layout_set_row_homogeneous (GTK_GRID_LAYOUT (priv->layout_manager), homogeneous);
|
2010-11-14 02:49:26 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (grid), obj_properties [PROP_ROW_HOMOGENEOUS]);
|
2010-09-27 14:44:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* gtk_grid_get_row_homogeneous: (attributes org.gtk.Method.get_property=row-homogeneous)
|
|
|
|
|
* @grid: a `GtkGrid`
|
2010-09-27 14:44:31 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns whether all rows of @grid have the same height.
|
|
|
|
|
*
|
|
|
|
|
* Returns: whether all rows of @grid have the same height.
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_grid_get_row_homogeneous (GtkGrid *grid)
|
|
|
|
|
{
|
2017-10-08 08:40:48 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
|
2010-09-27 14:44:31 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_GRID (grid), FALSE);
|
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
return gtk_grid_layout_get_row_homogeneous (GTK_GRID_LAYOUT (priv->layout_manager));
|
2010-09-27 14:44:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* gtk_grid_set_column_homogeneous: (attributes org.gtk.Method.set_property=column-homogeneous)
|
|
|
|
|
* @grid: a `GtkGrid`
|
2010-09-27 14:44:31 +00:00
|
|
|
|
* @homogeneous: %TRUE to make columns homogeneous
|
|
|
|
|
*
|
|
|
|
|
* Sets whether all columns of @grid will have the same width.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_grid_set_column_homogeneous (GtkGrid *grid,
|
|
|
|
|
gboolean homogeneous)
|
|
|
|
|
{
|
2017-10-08 08:40:48 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gboolean old_val;
|
|
|
|
|
|
2010-09-27 14:44:31 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_GRID (grid));
|
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
old_val = gtk_grid_layout_get_column_homogeneous (GTK_GRID_LAYOUT (priv->layout_manager));
|
|
|
|
|
if (old_val != !!homogeneous)
|
2010-09-27 14:44:31 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gtk_grid_layout_set_column_homogeneous (GTK_GRID_LAYOUT (priv->layout_manager), homogeneous);
|
2010-11-14 02:49:26 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (grid), obj_properties [PROP_COLUMN_HOMOGENEOUS]);
|
2010-09-27 14:44:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* gtk_grid_get_column_homogeneous: (attributes org.gtk.Method.get_property=column-homogeneous)
|
|
|
|
|
* @grid: a `GtkGrid`
|
2010-09-27 14:44:31 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns whether all columns of @grid have the same width.
|
|
|
|
|
*
|
|
|
|
|
* Returns: whether all columns of @grid have the same width.
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_grid_get_column_homogeneous (GtkGrid *grid)
|
|
|
|
|
{
|
2017-10-08 08:40:48 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
|
2010-09-27 14:44:31 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_GRID (grid), FALSE);
|
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
return gtk_grid_layout_get_column_homogeneous (GTK_GRID_LAYOUT (priv->layout_manager));
|
2010-09-27 14:44:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* gtk_grid_set_row_spacing: (attributes org.gtk.Method.set_property=row-spacing)
|
|
|
|
|
* @grid: a `GtkGrid`
|
2010-09-27 14:44:31 +00:00
|
|
|
|
* @spacing: the amount of space to insert between rows
|
|
|
|
|
*
|
|
|
|
|
* Sets the amount of space between rows of @grid.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_grid_set_row_spacing (GtkGrid *grid,
|
|
|
|
|
guint spacing)
|
|
|
|
|
{
|
2017-10-08 08:40:48 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
guint old_spacing;
|
|
|
|
|
|
2010-09-27 14:44:31 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_GRID (grid));
|
|
|
|
|
g_return_if_fail (spacing <= G_MAXINT16);
|
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
old_spacing = gtk_grid_layout_get_row_spacing (GTK_GRID_LAYOUT (priv->layout_manager));
|
|
|
|
|
if (old_spacing != spacing)
|
2010-09-27 14:44:31 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gtk_grid_layout_set_row_spacing (GTK_GRID_LAYOUT (priv->layout_manager), spacing);
|
2010-11-14 02:49:26 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (grid), obj_properties [PROP_ROW_SPACING]);
|
2010-09-27 14:44:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* gtk_grid_get_row_spacing: (attributes org.gtk.Method.get_property=row-spacing)
|
|
|
|
|
* @grid: a `GtkGrid`
|
2010-09-27 14:44:31 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns the amount of space between the rows of @grid.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the row spacing of @grid
|
|
|
|
|
*/
|
|
|
|
|
guint
|
|
|
|
|
gtk_grid_get_row_spacing (GtkGrid *grid)
|
|
|
|
|
{
|
2017-10-08 08:40:48 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
|
2010-09-27 14:44:31 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_GRID (grid), 0);
|
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
return gtk_grid_layout_get_row_spacing (GTK_GRID_LAYOUT (priv->layout_manager));
|
2010-09-27 14:44:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* gtk_grid_set_column_spacing: (attributes org.gtk.Method.set_property=column-spacing)
|
|
|
|
|
* @grid: a `GtkGrid`
|
2010-09-27 14:44:31 +00:00
|
|
|
|
* @spacing: the amount of space to insert between columns
|
|
|
|
|
*
|
|
|
|
|
* Sets the amount of space between columns of @grid.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_grid_set_column_spacing (GtkGrid *grid,
|
|
|
|
|
guint spacing)
|
|
|
|
|
{
|
2017-10-08 08:40:48 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
guint old_spacing;
|
|
|
|
|
|
2010-09-27 14:44:31 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_GRID (grid));
|
|
|
|
|
g_return_if_fail (spacing <= G_MAXINT16);
|
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
old_spacing = gtk_grid_layout_get_column_spacing (GTK_GRID_LAYOUT (priv->layout_manager));
|
|
|
|
|
if (old_spacing != spacing)
|
2010-09-27 14:44:31 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gtk_grid_layout_set_column_spacing (GTK_GRID_LAYOUT (priv->layout_manager), spacing);
|
2010-11-14 02:49:26 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (grid), obj_properties [PROP_COLUMN_SPACING]);
|
2010-09-27 14:44:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* gtk_grid_get_column_spacing: (attributes org.gtk.Method.get_property=column-spacing)
|
|
|
|
|
* @grid: a `GtkGrid`
|
2010-09-27 14:44:31 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns the amount of space between the columns of @grid.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the column spacing of @grid
|
|
|
|
|
*/
|
|
|
|
|
guint
|
|
|
|
|
gtk_grid_get_column_spacing (GtkGrid *grid)
|
|
|
|
|
{
|
2017-10-08 08:40:48 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2010-09-27 14:44:31 +00:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_GRID (grid), 0);
|
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
return gtk_grid_layout_get_column_spacing (GTK_GRID_LAYOUT (priv->layout_manager));
|
2013-03-21 10:09:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_grid_set_row_baseline_position:
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* @grid: a `GtkGrid`
|
2013-03-21 10:09:43 +00:00
|
|
|
|
* @row: a row index
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* @pos: a `GtkBaselinePosition`
|
2013-03-21 10:09:43 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets how the baseline should be positioned on @row of the
|
|
|
|
|
* grid, in case that row is assigned more space than is requested.
|
2021-02-26 04:18:00 +00:00
|
|
|
|
*
|
|
|
|
|
* The default baseline position is %GTK_BASELINE_POSITION_CENTER.
|
2013-03-21 10:09:43 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_grid_set_row_baseline_position (GtkGrid *grid,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int row,
|
2013-03-21 10:09:43 +00:00
|
|
|
|
GtkBaselinePosition pos)
|
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2013-03-21 10:09:43 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_GRID (grid));
|
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gtk_grid_layout_set_row_baseline_position (GTK_GRID_LAYOUT (priv->layout_manager),
|
|
|
|
|
row,
|
|
|
|
|
pos);
|
2013-03-21 10:09:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_grid_get_row_baseline_position:
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* @grid: a `GtkGrid`
|
2013-03-21 10:09:43 +00:00
|
|
|
|
* @row: a row index
|
|
|
|
|
*
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* Returns the baseline position of @row.
|
|
|
|
|
*
|
|
|
|
|
* See [method@Gtk.Grid.set_row_baseline_position].
|
2013-03-21 10:09:43 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: the baseline position of @row
|
|
|
|
|
*/
|
|
|
|
|
GtkBaselinePosition
|
|
|
|
|
gtk_grid_get_row_baseline_position (GtkGrid *grid,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int row)
|
2013-03-21 10:09:43 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2013-03-21 10:09:43 +00:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_GRID (grid), GTK_BASELINE_POSITION_CENTER);
|
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
return gtk_grid_layout_get_row_baseline_position (GTK_GRID_LAYOUT (priv->layout_manager), row);
|
2013-03-21 10:09:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* gtk_grid_set_baseline_row: (attributes org.gtk.Method.set_property=baseline-row)
|
|
|
|
|
* @grid: a `GtkGrid`
|
2013-03-21 10:09:43 +00:00
|
|
|
|
* @row: the row index
|
|
|
|
|
*
|
|
|
|
|
* Sets which row defines the global baseline for the entire grid.
|
2021-02-26 04:18:00 +00:00
|
|
|
|
*
|
2013-03-21 10:09:43 +00:00
|
|
|
|
* Each row in the grid can have its own local baseline, but only
|
|
|
|
|
* one of those is global, meaning it will be the baseline in the
|
|
|
|
|
* parent of the @grid.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_grid_set_baseline_row (GtkGrid *grid,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int row)
|
2013-03-21 10:09:43 +00:00
|
|
|
|
{
|
2017-10-08 08:40:48 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2019-04-04 17:40:34 +00:00
|
|
|
|
int old_row;
|
2013-03-21 10:09:43 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_GRID (grid));
|
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
old_row = gtk_grid_layout_get_baseline_row (GTK_GRID_LAYOUT (priv->layout_manager));
|
|
|
|
|
if (old_row != row)
|
2013-03-21 10:09:43 +00:00
|
|
|
|
{
|
2019-04-04 17:40:34 +00:00
|
|
|
|
gtk_grid_layout_set_baseline_row (GTK_GRID_LAYOUT (priv->layout_manager), row);
|
2013-03-21 10:09:43 +00:00
|
|
|
|
g_object_notify (G_OBJECT (grid), "baseline-row");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* gtk_grid_get_baseline_row: (attributes org.gtk.Method.get_property=baseline-row)
|
|
|
|
|
* @grid: a `GtkGrid`
|
2013-03-21 10:09:43 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns which row defines the global baseline of @grid.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the row index defining the global baseline
|
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2015-12-06 06:52:45 +00:00
|
|
|
|
gtk_grid_get_baseline_row (GtkGrid *grid)
|
2013-03-21 10:09:43 +00:00
|
|
|
|
{
|
2017-10-08 08:40:48 +00:00
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
2013-03-21 10:09:43 +00:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_GRID (grid), 0);
|
|
|
|
|
|
2019-04-04 17:40:34 +00:00
|
|
|
|
return gtk_grid_layout_get_baseline_row (GTK_GRID_LAYOUT (priv->layout_manager));
|
2013-03-21 10:09:43 +00:00
|
|
|
|
}
|
2019-04-04 21:41:19 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_grid_query_child:
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* @grid: a `GtkGrid`
|
|
|
|
|
* @child: a `GtkWidget` child of @grid
|
2020-08-02 18:13:14 +00:00
|
|
|
|
* @column: (out) (optional): the column used to attach the left side of @child
|
|
|
|
|
* @row: (out) (optional): the row used to attach the top side of @child
|
2019-04-05 11:59:24 +00:00
|
|
|
|
* @width: (out) (optional): the number of columns @child spans
|
2019-04-16 05:16:51 +00:00
|
|
|
|
* @height: (out) (optional): the number of rows @child spans
|
2019-04-04 21:41:19 +00:00
|
|
|
|
*
|
2021-02-26 04:18:00 +00:00
|
|
|
|
* Queries the attach points and spans of @child inside the given `GtkGrid`.
|
2019-04-04 21:41:19 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_grid_query_child (GtkGrid *grid,
|
|
|
|
|
GtkWidget *child,
|
2020-08-02 18:13:14 +00:00
|
|
|
|
int *column,
|
|
|
|
|
int *row,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int *width,
|
|
|
|
|
int *height)
|
2019-04-04 21:41:19 +00:00
|
|
|
|
{
|
|
|
|
|
GtkGridPrivate *priv = gtk_grid_get_instance_private (grid);
|
|
|
|
|
GtkGridLayoutChild *grid_child;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_GRID (grid));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (child));
|
|
|
|
|
g_return_if_fail (_gtk_widget_get_parent (child) == (GtkWidget *) grid);
|
|
|
|
|
|
|
|
|
|
grid_child = GTK_GRID_LAYOUT_CHILD (gtk_layout_manager_get_layout_child (priv->layout_manager, child));
|
|
|
|
|
|
2020-08-02 18:13:14 +00:00
|
|
|
|
if (column != NULL)
|
|
|
|
|
*column = gtk_grid_layout_child_get_column (grid_child);
|
|
|
|
|
if (row != NULL)
|
|
|
|
|
*row = gtk_grid_layout_child_get_row (grid_child);
|
2019-04-04 21:41:19 +00:00
|
|
|
|
if (width != NULL)
|
|
|
|
|
*width = gtk_grid_layout_child_get_column_span (grid_child);
|
|
|
|
|
if (height != NULL)
|
|
|
|
|
*height = gtk_grid_layout_child_get_row_span (grid_child);
|
|
|
|
|
}
|