mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-12 21:40:19 +00:00
gtksizegroup: Move public members to private structure
This commit is contained in:
parent
22d4515d9a
commit
d5c3fb5231
@ -28,6 +28,20 @@
|
|||||||
#include "gtksizerequest.h"
|
#include "gtksizerequest.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct _GtkSizeGroupPriv
|
||||||
|
{
|
||||||
|
GtkRequisition requisition;
|
||||||
|
|
||||||
|
GSList *widgets;
|
||||||
|
|
||||||
|
guint8 mode;
|
||||||
|
|
||||||
|
guint have_width : 1;
|
||||||
|
guint have_height : 1;
|
||||||
|
guint ignore_hidden : 1;
|
||||||
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_MODE,
|
PROP_MODE,
|
||||||
@ -124,12 +138,13 @@ add_group_to_closure (GtkSizeGroup *group,
|
|||||||
GSList **groups,
|
GSList **groups,
|
||||||
GSList **widgets)
|
GSList **widgets)
|
||||||
{
|
{
|
||||||
|
GtkSizeGroupPriv *priv = group->priv;
|
||||||
GSList *tmp_widgets;
|
GSList *tmp_widgets;
|
||||||
|
|
||||||
*groups = g_slist_prepend (*groups, group);
|
*groups = g_slist_prepend (*groups, group);
|
||||||
mark_visited (group);
|
mark_visited (group);
|
||||||
|
|
||||||
tmp_widgets = group->widgets;
|
tmp_widgets = priv->widgets;
|
||||||
while (tmp_widgets)
|
while (tmp_widgets)
|
||||||
{
|
{
|
||||||
GtkWidget *tmp_widget = tmp_widgets->data;
|
GtkWidget *tmp_widget = tmp_widgets->data;
|
||||||
@ -156,8 +171,9 @@ add_widget_to_closure (GtkWidget *widget,
|
|||||||
while (tmp_groups)
|
while (tmp_groups)
|
||||||
{
|
{
|
||||||
GtkSizeGroup *tmp_group = tmp_groups->data;
|
GtkSizeGroup *tmp_group = tmp_groups->data;
|
||||||
|
GtkSizeGroupPriv *tmp_priv = tmp_group->priv;
|
||||||
if ((tmp_group->mode == GTK_SIZE_GROUP_BOTH || tmp_group->mode == mode) &&
|
|
||||||
|
if ((tmp_priv->mode == GTK_SIZE_GROUP_BOTH || tmp_priv->mode == mode) &&
|
||||||
!is_visited (tmp_group))
|
!is_visited (tmp_group))
|
||||||
add_group_to_closure (tmp_group, mode, groups, widgets);
|
add_group_to_closure (tmp_group, mode, groups, widgets);
|
||||||
|
|
||||||
@ -186,10 +202,11 @@ reset_group_sizes (GSList *groups)
|
|||||||
while (tmp_list)
|
while (tmp_list)
|
||||||
{
|
{
|
||||||
GtkSizeGroup *tmp_group = tmp_list->data;
|
GtkSizeGroup *tmp_group = tmp_list->data;
|
||||||
|
GtkSizeGroupPriv *tmp_priv = tmp_group->priv;
|
||||||
|
|
||||||
|
tmp_priv->have_width = FALSE;
|
||||||
|
tmp_priv->have_height = FALSE;
|
||||||
|
|
||||||
tmp_group->have_width = FALSE;
|
|
||||||
tmp_group->have_height = FALSE;
|
|
||||||
|
|
||||||
tmp_list = tmp_list->next;
|
tmp_list = tmp_list->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -291,8 +308,10 @@ queue_resize_on_widget (GtkWidget *widget,
|
|||||||
static void
|
static void
|
||||||
queue_resize_on_group (GtkSizeGroup *size_group)
|
queue_resize_on_group (GtkSizeGroup *size_group)
|
||||||
{
|
{
|
||||||
if (size_group->widgets)
|
GtkSizeGroupPriv *priv = size_group->priv;
|
||||||
queue_resize_on_widget (size_group->widgets->data, TRUE);
|
|
||||||
|
if (priv->widgets)
|
||||||
|
queue_resize_on_widget (priv->widgets->data, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -339,18 +358,27 @@ gtk_size_group_class_init (GtkSizeGroupClass *klass)
|
|||||||
"when determining the size of the group"),
|
"when determining the size of the group"),
|
||||||
FALSE,
|
FALSE,
|
||||||
GTK_PARAM_READWRITE));
|
GTK_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (GtkSizeGroupPriv));
|
||||||
|
|
||||||
initialize_size_group_quarks ();
|
initialize_size_group_quarks ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_size_group_init (GtkSizeGroup *size_group)
|
gtk_size_group_init (GtkSizeGroup *size_group)
|
||||||
{
|
{
|
||||||
size_group->widgets = NULL;
|
GtkSizeGroupPriv *priv;
|
||||||
size_group->mode = GTK_SIZE_GROUP_HORIZONTAL;
|
|
||||||
size_group->have_width = 0;
|
size_group->priv = G_TYPE_INSTANCE_GET_PRIVATE (size_group,
|
||||||
size_group->have_height = 0;
|
GTK_TYPE_SIZE_GROUP,
|
||||||
size_group->ignore_hidden = 0;
|
GtkSizeGroupPriv);
|
||||||
|
priv = size_group->priv;
|
||||||
|
|
||||||
|
priv->widgets = NULL;
|
||||||
|
priv->mode = GTK_SIZE_GROUP_HORIZONTAL;
|
||||||
|
priv->have_width = 0;
|
||||||
|
priv->have_height = 0;
|
||||||
|
priv->ignore_hidden = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -393,14 +421,15 @@ gtk_size_group_get_property (GObject *object,
|
|||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
GtkSizeGroup *size_group = GTK_SIZE_GROUP (object);
|
GtkSizeGroup *size_group = GTK_SIZE_GROUP (object);
|
||||||
|
GtkSizeGroupPriv *priv = size_group->priv;
|
||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_MODE:
|
case PROP_MODE:
|
||||||
g_value_set_enum (value, size_group->mode);
|
g_value_set_enum (value, priv->mode);
|
||||||
break;
|
break;
|
||||||
case PROP_IGNORE_HIDDEN:
|
case PROP_IGNORE_HIDDEN:
|
||||||
g_value_set_boolean (value, size_group->ignore_hidden);
|
g_value_set_boolean (value, priv->ignore_hidden);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
@ -420,8 +449,9 @@ GtkSizeGroup *
|
|||||||
gtk_size_group_new (GtkSizeGroupMode mode)
|
gtk_size_group_new (GtkSizeGroupMode mode)
|
||||||
{
|
{
|
||||||
GtkSizeGroup *size_group = g_object_new (GTK_TYPE_SIZE_GROUP, NULL);
|
GtkSizeGroup *size_group = g_object_new (GTK_TYPE_SIZE_GROUP, NULL);
|
||||||
|
GtkSizeGroupPriv *priv = size_group->priv;
|
||||||
|
|
||||||
size_group->mode = mode;
|
priv->mode = mode;
|
||||||
|
|
||||||
return size_group;
|
return size_group;
|
||||||
}
|
}
|
||||||
@ -442,14 +472,18 @@ void
|
|||||||
gtk_size_group_set_mode (GtkSizeGroup *size_group,
|
gtk_size_group_set_mode (GtkSizeGroup *size_group,
|
||||||
GtkSizeGroupMode mode)
|
GtkSizeGroupMode mode)
|
||||||
{
|
{
|
||||||
|
GtkSizeGroupPriv *priv;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_SIZE_GROUP (size_group));
|
g_return_if_fail (GTK_IS_SIZE_GROUP (size_group));
|
||||||
|
|
||||||
if (size_group->mode != mode)
|
priv = size_group->priv;
|
||||||
|
|
||||||
|
if (priv->mode != mode)
|
||||||
{
|
{
|
||||||
if (size_group->mode != GTK_SIZE_GROUP_NONE)
|
if (priv->mode != GTK_SIZE_GROUP_NONE)
|
||||||
queue_resize_on_group (size_group);
|
queue_resize_on_group (size_group);
|
||||||
size_group->mode = mode;
|
priv->mode = mode;
|
||||||
if (size_group->mode != GTK_SIZE_GROUP_NONE)
|
if (priv->mode != GTK_SIZE_GROUP_NONE)
|
||||||
queue_resize_on_group (size_group);
|
queue_resize_on_group (size_group);
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (size_group), "mode");
|
g_object_notify (G_OBJECT (size_group), "mode");
|
||||||
@ -469,7 +503,7 @@ gtk_size_group_get_mode (GtkSizeGroup *size_group)
|
|||||||
{
|
{
|
||||||
g_return_val_if_fail (GTK_IS_SIZE_GROUP (size_group), GTK_SIZE_GROUP_BOTH);
|
g_return_val_if_fail (GTK_IS_SIZE_GROUP (size_group), GTK_SIZE_GROUP_BOTH);
|
||||||
|
|
||||||
return size_group->mode;
|
return size_group->priv->mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -487,13 +521,17 @@ void
|
|||||||
gtk_size_group_set_ignore_hidden (GtkSizeGroup *size_group,
|
gtk_size_group_set_ignore_hidden (GtkSizeGroup *size_group,
|
||||||
gboolean ignore_hidden)
|
gboolean ignore_hidden)
|
||||||
{
|
{
|
||||||
|
GtkSizeGroupPriv *priv;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_SIZE_GROUP (size_group));
|
g_return_if_fail (GTK_IS_SIZE_GROUP (size_group));
|
||||||
|
|
||||||
|
priv = size_group->priv;
|
||||||
|
|
||||||
ignore_hidden = ignore_hidden != FALSE;
|
ignore_hidden = ignore_hidden != FALSE;
|
||||||
|
|
||||||
if (size_group->ignore_hidden != ignore_hidden)
|
if (priv->ignore_hidden != ignore_hidden)
|
||||||
{
|
{
|
||||||
size_group->ignore_hidden = ignore_hidden;
|
priv->ignore_hidden = ignore_hidden;
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (size_group), "ignore-hidden");
|
g_object_notify (G_OBJECT (size_group), "ignore-hidden");
|
||||||
}
|
}
|
||||||
@ -514,7 +552,7 @@ gtk_size_group_get_ignore_hidden (GtkSizeGroup *size_group)
|
|||||||
{
|
{
|
||||||
g_return_val_if_fail (GTK_IS_SIZE_GROUP (size_group), FALSE);
|
g_return_val_if_fail (GTK_IS_SIZE_GROUP (size_group), FALSE);
|
||||||
|
|
||||||
return size_group->ignore_hidden;
|
return size_group->priv->ignore_hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -542,11 +580,14 @@ void
|
|||||||
gtk_size_group_add_widget (GtkSizeGroup *size_group,
|
gtk_size_group_add_widget (GtkSizeGroup *size_group,
|
||||||
GtkWidget *widget)
|
GtkWidget *widget)
|
||||||
{
|
{
|
||||||
|
GtkSizeGroupPriv *priv;
|
||||||
GSList *groups;
|
GSList *groups;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_SIZE_GROUP (size_group));
|
g_return_if_fail (GTK_IS_SIZE_GROUP (size_group));
|
||||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||||
|
|
||||||
|
priv = size_group->priv;
|
||||||
|
|
||||||
groups = get_size_groups (widget);
|
groups = get_size_groups (widget);
|
||||||
|
|
||||||
if (!g_slist_find (groups, size_group))
|
if (!g_slist_find (groups, size_group))
|
||||||
@ -554,7 +595,7 @@ gtk_size_group_add_widget (GtkSizeGroup *size_group,
|
|||||||
groups = g_slist_prepend (groups, size_group);
|
groups = g_slist_prepend (groups, size_group);
|
||||||
set_size_groups (widget, groups);
|
set_size_groups (widget, groups);
|
||||||
|
|
||||||
size_group->widgets = g_slist_prepend (size_group->widgets, widget);
|
priv->widgets = g_slist_prepend (priv->widgets, widget);
|
||||||
|
|
||||||
g_signal_connect (widget, "destroy",
|
g_signal_connect (widget, "destroy",
|
||||||
G_CALLBACK (gtk_size_group_widget_destroyed),
|
G_CALLBACK (gtk_size_group_widget_destroyed),
|
||||||
@ -577,11 +618,15 @@ void
|
|||||||
gtk_size_group_remove_widget (GtkSizeGroup *size_group,
|
gtk_size_group_remove_widget (GtkSizeGroup *size_group,
|
||||||
GtkWidget *widget)
|
GtkWidget *widget)
|
||||||
{
|
{
|
||||||
|
GtkSizeGroupPriv *priv;
|
||||||
GSList *groups;
|
GSList *groups;
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_SIZE_GROUP (size_group));
|
g_return_if_fail (GTK_IS_SIZE_GROUP (size_group));
|
||||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||||
g_return_if_fail (g_slist_find (size_group->widgets, widget));
|
|
||||||
|
priv = size_group->priv;
|
||||||
|
|
||||||
|
g_return_if_fail (g_slist_find (priv->widgets, widget));
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func (widget,
|
g_signal_handlers_disconnect_by_func (widget,
|
||||||
gtk_size_group_widget_destroyed,
|
gtk_size_group_widget_destroyed,
|
||||||
@ -591,7 +636,7 @@ gtk_size_group_remove_widget (GtkSizeGroup *size_group,
|
|||||||
groups = g_slist_remove (groups, size_group);
|
groups = g_slist_remove (groups, size_group);
|
||||||
set_size_groups (widget, groups);
|
set_size_groups (widget, groups);
|
||||||
|
|
||||||
size_group->widgets = g_slist_remove (size_group->widgets, widget);
|
priv->widgets = g_slist_remove (priv->widgets, widget);
|
||||||
queue_resize_on_group (size_group);
|
queue_resize_on_group (size_group);
|
||||||
gtk_widget_queue_resize (widget);
|
gtk_widget_queue_resize (widget);
|
||||||
|
|
||||||
@ -612,7 +657,7 @@ gtk_size_group_remove_widget (GtkSizeGroup *size_group,
|
|||||||
GSList *
|
GSList *
|
||||||
gtk_size_group_get_widgets (GtkSizeGroup *size_group)
|
gtk_size_group_get_widgets (GtkSizeGroup *size_group)
|
||||||
{
|
{
|
||||||
return size_group->widgets;
|
return size_group->priv->widgets;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
@ -675,11 +720,12 @@ compute_dimension (GtkWidget *widget,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
GtkSizeGroup *group = groups->data;
|
GtkSizeGroup *group = groups->data;
|
||||||
|
GtkSizeGroupPriv *priv = group->priv;
|
||||||
|
|
||||||
if (mode == GTK_SIZE_GROUP_HORIZONTAL && group->have_width)
|
if (mode == GTK_SIZE_GROUP_HORIZONTAL && priv->have_width)
|
||||||
result = group->requisition.width;
|
result = priv->requisition.width;
|
||||||
else if (mode == GTK_SIZE_GROUP_VERTICAL && group->have_height)
|
else if (mode == GTK_SIZE_GROUP_VERTICAL && priv->have_height)
|
||||||
result = group->requisition.height;
|
result = priv->requisition.height;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmp_list = widgets;
|
tmp_list = widgets;
|
||||||
@ -693,7 +739,7 @@ compute_dimension (GtkWidget *widget,
|
|||||||
else
|
else
|
||||||
dimension = get_base_dimension (tmp_widget, mode);
|
dimension = get_base_dimension (tmp_widget, mode);
|
||||||
|
|
||||||
if (gtk_widget_get_mapped (tmp_widget) || !group->ignore_hidden)
|
if (gtk_widget_get_mapped (tmp_widget) || !priv->ignore_hidden)
|
||||||
{
|
{
|
||||||
if (dimension > result)
|
if (dimension > result)
|
||||||
result = dimension;
|
result = dimension;
|
||||||
@ -706,16 +752,17 @@ compute_dimension (GtkWidget *widget,
|
|||||||
while (tmp_list)
|
while (tmp_list)
|
||||||
{
|
{
|
||||||
GtkSizeGroup *tmp_group = tmp_list->data;
|
GtkSizeGroup *tmp_group = tmp_list->data;
|
||||||
|
GtkSizeGroupPriv *tmp_priv = tmp_group->priv;
|
||||||
|
|
||||||
if (mode == GTK_SIZE_GROUP_HORIZONTAL)
|
if (mode == GTK_SIZE_GROUP_HORIZONTAL)
|
||||||
{
|
{
|
||||||
tmp_group->have_width = TRUE;
|
tmp_priv->have_width = TRUE;
|
||||||
tmp_group->requisition.width = result;
|
tmp_priv->requisition.width = result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmp_group->have_height = TRUE;
|
tmp_priv->have_height = TRUE;
|
||||||
tmp_group->requisition.height = result;
|
tmp_priv->requisition.height = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp_list = tmp_list->next;
|
tmp_list = tmp_list->next;
|
||||||
|
@ -38,6 +38,7 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _GtkSizeGroup GtkSizeGroup;
|
typedef struct _GtkSizeGroup GtkSizeGroup;
|
||||||
|
typedef struct _GtkSizeGroupPriv GtkSizeGroupPriv;
|
||||||
typedef struct _GtkSizeGroupClass GtkSizeGroupClass;
|
typedef struct _GtkSizeGroupClass GtkSizeGroupClass;
|
||||||
|
|
||||||
struct _GtkSizeGroup
|
struct _GtkSizeGroup
|
||||||
@ -45,15 +46,7 @@ struct _GtkSizeGroup
|
|||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
|
|
||||||
/* <private> */
|
/* <private> */
|
||||||
GSList *GSEAL (widgets);
|
GtkSizeGroupPriv *priv;
|
||||||
|
|
||||||
guint8 GSEAL (mode);
|
|
||||||
|
|
||||||
guint GSEAL (have_width) : 1;
|
|
||||||
guint GSEAL (have_height) : 1;
|
|
||||||
guint GSEAL (ignore_hidden) : 1;
|
|
||||||
|
|
||||||
GtkRequisition GSEAL (requisition);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GtkSizeGroupClass
|
struct _GtkSizeGroupClass
|
||||||
|
Loading…
Reference in New Issue
Block a user