* Fixes NB#84725, retrieve messages when the option "messages and attchaments" is...
[modest] / src / maemo / easysetup / modest-wizard-dialog.c
index 353296e..fbb25e3 100644 (file)
@@ -1,13 +1,32 @@
-/*
- * This is a copy of modest-wizard-dialog.h with a rename and some API additions,
- * for osso-modest-easysetup.
- * 
- * This file was part of modest-libs
+/* Copyright (c) 2006, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
  *
- * Copyright (C) 2005, 2006, 2007 Nokia Corporation, all rights reserved.
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived from
+ *   this software without specific prior written permission.
  *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
 /**
  * SECTION:modest-wizard-dialog
  * @short_description: A widget to create a guided installation
 #include <config.h>
 #endif
 
-#ifdef MODEST_HILDON_VERSION_0
+#ifdef MODEST_HAVE_HILDON0_WIDGETS
 #include <hildon-widgets/hildon-defines.h>
 #else
 #include <hildon/hildon-defines.h>
-#endif /*MODEST_HILDON_VERSION_0*/
+#endif /*MODEST_HAVE_HILDON0_WIDGETS*/
 
 #include "modest-wizard-dialog.h"
 
@@ -236,12 +255,15 @@ 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_HILDON_VERSION_0
+#ifdef MODEST_HAVE_HILDON0_WIDGETS
     priv->image = gtk_image_new_from_icon_name ("qgn_widg_wizard",
                                                HILDON_ICON_SIZE_WIDG_WIZARD);
-#else
+#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",
-                                               HILDON_ICON_SIZE_WIZARD);
+                                               icon_size);
 #endif /*MODEST_HILDON_VERSION_0*/
     /* Default values for user provided properties */
     priv->notebook = NULL;
@@ -271,20 +293,30 @@ init (ModestWizardDialog *wizard_dialog)
 }
 
 #if GTK_CHECK_VERSION(2, 10, 0) /* These signals were added in GTK+ 2.10: */
-static void on_notebook_page_added(ModestWizardDialog* dialog, 
-       GtkWidget   *child,
-       guint        page_num,
-       gpointer     user_data)
+static void on_notebook_page_added(GtkNotebook *notebook, 
+                                  GtkWidget   *child,
+                                  guint        page_num,
+                                  gpointer     user_data)
 {
+       ModestWizardDialog* dialog = NULL;
+
+       g_return_if_fail (MODEST_IS_WIZARD_DIALOG(user_data));
+       dialog = MODEST_WIZARD_DIALOG(user_data);
+
        /* The title should show the total number of pages: */
        create_title (dialog);
 }
 
-static void on_notebook_page_removed(ModestWizardDialog* dialog, 
-       GtkWidget   *child,
-       guint        page_num,
-       gpointer     user_data)
+static void on_notebook_page_removed(GtkNotebook *notebook, 
+                                    GtkWidget   *child,
+                                    guint        page_num,
+                                    gpointer     user_data)
 {
+       ModestWizardDialog* dialog = NULL;
+
+       g_return_if_fail (MODEST_IS_WIZARD_DIALOG(user_data));
+       dialog = MODEST_WIZARD_DIALOG(user_data);
+
        /* The title should show the total number of pages: */
        create_title (dialog);
 }
@@ -299,10 +331,10 @@ connect_to_notebook_signals(ModestWizardDialog* dialog)
        
        /* Connect to the notebook signals,
         * so we can update the title when necessary: */
-    g_signal_connect (G_OBJECT (priv->notebook), "page-added",
-            G_CALLBACK (on_notebook_page_added), NULL);
-    g_signal_connect (G_OBJECT (priv->notebook), "page-removed",
-            G_CALLBACK (on_notebook_page_removed), NULL);
+       g_signal_connect (G_OBJECT (priv->notebook), "page-added",
+                     G_CALLBACK (on_notebook_page_added), dialog);
+       g_signal_connect (G_OBJECT (priv->notebook), "page-removed",
+                     G_CALLBACK (on_notebook_page_removed), dialog);
 #endif /* GTK_CHECK_VERSION */
 }
 
@@ -412,31 +444,51 @@ get_property (GObject      *object,
 static void
 create_title (ModestWizardDialog *wizard_dialog)
 {
-    gint pages, current;
     gchar *str = NULL;
-    ModestWizardDialogPrivate *priv = wizard_dialog->priv;
-    GtkNotebook *notebook = priv->notebook;
+    ModestWizardDialogPrivate *priv = NULL;
+    GtkNotebook *notebook = NULL;
+
+    g_return_if_fail (MODEST_IS_WIZARD_DIALOG(wizard_dialog));
+    g_return_if_fail (wizard_dialog->priv != NULL);
+
+    priv = wizard_dialog->priv;    
+    notebook = priv->notebook;
 
     if (!notebook)
         return;
 
     /* Get page information, we'll need that when creating title */
-    pages = gtk_notebook_get_n_pages (notebook);
-    current = gtk_notebook_get_current_page (priv->notebook);
+    gint pages = gtk_notebook_get_n_pages (notebook);
+    if (pages == 0)
+      return;
+       
+    gint 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 (_("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));
-
+    */
+       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 (_("ecdg_ti_wizard_step"), 
                 priv->wizard_name, current + 1, pages, steps);
-    }
+        */
+
+        str = g_strdup_printf (_("%s: %s"), 
+                priv->wizard_name, steps);
+    /* } */
 
     /* Update the dialog to display the generated title */
     gtk_window_set_title (GTK_WINDOW (wizard_dialog), str);
@@ -446,7 +498,7 @@ create_title (ModestWizardDialog *wizard_dialog)
 /*
  * Response signal handler. This function is needed because GtkDialog's 
  * handler for this signal closes the dialog and we don't want that, we 
- * want to change pages and, dimm certain response buttons. Overriding the 
+ * want to change pages and, dim certain response buttons. Overriding the 
  * virtual function would not work because that would be called after the 
  * signal handler implemented by GtkDialog.
  * FIXME: There is a much saner way to do that [MDK]