aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-tasks.c
diff options
context:
space:
mode:
authorLarry Ewing <lewing@ximian.com>2004-06-02 17:33:36 +0800
committerLarry Ewing <lewing@src.gnome.org>2004-06-02 17:33:36 +0800
commit5786eb64a18ed1302ac6e10dc8aea2cc2d346ba1 (patch)
treeb186572bef6c3a1d2f3116682e0d50449d5b5e10 /calendar/gui/e-tasks.c
parent55e7f9a951704df272a3c56468be510cf0482e48 (diff)
downloadgsoc2013-evolution-5786eb64a18ed1302ac6e10dc8aea2cc2d346ba1.tar
gsoc2013-evolution-5786eb64a18ed1302ac6e10dc8aea2cc2d346ba1.tar.gz
gsoc2013-evolution-5786eb64a18ed1302ac6e10dc8aea2cc2d346ba1.tar.bz2
gsoc2013-evolution-5786eb64a18ed1302ac6e10dc8aea2cc2d346ba1.tar.lz
gsoc2013-evolution-5786eb64a18ed1302ac6e10dc8aea2cc2d346ba1.tar.xz
gsoc2013-evolution-5786eb64a18ed1302ac6e10dc8aea2cc2d346ba1.tar.zst
gsoc2013-evolution-5786eb64a18ed1302ac6e10dc8aea2cc2d346ba1.zip
add a drag delete handler. (table_drag_data_get): support text/vcard
2004-06-02 Larry Ewing <lewing@ximian.com> * gui/e-tasks.c (table_drag_data_delete): add a drag delete handler. (table_drag_data_get): support text/vcard drags. (setup_widgets): setup the etable as a drag source. * gui/tasks-component.c: add source selector Drag & Drop handlers. svn path=/trunk/; revision=26151
Diffstat (limited to 'calendar/gui/e-tasks.c')
-rw-r--r--calendar/gui/e-tasks.c121
1 files changed, 121 insertions, 0 deletions
diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c
index 22b2b1ce29..947cf60a11 100644
--- a/calendar/gui/e-tasks.c
+++ b/calendar/gui/e-tasks.c
@@ -102,6 +102,16 @@ enum {
LAST_SIGNAL
};
+enum DndTargetType {
+ TARGET_VCALENDAR
+};
+
+static GtkTargetEntry list_drag_types[] = {
+ { "text/calendar", 0, TARGET_VCALENDAR },
+ { "text/x-calendar", 0, TARGET_VCALENDAR }
+};
+static const int num_list_drag_types = sizeof (list_drag_types) / sizeof (list_drag_types[0]);
+
static GtkTableClass *parent_class;
static guint e_tasks_signals[LAST_SIGNAL] = { 0 };
@@ -325,6 +335,96 @@ setup_config (ETasks *tasks)
priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not));
}
+static void
+table_drag_data_get (ETable *table,
+ int row,
+ int col,
+ GdkDragContext *context,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint time,
+ ETasks *tasks)
+{
+ ETasksPrivate *priv;
+ ECalModelComponent *comp_data;
+
+ priv = tasks->priv;
+
+ if (priv->current_uid) {
+ ETableModel *model;
+
+ model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
+
+ comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row);
+
+ if (info == TARGET_VCALENDAR) {
+ /* we will pass an icalcalendar component for both types */
+ char *comp_str;
+ icalcomponent *vcal;
+
+ vcal = e_cal_util_new_top_level ();
+ e_cal_util_add_timezones_from_component (vcal, comp_data->icalcomp);
+ icalcomponent_add_component (
+ vcal,
+ icalcomponent_new_clone (comp_data->icalcomp));
+
+ comp_str = icalcomponent_as_ical_string (vcal);
+ if (comp_str) {
+ gtk_selection_data_set (selection_data, selection_data->target,
+ 8, comp_str, strlen (comp_str));
+ }
+ icalcomponent_free (vcal);
+ }
+ }
+}
+
+/*
+static void
+table_drag_begin (ETable *table,
+ int row,
+ int col,
+ GdkDragContext *context,
+ ETasks *tasks)
+{
+
+}
+
+
+static void
+table_drag_end (ETable *table,
+ int row,
+ int col,
+ GdkDragContext *context,
+ ETasks *tasks)
+{
+
+}
+*/
+
+static void
+table_drag_data_delete (ETable *table,
+ int row,
+ int col,
+ GdkDragContext *context,
+ ETasks *tasks)
+{
+ ETasksPrivate *priv;
+ ECalModelComponent *comp_data;
+ ETableModel *model;
+ gboolean read_only = TRUE;
+
+ priv = tasks->priv;
+
+ model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
+ comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row);
+
+ e_cal_is_read_only (comp_data->client, &read_only, NULL);
+ if (read_only)
+ return;
+
+ e_cal_remove_object (comp_data->client, icalcomponent_get_uid (comp_data->icalcomp), NULL);
+}
+
#define E_TASKS_TABLE_DEFAULT_STATE \
"<?xml version=\"1.0\"?>" \
"<ETableState>" \
@@ -374,6 +474,27 @@ setup_widgets (ETasks *tasks)
gtk_paned_add1 (GTK_PANED (paned), priv->tasks_view);
gtk_widget_show (priv->tasks_view);
+
+ e_table_drag_source_set (etable, GDK_BUTTON1_MASK,
+ list_drag_types, num_list_drag_types,
+ GDK_ACTION_MOVE|GDK_ACTION_COPY|GDK_ACTION_ASK);
+
+ g_signal_connect (etable, "table_drag_data_get",
+ G_CALLBACK(table_drag_data_get), tasks);
+ g_signal_connect (etable, "table_drag_data_delete",
+ G_CALLBACK(table_drag_data_delete), tasks);
+ /*
+ e_table_drag_dest_set (e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table)),
+ 0, list_drag_types, num_list_drag_types, GDK_ACTION_LINK);
+
+ g_signal_connect (e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table)),
+ "table_drag_motion", G_CALLBACK(table_drag_motion_cb), editor);
+ g_signal_connect (e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table)),
+ "table_drag_drop", G_CALLBACK (table_drag_drop_cb), editor);
+ g_signal_connect (e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table)),
+ "table_drag_data_received", G_CALLBACK(table_drag_data_received_cb), editor);
+ */
+
g_signal_connect (etable, "cursor_change", G_CALLBACK (table_cursor_change_cb), tasks);
g_signal_connect (etable, "selection_change", G_CALLBACK (table_selection_change_cb), tasks);