GTK Problem

Archives Forums/Linux Discussion/GTK Problem

Nigel Brown(Posted 2007) [#1]
Using the code below I get an error of sorts when I create a treeview. It seems to generate a GADGETSELECT event as well as the expected MENUACTION event?

This only happens when using the gtkmaxgui module, try commenting teh fltk module back in at the top and see the difference.

SuperStrict

Framework brl.blitz

?Linux
	Import bah.gtkmaxgui
'	Import brl.fltkmaxgui
?

Global main_window:TGadget = CreateWindow(AppTitle,0,0,320,240)
Global treeview:TGadget = CreateTreeView( 8, 4, 296-70, 176, main_window )
Global filemenu:TGadget = CreateMenu("Devices",	0,WindowMenu(main_window))

CreateMenu("Rescan Devices",101, filemenu )
UpdateWindowMenu(main_window)
ShowGadget(main_window)

Repeat

	DebugLog CurrentEvent.tostring()

	Select WaitEvent()

		Case EVENT_MENUACTION
				DebugLog "HERE ;-)"
	

			Select EventData()
				Case 101
					If treeview <> Null
						FreeGadget(treeview)
						treeview = Null
						GCCollect()
					EndIf
					treeview:TGadget = CreateTreeView( 8, 4, 296-70, 176, main_window )
			EndSelect

		Case EVENT_GADGETSELECT
			DebugLog "WHY HERE, WHEN I SELECT MENU?"

		Case EVENT_WINDOWCLOSE
			If EventSource() = main_window Then Exit

	End Select

Forever



Nigel Brown(Posted 2007) [#2]
Are you on hoiday Brucey? :-)


Brucey(Posted 2007) [#3]
I wish...

I've fixed it, just haven't got around to releasing it yet... (but I've only myself to blame!)


Brucey(Posted 2007) [#4]
If you are super-desperate for it, the fix is a one-liner :

gtkgadget.bmx

Before:
	Method initTreeView(x:Int, y:Int, w:Int, h:Int, label:String, group:TGadget, style:Int)
		init(GTK_TREEVIEW, x, y, w, h, style)

		kids = New TEList


After:
	Method initTreeView(x:Int, y:Int, w:Int, h:Int, label:String, group:TGadget, style:Int)
		init(GTK_TREEVIEW, x, y, w, h, style)

		ignoreListChangeEvent = True
		
		kids = New TEList



Of course, you are welcome to ask me why does a TreeView raise a select event on creation... I would reply by directing you to the GTK forums :-p


Brucey(Posted 2007) [#5]
Forgot to mention... a new GTK version is available via syncmods...

Will be updating my website proper in due course.