First of all: It works on my Xubuntu 13.10 (32-Bit) and Ubuntu 12.04, (64-Bit)
The last days i tried an improvement of my ListIcon-CellEdit to a more native version, still with problems.
Now i found your code and canceled my trials.
Congratulation and thank you for the short und fine solution!. This is VERY usefull.
To fulfill my needs for more than 1 editable column, i did a fusion with a small part of my trials and hope it makes it still more practicable.
What i've changed ...
- connect a 2. signal for 'editing-started' with a 2. callback
- in this callback i read the column of the current edited cell and save it in the ListIcon-Data like you did generally. So the column is flexible.
this callback also should be used for removing Keyboardshortcuts like #PB_Shortcut_Return, #PB_Shortcut_Escape, #PB_Shortcut_C | #PB_Shortcut_Control
during celledit if they are used for ListIcon-Lines or Buttons in the same window to avoid conflicts
- call the MakeColumnEditable() (my name: TV_ColumnSetEditable()) for each column i need
- the '_ColumEdited_Callback' also should be used to reactivate the removed Keyboardshortcuts
Please excuse my 'hijacking' of your code.
Code: Select all
EnableExplicit
ImportC "-gtk"
g_object_set(object, property.p-UTF8, value, v=0)
g_signal_connect(instance, signal.p-ascii, callback, vdata, destroy=0, flags=0) As "g_signal_connect_data"
gtk_cell_layout_get_cells(col)
g_type_check_instance_is_a(*instance.GTypeInstance, *type.GTypeClass)
EndImport
ProcedureC _ColumEditStart_Callback(Cell, Edit.s, Path.s, Gadget)
Protected *TreePath, *TreeColumn, *ColumnList.GList
Protected.i Column= -1
gtk_tree_view_get_cursor_(GadgetID(Gadget), @*TreePath, @*TreeColumn); pathes of cell just started to edit
If *TreePath
*ColumnList= gtk_tree_view_get_columns_(GadgetID(Gadget)); adress of column-List
Column = g_list_index_(*ColumnList, *TreeColumn); index of edited column
EndIf
SetGadgetData(Gadget, Column); Save current edited column in LIG-Data till next editstart
If *TreePath : gtk_tree_path_free_(*TreePath) : EndIf
g_list_free_(*ColumnList)
EndProcedure
ProcedureC _ColumEdited_Callback(Cell, Path.s, newTxt.s, Gadget)
Protected Row = Val(Path)
If GetGadgetData(Gadget)>- 1
SetGadgetItemText(Gadget, row, PeekS(@newTxt, -1, #PB_UTF8), GetGadgetData(Gadget))
EndIf
EndProcedure
Procedure MakeColumnEditable(ListIcon, Column)
Protected col = gtk_tree_view_get_column_(GadgetID(ListIcon), Column)
Protected aList = gtk_cell_layout_get_cells(col)
Protected renderer
Protected i
For i = 0 To g_list_length_(aList) - 1
renderer = g_list_nth_data_(alist, i)
If g_type_check_instance_is_a(renderer, gtk_cell_renderer_text_get_type_())
Break
EndIf
Next i
g_list_free_(aList)
SetGadgetData(ListIcon, -1)
g_signal_connect(renderer, "editing-started", @_ColumEditStart_Callback(), ListIcon)
g_signal_connect(renderer, "edited", @_ColumEdited_Callback(), ListIcon)
g_object_set(renderer, "editable", 1)
EndProcedure
OpenWindow(1, 100, 100,400, 200, "ListIcon Editing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(1, 5, 5, 390, 190, "Edit1", 90)
gtk_tree_view_set_enable_search_(GadgetID(1), 0)
AddGadgetColumn(1, 1, "Fix2", 200)
AddGadgetColumn(1, 2, "Edit3", 200)
MakeColumnEditable(1, 0)
MakeColumnEditable(1, 2)
AddGadgetItem(1,0, "001" + #LF$ + "Edit 2-1" + #LF$ + "Edit 3-1")
AddGadgetItem(1,1, "002" + #LF$ + "Edit 2-2" + #LF$ + "Edit 3-2")
AddGadgetItem(1,2, "003" + #LF$ + "Edit 2-3" + #LF$ + "Edit 3-3")
;
Repeat
Define Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End
ps: 2 fixes done, see shardiks postings