aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2008-11-18 05:09:36 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-11-18 05:09:36 +0800
commit8425d8bbe6359a1baae04f569864f72d34144b5c (patch)
tree72135dc992392c07047b8b53dd9876cb8e5713e5
parent05b8df9868e2828eadaefa1a733999faf0b8e08b (diff)
downloadgsoc2013-evolution-8425d8bbe6359a1baae04f569864f72d34144b5c.tar.gz
gsoc2013-evolution-8425d8bbe6359a1baae04f569864f72d34144b5c.tar.zst
gsoc2013-evolution-8425d8bbe6359a1baae04f569864f72d34144b5c.zip
** Fixes bug #557818
2008-11-17 Matthew Barnes <mbarnes@redhat.com> ** Fixes bug #557818 * addressbook/gui/component/addressbook-view.c: * calendar/gui/calendar-component.c: * calendar/gui/memos-component.c: * calendar/gui/tasks-component.c: ESourceSelector now handles most of the drag-and-drop signals. We just have to listen for the new "data-dropped" signal and deal with it. Gets rid of a lot of duplicate logic. svn path=/trunk/; revision=36793
-rw-r--r--addressbook/ChangeLog9
-rw-r--r--addressbook/gui/component/addressbook-view.c146
-rw-r--r--calendar/ChangeLog11
-rw-r--r--calendar/gui/calendar-component.c147
-rw-r--r--calendar/gui/memos-component.c153
-rw-r--r--calendar/gui/tasks-component.c153
6 files changed, 74 insertions, 545 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 983eb60ce6..adb36417bd 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,5 +1,14 @@
2008-11-17 Matthew Barnes <mbarnes@redhat.com>
+ ** Fixes part of bug #557818
+
+ * gui/component/addressbook-view.c:
+ ESourceSelector now handles most of the drag-and-drop signals.
+ We just have to listen for the new "data-dropped" signal and
+ deal with it. Gets rid of a lot of duplicate logic.
+
+2008-11-17 Matthew Barnes <mbarnes@redhat.com>
+
** Fixes part of bug #558322
* gui/component/addressbook-view.c (rename_addressbook_cb):
diff --git a/addressbook/gui/component/addressbook-view.c b/addressbook/gui/component/addressbook-view.c
index 417cb02dd4..7918770df5 100644
--- a/addressbook/gui/component/addressbook-view.c
+++ b/addressbook/gui/component/addressbook-view.c
@@ -997,88 +997,6 @@ popup_event_callback(ESourceSelector *selector, ESource *source, GdkEventButton
return TRUE;
}
-static gboolean
-selector_tree_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y,
- guint time,
- AddressbookView *view)
-{
- GtkTreeViewColumn *column;
- int cell_x;
- int cell_y;
- GtkTreePath *path;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gpointer data;
-
- if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), x, y, &path, &column, &cell_x, &cell_y))
- return FALSE;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
-
- if (!gtk_tree_model_get_iter (model, &iter, path)) {
- gtk_tree_path_free (path);
- return FALSE;
- }
-
- gtk_tree_model_get (model, &iter, 0, &data, -1);
-
- if (E_IS_SOURCE_GROUP (data)) {
- g_object_unref (data);
- gtk_tree_path_free (path);
- return FALSE;
- }
-
- gtk_tree_path_free (path);
- return TRUE;
-}
-
-static gboolean
-selector_tree_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y)
-{
- GtkTreePath *path = NULL;
- gpointer data = NULL;
- GtkTreeViewDropPosition pos;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GdkDragAction action = { 0, };
-
- if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
- x, y, &path, &pos))
- goto finish;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
-
- if (!gtk_tree_model_get_iter (model, &iter, path))
- goto finish;
-
- gtk_tree_model_get (model, &iter, 0, &data, -1);
-
- if (E_IS_SOURCE_GROUP (data) || e_source_get_readonly (data))
- goto finish;
-
- gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget), path, GTK_TREE_VIEW_DROP_INTO_OR_BEFORE);
- /* Make default action move, not copy */
- if (context->actions & GDK_ACTION_MOVE)
- action = GDK_ACTION_MOVE;
- else
- action = context->suggested_action;
-
- finish:
- if (path)
- gtk_tree_path_free (path);
- if (data)
- g_object_unref (data);
-
- gdk_drag_status (context, action, GDK_CURRENT_TIME);
- return TRUE;
-}
-
typedef struct
{
guint remove_from_source : 1;
@@ -1153,42 +1071,19 @@ merged_contact_cb (EBook *book, EBookStatus status, const char *id, gpointer clo
}
static gboolean
-selector_tree_drag_data_received (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *data,
- guint info,
- guint time,
- gpointer user_data)
-{
- GtkTreePath *path = NULL;
- GtkTreeViewDropPosition pos;
- gpointer target = NULL;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean success = FALSE;
+selector_tree_data_dropped (ESourceSelector *selector,
+ GtkSelectionData *data,
+ ESource *destination,
+ GdkDragAction action,
+ guint info,
+ AddressbookView *view)
+{
EBook *source_book, *target_book;
MergeContext *merge_context = NULL;
GList *contactlist;
- AddressbookView *view;
EABView *v;
- if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
- x, y, &path, &pos))
- goto finish;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
-
- if (!gtk_tree_model_get_iter (model, &iter, path))
- goto finish;
-
- gtk_tree_model_get (model, &iter, 0, &target, -1);
-
- if (E_IS_SOURCE_GROUP (target) || e_source_get_readonly (target))
- goto finish;
-
- target_book = e_book_new (target, NULL);
+ target_book = e_book_new (destination, NULL);
if (!target_book) {
g_message (G_STRLOC ":Couldn't create EBook.");
return FALSE;
@@ -1197,7 +1092,6 @@ selector_tree_drag_data_received (GtkWidget *widget,
eab_book_and_contact_list_from_string ((char *)data->data, &source_book, &contactlist);
- view = (AddressbookView *) user_data;
v = get_current_view (view);
g_object_get (v->model, "book",&source_book, NULL);
@@ -1211,32 +1105,17 @@ selector_tree_drag_data_received (GtkWidget *widget,
merge_context->current_contact = contactlist->data;
merge_context->remaining_contacts = g_list_delete_link (contactlist, contactlist);
- merge_context->remove_from_source = context->action == GDK_ACTION_MOVE ? TRUE : FALSE;
+ merge_context->remove_from_source = action == GDK_ACTION_MOVE ? TRUE : FALSE;
/* Start merge */
eab_merging_book_add_contact (target_book, merge_context->current_contact,
merged_contact_cb, merge_context);
- finish:
- if (path)
- gtk_tree_path_free (path);
- if (target)
- g_object_unref (target);
-
- gtk_drag_finish (context, success, merge_context->remove_from_source, time);
-
return TRUE;
}
static void
-selector_tree_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time, gpointer data)
-{
- gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget), NULL, GTK_TREE_VIEW_DROP_BEFORE);
-}
-
-
-static void
destroy_callback(gpointer data, GObject *where_object_was)
{
AddressbookView *view = data;
@@ -1338,10 +1217,9 @@ addressbook_view_init (AddressbookView *view)
priv->selector = e_source_selector_new (priv->source_list);
- g_signal_connect (priv->selector, "drag-motion", G_CALLBACK (selector_tree_drag_motion), view);
- g_signal_connect (priv->selector, "drag-leave", G_CALLBACK (selector_tree_drag_leave), view);
- g_signal_connect (priv->selector, "drag-drop", G_CALLBACK (selector_tree_drag_drop), view);
- g_signal_connect (priv->selector, "drag-data-received", G_CALLBACK (selector_tree_drag_data_received), view);
+ g_signal_connect (
+ priv->selector, "data-dropped",
+ G_CALLBACK (selector_tree_data_dropped), view);
gtk_drag_dest_set (priv->selector, GTK_DEST_DEFAULT_ALL, drag_types, num_drag_types, GDK_ACTION_COPY | GDK_ACTION_MOVE);
a11y = gtk_widget_get_accessible (GTK_WIDGET (priv->selector));
atk_object_set_name (a11y, _("Contact Source Selector"));
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 4cd2f2cbac..ffbde37e7f 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,16 @@
2008-11-17 Matthew Barnes <mbarnes@redhat.com>
+ ** Fixes part of bug #557818
+
+ * gui/calendar-component.c:
+ * gui/memos-component.c:
+ * gui/tasks-component.c:
+ ESourceSelector now handles most of the drag-and-drop signals.
+ We just have to listen for the new "data-dropped" signal and
+ deal with it. Gets rid of a lot of duplicate logic.
+
+2008-11-17 Matthew Barnes <mbarnes@redhat.com>
+
** Fixes part of bug #558322
* gui/calendar-component.c (rename_calendar_cb):
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c
index 099b834c16..705cedc862 100644
--- a/calendar/gui/calendar-component.c
+++ b/calendar/gui/calendar-component.c
@@ -1002,88 +1002,6 @@ impl_upgradeFromVersion (PortableServer_Servant servant,
}
static gboolean
-selector_tree_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y,
- guint time,
- CalendarComponent *component)
-{
- GtkTreeViewColumn *column;
- int cell_x;
- int cell_y;
- GtkTreePath *path;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gpointer data;
-
- if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), x, y, &path,
- &column, &cell_x, &cell_y))
- return FALSE;
-
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
-
- if (!gtk_tree_model_get_iter (model, &iter, path)) {
- gtk_tree_path_free (path);
- return FALSE;
- }
-
- gtk_tree_model_get (model, &iter, 0, &data, -1);
-
- if (E_IS_SOURCE_GROUP (data)) {
- g_object_unref (data);
- gtk_tree_path_free (path);
- return FALSE;
- }
-
- gtk_tree_path_free (path);
- return TRUE;
-}
-
-static gboolean
-selector_tree_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y,
- guint time,
- gpointer user_data)
-{
- GtkTreePath *path = NULL;
- gpointer data = NULL;
- GtkTreeViewDropPosition pos;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GdkDragAction action = GDK_ACTION_DEFAULT;
-
- if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
- x, y, &path, &pos))
- goto finish;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
-
- if (!gtk_tree_model_get_iter (model, &iter, path))
- goto finish;
-
- gtk_tree_model_get (model, &iter, 0, &data, -1);
-
- if (E_IS_SOURCE_GROUP (data) || e_source_get_readonly (data))
- goto finish;
-
- gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget), path, GTK_TREE_VIEW_DROP_INTO_OR_BEFORE);
- action = context->suggested_action;
-
- finish:
- if (path)
- gtk_tree_path_free (path);
- if (data)
- g_object_unref (data);
-
- gdk_drag_status (context, action, time);
- return TRUE;
-}
-
-static gboolean
update_single_object (ECal *client, icalcomponent *icalcomp)
{
char *uid;
@@ -1137,52 +1055,29 @@ update_objects (ECal *client, icalcomponent *icalcomp)
return TRUE;
}
-static void
-selector_tree_drag_data_received (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *data,
- guint info,
- guint time,
- gpointer user_data)
+static gboolean
+selector_tree_data_dropped (ESourceSelector *selector,
+ GtkSelectionData *data,
+ ESource *destination,
+ GdkDragAction action,
+ guint info)
{
- GtkTreePath *path = NULL;
- GtkTreeViewDropPosition pos;
- gpointer source = NULL;
- GtkTreeModel *model;
- GtkTreeIter iter;
gboolean success = FALSE;
icalcomponent *icalcomp = NULL;
ECal *client = NULL;
- if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
- x, y, &path, &pos))
- goto finish;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
-
- if (!gtk_tree_model_get_iter (model, &iter, path))
- goto finish;
-
-
- gtk_tree_model_get (model, &iter, 0, &source, -1);
-
- if (E_IS_SOURCE_GROUP (source) || e_source_get_readonly (source))
- goto finish;
-
icalcomp = icalparser_parse_string ((char *)data->data);
if (icalcomp) {
char * uid;
/* FIXME deal with GDK_ACTION_ASK */
- if (context->action == GDK_ACTION_COPY) {
+ if (action == GDK_ACTION_COPY) {
uid = e_cal_component_gen_uid ();
icalcomponent_set_uid (icalcomp, uid);
}
- client = auth_new_cal_from_source (source,
+ client = auth_new_cal_from_source (destination,
E_CAL_SOURCE_TYPE_EVENT);
if (client) {
@@ -1197,20 +1092,7 @@ selector_tree_drag_data_received (GtkWidget *widget,
icalcomponent_free (icalcomp);
}
- finish:
- if (source)
- g_object_unref (source);
- if (path)
- gtk_tree_path_free (path);
-
- gtk_drag_finish (context, success, context->action == GDK_ACTION_MOVE, time);
-}
-
-static void
-selector_tree_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time, gpointer data)
-{
- gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget),
- NULL, GTK_TREE_VIEW_DROP_BEFORE);
+ return success;
}
static void
@@ -1422,14 +1304,9 @@ create_component_view (CalendarComponent *calendar_component)
a11y = gtk_widget_get_accessible (GTK_WIDGET (component_view->source_selector));
atk_object_set_name (a11y, _("Calendar Source Selector"));
- g_signal_connect (component_view->source_selector, "drag-motion", G_CALLBACK (selector_tree_drag_motion),
- calendar_component);
- g_signal_connect (component_view->source_selector, "drag-leave", G_CALLBACK (selector_tree_drag_leave),
- calendar_component);
- g_signal_connect (component_view->source_selector, "drag-drop", G_CALLBACK (selector_tree_drag_drop),
- calendar_component);
- g_signal_connect (component_view->source_selector, "drag-data-received",
- G_CALLBACK (selector_tree_drag_data_received), calendar_component);
+ g_signal_connect (
+ component_view->source_selector, "data-dropped",
+ G_CALLBACK (selector_tree_data_dropped), NULL);
gtk_drag_dest_set(component_view->source_selector, GTK_DEST_DEFAULT_ALL, drag_types,
num_drag_types, GDK_ACTION_COPY | GDK_ACTION_MOVE);
diff --git a/calendar/gui/memos-component.c b/calendar/gui/memos-component.c
index b8b0983d75..8ae51a5fb5 100644
--- a/calendar/gui/memos-component.c
+++ b/calendar/gui/memos-component.c
@@ -638,90 +638,6 @@ impl_upgradeFromVersion (PortableServer_Servant servant,
}
static gboolean
-selector_tree_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y,
- guint time,
- CalendarComponent *component)
-{
- GtkTreeViewColumn *column;
- int cell_x;
- int cell_y;
- GtkTreePath *path;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gpointer data;
-
- if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), x, y, &path,
- &column, &cell_x, &cell_y))
- return FALSE;
-
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
-
- if (!gtk_tree_model_get_iter (model, &iter, path)) {
- gtk_tree_path_free (path);
- return FALSE;
- }
-
- gtk_tree_model_get (model, &iter, 0, &data, -1);
-
- if (E_IS_SOURCE_GROUP (data)) {
- g_object_unref (data);
- gtk_tree_path_free (path);
- return FALSE;
- }
-
- gtk_tree_path_free (path);
- return TRUE;
-}
-
-static gboolean
-selector_tree_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y,
- guint time,
- gpointer user_data)
-{
- GtkTreePath *path = NULL;
- gpointer data = NULL;
- GtkTreeViewDropPosition pos;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GdkDragAction action = GDK_ACTION_DEFAULT;
-
- if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
- x, y, &path, &pos))
- goto finish;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
-
- if (!gtk_tree_model_get_iter (model, &iter, path))
- goto finish;
-
- gtk_tree_model_get (model, &iter, 0, &data, -1);
-
- if (E_IS_SOURCE_GROUP (data) || e_source_get_readonly (data))
- goto finish;
-
- gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget), path, GTK_TREE_VIEW_DROP_INTO_OR_BEFORE);
- action = context->suggested_action;
- if (action == GDK_ACTION_COPY && (context->actions & GDK_ACTION_MOVE))
- action=GDK_ACTION_MOVE;
-
- finish:
- if (path)
- gtk_tree_path_free (path);
- if (data)
- g_object_unref (data);
-
- gdk_drag_status (context, action, time);
- return TRUE;
-}
-
-static gboolean
update_single_object (ECal *client, icalcomponent *icalcomp, gboolean fail_on_modify)
{
char *uid;
@@ -782,43 +698,21 @@ update_objects (ECal *client, icalcomponent *icalcomp)
return TRUE;
}
-static void
-selector_tree_drag_data_received (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *data,
- guint info,
- guint time,
- gpointer user_data)
+static gboolean
+selector_tree_data_dropped (ESourceSelector *selector,
+ GtkSelectionData *data,
+ ESource *destination,
+ GdkDragAction action,
+ guint info,
+ MemosComponent *component)
{
- GtkTreePath *path = NULL;
- GtkTreeViewDropPosition pos;
- gpointer source = NULL;
- GtkTreeModel *model;
- GtkTreeIter iter;
gboolean success = FALSE;
icalcomponent *icalcomp = NULL;
ECal *client = NULL;
GSList *components, *p;
- MemosComponent *component = MEMOS_COMPONENT (user_data);
-
- if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
- x, y, &path, &pos))
- goto finish;
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
-
- if (!gtk_tree_model_get_iter (model, &iter, path))
- goto finish;
-
-
- gtk_tree_model_get (model, &iter, 0, &source, -1);
-
- if (E_IS_SOURCE_GROUP (source) || e_source_get_readonly (source) || !data->data)
- goto finish;
-
- client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_JOURNAL);
+ client = auth_new_cal_from_source (
+ destination, E_CAL_SOURCE_TYPE_JOURNAL);
if (!client || !e_cal_open (client, TRUE, NULL))
goto finish;
@@ -844,7 +738,7 @@ selector_tree_drag_data_received (GtkWidget *widget,
continue;
/* FIXME deal with GDK_ACTION_ASK */
- if (context->action == GDK_ACTION_COPY) {
+ if (action == GDK_ACTION_COPY) {
old_uid = g_strdup (icalcomponent_get_uid (icalcomp));
uid = e_cal_component_gen_uid ();
icalcomponent_set_uid (icalcomp, uid);
@@ -861,7 +755,7 @@ selector_tree_drag_data_received (GtkWidget *widget,
/* this will report success by last item, but we don't care */
success = update_objects (client, icalcomp);
- if (success && context->action == GDK_ACTION_MOVE) {
+ if (success && action == GDK_ACTION_MOVE) {
/* remove components rather here, because we know which has been moved */
ESource *source_source;
ECal *source_client;
@@ -901,23 +795,11 @@ selector_tree_drag_data_received (GtkWidget *widget,
finish:
if (client)
g_object_unref (client);
- if (source)
- g_object_unref (source);
- if (path)
- gtk_tree_path_free (path);
- gtk_drag_finish (context, success, success && context->action == GDK_ACTION_MOVE, time);
+ return success;
}
static void
-selector_tree_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time, gpointer data)
-{
- gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget),
- NULL, GTK_TREE_VIEW_DROP_BEFORE);
-}
-
-
-static void
control_activate_cb (BonoboControl *control, gboolean activate, gpointer data)
{
MemosComponentView *component_view = data;
@@ -1113,14 +995,9 @@ create_component_view (MemosComponent *memos_component)
a11y = gtk_widget_get_accessible (GTK_WIDGET (component_view->source_selector));
atk_object_set_name (a11y, _("Memo Source Selector"));
- g_signal_connect (component_view->source_selector, "drag-motion", G_CALLBACK (selector_tree_drag_motion),
- memos_component);
- g_signal_connect (component_view->source_selector, "drag-leave", G_CALLBACK (selector_tree_drag_leave),
- memos_component);
- g_signal_connect (component_view->source_selector, "drag-drop", G_CALLBACK (selector_tree_drag_drop),
- memos_component);
- g_signal_connect (component_view->source_selector, "drag-data-received",
- G_CALLBACK (selector_tree_drag_data_received), memos_component);
+ g_signal_connect (
+ component_view->source_selector, "data-dropped",
+ G_CALLBACK (selector_tree_data_dropped), memos_component);
gtk_drag_dest_set(component_view->source_selector, GTK_DEST_DEFAULT_ALL, drag_types,
num_drag_types, GDK_ACTION_COPY | GDK_ACTION_MOVE);
diff --git a/calendar/gui/tasks-component.c b/calendar/gui/tasks-component.c
index a471450b91..c21dbfb612 100644
--- a/calendar/gui/tasks-component.c
+++ b/calendar/gui/tasks-component.c
@@ -629,90 +629,6 @@ impl_upgradeFromVersion (PortableServer_Servant servant,
}
static gboolean
-selector_tree_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y,
- guint time,
- CalendarComponent *component)
-{
- GtkTreeViewColumn *column;
- int cell_x;
- int cell_y;
- GtkTreePath *path;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gpointer data;
-
- if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), x, y, &path,
- &column, &cell_x, &cell_y))
- return FALSE;
-
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
-
- if (!gtk_tree_model_get_iter (model, &iter, path)) {
- gtk_tree_path_free (path);
- return FALSE;
- }
-
- gtk_tree_model_get (model, &iter, 0, &data, -1);
-
- if (E_IS_SOURCE_GROUP (data)) {
- g_object_unref (data);
- gtk_tree_path_free (path);
- return FALSE;
- }
-
- gtk_tree_path_free (path);
- return TRUE;
-}
-
-static gboolean
-selector_tree_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- int x,
- int y,
- guint time,
- gpointer user_data)
-{
- GtkTreePath *path = NULL;
- gpointer data = NULL;
- GtkTreeViewDropPosition pos;
- GtkTreeModel *model;
- GtkTreeIter iter;
- GdkDragAction action = GDK_ACTION_DEFAULT;
-
- if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
- x, y, &path, &pos))
- goto finish;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
-
- if (!gtk_tree_model_get_iter (model, &iter, path))
- goto finish;
-
- gtk_tree_model_get (model, &iter, 0, &data, -1);
-
- if (E_IS_SOURCE_GROUP (data) || e_source_get_readonly (data))
- goto finish;
-
- gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget), path, GTK_TREE_VIEW_DROP_INTO_OR_BEFORE);
- action = context->suggested_action;
- if (action == GDK_ACTION_COPY && (context->actions & GDK_ACTION_MOVE))
- action=GDK_ACTION_MOVE;
-
- finish:
- if (path)
- gtk_tree_path_free (path);
- if (data)
- g_object_unref (data);
-
- gdk_drag_status (context, action, time);
- return TRUE;
-}
-
-static gboolean
update_single_object (ECal *client, icalcomponent *icalcomp)
{
char *uid;
@@ -766,43 +682,21 @@ update_objects (ECal *client, icalcomponent *icalcomp)
return TRUE;
}
-static void
-selector_tree_drag_data_received (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *data,
- guint info,
- guint time,
- gpointer user_data)
+static gboolean
+selector_tree_data_dropped (ESourceSelector *selector,
+ GtkSelectionData *data,
+ ESource *destination,
+ GdkDragAction action,
+ guint info,
+ TasksComponent *component)
{
- GtkTreePath *path = NULL;
- GtkTreeViewDropPosition pos;
- gpointer source = NULL;
- GtkTreeModel *model;
- GtkTreeIter iter;
gboolean success = FALSE;
icalcomponent *icalcomp = NULL;
ECal *client = NULL;
GSList *components, *p;
- TasksComponent *component = TASKS_COMPONENT (user_data);
-
- if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
- x, y, &path, &pos))
- goto finish;
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
-
- if (!gtk_tree_model_get_iter (model, &iter, path))
- goto finish;
-
-
- gtk_tree_model_get (model, &iter, 0, &source, -1);
-
- if (E_IS_SOURCE_GROUP (source) || e_source_get_readonly (source) || !data->data)
- goto finish;
-
- client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_TODO);
+ client = auth_new_cal_from_source (
+ destination, E_CAL_SOURCE_TYPE_TODO);
if (!client || !e_cal_open (client, TRUE, NULL))
goto finish;
@@ -828,7 +722,7 @@ selector_tree_drag_data_received (GtkWidget *widget,
continue;
/* FIXME deal with GDK_ACTION_ASK */
- if (context->action == GDK_ACTION_COPY) {
+ if (action == GDK_ACTION_COPY) {
old_uid = g_strdup (icalcomponent_get_uid (icalcomp));
uid = e_cal_component_gen_uid ();
icalcomponent_set_uid (icalcomp, uid);
@@ -845,7 +739,7 @@ selector_tree_drag_data_received (GtkWidget *widget,
/* this will report success by last item, but we don't care */
success = update_objects (client, icalcomp);
- if (success && context->action == GDK_ACTION_MOVE) {
+ if (success && action == GDK_ACTION_MOVE) {
/* remove components rather here, because we know which has been moved */
ESource *source_source;
ECal *source_client;
@@ -885,23 +779,11 @@ selector_tree_drag_data_received (GtkWidget *widget,
finish:
if (client)
g_object_unref (client);
- if (source)
- g_object_unref (source);
- if (path)
- gtk_tree_path_free (path);
- gtk_drag_finish (context, success, context->action == GDK_ACTION_MOVE, time);
+ return success;
}
static void
-selector_tree_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time, gpointer data)
-{
- gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget),
- NULL, GTK_TREE_VIEW_DROP_BEFORE);
-}
-
-
-static void
control_activate_cb (BonoboControl *control, gboolean activate, gpointer data)
{
TasksComponentView *component_view = data;
@@ -1102,14 +984,9 @@ create_component_view (TasksComponent *tasks_component)
a11y = gtk_widget_get_accessible (GTK_WIDGET (component_view->source_selector));
atk_object_set_name (a11y, _("Task Source Selector"));
- g_signal_connect (component_view->source_selector, "drag-motion", G_CALLBACK (selector_tree_drag_motion),
- tasks_component);
- g_signal_connect (component_view->source_selector, "drag-leave", G_CALLBACK (selector_tree_drag_leave),
- tasks_component);
- g_signal_connect (component_view->source_selector, "drag-drop", G_CALLBACK (selector_tree_drag_drop),
- tasks_component);
- g_signal_connect (component_view->source_selector, "drag-data-received",
- G_CALLBACK (selector_tree_drag_data_received), tasks_component);
+ g_signal_connect (
+ component_view->source_selector, "data-dropped",
+ G_CALLBACK (selector_tree_data_dropped), tasks_component);
gtk_drag_dest_set(component_view->source_selector, GTK_DEST_DEFAULT_ALL, drag_types,
num_drag_types, GDK_ACTION_COPY | GDK_ACTION_MOVE);