Use scrollable in header window and mailboxes window.
authorJose Dapena Paz <jdapena@igalia.com>
Thu, 29 Oct 2009 18:16:52 +0000 (19:16 +0100)
committerJose Dapena Paz <jdapena@igalia.com>
Thu, 29 Oct 2009 18:48:00 +0000 (19:48 +0100)
src/hildon2/modest-header-window.c
src/hildon2/modest-mailboxes-window.c

index 16792f7..a537275 100644 (file)
@@ -28,8 +28,8 @@
  */
 
 #include <modest-header-window.h>
-#include <hildon/hildon-pannable-area.h>
-#include <hildon/hildon-helper.h>
+#include <hildon/hildon.h>
+#include <modest-scrollable.h>
 #include <modest-window-mgr.h>
 #include <modest-window-priv.h>
 #include <modest-signal-mgr.h>
@@ -45,9 +45,6 @@
 #include <modest-ui-actions.h>
 #include <modest-platform.h>
 #include <modest-text-utils.h>
-#include <hildon/hildon-button.h>
-#include <hildon/hildon-program.h>
-#include <hildon/hildon-banner.h>
 #include <modest-ui-dimming-rules.h>
 #include <modest-tny-folder.h>
 #include <tny-simple-list.h>
@@ -147,9 +144,16 @@ static gboolean on_expose_event(GtkTreeView *header_view,
 static gboolean on_map_event (GtkWidget *widget,
                              GdkEvent *event,
                              gpointer userdata);
+#ifdef MODEST_TOOLKIT_HILDON2
 static void on_vertical_movement (HildonPannableArea *area,
                                  HildonMovementDirection direction,
                                  gdouble x, gdouble y, gpointer user_data);
+static void on_horizontal_movement (HildonPannableArea *hildonpannable,
+                                   gint                direction,
+                                   gdouble             initial_x,
+                                   gdouble             initial_y,
+                                   gpointer            user_data);
+#endif
 static void on_queue_changed    (ModestMailOperationQueue *queue,
                                 ModestMailOperation *mail_op,
                                 ModestMailOperationQueueNotification type,
@@ -167,11 +171,6 @@ static void update_progress_hint (ModestHeaderWindow *self);
 static void on_sort_column_changed (GtkTreeSortable *treesortable,
                                    gpointer         user_data);
 static void update_sort_button (ModestHeaderWindow *self);
-static void on_horizontal_movement (HildonPannableArea *hildonpannable,
-                                   gint                direction,
-                                   gdouble             initial_x,
-                                   gdouble             initial_y,
-                                   gpointer            user_data);
 static void on_header_view_model_destroyed (gpointer user_data,
                                            GObject *model);
 static gboolean on_key_press(GtkWidget *widget,
@@ -395,13 +394,16 @@ connect_signals (ModestHeaderWindow *self)
                                           "map-event",
                                           G_CALLBACK (on_map_event),
                                           self);
-
-       priv->sighandlers =
-               modest_signal_mgr_connect (priv->sighandlers,
-                                          G_OBJECT (priv->contents_view), 
-                                          "vertical-movement", 
-                                          G_CALLBACK (on_vertical_movement), 
-                                          self);
+#ifdef MODEST_TOOLKIT_HILDON2
+       if (HILDON_IS_PANNABLE_AREA (priv->contents_view)) {
+               priv->sighandlers =
+                       modest_signal_mgr_connect (priv->sighandlers,
+                                                  G_OBJECT (priv->contents_view), 
+                                                  "vertical-movement", 
+                                                  G_CALLBACK (on_vertical_movement), 
+                                                  self);
+       }
+#endif
 
        /* Mail Operation Queue */
        priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
@@ -414,16 +416,20 @@ connect_signals (ModestHeaderWindow *self)
                                           "clicked",
                                           G_CALLBACK (modest_ui_actions_on_new_msg), self);
 
+#ifdef MODEST_TOOLKIT_HILDON2
        /* Delete using horizontal gesture */
        /* DISABLED because it's unreliabile */
-       if (FALSE) {
-               priv->sighandlers =
-                       modest_signal_mgr_connect (priv->sighandlers,
-                                                  (GObject *) priv->contents_view,
-                                                  "horizontal-movement",
-                                                  G_CALLBACK (on_horizontal_movement),
-                                                  self);
+       if (HILDON_IS_PANNABLE_AREA (priv->contents_view)) {
+               if (FALSE) {
+                       priv->sighandlers =
+                               modest_signal_mgr_connect (priv->sighandlers,
+                                                          (GObject *) priv->contents_view,
+                                                          "horizontal-movement",
+                                                          G_CALLBACK (on_horizontal_movement),
+                                                          self);
+               }
        }
+#endif
 
 
        g_signal_connect(G_OBJECT(self), "key-press-event",
@@ -723,6 +729,7 @@ create_empty_view (ModestWindow *self)
        return viewport;
 }
 
+#ifdef MODEST_TOOLKIT_HILDON2
 static void
 on_vertical_movement (HildonPannableArea *area,
                      HildonMovementDirection direction,
@@ -733,7 +740,7 @@ on_vertical_movement (HildonPannableArea *area,
 
        priv->autoscroll = FALSE;
 }
-
+#endif
 
 ModestWindow *
 modest_header_window_new (TnyFolder *folder, const gchar *account_name, const gchar *mailbox)
@@ -753,7 +760,7 @@ modest_header_window_new (TnyFolder *folder, const gchar *account_name, const gc
        self  = MODEST_HEADER_WINDOW(g_object_new(MODEST_TYPE_HEADER_WINDOW, NULL));
        priv = MODEST_HEADER_WINDOW_GET_PRIVATE(self);
 
-       priv->contents_view = hildon_pannable_area_new ();
+       priv->contents_view = modest_toolkit_factory_create_scrollable (modest_runtime_get_toolkit_factory ());
        alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
        gtk_alignment_set_padding (GTK_ALIGNMENT (alignment),
                                   HILDON_MARGIN_HALF, 0,
@@ -1143,7 +1150,7 @@ on_expose_event(GtkTreeView *header_view,
        g_return_val_if_fail (MODEST_IS_HEADER_WINDOW (self), FALSE);
 
        if (priv->autoscroll)
-               hildon_pannable_area_jump_to (HILDON_PANNABLE_AREA (priv->contents_view), 0.0, 0.0);
+               modest_scrollable_jump_to (MODEST_SCROLLABLE (priv->contents_view), 0.0, 0.0);
 
        return FALSE;
 }
@@ -1450,6 +1457,7 @@ update_sort_button (ModestHeaderWindow *self)
        hildon_button_set_value (HILDON_BUTTON (priv->sort_button), value?value:"");
 }
 
+#ifdef MODEST_TOOLKIT_HILDON2
 static void
 on_horizontal_movement (HildonPannableArea *hildonpannable,
                        gint                direction,
@@ -1484,13 +1492,13 @@ on_horizontal_movement (HildonPannableArea *hildonpannable,
                g_object_unref (header);
        }
 }
-
+#endif
 
 static gboolean
 on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
 {
        ModestHeaderWindowPrivate *priv;
-       HildonPannableArea *pannable;
+       ModestScrollable *scrollable;
        /* FIXME: set scroll_speed depends on for how long the key was pressed */
        gint scroll_speed = 3;
 
@@ -1499,18 +1507,18 @@ on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
 
        priv = MODEST_HEADER_WINDOW_GET_PRIVATE(user_data);
 
-       pannable = HILDON_PANNABLE_AREA (priv->contents_view);
+       scrollable = MODEST_SCROLLABLE (priv->contents_view);
 
        switch (event->keyval) {
 
        case GDK_Up:
                priv->autoscroll = FALSE;
-               modest_maemo_utils_scroll_pannable(pannable, 0, -scroll_speed);
+               modest_scrollable_scroll (scrollable, 0, -scroll_speed);
                break;
 
        case GDK_Down:
                priv->autoscroll = FALSE;
-               modest_maemo_utils_scroll_pannable(pannable, 0, scroll_speed);
+               modest_scrollable_scroll (scrollable, 0, scroll_speed);
                break;
        }
 
index 04e8a7a..b45e0d0 100644 (file)
@@ -28,7 +28,7 @@
  */
 
 #include <modest-mailboxes-window.h>
-#include <hildon/hildon-pannable-area.h>
+#include <modest-scrollable.h>
 #include <modest-window-mgr.h>
 #include <modest-signal-mgr.h>
 #include <modest-runtime.h>
@@ -270,7 +270,7 @@ modest_mailboxes_window_new (const gchar *account)
        ModestMailboxesWindowPrivate *priv = NULL;
        HildonProgram *app;
        GdkPixbuf *window_icon;
-       GtkWidget *pannable;
+       GtkWidget *scrollable;
        GtkWidget *action_area_box;
        GdkPixbuf *new_message_pixbuf;
        guint accel_key;
@@ -281,7 +281,7 @@ modest_mailboxes_window_new (const gchar *account)
        self  = MODEST_MAILBOXES_WINDOW(g_object_new(MODEST_TYPE_MAILBOXES_WINDOW, NULL));
        priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(self);
 
-       pannable = hildon_pannable_area_new ();
+       scrollable = modest_toolkit_factory_create_scrollable (modest_runtime_get_toolkit_factory ());
        priv->queue_change_handler =
                g_signal_connect (G_OBJECT (modest_runtime_get_mail_operation_queue ()),
                                  "queue-changed",
@@ -316,13 +316,13 @@ modest_mailboxes_window_new (const gchar *account)
                                   0, 0, 
                                   MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
 
-       gtk_container_add (GTK_CONTAINER (pannable), priv->folder_view);
-       gtk_box_pack_end (GTK_BOX (priv->top_vbox), pannable, TRUE, TRUE, 0);
+       gtk_container_add (GTK_CONTAINER (scrollable), priv->folder_view);
+       gtk_box_pack_end (GTK_BOX (priv->top_vbox), scrollable, TRUE, TRUE, 0);
        gtk_container_add (GTK_CONTAINER (top_alignment), priv->top_vbox);
        gtk_container_add (GTK_CONTAINER (self), top_alignment);
 
        gtk_widget_show (priv->folder_view);
-       gtk_widget_show (pannable);
+       gtk_widget_show (scrollable);
        gtk_widget_show (top_alignment);
        gtk_widget_show (priv->top_vbox);
 
@@ -619,23 +619,23 @@ static gboolean
 on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
 {
        ModestMailboxesWindowPrivate *priv;
-       HildonPannableArea *pannable;
+       ModestScrollable *scrollable;
 
        if (event->type == GDK_KEY_RELEASE)
                return FALSE;
 
        priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(user_data);
 
-       pannable = HILDON_PANNABLE_AREA (gtk_widget_get_parent (priv->folder_view));
+       scrollable = MODEST_SCROLLABLE (gtk_widget_get_parent (priv->folder_view));
 
        switch (event->keyval) {
 
        case GDK_Up:
-               modest_maemo_utils_scroll_pannable(pannable, 0, -1);
+               modest_scrollable_scroll (scrollable, 0, -1);
                break;
 
        case GDK_Down:
-               modest_maemo_utils_scroll_pannable(pannable, 0, 1);
+               modest_scrollable_scroll (scrollable, 0, 1);
                break;
        }