* Fixes NB#100997 disable previous button in the first page of accounts wizard
[modest] / src / widgets / modest-wizard-dialog.c
index 8e6e667..6f77c66 100644 (file)
 #include <config.h>
 #endif
 
-#ifdef MODEST_PLATFORM_MAEMO
-#ifdef MODEST_HAVE_HILDON0_WIDGETS
+#ifndef MODEST_TOOLKIT_GTK
+#if MODEST_HILDON_API == 0
 #include <hildon-widgets/hildon-defines.h>
 #else
 #include <hildon/hildon-defines.h>
-#endif /*MODEST_HAVE_HILDON0_WIDGETS*/
-#endif /*MODEST_PLATFORM_MAEMO*/
+#endif /*MODEST_HILDON_API == 0*/
+#endif /*!MODEST_TOOLKIT_GTK*/
 
 #include "modest-wizard-dialog.h"
-
-#include <libintl.h>
-
-#ifdef MODEST_PLATFORM_MAEMO
-/* Specify the hildon-libs translation domain,
- * so we can reuse its translations 
- * instead of repeating them in our own translations.
- */
-/* #define _(String) dgettext(PACKAGE, String) */
-
-#define _(String) dgettext("hildon-libs", String)
-#else
-#define _(String) gettext(String)
-#endif
+#include "modest-debug.h"
+#include "modest-text-utils.h"
 
 static GtkDialogClass *parent_class;
 
@@ -106,7 +94,7 @@ static void make_buttons_sensitive  (ModestWizardDialog *wizard_dialog,
                                      gboolean           previous,
                                      gboolean           finish,
                                      gboolean next);
-                                     
+
 static gboolean invoke_before_next_vfunc (ModestWizardDialog *wizard_dialog);
 static void invoke_enable_buttons_vfunc (ModestWizardDialog *wizard_dialog);
 
@@ -261,8 +249,13 @@ init (ModestWizardDialog *wizard_dialog)
     gtk_dialog_set_has_separator (dialog, FALSE);
     wizard_dialog->priv = priv;
     priv->box = GTK_BOX (gtk_hbox_new (FALSE, 0));
-#ifdef MODEST_PLATFORM_MAEMO
-#ifdef MODEST_HAVE_HILDON0_WIDGETS
+#ifdef MODEST_TOOLKIT_HILDON2
+    priv->image = NULL;
+#else
+#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      
@@ -271,10 +264,9 @@ init (ModestWizardDialog *wizard_dialog)
            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_VERSION_0*/
-#else /*MODEST_PLATFORM_MAEMO*/
-    priv->image = gtk_image_new_from_stock (GTK_STOCK_PREFERENCES, GTK_ICON_SIZE_DIALOG);
-#endif /*MODEST_PLATFORM_MAEMO*/
+#endif /*MODEST_HILDON_API == 0*/
+#endif /*!MODEST_TOOLKIT_GTK*/
+#endif /*MODEST_TOOLKIT_HILDON2 */
     /* Default values for user provided properties */
     priv->notebook = NULL;
     priv->wizard_name = NULL;
@@ -283,15 +275,22 @@ init (ModestWizardDialog *wizard_dialog)
     /* 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));
-    gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (priv->image), FALSE, FALSE, 0);
+    if (priv->image)
+      gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (priv->image), FALSE, FALSE, 0);
 
     /* Add response buttons: finish, previous, next, cancel */
-#ifdef MODEST_PLATFORM_MAEMO
-    gtk_dialog_add_button (dialog, _("ecdg_bd_wizard_finish"), MODEST_WIZARD_DIALOG_FINISH);
-    gtk_dialog_add_button (dialog, _("ecdg_bd_wizard_previous"), MODEST_WIZARD_DIALOG_PREVIOUS);
-    gtk_dialog_add_button (dialog, _("ecdg_bd_wizard_next"), MODEST_WIZARD_DIALOG_NEXT);
-    gtk_dialog_add_button (dialog, _("ecdg_bd_wizard_cancel"), MODEST_WIZARD_DIALOG_CANCEL);
-#else
+#ifdef MODEST_TOOLKIT_HILDON1
+    gtk_dialog_add_button (dialog, _HL("ecdg_bd_wizard_finish"), MODEST_WIZARD_DIALOG_FINISH);
+    gtk_dialog_add_button (dialog, _HL("ecdg_bd_wizard_previous"), MODEST_WIZARD_DIALOG_PREVIOUS);
+    gtk_dialog_add_button (dialog, _HL("ecdg_bd_wizard_next"), MODEST_WIZARD_DIALOG_NEXT);
+    gtk_dialog_add_button (dialog, _HL("ecdg_bd_wizard_cancel"), MODEST_WIZARD_DIALOG_CANCEL);
+#endif
+#ifdef MODEST_TOOLKIT_HILDON2
+    gtk_dialog_add_button (dialog, _HL("wdgt_bd_finish"), MODEST_WIZARD_DIALOG_FINISH);
+    gtk_dialog_add_button (dialog, _HL("wdgt_bd_previous"), MODEST_WIZARD_DIALOG_PREVIOUS);
+    gtk_dialog_add_button (dialog, _HL("wdgt_bd_next"), MODEST_WIZARD_DIALOG_NEXT);
+#endif
+#ifdef MODEST_TOOLKIT_GTK
     gtk_dialog_add_button (dialog, GTK_STOCK_SAVE, MODEST_WIZARD_DIALOG_FINISH);
     gtk_dialog_add_button (dialog, GTK_STOCK_GO_BACK, MODEST_WIZARD_DIALOG_PREVIOUS);
     gtk_dialog_add_button (dialog, GTK_STOCK_GO_FORWARD, MODEST_WIZARD_DIALOG_NEXT);
