Re: embedding G-I into apps
- From: Yu Feng <rainwoodman gmail com>
- To: Johan Dahlin <johan gnome org>
- Cc: Gtk+ Developers <gtk-devel-list gnome org>
- Subject: Re: embedding G-I into apps
- Date: Wed, 10 Sep 2008 10:14:31 -0400
Is it possible to make use of GTK_MODULES/ --gtk-modules ?
On Wed, 2008-09-10 at 13:59 +0200, Johan Dahlin wrote:
> Colin Walters wrote:
> > (Using this list for gobject-introspection development for now,
> > probably ignore if you're not jdahlin =))
> >
> > I was looking a bit today about applying our shiny new introspection
> > tool to Totem, with an eye to eliminating the manual binding
> > infrastructure, and more generally figure out how existing C
> > applications can use g-i (and something like Alex' GScript API) to
> > have a nicer way to embed Python or Spidermonkey.
>
> As far as I can see it there are two options:
> A) dlopen the executable (not portable)
> B) create a temporary shared library
> C) execute the scanner inside the application (as you suggested)
>
> Discarding A, as we want to be portable. I've always thought about using
> a temporary shared library to solve this particular problem, but the one you
> suggested appears to be better in many ways.
>
> > Now, the scanner requires, at build time, to load the app's code so we
> > can call the foo_get_type() functions and introspect
> > properties/signals etc. This is problematic because on some platforms
> > you can't just dlopen() an executable. Owen and I had a discussion
> > about this and it sounds like basically what we need to do is actually
> > invoke the scanner from inside the application. So here's how it
> > could work:
>
> get_type() functions obviously needs to be available to the whole application.
>
> > o Add a hidden --introspect option to application
> > o When given, dlopen("gobject-introspection-sanner.so")
> > o dlsym("g_introspection_scan")
> > o Pass our current argv to that function
> > o This function (in a separate shared library from
> > gobject-introspection.so), uses the cPython API to create an
> > interpreter and load /usr/bin/g-ir-scanner
> > o Locate the main() function inside the Python script g-ir-scanner,
> > and invoke it with the argv originally passed
> >
> > Kind of gross admittedly, but apps should only need a small patch for
> > this approach and it seems most likely to work on random platforms.
> > If someone knows a better/nicer way, let me know!
>
> I would rather do it the other way around, by creating C bindings
> for the scanner, so you could do:
>
> scanner = gi_scanner_new ()
> gi_scanner_set_namespace (scanner, "totem");
> gi_scanner_add_sources (scanner, "totem-menu.h", "totem-video-widget.h");
> etc.
>
> That would make it sufficient to just g_module_open(NULL);
>
> To do that we'd need two tools:
> 1) one to generate A GIR for a python interface
> 2) another to create C bindings for a python method.
>
> I have the beginning of a tool which does 2, which shouldn't be too hard to
> fix up to make it possible just to generate this small piece of clue.
>
> Johan
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]