Editing Legacy Maemo 5 Documentation/Graphical UI Tutorial/Utilities

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:
-
{{Legacy documentation}}
+
= Utilities =
-
 
+
Apart from the widgets, Hildon provides a set of helper functions and objects.  
Apart from the widgets, Hildon provides a set of helper functions and objects.  
== The Program object ==
== The Program object ==
 +
Hildon provides an object to represent a whole application, the HildonProgramObject. This object provides several convenience functions that make it easier to develop Hildon applications.
-
Hildon provides an object to represent a whole application, the <code>HildonProgram</code> 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 to it.
-
The <code>HildonProgram</code> provides the programmer with commodities including applying a common menu or toolbar to every <code>HildonWindow</code> registered with it.
+
In order to apply a shared menu and toolbar, all windows must be registered as belonging to the program.
-
To apply a shared menu and toolbar, register all windows as belonging to the program.
+
To register or unregister windows you should use the following functions:
-
To register or unregister windows, use the following functions:
+
<tt><span><font color="#009900">void</font></span>       <span>'''<span><font color="#000000">hildon_program_add_window</font></span>'''</span>       <span><font color="#990000">(</font></span>HildonProgram <span><font color="#990000"><nowiki>*</nowiki></font></span>self<span><font color="#990000">,</font></span>
-
 
+
                                              HildonWindow <span><font color="#990000"><nowiki>*</nowiki></font></span>window<span><font color="#990000">);</font></span>
-
<source lang="c">
+
<span><font color="#009900">void</font></span>       <span>'''<span><font color="#000000">hildon_program_remove_window</font></span>'''</span>   <span><font color="#990000">(</font></span>HildonProgram <span><font color="#990000"><nowiki>*</nowiki></font></span>self<span><font color="#990000">,</font></span>
-
void        hildon_program_add_window      (HildonProgram *self,
+
                                              HildonWindow <span><font color="#990000"><nowiki>*</nowiki></font></span>window<span><font color="#990000">);</font></span>
-
                                            HildonWindow *window);
+
</tt>
-
void        hildon_program_remove_window    (HildonProgram *self,
+
-
                                            HildonWindow *window);
+
-
</source>
+
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.
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.
-
<source lang="c">
+
<tt><span><font color="#009900">void</font></span>           <span>'''<span><font color="#000000">hildon_program_set_common_menu</font></span>'''</span>       <span><font color="#990000">(</font></span>HildonProgram <span><font color="#990000"><nowiki>*</nowiki></font></span>self<span><font color="#990000">,</font></span>
-
void          hildon_program_set_common_menu        (HildonProgram *self,
+
                                                      GtkMenu <span><font color="#990000"><nowiki>*</nowiki></font></span>menu<span><font color="#990000">);</font></span>
-
                                                      GtkMenu *menu);
+
GtkMenu<span><font color="#990000"><nowiki>*</nowiki></font></span>       <span>'''<span><font color="#000000">hildon_program_get_common_menu</font></span>'''</span>       <span><font color="#990000">(</font></span>HildonProgram <span><font color="#990000"><nowiki>*</nowiki></font></span>self<span><font color="#990000">);</font></span>
-
GtkMenu*      hildon_program_get_common_menu        (HildonProgram *self);
+
<span><font color="#009900">void</font></span>           <span>'''<span><font color="#000000">hildon_program_set_common_app_menu</font></span>'''</span>   <span><font color="#990000">(</font></span>HildonProgram <span><font color="#990000"><nowiki>*</nowiki></font></span>self<span><font color="#990000">,</font></span>
-
void          hildon_program_set_common_app_menu    (HildonProgram *self,
+
                                                      HildonAppMenu <span><font color="#990000"><nowiki>*</nowiki></font></span>menu<span><font color="#990000">);</font></span>
-
                                                      HildonAppMenu *menu);
+
HildonAppMenu<span><font color="#990000"><nowiki>*</nowiki></font></span> <span>'''<span><font color="#000000">hildon_program_get_common_app_menu</font></span>'''</span>   <span><font color="#990000">(</font></span>HildonProgram <span><font color="#990000"><nowiki>*</nowiki></font></span>self<span><font color="#990000">);</font></span>
-
HildonAppMenu* hildon_program_get_common_app_menu    (HildonProgram *self);
+
<span><font color="#009900">void</font></span>           <span>'''<span><font color="#000000">hildon_program_set_common_toolbar</font></span>'''</span>     <span><font color="#990000">(</font></span>HildonProgram <span><font color="#990000"><nowiki>*</nowiki></font></span>self<span><font color="#990000">,</font></span>
-
void          hildon_program_set_common_toolbar    (HildonProgram *self,
+
                                                      GtkToolbar <span><font color="#990000"><nowiki>*</nowiki></font></span>toolbar<span><font color="#990000">);</font></span>
-
                                                      GtkToolbar *toolbar);
