How to change behaviour of List?



Hello,

I want to build a GtkList with the following behaviour:

o left mouse button is pressed:
  -  mark the item under the mouse pointer
  -  unmark all other items
  -> like GTK_SELECTION_SINGLE
o right mouse button is pressed:
  -  mark/unmark the item under the mouse pointer
  -> like GTK_SELECTION_MULTIPLE
  -  but ensure that one item is marked everytime, that means
     don't unmark the item, if it is the only marked one

I tried to do this the following way:
 gtk_list_set_selection_mode(..., GTK_SELECTION_MULTIPLE);
 gtk_signal_connect(...,"button_release_event",GTK_SIGNAL_FUNC(list_event),...);
   (and connected not to "selection_changed" !!)

In list_event() the following is done:
   GList *dlist;
   dlist = GTK_LIST(gtklist)->selection;

   switch ( event->button ) {
   case 1: ...
           gtk_list_unselect_child("all except the first element of dlist")
           /* the first element seems me to be the last which was selected */
   case 3: ...
           if ( there are no selections )
              gtk_list_select_child("last selected item which was stored")
   }

This seems me to be a quite painfull way which is very slow.  Is there
any better solution?

By the way, I'm using GTK+ 1.0.4 from the Debian 2.0 distribution which
includes the fine tutorial from Ian Main.  Is there any newer version
of this tutorial on the net or better, what is the "homesite" of this
very nice document (thanks Ian and the others!!)?

Kind regards

          Andreas.




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