pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: put_chekckboxes_in_treeview


From: John Darrington
Subject: Re: put_chekckboxes_in_treeview
Date: Sat, 2 Feb 2008 18:06:41 +0900
User-agent: Mutt/1.5.17 (2007-11-01)

The problem is, that the toggle callback set by the 
put_checkbox_items_in_treeview function cached the
liststore which was set when the function was called.
Consequently, if the model subsequently changes, then
it'll be acting on the wrong object.

Patch #6387 should fix this problem.

J'

On Fri, Feb 01, 2008 at 10:35:16PM -0500, Jason Stover wrote:
     On Sat, Feb 02, 2008 at 10:35:53AM +0900, John Darrington wrote:
     > The put_checkbox_items_in_treeview function should be called only
     > once. 
     
     OK.
     
     > 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;
     >     }
     >   else
     >     {
     >       /* 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:
     
     static void
     on_statistics_clicked (struct crosstabs_dialog *cd)
     {
       GtkListStore *liststore;
       int ret;
     
       liststore = clone_list_store (GTK_LIST_STORE (cd->stats));
     
       ret = psppire_dialog_run (PSPPIRE_DIALOG (cd->stats_dialog));
     
       if ( ret == PSPPIRE_RESPONSE_CONTINUE )
         {
           g_object_unref (liststore);
         }
       else
         {
           g_object_unref (cd->stats);
           gtk_tree_view_set_model (GTK_TREE_VIEW (cd->stats_view) , 
GTK_TREE_MODEL (liststore));
           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.
     
     -Jason
     
     
     _______________________________________________
     pspp-dev mailing list
     address@hidden
     http://lists.gnu.org/mailman/listinfo/pspp-dev

-- 
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://pgp.mit.edu or any PGP keyserver for public key.


Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]