; Module/File: LIG_SelectionsCount.pb ; Function: Anzahl selektierter ListIconGadget-Items - Linux ; Author: Omi ; Date: Juli 12, 2014 ; Version: 0.1 ; Target Compiler: PureBasic 5.22/5.31/5.40 ; Target OS: Linux: (X/K/L)ubuntu, Mint, 32/64, Ascii/Uni ;-------------------------------------------------------------- EnableExplicit ;Object constants #MainWin= 0 #LIG = 0 #But = 1 #WinX= 200 #WinY= 200 #WinW= 500 #WinH= 400 Global.l gEvent, gQuit ;- Functions ... Procedure.i LIG_CountSelections(Gadget); LIG: Anzahl selektierter Zeilen (= Items) holen (auch Multiselect) Protected *tSel.GtkTreeSelection *tSel= gtk_tree_view_get_selection_(GadgetID(Gadget)) ProcedureReturn gtk_tree_selection_count_selected_rows_(*tSel) EndProcedure ;- ;- Example ... Procedure CreateWindow_Main() Protected.l I, O Protected *Column If OpenWindow(#MainWin, #WinX, #WinY, #WinW, #WinH, "debug amount of selections", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) ButtonGadget(#But, 5, 5, 100, 25, "Count") ListIconGadget(#LIG, 5, 30, 480, 350, "Spalte 1", 70, #PB_ListIcon_AlwaysShowSelection | #PB_ListIcon_GridLines | #PB_ListIcon_CheckBoxes | #PB_ListIcon_MultiSelect) For O= 1 To 4 AddGadgetColumn(#LIG, O, "Spalte "+Str(O+ 1), 70) Next O For I= 1 To 20 AddGadgetItem(#LIG, -1, Str(I)+".1") Next I For O= 1 To 4 For I= 0 To 19 SetGadgetItemText(#LIG, I, Str(I+1)+"."+Str(O+1), O) Next I Next O For O= 3 To 4 For I= 0 To 19 SetGadgetItemText(#LIG, I, Str(20-I)+"."+Str(O+1), O) Next I Next O For I= 1 To 20 Step 3 SetGadgetItemState(#LIG, I, #PB_ListIcon_Selected) Next I EndIf EndProcedure CreateWindow_Main() Repeat gEvent= WaitWindowEvent() Select gEvent Case #PB_Event_CloseWindow gQuit= #True Case #PB_Event_Gadget If EventGadget()= #But Debug "selected items: " + Str(LIG_CountSelections(#LIG)) EndIf EndSelect Until gQuit ; IDE Options = PureBasic 5.40 LTS Beta 9 (Linux - x86) ; CursorPosition = 8 ; Folding = - ; EnableUnicode ; EnableXP ; CurrentDirectory = /home/charly-xubuntu/Programming/PureBasic/purebasic/