; Module/File: LV_Scroll2ItemWithAlign.pb ; Function: scrolls 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 ;-------------------------------------------------------------- ;row_align (parameter 'RowAlign'): ; 0.0= top ; 0.5= center ; 1.0= bottom ; and all between 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, RowAlign.f); with row-alignment Protected *tPath= TV_GetPathFromIndex(Gadget, Item) gtk_tree_view_scroll_to_cell(GadgetID(Gadget), *tPath, #Null, #True, RowAlign, 0.0) gtk_tree_path_free_(*tPath) EndProcedure ;-Example ... If OpenWindow(0, 100, 100, 250, 200, "Scroll to Item w. align", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) ListViewGadget(0, 5, 5, WindowWidth(0) - 10, WindowHeight(0) - 45) SpinGadget(1, 5, WindowHeight(0)- 35, 100, 25, 1, 100, #PB_Spin_Numeric) SetGadgetText(1, "20") ButtonGadget(2, 170, 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 TV_Scroll2Item(0, GetGadgetState(1)-1, 0.5); row-align to center EndSelect EndIf Until gEvent= #PB_Event_CloseWindow EndIf ; IDE Options = PureBasic 5.40 LTS Beta 9 (Linux - x86) ; CursorPosition = 46 ; FirstLine = 24 ; Folding = - ; EnableUnicode ; EnableXP ; CurrentDirectory = /home/charly-xubuntu/Programming/PureBasic/purebasic/