Editing Legacy Maemo 5 Documentation/Graphical UI Tutorial/Controls

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.

Warning: This page is 46 kilobytes long; some browsers may have problems editing pages approaching or longer than 32kb. Please consider breaking the page into smaller sections.

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}}
{{Legacy documentation}}
 +
= Controls =
Hildon provides a set of controls specially designed for touchscreens that allows to build simple and easy-to-use interfaces. This chapter explains how to use these widgets.
Hildon provides a set of controls specially designed for touchscreens that allows to build simple and easy-to-use interfaces. This chapter explains how to use these widgets.
== Buttons ==
== Buttons ==
-
 
+
A Hildon application can use several types of buttons. Hildon provides specialized buttons derived from GtkButton which provide additional commodities specific to the Hildon framework. Using GtkButtons and GtkToggleButtons is also recommended.
-
A Hildon application can use several types of buttons. Hildon provides specialized buttons derived from GtkButton which provide additional commodities specific to the Hildon framework. Using <code>GtkButton</code>s and <code>GtkToggleButton</code>s is also recommended.
+
===Hildon Button===
===Hildon Button===
 +
HildonButton is a GtkButton which usually contains two labels, title and value. It can also include an image.
-
<code>HildonButton</code> is a <code>GtkButton</code> which usually contains two labels: <code>title</code> and <code>value</code>. It can also include an image.
+
To create a HildonButton, use the following functions:
-
 
+
-
To create a <code>HildonButton</code>, use the following functions:
+
-
<source lang="c">
+
<tt>GtkWidget<span><font color="#990000"><nowiki>*</nowiki></font></span> <span>'''<span><font color="#000000">hildon_button_new</font></span>'''</span>               <span><font color="#990000">(</font></span>HildonSizeType size<span><font color="#990000">,</font></span>
-
GtkWidget*  hildon_button_new              (HildonSizeType size,
+
                                              HildonButtonArrangement arrangement<span><font color="#990000">);</font></span>
-
                                            HildonButtonArrangement arrangement);
+
GtkWidget<span><font color="#990000"><nowiki>*</nowiki></font></span> <span>'''<span><font color="#000000">hildon_button_new_with_text</font></span>'''</span>     <span><font color="#990000">(</font></span>HildonSizeType size<span><font color="#990000">,</font></span>
-
GtkWidget*  hildon_button_new_with_text    (HildonSizeType size,
+
                                              HildonButtonArrangement arrangement<span><font color="#990000">,</font></span>
-
                                            HildonButtonArrangement arrangement,
+
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>title<span><font color="#990000">,</font></span>
-
                                            const gchar *title,
+
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>value<span><font color="#990000">)</font></span>
-
                                            const gchar *value);
