A Glade plugin to include a hack of Christian Hergert GtkBuilderScript and enable edit JavaScript.
GtkBuilder + Inline JavaScript.
This is a quick hack to allow writing javascript inside of a GtkBuilder xml file and attaching signals to said javascript functions.
GScriptJs is an object that can be created from within the GtkBuilder file. The "script" property is used to eval javascript into the JSContext.
Use a connect callback similar to connect_func in script.c.
Cheers, and Happy Hacking,
Christian Hergert chris@dronelabs.com
In Ubuntu 14.10, install (at least) these packages:
- libcjs-dev: Required.
- libgirepository1.0-dev: Required.
- libgladeui-dev: For Glade plugin.
- libgtksourceview-3.0-dev: For editor, also required by Glade plugin.
- gir1.2-gstreamer-1.0: For guitar tuner example.
- gir1.2-gda-5.0: For phonebook example.
$ apt-get install libcjs-dev libgladeui-dev libgtksourceview-3.0-dev libgirepository1.0-dev gir1.2-gda-5.0 gir1.2-gstreamer-1.0
And, of course, a C compiler, make and pkg-config utilities and you probably want Glade too!
git clone https://github.com/jmouriz/visual-gtk
cd visual-gtk
. set-glade-environment.sh
This will exports:
- PATH: Search path to binary application.
- LD_LIBRARY_PATH: Search path to shared objects (.so) library.
- GI_TYPELIB_PATH: Search path to GObject Introspection .typelib file.
- GLADE_CATALOG_SEARCH_PATH: Search path to Glade catalog .xml file.
- GLADE_MODULE_SEARCH_PATH: Search path to Glade plugin (.so) file.
- XDG_DATA_DIRS: Search path to Glade palette icon.
- GSCRIPT_MODULE_SEARCH_PATH: Search path for GScript internal modules (.js).
make
g-script
examples/calculator/calculator.ui
[Download]
g-script
examples/phonebook/phonebook.ui
[Download]
g-script
examples/tuner/tuner.ui
[Download]
g-script
examples/viewer/viewer.ui
[Download]
And enjoy with Glade.
Juan Manuel Mouriz jmouriz@gmail.com