-/*
- * 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 <gtk/gtkhbox.h>
#include <gtk/gtkvbox.h>
#include <gtk/gtkbutton.h>
+#include <gtk/gtk.h>
#ifdef HAVE_CONFIG_H
#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"
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;
G_CALLBACK (response), NULL);
}
+#if GTK_CHECK_VERSION(2, 10, 0) /* These signals were added in GTK+ 2.10: */
+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(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);
+}
+#endif /* GTK_CHECK_VERSION */
+
+static void
+connect_to_notebook_signals(ModestWizardDialog* dialog)
+{
+#if GTK_CHECK_VERSION(2, 10, 0) /* These signals were added in GTK+ 2.10: */
+ ModestWizardDialogPrivate *priv = MODEST_WIZARD_DIALOG(dialog)->priv;
+ g_return_if_fail (priv->notebook);
+
+ /* 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), dialog);
+ g_signal_connect (G_OBJECT (priv->notebook), "page-removed",
+ G_CALLBACK (on_notebook_page_removed), dialog);
+#endif /* GTK_CHECK_VERSION */
+}
+
+
static void
set_property (GObject *object,
guint property_id,
* all that is required to display the dialog correctly */
gtk_widget_show ( GTK_WIDGET (priv->notebook));
- /* Update dialog title to reflect current page stats etc */
+ /* Update dialog title to reflect current page stats etc */
+ ModestWizardDialog *wizard_dialog = MODEST_WIZARD_DIALOG (object);
if (priv->wizard_name && priv->autotitle)
- create_title (MODEST_WIZARD_DIALOG (object));
+ create_title (wizard_dialog);
+
+ connect_to_notebook_signals (wizard_dialog);
- } break;
+ }break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
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);
/*
* 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]
return widget;
}
+/**
+ * modest_wizard_dialog_force_title_update:
+ * @wizard_dialog: The wizard dialog
+ *
+ * Force the title to be rebuilt, for instance when you have added or
+ * removed notebook pages. This function is not necessary when using GTK+ 2.10,
+ * because that has GtkNotebook signals that will be used to update the title
+ * automatically.
+ */
+void
+modest_wizard_dialog_force_title_update (ModestWizardDialog *wizard_dialog)
+{
+ create_title (wizard_dialog);
+}
+
static gboolean
invoke_before_next_vfunc (ModestWizardDialog *wizard_dialog)
{