diff options
author | Chris Toshok <toshok@ximian.com> | 2001-04-10 10:14:08 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2001-04-10 10:14:08 +0800 |
commit | fc3440ee9c435bc2fa30fb695caa853d71c17557 (patch) | |
tree | 6003917d995bf55efcfe67a595c417ab1cea7d68 /addressbook/gui/widgets/e-addressbook-view.c | |
parent | c3c9ca3526ff8d8678c28338cd7368e955b75ef6 (diff) | |
download | gsoc2013-evolution-fc3440ee9c435bc2fa30fb695caa853d71c17557.tar gsoc2013-evolution-fc3440ee9c435bc2fa30fb695caa853d71c17557.tar.gz gsoc2013-evolution-fc3440ee9c435bc2fa30fb695caa853d71c17557.tar.bz2 gsoc2013-evolution-fc3440ee9c435bc2fa30fb695caa853d71c17557.tar.lz gsoc2013-evolution-fc3440ee9c435bc2fa30fb695caa853d71c17557.tar.xz gsoc2013-evolution-fc3440ee9c435bc2fa30fb695caa853d71c17557.tar.zst gsoc2013-evolution-fc3440ee9c435bc2fa30fb695caa853d71c17557.zip |
on BUTTON_PRESS: if it's button 1, store the button x, y, and set
2001-04-09 Chris Toshok <toshok@ximian.com>
* gui/widgets/e-minicard.c (e_minicard_event): on BUTTON_PRESS: if
it's button 1, store the button x, y, and set drag_button_down to
TRUE. on BUTTON_RELEASE: always set drag_button_down to FALSE.
for MOTION_NOTIFY: initiate drag if the pointer has moved 3
pixels.
* gui/widgets/e-minicard.h (struct _EMinicard): add fields for
button x, y, and a bit for if the button has been pressed so we
can tell whether a motion should be a drag.
(struct _EMinicardClass): add drag_begin signal.
* gui/widgets/e-minicard-view.c (e_minicard_view_drag_begin): new
function, starts the drag.
(book_view_loaded): connect the "drag_data_get" signal.
(e_minicard_view_drag_data_get): new function.
* gui/widgets/e-minicard-view.h (struct _EMinicardView): add
drag_card and id for canvas_drag_data_get_id.
* gui/widgets/e-addressbook-view.c (table_drag_data_get): new
function.
(create_table_view): add d&d stuff.
svn path=/trunk/; revision=9209
Diffstat (limited to 'addressbook/gui/widgets/e-addressbook-view.c')
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index 685ee0b79d..60ec90b7f9 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -74,6 +74,15 @@ enum { LAST_SIGNAL }; +enum DndTargetType { + DND_TARGET_TYPE_VCARD, +}; +#define VCARD_TYPE "text/x-vcard" +static GtkTargetEntry drag_types[] = { + { VCARD_TYPE, 0, DND_TARGET_TYPE_VCARD }, +}; +static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]); + static guint e_addressbook_view_signals [LAST_SIGNAL] = {0, }; GtkType @@ -588,6 +597,38 @@ table_right_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EA } static void +table_drag_data_get (ETable *table, + int row, + int col, + GdkDragContext *context, + GtkSelectionData *selection_data, + guint info, + guint time, + gpointer user_data) +{ + EAddressbookView *view = user_data; + + printf ("table_drag_data_get (row %d, col %d)\n", row, col); + + if (!E_IS_ADDRESSBOOK_MODEL(view->object)) + return; + + switch (info) { + case DND_TARGET_TYPE_VCARD: { + char *value; + + value = e_card_simple_get_vcard(E_ADDRESSBOOK_MODEL(view->object)->data[row]); + + gtk_selection_data_set (selection_data, + selection_data->target, + 8, + value, strlen (value)); + break; + } + } +} + +static void status_message (GtkObject *object, const gchar *status, EAddressbookView *eav) { gtk_signal_emit (GTK_OBJECT (eav), @@ -707,6 +748,15 @@ create_table_view (EAddressbookView *view) gtk_signal_connect(GTK_OBJECT(e_table_scrolled_get_table(E_TABLE_SCROLLED(table))), "right_click", GTK_SIGNAL_FUNC(table_right_click), view); + /* drag & drop signals */ + e_table_drag_source_set (E_TABLE(E_TABLE_SCROLLED(table)->table), GDK_BUTTON1_MASK, + drag_types, num_drag_types, GDK_ACTION_MOVE); + + gtk_signal_connect (GTK_OBJECT (E_TABLE_SCROLLED(table)->table), + "table_drag_data_get", + GTK_SIGNAL_FUNC (table_drag_data_get), + view); + gtk_table_attach(GTK_TABLE(view), table, 0, 1, 0, 1, |