Unable deselect a row in a GtkTreeView with the mouse and other questions



Hi,

I wrote an application in GTK2 but it gives strange me behaviour.
First, I cannot deselect a row in a GtkTreeView with the mouse,
despite the GtkListStore behind it is GTK_SELECTION_SINGLE.
From the documentation:

GTK_SELECTION_SINGLE    Zero or one element may be selected.
GTK_SELECTION_BROWSE Exactly one element is selected. In some circumstances, such as initially or during a search operation, it's possible for no element to be selected with GTK_SELECTION_BROWSE. What is really enforced is that the user can't deselect a currently selected element except by selecting another element.

So, I guess GTK_SELECTION_SINGLE provides a way for the user to deselect
the already selected row, but how? In GTK-1.2.x, a mouse click deselects the
already selected row.

I used the "changed" signal of GtkTreeSelection to detect any changes in
the state of the selection. Is it a problem? This is the event callback I used:

static void jk_sel_changed_cb (GtkTreeSelection *selection, gpointer data) {
 GtkTreeIter           iter;
 GtkTreeModel          *model;

 if (gtk_tree_selection_get_selected (selection, &model, &iter))
   do_something();
 else
   printf("unselect\n");
}

The do_something() function uses gtk_tree_model_get() on the
model behind the view, but it doesn't change it in any way.
I can only trigger the printf() above only from my code, e.g.
by using gtk_tree_selection_unselect_all().

There is another problem with the way focus is handled when
I put GtkNotebooks on pages of a GtkNotebook. The "leaf" GtkNotebooks
mostly contain GtkTreeViews. On startup, I fill the GtkListStores behind the
Views and use  gtk_tree_selection_unselect_all() so the user should have to
select the data he wants to view. I can see the TreeViews have no selected
rows if I only change pages of the root GtkNotebook. Problem is:
the first leaf GtkNotebook I change page on somehow selects the first row
on all the GtkTreeViews on its pages. E.g. I choose any page of the
main Notebook and start browsing the pages of the Notebook on that page
selects the first rows of the Views. I choose another page of the main
Notebook, the Views on the pages of the Notebook on the page
I selected second stay unselected. How can I prevent this?

Thanks and best regards,
Zoltán Böszörményi




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