[gtk+/grid-widget: 20/20] Remove expand child properties from GtkGrid
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/grid-widget: 20/20] Remove expand child properties from GtkGrid
- Date: Fri, 15 Oct 2010 00:06:26 +0000 (UTC)
commit 9dd6e9a3d0c60c6a42fe183ce5432e3704eb3399
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Oct 14 18:47:38 2010 -0400
Remove expand child properties from GtkGrid
gtk/gtkgrid.c | 46 ++++------------------------------------------
tests/testgrid.c | 24 ++++++++++--------------
2 files changed, 14 insertions(+), 56 deletions(-)
---
diff --git a/gtk/gtkgrid.c b/gtk/gtkgrid.c
index eda8518..05acf9a 100644
--- a/gtk/gtkgrid.c
+++ b/gtk/gtkgrid.c
@@ -39,7 +39,6 @@ struct _GtkGridChildAttach
{
gint pos;
gint span;
- gboolean expand;
};
struct _GtkGridChild
@@ -50,10 +49,8 @@ struct _GtkGridChild
#define CHILD_LEFT(child) ((child)->attach[GTK_ORIENTATION_HORIZONTAL].pos)
#define CHILD_WIDTH(child) ((child)->attach[GTK_ORIENTATION_HORIZONTAL].span)
-#define CHILD_HEXPAND(child) ((child)->attach[GTK_ORIENTATION_HORIZONTAL].expand)
#define CHILD_TOP(child) ((child)->attach[GTK_ORIENTATION_VERTICAL].pos)
#define CHILD_HEIGHT(child) ((child)->attach[GTK_ORIENTATION_VERTICAL].span)
-#define CHILD_VEXPAND(child) ((child)->attach[GTK_ORIENTATION_VERTICAL].expand)
/* A GtkGridLineData struct contains row/column specific parts
* of the grid.
@@ -120,9 +117,7 @@ enum
CHILD_PROP_LEFT_ATTACH,
CHILD_PROP_TOP_ATTACH,
CHILD_PROP_WIDTH,
- CHILD_PROP_HEIGHT,
- CHILD_PROP_HEXPAND,
- CHILD_PROP_VEXPAND
+ CHILD_PROP_HEIGHT
};
G_DEFINE_TYPE_WITH_CODE (GtkGrid, gtk_grid, GTK_TYPE_CONTAINER,
@@ -312,14 +307,6 @@ gtk_grid_get_child_property (GtkContainer *container,
g_value_set_int (value, CHILD_HEIGHT (grid_child));
break;
- case CHILD_PROP_HEXPAND:
- g_value_set_boolean (value, CHILD_HEXPAND (grid_child));
- break;
-
- case CHILD_PROP_VEXPAND:
- g_value_set_boolean (value, CHILD_VEXPAND (grid_child));
- break;
-
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
@@ -362,15 +349,6 @@ gtk_grid_set_child_property (GtkContainer *container,
CHILD_HEIGHT (grid_child) = g_value_get_int (value);
break;
- case CHILD_PROP_HEXPAND:
- CHILD_HEXPAND (grid_child) = g_value_get_boolean (value);
- gtk_widget_queue_resize (GTK_WIDGET (grid));
- break;
-
- case CHILD_PROP_VEXPAND:
- CHILD_VEXPAND (grid_child) = g_value_get_boolean (value);
- break;
-
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
@@ -566,7 +544,7 @@ gtk_grid_request_init (GtkGridRequest *request,
child = list->data;
attach = &child->attach[orientation];
- if (attach->span == 1 && attach->expand)
+ if (attach->span == 1 && gtk_widget_compute_expand (child->widget, orientation))
lines->lines[attach->pos - lines->min].expand = TRUE;
}
}
@@ -846,7 +824,7 @@ gtk_grid_request_compute_expand (GtkGridRequest *request,
line = &lines->lines[attach->pos - lines->min];
line->empty = FALSE;
- if (attach->expand)
+ if (gtk_widget_compute_expand (child->widget, orientation))
line->expand = TRUE;
}
@@ -870,7 +848,7 @@ gtk_grid_request_compute_expand (GtkGridRequest *request,
has_expand = TRUE;
}
- if (attach->expand && !has_expand)
+ if (!has_expand && gtk_widget_compute_expand (child->widget, orientation))
{
for (i = 0; i < attach->span; i++)
{
@@ -1359,20 +1337,6 @@ gtk_grid_class_init (GtkGridClass *class)
1, G_MAXINT, 1,
GTK_PARAM_READWRITE));
- gtk_container_class_install_child_property (container_class, CHILD_PROP_HEXPAND,
- g_param_spec_boolean ("hexpand",
- P_("Horizontal expand"),
- P_("Horizontal expand"),
- FALSE,
- GTK_PARAM_READWRITE));
-
- gtk_container_class_install_child_property (container_class, CHILD_PROP_VEXPAND,
- g_param_spec_boolean ("vexpand",
- P_("Vertical expand"),
- P_("Vertical expand"),
- FALSE,
- GTK_PARAM_READWRITE));
-
g_type_class_add_private (class, sizeof (GtkGridPrivate));
}
@@ -1406,8 +1370,6 @@ grid_attach (GtkGrid *grid,
CHILD_TOP (child) = top;
CHILD_WIDTH (child) = width;
CHILD_HEIGHT (child) = height;
- CHILD_HEXPAND (child) = FALSE;
- CHILD_VEXPAND (child) = FALSE;
priv->children = g_list_prepend (priv->children, child);
diff --git a/tests/testgrid.c b/tests/testgrid.c
index eba15f2..1eb22ac 100644
--- a/tests/testgrid.c
+++ b/tests/testgrid.c
@@ -54,11 +54,11 @@ simple_grid (void)
gtk_container_add (GTK_CONTAINER (grid), test_widget ("3", "blue"));
child = test_widget ("4", "green");
gtk_grid_attach (GTK_GRID (grid), child, 0, 1, 1, 1);
- gtk_container_child_set (GTK_CONTAINER (grid), child, "vexpand", TRUE, NULL);
+ gtk_widget_set_vexpand (child, TRUE);
gtk_grid_attach_next_to (GTK_GRID (grid), test_widget ("5", "blue"), child, GTK_POS_RIGHT, 2, 1);
child = test_widget ("6", "yellow");
gtk_grid_attach (GTK_GRID (grid), child, -1, 0, 1, 2);
- gtk_container_child_set (GTK_CONTAINER (grid), child, "hexpand", TRUE, NULL);
+ gtk_widget_set_hexpand (child, TRUE);
gtk_widget_show_all (window);
}
@@ -150,7 +150,7 @@ box_comparison (void)
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
gtk_label_set_width_chars (GTK_LABEL (label), 10);
gtk_grid_attach (GTK_GRID (grid), label, 1, 0, 1, 1);
- gtk_container_child_set (GTK_CONTAINER (grid), label, "hexpand", TRUE, NULL);
+ gtk_widget_set_hexpand (label, TRUE);
gtk_grid_attach (GTK_GRID (grid), test_widget ("2", "green"), 2, 0, 1, 1);
@@ -158,7 +158,7 @@ box_comparison (void)
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_label_set_width_chars (GTK_LABEL (label), 10);
gtk_grid_attach (GTK_GRID (grid), label, 3, 0, 1, 1);
- gtk_container_child_set (GTK_CONTAINER (grid), label, "hexpand", TRUE, NULL);
+ gtk_widget_set_hexpand (label, TRUE);
gtk_grid_attach (GTK_GRID (grid), test_widget ("3", "red"), 4, 0, 1, 1);
@@ -184,10 +184,8 @@ empty_line (void)
child = test_widget ("(0, 0)", "red");
gtk_grid_attach (GTK_GRID (grid), child, 0, 0, 1, 1);
- gtk_container_child_set (GTK_CONTAINER (grid), child,
- "hexpand", TRUE,
- "vexpand", TRUE,
- NULL);
+ gtk_widget_set_hexpand (child, TRUE);
+ gtk_widget_set_vexpand (child, TRUE);
gtk_grid_attach (GTK_GRID (grid), test_widget ("(0, 1)", "blue"), 0, 1, 1, 1);
@@ -218,10 +216,8 @@ scrolling (void)
child = oriented_test_widget ("#800080", "#800080", -45.0);
gtk_grid_attach (GTK_GRID (grid), child, 0, 0, 1, 1);
- gtk_container_child_set (GTK_CONTAINER (grid), child,
- "hexpand", TRUE,
- "vexpand", TRUE,
- NULL);
+ gtk_widget_set_hexpand (child, TRUE);
+ gtk_widget_set_vexpand (child, TRUE);
for (i = 1; i < 16; i++)
{
@@ -229,7 +225,7 @@ scrolling (void)
color = g_strdup_printf ("#%02x00%02x", 128 + 8*i, 128 - 8*i);
child = test_widget (color, color);
gtk_grid_attach (GTK_GRID (grid), child, 0, i, i + 1, 1);
- gtk_container_child_set (GTK_CONTAINER (grid), child, "hexpand", TRUE, NULL);
+ gtk_widget_set_hexpand (child, TRUE);
g_free (color);
}
@@ -239,7 +235,7 @@ scrolling (void)
color = g_strdup_printf ("#%02x00%02x", 128 - 8*i, 128 + 8*i);
child = oriented_test_widget (color, color, -90.0);
gtk_grid_attach (GTK_GRID (grid), child, i, 0, 1, i);
- gtk_container_child_set (GTK_CONTAINER (grid), child, "vexpand", TRUE, NULL);
+ gtk_widget_set_vexpand (child, TRUE);
g_free (color);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]