[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fri, 1 Feb 2008 22:35:16 -0500
On Sat, Feb 02, 2008 at 10:35:53AM +0900, John Darrington wrote:
> The put_checkbox_items_in_treeview function should be called only
> I would attempt to solve your problem with something like this
> (the following code has not been compiled or tested in any way):
> static void
> on_statistics_clicked (struct crosstabs_dialog *cd)
> GtkTreeIter iter;
> bool ok;
> int ret;
> GtkListStore *temp_store = clone_list_store (GTK_LIST_STORE (cd->stats));
> gtk_tree_view_set_model (cd->stats_view, temp_store);
> ret = psppire_dialog_run (PSPPIRE_DIALOG (cd->stats_dialog));
> if ( ret == PSPPIRE_RESPONSE_CONTINUE )
> /* Discard the original list_store */
> g_object_unref (cd->stats);
> /* Make the temporary store, the permanent one */
> cd->stats = temp_store;
> /* Discard the temporary list store */
> g_object_unref (temp_store);
This is similar to the approach I tried originally. I then tried the
approach with the GtkTreeIter because using clone_list_store caused
the following problem, which I don't understand:
Using the method you mentioned above, on_statistics_clicked() opens
the dialog and will not let the user select anything. The default is
selected, and that's how it stays.
The code I tried first is below. It suffers from the same problem,
but later in the process: If I hit 'Cancel', then return to the dialog,
I can no longer select any of the checkboxes.
Notice the only difference between what you showed an the approach
below is that latter replaces cd->stats after the user presses
'Continue', whereas the former code replaces cd->stats right away,
then undoes that if the user hits 'Cancel'. So it seems the trouble
has something to do with cd->stats being overwritten by the temporary
liststore, which somehow makes the checkboxes immutable.
Anyway, here is the code I tried originally:
on_statistics_clicked (struct crosstabs_dialog *cd)
liststore = clone_list_store (GTK_LIST_STORE (cd->stats));
ret = psppire_dialog_run (PSPPIRE_DIALOG (cd->stats_dialog));
if ( ret == PSPPIRE_RESPONSE_CONTINUE )
gtk_tree_view_set_model (GTK_TREE_VIEW (cd->stats_view) , GTK_TREE_MODEL
cd->stats = liststore;
> Part of your confusion I think arrises from the fact that
> put_checkbox_items_in_treeview does two jobs:
> 1. It sets the GtkTreeView widget's state so it's suitable to
> display checkboxes.
> 2. It also creates and populates a liststore, and sets it as the model
> for the treeview.
> Perhaps these two jobs should be done by separate functions?
I don't know. Your explanation suggests put_checkbox_items_in_treeview
isn't the source of my trouble, so I'll leave that decision up to you.