+
</tt>
-
</source>
+
-
Note that in the creation of a <code>HildonButton</code> you must indicate the value for the properties "<code>size</code>" and "<code>arrangement</code>", choosing a [[Legacy Maemo 5 Documentation/Graphical UI Tutorial/Additions to GTK+#Hildon size types|Hildon size]] and a horizontal or vertical arrangement of the labels.
+
Note that in the creation of a HildonButton you must indicate the value for the properties "size" and "arrangement", choosing a Hildon size and a horizontal or vertical arrangement of the labels.
You can set and retrieve both labels by using the following convenience functions:
You can set and retrieve both labels by using the following convenience functions:
-
<source lang="c">
+
<tt><span><font color="#009900">void</font></span>       <span>'''<span><font color="#000000">hildon_button_set_title</font></span>'''</span>         <span><font color="#990000">(</font></span>HildonButton <span><font color="#990000"><nowiki>*</nowiki></font></span>button<span><font color="#990000">,</font></span>
-
void        hildon_button_set_title        (HildonButton *button,
+
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>title<span><font color="#990000">);</font></span>
-
                                            const gchar *title);
+
<span><font color="#009900">void</font></span>       <span>'''<span><font color="#000000">hildon_button_set_value</font></span>'''</span>         <span><font color="#990000">(</font></span>HildonButton <span><font color="#990000"><nowiki>*</nowiki></font></span>button<span><font color="#990000">,</font></span>
-
void        hildon_button_set_value        (HildonButton *button,
+
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>value<span><font color="#990000">);</font></span>
-
                                            const gchar *value);
+
<span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar<span><font color="#990000"><nowiki>*</nowiki></font></span> <span>'''<span><font color="#000000">hildon_button_get_title</font></span>'''</span>       <span><font color="#990000">(</font></span>HildonButton <span><font color="#990000"><nowiki>*</nowiki></font></span>button<span><font color="#990000">);</font></span>
-
const gchar* hildon_button_get_title        (HildonButton *button);
+
<span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar<span><font color="#990000"><nowiki>*</nowiki></font></span> <span>'''<span><font color="#000000">hildon_button_get_value</font></span>'''</span>       <span><font color="#990000">(</font></span>HildonButton <span><font color="#990000"><nowiki>*</nowiki></font></span>button<span><font color="#990000">);</font></span>
-
const gchar* hildon_button_get_value        (HildonButton *button);
+
</tt>
-
</source>
+
-
Alternatively, use the following function to set both labels of a <code>HildonButton</code>:
+
Alternatively, use the following function to set both labels of a HildonButton:
-
<source lang="c">
+
<tt><span><font color="#009900">void</font></span>       <span>'''<span><font color="#000000">hildon_button_set_text</font></span>'''</span>         <span><font color="#990000">(</font></span>HildonButton <span><font color="#990000"><nowiki>*</nowiki></font></span>button<span><font color="#990000">,</font></span>
-
void        hildon_button_set_text          (HildonButton *button,
+
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>title<span><font color="#990000">,</font></span>
-
                                            const gchar *title,
+
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>value<span><font color="#990000">);</font></span>
-
                                            const gchar *value);
+
</tt>
-
</source>
+
-
To add images to <code>HildonButton</code>s, use the following functions to set and retrieve the current image: <code>hildon_button_set_image()</code> and <code>hildon_button_get_image()</code>.
+
To add images to HildonButtons, use the following functions to set and retrieve the current image: <code>hildon_button_set_image()</code> and <code>hildon_button_get_image()</code>.
You can also set the position of the image.
You can also set the position of the image.
-
<source lang="c">
+
<tt><span><font color="#009900">void</font></span>       <span>'''<span><font color="#000000">hildon_button_set_image_position</font></span>'''</span> <span><font color="#990000">(</font></span>HildonButton <span><font color="#990000"><nowiki>*</nowiki></font></span>button<span><font color="#990000">,</font></span>
-
void        hildon_button_set_image_position (HildonButton *button,
+
                                              GtkPositionType position<span><font color="#990000">);</font></span>
-
                                              GtkPositionType position);
+
</tt>
-
</source>
+
-
Currently supported positions are <code>GTK_POS_LEFT</code> or <code>GTK_POS_RIGHT</code>.
+
Currently supported positions are GTK_POS_LEFT or GTK_POS_RIGHT.
-
The visual style (color, fonts, etc.) of a <code>HildonButton</code> can be changed by using the function <code>hildon_button_set_style()</code>. Use <code>HILDON_BUTTON_STYLE_NORMAL</code> to make it look like a normal <code>HildonButton</code>, or <code>HILDON_BUTTON_STYLE_PICKER</code> to make it look like a <code>HildonPickerButton</code>.
+
The visual style (color, fonts, etc) of a HildonButton can be changed by using the function <code>hildon_button_set_style()</code>. Use HILDON_BUTTON_STYLE_NORMAL to make it look like a normal HildonButton, or HILDON_BUTTON_STYLE_PICKER to make it look like a HildonPickerButton.
-
The next simple example shows how to create a <code>HildonButton</code>, set the label text and add an image.
+
The next simple example shows how to create a HildonButton, set the label text and add an image.
'''Example 7.1. Example of a Hildon button with a label and an image'''
'''Example 7.1. Example of a Hildon button with a label and an image'''
-
<source lang="c">
+
<tt>GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>
-
GtkWidget *
+
<span>'''<span><font color="#000000">create_button</font></span>'''</span> <span><font color="#990000">(</font></span><span><font color="#009900">void</font></span><span><font color="#990000">)</font></span>
-
create_button (void)
+
<span><font color="#FF0000">{</font></span>
-
{
+
    GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>button<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
    GtkWidget *button;
+
    GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>image<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
    GtkWidget *image;
+
    <span>''<span><font color="#9A1900">/* Create a hildon button */</font></span>''</span>
-
    /* Create a hildon button */
+
    button <span><font color="#990000"><nowiki>=</nowiki></font></span> <span>'''<span><font color="#000000">hildon_button_new</font></span>'''</span> <span><font color="#990000">(</font></span>HILDON_SIZE_AUTO_WIDTH <span><font color="#990000"><nowiki>|</nowiki></font></span> HILDON_SIZE_FINGER_HEIGHT<span><font color="#990000">,</font></span>
-
    button = hildon_button_new (HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT,
+
                                HILDON_BUTTON_ARRANGEMENT_VERTICAL<span><font color="#990000">);</font></span>
-
                                HILDON_BUTTON_ARRANGEMENT_VERTICAL);
+
    <span>''<span><font color="#9A1900">/* Set labels value */</font></span>''</span>
-
    /* Set labels value */
+
    <span>'''<span><font color="#000000">hildon_button_set_text</font></span>'''</span> <span><font color="#990000">(</font></span><span>'''<span><font color="#000000">HILDON_BUTTON</font></span>'''</span> <span><font color="#990000">(</font></span>button<span><font color="#990000">),</font></span> <span><font color="#FF0000">"Some title"</font></span><span><font color="#990000">,</font></span> <span><font color="#FF0000">"Some value"</font></span><span><font color="#990000">);</font></span>
-
    hildon_button_set_text (HILDON_BUTTON (button), "Some title", "Some value");
+
    <span>''<span><font color="#9A1900">/* Set image */</font></span>''</span>
-
    /* Set image */
+
    image <span><font color="#990000"><nowiki>=</nowiki></font></span> <span>'''<span><font color="#000000">gtk_image_new_from_stock</font></span>'''</span> <span><font color="#990000">(</font></span>GTK_STOCK_INFO<span><font color="#990000">,</font></span> GTK_ICON_SIZE_BUTTON<span><font color="#990000">);</font></span>
-
    image = gtk_image_new_from_stock (GTK_STOCK_INFO, GTK_ICON_SIZE_BUTTON);
+
    <span>'''<span><font color="#000000">hildon_button_set_image</font></span>'''</span> <span><font color="#990000">(</font></span><span>'''<span><font color="#000000">HILDON_BUTTON</font></span>'''</span> <span><font color="#990000">(</font></span>button<span><font color="#990000">),</font></span> image<span><font color="#990000">);</font></span>
-
    hildon_button_set_image (HILDON_BUTTON (button), image);
+
    <span>'''<span><font color="#000000">hildon_button_set_image_position</font></span>'''</span> <span><font color="#990000">(</font></span><span>'''<span><font color="#000000">HILDON_BUTTON</font></span>'''</span> <span><font color="#990000">(</font></span>button<span><font color="#990000">),</font></span> GTK_POS_RIGHT<span><font color="#990000">);</font></span>
-
    hildon_button_set_image_position (HILDON_BUTTON (button), GTK_POS_RIGHT);
+
    <span>'''<span><font color="#0000FF">return</font></span>'''</span> button<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
    return button;
+
<span><font color="#FF0000">}</font></span>
-
}
+
</tt>
-
</source>
+
===Hildon Check Button===
===Hildon Check Button===
 +
HildonCheckButton is a button that contains a label and a check box. The check box toggles between checked or unchecked.
-
<code>HildonCheckButton</code> is a button that contains a label and a check box. The check box toggles between checked or unchecked.
+
To create a HildonCheckButton:
-
To create a <code>HildonCheckButton</code>:
+
<tt> GtkWidget<span><font color="#990000"><nowiki>*</nowiki></font></span> <span>'''<span><font color="#000000">hildon_check_button_new</font></span>'''</span>         <span><font color="#990000">(</font></span>HildonSizeType size<span><font color="#990000">);</font></span>
-
 
+
</tt>
-
<source lang="c">
+
-
GtkWidget*  hildon_check_button_new        (HildonSizeType size);
+
-
</source>
+
Note that, again, you must specify the size of the button.
Note that, again, you must specify the size of the button.
Line 94: Line 86:
You can retrieve or set the current state of the button with the following functions, respectively:
You can retrieve or set the current state of the button with the following functions, respectively:
-
<source lang="c">
+
<tt>gboolean    <span>'''<span><font color="#000000">hildon_check_button_get_active</font></span>'''</span> <span><font color="#990000">(</font></span>HildonCheckButton <span><font color="#990000"><nowiki>*</nowiki></font></span>button<span><font color="#990000">);</font></span>
-
gboolean    hildon_check_button_get_active  (HildonCheckButton *button);
+
<span><font color="#009900">void</font></span>       <span>'''<span><font color="#000000">hildon_check_button_set_active</font></span>'''</span> <span><font color="#990000">(</font></span>HildonCheckButton <span><font color="#990000"><nowiki>*</nowiki></font></span>button<span><font color="#990000">,</font></span>
-
void        hildon_check_button_set_active  (HildonCheckButton *button,
+
                                              gboolean is_active<span><font color="#990000">);</font></span>
-
                                            gboolean is_active);
+
</tt>
-
</source>
+
-
The signal "<code>toggled</code>" is emitted when the state of the button changes. A handler can be attached to this signal if a further action is required.
+
The signal "toggled" is emitted when the state of the button changes. A handler can be attached to this signal if a further action is required.
-
Here is a simple example which creates a check button and a simple callback to handle the signal "<code>toggled</code>".
+
Here is a simple example which creates a check button and a simple callback to handle the signal "toggled".
'''Example 7.2. Example of a Hildon check button'''
'''Example 7.2. Example of a Hildon check button'''
-
<source lang="c">
+
<tt><span><font color="#009900">void</font></span>
-
void
+
<span>'''<span><font color="#000000">button_toggled</font></span>'''</span> <span><font color="#990000">(</font></span>HildonCheckButton <span><font color="#990000"><nowiki>*</nowiki></font></span>button<span><font color="#990000">,</font></span> gpointer user_data<span><font color="#990000">)</font></span>
-
button_toggled (HildonCheckButton *button, gpointer user_data)
+
<span><font color="#FF0000">{</font></span>
-
{
+
    gboolean active<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
    gboolean active;
+
    active <span><font color="#990000"><nowiki>=</nowiki></font></span> <span>'''<span><font color="#000000">hildon_check_button_get_active</font></span>'''</span> <span><font color="#990000">(</font></span>button<span><font color="#990000">);</font></span>
-
    active = hildon_check_button_get_active (button);
+
    <span>'''<span><font color="#0000FF">if</font></span>'''</span> <span><font color="#990000">(</font></span>active<span><font color="#990000">)</font></span>
-
    if (active)
+
        <span>'''<span><font color="#000000">g_debug</font></span>'''</span> <span><font color="#990000">(</font></span><span><font color="#FF0000">"Button is active"</font></span><span><font color="#990000">);</font></span>
-
      g_debug ("Button is active");
+
    <span>'''<span><font color="#0000FF">else</font></span>'''</span>
-
    else
+
        <span>'''<span><font color="#000000">g_debug</font></span>'''</span> <span><font color="#990000">(</font></span><span><font color="#FF0000">"Button is not active"</font></span><span><font color="#990000">);</font></span>
-
      g_debug ("Button is not active");
+
<span><font color="#FF0000">}</font></span>
-
}
+
GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>
-
GtkWidget *
+
<span>'''<span><font color="#000000">create_button</font></span>'''</span> <span><font color="#990000">(</font></span><span><font color="#009900">void</font></span><span><font color="#990000">)</font></span>
-
create_button (void)
+
<span><font color="#FF0000">{</font></span>
-
{
+
    GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>button<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
    GtkWidget *button;
+
    button <span><font color="#990000"><nowiki>=</nowiki></font></span> <span>'''<span><font color="#000000">hildon_check_button_new</font></span>'''</span> <span><font color="#990000">(</font></span>HILDON_SIZE_AUTO<span><font color="#990000">);</font></span>
-
    button = hildon_check_button_new (HILDON_SIZE_AUTO);
+
    <span>'''<span><font color="#000000">gtk_button_set_label</font></span>'''</span> <span><font color="#990000">(</font></span><span>'''<span><font color="#000000">GTK_BUTTON</font></span>'''</span> <span><font color="#990000">(</font></span>button<span><font color="#990000">),</font></span> <span><font color="#FF0000">"Click me"</font></span><span><font color="#990000">);</font></span>
-
    gtk_button_set_label (GTK_BUTTON (button), "Click me");
+
    <span>'''<span><font color="#000000">g_signal_connect</font></span>'''</span> <span><font color="#990000">(</font></span>button<span><font color="#990000">,</font></span> <span><font color="#FF0000">"toggled"</font></span><span><font color="#990000">,</font></span> <span>'''<span><font color="#000000">G_CALLBACK</font></span>'''</span> <span><font color="#990000">(</font></span>button_toggled<span><font color="#990000">),</font></span> NULL<span><font color="#990000">);</font></span>
-
    g_signal_connect (button, "toggled", G_CALLBACK (button_toggled), NULL);
+
    <span>'''<span><font color="#0000FF">return</font></span>'''</span> button<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
    return button;
+
<span><font color="#FF0000">}</font></span>
-
}
+
</tt>
-
</source>
+
 
==Using Gtk Buttons and Toggles==
==Using Gtk Buttons and Toggles==
-
 
+
As was said above, apart from Hildon specific buttons, use GtkButton and GtkToggleButton also in the Hildon framework.
-
As was said above, apart from Hildon specific buttons, use <code>GtkButton</code> and <code>GtkToggleButton</code> also in the Hildon framework.
+
===GtkButton===
===GtkButton===
 +
If only a label is needed, you do not need to use HildonButtons and a GtkButton can be used instead. You can use it as you would do in a GTK application. The only change is the creation function that you must use:
-
If only a label is needed, you do not need to use <code>HildonButton</code>s and a <code>GtkButton</code> can be used instead. You can use it as you would do in a GTK+ application. The only change is the creation function that you must use:
+
<tt>GtkWidget<span><font color="#990000"><nowiki>*</nowiki></font></span>  <span>'''<span><font color="#000000">hildon_gtk_button_new</font></span>'''</span>           <span><font color="#990000">(</font></span>HildonSizeType size<span><font color="#990000">);</font></span>
-
 
+
</tt>
-
<source lang="c">
+
-
GtkWidget*  hildon_gtk_button_new          (HildonSizeType size);
+
-
</source>
+
This alternative constructor allows you to set a Hildon size for the newly create function.
This alternative constructor allows you to set a Hildon size for the newly create function.
===GtkToggleButton===
===GtkToggleButton===
 +
To create a GtkToggleButton in a Hildon application you should use:
-
To create a <code>GtkToggleButton</code> in a Hildon application you should use:
+
<tt>GtkWidget<span><font color="#990000"><nowiki>*</nowiki></font></span> <span>'''<span><font color="#000000">hildon_gtk_toggle_button_new</font></span>'''</span>   <span><font color="#990000">(</font></span>HildonSizeType size<span><font color="#990000">);</font></span>
-
 
+
</tt>
-
<source lang="c">
+
-
GtkWidget*  hildon_gtk_toggle_button_new    (HildonSizeType size);
+
-
</source>
+
==GtkRadioButton==
==GtkRadioButton==
 +
To create a GtkRadioButton in a Hildon application, use:
-
To create a <code>GtkRadioButton</code> in a Hildon application, use:
+
<tt>GtkWidget<span><font color="#990000"><nowiki>*</nowiki></font></span> <span>'''<span><font color="#000000">hildon_gtk_radio_button_new</font></span>'''</span>     <span><font color="#990000">(</font></span>HildonSizeType size<span><font color="#990000">,</font></span>
-
 
+
                                              GSList <span><font color="#990000"><nowiki>*</nowiki></font></span>group<span><font color="#990000">);</font></span>
-
<source lang="c">
+
</tt>
-
GtkWidget*  hildon_gtk_radio_button_new    (HildonSizeType size,
+
-
                                            GSList *group);
+
-
</source>
+
The most common use case of this type of buttons in a Hildon application is as filters in a application menu. For more information, see section Touch View Menu.
The most common use case of this type of buttons in a Hildon application is as filters in a application menu. For more information, see section Touch View Menu.
==Text display and handling ==
==Text display and handling ==
-
 
+
Text entry fields are used for entering one or more lines of plain text. Use a HildonEntry for a single-line text input or HildonTextView if you need a multi-line text input.
-
Text entry fields are used for entering one or more lines of plain text. Use a <code>HildonEntry</code> for a single-line text input or <code>HildonTextView</code> if you need a multi-line text input.
+
===Hildon Text Entry===
===Hildon Text Entry===
-
 
+
The HildonEntry is a GTK+ widget which represents a text entry. It is derived from the GtkEntry widget and provides additional commodities specific to the Hildon framework.
-
The <code>HildonEntry</code> is a GTK+ widget which represents a text entry. It is derived from the <code>GtkEntry</code> widget and provides additional commodities specific to the Hildon framework.
+
The main additional feature is a placeholder text to display if the entry is empty and not in focus.
The main additional feature is a placeholder text to display if the entry is empty and not in focus.
-
Creating a new <code>HildonEntry</code>:
+
Creating a new HildonEntry:
-
<source lang="c">
+
<tt>GtkWidget<span><font color="#990000"><nowiki>*</nowiki></font></span> <span>'''<span><font color="#000000">hildon_entry_new</font></span>'''</span>               <span><font color="#990000">(</font></span>HildonSizeType size<span><font color="#990000">);</font></span>
-
GtkWidget*  hildon_entry_new                (HildonSizeType size);
+
</tt>
-
</source>
+
-
Note that the creation function needs to specify a size from <code>HildonSizeType</code>.
+
Note that the creation function needs to specify a size from HildonSizeType.
The placeholder is stored as a property. To set it, use the following convenience function:
The placeholder is stored as a property. To set it, use the following convenience function:
-
<source lang="c">
+
<tt><span><font color="#009900">void</font></span>       <span>'''<span><font color="#000000">hildon_entry_set_placeholder</font></span>'''</span>   <span><font color="#990000">(</font></span>HildonEntry <span><font color="#990000"><nowiki>*</nowiki></font></span>entry<span><font color="#990000">,</font></span>
-
void        hildon_entry_set_placeholder    (HildonEntry *entry,
+
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>text<span><font color="#990000">);</font></span>
-
                                            const gchar *text);
+
</tt>
-
</source>
+
Here's a very simple example showing how to create a HindonEntry.
Here's a very simple example showing how to create a HindonEntry.
Line 190: Line 170:
'''Example 7.3. Example of a Hildon entry'''
'''Example 7.3. Example of a Hildon entry'''
-
<source lang="c">
+
<tt>GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>
-
GtkWidget *
+
<span>'''<span><font color="#000000">create_entry</font></span>'''</span> <span><font color="#990000">(</font></span><span><font color="#009900">void</font></span><span><font color="#990000">)</font></span>
-
create_entry (void)
+
<span><font color="#FF0000">{</font></span>
-
{
+
    GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>entry<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
    GtkWidget *entry;
+
    entry <span><font color="#990000"><nowiki>=</nowiki></font></span> <span>'''<span><font color="#000000">hildon_entry_new</font></span>'''</span> <span><font color="#990000">(</font></span>HILDON_SIZE_AUTO<span><font color="#990000">);</font></span>
-
    entry = hildon_entry_new (HILDON_SIZE_AUTO);
+
    <span>'''<span><font color="#000000">hildon_entry_set_placeholder</font></span>'''</span> <span><font color="#990000">(</font></span><span>'''<span><font color="#000000">HILDON_ENTRY</font></span>'''</span> <span><font color="#990000">(</font></span>entry<span><font color="#990000">),</font></span>
-
    hildon_entry_set_placeholder (HILDON_ENTRY (entry),
+
                          <span><font color="#FF0000">"First name"</font></span><span><font color="#990000">);</font></span>
-
                          "First name");
+
    <span>'''<span><font color="#0000FF">return</font></span>'''</span> entry<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
    return entry;
+
<span><font color="#FF0000">}</font></span>
-
}
+
</tt>
-
</source>
+
===Hildon Text Area===
===Hildon Text Area===
-
The <code>HildonTextView</code> is a GTK+ widget which represents a text area in Hildon applications. It is derived from the <code>GtkTextView</code> widget and provides additional commodities specific to the Hildon framework.
+
The HildonTextView is a GTK+ widget which represents a text area in Hildon applications. It is derived from the GtkTextView widget and provides additional commodities specific to the Hildon framework.
-
Create a <code>HildonTextView</code>:
+
Create a HildonTextView:
-
<source lang="c">
+
<tt>GtkWidget<span><font color="#990000"><nowiki>*</nowiki></font></span> <span>'''<span><font color="#000000">hildon_text_view_new</font></span>'''</span>           <span><font color="#990000">(</font></span><span><font color="#009900">void</font></span><span><font color="#990000">);</font></span>
-
GtkWidget*  hildon_text_view_new            (void);
+
</tt>
-
</source>
+
-
Like for the <code>HildonTextEntry</code> presented above, you can store a placeholder as well using the function.
+
Like for the HildonTextEntry presented above, you can store a placeholder as well using the function.
-
<source lang="c">
+
<tt><span><font color="#009900">void</font></span>       <span>'''<span><font color="#000000">hildon_text_view_set_placeholder</font></span>'''</span>   <span><font color="#990000">(</font></span>HildonTextView <span><font color="#990000"><nowiki>*</nowiki></font></span>text_view<span><font color="#990000">,</font></span>
-
void        hildon_text_view_set_placeholder    (HildonTextView *text_view,
+
                                                  <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>text<span><font color="#990000">);</font></span>
-
                                                const gchar *text);
+
</tt>
-
</source>
+
-
The text that is being edited with a <code>HildonTextView</code> is represented by a object <code>GtkTextBuffer</code>. The following functions can be used to set and retrieve the buffer associated with a <code>HildonTextView</code>.
+
The text that is being edited with a HildonTextView is represented by a object GtkTextBuffer. The following functions can be used to set and retrieve the buffer associated with a HildonTextView.
-
<source lang="c">
+
<tt><span><font color="#009900">void</font></span>       <span>'''<span><font color="#000000">hildon_text_view_set_buffer</font></span>'''</span>         <span><font color="#990000">(</font></span>HildonTextView <span><font color="#990000"><nowiki>*</nowiki></font></span>text_view<span><font color="#990000">,</font></span>
-
void        hildon_text_view_set_buffer        (HildonTextView *text_view,
+
                                                  GtkTextBuffer <span><font color="#990000"><nowiki>*</nowiki></font></span>buffer<span><font color="#990000">);</font></span>
-
                                                GtkTextBuffer *buffer);
+
GtkTextBuffer<span><font color="#990000"><nowiki>*</nowiki></font></span> <span>'''<span><font color="#000000">hildon_text_view_get_buffer</font></span>'''</span>     <span><font color="#990000">(</font></span>HildonTextView <span><font color="#990000"><nowiki>*</nowiki></font></span>text_view<span><font color="#990000">);</font></span>
-
GtkTextBuffer* hildon_text_view_get_buffer      (HildonTextView *text_view);
+
</tt>
-
</source>
+
-
Here is an example that shows how to create a <code>HildonTextView</code> and how to set its placeholder. Also, the buffer is retrieved and a function is set as a handler to the "changed" of the buffer. The handler simply gets the text from the <code>HildonTextView</code>'s buffer and prints it.
+
Here is an example that shows how to create a HildonTextView and how to set its placeholder. Also, the buffer is retrieved and a function is set as a handler to the "changed" of the buffer. The handler simply gets the text from the HildonTextView's buffer and prints it.
'''Example 7.4. Example of a Hildon text view with a placeholder'''
'''Example 7.4. Example of a Hildon text view with a placeholder'''
-
<source lang="c">
+
<tt><span>'''<span><font color="#0000FF">static</font></span>'''</span> <span><font color="#009900">void</font></span>
-
static void
+
<span>'''<span><font color="#000000">text_changed</font></span>'''</span> <span><font color="#990000">(</font></span>GtkTextBuffer <span><font color="#990000"><nowiki>*</nowiki></font></span>buffer<span><font color="#990000">,</font></span>
-
text_changed (GtkTextBuffer *buffer,  
+
              gpointer <span><font color="#990000"><nowiki>*</nowiki></font></span>user_data<span><font color="#990000">)</font></span>
-
              gpointer *user_data)
+
<span><font color="#FF0000">{</font></span>
-
{
+
    gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>text<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
    gchar *text;
+
    GtkTextIter start<span><font color="#990000">,</font></span> end<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
    GtkTextIter start, end;
+
    <span>'''<span><font color="#000000">gtk_text_buffer_get_start_iter</font></span>'''</span> <span><font color="#990000">(</font></span>buffer<span><font color="#990000">,</font></span> <span><font color="#990000">&amp;</font></span>start<span><font color="#990000">);</font></span>
-
    gtk_text_buffer_get_start_iter (buffer, &start);
+
    <span>'''<span><font color="#000000">gtk_text_buffer_get_end_iter</font></span>'''</span> <span><font color="#990000">(</font></span>buffer<span><font color="#990000">,</font></span> <span><font color="#990000">&amp;</font></span>end<span><font color="#990000">);</font></span>
-
    gtk_text_buffer_get_end_iter (buffer, &end);
+
    text <span><font color="#990000"><nowiki>=</nowiki></font></span> <span>'''<span><font color="#000000">gtk_text_buffer_get_text</font></span>'''</span> <span><font color="#990000">(</font></span>buffer<span><font color="#990000">,</font></span> <span><font color="#990000">&amp;</font></span>start<span><font color="#990000">,</font></span> <span><font color="#990000">&amp;</font></span>end<span><font color="#990000">,</font></span> FALSE<span><font color="#990000">);</font></span>
-
    text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+
    <span>'''<span><font color="#000000">g_debug</font></span>'''</span> <span><font color="#990000">(</font></span>text<span><font color="#990000">);</font></span>
-
    g_debug (text);
+
<span><font color="#FF0000">}</font></span>
-
}
+
GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>
-
GtkWidget *
+
<span>'''<span><font color="#000000">create_text_view</font></span>'''</span> <span><font color="#990000">(</font></span><span><font color="#009900">void</font></span><span><font color="#990000">)</font></span>
-
create_text_view (void)
+
<span><font color="#FF0000">{</font></span>
-
{
+
    GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>text_view<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
    GtkWidget *text_view;
+
    GtkTextBuffer <span><font color="#990000"><nowiki>*</nowiki></font></span>buffer<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
    GtkTextBuffer *buffer;
+
    text_view <span><font color="#990000"><nowiki>=</nowiki></font></span> <span>'''<span><font color="#000000">hildon_text_view_new</font></span>'''</span><span><font color="#990000">();</font></span>
-
    text_view = hildon_text_view_new();
+
    <span>'''<span><font color="#000000">hildon_text_view_set_placeholder</font></span>'''</span> <span><font color="#990000">(</font></span><span>'''<span><font color="#000000">HILDON_TEXT_VIEW</font></span>'''</span> <span><font color="#990000">(</font></span>text_view<span><font color="#990000">),</font></span>
-
    hildon_text_view_set_placeholder (HILDON_TEXT_VIEW (text_view),
+
                                      <span><font color="#FF0000">"Type some text here"</font></span><span><font color="#990000">);</font></span>
-
                                      "Type some text here");
+
    buffer <span><font color="#990000"><nowiki>=</nowiki></font></span> <span>'''<span><font color="#000000">hildon_text_view_get_buffer</font></span>'''</span><span><font color="#990000">(</font></span><span>'''<span><font color="#000000">HILDON_TEXT_VIEW</font></span>'''</span><span><font color="#990000">(</font></span>text_view<span><font color="#990000">));</font></span>
-
    buffer = hildon_text_view_get_buffer(HILDON_TEXT_VIEW(text_view));
+
    <span>'''<span><font color="#000000">g_signal_connect</font></span>'''</span> <span><font color="#990000">(</font></span>buffer<span><font color="#990000">,</font></span>
-
    g_signal_connect (buffer,
+
                      <span><font color="#FF0000">"changed"</font></span><span><font color="#990000">,</font></span>
-
                      "changed",
+
                      <span>'''<span><font color="#000000">G_CALLBACK</font></span>'''</span> <span><font color="#990000">(</font></span>text_changed<span><font color="#990000">),</font></span>
-
                      G_CALLBACK (text_changed),
+
                      NULL<span><font color="#990000">);</font></span>
-
                      NULL);
+
    <span>'''<span><font color="#0000FF">return</font></span>'''</span> text_view<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
    return text_view;
+
<span><font color="#FF0000">}</font></span>
-
}
+
</tt>
-
</source>
+
===Warning===
===Warning===
-
Although <code>HildonTextView</code> is derived from <code>GtkTextView</code>, <code>gtk_text_view_get_buffer()</code> and<code> gtk_text_view_set_buffer()</code> must never be used to get/set the buffer in this widget, <code>hildon_text_view_get_buffer()</code> and <code>hildon_text_view_set_buffer()</code> must be used instead.
+
Although HildonTextView is derived from GtkTextView, <code>gtk_text_view_get_buffer()</code> and<code> gtk_text_view_set_buffer()</code> must never be used to get/set the buffer in this widget, <code>hildon_text_view_get_buffer()</code> and <code>hildon_text_view_set_buffer()</code> must be used instead.
 +
 
==Notification widgets ==
==Notification widgets ==
-
 
+
To cover the main use cases regarding notification of users, Hildon provides banners and notes. Banner widgets display a text information during a certain period of time. Notes are specialized GtkDialogs that need a small amount of input from the user.
-
To cover the main use cases regarding notification of users, Hildon provides banners and notes. Banner widgets display a text information during a certain period of time. Notes are specialized <code>GtkDialog</code>s that need a small amount of input from the user.
+
===Banners===
===Banners===
-
 
+
A HildonBanner is useful to display information which does not need any user response. This widget automatically disappears after a certain time period.
-
A <code>HildonBanner</code> is useful to display information which does not need any user response. This widget automatically disappears after a certain time period.
+
To create and show a banner, use the following function:
To create and show a banner, use the following function:
-
<source lang="c">
+
<tt>GtkWidget<span><font color="#990000"><nowiki>*</nowiki></font></span> <span>'''<span><font color="#000000">hildon_banner_show_information</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>
-
GtkWidget*  hildon_banner_show_information  (GtkWidget *widget,
+
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>icon_name<span><font color="#990000">,</font></span>
-
                                            const gchar *icon_name,
+
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>text<span><font color="#990000">);</font></span>
-
                                            const gchar *text);
+
GtkWidget<span><font color="#990000"><nowiki>*</nowiki></font></span> <span>'''<span><font color="#000000">hildon_banner_show_informationf</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>
-
GtkWidget*  hildon_banner_show_informationf (GtkWidget *widget,
+
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>icon_name<span><font color="#990000">,</font></span>
-
                                            const gchar *icon_name,
+
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>format<span><font color="#990000">,</font></span>
-
                                            const gchar *format,
+
                                              <span><font color="#990000">...);</font></span>
-
                                            ...);
+
GtkWidget<span><font color="#990000"><nowiki>*</nowiki></font></span> hildon_banner_show_information_with_markup
-
GtkWidget*  hildon_banner_show_information_with_markup
+
                                            <span><font color="#990000">(</font></span>GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>widget<span><font color="#990000">,</font></span>
-
                                            (GtkWidget *widget,
+
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>icon_name<span><font color="#990000">,</font></span>
-
                                            const gchar *icon_name,
+
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>markup<span><font color="#990000">);</font></span>
-
                                            const gchar *markup);
+
</tt>
-
</source>
+
All functions above require a widget as an argument that must be a pointer to the owner widget of the banner. Usually, the owner is the window that represents the currently displayed view.
All functions above require a widget as an argument that must be a pointer to the owner widget of the banner. Usually, the owner is the window that represents the currently displayed view.
Line 297: Line 270:
===Warning===
===Warning===
 +
Currently, icons are not displayed in banners, so any value that you pass as the icon_name is ignored.
-
Currently, icons are not displayed in banners, so any value that you pass as the <code>icon_name</code> is ignored.
+
The period of time after the banner automatically disappear is stored in the property "timeout" (in miliseconds). A convenience function to set this property is provided:
-
The period of time after the banner automatically disappear is stored in the property "<code>timeout</code>" (in miliseconds). A convenience function to set this property is provided:
+
<tt><span><font color="#009900">void</font></span>       <span>'''<span><font color="#000000">hildon_banner_set_timeout</font></span>'''</span>       <span><font color="#990000">(</font></span>HildonBanner <span><font color="#990000"><nowiki>*</nowiki></font></span>self<span><font color="#990000">,</font></span>
-
 
+
                                              guint timeout<span><font color="#990000">);</font></span>
-
<source lang="c">
+
</tt>
-
void        hildon_banner_set_timeout      (HildonBanner *self,
+
-
                                            guint timeout);
+
-
</source>
+
Here is a simple example showing how to setup and show an informational banner.
Here is a simple example showing how to setup and show an informational banner.
Line 311: Line 282:
'''Example 7.5. Setting up an informational banner'''
'''Example 7.5. Setting up an informational banner'''
-
<source lang="c">
+
<tt>    GtkWidget<span><font color="#990000"><nowiki>*</nowiki></font></span> banner<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
GtkWidget* banner;
+
    <span>''<span><font color="#9A1900">/* Create a banner with a markup */</font></span>''</span>
-
/* Create a banner with a markup */
+
    banner <span><font color="#990000"><nowiki>=</nowiki></font></span> <span>'''<span><font color="#000000">hildon_banner_show_information_with_markup</font></span>'''</span> <span><font color="#990000">(</font></span>widget<span><font color="#990000">,</font></span>
-
banner = hildon_banner_show_information_with_markup (widget,
+
                                                          NULL<span><font color="#990000">,</font></span>
-
                                                    NULL,
+
                                                          <span><font color="#FF0000">"&lt;b&gt;Information banner&lt;/b&gt;"</font></span><span><font color="#990000">);</font></span>
-
                                                    "<b>Information banner</b>");
+
    <span>'''<span><font color="#000000">hildon_banner_set_timeout</font></span>'''</span> <span><font color="#990000">(</font></span><span>'''<span><font color="#000000">HILDON_BANNER</font></span>'''</span> <span><font color="#990000">(</font></span>banner<span><font color="#990000">),</font></span> <span><font color="#993399">9000</font></span><span><font color="#990000">);</font></span>
-
hildon_banner_set_timeout (HILDON_BANNER (banner), 9000);
+
</tt>
-
</source>
+
===Note===
===Note===
-
 
Only one timed banner can exist for each window in your application. If you spawn a new banner before the previous one has timed out, the first one is replaced.
Only one timed banner can exist for each window in your application. If you spawn a new banner before the previous one has timed out, the first one is replaced.
====Notes====
====Notes====
-
 
+
HildonNotes are GtkDialogs designed to request a small amount of input from users. Usually, notes show an information text and buttons to confirm and cancel, for example, according to their type.
-
<code>HildonNote</code>s are <code>GtkDialog</code>s designed to request a small amount of input from users. Usually, notes show an information text and buttons to confirm and cancel, for example, according to their type.
+
Unlike banners, notes always need a user action, that is, notes do not disappear automatically after a period of time.
Unlike banners, notes always need a user action, that is, notes do not disappear automatically after a period of time.
-
The <code>HildonNote</code> widget provides functions to create and show different types of notes: information notes, confirmation notes and cancel notes.
+
The HildonNote widget provides functions to create and show different types of notes: information notes, confirmation notes and cancel notes.
-
<source lang="c">
+
<tt>GtkWidget<span><font color="#990000"><nowiki>*</nowiki></font></span> <span>'''<span><font color="#000000">hildon_note_new_information</font></span>'''</span>     <span><font color="#990000">(</font></span>GtkWindow <span><font color="#990000"><nowiki>*</nowiki></font></span>parent<span><font color="#990000">,</font></span>
-
GtkWidget*  hildon_note_new_information    (GtkWindow *parent,
+
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>description<span><font color="#990000">);</font></span>
-
                                            const gchar *description);
+
GtkWidget<span><font color="#990000"><nowiki>*</nowiki></font></span> <span>'''<span><font color="#000000">hildon_note_new_confirmation</font></span>'''</span>   <span><font color="#990000">(</font></span>GtkWindow <span><font color="#990000"><nowiki>*</nowiki></font></span>parent<span><font color="#990000">,</font></span>
-
GtkWidget*  hildon_note_new_confirmation    (GtkWindow *parent,
+
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>description<span><font color="#990000">);</font></span>
-
                                            const gchar *description);
+
GtkWidget<span><font color="#990000"><nowiki>*</nowiki></font></span> hildon_note_new_confirmation_add_buttons
-
GtkWidget*  hildon_note_new_confirmation_add_buttons
+
                                            <span><font color="#990000">(</font></span>GtkWindow <span><font color="#990000"><nowiki>*</nowiki></font></span>parent<span><font color="#990000">,</font></span>
-
                                            (GtkWindow *parent,
+
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>description<span><font color="#990000">,</font></span>
-
                                            const gchar *description,
+
                                              <span><font color="#990000">...);</font></span>
-
                                            ...);
+
GtkWidget<span><font color="#990000"><nowiki>*</nowiki></font></span> hildon_note_new_cancel_with_progress_bar
-
GtkWidget*  hildon_note_new_cancel_with_progress_bar
+
                                            <span><font color="#990000">(</font></span>GtkWindow <span><font color="#990000"><nowiki>*</nowiki></font></span>parent<span><font color="#990000">,</font></span>
-
                                            (GtkWindow *parent,
+
                                              <span>'''<span><font color="#0000FF">const</font></span>'''</span> gchar <span><font color="#990000"><nowiki>*</nowiki></font></span>description<span><font color="#990000">,</font></span>
-
                                            const gchar *description,
+
                                              GtkProgressBar <span><font color="#990000"><nowiki>*</nowiki></font></span>progressbar<span><font color="#990000">);</font></span>
-
                                            GtkProgressBar *progressbar);
+
</tt>
-
</source>
+
Every function to create notes receives as a parameter the parent window of the newly created note. This is important in order to allow the window manager to handle the windows properly.
Every function to create notes receives as a parameter the parent window of the newly created note. This is important in order to allow the window manager to handle the windows properly.
====Information Notes====
====Information Notes====
-
 
Information notes are used to show an information to the users. This note disappears when user taps outside the note's area. Otherwise the note remains visible.
Information notes are used to show an information to the users. This note disappears when user taps outside the note's area. Otherwise the note remains visible.
Line 357: Line 323:
'''Example 7.6. Example of a Hildon information note'''
'''Example 7.6. Example of a Hildon information note'''
-
<source lang="c">
+
<tt><span>'''<span><font color="#0000FF">static</font></span>'''</span> <span><font color="#009900">void</font></span>
-
static void
+
<span>'''<span><font color="#000000">show_information_note</font></span>'''</span>                         <span><font color="#990000">(</font></span>GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>parent<span><font color="#990000">)</font></span>
-
show_information_note                          (GtkWidget *parent)
+
<span><font color="#FF0000">{</font></span>
-
{
+
  GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>window<span><font color="#990000">,</font></span> <span><font color="#990000"><nowiki>*</nowiki></font></span>note<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
  GtkWidget *window, *note;
+
  gint response<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
  gint response;
+
  note <span><font color="#990000"><nowiki>=</nowiki></font></span> <span>'''<span><font color="#000000">hildon_note_new_information</font></span>'''</span> <span><font color="#990000">(</font></span>NULL<span><font color="#990000">,</font></span>
-
  note = hildon_note_new_information (NULL,
+
    <span><font color="#FF0000">"Lorem ipsum dolor sit amet, consectetur adipiscing elit."</font></span>
-
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
+
    <span><font color="#FF0000">"Maecenas tristique dictum est. Aenean rhoncus aliquam mi."</font></span>
-
    "Maecenas tristique dictum est. Aenean rhoncus aliquam mi."
+
    <span><font color="#FF0000">"In hac habitasse platea dictumst."</font></span><span><font color="#990000">);</font></span>
-
    "In hac habitasse platea dictumst.");
+
  response <span><font color="#990000"><nowiki>=</nowiki></font></span> <span>'''<span><font color="#000000">gtk_dialog_run</font></span>'''</span> <span><font color="#990000">(</font></span><span>'''<span><font color="#000000">GTK_DIALOG</font></span>'''</span> <span><font color="#990000">(</font></span>note<span><font color="#990000">));</font></span>
-
  response = gtk_dialog_run (GTK_DIALOG (note));
+
  <span>'''<span><font color="#0000FF">if</font></span>'''</span> <span><font color="#990000">(</font></span>response <span><font color="#990000"><nowiki>==</nowiki></font></span> GTK_RESPONSE_DELETE_EVENT<span><font color="#990000">)</font></span>
-
  if (response == GTK_RESPONSE_DELETE_EVENT)
+
    <span>'''<span><font color="#000000">g_debug</font></span>'''</span> <span><font color="#990000">(</font></span><span><font color="#FF0000">"%s: GTK_RESPONSE_DELETE_EVENT"</font></span><span><font color="#990000">,</font></span> __FUNCTION__<span><font color="#990000">);</font></span>
-
    g_debug ("%s: GTK_RESPONSE_DELETE_EVENT", __FUNCTION__);
+
  <span>'''<span><font color="#000000">gtk_object_destroy</font></span>'''</span> <span><font color="#990000">(</font></span><span>'''<span><font color="#000000">GTK_OBJECT</font></span>'''</span> <span><font color="#990000">(</font></span>note<span><font color="#990000">));</font></span>
-
  gtk_object_destroy (GTK_OBJECT (note));
+
<span><font color="#FF0000">}</font></span>
-
}
+
</tt>
-
</source>
+
====Confirmation Notes====
====Confirmation Notes====
-
 
Confirmation notes show an information text that is usually a question and two buttons labelled "Yes" and "No".
Confirmation notes show an information text that is usually a question and two buttons labelled "Yes" and "No".
Line 382: Line 346:
'''Example 7.7. Example of a Hildon confirmation note'''
'''Example 7.7. Example of a Hildon confirmation note'''
-
<source lang="c">
+
<tt><span>'''<span><font color="#0000FF">static</font></span>'''</span> <span><font color="#009900">void</font></span>
-
static void
+
<span>'''<span><font color="#000000">show_confirmation_note</font></span>'''</span>                         <span><font color="#990000">(</font></span>GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>parent<span><font color="#990000">)</font></span>
-
show_confirmation_note                          (GtkWidget *parent)
+
<span><font color="#FF0000">{</font></span>
-
{
+
    GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>note<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
    GtkWidget *note;
+
    gint response<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
    gint response;
+
    note <span><font color="#990000"><nowiki>=</nowiki></font></span> <span>'''<span><font color="#000000">hildon_note_new_confirmation</font></span>'''</span> <span><font color="#990000">(</font></span>parent<span><font color="#990000">,</font></span>
-
    note = hildon_note_new_confirmation (parent,
+
                                          <span><font color="#FF0000">"Do you want foo ?"</font></span><span><font color="#990000">);</font></span>
-
                                        "Do you want foo ?");
+
    response <span><font color="#990000"><nowiki>=</nowiki></font></span> <span>'''<span><font color="#000000">gtk_dialog_run</font></span>'''</span> <span><font color="#990000">(</font></span><span>'''<span><font color="#000000">GTK_DIALOG</font></span>'''</span> <span><font color="#990000">(</font></span>note<span><font color="#990000">));</font></span>
-
    response = gtk_dialog_run (GTK_DIALOG (note));
+
    <span>'''<span><font color="#0000FF">if</font></span>'''</span> <span><font color="#990000">(</font></span>response <span><font color="#990000"><nowiki>==</nowiki></font></span> GTK_RESPONSE_DELETE_EVENT<span><font color="#990000">)</font></span>
-
    if (response == GTK_RESPONSE_DELETE_EVENT)
+
      <span>'''<span><font color="#000000">g_debug</font></span>'''</span> <span><font color="#990000">(</font></span><span><font color="#FF0000">"%s: GTK_RESPONSE_DELETE_EVENT"</font></span><span><font color="#990000">,</font></span> __FUNCTION__<span><font color="#990000">);</font></span>
-
      g_debug ("%s: GTK_RESPONSE_DELETE_EVENT", __FUNCTION__);
+
    <span>'''<span><font color="#000000">gtk_object_destroy</font></span>'''</span> <span><font color="#990000">(</font></span><span>'''<span><font color="#000000">GTK_OBJECT</font></span>'''</span> <span><font color="#990000">(</font></span>note<span><font color="#990000">));</font></span>
-
    gtk_object_destroy (GTK_OBJECT (note));
+
<span><font color="#FF0000">}</font></span>
-
}
+
</tt>
-
</source>
+
Alternatively, you can use <code>hildon_note_new_confirmation_add_buttons()</code> to create a confirmation note with custom buttons.
Alternatively, you can use <code>hildon_note_new_confirmation_add_buttons()</code> to create a confirmation note with custom buttons.
-
'''Example 7.8. Example of a Hildon confirmation note with custom buttons'''
+
'''Example 7.8. Example of a Hildon copnfirmation note with custom buttons'''
-
<source lang="c">
+
<tt><span>'''<span><font color="#0000FF">static</font></span>'''</span> <span><font color="#009900">void</font></span>
-
static void
+
<span>'''<span><font color="#000000">show_confirmation_note</font></span>'''</span>                         <span><font color="#990000">(</font></span>GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>parent<span><font color="#990000">)</font></span>
-
show_confirmation_note                          (GtkWidget *parent)
+
<span><font color="#FF0000">{</font></span>
-
{
+
    GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>note<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
    GtkWidget *note;
+
    gint response<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
    gint response;
+
    note <span><font color="#990000"><nowiki>=</nowiki></font></span> <span>'''<span><font color="#000000">hildon_note_new_confirmation_add_buttons</font></span>'''</span><span><font color="#990000">(</font></span>parent<span><font color="#990000">,</font></span>
-
    note = hildon_note_new_confirmation_add_buttons(parent,
+
                                                    <span><font color="#FF0000">"Do you want foo?"</font></span><span><font color="#990000">,</font></span>
-
                                                    "Do you want foo?",
+
                                                    <span><font color="#FF0000">"ACCEPT"</font></span><span><font color="#990000">,</font></span> GTK_RESPONSE_OK<span><font color="#990000">,</font></span>
-
                                                    "ACCEPT", GTK_RESPONSE_OK,
+
                                                    <span><font color="#FF0000">"CANCEL"</font></span><span><font color="#990000">,</font></span> GTK_RESPONSE_CANCEL<span><font color="#990000">,</font></span>
-
                                                    "CANCEL", GTK_RESPONSE_CANCEL,
+
                                                    <span><font color="#FF0000">"DELETE"</font></span><span><font color="#990000">,</font></span> GTK_RESPONSE_DELETE_EVENT<span><font color="#990000">,</font></span>
-
                                                    "DELETE", GTK_RESPONSE_DELETE_EVENT,
+
                                                    NULL<span><font color="#990000">);</font></span>
-
                                                    NULL);
+
    response <span><font color="#990000"><nowiki>=</nowiki></font></span> <span>'''<span><font color="#000000">gtk_dialog_run</font></span>'''</span> <span><font color="#990000">(</font></span><span>'''<span><font color="#000000">GTK_DIALOG</font></span>'''</span> <span><font color="#990000">(</font></span>note<span><font color="#990000">));</font></span>
-
    response = gtk_dialog_run (GTK_DIALOG (note));
+
    <span>'''<span><font color="#0000FF">if</font></span>'''</span> <span><font color="#990000">(</font></span>response <span><font color="#990000"><nowiki>==</nowiki></font></span> GTK_RESPONSE_DELETE_EVENT<span><font color="#990000">)</font></span>
-
    if (response == GTK_RESPONSE_DELETE_EVENT)
+
      <span>'''<span><font color="#000000">g_debug</font></span>'''</span> <span><font color="#990000">(</font></span><span><font color="#FF0000">"%s: GTK_RESPONSE_DELETE_EVENT"</font></span><span><font color="#990000">,</font></span> __FUNCTION__<span><font color="#990000">);</font></span>
-
      g_debug ("%s: GTK_RESPONSE_DELETE_EVENT", __FUNCTION__);
+
    <span>'''<span><font color="#000000">gtk_object_destroy</font></span>'''</span> <span><font color="#990000">(</font></span><span>'''<span><font color="#000000">GTK_OBJECT</font></span>'''</span> <span><font color="#990000">(</font></span>note<span><font color="#990000">));</font></span>
-
    gtk_object_destroy (GTK_OBJECT (note));
+
<span><font color="#FF0000">}</font></span>
-
}
+
</tt>
-
</source>
+
'''Cancel Notes'''
'''Cancel Notes'''
Line 428: Line 390:
'''Example 7.9. Example of a Hildon cancel note with a progress bar'''
'''Example 7.9. Example of a Hildon cancel note with a progress bar'''
-
<source lang="c">
+
<tt><span>'''<span><font color="#0000FF">static</font></span>'''</span> <span><font color="#009900">void</font></span>
-
static void
+
<span>'''<span><font color="#000000">show_information_note</font></span>'''</span>                         <span><font color="#990000">(</font></span>GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>parent<span><font color="#990000">)</font></span>
-
show_information_note                          (GtkWidget *parent)
+
<span><font color="#FF0000">{</font></span>
-
{
+
  GtkWidget <span><font color="#990000"><nowiki>*</nowiki></font></span>note
-
  GtkWidget *note
+
  GtkProgressBar <span><font color="#990000"><nowiki>*</nowiki></font></span>progressbar
-
  GtkProgressBar *progressbar
+
  gint response<span><font color="#990000"><nowiki>;</nowiki></font></span>
-
  gint response;
+
  progressbar <span><font color="#990000"><nowiki>=</nowiki></font></span> <span>'''<span><font color="#000000">gtk_progress_bar_new</font><font color="#990000">()</font></span>'''
-
  progressbar = gtk_progress_bar_new()
+
  note <span><font color="#990000"><nowiki>=</nowiki></font></span> <span>'''<span><font color="#000000">hildon_note_new_cancel_with_progress_bar</font></span>'''</span> <span><font color="#990000">(</font></span>parent<span><font color="#990000">,</font></span>
-
  note = hildon_note_new_cancel_with_progress_bar (parent,
+
                                                  <span><font color="#FF0000">"A large task is happening"</font></span>
-
                                                  "A large task is happening"
+
                                                  <span><font color="#990000">progressbar</font></span><span><font color="#990000">);</font></span>
-
                                                  progressbar);
+
  response <span><font color="#990000"><nowiki>=</nowiki></font></span> <span>'''<span><font color="#000000">gtk_dialog_run</font></span>'''</span> <span><font color="#990000">(</font></span><span>'''<span><font color="#000000">GTK_DIALOG</font></span>'''</span> <span><font color="#990000">(</font></span>note<span><font color="#990000">));</font></span>
-
  response = gtk_dialog_run (GTK_DIALOG (note));
+
  <span>'''<span><font color="#0000FF">if</font></span>'''</span> <span><font color="#990000">(</font></span>response <span><font color="#990000"><nowiki>==</nowiki></font></span> GTK_RESPONSE_DELETE_EVENT<span><font color="#990000">)</font></span>
-
  if (response == GTK_RESPONSE_DELETE_EVENT)
+
    <span>'''<span><font color="#000000">g_debug</font></span>'''</span> <span><font color="#990000">(</font></span><span><font color="#FF0000">"%s: GTK_RESPONSE_DELETE_EVENT"</font></span><span><font color="#990000">,</font></span> __FUNCTION__<span><font color="#990000">);</font></span>
-
    g_debug ("%s: GTK_RESPONSE_DELETE_EVENT", __FUNCTION__);
+
  <span>'''<span><font color="#000000">gtk_object_destroy</font></span>'''</span> <span><font color="#990000">(</font></span><span>'''<span><font color="#000000">GTK_OBJECT</font></span>'''</span> <span><font color="#990000">(</font></span>note<span><font color="#990000">));</font></span>
-
  gtk_object_destroy (GTK_OBJECT (note));
+
<span><font color="#FF0000">}</font></span>
-
}
+
-
</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: