Hildon Desktop Widgets by Dimitry Pastushenko

1,348 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,348
On SlideShare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Hildon Desktop Widgets by Dimitry Pastushenko

  1. 1. Hildon Desktop Widgets Dmitry Pastushenko Discover Maemo Santa Clara, CA Dec 09
  2. 2. Agenda •Hildon Desktop Home Widgets •Widget Packaging •Widget Declaration and Definition •Widget API •Hands-on •Summary Discover Maemo Santa Clara, CA Dec 09
  3. 3. Hildon Desktop Widgets 4 Desktops, 3200x424 pixels total space Discover Maemo Santa Clara, CA Dec 09
  4. 4. Example Widget •Calculates random numbers in 0-1000 range every second •Changes color of generated number every 1/3 of a second •Implements settings dialog •Preserves battery life Discover Maemo Santa Clara, CA Dec 09
  5. 5. Widget Debian Package • Shared Library • /usr/lib/hildon-desktop/libwidgetexample.so • Desktop File • /usr/share/applications/hildon-home/widget-example.desktop • Data (Resources) • /usr/share/… Discover Maemo Santa Clara, CA Dec 09
  6. 6. Desktop file (widget-example.desktop) [Desktop Entry] Name=Widget Example Comment=Widget Example Type=default X-Path=libwidgetexample.so X-Multiple-Instances=false Discover Maemo Santa Clara, CA Dec 09
  7. 7. WidgetExample Dependency Discover Maemo Santa Clara, CA Dec 09
  8. 8. GObject Library • Cornerstone of GNOME and is used throughout GTK+, Pango, and most higher-level GNOME libraries • Provides transparent cross-language interoperability • Provides a portable object system Discover Maemo Santa Clara, CA Dec 09
  9. 9. WidgetExample Class Diagram Discover Maemo Santa Clara, CA Dec 09
  10. 10. Widget Declaration, Part 1 typedef struct _WidgetExample WidgetExample; typedef struct _WidgetExampleClass WidgetExampleClass; typedef struct _WidgetExamplePrivate WidgetExamplePrivate; struct _WidgetExample { /* instance */ HDHomePluginItem item; /* superclass instance */ WidgetExamplePrivate *priv; /* private data */ }; struct _WidgetExampleClass { /* class */ HDHomePluginItemClass parent_class; /* superclass */ }; GType widget_example_get_type (void); Discover Maemo Santa Clara, CA Dec 09
  11. 11. Widget Declaration, Part 2 #define TYPE_WIDGET_EXAMPLE (widget_example_get_type ()) #define WIDGET_EXAMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_WIDGET_EXAMPLE, WidgetExample)) #define WIDGET_EXAMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_WIDGET_EXAMPLE, WidgetExampleClass)) #define IS_WIDGET_EXAMPLE(obj) ( G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_WIDGET_EXAMPLE) ) #define IS_WIDGET_EXAMPLE_CLASS(klass) ( G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_WIDGET_EXAMPLE) ) #define WIDGET_EXAMPLE_GET_CLASS(obj) ( G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_WIDGET_EXAMPLE, WidgetExampleClass) ) #define WIDGET_EXAMPLE_GET_PRIVATE(obj) ( G_TYPE_INSTANCE_GET_PRIVATE (obj, TYPE_WIDGET_EXAMPLE, WidgetExamplePrivate) ) Discover Maemo Santa Clara, CA Dec 09
  12. 12. Widget Definition & Mandatory Methods • HD_DEFINE_PLUGIN_MODULE (WidgetExample, widget_example, HD_TYPE_HOME_PLUGIN_ITEM); • static void widget_example_class_init (WidgetExampleClass *class) • Object Initialization – override GObject::dispose, GtkWindow::realize, GtkWindow::expose_event • Register private data • static void widget_example_class_finalize (WidgetExampleClass *class) • Object Destruction • static void widget_example_init (WidgetExample * applet) • Initialize all public and private members of instance to default values • Create UI • Subscribe on signals Discover Maemo Santa Clara, CA Dec 09
  13. 13. Call Flow Discover Maemo Santa Clara, CA Dec 09
  14. 14. Summary • Follow Nokia’s UI guideline • Should provide most crucial features • Use semitransparent background, if applicable • Events should be initiated on release • Never exceed half of desktop space • Preserve battery life • On current display signal • Device inactivity state signal • Applet is a plug-in - don’t forget to yield • Threads are allowed, but drawing should be done from main loop Discover Maemo Santa Clara, CA Dec 09
  15. 15. Q&A Discover Maemo Santa Clara, CA Dec 09

×