X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fwidgets%2Fmodest-wizard-dialog.c;h=c2792d15fa77a7cabf04b714cba240cdca028ad3;hb=24e392d70eda5725d60701861dc214ee7f47498c;hp=6f11957c564b4b8d73e59fb0a6e42f09e31ae644;hpb=85b4e34d82bc387cb79bb22f456b99843bc9a21d;p=modest diff --git a/src/widgets/modest-wizard-dialog.c b/src/widgets/modest-wizard-dialog.c index 6f11957..c2792d1 100644 --- a/src/widgets/modest-wizard-dialog.c +++ b/src/widgets/modest-wizard-dialog.c @@ -41,26 +41,15 @@ */ #include -#include -#include -#include -#include -#include -#include -#include #include #ifdef HAVE_CONFIG_H #include #endif -#ifndef MODEST_TOOLKIT_GTK -#if MODEST_HILDON_API == 0 -#include -#else +#ifdef MODEST_TOOLKIT_HILDON2 #include -#endif /*MODEST_HILDON_API == 0*/ -#endif /*!MODEST_TOOLKIT_GTK*/ +#endif #include "modest-wizard-dialog.h" #include "modest-debug.h" @@ -97,6 +86,8 @@ static void make_buttons_sensitive (ModestWizardDialog *wizard_dialog, static gboolean invoke_before_next_vfunc (ModestWizardDialog *wizard_dialog); static void invoke_enable_buttons_vfunc (ModestWizardDialog *wizard_dialog); +static void invoke_update_model_vfunc (ModestWizardDialog *wizard_dialog); +static gboolean invoke_save_vfunc (ModestWizardDialog *wizard_dialog); enum { PROP_ZERO, @@ -159,6 +150,11 @@ class_init (ModestWizardDialogClass *wizard_dialog_class) object_class->get_property = get_property; object_class->finalize = finalize; + wizard_dialog_class->before_next = NULL; + wizard_dialog_class->update_model = NULL; + wizard_dialog_class->save = NULL; + wizard_dialog_class->enable_buttons = NULL; + /** * ModestWizardDialog:wizard-name: * @@ -258,16 +254,11 @@ init (ModestWizardDialog *wizard_dialog) #ifdef MODEST_TOOLKIT_GTK priv->image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_DIALOG); #else /*MODEST_TOOLKIT_GTK*/ -#if MODEST_HILDON_API == 0 - priv->image = gtk_image_new_from_icon_name ("qgn_widg_wizard", - HILDON_ICON_SIZE_WIDG_WIZARD); -#else static int icon_size = 0; if (!icon_size) icon_size = gtk_icon_size_register("modest_wizard", 50, 50); priv->image = gtk_image_new_from_icon_name ("qgn_widg_wizard", icon_size); -#endif /*MODEST_HILDON_API == 0*/ #endif /*!MODEST_TOOLKIT_GTK*/ #endif /*MODEST_TOOLKIT_HILDON2 */ /* Default values for user provided properties */ @@ -276,10 +267,14 @@ init (ModestWizardDialog *wizard_dialog) priv->autotitle = TRUE; /* Build wizard layout */ - gtk_box_pack_start_defaults (GTK_BOX (dialog->vbox), GTK_WIDGET (priv->box)); - gtk_box_pack_start_defaults (GTK_BOX (priv->box), GTK_WIDGET (vbox)); - if (priv->image) - gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (priv->image), FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (dialog->vbox), GTK_WIDGET (priv->box), TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (priv->box), GTK_WIDGET (vbox), FALSE, FALSE, 0); + gtk_widget_show (vbox); + gtk_widget_show (GTK_WIDGET (priv->box)); + if (priv->image) { + gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (priv->image), TRUE, TRUE, 0); + gtk_widget_show (priv->image); + } /* Add response buttons: finish, previous, next, cancel */ #ifdef MODEST_TOOLKIT_HILDON1 @@ -303,8 +298,7 @@ init (ModestWizardDialog *wizard_dialog) /* Set initial button states: previous and finish buttons are disabled */ make_buttons_sensitive (wizard_dialog, FALSE, FALSE, TRUE); - /* Show all the internal widgets */ - gtk_widget_show_all (GTK_WIDGET (dialog->vbox)); + gtk_widget_show (GTK_WIDGET (dialog->vbox)); /* connect to dialog's response signal */ g_signal_connect (G_OBJECT (dialog), "response", @@ -425,7 +419,7 @@ set_property (GObject *object, * and remove borders) to make it look like a nice wizard widget */ gtk_notebook_set_show_tabs (priv->notebook, FALSE); gtk_notebook_set_show_border (priv->notebook, FALSE); - gtk_box_pack_start_defaults (GTK_BOX( priv->box), GTK_WIDGET (priv->notebook)); + gtk_box_pack_start (GTK_BOX( priv->box), GTK_WIDGET (priv->notebook), TRUE, TRUE, 0); /* Show the notebook so that a gtk_widget_show on the dialog is * all that is required to display the dialog correctly */ @@ -480,48 +474,33 @@ create_title (ModestWizardDialog *wizard_dialog) gchar *str = NULL; ModestWizardDialogPrivate *priv = NULL; GtkNotebook *notebook = NULL; + gint pages, current; + const gchar *steps; g_return_if_fail (MODEST_IS_WIZARD_DIALOG(wizard_dialog)); g_return_if_fail (wizard_dialog->priv != NULL); - priv = wizard_dialog->priv; + priv = wizard_dialog->priv; notebook = priv->notebook; if (!notebook) return; /* Get page information, we'll need that when creating title */ - gint pages = gtk_notebook_get_n_pages (notebook); + pages = gtk_notebook_get_n_pages (notebook); if (pages == 0) - return; - - gint current = gtk_notebook_get_current_page (priv->notebook); + return; + + current = gtk_notebook_get_current_page (priv->notebook); if (current < 0) - current = 0; - - /* the welcome title on the initial page */ - /* This is the standard wizard title, with, e.g., 1/4 at the end, - * but the Modest UI spec does not want this. */ - /* - if (current == 0) { - str = g_strdup_printf (_HL("ecdg_ti_wizard_welcome"), - priv->wizard_name, pages); - } else { - */ - const gchar *steps = gtk_notebook_get_tab_label_text (notebook, - gtk_notebook_get_nth_page (notebook, current)); - - /* This is the standard wizard title, with, e.g., 1/4 at the end, - * but the Modest UI spec does not want this. - */ - /* - str = g_strdup_printf (_HL("ecdg_ti_wizard_step"), - priv->wizard_name, current + 1, pages, steps); - */ - - str = g_strdup_printf ((steps&&*steps)?_HL("%s: %s"):_HL("%s"), - priv->wizard_name, steps); - /* } */ + current = 0; + + steps = gtk_notebook_get_tab_label_text (notebook, + gtk_notebook_get_nth_page (notebook, current)); + + str = g_strdup_printf ((steps&&*steps)?_HL("%s%s %s"):_HL("%s"), + priv->wizard_name, _HL("ecdg_ti_caption_separator"), + steps); /* Update the dialog to display the generated title */ gtk_window_set_title (GTK_WINDOW (wizard_dialog), str); @@ -719,6 +698,30 @@ invoke_enable_buttons_vfunc (ModestWizardDialog *wizard_dialog) } } +static void +invoke_update_model_vfunc (ModestWizardDialog *wizard_dialog) +{ + ModestWizardDialogClass *klass = MODEST_WIZARD_DIALOG_GET_CLASS (wizard_dialog); + + /* Call the vfunc, which may be overridden by derived classes: */ + if (klass->update_model) { + (*(klass->update_model)) (wizard_dialog); + } +} + +static gboolean +invoke_save_vfunc (ModestWizardDialog *wizard_dialog) +{ + ModestWizardDialogClass *klass = MODEST_WIZARD_DIALOG_GET_CLASS (wizard_dialog); + + /* Call the vfunc, which may be overridden by derived classes: */ + if (klass->save) { + return (*(klass->save)) (wizard_dialog); + } else { + return TRUE; + } +} + void modest_wizard_dialog_set_response_override_handler (ModestWizardDialog *wizard_dialog, ModestWizardDialogResponseOverrideFunc callback) @@ -727,3 +730,19 @@ modest_wizard_dialog_set_response_override_handler (ModestWizardDialog *wizard_d priv->override_func = callback; } + +void +modest_wizard_dialog_update_model (ModestWizardDialog *wizard_dialog) +{ + g_return_if_fail (MODEST_IS_WIZARD_DIALOG (wizard_dialog)); + + invoke_update_model_vfunc (wizard_dialog); +} + +gboolean +modest_wizard_dialog_save (ModestWizardDialog *wizard_dialog) +{ + g_return_val_if_fail (MODEST_IS_WIZARD_DIALOG (wizard_dialog), FALSE); + + return invoke_save_vfunc (wizard_dialog); +}