aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/widgets/e-addressbook-view.c
diff options
context:
space:
mode:
authorHans Petter Jansson <hpj@ximian.com>2004-06-24 06:40:24 +0800
committerHans Petter <hansp@src.gnome.org>2004-06-24 06:40:24 +0800
commit54a5d78f7876c7ebbe6e973a7d0321efb48128e0 (patch)
treec4cf1430105eddc54c3ea70e5aee7648e1effac6 /addressbook/gui/widgets/e-addressbook-view.c
parent00fc3d7f480b020e90de31894f575c54dd78a034 (diff)
downloadgsoc2013-evolution-54a5d78f7876c7ebbe6e973a7d0321efb48128e0.tar.gz
gsoc2013-evolution-54a5d78f7876c7ebbe6e973a7d0321efb48128e0.tar.zst
gsoc2013-evolution-54a5d78f7876c7ebbe6e973a7d0321efb48128e0.zip
Add an x-source-vcard target entry that includes the source book URI.
2004-06-23 Hans Petter Jansson <hpj@ximian.com> * gui/component/addressbook-view.c: Add an x-source-vcard target entry that includes the source book URI. (destroy_merge_context): Implement. (removed_contact_cb): Implement. (merged_contact_cb): Implement. (selector_tree_drag_data_received): Get the source and target books, and see if we need to remove contacts from source after they're added to target. Copy contacts sequentially, not in parallel, with a callback. * gui/widgets/e-addressbook-view.c: Add an x-source-vcard target entry that includes the source book URI. (table_drag_data_delete): Remove. This is handled by the drag target. (table_drag_data_get): Handle more than one contact. Supply source. (create_table_view): Don't connect to the delete signal. * gui/widgets/e-minicard-view.c: Add an x-source-vcard target entry that includes the source book URI. (e_minicard_view_drag_data_delete): Remove. This is handled by the drag target. (e_minicard_view_drag_data_get): Handle x-source-vcard target. (e_minicard_view_drag_begin): Don't connect to the delete signal. (e_minicard_view_dispose): Don't disconnect from the delete signal. (e_minicard_view_init): Don't init delete_id. * gui/widgets/e-minicard-view.h: Remove delete_id from struct. * util/eab-book-util.[ch] (eab_contact_list_from_string): Skip the source URI if present. (eab_book_and_contact_list_from_string): Create the source book from the provided URI, if present. (eab_book_and_contact_list_to_string): Include the book URI in generated string. svn path=/trunk/; revision=26485
Diffstat (limited to 'addressbook/gui/widgets/e-addressbook-view.c')
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c62
1 files changed, 24 insertions, 38 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index 44db0a1edd..907309348a 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -98,6 +98,7 @@ static void writable_status (GtkObject *object, gboolean writable, EABView *e
static void backend_died (GtkObject *object, EABView *eav);
static void contact_changed (EABModel *model, gint index, EABView *eav);
static void contact_removed (EABModel *model, gint index, EABView *eav);
+static GList *get_selected_contacts (EABView *view);
static void command_state_change (EABView *eav);
@@ -137,11 +138,14 @@ enum {
};
enum DndTargetType {
- DND_TARGET_TYPE_VCARD,
+ DND_TARGET_TYPE_SOURCE_VCARD,
+ DND_TARGET_TYPE_VCARD
};
#define VCARD_TYPE "text/x-vcard"
+#define SOURCE_VCARD_TYPE "text/x-source-vcard"
static GtkTargetEntry drag_types[] = {
- { VCARD_TYPE, 0, DND_TARGET_TYPE_VCARD },
+ { SOURCE_VCARD_TYPE, 0, DND_TARGET_TYPE_SOURCE_VCARD },
+ { VCARD_TYPE, 0, DND_TARGET_TYPE_VCARD }
};
static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]);
@@ -1218,36 +1222,6 @@ table_white_space_event(ETableScrolled *table, GdkEvent *event, EABView *view)
}
static void
-table_drag_data_delete (ETable *table,
- int row,
- int col,
- GdkDragContext *context,
- gpointer user_data)
-{
- EABView *view = user_data;
- EContact *contact;
- EBook *book;
-
- if (!E_IS_ADDRESSBOOK_TABLE_ADAPTER(view->object))
- return;
-
- g_object_get(view->model,
- "book", &book,
- NULL);
-
- contact = eab_model_contact_at(view->model, row);
- /* Remove the card. */
- /* XXX no callback specified... ugh */
- e_book_async_remove_contact (book,
- contact,
- NULL,
- NULL);
-
- g_object_unref(book);
-}
-
-
-static void
table_drag_data_get (ETable *table,
int row,
int col,
@@ -1258,15 +1232,18 @@ table_drag_data_get (ETable *table,
gpointer user_data)
{
EABView *view = user_data;
+ GList *contact_list;
if (!E_IS_ADDRESSBOOK_TABLE_ADAPTER(view->object))
return;
+ contact_list = get_selected_contacts (view);
+
switch (info) {
case DND_TARGET_TYPE_VCARD: {
char *value;
- value = e_vcard_to_string (E_VCARD (view->model->data[row]), EVC_FORMAT_VCARD_30);
+ value = eab_contact_list_to_string (contact_list);
gtk_selection_data_set (selection_data,
selection_data->target,
@@ -1274,7 +1251,21 @@ table_drag_data_get (ETable *table,
value, strlen (value));
break;
}
+ case DND_TARGET_TYPE_SOURCE_VCARD: {
+ char *value;
+
+ value = eab_book_and_contact_list_to_string (view->book, contact_list);
+
+ gtk_selection_data_set (selection_data,
+ selection_data->target,
+ 8,
+ value, strlen (value));
+ break;
}
+ }
+
+ g_list_foreach (contact_list, (GFunc) g_object_unref, NULL);
+ g_list_free (contact_list);
}
static void
@@ -1433,11 +1424,6 @@ create_table_view (EABView *view)
"table_drag_data_get",
G_CALLBACK (table_drag_data_get),
view);
-
- g_signal_connect (E_TABLE_SCROLLED(table)->table,
- "table_drag_data_delete",
- G_CALLBACK (table_drag_data_delete),
- view);
gtk_paned_add1 (GTK_PANED (view->paned), table);