* src/widgets/modest-gtkhtml-msg-view.c:
[modest] / src / widgets / modest-gtkhtml-msg-view.c
index a2d66c1..4532119 100644 (file)
@@ -98,6 +98,13 @@ static void disconnect_vadjustment (ModestGtkhtmlMsgView *obj);
 static void disconnect_hadjustment (ModestGtkhtmlMsgView *obj);
 static gboolean idle_readjust_scroll (ModestGtkhtmlMsgView *obj);
 
+/* vertical panning implementation */
+#ifdef MAEMO_CHANGES
+static gboolean motion_notify_event (GtkWidget *widget,
+                                    GdkEventMotion *event,
+                                    gpointer userdata);
+#endif
+
 /* GtkContainer methods */
 static void forall (GtkContainer *container, gboolean include_internals,
                    GtkCallback callback, gpointer userdata);
@@ -148,8 +155,8 @@ static void modest_gtkhtml_msg_view_set_shadow_type (ModestMsgView *self, GtkSha
 static GtkShadowType modest_gtkhtml_msg_view_get_shadow_type (ModestMsgView *self);
 static TnyHeaderFlags modest_gtkhtml_msg_view_get_priority (ModestMsgView *self);
 static void modest_gtkhtml_msg_view_set_priority (ModestMsgView *self, TnyHeaderFlags flags);
-static GList *modest_gtkhtml_msg_view_get_selected_attachments (ModestMsgView *self);
-static GList *modest_gtkhtml_msg_view_get_attachments (ModestMsgView *self);
+static TnyList *modest_gtkhtml_msg_view_get_selected_attachments (ModestMsgView *self);
+static TnyList *modest_gtkhtml_msg_view_get_attachments (ModestMsgView *self);
 static void modest_gtkhtml_msg_view_grab_focus (ModestMsgView *self);
 static void modest_gtkhtml_msg_view_remove_attachment (ModestMsgView *view, TnyMimePart *attachment);
 static GtkAdjustment *modest_gtkhtml_msg_view_get_vadjustment_default (ModestMsgView *self);
@@ -160,8 +167,8 @@ static void modest_gtkhtml_msg_view_set_shadow_type_default (ModestMsgView *self
 static GtkShadowType modest_gtkhtml_msg_view_get_shadow_type_default (ModestMsgView *self);
 static TnyHeaderFlags modest_gtkhtml_msg_view_get_priority_default (ModestMsgView *self);
 static void modest_gtkhtml_msg_view_set_priority_default (ModestMsgView *self, TnyHeaderFlags flags);
-static GList *modest_gtkhtml_msg_view_get_selected_attachments_default (ModestMsgView *self);
-static GList *modest_gtkhtml_msg_view_get_attachments_default (ModestMsgView *self);
+static TnyList *modest_gtkhtml_msg_view_get_selected_attachments_default (ModestMsgView *self);
+static TnyList *modest_gtkhtml_msg_view_get_attachments_default (ModestMsgView *self);
 static void modest_gtkhtml_msg_view_grab_focus_default (ModestMsgView *self);
 static void modest_gtkhtml_msg_view_remove_attachment_default (ModestMsgView *view, TnyMimePart *attachment);
 
@@ -181,8 +188,8 @@ static void set_shadow_type (ModestGtkhtmlMsgView *self, GtkShadowType type);
 static GtkShadowType get_shadow_type (ModestGtkhtmlMsgView *self);
 static TnyHeaderFlags get_priority (ModestGtkhtmlMsgView *self);
 static void set_priority (ModestGtkhtmlMsgView *self, TnyHeaderFlags flags);
-static GList *get_selected_attachments (ModestGtkhtmlMsgView *self);
-static GList *get_attachments (ModestGtkhtmlMsgView *self);
+static TnyList *get_selected_attachments (ModestGtkhtmlMsgView *self);
+static TnyList *get_attachments (ModestGtkhtmlMsgView *self);
 static void grab_focus (ModestGtkhtmlMsgView *self);
 static void remove_attachment (ModestGtkhtmlMsgView *view, TnyMimePart *attachment);
 
@@ -1043,6 +1050,10 @@ modest_gtkhtml_msg_view_init (ModestGtkhtmlMsgView *obj)
                                       G_CALLBACK(on_fetch_url), obj);
        g_signal_connect (G_OBJECT(priv->body_view), "link_hover",
                                       G_CALLBACK(on_link_hover), obj);
+#ifdef MAEMO_CHANGES
+       g_signal_connect (G_OBJECT(priv->body_view), "motion-notify-event",
+                         G_CALLBACK (motion_notify_event), obj);
+#endif
 
        g_signal_connect (G_OBJECT (priv->mail_header_view), "recpt-activated", 
                          G_CALLBACK (on_recpt_activated), obj);
@@ -1126,6 +1137,35 @@ modest_gtkhtml_msg_view_destroy (GtkObject *obj)
 
 /* INTERNAL METHODS */
 
+#ifdef MAEMO_CHANGES
+static gboolean 
+motion_notify_event (GtkWidget *widget,
+                    GdkEventMotion *event,
+                    gpointer userdata)
+{
+       ModestGtkhtmlMsgViewPrivate *priv = MODEST_GTKHTML_MSG_VIEW_GET_PRIVATE (userdata);
+
+       /* Use panning information in gtkhtml widget to support also vertical panning */
+
+       if (GTK_HTML (widget)->panning) {
+               gint y, dy;
+               gdouble value;
+
+               gdk_window_get_pointer (GTK_LAYOUT (widget)->bin_window, NULL, &y, NULL);
+               dy = y - GTK_HTML (widget)->lasty;
+               value = priv->vadj->value - (gdouble) dy;
+
+               if (value < priv->vadj->lower)
+                       value = priv->vadj->lower;
+               else if (value > priv->vadj->upper - priv->vadj->page_size)
+                       value = priv->vadj->upper - priv->vadj->page_size;
+               gtk_adjustment_set_value (priv->vadj, value);
+               
+       }
+       return FALSE;
+}
+#endif
+
 static GtkAdjustment *
 get_vadjustment (ModestGtkhtmlMsgView *self)
 {
@@ -1405,7 +1445,7 @@ on_fetch_url (GtkWidget *widget, const gchar *uri,
                return FALSE;   
        }
 
-       tny_mime_part_decode_to_stream ((TnyMimePart*)part, stream);
+       tny_mime_part_decode_to_stream ((TnyMimePart*)part, stream, NULL);
        g_object_unref (G_OBJECT(part));
        return TRUE;
 }
@@ -1633,7 +1673,7 @@ search_next (ModestGtkhtmlMsgView *self)
        return result;
 }
 
