2006/1/19, Chris Shoemaker <[EMAIL PROTECTED]>:
> On Thu, Jan 19, 2006 at 08:19:14PM +0100, Eskil Bylund wrote:
> > > Only that the static tree model probably shouldn't contain selection
> > > state.  It might be shared by multiple views that want different
> > > selections.
> > >
> > No, of course. See above.
> >
> > > Maybe that's why you wanted to provide the treemodel as an argument?
> > > So you could filter the non-static treemodels?
> > >
> > Yes. Currently there are no non-static treemodels that will be
> > filtered, but I added it just in case.
> >
> > To summarize above: I would like to remove the GtkTreeView specific
> > functions from the model and make the Filter dialog use its own model
> > for storing selection state.
>
> It would definitely be nice to show selection state with checkboxes.
> But it'd also be nice to use the static account types tree model.
>
> What do you think about this:?
>
> Keep the selection state private to the filterBy dialog instead of
> using a new tree model for each dialog.  You can even put that
> selection state right into a new field in the AccountFilterDialog struct.
>
> Instead of using an attribute mapping to the checkbox's treeviewcolumn
> from the new model's selection-state column, use a GtkTreeCellDataFunc
> that updates the "active" property of the GtkCellRendererToggle from
> that private selection state field.  Then the filterBy dialog can
> always use the static treemodel.
>

Yes, this is a good solution. I'll implement this right away.

To not spam the list with lots of mail, I've attached another patch
for GncTreeModelAccountTypes here. It makes the model emit the
"row_changed" signal when the selection is changed. The cell renderer
won't render properly otherwise.
Index: src/gnome-utils/gnc-tree-model-account-types.c
===================================================================
--- src/gnome-utils/gnc-tree-model-account-types.c	(revision 12903)
+++ src/gnome-utils/gnc-tree-model-account-types.c	(arbetskopia)
@@ -202,11 +202,31 @@
 					   guint32 selected)
 {
 	GncTreeModelAccountTypesPrivate *priv;
+	GtkTreePath *path;
+	GtkTreeIter iter;
+	gint *path_idx;
+	guint32 updated_types;
+	gint i;
 
 	g_return_if_fail (model != NULL);
 
 	priv = GNC_TREE_MODEL_ACCOUNT_TYPES_GET_PRIVATE(model);
+	updated_types = priv->selected ^ selected;
 	priv->selected = selected;
+
+	path = gtk_tree_path_new_first();
+	path_idx = gtk_tree_path_get_indices(path);
+
+	for (i = 0; i < NUM_ACCOUNT_TYPES; i++) {
+		if (updated_types & (1 << i)) {
+			path_idx[0] = i;
+			iter.stamp = model->stamp;
+			iter.user_data = GINT_TO_POINTER (i);
+
+			gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, &iter);
+		}
+	}
+	gtk_tree_path_free(path);
 }
 
 guint32
_______________________________________________
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to