8af9e34dc07a09be02f7ef5934d2757a30c5f23e
[modest] / src / maemo / easysetup / 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 #ifdef MODEST_HILDON_VERSION_0
58 #include <hildon-widgets/hildon-defines.h>
59 #else
60 #include <hildon/hildon-defines.h>
61 #endif /*MODEST_HILDON_VERSION_0*/
62
63 #include "modest-wizard-dialog.h"
64
65 #include <libintl.h>
66
67 /* Specify the hildon-libs translation domain,
68  * so we can reuse its translations 
69  * instead of repeating them in our own translations.
70  */
71 /* #define _(String) dgettext(PACKAGE, String) */
72
73 #define _(String) dgettext("hildon-libs", String)
74
75 static GtkDialogClass *parent_class;
76
77 static void class_init              (ModestWizardDialogClass   *wizard_dialog_class);
78
79 static void init                    (ModestWizardDialog        *wizard_dialog);
80
81 static void create_title            (ModestWizardDialog        *wizard_dialog);
82
83 static void set_property            (GObject                   *object,
84                                      guint                     property_id,
85                                      const GValue              *value,
86                                      GParamSpec                *pspec);
87
88 static void get_property            (GObject                   *object,
89                                      guint                     property_id,
90                                      GValue                    *value,
91                                      GParamSpec                *pspec);
92
93 static void finalize                (GObject                   *object);
94
95 static void response                (ModestWizardDialog        *wizard, 
96                                      gint                      response_id,
97                                      gpointer                  unused);
98
99 static void make_buttons_sensitive  (ModestWizardDialog *wizard_dialog,
100                                      gboolean           previous,
101                                      gboolean           finish,
102                                      gboolean next);
103                                      
104 static gboolean invoke_before_next_vfunc (ModestWizardDialog *wizard_dialog);
105 static void invoke_enable_buttons_vfunc (ModestWizardDialog *wizard_dialog);
106
107 enum {
108     PROP_ZERO,
109     PROP_WIZARD_NAME,
110     PROP_WIZARD_NOTEBOOK,
111     PROP_WIZARD_AUTOTITLE
112 };
113
114 struct _ModestWizardDialogPrivate {
115     gchar       *wizard_name;
116     GtkNotebook *notebook;
117     GtkBox      *box;
118     GtkWidget   *image;
119     gboolean    autotitle;
120 };
121
122
123 GType
124 modest_wizard_dialog_get_type (void)
125 {
126     static GType wizard_dialog_type = 0;
127
128     if (!wizard_dialog_type) {
129
130         static const GTypeInfo wizard_dialog_info = {
131             sizeof (ModestWizardDialogClass),
132             NULL,       /* base_init      */
133             NULL,       /* base_finalize  */
134             (GClassInitFunc) class_init,
135             NULL,       /* class_finalize */
136             NULL,       /* class_data     */
137             sizeof (ModestWizardDialog),
138             0,          /* n_preallocs    */
139             (GInstanceInitFunc) init,
140         };
141
142         wizard_dialog_type = g_type_register_static (GTK_TYPE_DIALOG,
143                                                      "ModestWizardDialog",
144                                                      &wizard_dialog_info,
145                                                      0);
146     }
147
148     return wizard_dialog_type;
149 }
150
151 static void
152 class_init (ModestWizardDialogClass *wizard_dialog_class)
153 {
154     GObjectClass *object_class = G_OBJECT_CLASS (wizard_dialog_class);
155
156     parent_class = g_type_class_peek_parent (wizard_dialog_class);
157
158     g_type_class_add_private (wizard_dialog_class,
159                               sizeof(ModestWizardDialogPrivate));
160
161     /* Override virtual methods */
162     object_class->set_property = set_property;
163     object_class->get_property = get_property;
164     object_class->finalize     = finalize;
165
166     /**
167      * ModestWizardDialog:wizard-name:
168      *
169      * The name of the wizard.
170      */
171     g_object_class_install_property (object_class, PROP_WIZARD_NAME,
172             g_param_spec_string 
173             ("wizard-name",
174              "Wizard Name",
175              "The name of the ModestWizardDialog",
176              NULL,
177              G_PARAM_READWRITE));
178
179     /**
180      * ModestWizardDialog:wizard-notebook:
181      *
182      * The notebook object, which is used by the ModestWizardDialog.
183      */
184     g_object_class_install_property(object_class, PROP_WIZARD_NOTEBOOK,
185             g_param_spec_object 
186             ("wizard-notebook",
187              "Wizard Notebook",
188              "GtkNotebook object to be used in the "
189              "ModestWizardDialog",
190              GTK_TYPE_NOTEBOOK, G_PARAM_READWRITE));
191
192     /**
193      * ModestWizardDialog:autotitle
194      *
195      * If the wizard should automatically try to change the window title when changing steps. 
196      * Set to FALSE if you'd like to override the default behaviour. 
197      *
198      * Since: 0.14.5 
199      */
200     g_object_class_install_property(object_class, PROP_WIZARD_AUTOTITLE,
201             g_param_spec_boolean 
202             ("autotitle",
203              "AutoTitle",
204              "If the wizard should autotitle itself",
205              TRUE, 
206              G_PARAM_READWRITE));
207 }
208
209 static void 
210 finalize (GObject *object)
211 {
212     ModestWizardDialog *dialog = MODEST_WIZARD_DIALOG (object);
213     g_return_if_fail (dialog != NULL);
214
215     if (dialog->priv->wizard_name != NULL)
216         g_free (MODEST_WIZARD_DIALOG (object)->priv->wizard_name);
217     
218     if (G_OBJECT_CLASS (parent_class)->finalize)
219         G_OBJECT_CLASS (parent_class)->finalize(object);
220 }
221
222 /* Disable or enable the Previous, Next and Finish buttons */
223 static void
224 make_buttons_sensitive (ModestWizardDialog *wizard_dialog,
225                         gboolean previous,
226                         gboolean finish,
227                         gboolean next)
228 {
229     gtk_dialog_set_response_sensitive (GTK_DIALOG (wizard_dialog),
230                                        MODEST_WIZARD_DIALOG_PREVIOUS,
231                                        previous);
232
233     gtk_dialog_set_response_sensitive (GTK_DIALOG (wizard_dialog),
234                                        MODEST_WIZARD_DIALOG_FINISH,
235                                        finish);
236
237     gtk_dialog_set_response_sensitive (GTK_DIALOG (wizard_dialog),
238                                        MODEST_WIZARD_DIALOG_NEXT,
239                                        next);
240 }
241
242 static void 
243 init (ModestWizardDialog *wizard_dialog)
244 {
245     /* Initialize private structure for faster member access */
246     ModestWizardDialogPrivate *priv =
247         G_TYPE_INSTANCE_GET_PRIVATE (wizard_dialog,
248                 MODEST_TYPE_WIZARD_DIALOG,
249                 ModestWizardDialogPrivate);
250
251     GtkDialog *dialog = GTK_DIALOG (wizard_dialog);
252
253     /* Init internal widgets */
254     GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
255     gtk_dialog_set_has_separator (dialog, FALSE);
256     wizard_dialog->priv = priv;
257     priv->box = GTK_BOX (gtk_hbox_new (FALSE, 0));
258 #ifdef MODEST_HILDON_VERSION_0
259     priv->image = gtk_image_new_from_icon_name ("qgn_widg_wizard",
260                                                 HILDON_ICON_SIZE_WIDG_WIZARD);
261 #else
262     priv->image = gtk_image_new_from_icon_name ("qgn_widg_wizard",
263                                                 HILDON_ICON_SIZE_WIZARD);
264 #endif /*MODEST_HILDON_VERSION_0*/
265     /* Default values for user provided properties */
266     priv->notebook = NULL;
267     priv->wizard_name = NULL;
268     priv->autotitle = TRUE;
269
270     /* Build wizard layout */
271     gtk_box_pack_start_defaults (GTK_BOX (dialog->vbox), GTK_WIDGET (priv->box));
272     gtk_box_pack_start_defaults (GTK_BOX (priv->box), GTK_WIDGET (vbox));
273     gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (priv->image), FALSE, FALSE, 0);
274
275     /* Add response buttons: finish, previous, next, cancel */
276     gtk_dialog_add_button (dialog, _("ecdg_bd_wizard_finish"), MODEST_WIZARD_DIALOG_FINISH);
277     gtk_dialog_add_button (dialog, _("ecdg_bd_wizard_previous"), MODEST_WIZARD_DIALOG_PREVIOUS);
278     gtk_dialog_add_button (dialog, _("ecdg_bd_wizard_next"), MODEST_WIZARD_DIALOG_NEXT);
279     gtk_dialog_add_button (dialog, _("ecdg_bd_wizard_cancel"), MODEST_WIZARD_DIALOG_CANCEL);
280
281     /* Set initial button states: previous and finish buttons are disabled */
282     make_buttons_sensitive (wizard_dialog, FALSE, FALSE, TRUE);
283
284     /* Show all the internal widgets */
285     gtk_widget_show_all (GTK_WIDGET (dialog->vbox));
286
287     /* connect to dialog's response signal */
288     g_signal_connect (G_OBJECT (dialog), "response",
289             G_CALLBACK (response), NULL);
290 }
291
292 #if GTK_CHECK_VERSION(2, 10, 0) /* These signals were added in GTK+ 2.10: */
293 static void on_notebook_page_added(GtkNotebook *notebook, 
294                                    GtkWidget   *child,
295                                    guint        page_num,
296                                    gpointer     user_data)
297 {
298         ModestWizardDialog* dialog = NULL;
299
300         g_return_if_fail (MODEST_IS_WIZARD_DIALOG(user_data));
301         dialog = MODEST_WIZARD_DIALOG(user_data);
302
303         /* The title should show the total number of pages: */
304         create_title (dialog);
305 }
306
307 static void on_notebook_page_removed(GtkNotebook *notebook, 
308                                      GtkWidget   *child,
309                                      guint        page_num,
310                                      gpointer     user_data)
311 {
312         ModestWizardDialog* dialog = NULL;
313
314         g_return_if_fail (MODEST_IS_WIZARD_DIALOG(user_data));
315         dialog = MODEST_WIZARD_DIALOG(user_data);
316
317         /* The title should show the total number of pages: */
318         create_title (dialog);
319 }
320 #endif /* GTK_CHECK_VERSION */
321
322 static void
323 connect_to_notebook_signals(ModestWizardDialog* dialog)
324 {
325 #if GTK_CHECK_VERSION(2, 10, 0) /* These signals were added in GTK+ 2.10: */
326         ModestWizardDialogPrivate *priv = MODEST_WIZARD_DIALOG(dialog)->priv;
327         g_return_if_fail (priv->notebook);
328         
329         /* Connect to the notebook signals,
330          * so we can update the title when necessary: */
331         g_signal_connect (G_OBJECT (priv->notebook), "page-added",
332                       G_CALLBACK (on_notebook_page_added), dialog);
333         g_signal_connect (G_OBJECT (priv->notebook), "page-removed",
334                       G_CALLBACK (on_notebook_page_removed), dialog);
335 #endif /* GTK_CHECK_VERSION */
336 }
337
338
339 static void
340 set_property (GObject      *object, 
341               guint        property_id,
342               const GValue *value, 
343               GParamSpec   *pspec)
344 {
345     ModestWizardDialogPrivate *priv = MODEST_WIZARD_DIALOG(object)->priv;
346
347     switch (property_id) {
348
349         case PROP_WIZARD_AUTOTITLE:
350
351             priv->autotitle = g_value_get_boolean (value);
352
353             if (priv->autotitle && 
354                 priv->wizard_name && 
355                 priv->notebook)
356                 create_title (MODEST_WIZARD_DIALOG (object));
357             else if (priv->wizard_name)
358                 gtk_window_set_title (GTK_WINDOW (object), priv->wizard_name);
359             
360             break;
361
362         case PROP_WIZARD_NAME: 
363
364             /* Set new wizard name. This name will appear in titlebar */
365             if (priv->wizard_name)
366                 g_free (priv->wizard_name);
367
368             gchar *str = (gchar *) g_value_get_string (value);
369             g_return_if_fail (str != NULL);
370
371             priv->wizard_name = g_strdup (str);
372
373             /* We need notebook in order to create title, since page information
374                is used in title generation */
375             
376             if (priv->notebook && priv->autotitle)
377                 create_title (MODEST_WIZARD_DIALOG (object));
378     
379             break;
380
381         case PROP_WIZARD_NOTEBOOK: {
382
383             GtkNotebook *book = GTK_NOTEBOOK (g_value_get_object (value));
384             g_return_if_fail (book != NULL);
385
386             priv->notebook = book;
387
388             /* Set the default properties for the notebook (disable tabs,
389              * and remove borders) to make it look like a nice wizard widget */
390             gtk_notebook_set_show_tabs (priv->notebook, FALSE);
391             gtk_notebook_set_show_border (priv->notebook, FALSE);
392             gtk_box_pack_start_defaults (GTK_BOX( priv->box), GTK_WIDGET (priv->notebook));
393
394             /* Show the notebook so that a gtk_widget_show on the dialog is
395              * all that is required to display the dialog correctly */
396             gtk_widget_show ( GTK_WIDGET (priv->notebook));
397
398             /* Update dialog title to reflect current page stats etc */ 
399             ModestWizardDialog *wizard_dialog = MODEST_WIZARD_DIALOG (object);      
400             if (priv->wizard_name && priv->autotitle)
401                 create_title (wizard_dialog);
402                 
403             connect_to_notebook_signals (wizard_dialog);
404             
405             }break;
406
407         default:
408             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
409             break;
410     }
411 }
412
413 static void
414 get_property (GObject      *object,
415               guint        property_id,
416               GValue       *value,
417               GParamSpec   *pspec)
418 {
419     ModestWizardDialogPrivate *priv = MODEST_WIZARD_DIALOG (object)->priv;
420
421     switch (property_id) {
422
423         case PROP_WIZARD_NAME:
424             g_value_set_string (value, priv->wizard_name);
425             break;
426
427         case PROP_WIZARD_NOTEBOOK:
428             g_value_set_object (value, priv->notebook);
429             break;
430
431         default:
432             G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
433             break;
434     }
435 }
436
437 /*
438  * Creates the title of the dialog taking into account the current 
439  * page of the notebook.
440  */
441 static void
442 create_title (ModestWizardDialog *wizard_dialog)
443 {
444     gchar *str = NULL;
445     ModestWizardDialogPrivate *priv = NULL;
446     GtkNotebook *notebook = NULL;
447
448     g_return_if_fail (MODEST_IS_WIZARD_DIALOG(wizard_dialog));
449     g_return_if_fail (wizard_dialog->priv != NULL);
450
451     priv = wizard_dialog->priv;    
452     notebook = priv->notebook;
453
454     if (!notebook)
455         return;
456
457     /* Get page information, we'll need that when creating title */
458     gint pages = gtk_notebook_get_n_pages (notebook);
459     if (pages == 0)
460       return;
461         
462     gint current = gtk_notebook_get_current_page (priv->notebook);
463     if (current < 0)
464         current = 0;
465
466     /* the welcome title on the initial page */
467     /* This is the standard wizard title, with, e.g., 1/4 at the end,
468          * but the Modest UI spec does not want this. */
469         /*
470     if (current == 0) {
471         str = g_strdup_printf (_("ecdg_ti_wizard_welcome"), 
472                 priv->wizard_name, pages);
473     } else {
474     */
475         const gchar *steps = gtk_notebook_get_tab_label_text (notebook,
476                 gtk_notebook_get_nth_page (notebook, current));
477                 
478                 /* This is the standard wizard title, with, e.g., 1/4 at the end,
479                  * but the Modest UI spec does not want this.
480                  */
481                 /*
482         str = g_strdup_printf (_("ecdg_ti_wizard_step"), 
483                 priv->wizard_name, current + 1, pages, steps);
484         */
485
486         str = g_strdup_printf (_("%s: %s"), 
487                 priv->wizard_name, steps);
488     /* } */
489
490     /* Update the dialog to display the generated title */
491     gtk_window_set_title (GTK_WINDOW (wizard_dialog), str);
492     g_free (str);
493 }
494
495 /*
496  * Response signal handler. This function is needed because GtkDialog's 
497  * handler for this signal closes the dialog and we don't want that, we 
498  * want to change pages and, dim certain response buttons. Overriding the 
499  * virtual function would not work because that would be called after the 
500  * signal handler implemented by GtkDialog.
501  * FIXME: There is a much saner way to do that [MDK]
502  */
503 static void 
504 response (ModestWizardDialog   *wizard_dialog,
505           gint                 response_id,
506           gpointer             unused)
507 {
508     ModestWizardDialogPrivate *priv = wizard_dialog->priv;
509     GtkNotebook *notebook = priv->notebook;
510     gint current = 0;
511     gboolean is_first, is_last;
512     
513     switch (response_id) {
514         
515         case MODEST_WIZARD_DIALOG_PREVIOUS:
516             gtk_notebook_prev_page (notebook); /* go to previous page */
517             break;
518
519         case MODEST_WIZARD_DIALOG_NEXT:
520                 if (invoke_before_next_vfunc (wizard_dialog))
521                 gtk_notebook_next_page (notebook); /* go to next page */
522                 
523             break;
524
525         case MODEST_WIZARD_DIALOG_CANCEL:
526                 return;
527                 break;      
528         case MODEST_WIZARD_DIALOG_FINISH:
529                 if (invoke_before_next_vfunc (wizard_dialog))
530                 return;
531             
532             break;
533
534     }
535
536     current = gtk_notebook_get_current_page (notebook);
537     gint last = gtk_notebook_get_n_pages (notebook) - 1;
538     is_last = current == last;
539     is_first = current == 0;
540     
541     /* If first page, previous and finish are disabled, 
542        if last page, next is disabled */
543     make_buttons_sensitive (wizard_dialog,
544             !is_first /* previous */, !is_first /* finish */, !is_last /* next*/);
545             
546     /* Allow derived classes to disable buttons to prevent navigation,
547      * according to their own validation logic: */
548     invoke_enable_buttons_vfunc (wizard_dialog);
549     
550     /* Don't let the dialog close */
551     g_signal_stop_emission_by_name (wizard_dialog, "response");
552
553     /* We show the default image on first and last pages */
554     last = gtk_notebook_get_n_pages (notebook) - 1;
555     if (current == last || current == 0)
556         gtk_widget_show (GTK_WIDGET(priv->image));
557     else
558         gtk_widget_hide (GTK_WIDGET(priv->image));
559
560     /* New page number may appear in the title, update it */
561     if (priv->autotitle) 
562         create_title (wizard_dialog);
563 }
564
565 /**
566  * modest_wizard_dialog_new:
567  * @parent: a #GtkWindow
568  * @wizard_name: the name of dialog
569  * @notebook: the notebook to be shown on the dialog
570  *
571  * Creates a new #ModestWizardDialog.
572  *
573  * Returns: a new #ModestWizardDialog
574  */
575 GtkWidget*
576 modest_wizard_dialog_new (GtkWindow   *parent,
577                           const char  *wizard_name,
578                           GtkNotebook *notebook)
579 {
580     GtkWidget *widget;
581
582     g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL);
583
584     widget = GTK_WIDGET (g_object_new
585             (MODEST_TYPE_WIZARD_DIALOG,
586              "wizard-name", wizard_name,
587              "wizard-notebook", notebook, NULL));
588
589     if (parent)
590         gtk_window_set_transient_for (GTK_WINDOW (widget), parent);
591
592     return widget;
593 }
594
595 /**
596  * modest_wizard_dialog_force_title_update:
597  * @wizard_dialog: The wizard dialog
598  *
599  * Force the title to be rebuilt, for instance when you have added or 
600  * removed notebook pages. This function is not necessary when using GTK+ 2.10, 
601  * because that has GtkNotebook signals that will be used to update the title 
602  * automatically.
603  */
604 void
605 modest_wizard_dialog_force_title_update (ModestWizardDialog   *wizard_dialog)
606 {
607         create_title (wizard_dialog);
608 }
609
610 static gboolean
611 invoke_before_next_vfunc (ModestWizardDialog *wizard_dialog)
612 {
613         ModestWizardDialogClass *klass = MODEST_WIZARD_DIALOG_GET_CLASS (wizard_dialog);
614         
615         /* Call the vfunc, which may be overridden by derived classes: */
616         if (klass->before_next) {
617                 ModestWizardDialogPrivate *priv = MODEST_WIZARD_DIALOG(wizard_dialog)->priv;
618         
619                 gint current_page_num = gtk_notebook_get_current_page (priv->notebook);
620                 
621                 /* Get widgets for the two pages: */
622                 GtkWidget* current_page_widget = gtk_notebook_get_nth_page (priv->notebook, current_page_num);
623                 
624                 GtkWidget* next_page_widget = NULL;
625                 if ((current_page_num + 1) < gtk_notebook_get_n_pages (priv->notebook))
626                         next_page_widget = gtk_notebook_get_nth_page (priv->notebook, current_page_num + 1);
627                 
628                 /* Ask the vfunc implementation whether navigation should be allowed: */
629                 return (*(klass->before_next))(wizard_dialog, current_page_widget, next_page_widget);
630         }
631         
632         /* Allow navigation by default if there is no vfunc implementation: */
633         return TRUE;
634 }
635
636 static void
637 invoke_enable_buttons_vfunc (ModestWizardDialog *wizard_dialog)
638 {
639         ModestWizardDialogClass *klass = MODEST_WIZARD_DIALOG_GET_CLASS (wizard_dialog);
640         
641         /* Call the vfunc, which may be overridden by derived classes: */
642         if (klass->enable_buttons) {
643                 ModestWizardDialogPrivate *priv = MODEST_WIZARD_DIALOG(wizard_dialog)->priv;
644         
645                 gint current_page_num = gtk_notebook_get_current_page (priv->notebook);
646                 
647                 GtkWidget* current_page_widget = gtk_notebook_get_nth_page (priv->notebook, current_page_num);
648                         
649                 (*(klass->enable_buttons))(wizard_dialog, current_page_widget);
650         }
651 }