Recent

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

guest58172

  • 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 https://developer.gnome.org/vte/unstable/VteTerminal.html#VteTerminal.implemented-interfaces 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).

guest58172

  • 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 (https://developer.gnome.org/vte/0.28/VteTerminal.html#vte-terminal-get-adjustment)

 

TinyPortal © 2005-2018