[egg-list-box/flow-box-enhancements] Drop h/valign-policy
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [egg-list-box/flow-box-enhancements] Drop h/valign-policy
- Date: Sun, 29 Sep 2013 07:54:27 +0000 (UTC)
commit 1a16cffdf4a871e8a33ac5622d4429a41ea07063
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Sep 29 03:53:41 2013 -0400
Drop h/valign-policy
These turn out to be redundant; the widget align properties
have exactly the same effect.
egg-flow-box.c | 149 +++++-------------------------------------------------
egg-flow-box.h | 6 --
test-flow-box.c | 9 ++--
3 files changed, 19 insertions(+), 145 deletions(-)
---
diff --git a/egg-flow-box.c b/egg-flow-box.c
index 397a38c..e65792e 100644
--- a/egg-flow-box.c
+++ b/egg-flow-box.c
@@ -161,8 +161,6 @@ enum {
typedef struct _EggFlowBoxPrivate EggFlowBoxPrivate;
struct _EggFlowBoxPrivate {
GtkOrientation orientation;
- GtkAlign halign_policy;
- GtkAlign valign_policy;
gboolean homogeneous;
guint row_spacing;
@@ -225,13 +223,15 @@ 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) \
- (BOX_PRIV(box)->orientation == GTK_ORIENTATION_HORIZONTAL ? \
- BOX_PRIV(box)->halign_policy : BOX_PRIV(box)->valign_policy)
+#define ORIENTATION_ALIGN(box) \
+ (BOX_PRIV(box)->orientation == GTK_ORIENTATION_HORIZONTAL \
+ ? gtk_widget_get_halign (GTK_WIDGET (box)) \
+ : gtk_widget_get_valign (GTK_WIDGET (box)))
-#define OPPOSING_ORIENTATION_ALIGN_POLICY(box) \
- (BOX_PRIV(box)->orientation == GTK_ORIENTATION_HORIZONTAL ? \
- BOX_PRIV(box)->valign_policy : BOX_PRIV(box)->halign_policy)
+#define OPPOSING_ORIENTATION_ALIGN(box) \
+ (BOX_PRIV(box)->orientation == GTK_ORIENTATION_HORIZONTAL \
+ ? gtk_widget_get_valign (GTK_WIDGET (box)) \
+ : gtk_widget_get_halign (GTK_WIDGET (box)))
static void egg_flow_box_update_cursor (EggFlowBox *box,
@@ -961,7 +961,7 @@ get_largest_size_for_line_in_opposing_orientation (EggFlowBox *box,
/* Distribute the extra pixels to the first children in the line
* (could be fancier and spread them out more evenly) */
this_item_size = item_sizes[i].minimum_size;
- if (extra_pixels > 0 && ORIENTATION_ALIGN_POLICY (box) == GTK_ALIGN_FILL)
+ if (extra_pixels > 0 && ORIENTATION_ALIGN (box) == GTK_ALIGN_FILL)
{
this_item_size++;
extra_pixels--;
@@ -1032,7 +1032,7 @@ gather_aligned_item_requests (EggFlowBox *box,
/* Get the index and push it over for the last line when spreading to the end */
position = i % line_length;
- item_align = ORIENTATION_ALIGN_POLICY (box);
+ item_align = ORIENTATION_ALIGN (box);
if (item_align == GTK_ALIGN_END && i >= n_children - extra_items)
position += line_length - extra_items;
@@ -1193,8 +1193,8 @@ egg_flow_box_size_allocate (GtkWidget *widget,
line_spacing = priv->column_spacing;
}
- item_align = ORIENTATION_ALIGN_POLICY (box);
- line_align = OPPOSING_ORIENTATION_ALIGN_POLICY (box);
+ item_align = ORIENTATION_ALIGN (box);
+ line_align = OPPOSING_ORIENTATION_ALIGN (box);
/* Get how many lines we'll be needing to flow */
n_children = get_visible_children (box);
@@ -1890,7 +1890,7 @@ egg_flow_box_get_preferred_height_for_width (GtkWidget *widget,
item_size = (avail_size - (line_length - 1) * priv->column_spacing) / line_length;
/* Cut out the expand space if we're not distributing any */
- if (priv->halign_policy != GTK_ALIGN_FILL)
+ if (gtk_widget_get_halign (widget) != GTK_ALIGN_FILL)
{
item_size = MIN (item_size, nat_item_width);
extra_pixels = 0;
@@ -2054,7 +2054,7 @@ egg_flow_box_get_preferred_width_for_height (GtkWidget *widget,
item_size = (avail_size - (line_length - 1) * priv->row_spacing) / line_length;
/* Cut out the expand space if we're not distributing any */
- if (priv->valign_policy != GTK_ALIGN_FILL)
+ if (gtk_widget_get_valign (widget) != GTK_ALIGN_FILL)
{
item_size = MIN (item_size, nat_item_height);
extra_pixels = 0;
@@ -2155,84 +2155,6 @@ egg_flow_box_get_preferred_width_for_height (GtkWidget *widget,
}
/**
- * egg_flow_box_set_halign_policy:
- * @box: An #EggFlowBox
- * @align: The #GtkAlign to use
- *
- * Sets the horizontal align policy for @box's children.
- */
-void
-egg_flow_box_set_halign_policy (EggFlowBox *box,
- GtkAlign align)
-{
- g_return_if_fail (EGG_IS_FLOW_BOX (box));
-
- if (BOX_PRIV (box)->halign_policy != align)
- {
- BOX_PRIV (box)->halign_policy = align;
-
- gtk_widget_queue_resize (GTK_WIDGET (box));
- g_object_notify (G_OBJECT (box), "halign-policy");
- }
-}
-
-/**
- * egg_flow_box_get_halign_policy:
- * @box: An #EggFlowBox
- *
- * Gets the horizontal alignment policy.
- *
- * Returns: The horizontal #GtkAlign for @box.
- */
-GtkAlign
-egg_flow_box_get_halign_policy (EggFlowBox *box)
-{
- g_return_val_if_fail (EGG_IS_FLOW_BOX (box), FALSE);
-
- return BOX_PRIV (box)->halign_policy;
-}
-
-
-/**
- * egg_flow_box_set_valign_policy:
- * @box: An #EggFlowBox
- * @align: The #GtkAlign to use
- *
- * Sets the vertical alignment policy for @box's children.
- */
-void
-egg_flow_box_set_valign_policy (EggFlowBox *box,
- GtkAlign align)
-{
- g_return_if_fail (EGG_IS_FLOW_BOX (box));
-
- if (BOX_PRIV (box)->valign_policy != align)
- {
- BOX_PRIV (box)->valign_policy = align;
-
- gtk_widget_queue_resize (GTK_WIDGET (box));
- g_object_notify (G_OBJECT (box), "valign-policy");
- }
-}
-
-/**
- * egg_flow_box_get_valign_policy:
- * @box: An #EggFlowBox
- *
- * Gets the vertical alignment policy.
- *
- * Returns: The vertical #GtkAlign for @box.
- */
-GtkAlign
-egg_flow_box_get_valign_policy (EggFlowBox *box)
-{
- g_return_val_if_fail (EGG_IS_FLOW_BOX (box), FALSE);
-
- return BOX_PRIV (box)->valign_policy;
-}
-
-
-/**
* egg_flow_box_set_row_spacing:
* @box: An #EggFlowBox
* @spacing: The spacing to use
@@ -2447,12 +2369,6 @@ egg_flow_box_get_property (GObject *object,
case PROP_HOMOGENEOUS:
g_value_set_boolean (value, priv->homogeneous);
break;
- case PROP_HALIGN_POLICY:
- g_value_set_enum (value, priv->halign_policy);
- break;
- case PROP_VALIGN_POLICY:
- g_value_set_enum (value, priv->valign_policy);
- break;
case PROP_COLUMN_SPACING:
g_value_set_uint (value, priv->column_spacing);
break;
@@ -2496,12 +2412,6 @@ egg_flow_box_set_property (GObject *object,
case PROP_HOMOGENEOUS:
egg_flow_box_set_homogeneous (box, g_value_get_boolean (value));
break;
- case PROP_HALIGN_POLICY:
- egg_flow_box_set_halign_policy (box, g_value_get_enum (value));
- break;
- case PROP_VALIGN_POLICY:
- egg_flow_box_set_valign_policy (box, g_value_get_enum (value));
- break;
case PROP_COLUMN_SPACING:
egg_flow_box_set_column_spacing (box, g_value_get_uint (value));
break;
@@ -3938,35 +3848,6 @@ egg_flow_box_class_init (EggFlowBoxClass *class)
G_PARAM_READWRITE));
/**
- * EggFlowBox:halign-policy:
- *
- * The #GtkAlign to used to define what is done with extra
- * space in a given orientation.
- */
- g_object_class_install_property (object_class,
- PROP_HALIGN_POLICY,
- g_param_spec_enum ("halign-policy",
- P_("Horizontal align policy"),
- P_("The align policy horizontally"),
- GTK_TYPE_ALIGN,
- GTK_ALIGN_FILL,
- G_PARAM_READWRITE));
- /**
- * EggFlowBox:valign-policy:
- *
- * The #GtkAlign to used to define what is done with extra
- * space in a given orientation.
- */
- g_object_class_install_property (object_class,
- PROP_VALIGN_POLICY,
- g_param_spec_enum ("valign-policy",
- P_("Vertical align policy"),
- P_("The align policy vertically"),
- GTK_TYPE_ALIGN,
- GTK_ALIGN_START,
- G_PARAM_READWRITE));
-
- /**
* EggFlowBox:min-children-per-line:
*
* The minimum number of children to allocate consecutively in the given orientation.
@@ -4149,8 +4030,6 @@ egg_flow_box_init (EggFlowBox *box)
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
priv->selection_mode = GTK_SELECTION_SINGLE;
- priv->halign_policy = GTK_ALIGN_FILL;
- priv->valign_policy = GTK_ALIGN_START;
priv->max_children_per_line = DEFAULT_MAX_CHILDREN_PER_LINE;
priv->column_spacing = 0;
priv->row_spacing = 0;
diff --git a/egg-flow-box.h b/egg-flow-box.h
index 8904e2a..932f9cb 100644
--- a/egg-flow-box.h
+++ b/egg-flow-box.h
@@ -109,12 +109,6 @@ GtkWidget *egg_flow_box_new (void);
void egg_flow_box_set_homogeneous (EggFlowBox *box,
gboolean homogeneous);
gboolean egg_flow_box_get_homogeneous (EggFlowBox *box);
-void egg_flow_box_set_halign_policy (EggFlowBox *box,
- GtkAlign align);
-GtkAlign egg_flow_box_get_halign_policy (EggFlowBox *box);
-void egg_flow_box_set_valign_policy (EggFlowBox *box,
- GtkAlign align);
-GtkAlign egg_flow_box_get_valign_policy (EggFlowBox *box);
void egg_flow_box_set_row_spacing (EggFlowBox *box,
guint spacing);
guint egg_flow_box_get_row_spacing (EggFlowBox *box);
diff --git a/test-flow-box.c b/test-flow-box.c
index d55aa81..93f95d5 100644
--- a/test-flow-box.c
+++ b/test-flow-box.c
@@ -240,7 +240,7 @@ horizontal_alignment_changed (GtkComboBox *box,
{
GtkAlign alignment = gtk_combo_box_get_active (box);
- egg_flow_box_set_halign_policy (flowbox, alignment);
+ gtk_widget_set_halign (GTK_WIDGET (flowbox), alignment);
}
static void
@@ -249,7 +249,7 @@ vertical_alignment_changed (GtkComboBox *box,
{
GtkAlign alignment = gtk_combo_box_get_active (box);
- egg_flow_box_set_valign_policy (flowbox, alignment);
+ gtk_widget_set_valign (GTK_WIDGET (flowbox), alignment);
}
static void
@@ -428,9 +428,10 @@ create_window (void)
gtk_box_pack_start (GTK_BOX (hbox), swindow, TRUE, TRUE, 0);
flowbox = egg_flow_box_new ();
+ gtk_widget_set_halign (flowbox, GTK_ALIGN_END);
the_flowbox = (EggFlowBox *)flowbox;
- egg_flow_box_set_halign_policy (EGG_FLOW_BOX (flowbox), INITIAL_HALIGN);
- egg_flow_box_set_valign_policy (EGG_FLOW_BOX (flowbox), INITIAL_VALIGN);
+ gtk_widget_set_halign (flowbox, INITIAL_HALIGN);
+ gtk_widget_set_valign (flowbox, INITIAL_VALIGN);
egg_flow_box_set_column_spacing (EGG_FLOW_BOX (flowbox), INITIAL_CSPACING);
egg_flow_box_set_row_spacing (EGG_FLOW_BOX (flowbox), INITIAL_RSPACING);
egg_flow_box_set_min_children_per_line (EGG_FLOW_BOX (flowbox), INITIAL_MINIMUM_LENGTH);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]