Author Topic: [SOLVED] How can I extract an interface from a TGtkWidget (GtkScrollable) ?  (Read 312 times)


  • Guest
The widget implements GtkScrollable. In theory I could use

Code: Pascal  [Select][+][-]
  1.   gtk_scrollable_get_hadjustment: function(scrollable: PGtkWidget): PGtkAdjustment; cdecl;
  2.   gtk_scrollable_get_vadjustment: function(scrollable: PGtkWidget): PGtkAdjustment; cdecl;  

with my widget, but the parameter "scrollable" should actually be a PGtkScrollable, which is defined nowhere in the bindings. So I try using the PGtkWidget directly and then the funcs  obviously return garbages as this is not the right address.

See for more details. The idea is to sync a TScrollBar to the vertical scrollbar of the widget.

I'd eventually be okay to use a hacky method based on the ABI, e.g unsafe pointer arithmetic.
As the object structure is known the right pointer must be something like address of the widget + 8 * n (to get the location of the virtual table), then the dereference of this pointer + 8 * m (m is 0, 1 or 2 as there's only 3 interfaces in this widget).


  • Guest
Re: How can I extract an interface from a TGtkWidget (GtkScrollable) ?
« Reply #1 on: March 06, 2020, 10:02:16 pm »
looks like this is only possible since the gtk3 interface. the gtk2 version obiously has no interface and provide a direct getter (


TinyPortal © 2005-2018