Fixes NB#111978, show the proper plural form if we have multiple attachments in a...
authorSergio Villar Senin <svillar@igalia.com>
Mon, 20 Apr 2009 11:42:02 +0000 (11:42 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Mon, 20 Apr 2009 11:42:02 +0000 (11:42 +0000)
pmo-trunk-r8949

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

index 96f21c7..f01c51f 100644 (file)
@@ -1006,3 +1006,20 @@ modest_attachments_view_set_style (ModestAttachmentsView *self,
 
        }
 }
+
+guint
+modest_attachments_view_get_num_attachments (ModestAttachmentsView *atts_view)
+{
+       ModestAttachmentsViewPrivate *priv;
+       GList *children;
+       gint result;
+
+       g_return_val_if_fail (MODEST_IS_ATTACHMENTS_VIEW (atts_view), 0);
+       priv = MODEST_ATTACHMENTS_VIEW_GET_PRIVATE (atts_view);
+
+       children = gtk_container_get_children (GTK_CONTAINER (priv->box));
+       result = g_list_length (children);
+       g_list_free (children);
+
+       return result;
+}
index 66b7ad1..27d767a 100644 (file)
@@ -90,7 +90,7 @@ void modest_attachments_view_get_sizes (ModestAttachmentsView *attachments_view,
 
 void modest_attachments_view_set_style (ModestAttachmentsView *attachments_view,
                                        ModestAttachmentsViewStyle style);
-
+guint modest_attachments_view_get_num_attachments (ModestAttachmentsView *atts_view);
 G_END_DECLS
 
 #endif
index 55932a3..63924b9 100644 (file)
@@ -1700,20 +1700,36 @@ set_message (ModestGtkhtmlMsgView *self, TnyMsg *msg)
                                             msg);
 
        modest_mime_part_view_set_view_images (MODEST_MIME_PART_VIEW (priv->body_view), tny_msg_get_allow_external_images (msg));
-       
+
        body = modest_tny_msg_find_body_part (msg, TRUE);
        if (body) {
+               ModestAttachmentsView *widget;
+
                tny_mime_part_view_set_part (TNY_MIME_PART_VIEW (priv->body_view), body);
                g_object_unref (body);
-
-               if(modest_attachments_view_has_attachments (MODEST_ATTACHMENTS_VIEW (priv->attachments_view))) {
+               widget = MODEST_ATTACHMENTS_VIEW (priv->attachments_view);
+
+               if (modest_attachments_view_has_attachments (widget)) {
+                       GtkLabel *label;
+                       GList *children = NULL;
+                       gchar *text = NULL;
+                       /* Ugly but... */
+                       children = gtk_container_get_children (GTK_CONTAINER (priv->attachments_box));
+                       label = GTK_LABEL (children->data);
                        gtk_widget_show_all (priv->attachments_box);
+                       if (modest_attachments_view_get_num_attachments (widget) > 1) {
+                               text = _("mail_va_attachments");
+                       } else {
+                               text = _("mail_va_attachment");
+                       }
+                       gtk_label_set_text (label, text);
                } else {
                        gtk_widget_hide_all (priv->attachments_box);
                }
 
-       } else 
+       } else {
                tny_mime_part_view_clear (TNY_MIME_PART_VIEW (priv->body_view));
+       }
 
        if (modest_mime_part_view_has_external_images (MODEST_MIME_PART_VIEW (priv->body_view)) &&
            !modest_mime_part_view_get_view_images (MODEST_MIME_PART_VIEW (priv->body_view))) {