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-minicard.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-minicard.c')
-rw-r--r-- | addressbook/gui/widgets/e-minicard.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c index 0a05185288..1ca1d12aad 100644 --- a/addressbook/gui/widgets/e-minicard.c +++ b/addressbook/gui/widgets/e-minicard.c @@ -22,6 +22,7 @@ #include <config.h> #include <glib.h> +#include <gtk/gtkdnd.h> #include <gdk/gdkkeysyms.h> #include <libgnome/gnome-defs.h> #include <libgnome/gnome-i18n.h> @@ -54,6 +55,8 @@ static void e_minicard_reflow ( GnomeCanvasItem *item, int flags ); static void e_minicard_resize_children( EMinicard *e_minicard ); static void remodel( EMinicard *e_minicard ); +static gint e_minicard_drag_begin (EMinicard *minicard, GdkEvent *event); + static GnomeCanvasGroupClass *parent_class = NULL; typedef struct _EMinicardField EMinicardField; @@ -85,6 +88,7 @@ enum { enum { SELECTED, + DRAG_BEGIN, LAST_SIGNAL }; @@ -147,6 +151,14 @@ e_minicard_class_init (EMinicardClass *klass) gtk_marshal_INT__POINTER, GTK_TYPE_INT, 1, GTK_TYPE_POINTER); + e_minicard_signals [DRAG_BEGIN] = + gtk_signal_new ("drag_begin", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (EMinicardClass, drag_begin), + gtk_marshal_INT__POINTER, + GTK_TYPE_INT, 1, GTK_TYPE_POINTER); + gtk_object_class_add_signals (object_class, e_minicard_signals, LAST_SIGNAL); object_class->set_arg = e_minicard_set_arg; @@ -647,6 +659,9 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) if (event->button.button == 1) { int ret_val = e_minicard_selected(e_minicard, event); e_canvas_item_grab_focus(item, TRUE); + e_minicard->button_x = event->button.x; + e_minicard->button_y = event->button.y; + e_minicard->drag_button_down = TRUE; return ret_val; } else if (event->button.button == 3) { MinicardAndParent *mnp = g_new(MinicardAndParent, 1); @@ -666,7 +681,25 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) e_popup_menu_run (menu, event, 0, E_IS_MINICARD_VIEW(mnp->parent) ? 0 : 1, mnp); } break; + case GDK_BUTTON_RELEASE: + e_minicard->drag_button_down = FALSE; + break; + case GDK_MOTION_NOTIFY: + /* shamelessly ripped from e-table.c, complete with + broken stuck-grab behavior */ + if (e_minicard->drag_button_down && event->motion.state & GDK_BUTTON1_MASK) { + if (MAX (abs (e_minicard->button_x - event->motion.x), + abs (e_minicard->button_y - event->motion.y)) > 3) { + gint ret_val = e_minicard_drag_begin(e_minicard, event); + + printf ("signalled drag begin\n"); + + e_minicard->drag_button_down = FALSE; + return ret_val; + } + } + break; case GDK_2BUTTON_PRESS: if (event->button.button == 1 && E_IS_MINICARD_VIEW(item->parent)) { if (e_minicard->editor) { @@ -989,3 +1022,13 @@ e_minicard_selected (EMinicard *minicard, GdkEvent *event) event, &ret_val); return ret_val; } + +static gint +e_minicard_drag_begin (EMinicard *minicard, GdkEvent *event) +{ + gint ret_val = 0; + gtk_signal_emit (GTK_OBJECT(minicard), + e_minicard_signals[DRAG_BEGIN], + event, &ret_val); + return ret_val; +} |