Recent

Author Topic: Capturing selection change in TListview (GTK signals)  (Read 7061 times)

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Capturing selection change in TListview (GTK signals)
« on: August 01, 2011, 06:50:37 am »
G'day,

Trying to debug some issues with GTK2 ListView relating to selection events.  In my code I've got all the kinks out of TListView with viewstyle set to vsReport (and I think vsList - the one which is just a one column, headerless treeview).  Now working on viewstyle set to vsIcon and vsSmallIcon.

I'm working with Lazarus 0.9.30 under Ubuntu 11.04 - 64bit version.

Here's what I've worked out so far, but I'm getting out of my depth a bit, and wouldn't mind some pointers from those in the know :-)

The unit I'm working in is gtk2wscustomlistview.inc

We're listening to the "selection-changed" signal when setting the GTK TreeView to Icon style.  My problem is this message is only being broadcast by the underlying GTK control when an item is selected.  We're not getting any notification of when an item is unselected.  This leads to issues with various listitems thinking they're still selected when we programmatically change selection.  (Interestingly I've only got to cycle over all ListItems and query their selected state to refresh their state, but that's a bit cumbersome for day to day use).

We're listening to the "changed" signal when setting the GTK TreeView to TreeView style.  In this model we're receiving both the select and unselect notifications.  This means the state of all the listitems within the TListView is maintained correctly.  The underlying GTK control is actually broadcasting way too many change messages (the GTK documentation acknowledges this), but by and large some smart code in customlistview.inc prevents duplicate OnSelects from being called (at least for the selected item - extra unselects on the old selected item still slip through in one place).

So, I've been trying to connect to the "changed" signal for GTK TreeView set to Icon mode.  Unsuccessfully.    I'm persevering (it's all a good learning curve) but am hoping someone can tell me how to do it :-) 

Alternatively, is there a way of finding out what the OLD selected items where when a "selection-changed" signal is fired?

Also, I'm slowly coming up to speed with the GTK2 documentation.  What I'm looking for is a list of what triggers fire off each signal, but I can't seem to find this.  Does anyone know if this documentation exists anywhere?
« Last Edit: August 01, 2011, 06:57:45 am by Mike.Cornflake »
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: Capturing selection change in TListview (GTK signals)
« Reply #1 on: August 06, 2011, 12:32:37 am »
FYI

So far, been completely unable to hook up "change", which is no surprise really - the GTK Icon View documentation doesn't list this signal.  All it lists is the signal we're using http://developer.gnome.org/gtk/2.24/GtkIconView.html#GtkIconView-selection-changed
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

 

TinyPortal © 2005-2018