static gboolean button_release_event (GtkWidget *widget, GdkEventButton *event, ModestAttachmentsView *atts_view);
static gboolean key_press_event (GtkWidget *widget, GdkEventKey *event, ModestAttachmentsView *atts_view);
static gboolean focus_out_event (GtkWidget *widget, GdkEventFocus *event, ModestAttachmentsView *atts_view);
+static gboolean focus (GtkWidget *widget, GtkDirectionType direction, ModestAttachmentsView *atts_view);
static GtkWidget *get_att_view_at_coords (ModestAttachmentsView *atts_view,
gdouble x, gdouble y);
static void unselect_all (ModestAttachmentsView *atts_view);
ModestAttachmentsViewPrivate *priv = MODEST_ATTACHMENTS_VIEW_GET_PRIVATE (attachments_view);
TnyList *parts;
TnyIterator *iter;
+ const gchar *msg_content_type = NULL;
if (msg == priv->msg) return;
return;
}
+ /* If the top mime part is a multipart/related, we don't show the attachments, as they're
+ * embedded images in body */
+ msg_content_type = tny_mime_part_get_content_type (TNY_MIME_PART (priv->msg));
+ if ((msg_content_type != NULL) && !strcasecmp (msg_content_type, "multipart/related")) {
+ gtk_widget_queue_draw (GTK_WIDGET (attachments_view));
+ return;
+ }
+
+
parts = TNY_LIST (tny_simple_list_new ());
tny_mime_part_get_parts (TNY_MIME_PART (priv->msg), parts);
iter = tny_list_create_iterator (parts);
TnyMimePart *part;
part = TNY_MIME_PART (tny_iterator_get_current (iter));
- if (tny_mime_part_is_attachment (part) || TNY_IS_MSG (part)) {
+ if (part && (tny_mime_part_is_attachment (part) || TNY_IS_MSG (part))) {
modest_attachments_view_add_attachment (attachments_view, part);
}
- g_object_unref (part);
+
+ if (part)
+ g_object_unref (part);
+
tny_iterator_next (iter);
}
}
if (found_att_view) {
- priv->selected = g_list_remove (priv->selected, found_att_view);
- gtk_widget_destroy (GTK_WIDGET (found_att_view));
+ GList *node = NULL;
+ GtkWidget *next_widget = NULL;
+ GList *box_children = NULL;
+
+ box_children = gtk_container_get_children (GTK_CONTAINER (priv->box));
+ node = g_list_find (box_children, found_att_view);
+ if (node->next)
+ next_widget = node->next->data;
+
+ g_list_free (box_children);
+
+ node = g_list_find (priv->selected, found_att_view);
+ if (node != NULL) {
+ priv->selected = g_list_delete_link (priv->selected, node);
+ gtk_widget_destroy (GTK_WIDGET (found_att_view));
+ if ((priv->selected == NULL) && (next_widget != NULL))
+ set_selected (MODEST_ATTACHMENTS_VIEW (atts_view),
+ MODEST_ATTACHMENT_VIEW (next_widget));
+ }
own_clipboard (atts_view);
}
g_signal_connect (G_OBJECT (instance), "motion-notify-event", G_CALLBACK (motion_notify_event), instance);
g_signal_connect (G_OBJECT (instance), "key-press-event", G_CALLBACK (key_press_event), instance);
g_signal_connect (G_OBJECT (instance), "focus-out-event", G_CALLBACK (focus_out_event), instance);
+ g_signal_connect (G_OBJECT (instance), "focus", G_CALLBACK (focus), instance);
GTK_WIDGET_SET_FLAGS (instance, GTK_CAN_FOCUS);
return FALSE;
}
+
+static gboolean
+focus (GtkWidget *widget, GtkDirectionType direction, ModestAttachmentsView *atts_view)
+{
+ ModestAttachmentsViewPrivate *priv = MODEST_ATTACHMENTS_VIEW_GET_PRIVATE (atts_view);
+ GList *children = NULL;
+ GtkWidget *toplevel = NULL;
+
+ toplevel = gtk_widget_get_toplevel (widget);
+ if (!gtk_window_has_toplevel_focus (GTK_WINDOW (toplevel)))
+ return FALSE;
+
+ children = gtk_container_get_children (GTK_CONTAINER (priv->box));
+ if (children != NULL) {
+ set_selected (atts_view, MODEST_ATTACHMENT_VIEW (children->data));
+ }
+ g_list_free (children);
+
+ return FALSE;
+}