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 10:35:53 +0900
User-agent: Mutt/1.5.17 (2007-11-01)

The put_checkbox_items_in_treeview function should be called only
once. 
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);
    }
}

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?

J'

On Fri, Feb 01, 2008 at 05:18:16PM -0500, Jason Stover wrote:
     I have a question about put_checkbox_items_in_treeview ().
     on_statistics_clicked() is the function that runs the stats dialog.
     The current version below is what I have to make the stats dialog box
     work correctly when the user presses the 'Cancel' button.  It mostly
     works. The call to put_checkbox_items_in_treeview() is there to restore
     the default after the user does anything but press 'Continue'. (I'll
     have to fix that so I don't restore the default if the user presses,
     say, 'Help', but that isn't the question I have now.)
     
     Here is the function:
     
     static void
     on_statistics_clicked (struct crosstabs_dialog *cd)
     {
       GtkTreeIter iter;
       bool ok;
       int ret;
       
       ret = psppire_dialog_run (PSPPIRE_DIALOG (cd->stats_dialog));
       
       if ( ret != PSPPIRE_RESPONSE_CONTINUE )
         {
           for (ok = gtk_tree_model_get_iter_first (cd->stats, &iter); ok;
           ok = gtk_tree_model_iter_next (cd->stats, &iter))
        {
          gtk_list_store_set (GTK_LIST_STORE (cd->stats), &iter,
                              CHECKBOX_COLUMN_SELECTED, false, -1);
        }
           put_checkbox_items_in_treeview (GTK_TREE_VIEW(cd->stats_view),
                                      B_CS_STATS_DEFAULT,
                                      N_CROSSTABS_STATS,
                                      stats);
         }
     }
     
     Now, without the call to put_checkbox_items_in_treeview (), the
     function behaves as expected and clears cd->stats. When I come back to
     the stats dialog, I can re-select whatever checkboxes I like. Groovy.
     
     But after the call to put_checkbox_items_in_treeview (), upon
     returning to the stats dialog, I cannot select any checkboxes. Except
     for the default checkbox, they are all empty, and I cannot change
     their states, no matter how frantically I click with the mouse.
     
     So is this a problem with put_checkbox_items_in_treeview (), or
     am I misunderstanding something?
     
     Also, I have tried different approaches to accomplish this task,
     and until this approach, all of them resulted in the user being unable
     to change the checkboxes on the second call to on_statistics_clicked().
     
     -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]