Move easysetup wizard to src/widgets
[modest] / src / hildon2 / modest-connection-specific-smtp-window.c
index 02d3f1e..9087019 100644 (file)
 #include "widgets/modest-ui-constants.h"
 
 #include <modest-runtime.h>
+
+#if MODEST_HAVE_CONIC
 #include <tny-maemo-conic-device.h>
+#endif
 
 #include <gtk/gtktreeview.h>
 #include <gtk/gtkcellrenderertext.h>
 #include <gtk/gtkliststore.h>
-#include <hildon/hildon-pannable-area.h>
+#include <modest-scrollable.h>
+#include <modest-toolkit-factory.h>
 #include <hildon/hildon-gtk.h>
 #include <gtk/gtkbutton.h>
 #include <gtk/gtkhbox.h>
@@ -65,7 +69,7 @@ struct _ModestConnectionSpecificSmtpWindowPrivate
        GtkTreeView *treeview;
        GtkTreeModel *model;
        GtkWidget *no_connection_label;
-       GtkWidget *pannable;
+       GtkWidget *scrollable;
        ModestAccountMgr *account_manager;
 };
 
@@ -166,11 +170,10 @@ modest_connection_specific_smtp_window_fill_with_connections (ModestConnectionSp
                                                              ModestAccountMgr *account_manager)
 {
        gboolean empty = TRUE;
-#ifdef MODEST_HAVE_CONIC
        ModestConnectionSpecificSmtpWindowPrivate *priv = 
                CONNECTION_SPECIFIC_SMTP_WINDOW_GET_PRIVATE (self);
        priv->account_manager = account_manager;
-       
+#ifdef MODEST_HAVE_CONIC
        GtkListStore *liststore = GTK_LIST_STORE (priv->model);
        
        TnyDevice *device = modest_runtime_get_device ();
@@ -233,17 +236,17 @@ modest_connection_specific_smtp_window_fill_with_connections (ModestConnectionSp
 #endif /*MODEST_HAVE_CONIC */
 
        GtkWidget *child;
-       child = gtk_bin_get_child (GTK_BIN (priv->pannable));
+       child = gtk_bin_get_child (GTK_BIN (priv->scrollable));
        if (child) {
-               gtk_container_remove (GTK_CONTAINER (priv->pannable), child);
+               gtk_container_remove (GTK_CONTAINER (priv->scrollable), child);
        }
 
        if (empty) {
-               hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (priv->pannable), 
-                                                       priv->no_connection_label);
+               modest_scrollable_add_with_viewport (MODEST_SCROLLABLE (priv->scrollable), 
+                                                    priv->no_connection_label);
                gtk_widget_show (priv->no_connection_label);
        } else {
-               gtk_container_add (GTK_CONTAINER (priv->pannable), GTK_WIDGET (priv->treeview));
+               gtk_container_add (GTK_CONTAINER (priv->scrollable), GTK_WIDGET (priv->treeview));
                gtk_widget_show (GTK_WIDGET (priv->treeview));
        }
 }
@@ -335,9 +338,10 @@ static void
 modest_connection_specific_smtp_window_init (ModestConnectionSpecificSmtpWindow *self)
 {
        ModestWindowMgr *mgr;
+       GtkWidget *align;
 
        /* Specify a default size */
-       gtk_window_set_default_size (GTK_WINDOW (self), -1, 320);
+       gtk_window_set_default_size (GTK_WINDOW (self), -1, MODEST_DIALOG_WINDOW_MAX_HEIGHT);
 
        /* This seems to be necessary to make the window show at the front with decoration.
         * If we use property type=GTK_WINDOW_TOPLEVEL instead of the default GTK_WINDOW_POPUP+decoration, 
@@ -368,6 +372,7 @@ modest_connection_specific_smtp_window_init (ModestConnectionSpecificSmtpWindow
        GtkTreeViewColumn *view_column = gtk_tree_view_column_new ();
        gtk_tree_view_column_set_expand (view_column, TRUE);
        GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
+       g_object_set (G_OBJECT (renderer), "xpad", MODEST_MARGIN_DOUBLE, NULL);
        gtk_tree_view_column_pack_start(view_column, renderer, TRUE);
        gtk_tree_view_column_set_attributes (view_column, renderer, 
        "text", MODEL_COL_NAME, NULL);
@@ -385,28 +390,24 @@ modest_connection_specific_smtp_window_init (ModestConnectionSpecificSmtpWindow
        /* The application must call modest_connection_specific_smtp_window_fill_with_connections(). */
 
        GtkWidget *vbox = GTK_DIALOG(self)->vbox;
-       //gtk_vbox_new (FALSE, MODEST_MARGIN_DEFAULT);
 
        /* Introductory note: */
-       /* TODO: For some reason this label does not wrap. It is truncated. */
        GtkWidget *label = gtk_label_new(_("mcen_ia_optionalsmtp_note"));
        gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-       /* So that it is shown without being truncated: */
-       /* gtk_label_set_max_width_chars (GTK_LABEL (label), 20); */
-       /* The documentation for gtk_label_set_line_wrap() says that we must 
-        * call gtk_widget_set_size_request() with a hard-coded width, 
-        * though I wonder why gtk_label_set_max_width_chars() isn't enough. */
-       /* gtk_widget_set_size_request (label, 400, -1); */
+       gtk_misc_set_padding (GTK_MISC (label), MODEST_MARGIN_DOUBLE + MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
+       gtk_widget_set_size_request (label, 600, -1);
        gtk_widget_show (label);
-       gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, MODEST_MARGIN_HALF);
-
-       /* Put the treeview in a pannable and add it to the box: */
-       priv->pannable = hildon_pannable_area_new ();
-       g_object_set (G_OBJECT (priv->pannable), "initial-hint", TRUE, NULL);
-       gtk_container_set_border_width (GTK_CONTAINER (priv->pannable), MODEST_MARGIN_DEFAULT);
-       gtk_widget_show (priv->pannable);
-       gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (priv->pannable), TRUE, TRUE, MODEST_MARGIN_HALF);
+       gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+       /* Put the treeview in a scrollable and add it to the box: */
+       priv->scrollable = modest_toolkit_factory_create_scrollable (modest_runtime_get_toolkit_factory ());
+       align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
+       gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, MODEST_MARGIN_DOUBLE, 0);
+       gtk_widget_show (priv->scrollable);
+       gtk_widget_show (align);
+       gtk_container_add (GTK_CONTAINER (align), GTK_WIDGET (priv->scrollable));
+       gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (align), TRUE, TRUE, 0);
        gtk_widget_show (vbox);
 
        g_signal_connect (G_OBJECT (priv->treeview), "row-activated", G_CALLBACK (on_row_activated), self);