Page 1 of 1

PB5.40B1-3 PB structure differences (Gtk)

Posted: Mon Sep 07, 2015 9:00 am
by Oma
Hi there.

In PB5.40B1-3 i've found some differences in the PureBasic structures for gtk. Maybe there are some more of this? Please try this code with V5.40 gtk3 (Standard) and Subsystem gtk2:

Code: Select all

ImportC ""
	gtk_widget_get_window(*widget.GtkWidget)
EndImport

Global.i gEvent, gQuit, gPointer
Global   *window.GtkWindow
Global   *widget.GtkWidget
Global   *GdkWindow.GdkWindowObject
Global   *gRange.GtkRange

If OpenWindow(0, 300, 200, 300, 200, "PB gtk-structures", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	TrackBarGadget(0, 5, 5, 290, 40, 0, 10)
	SetGadgetState(0, 5)
	
	; Window ...
	*window   = WindowID(0)
	*widget   = WindowID(0)
	*GdkWindow= gtk_widget_get_window(WindowID(0))
	gdk_window_get_user_data_(*GdkWindow, @gPointer)
	
	Debug "Differences in PB structures with gtk2 to gtk3 ..."
	Debug "GtkWindow from PB-ID                   : " + Str(*window)
	Debug "GdkWindow from GtkWindow (PB-Structure): " + Str(*widget\window);                 gtk2= GdkWindow; gtk3= 0
	Debug "GdkWindow from GtkWindow (API)         : " + Str(gtk_widget_get_window(*widget)); both ok
	Debug "GtkWindow from GdkWindow (PB-Structure): " + Str(*GdkWindow\user_data);           gtk2= GtkWindow; gtk3= ?
	Debug "GtkWindow from GdkWindow (API)         : " + Str(gPointer);                       gtk2= GtkWindow; gtk3= GtkWindow
	Debug "---"
	
	;TrackBar ...
	*gRange = GadgetID(0);                                                                   get range-class
	Debug "TrackBarPosition from (PB-Structure)   : " + Str(*gRange\adjustment\value);       preset value, gtk2= ok, gtk3= crash
	
	Repeat
		gEvent= WaitWindowEvent()
			Select gEvent
				Case #PB_Event_CloseWindow
					gQuit= #True
			EndSelect
	Until gQuit
EndIf
Regards, Charly

Re: PB5.40B1-3 PB structure differences (Gtk)

Posted: Mon Sep 07, 2015 9:33 am
by Fred
GtK3 doesn't allow to read structure field anymore, that's why you get some garbage.

Re: PB5.40B1-3 PB structure differences (Gtk)

Posted: Mon Sep 07, 2015 12:35 pm
by Oma
Hello Fred,

thank you. Good to know.
All issues i've found can be replaced with API-Functions.

Regards, Charly