diff options
-rw-r--r-- | addressbook/gui/contact-list-editor/e-contact-list-editor.c | 47 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-selector.c | 12 | ||||
-rw-r--r-- | calendar/gui/e-calendar-selector.c | 15 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 77 | ||||
-rw-r--r-- | calendar/gui/e-memo-list-selector.c | 15 | ||||
-rw-r--r-- | calendar/gui/e-task-list-selector.c | 15 | ||||
-rw-r--r-- | e-util/e-selection.c | 102 | ||||
-rw-r--r-- | e-util/e-selection.h | 15 | ||||
-rw-r--r-- | modules/addressbook/e-book-shell-view-actions.c | 2 | ||||
-rw-r--r-- | modules/calendar/e-memo-shell-content.c | 26 | ||||
-rw-r--r-- | modules/calendar/e-task-shell-content.c | 26 | ||||
-rw-r--r-- | widgets/misc/e-attachment-view.c | 23 |
12 files changed, 228 insertions, 147 deletions
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c index 0b0c71711d..23da590e72 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -25,6 +25,7 @@ #include "e-contact-list-editor.h" #include <e-util/e-util-private.h> #include <e-util/e-alert-dialog.h> +#include <e-util/e-selection.h> #include "shell/e-shell.h" #include <string.h> @@ -127,16 +128,6 @@ struct _EContactListEditorPrivate { EBook *load_book; }; -#define VCARD_TYPE "text/x-vcard" - -enum { - TARGET_TYPE_VCARD -}; - -static GtkTargetEntry targets[] = { - { (gchar *) VCARD_TYPE, 0, TARGET_TYPE_VCARD }, -}; - static gpointer parent_class; static EContactListEditor * @@ -439,24 +430,25 @@ contact_list_editor_drag_data_received_cb (GtkWidget *widget, void contact_list_editor_drag_data_received_cb (GtkWidget *widget, GdkDragContext *context, - gint x, gint y, - GtkSelectionData *selection_data, - guint info, - guint time) + gint x, gint y, + GtkSelectionData *selection_data, + guint info, + guint time) { EContactListEditor *editor; EContactListModel *model; - gchar *target_type; gboolean changed = FALSE; gboolean handled = FALSE; GList *list, *iter; + GdkAtom target; editor = contact_list_editor_extract (widget); model = E_CONTACT_LIST_MODEL (editor->priv->model); - target_type = gdk_atom_name (selection_data->target); - if (strcmp (target_type, VCARD_TYPE) != 0) + /* Sanity check the selection target. */ + target = gtk_selection_data_get_target (selection_data); + if (!e_targets_include_directory (&target, 1)) goto exit; list = eab_contact_list_from_string ((gchar *) selection_data->data); @@ -516,14 +508,8 @@ contact_list_editor_drag_drop_cb (GtkWidget *widget, for (iter = context->targets; iter != NULL; iter = iter->next) { GdkAtom target = GDK_POINTER_TO_ATOM (iter->data); - gchar *possible_type; - gboolean match; - possible_type = gdk_atom_name (target); - match = (strcmp (possible_type, VCARD_TYPE) == 0); - g_free (possible_type); - - if (match) { + if (e_targets_include_directory (&target, 1)) { gtk_drag_get_data (widget, context, target, time); return TRUE; } @@ -548,14 +534,8 @@ contact_list_editor_drag_motion_cb (GtkWidget *widget, for (iter = context->targets; iter != NULL; iter = iter->next) { GdkAtom target = GDK_POINTER_TO_ATOM (iter->data); - gchar *possible_type; - gboolean match; - - possible_type = gdk_atom_name (target); - match = (strcmp (possible_type, VCARD_TYPE) == 0); - g_free (possible_type); - if (match) { + if (e_targets_include_directory (&target, 1)) { gdk_drag_status (context, GDK_ACTION_LINK, time); return TRUE; } @@ -1318,8 +1298,9 @@ contact_list_editor_init (EContactListEditor *editor) gtk_tree_selection_set_mode ( gtk_tree_view_get_selection (view), GTK_SELECTION_MULTIPLE); - gtk_tree_view_enable_model_drag_dest ( - view, targets, G_N_ELEMENTS (targets), GDK_ACTION_LINK); + + gtk_tree_view_enable_model_drag_dest (view, NULL, 0, GDK_ACTION_LINK); + e_drag_dest_add_directory_targets (WIDGET (TREE_VIEW)); g_signal_connect ( priv->model, "row-deleted", diff --git a/addressbook/gui/widgets/e-addressbook-selector.c b/addressbook/gui/widgets/e-addressbook-selector.c index 21347e2529..d33680ac99 100644 --- a/addressbook/gui/widgets/e-addressbook-selector.c +++ b/addressbook/gui/widgets/e-addressbook-selector.c @@ -20,6 +20,8 @@ #include "e-addressbook-selector.h" +#include <e-util/e-selection.h> + #include <eab-book-util.h> #include <eab-contact-merging.h> @@ -53,14 +55,8 @@ enum { PROP_CURRENT_VIEW }; -enum { - DND_TARGET_TYPE_VCARD, - DND_TARGET_TYPE_SOURCE_VCARD -}; - static GtkTargetEntry drag_types[] = { - { (gchar *) "text/x-vcard", 0, DND_TARGET_TYPE_VCARD }, - { (gchar *) "text/x-source-vcard", 0, DND_TARGET_TYPE_SOURCE_VCARD } + { (gchar *) "text/x-source-vcard", 0, 0 } }; static gpointer parent_class; @@ -367,6 +363,8 @@ addressbook_selector_init (EAddressbookSelector *selector) GTK_WIDGET (selector), GTK_DEST_DEFAULT_ALL, drag_types, G_N_ELEMENTS (drag_types), GDK_ACTION_COPY | GDK_ACTION_MOVE); + + e_drag_dest_add_directory_targets (GTK_WIDGET (selector)); } GType diff --git a/calendar/gui/e-calendar-selector.c b/calendar/gui/e-calendar-selector.c index 14c635b698..0747b55b59 100644 --- a/calendar/gui/e-calendar-selector.c +++ b/calendar/gui/e-calendar-selector.c @@ -21,6 +21,7 @@ #include "e-calendar-selector.h" #include <libecal/e-cal.h> +#include "e-util/e-selection.h" #include "common/authentication.h" #define E_CALENDAR_SELECTOR_GET_PRIVATE(obj) \ @@ -31,15 +32,6 @@ struct _ECalendarSelectorPrivate { gint dummy_value; }; -enum { - DND_TARGET_TYPE_CALENDAR_LIST -}; - -static GtkTargetEntry drag_types[] = { - { (gchar *) "text/calendar", 0, DND_TARGET_TYPE_CALENDAR_LIST }, - { (gchar *) "text/x-calendar", 0, DND_TARGET_TYPE_CALENDAR_LIST } -}; - static gpointer parent_class; static gboolean @@ -174,8 +166,9 @@ calendar_selector_init (ECalendarSelector *selector) gtk_drag_dest_set ( GTK_WIDGET (selector), GTK_DEST_DEFAULT_ALL, - drag_types, G_N_ELEMENTS (drag_types), - GDK_ACTION_COPY | GDK_ACTION_MOVE); + NULL, 0, GDK_ACTION_COPY | GDK_ACTION_MOVE); + + e_drag_dest_add_calendar_targets (GTK_WIDGET (selector)); } GType diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 5b9d68b9ed..3800fd69c6 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -40,6 +40,7 @@ #include <e-util/e-binding.h> #include <e-util/e-categories-config.h> #include <e-util/e-dialog-utils.h> +#include <e-util/e-selection.h> #include <libecal/e-cal-time-util.h> #include <libedataserver/e-data-server-util.h> @@ -102,14 +103,8 @@ typedef struct { } AddEventData; /* Drag and Drop stuff. */ -enum { - TARGET_CALENDAR_EVENT, - TARGET_VCALENDAR -}; static GtkTargetEntry target_table[] = { - { (gchar *) "application/x-e-calendar-event", 0, TARGET_CALENDAR_EVENT }, - { (gchar *) "text/x-calendar", 0, TARGET_VCALENDAR }, - { (gchar *) "text/calendar", 0, TARGET_VCALENDAR } + { (gchar *) "application/x-e-calendar-event", 0, 0 } }; static void e_day_view_destroy (GtkObject *object); @@ -1330,14 +1325,19 @@ e_day_view_init (EDayView *day_view) day_view->last_cursor_set_in_main_canvas = NULL; /* Set up the drop sites. */ - gtk_drag_dest_set (day_view->top_canvas, - GTK_DEST_DEFAULT_ALL, - target_table, G_N_ELEMENTS (target_table), - GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK); - gtk_drag_dest_set (day_view->main_canvas, - GTK_DEST_DEFAULT_ALL, - target_table, G_N_ELEMENTS (target_table), - GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK); + gtk_drag_dest_set ( + day_view->top_canvas, GTK_DEST_DEFAULT_ALL, + target_table, G_N_ELEMENTS (target_table), + GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK); + + e_drag_dest_add_calendar_targets (day_view->top_canvas); + + gtk_drag_dest_set ( + day_view->main_canvas, GTK_DEST_DEFAULT_ALL, + target_table, G_N_ELEMENTS (target_table), + GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK); + + e_drag_dest_add_calendar_targets (day_view->main_canvas); /* connect to ECalendarView's signals */ g_signal_connect (G_OBJECT (day_view), "timezone_changed", @@ -3861,6 +3861,7 @@ e_day_view_on_top_canvas_motion (GtkWidget *widget, target_list = gtk_target_list_new ( target_table, G_N_ELEMENTS (target_table)); + e_target_list_add_calendar_targets (target_list, 0); gtk_drag_begin (widget, target_list, GDK_ACTION_COPY | GDK_ACTION_MOVE, 1, (GdkEvent*)mevent); @@ -3962,6 +3963,7 @@ e_day_view_on_main_canvas_motion (GtkWidget *widget, target_list = gtk_target_list_new ( target_table, G_N_ELEMENTS (target_table)); + e_target_list_add_calendar_targets (target_list, 0); gtk_drag_begin (widget, target_list, GDK_ACTION_COPY | GDK_ACTION_MOVE, 1, (GdkEvent*)mevent); @@ -7548,7 +7550,9 @@ e_day_view_on_drag_data_get (GtkWidget *widget, EDayView *day_view) { EDayViewEvent *event; + icalcomponent *vcal; gint day, event_num; + gchar *comp_str; day = day_view->drag_event_day; event_num = day_view->drag_event_num; @@ -7564,34 +7568,31 @@ e_day_view_on_drag_data_get (GtkWidget *widget, event = &g_array_index (day_view->events[day], EDayViewEvent, event_num); - if (info == TARGET_CALENDAR_EVENT || info == TARGET_VCALENDAR) { - /* we will pass an icalcalendar component for both types */ - gchar *comp_str; - icalcomponent *vcal; - - vcal = e_cal_util_new_top_level (); - e_cal_util_add_timezones_from_component (vcal, event->comp_data->icalcomp); - icalcomponent_add_component (vcal, icalcomponent_new_clone (event->comp_data->icalcomp)); + vcal = e_cal_util_new_top_level (); + e_cal_util_add_timezones_from_component ( + vcal, event->comp_data->icalcomp); + icalcomponent_add_component ( + vcal, icalcomponent_new_clone (event->comp_data->icalcomp)); - comp_str = icalcomponent_as_ical_string_r (vcal); - if (comp_str) { - ESource *source = e_cal_get_source (event->comp_data->client); - const gchar *source_uid = e_source_peek_uid (source); - gchar *tmp; + comp_str = icalcomponent_as_ical_string_r (vcal); + if (comp_str) { + ESource *source = e_cal_get_source (event->comp_data->client); + const gchar *source_uid = e_source_peek_uid (source); + gchar *tmp; - if (!source_uid) - source_uid = ""; + if (!source_uid) + source_uid = ""; - tmp = g_strconcat (source_uid, "\n", comp_str, NULL); - gtk_selection_data_set (selection_data, selection_data->target, - 8, (guchar *)tmp, strlen (tmp)); + tmp = g_strconcat (source_uid, "\n", comp_str, NULL); + gtk_selection_data_set ( + selection_data, selection_data->target, + 8, (guchar *) tmp, strlen (tmp)); - g_free (tmp); - } - - icalcomponent_free (vcal); - g_free (comp_str); + g_free (tmp); } + + icalcomponent_free (vcal); + g_free (comp_str); } static void diff --git a/calendar/gui/e-memo-list-selector.c b/calendar/gui/e-memo-list-selector.c index d84a70b3b3..8e0ae7c203 100644 --- a/calendar/gui/e-memo-list-selector.c +++ b/calendar/gui/e-memo-list-selector.c @@ -22,6 +22,7 @@ #include <string.h> #include <libecal/e-cal.h> +#include "e-util/e-selection.h" #include "calendar/common/authentication.h" #include "calendar/gui/comp-util.h" @@ -33,15 +34,6 @@ struct _EMemoListSelectorPrivate { gint dummy_value; }; -enum { - DND_TARGET_TYPE_CALENDAR_LIST -}; - -static GtkTargetEntry drag_types[] = { - { (gchar *) "text/calendar", 0, DND_TARGET_TYPE_CALENDAR_LIST }, - { (gchar *) "text/x-calendar", 0, DND_TARGET_TYPE_CALENDAR_LIST } -}; - static gpointer parent_class; static gboolean @@ -245,8 +237,9 @@ memo_list_selector_init (EMemoListSelector *selector) gtk_drag_dest_set ( GTK_WIDGET (selector), GTK_DEST_DEFAULT_ALL, - drag_types, G_N_ELEMENTS (drag_types), - GDK_ACTION_COPY | GDK_ACTION_MOVE); + NULL, 0, GDK_ACTION_COPY | GDK_ACTION_MOVE); + + e_drag_dest_add_calendar_targets (GTK_WIDGET (selector)); } GType diff --git a/calendar/gui/e-task-list-selector.c b/calendar/gui/e-task-list-selector.c index 34432b0ed4..317d7cae37 100644 --- a/calendar/gui/e-task-list-selector.c +++ b/calendar/gui/e-task-list-selector.c @@ -22,6 +22,7 @@ #include <string.h> #include <libecal/e-cal.h> +#include "e-util/e-selection.h" #include "calendar/common/authentication.h" #include "calendar/gui/comp-util.h" @@ -33,15 +34,6 @@ struct _ETaskListSelectorPrivate { gint dummy_value; }; -enum { - DND_TARGET_TYPE_CALENDAR_LIST -}; - -static GtkTargetEntry drag_types[] = { - { (gchar *) "text/calendar", 0, DND_TARGET_TYPE_CALENDAR_LIST }, - { (gchar *) "text/x-calendar", 0, DND_TARGET_TYPE_CALENDAR_LIST } -}; - static gpointer parent_class; static gboolean @@ -246,8 +238,9 @@ task_list_selector_init (ETaskListSelector *selector) gtk_drag_dest_set ( GTK_WIDGET (selector), GTK_DEST_DEFAULT_ALL, - drag_types, G_N_ELEMENTS (drag_types), - GDK_ACTION_COPY | GDK_ACTION_MOVE); + NULL, 0, GDK_ACTION_COPY | GDK_ACTION_MOVE); + + e_drag_dest_add_calendar_targets (GTK_WIDGET (selector)); } GType diff --git a/e-util/e-selection.c b/e-util/e-selection.c index 21c63023f0..8be4c0b55a 100644 --- a/e-util/e-selection.c +++ b/e-util/e-selection.c @@ -797,3 +797,105 @@ e_clipboard_wait_is_html_available (GtkClipboard *clipboard) return result; } + +void +e_drag_dest_add_calendar_targets (GtkWidget *widget) +{ + GtkTargetList *target_list; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + + target_list = gtk_drag_source_get_target_list (widget); + if (target_list != NULL) + gtk_target_list_ref (target_list); + else + target_list = gtk_target_list_new (NULL, 0); + e_target_list_add_calendar_targets (target_list, 0); + gtk_drag_dest_set_target_list (widget, target_list); + gtk_target_list_unref (target_list); +} + +void +e_drag_dest_add_directory_targets (GtkWidget *widget) +{ + GtkTargetList *target_list; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + + target_list = gtk_drag_source_get_target_list (widget); + if (target_list != NULL) + gtk_target_list_ref (target_list); + else + target_list = gtk_target_list_new (NULL, 0); + e_target_list_add_directory_targets (target_list, 0); + gtk_drag_dest_set_target_list (widget, target_list); + gtk_target_list_unref (target_list); +} + +void +e_drag_dest_add_html_targets (GtkWidget *widget) +{ + GtkTargetList *target_list; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + + target_list = gtk_drag_source_get_target_list (widget); + if (target_list != NULL) + gtk_target_list_ref (target_list); + else + target_list = gtk_target_list_new (NULL, 0); + e_target_list_add_html_targets (target_list, 0); + gtk_drag_dest_set_target_list (widget, target_list); + gtk_target_list_unref (target_list); +} + +void +e_drag_source_add_calendar_targets (GtkWidget *widget) +{ + GtkTargetList *target_list; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + + target_list = gtk_drag_source_get_target_list (widget); + if (target_list != NULL) + gtk_target_list_ref (target_list); + else + target_list = gtk_target_list_new (NULL, 0); + e_target_list_add_calendar_targets (target_list, 0); + gtk_drag_source_set_target_list (widget, target_list); + gtk_target_list_unref (target_list); +} + +void +e_drag_source_add_directory_targets (GtkWidget *widget) +{ + GtkTargetList *target_list; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + + target_list = gtk_drag_source_get_target_list (widget); + if (target_list != NULL) + gtk_target_list_ref (target_list); + else + target_list = gtk_target_list_new (NULL, 0); + e_target_list_add_directory_targets (target_list, 0); + gtk_drag_source_set_target_list (widget, target_list); + gtk_target_list_unref (target_list); +} + +void +e_drag_source_add_html_targets (GtkWidget *widget) +{ + GtkTargetList *target_list; + + g_return_if_fail (GTK_IS_WIDGET (widget)); + + target_list = gtk_drag_source_get_target_list (widget); + if (target_list != NULL) + gtk_target_list_ref (target_list); + else + target_list = gtk_target_list_new (NULL, 0); + e_target_list_add_html_targets (target_list, 0); + gtk_drag_source_set_target_list (widget, target_list); + gtk_target_list_unref (target_list); +} diff --git a/e-util/e-selection.h b/e-util/e-selection.h index 2c59d3d641..f179180cd9 100644 --- a/e-util/e-selection.h +++ b/e-util/e-selection.h @@ -114,6 +114,21 @@ gboolean e_clipboard_wait_is_directory_available gboolean e_clipboard_wait_is_html_available (GtkClipboard *clipboard); +/* Drag and Drop Functions */ + +void e_drag_dest_add_calendar_targets + (GtkWidget *widget); +void e_drag_dest_add_directory_targets + (GtkWidget *widget); +void e_drag_dest_add_html_targets + (GtkWidget *widget); +void e_drag_source_add_calendar_targets + (GtkWidget *widget); +void e_drag_source_add_directory_targets + (GtkWidget *widget); +void e_drag_source_add_html_targets + (GtkWidget *widget); + G_END_DECLS #endif /* E_SELECTION_H */ diff --git a/modules/addressbook/e-book-shell-view-actions.c b/modules/addressbook/e-book-shell-view-actions.c index c439fafec8..dbfdc991e7 100644 --- a/modules/addressbook/e-book-shell-view-actions.c +++ b/modules/addressbook/e-book-shell-view-actions.c @@ -552,7 +552,7 @@ action_contact_save_as_cb (GtkAction *action, /* XXX No callback means errors are discarded. * - * There an EAlert for this which I'm not using + * There's an EAlert for this which I'm not using * until I figure out a better way to display errors: * * "addressbook:save-error" diff --git a/modules/calendar/e-memo-shell-content.c b/modules/calendar/e-memo-shell-content.c index e34af1fbf8..34946b7bdd 100644 --- a/modules/calendar/e-memo-shell-content.c +++ b/modules/calendar/e-memo-shell-content.c @@ -70,15 +70,6 @@ enum { PROP_PREVIEW_VISIBLE }; -enum { - TARGET_VCALENDAR -}; - -static GtkTargetEntry drag_types[] = { - { (gchar *) "text/calendar", 0, TARGET_VCALENDAR }, - { (gchar *) "text/x-calendar", 0, TARGET_VCALENDAR } -}; - static gpointer parent_class; static GType memo_shell_content_type; @@ -146,13 +137,16 @@ memo_shell_content_table_drag_data_get_cb (EMemoShellContent *memo_shell_content guint time) { EMemoTable *memo_table; + GdkAtom target; struct { ECalModel *model; GSList *list; } foreach_data; - if (info != TARGET_VCALENDAR) + /* Sanity check the selection target. */ + target = gtk_selection_data_get_target (selection_data); + if (!e_targets_include_calendar (&target, 1)) return; memo_table = e_memo_shell_content_get_memo_table (memo_shell_content); @@ -404,9 +398,12 @@ memo_shell_content_constructed (GObject *object) GalViewInstance *view_instance; icaltimezone *timezone; GConfBridge *bridge; + GtkTargetList *target_list; + GtkTargetEntry *targets; GtkWidget *container; GtkWidget *widget; const gchar *key; + gint n_targets; priv = E_MEMO_SHELL_CONTENT_GET_PRIVATE (object); @@ -480,11 +477,18 @@ memo_shell_content_constructed (GObject *object) e_table_set_state ( E_TABLE (priv->memo_table), E_MEMO_TABLE_DEFAULT_STATE); + target_list = gtk_target_list_new (NULL, 0); + e_target_list_add_calendar_targets (target_list, 0); + targets = gtk_target_table_new_from_list (target_list, &n_targets); + e_table_drag_source_set ( E_TABLE (priv->memo_table), - GDK_BUTTON1_MASK, drag_types, G_N_ELEMENTS (drag_types), + GDK_BUTTON1_MASK, targets, n_targets, GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_ASK); + gtk_target_table_free (targets, n_targets); + gtk_target_list_unref (target_list); + g_signal_connect_swapped ( priv->memo_table, "table-drag-data-get", G_CALLBACK (memo_shell_content_table_drag_data_get_cb), diff --git a/modules/calendar/e-task-shell-content.c b/modules/calendar/e-task-shell-content.c index fd76fe7513..5fb39a9738 100644 --- a/modules/calendar/e-task-shell-content.c +++ b/modules/calendar/e-task-shell-content.c @@ -70,15 +70,6 @@ enum { PROP_PREVIEW_VISIBLE }; -enum { - TARGET_VCALENDAR -}; - -static GtkTargetEntry drag_types[] = { - { (gchar *) "text/calendar", 0, TARGET_VCALENDAR }, - { (gchar *) "text/x-calendar", 0, TARGET_VCALENDAR } -}; - static gpointer parent_class; static GType task_shell_content_type; @@ -146,13 +137,16 @@ task_shell_content_table_drag_data_get_cb (ETaskShellContent *task_shell_content guint time) { ETaskTable *task_table; + GdkAtom target; struct { ECalModel *model; GSList *list; } foreach_data; - if (info != TARGET_VCALENDAR) + /* Sanity check the selection target. */ + target = gtk_selection_data_get_target (selection_data); + if (!e_targets_include_calendar (&target, 1)) return; task_table = e_task_shell_content_get_task_table (task_shell_content); @@ -402,9 +396,12 @@ task_shell_content_constructed (GObject *object) GalViewInstance *view_instance; icaltimezone *timezone; GConfBridge *bridge; + GtkTargetList *target_list; + GtkTargetEntry *targets; GtkWidget *container; GtkWidget *widget; const gchar *key; + gint n_targets; priv = E_TASK_SHELL_CONTENT_GET_PRIVATE (object); @@ -477,11 +474,18 @@ task_shell_content_constructed (GObject *object) e_table_set_state ( E_TABLE (priv->task_table), E_TASK_TABLE_DEFAULT_STATE); + target_list = gtk_target_list_new (NULL, 0); + e_target_list_add_calendar_targets (target_list, 0); + targets = gtk_target_table_new_from_list (target_list, &n_targets); + e_table_drag_source_set ( E_TABLE (priv->task_table), - GDK_BUTTON1_MASK, drag_types, G_N_ELEMENTS (drag_types), + GDK_BUTTON1_MASK, targets, n_targets, GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_ASK); + gtk_target_table_free (targets, n_targets); + gtk_target_list_unref (target_list); + g_signal_connect_swapped ( priv->task_table, "table-drag-data-get", G_CALLBACK (task_shell_content_table_drag_data_get_cb), diff --git a/widgets/misc/e-attachment-view.c b/widgets/misc/e-attachment-view.c index 7529e669fb..1d76b5dd8d 100644 --- a/widgets/misc/e-attachment-view.c +++ b/widgets/misc/e-attachment-view.c @@ -27,6 +27,7 @@ #include <camel/camel-stream-mem.h> #include "e-util/e-binding.h" +#include "e-util/e-selection.h" #include "e-util/e-util.h" #include "e-attachment-dialog.h" #include "e-attachment-handler-image.h" @@ -39,9 +40,7 @@ enum { /* Note: Do not use the info field. */ static GtkTargetEntry target_table[] = { - { (gchar *) "_NETSCAPE_URL", 0, 0 }, - { (gchar *) "text/x-vcard", 0, 0 }, - { (gchar *) "text/calendar", 0, 0 } + { (gchar *) "_NETSCAPE_URL", 0, 0 } }; static const gchar *ui = @@ -421,20 +420,18 @@ attachment_view_text_calendar (EAttachmentView *view, guint info, guint time) { - static GdkAtom atom = GDK_NONE; EAttachmentStore *store; EAttachment *attachment; CamelMimePart *mime_part; GdkAtom data_type; + GdkAtom target; const gchar *data; gpointer parent; gchar *content_type; gint length; - if (G_UNLIKELY (atom == GDK_NONE)) - atom = gdk_atom_intern_static_string ("text/calendar"); - - if (gtk_selection_data_get_target (selection_data) != atom) + target = gtk_selection_data_get_target (selection_data); + if (!e_targets_include_calendar (&target, 1)) return; g_signal_stop_emission_by_name (view, "drag-data-received"); @@ -477,20 +474,18 @@ attachment_view_text_x_vcard (EAttachmentView *view, guint info, guint time) { - static GdkAtom atom = GDK_NONE; EAttachmentStore *store; EAttachment *attachment; CamelMimePart *mime_part; GdkAtom data_type; + GdkAtom target; const gchar *data; gpointer parent; gchar *content_type; gint length; - if (G_UNLIKELY (atom == GDK_NONE)) - atom = gdk_atom_intern_static_string ("text/x-vcard"); - - if (gtk_selection_data_get_target (selection_data) != atom) + target = gtk_selection_data_get_target (selection_data); + if (!e_targets_include_directory (&target, 1)) return; g_signal_stop_emission_by_name (view, "drag-data-received"); @@ -713,6 +708,8 @@ attachment_view_init_handlers (EAttachmentView *view) target_table, G_N_ELEMENTS (target_table)); gtk_target_list_add_uri_targets (target_list, 0); + e_target_list_add_calendar_targets (target_list, 0); + e_target_list_add_directory_targets (target_list, 0); priv->handlers = g_ptr_array_new (); priv->target_list = target_list; |