aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/tasks-component.c
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 /calendar/gui/tasks-component.c
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
Diffstat (limited to 'calendar/gui/tasks-component.c')
-rw-r--r--calendar/gui/tasks-component.c153
1 files changed, 15 insertions, 138 deletions
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);