GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GTK_SELECTION_SINGLE not working on GtkTreeView

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
carlos
Familiar Face


Joined: 25 Mar 2008
Posts: 7

PostPosted: Tue Mar 25, 2008 10:59 pm    Post subject: GTK_SELECTION_SINGLE not working on GtkTreeView Reply with quote

In all the GtkTreeView examples I saw so far,

GTK_SELECTION_NONE, GTK_SELECTION_BROWSE, GTK_SELECTION_MULTIPLE, work as expected, but
GTK_SELECTION_SINGLE just does the same as GTK_SELECTION_BROWSE, so an object is always selected, even at the beiginning.

Could someone explain to me what is going on here? it seems a serious bug...

The code to set the selection mode is just:

GtkWidget *treeview;
GtkTreeSelection *selection;

selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);

Thank you, for your time!
Carlos
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 407
Location: Portland, OR USA

PostPosted: Wed Mar 26, 2008 2:25 pm    Post subject: Reply with quote

Using GTK_SELECTION_SINGLE works for me, however, it seems that since the treeview is the only widget in my little test window, it's getting focus when shown and automatically selects the first item. But I can de-select it using CTRL+click when in GTK_SELECTION_SINGLE and cannot using GTK_SELECTION_BROWSE.
Back to top
carlos
Familiar Face


Joined: 25 Mar 2008
Posts: 7

PostPosted: Wed Mar 26, 2008 4:16 pm    Post subject: Reply with quote

I can reproduce your results, but there are two problems with that approach:

1) a default option is always shown in the beginning, usually the first one. This is usually the wrong approach. Setting a default is confusing and shows some guidance from the program that users don't like. Let's say I have a list of hotels for the user to choose. Which hotel is going to be the default? the correct answer is: none! If the first hotel is the default, then users correctly think that the program is giving an unfair advantage to that hotel... that the program is pushing that option into them...

In my app, when users click on a list in a second level dialog, that information is transported to a first level dialog. With the current implementation, when users open the second dialog, the first item in the list is immediately transported to the first level dialog. Totally absurd.

Fortunately I found a workaround for this bug, which is to start in mode GTK_SELECTION_NONE, and after the window is realized, to change to mode GTK_SELECTION_SELECTION. But is ugly.

2) To unselect an item should be as simple as to select it. Users of course totally ignore the Ctrl-click trick, so in my hotel example, they will keep clicking and as nothing happens they will take the conclusion that they cannot unselect an hotel, so the program is forcing them to make a choice that they do not want... to spend their money in the hotel... totally absurd...
Back to top
carlos
Familiar Face


Joined: 25 Mar 2008
Posts: 7

PostPosted: Wed Mar 26, 2008 4:43 pm    Post subject: Reply with quote

In fact the Ctr click trick is broken. Just download the small example I posted at: http://www.gamgi.org/treeview.c

When you start, it shows three rows: apples, oranges, bananas, in this order. So apples is automatically selected,
and the callback message shows that.

Now, press Ctr click on apples. You are unselecting apples but
gtk_tree_selection_get_selected says that apples was actually selected! gtk_tree_selection_get_selected should return FALSE, because no selection exists t this moment.

Press apples again. gtk_tree_selection_get_selected gives the right answer, you selected apples.
Now press Ctr click on bananas. You are selecting bananas (sort of) but gtk_tree_selection_get_selected again says that you selected apples!

So GTK_SELECTION_SINGLE is unnusable, even if you accept the default and the Ctr click trick.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP