[egg-list-box/flow-box-enhancements] Drop private pointer
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [egg-list-box/flow-box-enhancements] Drop private pointer
- Date: Sun, 29 Sep 2013 07:37:16 +0000 (UTC)
commit 4932b627d88f390571ea35c448f415f9381d34f4
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Sep 28 20:39:29 2013 -0400
Drop private pointer
We can do without nowadays.
egg-flow-box.c | 553 ++++++++++++++++++++++++--------------------------------
egg-flow-box.h | 8 +-
2 files changed, 237 insertions(+), 324 deletions(-)
---
diff --git a/egg-flow-box.c b/egg-flow-box.c
index c35ae25..d08ca49 100644
--- a/egg-flow-box.c
+++ b/egg-flow-box.c
@@ -113,6 +113,7 @@ enum {
PROP_ACTIVATE_ON_SINGLE_CLICK
};
+typedef struct _EggFlowBoxPrivate EggFlowBoxPrivate;
struct _EggFlowBoxPrivate {
GtkOrientation orientation;
GtkAlign halign_policy;
@@ -161,19 +162,20 @@ static guint signals[LAST_SIGNAL] = { 0 };
static guint child_signals[CHILD_LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE_WITH_CODE (EggFlowBox, egg_flow_box, GTK_TYPE_CONTAINER,
+ G_ADD_PRIVATE (EggFlowBox)
G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL))
G_DEFINE_TYPE_WITH_PRIVATE (EggFlowBoxChild, egg_flow_box_child, GTK_TYPE_BIN)
+#define BOX_PRIV(box) ((EggFlowBoxPrivate*)egg_flow_box_get_instance_private ((EggFlowBox*)(box)))
+#define CHILD_PRIV(child) ((EggFlowBoxChildPrivate*)egg_flow_box_child_get_instance_private
((EggFlowBoxChild*)(child)))
-#define ORIENTATION_ALIGN_POLICY(box) \
- (((EggFlowBox *)(box))->priv->orientation == GTK_ORIENTATION_HORIZONTAL ? \
- ((EggFlowBox *)(box))->priv->halign_policy : \
- ((EggFlowBox *)(box))->priv->valign_policy)
+#define ORIENTATION_ALIGN_POLICY(box) \
+ (BOX_PRIV(box)->orientation == GTK_ORIENTATION_HORIZONTAL ? \
+ BOX_PRIV(box)->halign_policy : BOX_PRIV(box)->valign_policy)
-#define OPPOSING_ORIENTATION_ALIGN_POLICY(box) \
- (((EggFlowBox *)(box))->priv->orientation == GTK_ORIENTATION_HORIZONTAL ? \
- ((EggFlowBox *)(box))->priv->valign_policy : \
- ((EggFlowBox *)(box))->priv->halign_policy)
+#define OPPOSING_ORIENTATION_ALIGN_POLICY(box) \
+ (BOX_PRIV(box)->orientation == GTK_ORIENTATION_HORIZONTAL ? \
+ BOX_PRIV(box)->valign_policy : BOX_PRIV(box)->halign_policy)
static void egg_flow_box_update_cursor (EggFlowBox *box,
@@ -585,7 +587,7 @@ egg_flow_box_child_get_index (EggFlowBoxChild *child)
g_return_val_if_fail (EGG_IS_FLOW_BOX_CHILD (child), -1);
- priv = egg_flow_box_child_get_instance_private (child);
+ priv = CHILD_PRIV (child);
if (priv->iter != NULL)
return g_sequence_iter_get_position (priv->iter);
@@ -597,12 +599,16 @@ void
egg_flow_box_set_hadjustment (EggFlowBox *box,
GtkAdjustment *adjustment)
{
- EggFlowBoxPrivate *priv = box->priv;
+ EggFlowBoxPrivate *priv;
+
+ g_return_if_fail (EGG_IS_FLOW_BOX (box));
+ g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
- g_return_if_fail (box != NULL);
+ priv = BOX_PRIV (box);
g_object_ref (adjustment);
- g_clear_object (&priv->hadjustment);
+ if (priv->hadjustment)
+ g_object_unref (priv->hadjustment);
priv->hadjustment = adjustment;
gtk_container_set_focus_hadjustment (GTK_CONTAINER (box), adjustment);
}
@@ -611,12 +617,16 @@ void
egg_flow_box_set_vadjustment (EggFlowBox *box,
GtkAdjustment *adjustment)
{
- EggFlowBoxPrivate *priv = box->priv;
+ EggFlowBoxPrivate *priv;
+
+ g_return_if_fail (EGG_IS_FLOW_BOX (box));
+ g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
- g_return_if_fail (box != NULL);
+ priv = BOX_PRIV (box);
g_object_ref (adjustment);
- g_clear_object (&priv->vadjustment);
+ if (priv->vadjustment)
+ g_object_unref (priv->vadjustment);
priv->vadjustment = adjustment;
gtk_container_set_focus_vadjustment (GTK_CONTAINER (box), adjustment);
}
@@ -633,9 +643,9 @@ egg_flow_box_set_vadjustment (EggFlowBox *box,
gboolean
egg_flow_box_get_homogeneous (EggFlowBox *box)
{
- g_return_val_if_fail (GTK_IS_BOX (box), FALSE);
+ g_return_val_if_fail (EGG_IS_FLOW_BOX (box), FALSE);
- return box->priv->homogeneous;
+ return BOX_PRIV (box)->homogeneous;
}
/**
@@ -652,15 +662,14 @@ void
egg_flow_box_set_homogeneous (EggFlowBox *box,
gboolean homogeneous)
{
- EggFlowBoxPrivate *priv;
-
g_return_if_fail (EGG_IS_FLOW_BOX (box));
- priv = box->priv;
+ homogeneous = homogeneous != FALSE;
- if ((homogeneous ? TRUE : FALSE) != priv->homogeneous)
+ if (BOX_PRIV (box)->homogeneous != homogeneous)
{
- priv->homogeneous = homogeneous ? TRUE : FALSE;
+ BOX_PRIV (box)->homogeneous = homogeneous;
+
g_object_notify (G_OBJECT (box), "homogeneous");
gtk_widget_queue_resize (GTK_WIDGET (box));
}
@@ -669,7 +678,7 @@ egg_flow_box_set_homogeneous (EggFlowBox *box,
/* Children are visible if they are shown by the app (visible)
* and not filtered out (child_visible) by the box
*/
-static gboolean
+static inline gboolean
child_is_visible (GtkWidget *child)
{
return gtk_widget_get_visible (child) &&
@@ -679,21 +688,18 @@ child_is_visible (GtkWidget *child)
static gint
get_visible_children (EggFlowBox *box)
{
- EggFlowBoxPrivate *priv = box->priv;
GSequenceIter *iter;
gint i = 0;
- for (iter = g_sequence_get_begin_iter (priv->children);
+ for (iter = g_sequence_get_begin_iter (BOX_PRIV (box)->children);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
GtkWidget *child;
child = g_sequence_get (iter);
- if (!child_is_visible (child))
- continue;
-
- i++;
+ if (child_is_visible (child))
+ i++;
}
return i;
@@ -708,12 +714,11 @@ get_max_item_size (EggFlowBox *box,
gint *min_size,
gint *nat_size)
{
- EggFlowBoxPrivate *priv = box->priv;
GSequenceIter *iter;
gint max_min_size = 0;
gint max_nat_size = 0;
- for (iter = g_sequence_get_begin_iter (priv->children);
+ for (iter = g_sequence_get_begin_iter (BOX_PRIV (box)->children);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
@@ -742,8 +747,9 @@ get_max_item_size (EggFlowBox *box,
}
-/* Gets the largest minimum/natural size for a given size
- * (used to get the largest item heights for a fixed item width and the opposite) */
+/* Gets the largest minimum/natural size for a given size (used to get
+ * the largest item heights for a fixed item width and the opposite)
+ */
static void
get_largest_size_for_opposing_orientation (EggFlowBox *box,
GtkOrientation orientation,
@@ -751,12 +757,11 @@ get_largest_size_for_opposing_orientation (EggFlowBox *box,
gint *min_item_size,
gint *nat_item_size)
{
- EggFlowBoxPrivate *priv = box->priv;
GSequenceIter *iter;
gint max_min_size = 0;
gint max_nat_size = 0;
- for (iter = g_sequence_get_begin_iter (priv->children);
+ for (iter = g_sequence_get_begin_iter (BOX_PRIV (box)->children);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
@@ -788,10 +793,10 @@ get_largest_size_for_opposing_orientation (EggFlowBox *box,
*nat_item_size = max_nat_size;
}
-
/* Gets the largest minimum/natural size on a single line for a given size
* (used to get the largest line heights for a fixed item width and the opposite
- * while itterating over a list of children, note the new index is returned) */
+ * while iterating over a list of children, note the new index is returned)
+ */
static GSequenceIter *
get_largest_size_for_line_in_opposing_orientation (EggFlowBox *box,
GtkOrientation orientation,
@@ -863,7 +868,6 @@ gather_aligned_item_requests (EggFlowBox *box,
gint n_children,
GtkRequestedSize *item_sizes)
{
- EggFlowBoxPrivate *priv = box->priv;
GSequenceIter *iter;
gint i;
gint extra_items, natural_line_size = 0;
@@ -871,7 +875,7 @@ gather_aligned_item_requests (EggFlowBox *box,
extra_items = n_children % line_length;
i = 0;
- for (iter = g_sequence_get_begin_iter (priv->children);
+ for (iter = g_sequence_get_begin_iter (BOX_PRIV (box)->children);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
@@ -937,7 +941,8 @@ fit_aligned_item_requests (EggFlowBox *box,
sizes);
/* Try columnizing the whole thing and adding an item to the end of the line;
- * try to fit as many columns into the available size as possible */
+ * try to fit as many columns into the available size as possible
+ */
for (try_length = *line_length + 1; try_line_size < avail_size; try_length++)
{
try_sizes = g_new0 (GtkRequestedSize, try_length);
@@ -1002,7 +1007,7 @@ egg_flow_box_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
EggFlowBox *box = EGG_FLOW_BOX (widget);
- EggFlowBoxPrivate *priv = box->priv;
+ EggFlowBoxPrivate *priv = BOX_PRIV (box);
GtkAllocation child_allocation;
gint avail_size, avail_other_size, min_items, item_spacing, line_spacing;
GtkAlign item_align;
@@ -1044,8 +1049,7 @@ egg_flow_box_size_allocate (GtkWidget *widget,
{
avail_size = allocation->width;
avail_other_size = allocation->height;
- item_spacing = priv->column_spacing;
- line_spacing = priv->row_spacing;
+ item_spacing = priv->column_spacing; line_spacing = priv->row_spacing;
}
else /* GTK_ORIENTATION_VERTICAL */
{
@@ -1382,7 +1386,7 @@ egg_flow_box_remove (GtkContainer *container,
GtkWidget *widget)
{
EggFlowBox *box = EGG_FLOW_BOX (container);
- EggFlowBoxPrivate *priv = box->priv;
+ EggFlowBoxPrivate *priv = BOX_PRIV (box);
gboolean was_visible;
gboolean was_selected;
EggFlowBoxChild *child;
@@ -1400,7 +1404,7 @@ egg_flow_box_remove (GtkContainer *container,
}
}
- child_priv = egg_flow_box_child_get_instance_private (child);
+ child_priv = CHILD_PRIV (child);
was_visible = child_is_visible (GTK_WIDGET (child));
was_selected = child_priv->selected;
@@ -1428,12 +1432,10 @@ egg_flow_box_forall (GtkContainer *container,
GtkCallback callback,
gpointer callback_target)
{
- EggFlowBox *box = EGG_FLOW_BOX (container);
- EggFlowBoxPrivate *priv = box->priv;
GSequenceIter *iter;
GtkWidget *child;
- iter = g_sequence_get_begin_iter (priv->children);
+ iter = g_sequence_get_begin_iter (BOX_PRIV (container)->children);
while (!g_sequence_iter_is_end (iter))
{
child = g_sequence_get (iter);
@@ -1452,9 +1454,8 @@ static GtkSizeRequestMode
egg_flow_box_get_request_mode (GtkWidget *widget)
{
EggFlowBox *box = EGG_FLOW_BOX (widget);
- EggFlowBoxPrivate *priv = box->priv;
- return (priv->orientation == GTK_ORIENTATION_HORIZONTAL) ?
+ return (BOX_PRIV (box)->orientation == GTK_ORIENTATION_HORIZONTAL) ?
GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH : GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT;
}
@@ -1467,7 +1468,6 @@ get_largest_aligned_line_length (EggFlowBox *box,
gint *min_size,
gint *nat_size)
{
- EggFlowBoxPrivate *priv = box->priv;
GSequenceIter *iter;
gint max_min_size = 0;
gint max_nat_size = 0;
@@ -1475,16 +1475,16 @@ get_largest_aligned_line_length (EggFlowBox *box,
GtkRequestedSize *aligned_item_sizes;
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- spacing = priv->column_spacing;
+ spacing = BOX_PRIV (box)->column_spacing;
else
- spacing = priv->row_spacing;
+ spacing = BOX_PRIV (box)->row_spacing;
aligned_item_sizes = g_new0 (GtkRequestedSize, line_length);
/* Get the largest sizes of each index in the line.
*/
i = 0;
- for (iter = g_sequence_get_begin_iter (priv->children);
+ for (iter = g_sequence_get_begin_iter (BOX_PRIV (box)->children);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
@@ -1537,7 +1537,7 @@ egg_flow_box_get_preferred_width (GtkWidget *widget,
gint *natural_size)
{
EggFlowBox *box = EGG_FLOW_BOX (widget);
- EggFlowBoxPrivate *priv = box->priv;
+ EggFlowBoxPrivate *priv = BOX_PRIV (box);
gint min_item_width, nat_item_width;
gint min_items, nat_items;
gint min_width, nat_width;
@@ -1622,8 +1622,8 @@ egg_flow_box_get_preferred_height (GtkWidget *widget,
gint *minimum_size,
gint *natural_size)
{
- EggFlowBox *box = EGG_FLOW_BOX (widget);
- EggFlowBoxPrivate *priv = box->priv;
+ EggFlowBox *box = EGG_FLOW_BOX (widget);
+ EggFlowBoxPrivate *priv = BOX_PRIV (box);
gint min_item_height, nat_item_height;
gint min_items, nat_items;
gint min_height, nat_height;
@@ -1644,7 +1644,7 @@ egg_flow_box_get_preferred_height (GtkWidget *widget,
}
else /* GTK_ORIENTATION_VERTICAL */
{
- min_height = nat_height = 0;
+ min_height = nat_height = 0;
if (! priv->homogeneous)
{
@@ -1680,9 +1680,11 @@ egg_flow_box_get_preferred_height (GtkWidget *widget,
}
}
- else /* In homogeneous mode; vertically oriented boxs
- * give the same height to all children */
+ else
{
+ /* In homogeneous mode; vertically oriented boxes
+ * give the same height to all children
+ */
get_max_item_size (box,
GTK_ORIENTATION_VERTICAL,
&min_item_height,
@@ -1710,7 +1712,7 @@ egg_flow_box_get_preferred_height_for_width (GtkWidget *widget,
gint *natural_height)
{
EggFlowBox *box = EGG_FLOW_BOX (widget);
- EggFlowBoxPrivate *priv = box->priv;
+ EggFlowBoxPrivate *priv = BOX_PRIV (box);
gint min_item_width, nat_item_width;
gint min_items;
gint min_height, nat_height;
@@ -1734,13 +1736,14 @@ egg_flow_box_get_preferred_height_for_width (GtkWidget *widget,
/* Make sure its no smaller than the minimum */
GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, &min_width, NULL);
- avail_size = MAX (width, min_width);
+ avail_size = MAX (width, min_width);
if (avail_size <= 0)
goto out;
get_max_item_size (box, GTK_ORIENTATION_HORIZONTAL, &min_item_width, &nat_item_width);
if (nat_item_width <= 0)
goto out;
+
/* By default flow at the natural item width */
line_length = avail_size / (nat_item_width + priv->column_spacing);
@@ -1749,7 +1752,8 @@ egg_flow_box_get_preferred_height_for_width (GtkWidget *widget,
line_length++;
/* Its possible we were allocated just less than the natural width of the
- * minimum item flow length */
+ * minimum item flow length
+ */
line_length = MAX (min_items, line_length);
line_length = MIN (line_length, priv->max_children_per_line);
@@ -1772,7 +1776,8 @@ egg_flow_box_get_preferred_height_for_width (GtkWidget *widget,
gint lines;
/* Here we just use the largest height-for-width and
- * add up the size accordingly */
+ * add up the size accordingly
+ */
get_largest_size_for_opposing_orientation (box,
GTK_ORIENTATION_HORIZONTAL,
item_size,
@@ -1868,7 +1873,7 @@ egg_flow_box_get_preferred_width_for_height (GtkWidget *widget,
gint *natural_width)
{
EggFlowBox *box = EGG_FLOW_BOX (widget);
- EggFlowBoxPrivate *priv = box->priv;
+ EggFlowBoxPrivate *priv = BOX_PRIV (box);
gint min_item_height, nat_item_height;
gint min_items;
gint min_width, nat_width;
@@ -1911,7 +1916,8 @@ egg_flow_box_get_preferred_width_for_height (GtkWidget *widget,
line_length++;
/* Its possible we were allocated just less than the natural width of the
- * minimum item flow length */
+ * minimum item flow length
+ */
line_length = MAX (min_items, line_length);
line_length = MIN (line_length, priv->max_children_per_line);
@@ -1921,7 +1927,7 @@ egg_flow_box_get_preferred_width_for_height (GtkWidget *widget,
/* Cut out the expand space if we're not distributing any */
if (priv->valign_policy != GTK_ALIGN_FILL)
{
- item_size = MIN (item_size, nat_item_height);
+ item_size = MIN (item_size, nat_item_height);
extra_pixels = 0;
}
else
@@ -1934,7 +1940,8 @@ egg_flow_box_get_preferred_width_for_height (GtkWidget *widget,
gint lines;
/* Here we just use the largest height-for-width and
- * add up the size accordingly */
+ * add up the size accordingly
+ */
get_largest_size_for_opposing_orientation (box,
GTK_ORIENTATION_VERTICAL,
item_size,
@@ -2021,7 +2028,7 @@ egg_flow_box_get_preferred_width_for_height (GtkWidget *widget,
/**
* egg_flow_box_set_halign_policy:
* @box: An #EggFlowBox
- * @align: The #GtkAlign to use.
+ * @align: The #GtkAlign to use
*
* Sets the horizontal align policy for @box's children.
*/
@@ -2029,18 +2036,13 @@ void
egg_flow_box_set_halign_policy (EggFlowBox *box,
GtkAlign align)
{
- EggFlowBoxPrivate *priv;
-
g_return_if_fail (EGG_IS_FLOW_BOX (box));
- priv = box->priv;
-
- if (priv->halign_policy != align)
+ if (BOX_PRIV (box)->halign_policy != align)
{
- priv->halign_policy = align;
+ BOX_PRIV (box)->halign_policy = align;
gtk_widget_queue_resize (GTK_WIDGET (box));
-
g_object_notify (G_OBJECT (box), "halign-policy");
}
}
@@ -2058,14 +2060,14 @@ egg_flow_box_get_halign_policy (EggFlowBox *box)
{
g_return_val_if_fail (EGG_IS_FLOW_BOX (box), FALSE);
- return box->priv->halign_policy;
+ return BOX_PRIV (box)->halign_policy;
}
/**
* egg_flow_box_set_valign_policy:
* @box: An #EggFlowBox
- * @align: The #GtkAlign to use.
+ * @align: The #GtkAlign to use
*
* Sets the vertical alignment policy for @box's children.
*/
@@ -2073,18 +2075,13 @@ void
egg_flow_box_set_valign_policy (EggFlowBox *box,
GtkAlign align)
{
- EggFlowBoxPrivate *priv;
-
g_return_if_fail (EGG_IS_FLOW_BOX (box));
- priv = box->priv;
-
- if (priv->valign_policy != align)
+ if (BOX_PRIV (box)->valign_policy != align)
{
- priv->valign_policy = align;
+ BOX_PRIV (box)->valign_policy = align;
gtk_widget_queue_resize (GTK_WIDGET (box));
-
g_object_notify (G_OBJECT (box), "valign-policy");
}
}
@@ -2102,33 +2099,28 @@ egg_flow_box_get_valign_policy (EggFlowBox *box)
{
g_return_val_if_fail (EGG_IS_FLOW_BOX (box), FALSE);
- return box->priv->valign_policy;
+ return BOX_PRIV (box)->valign_policy;
}
/**
* egg_flow_box_set_row_spacing:
* @box: An #EggFlowBox
- * @spacing: The spacing to use.
+ * @spacing: The spacing to use
*
* Sets the vertical space to add between children.
*/
void
-egg_flow_box_set_row_spacing (EggFlowBox *box,
- guint spacing)
+egg_flow_box_set_row_spacing (EggFlowBox *box,
+ guint spacing)
{
- EggFlowBoxPrivate *priv;
-
g_return_if_fail (EGG_IS_FLOW_BOX (box));
- priv = box->priv;
-
- if (priv->row_spacing != spacing)
+ if (BOX_PRIV (box)->row_spacing != spacing)
{
- priv->row_spacing = spacing;
+ BOX_PRIV (box)->row_spacing = spacing;
gtk_widget_queue_resize (GTK_WIDGET (box));
-
g_object_notify (G_OBJECT (box), "vertical-spacing");
}
}
@@ -2142,36 +2134,31 @@ egg_flow_box_set_row_spacing (EggFlowBox *box,
* Returns: The vertical spacing.
*/
guint
-egg_flow_box_get_row_spacing (EggFlowBox *box)
+egg_flow_box_get_row_spacing (EggFlowBox *box)
{
g_return_val_if_fail (EGG_IS_FLOW_BOX (box), FALSE);
- return box->priv->row_spacing;
+ return BOX_PRIV (box)->row_spacing;
}
/**
* egg_flow_box_set_column_spacing:
* @box: An #EggFlowBox
- * @spacing: The spacing to use.
+ * @spacing: The spacing to use
*
* Sets the horizontal space to add between children.
*/
void
-egg_flow_box_set_column_spacing (EggFlowBox *box,
- guint spacing)
+egg_flow_box_set_column_spacing (EggFlowBox *box,
+ guint spacing)
{
- EggFlowBoxPrivate *priv;
-
g_return_if_fail (EGG_IS_FLOW_BOX (box));
- priv = box->priv;
-
- if (priv->column_spacing != spacing)
+ if (BOX_PRIV (box)->column_spacing != spacing)
{
- priv->column_spacing = spacing;
+ BOX_PRIV (box)->column_spacing = spacing;
gtk_widget_queue_resize (GTK_WIDGET (box));
-
g_object_notify (G_OBJECT (box), "horizontal-spacing");
}
}
@@ -2189,7 +2176,7 @@ egg_flow_box_get_column_spacing (EggFlowBox *box)
{
g_return_val_if_fail (EGG_IS_FLOW_BOX (box), FALSE);
- return box->priv->column_spacing;
+ return BOX_PRIV (box)->column_spacing;
}
/**
@@ -2204,18 +2191,13 @@ void
egg_flow_box_set_min_children_per_line (EggFlowBox *box,
guint n_children)
{
- EggFlowBoxPrivate *priv;
-
g_return_if_fail (EGG_IS_FLOW_BOX (box));
- priv = box->priv;
-
- if (priv->min_children_per_line != n_children)
+ if (BOX_PRIV (box)->min_children_per_line != n_children)
{
- priv->min_children_per_line = n_children;
+ BOX_PRIV (box)->min_children_per_line = n_children;
gtk_widget_queue_resize (GTK_WIDGET (box));
-
g_object_notify (G_OBJECT (box), "min-children-per-line");
}
}
@@ -2233,7 +2215,7 @@ egg_flow_box_get_min_children_per_line (EggFlowBox *box)
{
g_return_val_if_fail (EGG_IS_FLOW_BOX (box), FALSE);
- return box->priv->min_children_per_line;
+ return BOX_PRIV (box)->min_children_per_line;
}
/**
@@ -2252,18 +2234,13 @@ void
egg_flow_box_set_max_children_per_line (EggFlowBox *box,
guint n_children)
{
- EggFlowBoxPrivate *priv;
-
g_return_if_fail (EGG_IS_FLOW_BOX (box));
- priv = box->priv;
-
- if (priv->max_children_per_line != n_children)
+ if (BOX_PRIV (box)->max_children_per_line != n_children)
{
- priv->max_children_per_line = n_children;
+ BOX_PRIV (box)->max_children_per_line = n_children;
gtk_widget_queue_resize (GTK_WIDGET (box));
-
g_object_notify (G_OBJECT (box), "max-children-per-line");
}
}
@@ -2281,7 +2258,7 @@ egg_flow_box_get_max_children_per_line (EggFlowBox *box)
{
g_return_val_if_fail (EGG_IS_FLOW_BOX (box), FALSE);
- return box->priv->max_children_per_line;
+ return BOX_PRIV (box)->max_children_per_line;
}
/**
@@ -2300,11 +2277,11 @@ egg_flow_box_set_activate_on_single_click (EggFlowBox *box,
single = single != FALSE;
- if (box->priv->activate_on_single_click == single)
- return;
-
- box->priv->activate_on_single_click = single;
- g_object_notify (G_OBJECT (box), "activate-on-single-click");
+ if (BOX_PRIV (box)->activate_on_single_click != single)
+ {
+ BOX_PRIV (box)->activate_on_single_click = single;
+ g_object_notify (G_OBJECT (box), "activate-on-single-click");
+ }
}
/**
@@ -2320,17 +2297,17 @@ egg_flow_box_get_activate_on_single_click (EggFlowBox *box)
{
g_return_val_if_fail (EGG_IS_FLOW_BOX (box), FALSE);
- return box->priv->activate_on_single_click;
+ return BOX_PRIV (box)->activate_on_single_click;
}
static void
-egg_flow_box_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+egg_flow_box_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- EggFlowBox *box = EGG_FLOW_BOX (object);
- EggFlowBoxPrivate *priv = box->priv;
+ EggFlowBox *box = EGG_FLOW_BOX (object);
+ EggFlowBoxPrivate *priv = BOX_PRIV (box);
switch (prop_id)
{
@@ -2377,13 +2354,12 @@ egg_flow_box_set_property (GObject *object,
GParamSpec *pspec)
{
EggFlowBox *box = EGG_FLOW_BOX (object);
- EggFlowBoxPrivate *priv = box->priv;
+ EggFlowBoxPrivate *priv = BOX_PRIV (box);
switch (prop_id)
{
case PROP_ORIENTATION:
priv->orientation = g_value_get_enum (value);
-
/* Re-box the children in the new orientation */
gtk_widget_queue_resize (GTK_WIDGET (box));
break;
@@ -2425,12 +2401,11 @@ egg_flow_box_find_child_at_pos (EggFlowBox *box,
gint x,
gint y)
{
- EggFlowBoxPrivate *priv = box->priv;
GtkWidget *child;
GSequenceIter *iter;
GtkAllocation allocation;
- for (iter = g_sequence_get_begin_iter (priv->children);
+ for (iter = g_sequence_get_begin_iter (BOX_PRIV (box)->children);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
@@ -2447,10 +2422,10 @@ egg_flow_box_find_child_at_pos (EggFlowBox *box,
}
static void
-egg_flow_box_update_prelight (EggFlowBox *box,
+egg_flow_box_update_prelight (EggFlowBox *box,
EggFlowBoxChild *child)
{
- EggFlowBoxPrivate *priv = box->priv;
+ EggFlowBoxPrivate *priv = BOX_PRIV (box);
if (child != priv->prelight_child)
{
@@ -2460,10 +2435,10 @@ egg_flow_box_update_prelight (EggFlowBox *box,
}
static void
-egg_flow_box_update_active (EggFlowBox *box,
+egg_flow_box_update_active (EggFlowBox *box,
EggFlowBoxChild *child)
{
- EggFlowBoxPrivate *priv = box->priv;
+ EggFlowBoxPrivate *priv = BOX_PRIV (box);
gboolean val;
val = priv->active_child == child;
@@ -2482,7 +2457,6 @@ egg_flow_box_enter_notify_event (GtkWidget *widget,
EggFlowBox *box = EGG_FLOW_BOX (widget);
EggFlowBoxChild *child;
-
if (event->window != gtk_widget_get_window (GTK_WIDGET (box)))
return FALSE;
@@ -2554,11 +2528,11 @@ egg_flow_box_button_press_event (GtkWidget *widget,
GdkEventButton *event)
{
EggFlowBox *box = EGG_FLOW_BOX (widget);
- EggFlowBoxPrivate *priv = box->priv;
+ EggFlowBoxPrivate *priv = BOX_PRIV (box);
+ EggFlowBoxChild *child;
if (event->button == GDK_BUTTON_PRIMARY)
{
- EggFlowBoxChild *child;
child = egg_flow_box_find_child_at_pos (box, event->x, event->y);
if (child != NULL)
{
@@ -2579,12 +2553,10 @@ egg_flow_box_child_set_selected (EggFlowBoxChild *child,
gboolean selected)
{
EggFlowBox *box;
- EggFlowBoxChildPrivate *priv;
- priv = egg_flow_box_child_get_instance_private (child);
- if (priv->selected != selected)
+ if (CHILD_PRIV (child)->selected != selected)
{
- priv->selected = selected;
+ CHILD_PRIV (child)->selected = selected;
if (selected)
gtk_widget_set_state_flags (GTK_WIDGET (child),
GTK_STATE_FLAG_SELECTED, FALSE);
@@ -2607,19 +2579,18 @@ static gboolean
egg_flow_box_unselect_all_internal (EggFlowBox *box)
{
EggFlowBoxChild *child;
- EggFlowBoxChildPrivate *priv;
GSequenceIter *iter;
gboolean dirty = FALSE;
- if (box->priv->selection_mode == GTK_SELECTION_NONE)
+ if (BOX_PRIV (box)->selection_mode == GTK_SELECTION_NONE)
return FALSE;
- for (iter = g_sequence_get_begin_iter (box->priv->children);
+ for (iter = g_sequence_get_begin_iter (BOX_PRIV (box)->children);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
child = g_sequence_get (iter);
- dirty != egg_flow_box_child_set_selected (child, FALSE);
+ dirty |= egg_flow_box_child_set_selected (child, FALSE);
}
return dirty;
@@ -2629,15 +2600,12 @@ static void
egg_flow_box_unselect_child_info (EggFlowBox *box,
EggFlowBoxChild *child)
{
- EggFlowBoxChildPrivate *priv;
-
- priv = egg_flow_box_child_get_instance_private (child);
- if (!priv->selected)
+ if (!CHILD_PRIV (child)->selected)
return;
- if (box->priv->selection_mode == GTK_SELECTION_NONE)
+ if (BOX_PRIV (box)->selection_mode == GTK_SELECTION_NONE)
return;
- else if (box->priv->selection_mode != GTK_SELECTION_MULTIPLE)
+ else if (BOX_PRIV (box)->selection_mode != GTK_SELECTION_MULTIPLE)
egg_flow_box_unselect_all_internal (box);
else
egg_flow_box_child_set_selected (child, FALSE);
@@ -2649,9 +2617,7 @@ static void
egg_flow_box_update_cursor (EggFlowBox *box,
EggFlowBoxChild *child)
{
- EggFlowBoxPrivate *priv = box->priv;
-
- priv->cursor_child = child;
+ BOX_PRIV (box)->cursor_child = child;
gtk_widget_grab_focus (GTK_WIDGET (child));
gtk_widget_queue_draw (GTK_WIDGET (child));
_egg_flow_box_accessible_update_cursor (GTK_WIDGET (box), GTK_WIDGET (child));
@@ -2661,18 +2627,16 @@ static void
egg_flow_box_select_child_info (EggFlowBox *box,
EggFlowBoxChild *child)
{
- EggFlowBoxChildPrivate *child_priv;
-
- child_priv = egg_flow_box_child_get_instance_private (child);
- if (child_priv->selected)
+ if (CHILD_PRIV (child)->selected)
return;
- if (box->priv->selection_mode == GTK_SELECTION_NONE)
+
+ if (BOX_PRIV (box)->selection_mode == GTK_SELECTION_NONE)
return;
- if (box->priv->selection_mode != GTK_SELECTION_MULTIPLE)
+ if (BOX_PRIV (box)->selection_mode != GTK_SELECTION_MULTIPLE)
egg_flow_box_unselect_all_internal (box);
egg_flow_box_child_set_selected (child, TRUE);
- box->priv->selected_child = child;
+ BOX_PRIV (box)->selected_child = child;
g_signal_emit (box, signals[SELECTED_CHILDREN_CHANGED], 0);
@@ -2688,20 +2652,14 @@ egg_flow_box_select_all_between (EggFlowBox *box,
EggFlowBoxChildPrivate *priv;
if (child1)
- {
- priv = egg_flow_box_child_get_instance_private (child1);
- iter1 = priv->iter;
- }
+ iter1 = CHILD_PRIV (child1)->iter;
else
- iter1 = g_sequence_get_begin_iter (box->priv->children);
+ iter1 = g_sequence_get_begin_iter (BOX_PRIV (box)->children);
if (child2)
- {
- priv = egg_flow_box_child_get_instance_private (child2);
- iter2 = priv->iter;
- }
+ iter2 = CHILD_PRIV (child2)->iter;
else
- iter2 = g_sequence_get_end_iter (box->priv->children);
+ iter2 = g_sequence_get_end_iter (BOX_PRIV (box)->children);
if (g_sequence_iter_compare (iter2, iter1) < 0)
{
@@ -2710,7 +2668,9 @@ egg_flow_box_select_all_between (EggFlowBox *box,
iter2 = iter;
}
- for (iter = iter1; !g_sequence_iter_is_end (iter); iter = g_sequence_iter_next (iter))
+ for (iter = iter1;
+ !g_sequence_iter_is_end (iter);
+ iter = g_sequence_iter_next (iter))
{
GtkWidget *child;
@@ -2729,10 +2689,7 @@ egg_flow_box_update_selection (EggFlowBox *box,
gboolean modify,
gboolean extend)
{
- EggFlowBoxPrivate *priv = box->priv;
- EggFlowBoxChildPrivate *child_priv;
-
- child_priv = egg_flow_box_child_get_instance_private (child);
+ EggFlowBoxPrivate *priv = BOX_PRIV (box);
egg_flow_box_update_cursor (box, child);
@@ -2749,10 +2706,10 @@ egg_flow_box_update_selection (EggFlowBox *box,
{
gboolean was_selected;
- was_selected = child_priv->selected;
+ was_selected = CHILD_PRIV (child)->selected;
egg_flow_box_unselect_all_internal (box);
egg_flow_box_child_set_selected (child, modify ? !was_selected : TRUE);
- priv->selected_child = child_priv->selected ? child : NULL;
+ priv->selected_child = CHILD_PRIV (child)->selected ? child : NULL;
}
else /* GTK_SELECTION_MULTIPLE */
{
@@ -2769,7 +2726,7 @@ egg_flow_box_update_selection (EggFlowBox *box,
}
else
{
- egg_flow_box_child_set_selected (child, modify ? !child_priv->selected : TRUE);
+ egg_flow_box_child_set_selected (child, modify ? !CHILD_PRIV (child)->selected : TRUE);
priv->selected_child = child;
}
}
@@ -2793,7 +2750,7 @@ egg_flow_box_button_release_event (GtkWidget *widget,
GdkEventButton *event)
{
EggFlowBox *box = EGG_FLOW_BOX (widget);
- EggFlowBoxPrivate *priv = box->priv;
+ EggFlowBoxPrivate *priv = BOX_PRIV (box);
gboolean modify_selection;
gboolean extend_selection;
@@ -2858,14 +2815,13 @@ egg_flow_box_get_next_focusable (EggFlowBox *box,
static GSequenceIter *
egg_flow_box_get_first_focusable (EggFlowBox *box)
{
- EggFlowBoxPrivate *priv = box->priv;
GSequenceIter *iter;
EggFlowBoxChild *child;
- iter = g_sequence_get_begin_iter (priv->children);
+ iter = g_sequence_get_begin_iter (BOX_PRIV (box)->children);
child = g_sequence_get (iter);
if (child_is_visible (GTK_WIDGET (child)) &&
- gtk_widget_is_sensitive (GTK_WIDGET (child)))
+ gtk_widget_is_sensitive (GTK_WIDGET (child)))
return iter;
return egg_flow_box_get_next_focusable (box, iter);
@@ -2874,10 +2830,9 @@ egg_flow_box_get_first_focusable (EggFlowBox *box)
static GSequenceIter *
egg_flow_box_get_last_focusable (EggFlowBox *box)
{
- EggFlowBoxPrivate *priv = box->priv;
GSequenceIter *iter;
- iter = g_sequence_get_end_iter (priv->children);
+ iter = g_sequence_get_end_iter (BOX_PRIV (box)->children);
return egg_flow_box_get_previous_focusable (box, iter);
}
@@ -2892,7 +2847,7 @@ egg_flow_box_get_above_focusable (EggFlowBox *box,
while (TRUE)
{
i = 0;
- while (i < box->priv->cur_children_per_line)
+ while (i < BOX_PRIV (box)->cur_children_per_line)
{
if (g_sequence_iter_is_begin (iter))
return NULL;
@@ -2918,7 +2873,7 @@ egg_flow_box_get_below_focusable (EggFlowBox *box,
while (TRUE)
{
i = 0;
- while (i < box->priv->cur_children_per_line)
+ while (i < BOX_PRIV (box)->cur_children_per_line)
{
iter = g_sequence_iter_next (iter);
if (g_sequence_iter_is_end (iter))
@@ -2935,14 +2890,12 @@ egg_flow_box_get_below_focusable (EggFlowBox *box,
}
static gboolean
-egg_flow_box_focus (GtkWidget *widget,
- GtkDirectionType direction)
+egg_flow_box_focus (GtkWidget *widget,
+ GtkDirectionType direction)
{
EggFlowBox *box = EGG_FLOW_BOX (widget);
- EggFlowBoxPrivate *priv = box->priv;
GtkWidget *focus_child;
GSequenceIter *iter;
- EggFlowBoxChildPrivate *child_priv;
gboolean had_focus = FALSE;
GtkWidget *recurse_into;
@@ -2960,26 +2913,24 @@ egg_flow_box_focus (GtkWidget *widget,
if (gtk_widget_child_focus (focus_child, direction))
return TRUE;
- child_priv = egg_flow_box_child_get_instance_private (EGG_FLOW_BOX_CHILD (focus_child));
+ iter = CHILD_PRIV (focus_child)->iter;
- if (direction == GTK_DIR_LEFT ||
- direction == GTK_DIR_TAB_BACKWARD)
- iter = egg_flow_box_get_previous_focusable (box, child_priv->iter);
- else if (direction == GTK_DIR_RIGHT ||
- direction == GTK_DIR_TAB_FORWARD)
- iter = egg_flow_box_get_next_focusable (box, child_priv->iter);
+ if (direction == GTK_DIR_LEFT || direction == GTK_DIR_TAB_BACKWARD)
+ iter = egg_flow_box_get_previous_focusable (box, iter);
+ else if (direction == GTK_DIR_RIGHT || direction == GTK_DIR_TAB_FORWARD)
+ iter = egg_flow_box_get_next_focusable (box, iter);
else if (direction == GTK_DIR_UP)
- iter = egg_flow_box_get_above_focusable (box, child_priv->iter);
+ iter = egg_flow_box_get_above_focusable (box, iter);
else if (direction == GTK_DIR_DOWN)
- iter = egg_flow_box_get_below_focusable (box, child_priv->iter);
+ iter = egg_flow_box_get_below_focusable (box, iter);
if (iter != NULL && !g_sequence_iter_is_end (iter))
next_focus_child = g_sequence_get (iter);
}
else
{
- if (priv->selected_child)
- next_focus_child = priv->selected_child;
+ if (BOX_PRIV (box)->selected_child)
+ next_focus_child = BOX_PRIV (box)->selected_child;
else
{
if (direction == GTK_DIR_UP || direction == GTK_DIR_TAB_BACKWARD)
@@ -3016,8 +2967,8 @@ typedef struct {
} ChildFlags;
static ChildFlags *
-child_flags_find_or_add (ChildFlags *array,
- int *array_length,
+child_flags_find_or_add (ChildFlags *array,
+ gint *array_length,
EggFlowBoxChild *to_find)
{
gint i;
@@ -3031,15 +2982,16 @@ child_flags_find_or_add (ChildFlags *array,
*array_length = *array_length + 1;
array[*array_length - 1].child = to_find;
array[*array_length - 1].state = 0;
+
return &array[*array_length - 1];
}
static void
-egg_flow_box_add_move_binding (GtkBindingSet *binding_set,
- guint keyval,
- GdkModifierType modmask,
- GtkMovementStep step,
- gint count)
+egg_flow_box_add_move_binding (GtkBindingSet *binding_set,
+ guint keyval,
+ GdkModifierType modmask,
+ GtkMovementStep step,
+ gint count)
{
GdkDisplay *display;
GdkModifierType extend_mod_mask = GDK_SHIFT_MASK;
@@ -3079,25 +3031,20 @@ egg_flow_box_add_move_binding (GtkBindingSet *binding_set,
static void
egg_flow_box_activate_cursor_child (EggFlowBox *box)
{
- EggFlowBoxPrivate *priv = box->priv;
-
- egg_flow_box_select_and_activate (box, priv->cursor_child);
+ egg_flow_box_select_and_activate (box, BOX_PRIV (box)->cursor_child);
}
static void
egg_flow_box_toggle_cursor_child (EggFlowBox *box)
{
- EggFlowBoxPrivate *priv = box->priv;
- EggFlowBoxChildPrivate *child_priv;
+ EggFlowBoxPrivate *priv = BOX_PRIV (box);
if (priv->cursor_child == NULL)
return;
- child_priv = egg_flow_box_child_get_instance_private (priv->cursor_child);
-
if ((priv->selection_mode == GTK_SELECTION_SINGLE ||
priv->selection_mode == GTK_SELECTION_MULTIPLE) &&
- child_priv->selected)
+ CHILD_PRIV (priv->cursor_child)->selected)
egg_flow_box_unselect_child_info (box, priv->cursor_child);
else
egg_flow_box_select_and_activate (box, priv->cursor_child);
@@ -3108,7 +3055,7 @@ egg_flow_box_move_cursor (EggFlowBox *box,
GtkMovementStep step,
gint count)
{
- EggFlowBoxPrivate *priv = box->priv;
+ EggFlowBoxPrivate *priv = BOX_PRIV (box);
gboolean modify_selection;
gboolean extend_selection;
EggFlowBoxChild *child;
@@ -3147,8 +3094,7 @@ egg_flow_box_move_cursor (EggFlowBox *box,
case GTK_MOVEMENT_VISUAL_POSITIONS:
if (priv->cursor_child != NULL)
{
- child_priv = egg_flow_box_child_get_instance_private (priv->cursor_child);
- iter = child_priv->iter;
+ iter = CHILD_PRIV (priv->cursor_child)->iter;
if (gtk_widget_get_direction (GTK_WIDGET (box)) == GTK_TEXT_DIR_RTL)
count = - count;
@@ -3180,8 +3126,7 @@ egg_flow_box_move_cursor (EggFlowBox *box,
case GTK_MOVEMENT_DISPLAY_LINES:
if (priv->cursor_child != NULL)
{
- child_priv = egg_flow_box_child_get_instance_private (priv->cursor_child);
- iter = child_priv->iter;
+ iter = CHILD_PRIV (priv->cursor_child)->iter;
while (count < 0 && iter != NULL)
{
@@ -3201,19 +3146,18 @@ egg_flow_box_move_cursor (EggFlowBox *box,
case GTK_MOVEMENT_PAGES:
page_size = 100;
- adjustment = vertical ? priv->hadjustment : priv->vadjustment;
+ adjustment = vertical ? priv->hadjustment : priv->vadjustment;
if (adjustment)
page_size = gtk_adjustment_get_page_increment (adjustment);
if (priv->cursor_child != NULL)
{
- gtk_widget_get_allocation (GTK_WIDGET (priv->cursor_child), &allocation);
- child_priv = egg_flow_box_child_get_instance_private (priv->cursor_child);
+ child = priv->cursor_child;
+ iter = CHILD_PRIV (child)->iter;
+ gtk_widget_get_allocation (GTK_WIDGET (child), &allocation);
start = vertical ? allocation.x : allocation.y;
end = start;
- iter = child_priv->iter;
- child = priv->cursor_child;
if (count < 0)
{
gint i = 0;
@@ -3226,7 +3170,6 @@ egg_flow_box_move_cursor (EggFlowBox *box,
break;
prev = g_sequence_get (iter);
- child_priv = egg_flow_box_child_get_instance_private (prev);
/* go up an even number of rows */
if (i % priv->cur_children_per_line == 0)
@@ -3252,7 +3195,6 @@ egg_flow_box_move_cursor (EggFlowBox *box,
break;
next = g_sequence_get (iter);
- child_priv = egg_flow_box_child_get_instance_private (next);
if (i % priv->cur_children_per_line == 0)
{
@@ -3302,10 +3244,10 @@ egg_flow_box_select_all (EggFlowBox *box)
{
g_return_if_fail (EGG_IS_FLOW_BOX (box));
- if (box->priv->selection_mode != GTK_SELECTION_MULTIPLE)
+ if (BOX_PRIV (box)->selection_mode != GTK_SELECTION_MULTIPLE)
return;
- if (g_sequence_get_length (box->priv->children) > 0)
+ if (g_sequence_get_length (BOX_PRIV (box)->children) > 0)
{
egg_flow_box_select_all_between (box, NULL, NULL);
g_signal_emit (box, signals[SELECTED_CHILDREN_CHANGED], 0);
@@ -3319,7 +3261,7 @@ egg_flow_box_unselect_all (EggFlowBox *box)
g_return_if_fail (EGG_IS_FLOW_BOX (box));
- if (box->priv->selection_mode == GTK_SELECTION_BROWSE)
+ if (BOX_PRIV (box)->selection_mode == GTK_SELECTION_BROWSE)
return;
dirty = egg_flow_box_unselect_all_internal (box);
@@ -3333,14 +3275,8 @@ egg_flow_box_draw (GtkWidget *widget,
cairo_t *cr)
{
EggFlowBox *box = EGG_FLOW_BOX (widget);
- EggFlowBoxPrivate *priv = box->priv;
GtkAllocation allocation = {0};
GtkStyleContext* context;
- GtkStateFlags state;
- gint focus_pad;
- int i;
- GSequenceIter *iter;
- EggFlowBoxChildPrivate *child_priv;
gtk_widget_get_allocation (GTK_WIDGET (box), &allocation);
context = gtk_widget_get_style_context (GTK_WIDGET (box));
@@ -3375,15 +3311,14 @@ egg_flow_box_realize (GtkWidget *widget)
window = gdk_window_new (gtk_widget_get_parent_window (GTK_WIDGET (box)),
&attributes, GDK_WA_X | GDK_WA_Y);
gtk_style_context_set_background (gtk_widget_get_style_context (GTK_WIDGET (box)), window);
- gdk_window_set_user_data (window, (GObject*) box);
- gtk_widget_set_window (GTK_WIDGET (box), window); /* Passes ownership */
+ gtk_widget_register_window (GTK_WIDGET (box), window);
+ gtk_widget_set_window (GTK_WIDGET (box), window);
}
static void
egg_flow_box_finalize (GObject *obj)
{
- EggFlowBox *box = EGG_FLOW_BOX (obj);
- EggFlowBoxPrivate *priv = box->priv;
+ EggFlowBoxPrivate *priv = BOX_PRIV (obj);
if (priv->filter_destroy != NULL)
priv->filter_destroy (priv->filter_data);
@@ -3670,17 +3605,13 @@ egg_flow_box_class_init (EggFlowBoxClass *class)
gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
"unselect-all", 0);
- g_type_class_add_private (class, sizeof (EggFlowBoxPrivate));
-
gtk_widget_class_set_accessible_type (widget_class, EGG_TYPE_FLOW_BOX_ACCESSIBLE);
}
static void
egg_flow_box_init (EggFlowBox *box)
{
- EggFlowBoxPrivate *priv;
-
- box->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (box, EGG_TYPE_FLOW_BOX, EggFlowBoxPrivate);
+ EggFlowBoxPrivate *priv = BOX_PRIV (box);
gtk_widget_set_has_window (GTK_WIDGET (box), TRUE);
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (box), TRUE);
@@ -3722,19 +3653,17 @@ GList *
egg_flow_box_get_selected_children (EggFlowBox *box)
{
EggFlowBoxChild *child;
- EggFlowBoxChildPrivate *child_priv;
GSequenceIter *iter;
GList *selected = NULL;
- g_return_val_if_fail (box != NULL, NULL);
+ g_return_val_if_fail (EGG_IS_FLOW_BOX (box), NULL);
- for (iter = g_sequence_get_begin_iter (box->priv->children);
+ for (iter = g_sequence_get_begin_iter (BOX_PRIV (box)->children);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
child = g_sequence_get (iter);
- child_priv = egg_flow_box_child_get_instance_private (child);
- if (child_priv->selected)
+ if (CHILD_PRIV (child)->selected)
selected = g_list_prepend (selected, child);
}
@@ -3764,13 +3693,9 @@ egg_flow_box_unselect_child (EggFlowBox *box,
gboolean
egg_flow_box_child_is_selected (EggFlowBoxChild *child)
{
- EggFlowBoxChildPrivate *priv;
-
g_return_if_fail (EGG_IS_FLOW_BOX_CHILD (child));
- priv = egg_flow_box_child_get_instance_private (child);
-
- return priv->selected;
+ return CHILD_PRIV (child)->selected;
}
/**
@@ -3783,24 +3708,22 @@ egg_flow_box_child_is_selected (EggFlowBoxChild *child)
* selection cannot be modified from within this function.
*/
void
-egg_flow_box_selected_foreach (EggFlowBox *box,
- EggFlowBoxForeachFunc func,
- gpointer data)
+egg_flow_box_selected_foreach (EggFlowBox *box,
+ EggFlowBoxForeachFunc func,
+ gpointer data)
{
EggFlowBoxChild *child;
- EggFlowBoxChildPrivate *priv;
GSequenceIter *iter;
g_return_if_fail (EGG_IS_FLOW_BOX (box));
- for (iter = g_sequence_get_begin_iter (box->priv->children);
+ for (iter = g_sequence_get_begin_iter (BOX_PRIV (box)->children);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
child = g_sequence_get (iter);
- priv = egg_flow_box_child_get_instance_private (child);
- if (priv->selected)
- (* func) (box, child, data);
+ if (CHILD_PRIV (child)->selected)
+ (*func) (box, child, data);
}
}
@@ -3812,17 +3735,17 @@ egg_flow_box_set_selection_mode (EggFlowBox *box,
g_return_if_fail (EGG_IS_FLOW_BOX (box));
- if (mode == box->priv->selection_mode)
+ if (mode == BOX_PRIV (box)->selection_mode)
return;
if (mode == GTK_SELECTION_NONE ||
- box->priv->selection_mode == GTK_SELECTION_MULTIPLE)
+ BOX_PRIV (box)->selection_mode == GTK_SELECTION_MULTIPLE)
{
dirty = egg_flow_box_unselect_all_internal (box);
- box->priv->selected_child = NULL;
+ BOX_PRIV (box)->selected_child = NULL;
}
- box->priv->selection_mode = mode;
+ BOX_PRIV (box)->selection_mode = mode;
g_object_notify (G_OBJECT (box), "selection-mode");
@@ -3835,14 +3758,14 @@ egg_flow_box_get_selection_mode (EggFlowBox *box)
{
g_return_val_if_fail (EGG_IS_FLOW_BOX (box), GTK_SELECTION_SINGLE);
- return box->priv->selection_mode;
+ return BOX_PRIV (box)->selection_mode;
}
static void
egg_flow_box_apply_filter (EggFlowBox *box,
EggFlowBoxChild *child)
{
- EggFlowBoxPrivate *priv = box->priv;
+ EggFlowBoxPrivate *priv = BOX_PRIV (box);
gboolean do_show;
do_show = TRUE;
@@ -3855,11 +3778,10 @@ egg_flow_box_apply_filter (EggFlowBox *box,
static void
egg_flow_box_apply_filter_all (EggFlowBox *box)
{
- EggFlowBoxPrivate *priv = box->priv;
EggFlowBoxChild *child;
GSequenceIter *iter;
- for (iter = g_sequence_get_begin_iter (priv->children);
+ for (iter = g_sequence_get_begin_iter (BOX_PRIV (box)->children);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
{
@@ -3879,7 +3801,7 @@ egg_flow_box_set_filter_func (EggFlowBox *box,
g_return_if_fail (EGG_IS_FLOW_BOX (box));
- priv = box->priv;
+ priv = BOX_PRIV (box);
if (priv->filter_destroy != NULL)
priv->filter_destroy (priv->filter_data);
@@ -3910,7 +3832,7 @@ egg_flow_box_set_sort_func (EggFlowBox *box,
g_return_if_fail (EGG_IS_FLOW_BOX (box));
- priv = box->priv;
+ priv = BOX_PRIV (box);
if (priv->sort_destroy != NULL)
priv->sort_destroy (priv->sort_data);
@@ -3927,7 +3849,7 @@ egg_flow_box_sort (EggFlowBoxChild *a,
EggFlowBoxChild *b,
EggFlowBox *box)
{
- EggFlowBoxPrivate *priv = box->priv;
+ EggFlowBoxPrivate *priv = BOX_PRIV (box);
return priv->sort_func (a, b, priv->sort_data);
}
@@ -3939,7 +3861,7 @@ egg_flow_box_invalidate_sort (EggFlowBox *box)
g_return_if_fail (EGG_IS_FLOW_BOX (box));
- priv = box->priv;
+ priv = BOX_PRIV (box);
if (priv->sort_func != NULL)
{
@@ -3953,19 +3875,17 @@ void
egg_flow_box_child_changed (EggFlowBoxChild *child)
{
EggFlowBox *box;
- EggFlowBoxPrivate *priv;
- EggFlowBoxChildPrivate *child_priv;
- child_priv = egg_flow_box_child_get_instance_private (child);
+ g_return_if_fail (EGG_IS_FLOW_BOX_CHILD (child));
+
box = egg_flow_box_child_get_box (child);
- priv = box->priv;
if (box == NULL)
return;
- if (priv->sort_func != NULL)
+ if (BOX_PRIV (box)->sort_func != NULL)
{
- g_sequence_sort_changed (child_priv->iter,
+ g_sequence_sort_changed (CHILD_PRIV (child)->iter,
(GCompareDataFunc)egg_flow_box_sort, box);
gtk_widget_queue_resize (GTK_WIDGET (box));
}
@@ -3975,58 +3895,55 @@ egg_flow_box_child_changed (EggFlowBoxChild *child)
void
egg_flow_box_insert (EggFlowBox *box,
- GtkWidget *child,
+ GtkWidget *widget,
gint position)
{
- EggFlowBoxPrivate *priv = box->priv;
- EggFlowBoxChild *info;
- EggFlowBoxChildPrivate *child_priv;
- GSequenceIter *iter = NULL;
+ EggFlowBoxPrivate *priv;
+ EggFlowBoxChild *child;
+ GSequenceIter *iter;
g_return_if_fail (EGG_IS_FLOW_BOX (box));
- g_return_if_fail (GTK_IS_WIDGET (child));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ priv = BOX_PRIV (box);
- if (EGG_IS_FLOW_BOX_CHILD (child))
- info = EGG_FLOW_BOX_CHILD (child);
+ if (EGG_IS_FLOW_BOX_CHILD (widget))
+ child = EGG_FLOW_BOX_CHILD (widget);
else
{
- info = EGG_FLOW_BOX_CHILD (egg_flow_box_child_new ());
- gtk_widget_show (GTK_WIDGET (info));
- gtk_container_add (GTK_CONTAINER (info), child);
+ child = EGG_FLOW_BOX_CHILD (egg_flow_box_child_new ());
+ gtk_widget_show (GTK_WIDGET (child));
+ gtk_container_add (GTK_CONTAINER (child), widget);
}
if (priv->sort_func != NULL)
- iter = g_sequence_insert_sorted (priv->children, info,
+ iter = g_sequence_insert_sorted (priv->children, child,
(GCompareDataFunc)egg_flow_box_sort, box);
else if (position == 0)
- iter = g_sequence_prepend (priv->children, info);
+ iter = g_sequence_prepend (priv->children, child);
else if (position == -1)
- iter = g_sequence_append (priv->children, info);
+ iter = g_sequence_append (priv->children, child);
else
{
GSequenceIter *pos;
pos = g_sequence_get_iter_at_pos (priv->children, position);
- iter = g_sequence_insert_before (pos, info);
+ iter = g_sequence_insert_before (pos, child);
}
- child_priv = egg_flow_box_child_get_instance_private (info);
- child_priv->iter = iter;
- gtk_widget_set_parent (GTK_WIDGET (info), GTK_WIDGET (box));
- egg_flow_box_apply_filter (box, info);
+ CHILD_PRIV (child)->iter = iter;
+ gtk_widget_set_parent (GTK_WIDGET (child), GTK_WIDGET (box));
+ egg_flow_box_apply_filter (box, child);
}
EggFlowBoxChild *
egg_flow_box_get_child_at_index (EggFlowBox *box,
- gint index_)
+ gint idx)
{
- EggFlowBoxPrivate *priv;
GSequenceIter *iter;
g_return_val_if_fail (EGG_IS_FLOW_BOX (box), NULL);
- priv = egg_flow_box_get_instance_private (box);
-
- iter = g_sequence_get_iter_at_pos (priv->children, index_);
+ iter = g_sequence_get_iter_at_pos (BOX_PRIV (box)->children, idx);
if (iter)
return g_sequence_get (iter);
diff --git a/egg-flow-box.h b/egg-flow-box.h
index f4e4805..9885f17 100644
--- a/egg-flow-box.h
+++ b/egg-flow-box.h
@@ -39,7 +39,6 @@ G_BEGIN_DECLS
#define EGG_FLOW_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_FLOW_BOX,
EggFlowBoxClass))
typedef struct _EggFlowBox EggFlowBox;
-typedef struct _EggFlowBoxPrivate EggFlowBoxPrivate;
typedef struct _EggFlowBoxClass EggFlowBoxClass;
typedef struct _EggFlowBoxChild EggFlowBoxChild;
@@ -48,9 +47,6 @@ typedef struct _EggFlowBoxChildClass EggFlowBoxChildClass;
struct _EggFlowBox
{
GtkContainer container;
-
- /*< private >*/
- EggFlowBoxPrivate *priv;
};
struct _EggFlowBoxClass
@@ -139,10 +135,10 @@ void egg_flow_box_set_activate_on_single_click (EggFlowBox
gboolean egg_flow_box_get_activate_on_single_click (EggFlowBox *box);
void egg_flow_box_insert (EggFlowBox *box,
- GtkWidget *child,
+ GtkWidget *widget,
gint position);
EggFlowBoxChild *egg_flow_box_get_child_at_index (EggFlowBox *box,
- gint index_);
+ gint idx);
typedef void (* EggFlowBoxForeachFunc) (EggFlowBox *box,
EggFlowBoxChild *child,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]