aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-02-09 03:52:18 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-02-09 07:57:24 +0800
commit67ce5f3b140525c2f5944270a9383616f9d67923 (patch)
tree167788f4efa12f87ac04c474598d61b5ca446464 /calendar/gui
parent9cd1f937a26363aa108f3d2b36606b167597a2eb (diff)
downloadgsoc2013-evolution-67ce5f3b140525c2f5944270a9383616f9d67923.tar.gz
gsoc2013-evolution-67ce5f3b140525c2f5944270a9383616f9d67923.tar.zst
gsoc2013-evolution-67ce5f3b140525c2f5944270a9383616f9d67923.zip
Add DnD support to e-selection.c.
Avoid listing calendar and directory targets explicitly, so that e-selection.c contains the one and only master list. Still need to figure out how to centralize "text/x-source-vcard".
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/e-calendar-selector.c15
-rw-r--r--calendar/gui/e-day-view.c77
-rw-r--r--calendar/gui/e-memo-list-selector.c15
-rw-r--r--calendar/gui/e-task-list-selector.c15
4 files changed, 51 insertions, 71 deletions
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