Gazpacho for maemo 3.x
Please note that Gazpacho in maemo 3.x is not officially supported. This document may not be complete up-to-date nor accurate.
Introduction to Gazpacho
Gazpacho is an application for GUI design, written entirely in Python, and aimed at the GTK+ widget set. The target audience is the same as for Glade.
Gazpacho output is a Glade XML file. In theory, this file can be loaded by libglade but this does not work as yet: Gazpacho makes use of the Glade XML in extended ways that libglade does not yet respond to.
To cope with this, the Gazpacho project also supplies an XML loader that is employed in place of libglade. This is the only piece of code that the XML "consumer" needs to have installed. In the future, when libglade fully understands Gazpacho XML files, this loader is no longer necessary.
The Gazpacho loader is implemented in Python, so, for now, only Python/GTK+ applications can make use of Gazpacho-designed GUIs.
Unlike libglade, Gazpacho is intended to be extensible, so it is very easy to add support to new widgets (both at GUI designer and at loader side), like the Hildon widget set present in maemo platform.
Gazpacho for maemo is still presently in active development. If you find any bugs, report to http://bugs.maemo.org.
The official Gazpacho site is located at http://gazpacho.sicem.biz/.
Gazpacho for maemo
Gazpacho for maemo is a package that extends Gazpacho with the Hildon widget set, allowing for easy GUI development with Hildon components, as well as allowing Hildon GUIs to be encoded in XML.
Before Gazpacho for maemo, Hildon components could not function in XML .glade files; the interface had to be hard-coded in the application (either in C or in Python).
Gazpacho for maemo files go mainly into two folders:
- /usr/share/gazpacho/resources/hildonwidgets supplies the widget set extension for the GUI builder. It does not have any Python code, and it is not necessary at runtime.
- /usr/lib/python2.4/site-packages/gazpacho/widgets/hildonwidgets contains Python code, mostly adaptors for Hildon classes. These files are necessary both at design and runtime.
Note the the folders contain very little code and data, since Python makes it so easy to create objects based on classes' names (in this case, building the GTK+ object tree based on a XML tree) that the Gazpacho loader offloads most of the hard work onto the Python-Hildon bindings.
Installing Gazpacho
To install Gazpacho go to garage and download the required Gazpacho components from there.
The direct link to find the gazpacho modules is:
-
The following packages must be downloaded and installed for development:
- Gazpacho-Maemo
- Gazpacho-Plugins
- Gazpacho-Hildon
They must be installed inside Scratchbox since Gazpacho/Hildon extra widgets depend on Hildon library and Python-Hildon bindings, which lie inside the SDK sandbox.
Gazpacho for Hildon must be run inside Scratchbox and inside a Xephyr window, since it also depends on maemo graphic services. Run Gazpacho in a window bigger than the normal 800x480:
/home/epx $ # outside Scratchbox /home/epx $ xhost + access control disabled, clients can connect from any host
[scratchbox: ~] # inside Scratchbox, note the bigger Xephyr screen resolution 1024x768 [scratchbox: ~] > DISPLAY=:0 Xephyr :2 -host-cursor -screen 1024x768x16 -dpi 96 -ac &
You also need to start some maemo services to allow Gazpacho to run inside Scratchbox. The script gazenv-init.sh (included in the gazpacho-hildon package) is analogous to the af-sb-init script, but starts only the required services. Run the script as follows:
[scratchbox: ~] # inside Scratchbox [scratchbox: ~] > DISPLAY=:2 gazenv-init.sh start
You need a window manager for this virtual screen. The maemo window manager is not sufficient because it expects a 800x480 screen. From outside Scratchbox, run the window manager of your preference , for example, metacity:
/home/epx $ # outside Scratchbox /home/epx $ DISPLAY=:2 metacity &
-
Run Gazpacho:
[scratchbox: ~] # inside Scratchbox [scratchbox: ~] > DISPLAY=:2 gazpacho &
Figure 1. Gazpacho/Hildon splash screen inside the Xephyr window
To run Gazpacho applications in the target device, you need to install Gazpacho-loader and Gazpacho-Hildon in the device.
Installing the latest Gazpacho development packages
The latest Gazpacho development branch is supported on the maemo platform. There are good reasons for using this branch. For example, it is actively developed and it contains features that are missing from the package version of Gazpacho. However, installation is more complicated.
To run the development version of Gazpacho, you need the following packages
- Gazpacho source code from Gazpacho's trunk
- Source code for Kiwi widgets
- Source code for Gazpacho-Hildon binding
To install the development packages:
-
Obtain the source code for the Kiwi widgets from http://www.async.com.br/projects/kiwi/. Download version 1.9.6 or later. Install Kiwi widget set by running the following commands:
[scratchbox: ~] # inside Scratchbox [scratchbox: ~] > tar -xzf [KIWIPACKAGE] [scratchbox: ~] > cd kiwi-1.9.X [scratchbox: ~] > $PYTHON setup.py install
-
When Kiwi has been installed, the Gazpacho can be installed. To do this you have to obtain the latest source code and install it.
[scratchbox: ~] # inside Scratchbox [scratchbox: ~] > svn co http://svn.sicem.biz/gazpacho/trunk gazpacho [scratchbox: ~] > cd gazpacho [scratchbox: ~] > $PYTHON setup.py install
-
Gazpacho-hildon bindings are required to ensure that the hildon widgets can be used to construct UIs. This package is also obtained from the following repository:
[scratchbox: ~] # inside Scratchbox [scratchbox: ~] > svn co https://stage.maemo.org/svn/maemo/projects/haf/ [scratchbox: ~] > cd gazpacho-hildon [scratchbox: ~] > dpkg-buildpackage -rfakeroot [scratchbox: ~] > cd .. [scratchbox: ~] > fakeroot dpkg -i gazpaco-hildon_PACKAGE_VERSION_all.deb
-
After you have installed all packages, you must start Gazpacho.
/home/epx $ # outside Scratchbox /home/epx $ cp .Xauthority /scratchbox/users/$USER/$HOME /home/epx $ scratchbox /usr/bin/run-gazpacho.sh
Example of a Gazpacho/Hildon application
You can now make a basic "Hello World"-style application with Gazpacho to make sure that your installation is correct. Firstly, you must design the GUI inside Gazpacho.
The top-level widget must be the Hildon Window (HildonWindow class). The Hildon Application (HildonApp class) is obsolete and would trigger an exception in Gazpacho.
Figure 2. Gazpacho/Hildon with a top-level HildonWindow open
Once you have a Hildon Window, you can throw in more widgets, like horizontal boxes, vertical boxes, labels, entries and so on.
Figure 3. Gazpacho/Hildon, HildonWindow with some widgets added
The GUI shown in the figure above translates into the following Glade XML (saved as helloworld.glade):
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> <!DOCTYPE glade-interface SYSTEM "http://gazpacho.sicem.biz/gazpacho-0.1.dtd"> <glade-interface> <widget class="HildonWindow" id="window1"> <property name="height_request">396</property> <property name="title" context="yes" translatable="yes">Hello World</property> <property name="width_request">672</property> <child> <widget class="GtkVBox" id="vbox1"> <child> <widget class="GtkLabel" id="label1"> <property name="label" context="yes" translatable="yes">Hello world!</property> </widget> </child> <child> <widget class="GtkEntry" id="entry1"> <property name="text" context="yes" translatable="yes">Hello World</property> </widget> <packing> <property name="position">1</property> </packing> </child> <child> <widget class="GtkHBox" id="hbox1"> <child> <widget class="HildonColorButton" id="colorbutton1"> <property name="color"><GdkColor at 0x855bc10></property> </widget> </child> <child> <widget class="HildonVVolumebar" id="vvolumebar1"/> <packing> <property name="position">1</property> </packing> </child> <child> <widget class="HildonHVolumebar" id="hvolumebar1"/> <packing> <property name="position">2</property> </packing> </child> </widget> <packing> <property name="position">2</property> </packing> </child> </widget> </child> </widget> </glade-interface>
As you can note, The XML grammar is almost the same as Glade, but the Hildon-specific widgets are in place. You should now run this interface. You need some code to load and display it:
import pygtk pygtk.require('2.0') import gtk import hildon from sys import argv from gazpacho.loader.loader import ObjectBuilder if __name__ == '__main__': app = hildon.Program() wt = ObjectBuilder('helloworld.glade') wt.signal_autoconnect(globals()) # wt contains all windows inside hildontest.glade file. # Let's get the first one wt.toplevels[0].show_all() app.add_window(wt.toplevels[0]) gtk.main()
You must now execute this program, since the regular maemo graphics environment (with af-sb-init.sh started):
[scratchbox: ~] > # In the case you did not stop Gazpacho services ... [scratchbox: ~] > gazenv-init.sh stop [scratchbox: ~] > # now close the Xehpyr 1024x768 window [scratchbox: ~] > DISPLAY=:0 Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac & [scratchbox: ~] > af-sb-init.sh start [scratchbox: ~] > run-standalone.sh python2.4 helloworld.py
Figure 4. helloworld.py loaded, splash screen
Figure 5. helloworld.py, editing the Entry
The small program has no event handling, so you do not quit when you close the window; you need to interrupt with the prompt by Ctrl-C.
References
For more documentation about Gazpacho, go to the official Gazpacho site: http://gazpacho.sicem.biz/
For more documentation on Hildon widgets, as well as Python APIs for Hildon and Libosso, go to: http://www.maemo.org/development/documentation/apis/3-x/.
Improve this page