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);
if (msg == priv->msg) return;
- if (priv->msg)
+ if (priv->msg)
g_object_unref (priv->msg);
if (msg)
g_object_ref (G_OBJECT(msg));
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));
+ own_clipboard (atts_view);
}
}
const gchar *mime_part_id = NULL;
mime_part_id = tny_mime_part_get_content_id (cur_mime_part);
- if ((mime_part_id != NULL) && (strcmp (mime_part_id, att_id) == 0))
+ if ((mime_part_id != NULL) && (strcmp (mime_part_id, att_id) == 0)) {
gtk_widget_destroy (GTK_WIDGET (att_view));
+ priv->selected = g_list_remove (priv->selected, att_view);
+ }
g_object_unref (cur_mime_part);
}
+ own_clipboard (atts_view);
+
}
static void
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;
+}