Editing PyMaemo/HildonDesktop
Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
- | = Python bindings for libhildondesktop = | + | == Python bindings for libhildondesktop == |
- | These bindings allow to create the so called Hildon Home | + | These bindings allow to create the so called Hildon Home applets (or widgets, in Maemo 5). It consists of two binary packages: |
* python-hildondesktop: the actual Python bindings. Can be used to write standalone widgets, or ones that can be added by the user using the "Add widget" option in Maemo 5. | * python-hildondesktop: the actual Python bindings. Can be used to write standalone widgets, or ones that can be added by the user using the "Add widget" option in Maemo 5. | ||
* hildon-desktop-python-loader: this is a Hildon Desktop loader for Python plugins. | * hildon-desktop-python-loader: this is a Hildon Desktop loader for Python plugins. | ||
- | == | + | === API changes for Fremantle === |
- | The libhildondesktop version in | + | The libhildondesktop version in Fremantle contains some API changes that also reflect on the Python bindings. Namely, you should pay attention to the following differences when migrating Home Widgets from older Maemo releases to Fremantle: |
* The base class for Home Widgets is now called "HomePluginItem", instead of the older "HomeItem" name. | * The base class for Home Widgets is now called "HomePluginItem", instead of the older "HomeItem" name. | ||
- | * | + | * The callback function that is called by the load is now called "hd_plugin_get_object", instead of the older "hd_plugin_get_objects". This is so because in fremantle the plugin is can create only one plugin object. |
- | * | + | * Also note that the "hd_plugin_get_object" function should return a single object, instead of a list. |
+ | * The returned object must be instantiated using the gobject.new() function (see the example below). This is necessary because the plugin-id property needs to be set, otherwise the hildon-home process will crash. | ||
- | + | <b>NOTE:</b> this last requirement might change in future, to avoid the mentioned crash. | |
- | + | === Example (Fremantle only) === | |
- | + | ||
- | + | The code below was based on the C example that can be found on the maemo-examples package sources [https://garage.maemo.org/svn/maemoexamples/branches/fremantle-sdk-testing/maemo-examples/hello-world-home.c]. | |
<pre> | <pre> | ||
+ | import gobject | ||
import gtk | import gtk | ||
import hildondesktop | import hildondesktop | ||
+ | |||
+ | class HelloWorldButton(gtk.Button): | ||
+ | def __init__(self, padding): | ||
+ | gtk.Button.__init__(self) | ||
+ | icon_theme = gtk.icon_theme_get_default() | ||
+ | icon = icon_theme.load_icon("hello", 40, 0) | ||
+ | if icon is None: | ||
+ | icon = icon_theme.load_icon("qgn_list_gene_default_app", 40, 0) | ||
+ | icon_image = gtk.Image() | ||
+ | icon_image.set_from_pixbuf(icon) | ||
+ | icon_image.set_padding(padding, padding) | ||
+ | self.add(icon_image) | ||
+ | self.show_all() | ||
class HelloWorldDialog(gtk.Dialog): | class HelloWorldDialog(gtk.Dialog): | ||
Line 39: | Line 53: | ||
class HelloHomePlugin(hildondesktop.HomePluginItem): | class HelloHomePlugin(hildondesktop.HomePluginItem): | ||
+ | __gtype_name__ = 'HelloHomePlugin' | ||
+ | |||
def __init__(self): | def __init__(self): | ||
hildondesktop.HomePluginItem.__init__(self) | hildondesktop.HomePluginItem.__init__(self) | ||
- | button = | + | button = HelloWorldButton(10) |
button.connect("clicked", hello_world_dialog_show) | button.connect("clicked", hello_world_dialog_show) | ||
button.show_all() | button.show_all() | ||
self.add(button) | self.add(button) | ||
- | + | def hd_plugin_get_object(): | |
+ | return gobject.new(HelloHomePlugin, plugin_id="hello_world_home") | ||
- | |||
- | |||
if __name__ == "__main__": | if __name__ == "__main__": | ||
- | + | obj = hd_plugin_get_object() | |
- | + | ||
- | obj = | + | |
obj.show_all() | obj.show_all() | ||
gtk.main() | gtk.main() | ||
Line 60: | Line 73: | ||
=== Testing the example === | === Testing the example === | ||
- | + | Save the example code shown above as <b>/usr/lib/hildon-desktop/hello_world_home.py</b> inside your FREMANTLE_X86 target. Next, save the following text as <b>/usr/share/applications/hildon-home/hello_world_home.desktop</b>: | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | Save the example code shown above as /usr/lib/hildon-desktop/hello_world_home.py inside your FREMANTLE_X86 target. | + | |
- | + | ||
- | Next, save the following text as /usr/share/applications/hildon-home/hello_world_home.desktop: | + | |
<pre> | <pre> | ||
Line 78: | Line 83: | ||
</pre> | </pre> | ||
- | + | Make sure the hildon desktop and hildon-home are running. For that, you can use the following commands: | |
- | Now you need to add the newly installed home widget to the desktop. | + | <pre> |
+ | export DISPLAY=:2 # if you are using scratchbox + Xephyr | ||
+ | af-sb-init.sh start | ||
+ | run-standalone.sh maemo-summoner /usr/bin/hildon-home.launch & | ||
+ | </pre> | ||
+ | |||
+ | Now you need to add the newly installed home widget to the desktop. For that you can either manually add it to the <b>~/.config/hildon-desktop/home.plugins</b> file, or follow these instructions to add it using the Hildon Desktop interface: | ||
# Click anywhere on the Maemo desktop background. | # Click anywhere on the Maemo desktop background. | ||
Line 96: | Line 107: | ||
[[Image:Hello_world_home_python2.png]] | [[Image:Hello_world_home_python2.png]] | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- |
Learn more about Contributing to the wiki.