Page 1 of 1

Posted: Mon Mar 02, 2009 12:57 am
by freak

Code: Select all

ProcedureC ColumnClick(*Column, user_data)
  Debug "Column clicked: " + Str(user_data)
EndProcedure

If OpenWindow(0, 100, 100, 300, 100, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(0, 5, 5, 290, 90, "Column0", 100, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
  AddGadgetColumn(0, 1, "Column1", 100)
  AddGadgetColumn(0, 1, "Column2", 150)

  ; make the header clickable
  gtk_tree_view_set_headers_clickable_(GadgetID(0), #True)
  
  For ColumnIndex = 0 To 2
  
    ; get the pointer to the column 
    *Column = gtk_tree_view_get_column_(GadgetID(0), ColumnIndex)
    If *Column
      ; Connect signal handler
      ;
      ; In unicode mode, "clicked" must be converted to ascii!
      ; The ColumnIndex parameter will be passed as user_data to the callback
      g_signal_connect_data_(*Column, "clicked", @ColumnClick(), ColumnIndex, 0, 0)
    EndIf
    
  Next ColumnIndex
      
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
There are also functions to let the Gadget handle most of the sorting, but i did not try those yet.

Posted: Mon Mar 02, 2009 7:47 am
by bembulak
Praise you, freak!
You made my day.
Thanks a lot!