+
GtkToolbar<span><font color="#990000"><nowiki>*</nowiki></font></span>   <span>'''<span><font color="#000000">hildon_program_get_common_toolbar</font></span>'''</span>     <span><font color="#990000">(</font></span>HildonProgram <span><font color="#990000"><nowiki>*</nowiki></font></span>self<span><font color="#990000">);</font></span>
-
GtkToolbar*    hildon_program_get_common_toolbar    (HildonProgram *self);
+
</tt>
-
</source>
+
-
<code>HildonProgram</code> also allows users to apply program-wide properties. For example, the property "<code>can-hibernate</code>" that specify whether the program should be set to hibernate by the Task Navigator in a low memory situation or not.
+
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 "<code>can-hibernate</code>".
+
The following convenience functions are provided to set and retrieve the value of the property "can-hibernate".
-
<source lang="c">
+
<tt><span><font color="#009900">void</font></span>       <span>'''<span><font color="#000000">hildon_program_set_can_hibernate</font></span>'''</span>     <span><font color="#990000">(</font></span>HildonProgram <span><font color="#990000"><nowiki>*</nowiki></font></span>self<span><font color="#990000">,</font></span>
-
void        hildon_program_set_can_hibernate      (HildonProgram *self,
+
                                                    gboolean can_hibernate<span><font color="#990000">);</font></span>
-
                                                  gboolean can_hibernate);
+
gboolean    <span>'''<span><font color="#000000">hildon_program_get_can_hibernate</font></span>'''</span>     <span><font color="#990000">(</font></span>HildonProgram <span><font color="#990000"><nowiki>*</nowiki></font></span>self<span><font color="#990000">);</font></span>
-
gboolean    hildon_program_get_can_hibernate      (HildonProgram *self);
+
</tt>
-
</source>
+
==Sound utilities ==
==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
-
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 <code>/apps/osso/sound/system_alert_volume</code>
+
void        hildon_play_system_sound        (const gchar *sample);
-
<source lang="c">
 
-
void        hildon_play_system_sound        (const gchar *sample);
 
-
</source>
 
-
== Miscellaneous helper functions ==
+
==Miscellaneous helper functions ==
===Text Font and Colors===
===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 should be defined by the GTK's rc files defined as part of the themes definition.
-
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 the theme is changed the widget keeps the same logical font or color set by these functions.
-
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.
+
<tt>gulong      <span>'''<span><font color="#000000">hildon_helper_set_logical_font</font></span>'''</span>  <span><font color="#990000">(</font></span>GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>widget<span><font color="#990000">,</font></span>
 +
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>logicalfontname<span><font color="#990000">);</font></span>
 +
gulong      <span>'''<span><font color="#000000">hildon_helper_set_logical_color</font></span>'''</span> <span><font color="#990000">(</font></span>GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>widget<span><font color="#990000">,</font></span>
 +
                                              GtkRcFlags rcflags<span><font color="#990000">,</font></span>
 +
                                              GtkStateType state<span><font color="#990000">,</font></span>
 +
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>logicalcolorname<span><font color="#990000">);</font></span>
 +
</tt>
-
<source lang="c">
+
These functions achieve to keep the set logical font or color by connecting to "style-set" signal. The returned signal identifier can be used to disconnect the signal.
-
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);
+
-
</source>
+
-
These functions keep the set logical font or color by connecting to "<code>style-set</code>" signal. Use the returned signal identifier to disconnect the signal.
+
To set a logical color is necessary to 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.
-
 
+
-
To set a logical color, pass in the <code>GtkRcFlags</code> and <code>GtkStateType</code> 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 <code>GTK_RC_BG</code> and state to <code>GTK_STATE_NORMAL</code>.
+
===Finger Events===
===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.
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.
-
<source lang="c">
+
<tt>gboolean    <span>'''<span><font color="#000000">hildon_helper_event_button_is_finger</font></span>'''</span> <span><font color="#990000">(</font></span>GdkEventButton <span><font color="#990000"><nowiki>*</nowiki></font></span>event<span><font color="#990000">);</font></span>
-
gboolean    hildon_helper_event_button_is_finger (GdkEventButton *event);
+
</tt>
-
</source>
+
-
This function is rarely used in application development.
+
This function is rarely used in applications development.
===Thumbable Scrollbars===
===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.
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.
-
<source lang="c">
+
<tt><span><font color="#009900">void</font></span>       <span>'''<span><font color="#000000">hildon_helper_set_thumb_scrollbar</font></span>'''</span> <span><font color="#990000">(</font></span>GtkScrolledWindow <span><font color="#990000"><nowiki>*</nowiki></font></span>win<span><font color="#990000">,</font></span>
-
void        hildon_helper_set_thumb_scrollbar (GtkScrolledWindow *win,
+
                                                gboolean thumb<span><font color="#990000">);</font></span>
-
                                              gboolean thumb);
+
</tt>
-
</source>
+

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)

Templates used on this page: