static gboolean motion_notify_event (GtkWidget *widget, GdkEventMotion *event, ModestAttachmentsView *atts_view);
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 GtkWidget *get_att_view_at_coords (ModestAttachmentsView *atts_view,
gdouble x, gdouble y);
static void unselect_all (ModestAttachmentsView *atts_view);
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);
}
g_signal_connect (G_OBJECT (instance), "button-release-event", G_CALLBACK (button_release_event), instance);
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);
GTK_WIDGET_SET_FLAGS (instance, GTK_CAN_FOCUS);
clipboard_get, clipboard_clear, G_OBJECT(atts_view));
}
+
+static gboolean
+focus_out_event (GtkWidget *widget, GdkEventFocus *event, ModestAttachmentsView *atts_view)
+{
+ if (!gtk_widget_is_focus (widget))
+ unselect_all (atts_view);
+
+ return FALSE;
+}