-static GList *
+static TnyList *
 get_selected_attachments (ModestGtkhtmlMsgView *self)
 {
        ModestGtkhtmlMsgViewPrivate *priv;
@@ -1645,7 +1685,7 @@ get_selected_attachments (ModestGtkhtmlMsgView *self)
        
 }
 
-static GList *
+static TnyList *
 get_attachments (ModestGtkhtmlMsgView *self)
 {
        ModestGtkhtmlMsgViewPrivate *priv;
@@ -1689,12 +1729,12 @@ tny_msg_view_init (gpointer g, gpointer iface_data)
 {
        TnyMsgViewIface *klass = (TnyMsgViewIface *)g;
 
-       klass->get_msg_func = modest_msg_view_get_msg;
-       klass->set_msg_func = modest_msg_view_set_msg;
-       klass->set_unavailable_func = modest_msg_view_set_unavailable;
-       klass->clear_func = modest_msg_view_clear;
-       klass->create_mime_part_view_for_func = modest_msg_view_create_mime_part_view_for;
-       klass->create_new_inline_viewer_func = modest_msg_view_create_new_inline_viewer;
+       klass->get_msg = modest_msg_view_get_msg;
+       klass->set_msg = modest_msg_view_set_msg;
+       klass->set_unavailable = modest_msg_view_set_unavailable;
+       klass->clear = modest_msg_view_clear;
+       klass->create_mime_part_view_for = modest_msg_view_create_mime_part_view_for;
+       klass->create_new_inline_viewer = modest_msg_view_create_new_inline_viewer;
 
        return;
 }
@@ -1786,9 +1826,9 @@ tny_mime_part_view_init (gpointer g, gpointer iface_data)
 {
        TnyMimePartViewIface *klass = (TnyMimePartViewIface *)g;
 
-       klass->get_part_func = modest_msg_view_mp_get_part;
-       klass->set_part_func = modest_msg_view_mp_set_part;
-       klass->clear_func = modest_msg_view_mp_clear;
+       klass->get_part = modest_msg_view_mp_get_part;
+       klass->set_part = modest_msg_view_mp_set_part;
+       klass->clear = modest_msg_view_mp_clear;
 
        return;
 }
@@ -2070,25 +2110,25 @@ modest_gtkhtml_msg_view_get_priority_default (ModestMsgView *self)
        return get_priority (MODEST_GTKHTML_MSG_VIEW (self));
 }
 
-static GList*
+static TnyList*
 modest_gtkhtml_msg_view_get_selected_attachments (ModestMsgView *self)
 {
        return MODEST_GTKHTML_MSG_VIEW_GET_CLASS (self)->get_selected_attachments_func (self);
 }
 
-static GList*
+static TnyList*
 modest_gtkhtml_msg_view_get_selected_attachments_default (ModestMsgView *self)
 {
        return get_selected_attachments (MODEST_GTKHTML_MSG_VIEW (self));
 }
 
-static GList*
+static TnyList*
 modest_gtkhtml_msg_view_get_attachments (ModestMsgView *self)
 {
        return MODEST_GTKHTML_MSG_VIEW_GET_CLASS (self)->get_attachments_func (self);
 }
 
-static GList*
+static TnyList*
 modest_gtkhtml_msg_view_get_attachments_default (ModestMsgView *self)
 {
        return get_attachments (MODEST_GTKHTML_MSG_VIEW (self));
@@ -2117,4 +2157,3 @@ modest_gtkhtml_msg_view_remove_attachment_default (ModestMsgView *self, TnyMimeP
 {
        remove_attachment (MODEST_GTKHTML_MSG_VIEW (self), attachment);
 }
-