Web lists-archives.com

GTK's interfaces and language bindings




Recently someone tried to style a widget using CSS,

https://github.com/StefanSalewski/gintro/issues/2#issuecomment-316167963

and so I discovered that there is still some labor for me...

Before I start coding, maybe it is better to verify my understanding of
the gobject interfaces...


For example, we have

https://developer.gnome.org/gtk3/stable/GtkStyleContext.html#gtk-style-context-add-provider

which may be called from C like

gtk_style_context_add_provider(gtk_widget_get_style_context(window),
                                   GTK_STYLE_PROVIDER(cssProvider),
                                   GTK_STYLE_PROVIDER_PRIORITY_USER);

So the second parameter is of type GtkStyleProvider, which is an
interface. GtkCssProvider provides that interface, so we can pass a
variable of that type. GTK_STYLE_PROVIDER() is basically only a cast, a
re-interpretation of the bit pattern, maybe with additional security
checks.

As we generally do not want such casts in higher level languages, we
may just provide an additional function with the same name which
accepts a GtkCssProvider.

For this special case that is clear, and already tested. So I assume,
that for all functions which has interfaces as parameters, I can just
pass all objects (gobjects) which provides that interface?

I even guess hat interfaces are fully abstract entities, so we will
never pass an instance of an interface, but always only objects
providing the interface. So we have only to provide functions which can
accepts all the objects providing the that interface, but we do not
really need functions which would accepts the interface parameter type
itself?

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list