Legacy Maemo 5 Documentation/Graphical UI Tutorial/Windows and dialogs

= Windows and dialogs = When creating applications for hand-held devices, you should take into account several issues about usability and device limitations. Screen size is a particularly large restriction; a simple interface is essential.

In contrast with GTK+ applications, Hildon applications display only one window at a time. A typical Hildon application uses several windows representing different views in a tree-like hierarchy.

Example 1.2, “Hildon Hello World program” [localhost#Hildon_Hello_World_program 6.4.1](the Hello World) has already shown how to use a simple HildonWindow can be used and how it resembles the use of a classical GTK+ window. The tree-like views represent a new concept introduced by Hildon.

To properly understand what views are, think of an application as a program that allows the user to perform one or more tasks. Each task can be broken down into several main activities.

Main activities in tasks should be done and presented in separate application views or windows, while assistance activities and steps to fulfill those tasks should be done in dialogs and menus on top of the currently displayed view.

Views work in a tree-like hierarchy. Root View acts as the "root" for the tree, and the subsequent Sub Views branch down the hierarchy.

@@IMAGE@@: VIEWS AND SUBVIEWS DIAGRAM

The view concept is implemented by the widget HildonStackableWindow. This widget allows building a navigable hierarchy of windows with less code.

Stackable windows
The HildonStackableWindow is a GTK+ widget which represents a top-level window in the Hildon framework. Stackable windows can be organized in a hierarchical way.

A stack sets the hierarchical relationships between windows. A child window is on top of its parent window. That allows navigate to previous window by removing the topmost window.

Users can only see and interact with the window on the top of stack. All other windows are mapped and visible but they are obscured by the topmost one. And they can go back to a root view from a subview by clicking in the navigation button in the top right corner of the window.

Each application has a default stack, and windows are automatically added to it when they are shown using. Most applications do not need to create extra stacks. Create more than one stack could make your UI too complex, so think twice before doing it.

Let's see a simple example to show the use of this widget. This simple program creates a stackable window with a button to navigate towards a subview, a new window on top of the stack.

'''Example 2.1. Example of stackable windows'''

   #include                                        &lt;hildon/hildon.h&gt;  static  void  show_new_window  (  void  ) { GtkWidget  * win  ; GtkWidget  * vbox  ; GtkWidget  * label  ;  <font color="#9A1900">/* Create the main window */  win <font color="#990000"> =  <font color="#000000">hildon_stackable_window_new   <font color="#990000">;  <font color="#000000">gtk_window_set_title  <font color="#990000">(   <font color="#000000">GTK_WINDOW   <font color="#990000">( win <font color="#990000">),  <font color="#FF0000">"Subview"  <font color="#990000">);  <font color="#9A1900">/* Setting a label in the new window */  label <font color="#990000"> =  <font color="#000000">gtk_label_new   <font color="#990000">(  <font color="#FF0000">"This is a subview"  <font color="#990000">); vbox <font color="#990000"> =  <font color="#000000">gtk_vbox_new   <font color="#990000">( FALSE <font color="#990000">,  <font color="#993399">0  <font color="#990000">);  <font color="#000000">gtk_box_pack_start  <font color="#990000">(   <font color="#000000">GTK_BOX   <font color="#990000">( vbox <font color="#990000">),                          label <font color="#990000">,                          TRUE <font color="#990000">,                          TRUE <font color="#990000">,                          <font color="#993399">0  <font color="#990000">);  <font color="#000000">gtk_container_add  <font color="#990000">(   <font color="#000000">GTK_CONTAINER   <font color="#990000">( win <font color="#990000">),                         vbox <font color="#990000">);  <font color="#000000">g_signal_connect  <font color="#990000">( win <font color="#990000">,  <font color="#FF0000">"destroy"  <font color="#990000">,   <font color="#000000">G_CALLBACK   <font color="#990000">( test <font color="#990000">), NULL <font color="#990000">);  <font color="#9A1900">/* This call show the window and also add the window to the stack */   <font color="#000000">gtk_widget_show_all  <font color="#990000">( win <font color="#990000">); <font color="#FF0000">} <font color="#009900">int  <font color="#000000">main  <font color="#990000">(  <font color="#009900">int argc <font color="#990000">,        <font color="#009900">char  <font color="#990000"> ** argv <font color="#990000">) <font color="#FF0000">{ HildonProgram <font color="#990000"> * program <font color="#990000"> ; GtkWidget <font color="#990000"> * win <font color="#990000"> ; GtkWidget <font color="#990000"> * button <font color="#990000"> ;  <font color="#000000">hildon_gtk_init  <font color="#990000">(&amp; argc <font color="#990000">,  <font color="#990000">&amp; argv <font color="#990000">); program <font color="#990000"> =  <font color="#000000">hildon_program_get_instance   <font color="#990000">;  <font color="#9A1900">/* Create the main window */  win <font color="#990000"> =  <font color="#000000">hildon_stackable_window_new   <font color="#990000">;  <font color="#000000">gtk_window_set_title  <font color="#990000">(   <font color="#000000">GTK_WINDOW   <font color="#990000">( win <font color="#990000">),  <font color="#FF0000">"Main window"  <font color="#990000">); button <font color="#990000"> =  <font color="#000000">gtk_button_new_with_label   <font color="#990000">(  <font color="#FF0000">"Go to subview"  <font color="#990000">);  <font color="#000000">gtk_container_add  <font color="#990000">(   <font color="#000000">GTK_CONTAINER   <font color="#990000">( win <font color="#990000">),                          button <font color="#990000">);  <font color="#000000">g_signal_connect  <font color="#990000">( button <font color="#990000">,  <font color="#FF0000">"clicked"  <font color="#990000">,   <font color="#000000">G_CALLBACK   <font color="#990000">( show_new_window <font color="#990000">), NULL <font color="#990000">);  <font color="#000000">g_signal_connect  <font color="#990000">( win <font color="#990000">,  <font color="#FF0000">"destroy"  <font color="#990000">,   <font color="#000000">G_CALLBACK   <font color="#990000">( test <font color="#990000">), NULL <font color="#990000">);  <font color="#000000">g_signal_connect  <font color="#990000">( win <font color="#990000">,  <font color="#FF0000">"destroy"  <font color="#990000">,   <font color="#000000">G_CALLBACK   <font color="#990000">( gtk_main_quit <font color="#990000">), NULL <font color="#990000">);  <font color="#9A1900">/* This call show the window and also add the window to the stack */   <font color="#000000">gtk_widget_show_all  <font color="#990000">( win <font color="#990000">);  <font color="#000000">gtk_main  <font color="#990000">;  <font color="#0000FF">return  <font color="#993399">0  <font color="#990000"> ; <font color="#FF0000">} </tt>

The function  is set up as a handler for when the signal "clicked" is emitted. This function creates a new stackable window which is added on top of the stack by calling.

Displaying a stackable window by calling  or   automatically adds it on top of the default stack.

Note that no extra code exists for navigation between views because the navigation button in the top-right corner of the window allows users to return from subviews. When the user presses the navigation button, the topmost window is destroyed and the previous window becomes the topmost one.

In some applications it could be necessary to push and/or pop windows on the stack without destroying them, or even to build and handle extra windows' stacks. Next section explains how to do that.

Advanced stack handling
The object which represents a stack of windows in the Hildon framework is the HildonWindowStack. This object provides functions to push and/or pop windows on the stack, functions to access the topmost window or retrieve the current size of the stack are provided as well. Usual operations

To access the default stack, use the function. To access the stack that contains a particular window, use.

<tt>HildonWindowStack <font color="#990000"> *  <font color="#000000">hildon_window_stack_get_default           <font color="#990000">(  <font color="#009900">void  <font color="#990000">); </tt>

The following functions are available to push and/or pop windows on a stack:

<tt>       <font color="#009900">void         <font color="#000000">hildon_window_stack_push               <font color="#990000">( HildonWindowStack <font color="#990000"> * stack <font color="#990000">,  	                                                   HildonStackableWindow <font color="#990000"> * win1 <font color="#990000">,          	                                           <font color="#990000">...); <font color="#009900">void        <font color="#000000">hildon_window_stack_push_list          <font color="#990000">( HildonWindowStack <font color="#990000"> * stack <font color="#990000">,          	                                           GList <font color="#990000"> * list <font color="#990000">); <font color="#009900">void        <font color="#000000">hildon_window_stack_push_1             <font color="#990000">( HildonWindowStack <font color="#990000"> * stack <font color="#990000">,          	                                           HildonStackableWindow <font color="#990000"> * win <font color="#990000">); <font color="#009900">void        <font color="#000000">hildon_window_stack_pop                <font color="#990000">( HildonWindowStack <font color="#990000"> * stack <font color="#990000">,          	                                           gint nwindows <font color="#990000">,                  	                                   GList <font color="#990000"> ** popped_windows <font color="#990000">); GtkWidget <font color="#990000"> *  <font color="#000000">hildon_window_stack_pop_1              <font color="#990000">( HildonWindowStack <font color="#990000"> * stack <font color="#990000">); <font color="#009900">void        <font color="#000000">hildon_window_stack_pop_and_push       <font color="#990000">( HildonWindowStack <font color="#990000"> * stack <font color="#990000">,          	                                           gint nwindows <font color="#990000">,                  	                                   GList <font color="#990000"> ** popped_windows <font color="#990000">,                          	                           HildonStackableWindow <font color="#990000"> * win1 <font color="#990000">,                                  	                   <font color="#990000">...); <font color="#009900">void        <font color="#000000">hildon_window_stack_pop_and_push_list   <font color="#990000">( HildonWindowStack <font color="#990000"> * stack <font color="#990000">,          	                                           gint nwindows <font color="#990000">,                  	                                   GList <font color="#990000"> ** popped_windows <font color="#990000">,                          	                           GList <font color="#990000"> * list <font color="#990000">); </tt>

The example shows how to get the default stack and push a newly created window on the stack. (Note that you also can do the same in a single stack by calling ).

'''Example 2.2. Pushing a new window into a stack'''

<tt>   HildonWindowStack <font color="#990000"> * stack <font color="#990000"> = NULL <font color="#990000"> ; GtkWidget <font color="#990000"> * window <font color="#990000"> ; window <font color="#990000"> =  <font color="#000000">hildon_stackable_window_new   <font color="#990000">; stack <font color="#990000"> =  <font color="#000000">hildon_window_stack_get_default   <font color="#990000">;  <font color="#000000">hildon_window_stack_push_1  <font color="#990000">( stack <font color="#990000">,   <font color="#000000">HILDON_STACKABLE_WINDOW   <font color="#990000">( window <font color="#990000">)); </tt>

The push functions also displays the window. is not needed after a push operation.

A function also exists to push a list of windows in a single step. Windows are stacked in the listed order and users only see the window that was last pushed.

'''Example 2.3. Pushing a list of windows into a stack'''

<tt>  <font color="#0000FF">static  GtkWidget <font color="#990000"> *  <font color="#000000">create_customized_selector  <font color="#990000"> <font color="#FF0000">{ GtkWidget <font color="#990000"> * selector <font color="#990000"> ; GSList <font color="#990000"> * icon_list <font color="#990000"> = NULL <font color="#990000"> ; GtkListStore <font color="#990000"> * store_icons <font color="#990000"> = NULL <font color="#990000"> ; GSList <font color="#990000"> * item <font color="#990000"> = NULL <font color="#990000"> ; GtkCellRenderer <font color="#990000"> * renderer <font color="#990000"> = NULL <font color="#990000"> ; HildonTouchSelectorColumn <font color="#990000"> * column <font color="#990000"> = NULL <font color="#990000"> ;  <font color="#9A1900">/* Create a touch selector */  selector <font color="#990000"> =  <font color="#000000">hildon_touch_selector_new   <font color="#990000">;  <font color="#9A1900">/* Stock icons will be used for the example */  icon_list <font color="#990000"> =  <font color="#000000">gtk_stock_list_ids   <font color="#990000">;  <font color="#9A1900">/* Create model to store selector's items */  store_icons <font color="#990000"> =  <font color="#000000">gtk_list_store_new   <font color="#990000">(  <font color="#993399">1  <font color="#990000">, G_TYPE_STRING <font color="#990000">);  <font color="#9A1900">/* Populate model */   <font color="#0000FF">for  <font color="#990000">( item <font color="#990000"> = icon_list <font color="#990000"> ; item <font color="#990000"> ; item <font color="#990000"> =   <font color="#000000">g_slist_next   <font color="#990000">( item <font color="#990000">))  <font color="#FF0000">{ GtkTreeIter iter <font color="#990000"> ; gchar <font color="#990000"> * label <font color="#990000"> = item <font color="#990000">-&gt; data <font color="#990000"> ;  <font color="#000000">gtk_list_store_append  <font color="#990000">( store_icons <font color="#990000">,  <font color="#990000">&amp; iter <font color="#990000">);  <font color="#000000">gtk_list_store_set  <font color="#990000">( store_icons <font color="#990000">,  <font color="#990000">&amp; iter <font color="#990000">,  <font color="#993399">0  <font color="#990000">, label <font color="#990000">,  <font color="#990000">-  <font color="#993399">1  <font color="#990000">);  <font color="#000000">g_free  <font color="#990000">( label <font color="#990000">); <font color="#FF0000">}  <font color="#000000">g_slist_free  <font color="#990000">( icon_list <font color="#990000">);  <font color="#9A1900">/* Create and set up a pixbuf renderer to use in the selector */  renderer <font color="#990000"> =  <font color="#000000">gtk_cell_renderer_pixbuf_new   <font color="#990000">;  <font color="#000000">gtk_cell_renderer_set_fixed_size  <font color="#990000">( renderer <font color="#990000">,  <font color="#990000">-  <font color="#993399">1  <font color="#990000">,  <font color="#993399">100  <font color="#990000">);  <font color="#9A1900">/* Add the column to the selector */  column <font color="#990000"> =  <font color="#000000">hildon_touch_selector_append_column   <font color="#990000">(   <font color="#000000">HILDON_TOUCH_SELECTOR   <font color="#990000">( selector <font color="#990000">),                                                   <font color="#000000">GTK_TREE_MODEL   <font color="#990000">( store_icons <font color="#990000">),                                                  renderer <font color="#990000">,                                                  <font color="#FF0000">"stock-id"  <font color="#990000">,  <font color="#993399">0  <font color="#990000">,                                                  NULL <font color="#990000">);  <font color="#9A1900">/* Set the selection mode */   <font color="#000000">hildon_touch_selector_set_column_selection_mode  <font color="#990000">(   <font color="#000000">HILDON_TOUCH_SELECTOR   <font color="#990000">( selector <font color="#990000">),                                      HILDON_TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE <font color="#990000">);  <font color="#9A1900">/* Set the property "text-column" that indicates the column   <font color="#9A1900">  * of the model to get the string from */   <font color="#000000">g_object_set  <font color="#990000">(   <font color="#000000">G_OBJECT   <font color="#990000">( column <font color="#990000">),  <font color="#FF0000">"text-column"  <font color="#990000">,  <font color="#993399">0  <font color="#990000">, NULL <font color="#990000">);  <font color="#0000FF">return  selector <font color="#990000"> ; <font color="#FF0000">} </tt>

Similar functions exist for the pop operation. The example uses  to pop N windows from the default stack and stores them in the list of arguments. Notice that  is used to check the size of the stack.

'''Example 2.4. Popping a number of windows from a stack into a list'''

<tt>GList <font color="#990000"> * list <font color="#990000"> = NULL <font color="#990000"> ; HildonWindowStack <font color="#990000"> * stack <font color="#990000"> ; HildonStackableWindow <font color="#990000"> * window <font color="#990000"> ; gint nwindows <font color="#990000"> = <font color="#993399">10  <font color="#990000"> ; stack <font color="#990000"> =  <font color="#000000">hildon_stackable_window_get_default   <font color="#990000">;  <font color="#0000FF">if  <font color="#990000">(   <font color="#000000">hildon_stackable_window_size   <font color="#990000">( stack <font color="#990000">)  <font color="#990000">&gt; nwindows <font color="#990000">)  <font color="#FF0000">{  <font color="#000000">hildon_window_stack_pop  <font color="#990000">( stack <font color="#990000">, nwindows <font color="#990000">, list <font color="#990000">); <font color="#FF0000">} </tt>

HildonWindowStack object also provides more advanced functions to perform both pop and push operations at once such as, for example,  or. These functions do everything in a single transition, so the user only sees the last pushed window.

When you perform push/pop operations you should take into account two things:


 * All stacked windows are visible and all visible windows are stacked.
 * Each window can only be in one stack at a time.

Due to the first one, a push operation always shows the window and a pop operation always hides the window. Functions  and   always push and remove the window from its current stack, respectively.

Regarding the second one, operation push has no effect on windows which are already on a stack.

Multiple Stacks

Most applications do not need more than the default stack. Although you can use multiple stacks in one application, note that this increases the complexity of the UI, which is not desirable.

To create a new stack just use. A new stacks behaves like a new application or task. Newly created stacks are displayed on top of the current stack. Users need to use the task selector to change between stacks when they change tasks (applications).

Once a new stack is created, use the functions explained in the previous section to pop and/or push windows on the stack.

Dialogs
Dialog boxes are a convenient way to prompt the user for a small amount of input, e.g. to display a message, ask a question, or anything else that does not require extensive effort on the user's part.

Hildon provides specialized widgets to cover the most common dialog's use cases: HildonNote and HildonBanner.

HildonNote is useful to ask users a question and HildonBanner is used to show textual information which automatically disappear after a certain period of time without user interaction. For more information on these widgets, see section ???Notification widgets [localhost#sec:notification_widgets 6.10.3].

Besides those widgets, Hildon provides also specialized GtkDialogs designed to cover different use cases: HildonPickerDialog and HildonWizardDialog.

The widget HildonPickerDialog is used along with HildonPickerButton and HildonTouchSelector to give a way to make data selections. [localhost#sec:data_selection 6.9]Data election explains the use of such widgets.

To create a guided process which helps users accomplish complex task step by step, Hildon provide the HildonWizardDialog widget. For more information, see section ???next section.

HildonWizardDialog
HildonWizardDialog is a widget that allows one to create a guided process. The dialog has three standard buttons, previous, next and finish, and contains several pages. Users can close the dialog by tapping the dimmed area outside the dialog's window.

A good example of a guided process which could be implemented with this widget is the setup of a new e-mail account in an e-mail client. Users would have to fill several entries through several steps to accomplish the setup of the new account. The process of installing an application is another example of the uses of this widget.

This widget uses a GtkNotebook that contains the actual wizard pages. The notebook widget is pointed by the property "wizard-notebook" of the wizard. You need to create the notebook as well as the pages that are displayed. For more information on GtkNotebook, see the GTK+ Reference Manual.

To create a new wizard dialog you should call:

<tt>GtkWidget <font color="#990000"> *  <font color="#000000">hildon_wizard_dialog_new         <font color="#990000">( GtkWindow <font color="#990000"> * parent <font color="#990000">,                                                <font color="#0000FF">const   <font color="#009900">char  <font color="#990000"> * wizard_name <font color="#990000">,                                               GtkNotebook <font color="#990000"> * notebook <font color="#990000">); </tt>

The parent window is usually the current visible view. The wizard name is displayed as title in the wizard dialog.

Usually, you want to validate user input to decide whether it should move to the next step or not. To do that, set a user function by using:

<tt>  <font color="#000000">gboolean    <font color="#990000">(* HildonWizardDialogPageFunc <font color="#990000">)   <font color="#990000">( GtkNotebook <font color="#990000"> * notebook <font color="#990000">,                                               gint current_page <font color="#990000">,                                               gpointer data <font color="#990000">); </tt>

The function above sets the function "page_func" to be used to decide whether the user can go to the next page when pressing the forward button. The function should have the following signature:

<tt>  <font color="#000000">gboolean    <font color="#990000">(* HildonWizardDialogPageFunc <font color="#990000">)   <font color="#990000">( GtkNotebook <font color="#990000"> * notebook <font color="#990000">,                                               gint current_page <font color="#990000">,                                               gpointer data <font color="#990000">); </tt>

Here, an example of using a HildonWizardDialog

@@IMAGE@@: EXAMPLE BELOW

'''Example 2.5. Example of a Hildon wizard dialog'''

<tt>  <font color="#000080"> #include                                        <font color="#FF0000">&lt;stdio.h&gt;  <font color="#000080"> #include                                        <font color="#FF0000">&lt;stdlib.h&gt;  <font color="#000080"> #include                                        <font color="#FF0000">&lt;string.h&gt;  <font color="#000080"> #include                                        <font color="#FF0000">&lt;hildon/hildon.h&gt; gboolean  <font color="#000000">on_page_switch  <font color="#990000">( GtkNotebook <font color="#990000"> * notebook <font color="#990000">,                  GtkNotebookPage <font color="#990000"> * page <font color="#990000">,                  guint num <font color="#990000">,                  HildonWizardDialog <font color="#990000"> * dialog <font color="#990000">) <font color="#FF0000">{  <font color="#000000">g_debug  <font color="#990000">(  <font color="#FF0000">"Page %d"  <font color="#990000">, num <font color="#990000">);  <font color="#0000FF">return  TRUE <font color="#990000"> ; <font color="#FF0000">}  <font color="#0000FF">static  gboolean  <font color="#000000">some_page_func  <font color="#990000">( GtkNotebook <font color="#990000"> * nb <font color="#990000">,                  gint current <font color="#990000">,                  gpointer userdata <font color="#990000">) <font color="#FF0000">{ HildonEntry <font color="#990000"> * entry <font color="#990000"> ; '' <font color="#9A1900">/* Validate data only for the third page. */ ''    <font color="#0000FF">switch   <font color="#990000">( current <font color="#990000">)  <font color="#FF0000">{  <font color="#0000FF">case  <font color="#993399">2  <font color="#990000"> : entry <font color="#990000"> =  <font color="#000000">HILDON_ENTRY   <font color="#990000">(   <font color="#000000">gtk_notebook_get_nth_page   <font color="#990000">( nb <font color="#990000">, current <font color="#990000">));  <font color="#0000FF">return  <font color="#990000">(   <font color="#000000">strlen   <font color="#990000">(   <font color="#000000">hildon_entry_get_text   <font color="#990000">( entry <font color="#990000">))  <font color="#990000"> !=  <font color="#993399">0  <font color="#990000">);  <font color="#0000FF">default  <font color="#990000"> :  <font color="#0000FF">return  TRUE <font color="#990000"> ; <font color="#FF0000">} <font color="#FF0000">} <font color="#009900">int  <font color="#000000">main  <font color="#990000">(  <font color="#009900">int argc <font color="#990000">,  <font color="#009900">char  <font color="#990000"> ** argv <font color="#990000">) <font color="#FF0000">{  <font color="#000000">hildon_gtk_init  <font color="#990000">(&amp; argc <font color="#990000">,  <font color="#990000">&amp; argv <font color="#990000">); GtkWidget <font color="#990000"> * dialog <font color="#990000">,* notebook <font color="#990000">, <font color="#990000"> * label_1 <font color="#990000">,  <font color="#990000"> * label_2 <font color="#990000">,  <font color="#990000"> * entry_3 <font color="#990000">,  <font color="#990000"> * label_4 <font color="#990000"> ;  <font color="#9A1900">/* Create a notebook */  notebook <font color="#990000"> =  <font color="#000000">gtk_notebook_new   <font color="#990000">;  <font color="#9A1900">/* Create widgets to palce into the notebook's pages */  label_1 <font color="#990000"> =  <font color="#000000">gtk_label_new   <font color="#990000">(  <font color="#FF0000">"Page 1"  <font color="#990000">); label_2 <font color="#990000"> =  <font color="#000000">gtk_label_new   <font color="#990000">(  <font color="#FF0000">"Page 2"  <font color="#990000">); entry_3 <font color="#990000"> =  <font color="#000000">hildon_entry_new   <font color="#990000">( HILDON_SIZE_AUTO <font color="#990000">);  <font color="#000000">hildon_entry_set_placeholder  <font color="#990000">(   <font color="#000000">HILDON_ENTRY   <font color="#990000">( entry_3 <font color="#990000">),                                    <font color="#FF0000">" Write something to continue"  <font color="#990000">); label_4 <font color="#990000"> =  <font color="#000000">gtk_label_new   <font color="#990000">(  <font color="#FF0000">"Page 4"  <font color="#990000">);  <font color="#9A1900">/* Append pages */   <font color="#000000">gtk_notebook_append_page  <font color="#990000">(   <font color="#000000">GTK_NOTEBOOK   <font color="#990000">( notebook <font color="#990000">), label_1 <font color="#990000">, NULL <font color="#990000">);  <font color="#000000">gtk_notebook_append_page  <font color="#990000">(   <font color="#000000">GTK_NOTEBOOK   <font color="#990000">( notebook <font color="#990000">), label_2 <font color="#990000">, NULL <font color="#990000">);  <font color="#000000">gtk_notebook_append_page  <font color="#990000">(   <font color="#000000">GTK_NOTEBOOK   <font color="#990000">( notebook <font color="#990000">), entry_3 <font color="#990000">, NULL <font color="#990000">);  <font color="#000000">gtk_notebook_append_page  <font color="#990000">(   <font color="#000000">GTK_NOTEBOOK   <font color="#990000">( notebook <font color="#990000">), label_4 <font color="#990000">, NULL <font color="#990000">);  <font color="#9A1900">/* Create wizard dialog */  dialog <font color="#990000"> =  <font color="#000000">hildon_wizard_dialog_new   <font color="#990000">( NULL <font color="#990000">,  <font color="#FF0000">"Wizard"  <font color="#990000">,                                          <font color="#000000">GTK_NOTEBOOK   <font color="#990000">( notebook <font color="#990000">));  <font color="#9A1900">/* Set a handler for "switch-page" signal */   <font color="#000000">g_signal_connect  <font color="#990000">(   <font color="#000000">G_OBJECT   <font color="#990000">( notebook <font color="#990000">),                        <font color="#FF0000">"switch-page"  <font color="#990000">,                         <font color="#000000">G_CALLBACK   <font color="#990000">( on_page_switch <font color="#990000">),                        dialog <font color="#990000">);  <font color="#9A1900">/* Set a function to decide if user can go to next page */   <font color="#000000">hildon_wizard_dialog_set_forward_page_func  <font color="#990000">(   <font color="#000000">HILDON_WIZARD_DIALOG   <font color="#990000">( dialog <font color="#990000">),                                                  some_page_func <font color="#990000">, NULL <font color="#990000">, NULL <font color="#990000">);  <font color="#000000">gtk_widget_show_all  <font color="#990000">( dialog <font color="#990000">);  <font color="#000000">gtk_dialog_run  <font color="#990000">(   <font color="#000000">GTK_DIALOG   <font color="#990000">( dialog <font color="#990000">));  <font color="#0000FF">return  <font color="#993399">0  <font color="#990000"> ; <font color="#FF0000">} </tt>

Apart from how to create and use a wizard dialog, this example also sets up a handler to catch the signal "switch-page" from the notepad. This signal is emitted by the widget GtkNotebook when the user or a function changes the current page.

Using GtkDialogs in Hildon applications
In general, you can use GtkDialog much like you would use it in a GTK+ application, but you have to take into account the following:


 * In Hildon applications, buttons "cancel", "reject" and "close" are allowed. However, buttons which emit the signal "response" with GTK_RESPONSE_CANCEL, GTK_RESPONSE_REJECT or GTK_RESPONSE_CLOSE as the response's identifier are not displayed. Therefore, if you need to deal with the action of closing a GtkDialog in a Hildon application, you need to be aware of this detail and to handle the GTK_RESPONSE_DELETE_EVENT response identifier properly.
 * Another detail to take care of is that GtkDialogs can work in two modalities in a Hildon application: task-model or system-model. A dialog is task-modal if it is transient for the main window. That is the case when the function  is used or the dialog was created by calling gtk_dialog_new_with_buttons specifying a parent window. Otherwise, the dialog is system-modal.

If the dialog is task-modal, the Platform UI (Task button and Status area) are visible on top and can be used normally to switch between tasks.

If the dialog is system-modal, both the task button and status area are blurred and dimmed. They are not active while the dialog is open and task switching is not possible until it closes.

The following is an example for creating a task-modal dialog.

'''Example 2.6. Application modal dialog example'''

<tt>  <font color="#000080"> #include  <font color="#FF0000">&lt;hildon/hildon.h&gt; <font color="#009900">int  <font color="#000000">main                                            <font color="#990000">(  <font color="#009900">int argc <font color="#990000">,                                                   <font color="#009900">char  <font color="#990000"> ** argv <font color="#990000">) <font color="#FF0000">{ GtkWidget <font color="#990000"> * dialog <font color="#990000"> ; GtkWidget <font color="#990000"> * win <font color="#990000"> ;  <font color="#000000">hildon_gtk_init  <font color="#990000">(&amp; argc <font color="#990000">,  <font color="#990000">&amp; argv <font color="#990000">); win <font color="#990000"> =  <font color="#000000">hildon_stackable_window_new   <font color="#990000">  <font color="#990000"> ;  <font color="#000000">gtk_widget_show  <font color="#990000">( win <font color="#990000">); dialog <font color="#990000"> =  <font color="#000000">gtk_dialog_new   <font color="#990000">;  <font color="#000000">gtk_window_set_transient_for  <font color="#990000">(   <font color="#000000">GTK_WINDOW   <font color="#990000">( dialog <font color="#990000">),                                    <font color="#000000">GTK_WINDOW   <font color="#990000">( win <font color="#990000">));  <font color="#000000">gtk_window_set_title  <font color="#990000">(   <font color="#000000">GTK_WINDOW   <font color="#990000">( dialog <font color="#990000">),  <font color="#FF0000">"Hello!"  <font color="#990000">);  <font color="#000000">gtk_widget_show_all  <font color="#990000">(   <font color="#000000">GTK_WIDGET   <font color="#990000">( dialog <font color="#990000">));  <font color="#000000">gtk_dialog_run  <font color="#990000">(   <font color="#000000">GTK_DIALOG   <font color="#990000">( dialog <font color="#990000">));  <font color="#0000FF">return  <font color="#993399">0  <font color="#990000"> ; <font color="#FF0000">} </tt>