GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Nov 22, 2014 1:48 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: GTK_SELECTION_SINGLE not working on GtkTreeView
PostPosted: Tue Mar 25, 2008 10:59 pm 
Offline
Familiar Face

Joined: Tue Mar 25, 2008 9:41 pm
Posts: 7
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 26, 2008 2:25 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
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.

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 26, 2008 4:16 pm 
Offline
Familiar Face

Joined: Tue Mar 25, 2008 9:41 pm
Posts: 7
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...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 26, 2008 4:43 pm 
Offline
Familiar Face

Joined: Tue Mar 25, 2008 9:41 pm
Posts: 7
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group