aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLarry Ewing <lewing@ximian.com>2004-03-30 16:31:57 +0800
committerLarry Ewing <lewing@src.gnome.org>2004-03-30 16:31:57 +0800
commitbe8d119494fc3a3d1b705a3b24c4112b041d53ee (patch)
treeaabdd46e92bf10a7da513b1e10229f25656d1fbf
parente2a3911b478c1555886c09e2e3796a70b6863332 (diff)
downloadgsoc2013-evolution-be8d119494fc3a3d1b705a3b24c4112b041d53ee.tar
gsoc2013-evolution-be8d119494fc3a3d1b705a3b24c4112b041d53ee.tar.gz
gsoc2013-evolution-be8d119494fc3a3d1b705a3b24c4112b041d53ee.tar.bz2
gsoc2013-evolution-be8d119494fc3a3d1b705a3b24c4112b041d53ee.tar.lz
gsoc2013-evolution-be8d119494fc3a3d1b705a3b24c4112b041d53ee.tar.xz
gsoc2013-evolution-be8d119494fc3a3d1b705a3b24c4112b041d53ee.tar.zst
gsoc2013-evolution-be8d119494fc3a3d1b705a3b24c4112b041d53ee.zip
call drag_finish properly. (selector_tree_drag_motion): set the drag
2004-03-29 Larry Ewing <lewing@ximian.com> * gui/component/addressbook-component.c (selector_tree_drag_data_received): call drag_finish properly. (selector_tree_drag_motion): set the drag status properly. 2004-03-29 Larry Ewing <lewing@ximian.com> * gui/calendar-component.c (selector_tree_drag_data_received): deal with the action type a properly. in the normal case. * gui/calendar-component.c (selector_tree_drag_data_received): call drag_finish properly, change the uid. (selector_tree_drag_motion): set drag status properly. svn path=/trunk/; revision=25240
-rw-r--r--addressbook/ChangeLog6
-rw-r--r--addressbook/gui/component/addressbook-component.c114
-rw-r--r--calendar/ChangeLog9
-rw-r--r--calendar/gui/calendar-component.c117
4 files changed, 124 insertions, 122 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 526bfc83bd..840b9da6cf 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,9 @@
+2004-03-29 Larry Ewing <lewing@ximian.com>
+
+ * gui/component/addressbook-component.c
+ (selector_tree_drag_data_received): call drag_finish properly.
+ (selector_tree_drag_motion): set the drag status properly.
+
2004-03-25 Sivaiah Nallagatla <snallagatla@novell.com>
* gui/component/eab-editor.c (eab_editor_prompt_to_save_changes) :
diff --git a/addressbook/gui/component/addressbook-component.c b/addressbook/gui/component/addressbook-component.c
index 8109c1e4e6..429a991134 100644
--- a/addressbook/gui/component/addressbook-component.c
+++ b/addressbook/gui/component/addressbook-component.c
@@ -349,7 +349,6 @@ selector_tree_drag_drop (GtkWidget *widget,
return FALSE;
}
- gtk_drag_get_data (widget, context, gdk_atom_intern (VCARD_TYPE, FALSE), time);
gtk_tree_path_free (path);
return TRUE;
}
@@ -360,35 +359,37 @@ selector_tree_drag_motion (GtkWidget *widget,
int x,
int y)
{
- GtkTreePath *path;
+ GtkTreePath *path = NULL;
+ gpointer data = NULL;
GtkTreeViewDropPosition pos;
- gpointer data;
GtkTreeModel *model;
GtkTreeIter iter;
-
+ GdkDragAction action;
if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
x, y, &path, &pos))
- return FALSE;
+ goto finish;
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;
- }
+ 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)) {
- g_object_unref (data);
- gtk_tree_path_free (path);
- return FALSE;
- }
+ 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);
-
- gtk_tree_path_free (path);
+ 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;
}
@@ -402,68 +403,59 @@ selector_tree_drag_data_received (GtkWidget *widget,
guint time,
gpointer user_data)
{
- GtkTreePath *path;
+ GtkTreePath *path = NULL;
GtkTreeViewDropPosition pos;
- gpointer source;
+ gpointer source = NULL;
GtkTreeModel *model;
GtkTreeIter iter;
+ gboolean success = FALSE;
+
+ EBook *book;
+ GList *contactlist;
+ GList *l;
if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
x, y, &path, &pos))
- return FALSE;
+ goto finish;
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;
- }
+ 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)) {
- g_object_unref (source);
- gtk_tree_path_free (path);
- return FALSE;
- }
-
+ if (E_IS_SOURCE_GROUP (source) || e_source_get_readonly (source))
+ goto finish;
- if ((data->length >= 0) && (data->format == 8)) {
- gtk_drag_finish (context, FALSE, TRUE, time);
+ book = e_book_new ();
+ if (!book) {
+ g_message (G_STRLOC ":Couldn't create EBook.");
+ return FALSE;
}
-
- gtk_tree_path_free (path);
- gtk_drag_finish (context, FALSE, FALSE, time);
-
- printf ("got card\n%s", data->data);
+ e_book_load_source (book, source, TRUE, NULL);
+ contactlist = eab_contact_list_from_string (data->data);
- //e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (widget), source);
- {
- EBook *book;
- GList *contactlist;
- GList *l;
-
- book = e_book_new ();
- if (!book) {
- g_message (G_STRLOC ":Couldn't create EBook.");
- return FALSE;
- }
- e_book_load_source (book, source, TRUE, NULL);
- contactlist = eab_contact_list_from_string (data->data);
+ for (l = contactlist; l; l = l->next) {
+ EContact *contact = l->data;
- for (l = contactlist; l; l = l->next) {
- EContact *contact = l->data;
-
- /* XXX NULL for a callback /sigh */
- if (contact)
- eab_merging_book_add_contact (book, contact, NULL /* XXX */, NULL);
- }
-
- g_list_foreach (contactlist, (GFunc)g_object_unref, NULL);
- g_list_free (contactlist);
-
- g_object_unref (book);
+ /* XXX NULL for a callback /sigh */
+ if (contact)
+ eab_merging_book_add_contact (book, contact, NULL /* XXX */, NULL);
+ success = TRUE;
}
+
+ g_list_foreach (contactlist, (GFunc)g_object_unref, NULL);
+ g_list_free (contactlist);
+ g_object_unref (book);
+
+ finish:
+ if (path)
+ gtk_tree_path_free (path);
+ if (source)
+ g_object_unref (source);
+
+ gtk_drag_finish (context, success, context->action == GDK_ACTION_MOVE, time);
return TRUE;
}
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 8d786a5d63..020c64a062 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,12 @@
+2004-03-29 Larry Ewing <lewing@ximian.com>
+
+ * gui/calendar-component.c (selector_tree_drag_data_received):
+ deal with the action type a properly. in the normal case.
+
+ * gui/calendar-component.c (selector_tree_drag_data_received):
+ call drag_finish properly, change the uid.
+ (selector_tree_drag_motion): set drag status properly.
+
2004-03-29 William Jon McCann <mccann@jhu.edu>
* gui/tasks-component.c (delete_task_list_cb):
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c
index db6fdabe7d..566e5b15d7 100644
--- a/calendar/gui/calendar-component.c
+++ b/calendar/gui/calendar-component.c
@@ -627,7 +627,6 @@ selector_tree_drag_drop (GtkWidget *widget,
return FALSE;
}
- gtk_drag_get_data (widget, context, gdk_atom_intern (CALENDAR_TYPE, FALSE), time);
gtk_tree_path_free (path);
return TRUE;
}
@@ -638,34 +637,37 @@ selector_tree_drag_motion (GtkWidget *widget,
int x,
int y)
{
- GtkTreePath *path;
+ GtkTreePath *path = NULL;
+ gpointer data = NULL;
GtkTreeViewDropPosition pos;
- gpointer data;
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))
- return FALSE;
+ goto finish;
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;
- }
+ 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)) {
- g_object_unref (data);
- gtk_tree_path_free (path);
- return FALSE;
- }
+ 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);
-
- gtk_tree_path_free (path);
+ 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;
}
@@ -723,7 +725,7 @@ update_objects (ECal *client, icalcomponent *icalcomp)
return TRUE;
}
-static gboolean
+static void
selector_tree_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
@@ -733,70 +735,63 @@ selector_tree_drag_data_received (GtkWidget *widget,
guint time,
gpointer user_data)
{
- GtkTreePath *path;
+ GtkTreePath *path = NULL;
GtkTreeViewDropPosition pos;
- gpointer source;
+ gpointer source = NULL;
GtkTreeModel *model;
GtkTreeIter iter;
- gboolean ret = FALSE;
+ 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))
- return FALSE;
+ goto finish;
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;
- }
+ 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)) {
- g_object_unref (source);
- gtk_tree_path_free (path);
- return FALSE;
- }
-
-
- if ((data->length >= 0) && (data->format == 8)) {
- gtk_drag_finish (context, FALSE, TRUE, time);
- } else {
- gtk_drag_finish (context, FALSE, FALSE, time);
- }
- gtk_tree_path_free (path);
+ if (E_IS_SOURCE_GROUP (source) || e_source_get_readonly (source))
+ goto finish;
+ icalcomp = icalparser_parse_string (data->data);
- //e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (widget), source);
- {
- icalcomponent *ical_comp = NULL;
- icalvcal_defaults defaults = { 0 };
- VObject *vcal;
- ECal *client = NULL;
-
-
- vcal = Parse_MIME (data->data, data->length);
- if (vcal) {
- ical_comp = icalvcal_convert_with_defaults (vcal, &defaults);
- cleanVObject (vcal);
-
- if (ical_comp)
- client = auth_new_cal_from_source (source,
- E_CAL_SOURCE_TYPE_EVENT);
-
- if (client) {
- if (e_cal_open (client, TRUE, NULL)) {
- /* FIXME should the drag status be set here? */
- update_objects (client, ical_comp);
- }
+ if (icalcomp) {
+ char * uid;
+
+ /* FIXME deal with GDK_ACTION_ASK */
+ if (context->action == GDK_ACTION_COPY) {
+ uid = e_cal_component_gen_uid ();
+ icalcomponent_set_uid (icalcomp, uid);
+ }
- g_object_unref (client);
+ client = auth_new_cal_from_source (source,
+ E_CAL_SOURCE_TYPE_EVENT);
+
+ if (client) {
+ if (e_cal_open (client, TRUE, NULL)) {
+ success = TRUE;
+ update_objects (client, icalcomp);
}
+
+ g_object_unref (client);
}
+
+ icalcomponent_free (icalcomp);
}
- return ret;
+ 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