[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gobject introspection support in the xwidget branch
From: |
joakim |
Subject: |
gobject introspection support in the xwidget branch |
Date: |
Mon, 23 Jul 2012 15:42:55 +0200 |
User-agent: |
Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1.50 (gnu/linux) |
I have implemented gobject introspection support[1] in the xwidget branch[2].
See [3] for background information about the xwidget branch.
supporting gobject introspection means that more gtk widgets can be
tried out with less effort, and also that the build process and runtime
support for widgets is easier. The drawbacks are small: somewhat slower
execution, and difficulty in providing elisp bindings for introspection.
In order for GIR to work, it needs the namespace and class of a
widget. This is used to access the typelib file, which contains the
introspection data. The namespace and class is stored as a property
on the lisp symbol handle used by xwidgets to identify the widget
class.
This snippet sets the needed :xwgir-class property, and calls the
set_zoom_level method:
M-x xwidget-webkit-browse-url RET www.emacswiki.org RET
Then eval the following:
;;load the webkit typelib
(xwgir-require-namespace "WebKit" "2.0")
;;provide the metadata needed so xwgir can work with the webkit-osr xwidget
(put 'webkit-osr :xwgir-class '("WebKit" "WebView"))
;;call the method
(xwgir-call-method (xwidget-at 1) "set_zoom_level" '(3.0))
It's also possible to create widgets dynamically, by using
introspection to call a widget constructor(from xwidget-test.el):
(defun xwgir-test ()
(interactive)
(xwgir-require-namespace "Gtk" "3.0")
(put 'color-selection :xwgir-class '("Gtk" "ColorSelection"))
(xwgir-demo-a-xwgir-button)
(xwgir-call-method (xwidget-at 1) "set_label" '( "xwgir set label!"))
)
Current limitation:
- Only 0 arg constructors are supported at the moment. Since xwidgets
defer construction, the args needs to be stored with the xwidget, and
this hasn't been done yet.
- xwgir-call-method does indeed lisp to gobject conversion for the
arguments, but only some primitive types are supported atm.
- next to no argument checking. If wrong type args are used with the
xwgir methods, emacs crashes.
Footnotes:
[1] https://live.gnome.org/GObjectIntrospection/
[2] bzr branch http://bzr.savannah.gnu.org/r/emacs/xwidget
[3] http://bzr.savannah.gnu.org/lh/emacs/xwidget/annotate/head:/README.xwidget
--
Joakim Verona
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gobject introspection support in the xwidget branch,
joakim <=