; Module/File: LV_Scroll2Item.pb ; Function: Scroll to row (item) with bottom alignment - Linux gtk2/gtk3 ; Author: Omi ; Date: Oct. 14, 2014 ; Version: 0.2 (64-Bit Problem) ; Target Compiler: PureBasic 5.22/5.31/5.40 ; Target OS: Linux: (X/K/L)ubuntu, Mint, 32/64, Ascii/Uni ;-------------------------------------------------------------- EnableExplicit ImportC "" gtk_tree_view_scroll_to_cell(*widget.gtkwidget, *tPath, *tColumn, use_align, row_align.f, col_align.f) gtk_tree_model_get_iter_from_string(*tree_model, *iter.GtkTreeIter, path_string.p-utf8) EndImport Global.i gEvent Global.i I ;- Hilfsroutine ... Procedure.i TV_GetPathFromIndex(Gadget, Row); path-pointer from row Protected iter.GtkTreeIter Protected *tModel Protected *tPath *tModel= gtk_tree_view_get_model_(GadgetID(Gadget)) gtk_tree_model_get_iter_from_string(*tModel, @iter, Str(Row)) *tPath = gtk_tree_model_get_path_(*tModel , @iter) ProcedureReturn *tPath EndProcedure ;- End Hilfsroutine ;-Function ... Procedure TV_Scroll2Item(Gadget, Item); alignment deactivated, always bottom Protected *tPath= TV_GetPathFromIndex(Gadget, Item) gtk_tree_view_scroll_to_cell(GadgetID(Gadget), *tPath, #Null, #False, 0.0, 0.0) gtk_tree_path_free_ (*tPath) EndProcedure ;-Example ... If OpenWindow(0, 100, 100, 220, 220, "Scroll to Item", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) ListViewGadget(0, 5, 5, WindowWidth(0) - 10, WindowHeight(0) - 45) SpinGadget(1, 5, WindowHeight(0)- 35, 70, 25, 1, 100, #PB_Spin_Numeric) SetGadgetText(1, "20") ButtonGadget(2, 115, WindowHeight(0) - 35, 70, 25, "Jump to") For I= 1 To 100 AddGadgetItem(0, -1, "Line " + Str(i)) Next I Repeat gEvent = WaitWindowEvent() If gEvent = #PB_Event_Gadget Select EventGadget() Case 1 SetGadgetState(1, Val(GetGadgetText(1))) Case 2 CompilerSelect #PB_Compiler_OS CompilerCase #PB_OS_Linux TV_Scroll2Item(0, GetGadgetState(1)-1) CompilerCase #PB_OS_Windows SendMessage_(GadgetID(0), #LVM_ENSUREVISIBLE, GetGadgetState(1), #True) CompilerEndSelect EndSelect EndIf Until gEvent= #PB_Event_CloseWindow EndIf ; IDE Options = PureBasic 5.40 LTS Beta 9 (Linux - x86) ; CursorPosition = 43 ; Folding = - ; EnableUnicode ; EnableXP ; CurrentDirectory = /home/charly-xubuntu/Programming/PureBasic/purebasic/