problem with togglebutton in treeview



I have got a problem with a treeview, which has got 2 columns. The first
has got  a GtkCellRendererToggle and the  second has got a  normal text.
Each time the checkbutton is clicked I  have to run a callback to update
a data structure and to let toggle the button.

The first time I  click on the togglebutton it becomes  active, but if I
click  on it  other time  I  cannot make  it  toggle any  more. I  can't
understand why. I'm attaching the callback, can you please help me?

Thank you

void
on_treeview_clicked                     (GtkCellRendererToggle *cellrenderertoggle,
                                         gchar                 *arg1,
                                         gpointer              user_data)
{
  GtkTreeIter iter;
  GtkTreeModel *model;
  // GtkSwap is a custom widget that contains the treeview.
  GtkTreeView *tree = GTK_SWAP (user_data)->treeview;
  GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
  char *name;
  gboolean state;
                                                                                                               
  if (gtk_tree_selection_get_selected (selection, &model, &iter))
  {
    GtkTreePath *path;
    gtk_tree_model_get (model, &iter, USE_COLUMN, &state, NAME_COLUMN, &name, -1);
                                                                                                               
    state = !state;
                                                                                                               
    if (state==TRUE) printf("true\n");
    if (state==FALSE) printf("false\n");
                                                                                                               
    gtk_tree_store_set (GTK_TREE_STORE (model), &iter, USE_COLUMN, &state, -1);
    path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
    gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (model), path, &iter);
    gtk_tree_path_free (path);
  }
                                                                                                               
}

-- 
Non c'è più forza nella normalità, c'è solo monotonia.

Attachment: pgprU844hHTQI.pgp
Description: PGP signature



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