aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/widgets
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2001-08-21 07:31:16 +0800
committerChris Toshok <toshok@src.gnome.org>2001-08-21 07:31:16 +0800
commit13c5202cd9f214fddaa95ac259544efc9cd70bd5 (patch)
tree1948849b192d02cbceafb3fd151bbaad7cdb2b9a /addressbook/gui/widgets
parent27ab1e72a98d218c20c658b35fea7af721d708ab (diff)
downloadgsoc2013-evolution-13c5202cd9f214fddaa95ac259544efc9cd70bd5.tar
gsoc2013-evolution-13c5202cd9f214fddaa95ac259544efc9cd70bd5.tar.gz
gsoc2013-evolution-13c5202cd9f214fddaa95ac259544efc9cd70bd5.tar.bz2
gsoc2013-evolution-13c5202cd9f214fddaa95ac259544efc9cd70bd5.tar.lz
gsoc2013-evolution-13c5202cd9f214fddaa95ac259544efc9cd70bd5.tar.xz
gsoc2013-evolution-13c5202cd9f214fddaa95ac259544efc9cd70bd5.tar.zst
gsoc2013-evolution-13c5202cd9f214fddaa95ac259544efc9cd70bd5.zip
fix arg info - we're only passing 1 GTK_TYPE_POINTER arg, not 2.
2001-08-20 Chris Toshok <toshok@ximian.com> * gui/widgets/e-addressbook-reflow-adapter.c (e_addressbook_reflow_adapter_class_init): fix arg info - we're only passing 1 GTK_TYPE_POINTER arg, not 2. * gui/widgets/e-minicard.c (e_minicard_event): lots of fixes for DnD. For GDK_BUTTON_PRESS, we grab immediately. For GDK_BUTTON_MOTION, we start the drag after a certain threshold, and connect to the "drag_end" signal on our canvas so we'll know when the drag is complete. For GDK_BUTTON_RELEASE, we release the grab if we were dragging and get the event. (e_minicard_drag_end): new function, just remove the pointer/gtk grabs and disconnect. * gui/widgets/e-minicard.h (struct _EMinicard): add "gint drag_button" svn path=/trunk/; revision=12331
Diffstat (limited to 'addressbook/gui/widgets')
-rw-r--r--addressbook/gui/widgets/e-addressbook-reflow-adapter.c2
-rw-r--r--addressbook/gui/widgets/e-minicard.c67
-rw-r--r--addressbook/gui/widgets/e-minicard.h1
3 files changed, 53 insertions, 17 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
index b9f4917015..97ceb36a1f 100644
--- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
+++ b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
@@ -548,7 +548,7 @@ e_addressbook_reflow_adapter_class_init (GtkObjectClass *object_class)
object_class->type,
GTK_SIGNAL_OFFSET (EAddressbookReflowAdapterClass, drag_begin),
gtk_marshal_INT__POINTER,
- GTK_TYPE_INT, 2, GTK_TYPE_POINTER, GTK_TYPE_POINTER);
+ GTK_TYPE_INT, 1, GTK_TYPE_POINTER);
gtk_object_class_add_signals (object_class, e_addressbook_reflow_adapter_signals, LAST_SIGNAL);
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
index 6835017a5b..1638ee266c 100644
--- a/addressbook/gui/widgets/e-minicard.c
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -55,6 +55,7 @@ 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 void e_minicard_drag_end (GtkWidget *canvas, GdkDragContext *context, EMinicard *e_minicard);
static GnomeCanvasGroupClass *parent_class = NULL;
@@ -509,30 +510,49 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
}
}
break;
- case GDK_BUTTON_PRESS:
- 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) {
- return e_minicard_selected(e_minicard, event);
+ case GDK_BUTTON_PRESS: {
+ int ret_val = e_minicard_selected(e_minicard, event);
+ GdkEventMask mask = ((1 << (4 + event->button.button)) |
+ GDK_POINTER_MOTION_MASK |
+ GDK_BUTTON_RELEASE_MASK);
+
+ e_canvas_item_grab_focus(item, TRUE);
+
+ if (gnome_canvas_item_grab (GNOME_CANVAS_ITEM (e_minicard),
+ mask, NULL, event->button.time)) {
+ return FALSE;
}
- break;
+ gtk_grab_add (GTK_WIDGET (GNOME_CANVAS_ITEM (e_minicard)->canvas));
+ e_minicard->button_x = event->button.x;
+ e_minicard->button_y = event->button.y;
+ e_minicard->drag_button = event->button.button;
+ e_minicard->drag_button_down = TRUE;
+ return ret_val;
+ }
case GDK_BUTTON_RELEASE:
- e_minicard->drag_button_down = FALSE;
+ if (e_minicard->drag_button_down && e_minicard->drag_button == event->button.button) {
+ e_minicard->drag_button = 0;
+ e_minicard->drag_button_down = FALSE;
+ e_minicard->button_x = -1;
+ e_minicard->button_y = -1;
+
+ if (GTK_WIDGET_HAS_GRAB (GNOME_CANVAS_ITEM (e_minicard)->canvas)) {
+ gtk_grab_remove (GTK_WIDGET (GNOME_CANVAS_ITEM (e_minicard)->canvas));
+ gnome_canvas_item_ungrab (GNOME_CANVAS_ITEM (e_minicard), event->button.time);
+ }
+ }
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);
+ gint ret_val;
+
+ ret_val = e_minicard_drag_begin(e_minicard, event);
- printf ("signalled drag begin\n");
+ /* now we register with drag end on our canvas so we can know when to release our grab */
+ gtk_signal_connect (GTK_OBJECT (GNOME_CANVAS_ITEM (e_minicard)->canvas),
+ "drag_end", (GtkSignalFunc)e_minicard_drag_end, e_minicard);
e_minicard->drag_button_down = FALSE;
@@ -935,3 +955,18 @@ e_minicard_drag_begin (EMinicard *minicard, GdkEvent *event)
event, &ret_val);
return ret_val;
}
+
+static void
+e_minicard_drag_end (GtkWidget *canvas, GdkDragContext *context, EMinicard *e_minicard)
+{
+ e_minicard->drag_button = 0;
+ e_minicard->drag_button_down = FALSE;
+ e_minicard->button_x = -1;
+ e_minicard->button_y = -1;
+
+ gtk_grab_remove (GTK_WIDGET (GNOME_CANVAS_ITEM (e_minicard)->canvas));
+ gnome_canvas_item_ungrab (GNOME_CANVAS_ITEM (e_minicard), GDK_CURRENT_TIME);
+
+ gtk_signal_disconnect_by_func (GTK_OBJECT (GNOME_CANVAS_ITEM (e_minicard)->canvas),
+ (GtkSignalFunc)e_minicard_drag_end, e_minicard);
+}
diff --git a/addressbook/gui/widgets/e-minicard.h b/addressbook/gui/widgets/e-minicard.h
index 5a0f590c23..bd74a24c09 100644
--- a/addressbook/gui/widgets/e-minicard.h
+++ b/addressbook/gui/widgets/e-minicard.h
@@ -89,6 +89,7 @@ struct _EMinicard
guint editable : 1;
guint drag_button_down : 1;
+ gint drag_button;
gint button_x;
gint button_y;