* Remove cancel button in move to folder dialog.
[modest] / src / widgets / modest-wizard-dialog.c
1 /* Copyright (c) 2006, Nokia Corporation
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  *   notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  *   notice, this list of conditions and the following disclaimer in the
12  *   documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Nokia Corporation nor the names of its
14  *   contributors may be used to endorse or promote products derived from
15  *   this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 /**
31  * SECTION:modest-wizard-dialog
32  * @short_description: A widget to create a guided installation
33  * process wizard
34  *
35  * #ModestWizardDialog is a widget to create a guided installation
36  * process. The dialog has four standard buttons, previous, next,
37  * finish, cancel, and contains several pages with optional icons.
38  * Response buttons are dimmed/undimmed automatically and the standard
39  * icon is shown/hidden in response to page navigation. The notebook
40  * widget provided by users contains the actual wizard pages.
41  */
42
43 #include <config.h>
44 #include <gtk/gtkdialog.h>
45 #include <gtk/gtknotebook.h>
46 #include <gtk/gtkimage.h>
47 #include <gtk/gtkbox.h>
48 #include <gtk/gtkhbox.h>
49 #include <gtk/gtkvbox.h>
50 #include <gtk/gtkbutton.h>
51 #include <gtk/gtk.h>
52
53 #ifdef HAVE_CONFIG_H
54 #include <config.h>
55 #endif
56
57 #ifndef MODEST_TOOLKIT_GTK
58 #if MODEST_HILDON_API == 0
59 #include <hildon-widgets/hildon-defines.h>
60 #else
61 #include <hildon/hildon-defines.h>
62 #endif /*MODEST_HILDON_API == 0*/
63 #endif /*!MODEST_TOOLKIT_GTK*/
64
65 #include "modest-wizard-dialog.h"
66 #include "modest-debug.h"
67 #include "modest-text-utils.h"
68
69 static GtkDialogClass *parent_class;
70
71 static void class_init              (ModestWizardDialogClass   *wizard_dialog_class);
72
73 static void init                    (ModestWizardDialog        *wizard_dialog);
74
75 static void create_title            (ModestWizardDialog        *wizard_dialog);
76
77 static void set_property            (GObject                   *object,
78                                      guint                     property_id,
79                                      const GValue              *value,
80                                      GParamSpec                *pspec);
81
82 static void get_property            (GObject                   *object,
83                                      guint                     property_id,
84                                      GValue                    *value,
85                                      GParamSpec                *pspec);
86
87 static void finalize                (GObject                   *object);
88
89 static void response                (ModestWizardDialog        *wizard, 
90                                      gint                      response_id,
91                                      gpointer                  unused);
92
93 static void make_buttons_sensitive  (ModestWizardDialog *wizard_dialog,
94                                      gboolean           previous,
95                                      gboolean           finish,
96                                      gboolean next);
97                                      
98 static gboolean invoke_before_next_vfunc (ModestWizardDialog *wizard_dialog);
99 static void invoke_enable_buttons_vfunc (ModestWizardDialog *wizard_dialog);
100
101 enum {
102     PROP_ZERO,
103     PROP_WIZARD_NAME,
104     PROP_WIZARD_NOTEBOOK,
105     PROP_WIZARD_AUTOTITLE
106 };
107
108 struct _ModestWizardDialogPrivate {
109     gchar       *wizard_name;
110     GtkNotebook *notebook;
111     GtkBox      *box;
112     GtkWidget   *image;
113     gboolean    autotitle;
114 };
115
116
117 GType
118 modest_wizard_dialog_get_type (void)
119 {
120     static GType wizard_dialog_type = 0;
121
122     if (!wizard_dialog_type) {
123
124         static const GTypeInfo wizard_dialog_info = {
125             sizeof (ModestWizardDialogClass),
126             NULL,       /* base_init      */
127             NULL,       /* base_finalize  */
128             (GClassInitFunc) class_init,
129             NULL,       /* class_finalize */
130             NULL,       /* class_data     */
131             sizeof (ModestWizardDialog),
132             0,          /* n_preallocs    */
133             (GInstanceInitFunc) init,
134         };
135
136         wizard_dialog_type = g_type_register_static (GTK_TYPE_DIALOG,
137                                                      "ModestWizardDialog",
138                                                      &wizard_dialog_info,
139                                                      0);
140     }
141
142     return wizard_dialog_type;
143 }
144
145 static void
146 class_init (ModestWizardDialogClass *wizard_dialog_class)
147 {
148     GObjectClass *object_class = G_OBJECT_CLASS (wizard_dialog_class);
149
150     parent_class = g_type_class_peek_parent (wizard_dialog_class);
151
152     g_type_class_add_private (wizard_dialog_class,
153                               sizeof(ModestWizardDialogPrivate));
154
155     /* Override virtual methods */
156     object_class->set_property = set_property;
157     object_class->get_property = get_property;
158     object_class->finalize     = finalize;
159
160     /**
161      * ModestWizardDialog:wizard-name:
162      *
163      * The name of the wizard.
164      */
165     g_object_class_install_property (object_class, PROP_WIZARD_NAME,
166             g_param_spec_string 
167             ("wizard-name",
168              "Wizard Name",
169              "The name of the ModestWizardDialog",
170              NULL,
171              G_PARAM_READWRITE));
172
173     /**
174      * ModestWizardDialog:wizard-notebook:
175      *
176      * The notebook object, which is used by the ModestWizardDialog.
177      */
178     g_object_class_install_property(object_class, PROP_WIZARD_NOTEBOOK,
179             g_param_spec_object 
180             ("wizard-notebook",
181              "Wizard Notebook",
182              "GtkNotebook object to be used in the "
183              "ModestWizardDialog",
184              GTK_TYPE_NOTEBOOK, G_PARAM_READWRITE));
185
186     /**
187      * ModestWizardDialog:autotitle
188      *
189      * If the wizard should automatically try to change the window title when changing steps. 
190      * Set to FALSE if you'd like to override the default behaviour. 
191      *
192      * Since: 0.14.5 
193      */
194     g_object_class_install_property(object_class, PROP_WIZARD_AUTOTITLE,
195             g_param_spec_boolean 
196             ("autotitle",
197              "AutoTitle",
198              "If the wizard should autotitle itself",
199              TRUE, 
200              G_PARAM_READWRITE));
201 }
202
203 static void 
204 finalize (GObject *object)
205 {
206     ModestWizardDialog *dialog = MODEST_WIZARD_DIALOG (object);
207     g_return_if_fail (dialog != NULL);
208
209     if (dialog->priv->wizard_name != NULL)
210         g_free (MODEST_WIZARD_DIALOG (object)->priv->wizard_name);
211     
212     if (G_OBJECT_CLASS (parent_class)->finalize)
213         G_OBJECT_CLASS (parent_class)->finalize(object);
214 }
215
216 /* Disable or enable the Previous, Next and Finish buttons */
217 static void
218 make_buttons_sensitive (ModestWizardDialog *wizard_dialog,
219                         gboolean previous,
220                         gboolean finish,
221                         gboolean next)
222 {
223     gtk_dialog_set_response_sensitive (GTK_DIALOG (wizard_dialog),
224                                        MODEST_WIZARD_DIALOG_PREVIOUS,
225                                        previous);
226
227     gtk_dialog_set_response_sensitive (GTK_DIALOG (wizard_dialog),
228                                        MODEST_WIZARD_DIALOG_FINISH,
229                                        finish);
230
231     gtk_dialog_set_response_sensitive (GTK_DIALOG (wizard_dialog),
232                                        MODEST_WIZARD_DIALOG_NEXT,
233                                        next);
234 }
235
236 static void 
237 init (ModestWizardDialog *wizard_dialog)
238 {
239     /* Initialize private structure for faster member access */
240     ModestWizardDialogPrivate *priv =
241         G_TYPE_INSTANCE_GET_PRIVATE (wizard_dialog,
242                 MODEST_TYPE_WIZARD_DIALOG,
243                 ModestWizardDialogPrivate);
244
245     GtkDialog *dialog = GTK_DIALOG (wizard_dialog);
246
247     /* Init internal widgets */
248     GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
249     gtk_dialog_set_has_separator (dialog, FALSE);
250     wizard_dialog->priv = priv;
251     priv->box = GTK_BOX (gtk_hbox_new (FALSE, 0));
252 #ifdef MODEST_TOOLKIT_HILDON2
253     priv->image = NULL;
254 #else
255 #ifdef MODEST_TOOLKIT_GTK
256     priv->image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_DIALOG);
257 #else /*MODEST_TOOLKIT_GTK*/
258 #if MODEST_HILDON_API == 0
259     priv->image = gtk_image_new_from_icon_name ("qgn_widg_wizard",
260                                                 HILDON_ICON_SIZE_WIDG_WIZARD);
261 #else       
262     static int icon_size = 0;
263     if (!icon_size)
264             icon_size = gtk_icon_size_register("modest_wizard", 50, 50);
265     priv->image = gtk_image_new_from_icon_name ("qgn_widg_wizard",
266                                                 icon_size);
267 #endif /*MODEST_HILDON_API == 0*/
268 #endif /*!MODEST_TOOLKIT_GTK*/
269 #endif /*MODEST_TOOLKIT_HILDON2 */
270     /* Default values for user provided properties */
271     priv->notebook = NULL;
272     priv->wizard_name = NULL;
273     priv->autotitle = TRUE;
274
275     /* Build wizard layout */
276     gtk_box_pack_start_defaults (GTK_BOX (dialog->vbox), GTK_WIDGET (priv->box));
277     gtk_box_pack_start_defaults (GTK_BOX (priv->box), GTK_WIDGET (vbox));
278     if (priv->image)
279       gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (priv->image), FALSE, FALSE, 0);
280
281     /* Add response buttons: finish, previous, next, cancel */
282 #ifdef MODEST_TOOLKIT_HILDON1
283     gtk_dialog_add_button (dialog, _HL("ecdg_bd_wizard_finish"), MODEST_WIZARD_DIALOG_FINISH);
284     gtk_dialog_add_button (dialog, _HL("ecdg_bd_wizard_previous"), MODEST_WIZARD_DIALOG_PREVIOUS);
285     gtk_dialog_add_button (dialog, _HL("ecdg_bd_wizard_next"), MODEST_WIZARD_DIALOG_NEXT);
286     gtk_dialog_add_button (dialog, _HL("ecdg_bd_wizard_cancel"), MODEST_WIZARD_DIALOG_CANCEL);
287 #endif
288 #ifdef MODEST_TOOLKIT_HILDON2
289     gtk_dialog_add_button (dialog, _HL("wdgt_bd_finish"), MODEST_WIZARD_DIALOG_FINISH);
290     gtk_dialog_add_button (dialog, _HL("wdgt_bd_previous"), MODEST_WIZARD_DIALOG_PREVIOUS);
291     gtk_dialog_add_button (dialog, _HL("wdgt_bd_next"), MODEST_WIZARD_DIALOG_NEXT);
292 #endif
293 #ifdef MODEST_TOOLKIT_GTK
294     gtk_dialog_add_button (dialog, GTK_STOCK_SAVE, MODEST_WIZARD_DIALOG_FINISH);
295     gtk_dialog_add_button (dialog, GTK_STOCK_GO_BACK, MODEST_WIZARD_DIALOG_PREVIOUS);
296     gtk_dialog_add_button (dialog, GTK_STOCK_GO_FORWARD, MODEST_WIZARD_DIALOG_NEXT);
297     gtk_dialog_add_button (dialog, GTK_STOCK_CANCEL, MODEST_WIZARD_DIALOG_CANCEL);
298 #endif
299
300     /* Set initial button states: previous and finish buttons are disabled */
301     make_buttons_sensitive (wizard_dialog, FALSE, FALSE, TRUE);
302
303     /* Show all the internal widgets */
304     gtk_widget_show_all (GTK_WIDGET (dialog->vbox));
305
306     /* connect to dialog's response signal */
307     g_signal_connect (G_OBJECT (dialog), "response",
308             G_CALLBACK (response), NULL);
309 }
310
311 #if GTK_CHECK_VERSION(2, 10, 0) /* These signals were added in GTK+ 2.10: */
312 static void on_notebook_page_added(GtkNotebook *notebook, 
313                                    GtkWidget   *child,
314                                    guint        page_num,
315                                    gpointer     user_data)
316 {
317         ModestWizardDialog* dialog = NULL;
318
319         g_return_if_fail (MODEST_IS_WIZARD_DIALOG(user_data));
320         dialog = MODEST_WIZARD_DIALOG(user_data);
321
322         /* The title should show the total number of pages: */
323         create_title (dialog);
324 }
325
326 static void on_notebook_page_removed(GtkNotebook *notebook, 
327                                      GtkWidget   *child,
328                                      guint        page_num,
329                                      gpointer     user_data)
330 {
331         ModestWizardDialog* dialog = NULL;
332
333         g_return_if_fail (MODEST_IS_WIZARD_DIALOG(user_data));
334         dialog = MODEST_WIZARD_DIALOG(user_data);
335
336         /* The title should show the total number of pages: */
337         create_title (dialog);
338 }
339 #endif /* GTK_CHECK_VERSION */
340
341 static void
342 connect_to_notebook_signals(ModestWizardDialog* dialog)
343 {
344 #if GTK_CHECK_VERSION(2, 10, 0) /* These signals were added in GTK+ 2.10: */
345         ModestWizardDialogPrivate *priv = MODEST_WIZARD_DIALOG(dialog)->priv;
346         g_return_if_fail (priv->notebook);
347         
348         /* Connect to the notebook signals,
349          * so we can update the title when necessary: */
350         g_signal_connect (G_OBJECT (priv->notebook), "page-added",
351                       G_CALLBACK (on_notebook_page_added), dialog);
352         g_signal_connect (G_OBJECT (priv->notebook), "page-removed",
353                       G_CALLBACK (on_notebook_page_removed), dialog);
354 #endif /* GTK_CHECK_VERSION */
355 }
356
357
358 static void
359 set_property (GObject      *object, 
360               guint        property_id,
361               const GValue *value, 
362               GParamSpec   *pspec)
363 {
364     ModestWizardDialogPrivate *priv = MODEST_WIZARD_DIALOG(object)->priv;
365
366     switch (property_id) {
367
368         case PROP_WIZARD_AUTOTITLE:
369
370             priv->autotitle = g_value_get_boolean (value);
371
372             if (priv->autotitle && 
373                 priv->wizard_name && 
374                 priv->notebook)
375                 create_title (MODEST_WIZARD_DIALOG (object));
376             else if (priv->wizard_name)
377                 gtk_window_set_title (GTK_WINDOW (object), priv->wizard_name);
378             
379             break;
380
381         case PROP_WIZARD_NAME: 
382
383             /* Set new wizard name. This name will appear in titlebar */
384             if (priv->wizard_name)
385                 g_free (priv->wizard_name);
386
387             gchar *str = (gchar *) g_value_get_string (value);
388             g_return_if_fail (str != NULL);
389
390             priv->wizard_name = g_strdup (str);
391
392             /* We need notebook in order to create title, since page information
393                is used in title generation */
394             
395             if (priv->notebook && priv->autotitle)
396                 create_title (MODEST_WIZARD_DIALOG (object));
397     
398             break;
399
400         case PROP_WIZARD_NOTEBOOK: {
401
402             GtkNotebook *book = GTK_NOTEBOOK (g_value_get_object (value));
403             g_return_if_fail (book != NULL);
404
405             priv->notebook = book;
406
407             /* Set the default properties for the notebook (disable tabs,
408              * and remove borders) to make it look like a nice wizard widget */
409             gtk_notebook_set_show_tabs (priv->notebook, FALSE);
410             gtk_notebook_set_show_border (priv->notebook, FALSE);
411             gtk_box_pack_start_defaults (GTK_BOX( priv->box), GTK_WIDGET (priv->notebook));
412
413             /* Show the notebook so that a gtk_widget_show on the dialog is
414              * all that is required to display the dialog correctly */
415             gtk_widget_show ( GTK_WIDGET (priv->notebook));
416
417             /* Update dialog title to reflect current page stats etc */ 
418             ModestWizardDialog *wizard_dialog = MODEST_WIZARD_DIALOG (object);      
419             if (priv->wizard_name && priv->autotitle)
420                 create_title (wizard_dialog);
421                 
422             connect_to_notebook_signals (wizard_dialog);
423             
424             }break;
425
426         default:
427             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
428             break;
429     }
430 }
431
432 static void
433 get_property (GObject      *object,
434               guint        property_id,
435               GValue       *value,
436               GParamSpec   *pspec)
437 {
438     ModestWizardDialogPrivate *priv = MODEST_WIZARD_DIALOG (object)->priv;
439
440     switch (property_id) {
441
442         case PROP_WIZARD_NAME:
443             g_value_set_string (value, priv->wizard_name);
444             break;
445
446         case PROP_WIZARD_NOTEBOOK:
447             g_value_set_object (value, priv->notebook);
448             break;
449
450         default:
451             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
452             break;
453     }
454 }
455
456 /*
457  * Creates the title of the dialog taking into account the current 
458  * page of the notebook.
459  */
460 static void
461 create_title (ModestWizardDialog *wizard_dialog)
462 {
463     gchar *str = NULL;
464     ModestWizardDialogPrivate *priv = NULL;
465     GtkNotebook *notebook = NULL;
466
467     g_return_if_fail (MODEST_IS_WIZARD_DIALOG(wizard_dialog));
468     g_return_if_fail (wizard_dialog->priv != NULL);
469
470     priv = wizard_dialog->priv;    
471     notebook = priv->notebook;
472
473     if (!notebook)
474         return;
475
476     /* Get page information, we'll need that when creating title */
477     gint pages = gtk_notebook_get_n_pages (notebook);
478     if (pages == 0)
479       return;
480         
481     gint current = gtk_notebook_get_current_page (priv->notebook);
482     if (current < 0)
483         current = 0;
484
485     /* the welcome title on the initial page */
486     /* This is the standard wizard title, with, e.g., 1/4 at the end,
487          * but the Modest UI spec does not want this. */
488         /*
489     if (current == 0) {
490         str = g_strdup_printf (_HL("ecdg_ti_wizard_welcome"), 
491                 priv->wizard_name, pages);
492     } else {
493     */
494         const gchar *steps = gtk_notebook_get_tab_label_text (notebook,
495                 gtk_notebook_get_nth_page (notebook, current));
496                 
497                 /* This is the standard wizard title, with, e.g., 1/4 at the end,
498                  * but the Modest UI spec does not want this.
499                  */
500                 /*
501         str = g_strdup_printf (_HL("ecdg_ti_wizard_step"), 
502                 priv->wizard_name, current + 1, pages, steps);
503         */
504
505         str = g_strdup_printf (_HL("%s: %s"), 
506                 priv->wizard_name, steps);
507     /* } */
508
509     /* Update the dialog to display the generated title */
510     gtk_window_set_title (GTK_WINDOW (wizard_dialog), str);
511     g_free (str);
512 }
513
514 /*
515  * Response signal handler. This function is needed because GtkDialog's 
516  * handler for this signal closes the dialog and we don't want that, we 
517  * want to change pages and, dim certain response buttons. Overriding the 
518  * virtual function would not work because that would be called after the 
519  * signal handler implemented by GtkDialog.
520  * FIXME: There is a much saner way to do that [MDK]
521  */
522 static void 
523 response (ModestWizardDialog   *wizard_dialog,
524           gint                 response_id,
525           gpointer             unused)
526 {
527     ModestWizardDialogPrivate *priv = wizard_dialog->priv;
528     GtkNotebook *notebook = priv->notebook;
529     gint current = 0;
530     gboolean is_first, is_last;
531     
532     switch (response_id) {
533         
534         case MODEST_WIZARD_DIALOG_PREVIOUS:
535             gtk_notebook_prev_page (notebook); /* go to previous page */
536             break;
537
538         case MODEST_WIZARD_DIALOG_NEXT:
539                 if (invoke_before_next_vfunc (wizard_dialog))
540                         gtk_notebook_next_page (notebook); /* go to next page */
541                 
542             break;
543
544         case MODEST_WIZARD_DIALOG_CANCEL:
545                 return;
546                 break;      
547         case MODEST_WIZARD_DIALOG_FINISH:
548                 if (invoke_before_next_vfunc (wizard_dialog))
549                 return;
550             
551             break;
552
553     }
554
555     current = gtk_notebook_get_current_page (notebook);
556     gint last = gtk_notebook_get_n_pages (notebook) - 1;
557     is_last = current == last;
558     is_first = current == 0;
559     
560     /* If first page, previous and finish are disabled, 
561        if last page, next is disabled */
562     make_buttons_sensitive (wizard_dialog,
563             !is_first /* previous */, !is_first /* finish */, !is_last /* next*/);
564             
565     /* Allow derived classes to disable buttons to prevent navigation,
566      * according to their own validation logic: */
567     invoke_enable_buttons_vfunc (wizard_dialog);
568     
569     /* Don't let the dialog close */
570     g_signal_stop_emission_by_name (wizard_dialog, "response");
571
572     /* We show the default image on first and last pages */
573     last = gtk_notebook_get_n_pages (notebook) - 1;
574     if (priv->image) {
575             if (current == last || current == 0)
576                     gtk_widget_show (GTK_WIDGET(priv->image));
577             else
578                     gtk_widget_hide (GTK_WIDGET(priv->image));
579     }
580
581     /* New page number may appear in the title, update it */
582     if (priv->autotitle) 
583         create_title (wizard_dialog);
584 }
585
586 /**
587  * modest_wizard_dialog_new:
588  * @parent: a #GtkWindow
589  * @wizard_name: the name of dialog
590  * @notebook: the notebook to be shown on the dialog
591  *
592  * Creates a new #ModestWizardDialog.
593  *
594  * Returns: a new #ModestWizardDialog
595  */
596 GtkWidget*
597 modest_wizard_dialog_new (GtkWindow   *parent,
598                           const char  *wizard_name,
599                           GtkNotebook *notebook)
600 {
601     GtkWidget *widget;
602
603     g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL);
604
605     widget = GTK_WIDGET (g_object_new
606             (MODEST_TYPE_WIZARD_DIALOG,
607              "wizard-name", wizard_name,
608              "wizard-notebook", notebook, NULL));
609
610     if (parent)
611         gtk_window_set_transient_for (GTK_WINDOW (widget), parent);
612
613     return widget;
614 }
615
616 /**
617  * modest_wizard_dialog_force_title_update:
618  * @wizard_dialog: The wizard dialog
619  *
620  * Force the title to be rebuilt, for instance when you have added or 
621  * removed notebook pages. This function is not necessary when using GTK+ 2.10, 
622  * because that has GtkNotebook signals that will be used to update the title 
623  * automatically.
624  */
625 void
626 modest_wizard_dialog_force_title_update (ModestWizardDialog   *wizard_dialog)
627 {
628         create_title (wizard_dialog);
629 }
630
631 static gboolean
632 invoke_before_next_vfunc (ModestWizardDialog *wizard_dialog)
633 {
634         ModestWizardDialogClass *klass = MODEST_WIZARD_DIALOG_GET_CLASS (wizard_dialog);
635         
636         /* Call the vfunc, which may be overridden by derived classes: */
637         if (klass->before_next) {
638                 ModestWizardDialogPrivate *priv = MODEST_WIZARD_DIALOG(wizard_dialog)->priv;
639         
640                 gint current_page_num = gtk_notebook_get_current_page (priv->notebook);
641                 
642                 /* Get widgets for the two pages: */
643                 GtkWidget* current_page_widget = gtk_notebook_get_nth_page (priv->notebook, current_page_num);
644                 
645                 GtkWidget* next_page_widget = NULL;
646                 if ((current_page_num + 1) < gtk_notebook_get_n_pages (priv->notebook))
647                         next_page_widget = gtk_notebook_get_nth_page (priv->notebook, current_page_num + 1);
648
649                 MODEST_DEBUG_BLOCK (
650                 g_debug ("Switching to page %d (%s)",
651                          gtk_notebook_page_num (priv->notebook, next_page_widget),
652                          gtk_notebook_get_tab_label_text (priv->notebook, next_page_widget));
653
654                 {
655                         GtkWidget *p;
656                         gint i;
657                         g_debug ("\t***************");
658                         for (i=0; i<gtk_notebook_get_n_pages(priv->notebook);i++) {
659                                 p = gtk_notebook_get_nth_page (priv->notebook, i);
660                                 g_debug ("\t%d - %s", i, gtk_notebook_get_tab_label_text (priv->notebook, p));
661                         }
662                         g_debug ("\t***************");
663                 }
664                                     );
665                 
666                 /* Ask the vfunc implementation whether navigation should be allowed: */
667                 return (*(klass->before_next))(wizard_dialog, current_page_widget, next_page_widget);
668         }
669         
670         /* Allow navigation by default if there is no vfunc implementation: */
671         return TRUE;
672 }
673
674 static void
675 invoke_enable_buttons_vfunc (ModestWizardDialog *wizard_dialog)
676 {
677         ModestWizardDialogClass *klass = MODEST_WIZARD_DIALOG_GET_CLASS (wizard_dialog);
678         
679         /* Call the vfunc, which may be overridden by derived classes: */
680         if (klass->enable_buttons) {
681                 ModestWizardDialogPrivate *priv = MODEST_WIZARD_DIALOG(wizard_dialog)->priv;
682         
683                 gint current_page_num = gtk_notebook_get_current_page (priv->notebook);
684                 
685                 GtkWidget* current_page_widget = gtk_notebook_get_nth_page (priv->notebook, current_page_num);
686                         
687                 (*(klass->enable_buttons))(wizard_dialog, current_page_widget);
688         }
689 }