; Module/File: LIG_ItemsReorderable.pb ; Function: D&D-reorderable LIG items w. autoscroll, w/o PB-activation - Linux ; Author: Omi ; Date: Dec. 20, 2015 ; Version: 0.2; bug removed ; Target Compiler: PureBasic 5.22/5.31/5.40/5.5/5.6 ; Target OS: Linux: (X/K/L)ubuntu, Mint, 32/64, Ascii/Uni ;-------------------------------------------------------------- ;Warning: The correct 1:1 link from PureBasic-Item to the actual position is lost! EnableExplicit ;not neccessary ImportC "" g_signal_connect(*instance, detailed_signal.p-utf8, *c_handler, *pdata, destroy= 0, flags= 0) As "g_signal_connect_data" EndImport ;Object constants #MainWin= 0 #LIG = 0 Global.i gEvent, gQuit ;not neccessary, only to debug infos ... ProcedureC Callback_TreeView_RowInserted(*tree_model, *path, *iter, user_data) Debug "Row inserted: " + Str(PeekL(gtk_tree_path_get_indices_(*path))) EndProcedure ProcedureC Callback_TreeView_RowDeleted(*tree_model, *path, user_data) Debug "Row deleted : " + Str(PeekL(gtk_tree_path_get_indices_(*path))) EndProcedure ProcedureC Callback_TreeView_RowChanged(*tree_model, *path, *iter, user_data) Debug "Row changed : " + Str(PeekL(gtk_tree_path_get_indices_(*path))) EndProcedure ;----- Procedure CreateWindow_Main() Protected.i I, *TreeModel If OpenWindow(#MainWin, 200, 200, 500, 400, "ListIconGadget-Items reorderable", #PB_Window_SystemMenu) TextGadget(#PB_Any, 5, 5, 490, 22, "Reordering rows (items) by Drag&Drop whithin 1 ListIconGadget ...") ListIconGadget(#LIG, 5, 40, 490, 355, "column 0", 70, #PB_ListIcon_AlwaysShowSelection | #PB_ListIcon_GridLines) For I= 1 To 4 AddGadgetColumn(#LIG, I, "Column "+Str(I), 90) Next I For I= 0 To 19 AddGadgetItem(#LIG, -1, "Cell " + Str(I) + "-0" + #LF$ + "Cell " + Str(I) + "-1" + #LF$ + "Cell " + Str(I) + "-2" + #LF$ + "Cell " + Str(I) + "-3" + #LF$ + "Cell " + Str(I) + "-4") Next I EndIf ;no combination with Drop on further ListIconGadgets possible, if activated!!! & there's a bug at moment if you quit ... gtk_tree_view_set_reorderable_(GadgetID(#LIG), #True) ;not neccessary, only for additional infos ... *TreeModel= gtk_tree_view_get_model_(GadgetID(#LIG)) g_signal_connect(*TreeModel, "row-inserted", @Callback_TreeView_RowInserted(), #LIG) g_signal_connect(*TreeModel, "row-deleted", @Callback_TreeView_RowDeleted(), #LIG) g_signal_connect(*TreeModel, "row-changed", @Callback_TreeView_RowChanged(), #LIG) EndProcedure CreateWindow_Main() Repeat gEvent= WaitWindowEvent() Select gEvent Case #PB_Event_CloseWindow gQuit= #True EndSelect Until gQuit ; IDE Options = PureBasic 5.45 LTS (Linux - x86) ; CursorPosition = 37 ; Folding = - ; EnableUnicode ; EnableXP