2007-06-14 Armin Burgmeier <armin@openismus.com>
authorArmin Burgmeier <armin@openismus.com>
Thu, 14 Jun 2007 21:39:11 +0000 (21:39 +0000)
committerArmin Burgmeier <armin@openismus.com>
Thu, 14 Jun 2007 21:39:11 +0000 (21:39 +0000)
* src/widgets/modest-attachments-view.h:
* src/widgets/modest-attachments-view.c: Added
modest_attachments_view_has_attachments() and fixed coordinate
transformation in get_att_view_at_coords(). This fixes attachment
selection.

* src/widgets/modest-msg-view.c: Make use of
modest_attachments_view_has_attachments() to decide whether to show
attachments in the header.

pmo-trunk-r2243

ChangeLog2
src/widgets/modest-attachments-view.c
src/widgets/modest-attachments-view.h
src/widgets/modest-msg-view.c

index 1ef6ee1..43fad96 100644 (file)
@@ -1,3 +1,15 @@
+2007-06-14  Armin Burgmeier  <armin@openismus.com>
+
+       * src/widgets/modest-attachments-view.h:
+       * src/widgets/modest-attachments-view.c: Added
+       modest_attachments_view_has_attachments() and fixed coordinate
+       transformation in get_att_view_at_coords(). This fixes attachment
+       selection.
+
+       * src/widgets/modest-msg-view.c: Make use of
+       modest_attachments_view_has_attachments() to decide whether to show
+       attachments in the header.
+
 2007-06-14  Johannes Schmid <johannes.schmid@openismus.com>
 
        * src/maemo/modest-connection-specific-smtp-edit-window.c:
index e6a4b32..2ed99c7 100644 (file)
@@ -531,8 +531,8 @@ get_att_view_at_coords (ModestAttachmentsView *atts_view,
                w = att_view->allocation.width;
                h = att_view->allocation.height;
 
-               int_x = (gint) x;
-               int_y = (gint) y;
+               int_x = (gint) x - GTK_WIDGET (atts_view)->allocation.x;
+               int_y = (gint) y - GTK_WIDGET (atts_view)->allocation.y;
 
                if ((x >= pos_x) && (x <= (pos_x + w)) && (y >= pos_y) && (y <= (pos_y + h))) {
                        result = att_view;
@@ -720,6 +720,23 @@ modest_attachments_view_select_all (ModestAttachmentsView *atts_view)
        own_clipboard (atts_view);
 }
 
+gboolean
+modest_attachments_view_has_attachments (ModestAttachmentsView *atts_view)
+{
+       ModestAttachmentsViewPrivate *priv;
+       GList *children;
+       gboolean result;
+
+       g_return_val_if_fail (MODEST_IS_ATTACHMENTS_VIEW (atts_view), FALSE);
+       priv = MODEST_ATTACHMENTS_VIEW_GET_PRIVATE (atts_view);
+
+       children = gtk_container_get_children (GTK_CONTAINER (priv->box));
+       result = (children != NULL);
+       g_list_free (children);
+
+       return result;
+}
+
 static void
 own_clipboard (ModestAttachmentsView *atts_view)
 {
index 90f59e2..5677e85 100644 (file)
@@ -74,6 +74,7 @@ GList *modest_attachments_view_get_attachments (ModestAttachmentsView *attachmen
 GList *modest_attachments_view_get_selection (ModestAttachmentsView *attachments_view);
 void modest_attachments_view_select_all (ModestAttachmentsView *attachments_view);
 
+gboolean modest_attachments_view_has_attachments (ModestAttachmentsView *attachments_view);
 
 G_END_DECLS
 
index b0ab8d3..b480ce1 100644 (file)
@@ -1369,16 +1369,13 @@ modest_msg_view_set_message (ModestMsgView *self, TnyMsg *msg)
        
        body = modest_tny_msg_find_body_part (msg,TRUE);
        if (body) {
-               GList *att_children;
                if (tny_mime_part_content_type_is (body, "text/html"))
                        set_html_message (self, body, msg);
                else
                        set_text_message (self, body, msg);
 
-               att_children = gtk_container_get_children (GTK_CONTAINER (priv->attachments_view));
-               if (att_children != NULL) {
+               if(modest_attachments_view_has_attachments (MODEST_ATTACHMENTS_VIEW (priv->attachments_view))) {
                        gtk_widget_show_all (priv->attachments_box);
-                       g_list_free (att_children);
                } else {
                        gtk_widget_hide_all (priv->attachments_box);
                }