diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2010-11-09 14:09:47 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2010-11-09 14:09:47 +0900 |
commit | f85938a2112df8af9ce17423203117ecfc717f30 (patch) | |
tree | 4d74552e9047038caa70ef34ed2a2078bbb8cc00 /tests/cellareascaffold.c | |
parent | e03b280757fba41ab4c1dd671bd39d0e82c8fed2 (diff) | |
download | gtk+-f85938a2112df8af9ce17423203117ecfc717f30.tar.gz |
Changed testcellarea
Changed testcellarea to watch the iter for size changes and queue resizes
instead of explicitly queueing resizes when controls change.
Diffstat (limited to 'tests/cellareascaffold.c')
-rw-r--r-- | tests/cellareascaffold.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/tests/cellareascaffold.c b/tests/cellareascaffold.c index 4805a2832d..0da496d6ee 100644 --- a/tests/cellareascaffold.c +++ b/tests/cellareascaffold.c @@ -73,6 +73,8 @@ struct _CellAreaScaffoldPrivate { /* Cache some info about rows (hieghts etc) */ GArray *row_data; + + gulong size_changed_id; }; @@ -88,6 +90,18 @@ G_DEFINE_TYPE_WITH_CODE (CellAreaScaffold, cell_area_scaffold, GTK_TYPE_WIDGET, static void +size_changed_cb (GtkCellAreaIter *iter, + GParamSpec *pspec, + CellAreaScaffold *scaffold) +{ + if (!strcmp (pspec->name, "minimum-width") || + !strcmp (pspec->name, "natural-width") || + !strcmp (pspec->name, "minimum-height") || + !strcmp (pspec->name, "natural-height")) + gtk_widget_queue_resize (GTK_WIDGET (scaffold)); +} + +static void cell_area_scaffold_init (CellAreaScaffold *scaffold) { CellAreaScaffoldPrivate *priv; @@ -100,6 +114,10 @@ cell_area_scaffold_init (CellAreaScaffold *scaffold) priv->area = gtk_cell_area_box_new (); priv->iter = gtk_cell_area_create_iter (priv->area); + priv->size_changed_id = + g_signal_connect (priv->iter, "notify", + G_CALLBACK (size_changed_cb), scaffold); + priv->row_data = g_array_new (FALSE, FALSE, sizeof (RowData)); gtk_widget_set_has_window (GTK_WIDGET (scaffold), FALSE); @@ -158,8 +176,12 @@ cell_area_scaffold_dispose (GObject *object) if (priv->iter) { + /* Disconnect signals */ + g_signal_handler_disconnect (priv->iter, priv->size_changed_id); + g_object_unref (priv->iter); priv->iter = NULL; + priv->size_changed_id = 0; } if (priv->area) @@ -187,7 +209,6 @@ cell_area_scaffold_set_property (GObject *object, case PROP_ORIENTATION: gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->area), g_value_get_enum (value)); - gtk_widget_queue_resize (GTK_WIDGET (scaffold)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -294,6 +315,8 @@ request_all_base (CellAreaScaffold *scaffold) if (!priv->model) return; + g_signal_handler_block (priv->iter, priv->size_changed_id); + orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (priv->area)); valid = gtk_tree_model_get_iter_first (priv->model, &iter); @@ -315,6 +338,8 @@ request_all_base (CellAreaScaffold *scaffold) gtk_cell_area_iter_sum_preferred_width (priv->iter); else gtk_cell_area_iter_sum_preferred_height (priv->iter); + + g_signal_handler_unblock (priv->iter, priv->size_changed_id); } static void @@ -606,8 +631,6 @@ cell_area_scaffold_set_model (CellAreaScaffold *scaffold, } gtk_cell_area_iter_flush (priv->iter); - - gtk_widget_queue_resize (GTK_WIDGET (scaffold)); } } |