@@ -488,7 +487,7 @@ create_title (ModestWizardDialog *wizard_dialog)
         * but the Modest UI spec does not want this. */
        /*
     if (current == 0) {
-        str = g_strdup_printf (_("ecdg_ti_wizard_welcome"), 
+        str = g_strdup_printf (_HL("ecdg_ti_wizard_welcome"), 
                 priv->wizard_name, pages);
     } else {
     */
@@ -499,11 +498,11 @@ create_title (ModestWizardDialog *wizard_dialog)
                 * but the Modest UI spec does not want this.
                 */
                /*
-        str = g_strdup_printf (_("ecdg_ti_wizard_step"), 
+        str = g_strdup_printf (_HL("ecdg_ti_wizard_step"), 
                 priv->wizard_name, current + 1, pages, steps);
         */
 
-        str = g_strdup_printf (_("%s: %s"), 
+        str = g_strdup_printf (_HL("%s: %s"), 
                 priv->wizard_name, steps);
     /* } */
 
@@ -538,7 +537,7 @@ response (ModestWizardDialog   *wizard_dialog,
 
         case MODEST_WIZARD_DIALOG_NEXT:
                if (invoke_before_next_vfunc (wizard_dialog))
-               gtk_notebook_next_page (notebook); /* go to next page */
+                       gtk_notebook_next_page (notebook); /* go to next page */
                
             break;
 
@@ -557,25 +556,29 @@ response (ModestWizardDialog   *wizard_dialog,
     gint last = gtk_notebook_get_n_pages (notebook) - 1;
     is_last = current == last;
     is_first = current == 0;
-    
+
     /* If first page, previous and finish are disabled, 
        if last page, next is disabled */
     make_buttons_sensitive (wizard_dialog,
-            !is_first /* previous */, !is_first /* finish */, !is_last /* next*/);
-            
+                           (is_first) ? FALSE : TRUE,
+                           TRUE,
+                           (is_last) ? FALSE : TRUE);
+
     /* Allow derived classes to disable buttons to prevent navigation,
      * according to their own validation logic: */
     invoke_enable_buttons_vfunc (wizard_dialog);
-    
+
     /* Don't let the dialog close */
     g_signal_stop_emission_by_name (wizard_dialog, "response");
 
     /* We show the default image on first and last pages */
     last = gtk_notebook_get_n_pages (notebook) - 1;
-    if (current == last || current == 0)
-        gtk_widget_show (GTK_WIDGET(priv->image));
-    else
-        gtk_widget_hide (GTK_WIDGET(priv->image));
+    if (priv->image) {
+           if (current == last || current == 0)
+                   gtk_widget_show (GTK_WIDGET(priv->image));
+           else
+                   gtk_widget_hide (GTK_WIDGET(priv->image));
+    }
 
     /* New page number may appear in the title, update it */
     if (priv->autotitle) 
@@ -644,6 +647,23 @@ invoke_before_next_vfunc (ModestWizardDialog *wizard_dialog)
                GtkWidget* next_page_widget = NULL;
                if ((current_page_num + 1) < gtk_notebook_get_n_pages (priv->notebook))
                        next_page_widget = gtk_notebook_get_nth_page (priv->notebook, current_page_num + 1);
+
+               MODEST_DEBUG_BLOCK (
+               g_debug ("Switching to page %d (%s)",
+                        gtk_notebook_page_num (priv->notebook, next_page_widget),
+                        gtk_notebook_get_tab_label_text (priv->notebook, next_page_widget));
+
+               {
+                       GtkWidget *p;
+                       gint i;
+                       g_debug ("\t***************");
+                       for (i=0; i<gtk_notebook_get_n_pages(priv->notebook);i++) {
+                               p = gtk_notebook_get_nth_page (priv->notebook, i);
+                               g_debug ("\t%d - %s", i, gtk_notebook_get_tab_label_text (priv->notebook, p));
+                       }
+                       g_debug ("\t***************");
+               }
+                                   );
                
                /* Ask the vfunc implementation whether navigation should be allowed: */
                return (*(klass->before_next))(wizard_dialog, current_page_widget, next_page_widget);