Legacy Maemo 5 Documentation/Graphical UI Tutorial/Utilities
This article is legacy documentation, and is superseded by Forum Nokia documentation. The Forum Nokia documentation is available as the Hildon 2.2 UI style guide, Fremantle master layout guide and the Hildon 2.2 widget UI specification |
Apart from the widgets, Hildon provides a set of helper functions and objects.
Contents |
[edit] The Program object
Hildon provides an object to represent a whole application, the HildonProgram
object. This object provides several convenience functions that make it easier to develop Hildon applications.
The HildonProgram
provides the programmer with commodities including applying a common menu or toolbar to every HildonWindow
registered with it.
To apply a shared menu and toolbar, register all windows as belonging to the program.
To register or unregister windows, use the following functions:
void hildon_program_add_window (HildonProgram *self, HildonWindow *window); void hildon_program_remove_window (HildonProgram *self, HildonWindow *window);
The following functions take effect over each registered window, providing a convenient way to set up common elements for each registered window in your application.
void hildon_program_set_common_menu (HildonProgram *self, GtkMenu *menu); GtkMenu* hildon_program_get_common_menu (HildonProgram *self); void hildon_program_set_common_app_menu (HildonProgram *self, HildonAppMenu *menu); HildonAppMenu* hildon_program_get_common_app_menu (HildonProgram *self); void hildon_program_set_common_toolbar (HildonProgram *self, GtkToolbar *toolbar); GtkToolbar* hildon_program_get_common_toolbar (HildonProgram *self);
HildonProgram
also allows users to apply program-wide properties. For example, the property "can-hibernate
" that specify whether the program should be set to hibernate by the Task Navigator in a low memory situation or not.
The following convenience functions are provided to set and retrieve the value of the property "can-hibernate
".
void hildon_program_set_can_hibernate (HildonProgram *self, gboolean can_hibernate); gboolean hildon_program_get_can_hibernate (HildonProgram *self);
[edit] Sound utilities
Hildon provides the following function to play a sample. The function receives the sample file name as parameter and the volume level is controlled by the gconf variable /apps/osso/sound/system_alert_volume
void hildon_play_system_sound (const gchar *sample);
[edit] Miscellaneous helper functions
[edit] Text Font and Colors
The following funtions allows you to set a font or color for the text diplayed by a certain widget. The size or color is identified by a logical name which must be defined by the GTK's rc files defined as part of the themes definition.
Because logical names are used to identify the colors and font, they are independent from the theme, meaning that if you change the theme, the widget keeps the same logical font or color set by these functions.
gulong hildon_helper_set_logical_font (GtkWidget *widget, const gchar *logicalfontname); gulong hildon_helper_set_logical_color (GtkWidget *widget, GtkRcFlags rcflags, GtkStateType state, const gchar *logicalcolorname);
These functions keep the set logical font or color by connecting to "style-set
" signal. Use the returned signal identifier to disconnect the signal.
To set a logical color, pass in the GtkRcFlags
and GtkStateType
to indicate which color you want to modify. For example, to modify the foreground color of the widget during normal operations then set rcflags to GTK_RC_BG
and state to GTK_STATE_NORMAL
.
[edit] Finger Events
The following function can be in callbacks that handle button events to check if the given button event is a finger event, meaning that the event was emitted as a result of a push with the finger somewhere on the touchscreen.
gboolean hildon_helper_event_button_is_finger (GdkEventButton *event);
This function is rarely used in application development.
[edit] Thumbable Scrollbars
The function showed bellow enables a thumb scrollbar on a given scrolled window, converting the existing normal scrollbar into a larger, finger-usable scrollbar that works without a stylus.
void hildon_helper_set_thumb_scrollbar (GtkScrolledWindow *win, gboolean thumb);
- This page was last modified on 18 October 2010, at 09:32.
- This page has been accessed 15,183 times.