diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2010-11-22 15:51:51 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2011-01-04 23:37:06 +0900 |
commit | 88ec6a62ef18196a8abd3d0586115661be5d526f (patch) | |
tree | 9433f0fea3a66e867a4605e771580088c5fdac7a /gtk/gtkcellview.c | |
parent | 9ffaae50220da45e0004b4682ec7d1d1031fe924 (diff) | |
download | gtk+-88ec6a62ef18196a8abd3d0586115661be5d526f.tar.gz |
GtkCellView now watches the "row-changed" signal.
When the "row-changed" signal on the model is trapped, if the row which
changed is the displayed row then the context is flushed and sizes are
recalculated for every area in the same context.
Diffstat (limited to 'gtk/gtkcellview.c')
-rw-r--r-- | gtk/gtkcellview.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/gtk/gtkcellview.c b/gtk/gtkcellview.c index 2fa830f328..e1269fce84 100644 --- a/gtk/gtkcellview.c +++ b/gtk/gtkcellview.c @@ -54,6 +54,7 @@ struct _GtkCellViewPrivate gboolean background_set; gulong size_changed_id; + gulong row_changed_id; }; @@ -138,7 +139,10 @@ static void gtk_cell_view_get_preferred_height_for_width (GtkWidget static void context_size_changed_cb (GtkCellAreaContext *context, GParamSpec *pspec, GtkWidget *view); - +static void row_changed_cb (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + GtkCellView *view); static GtkBuildableIface *parent_buildable_iface; @@ -669,6 +673,24 @@ context_size_changed_cb (GtkCellAreaContext *context, gtk_widget_queue_resize (view); } +static void +row_changed_cb (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + GtkCellView *view) +{ + GtkTreePath *row_path; + + if (view->priv->displayed_row) + { + row_path = + gtk_tree_row_reference_get_path (view->priv->displayed_row); + + /* Resize everything in our context if our row changed */ + if (gtk_tree_path_compare (row_path, path) == 0) + gtk_cell_area_context_flush (view->priv->context); + } +} /** * gtk_cell_view_new: @@ -863,6 +885,10 @@ gtk_cell_view_set_model (GtkCellView *cell_view, if (cell_view->priv->model) { + g_signal_handler_disconnect (cell_view->priv->model, + cell_view->priv->row_changed_id); + cell_view->priv->row_changed_id = 0; + if (cell_view->priv->displayed_row) gtk_tree_row_reference_free (cell_view->priv->displayed_row); cell_view->priv->displayed_row = NULL; @@ -874,7 +900,13 @@ gtk_cell_view_set_model (GtkCellView *cell_view, cell_view->priv->model = model; if (cell_view->priv->model) - g_object_ref (cell_view->priv->model); + { + g_object_ref (cell_view->priv->model); + + cell_view->priv->row_changed_id = + g_signal_connect (cell_view->priv->model, "row-changed", + G_CALLBACK (row_changed_cb), cell_view); + } } /** |