aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-01-26 08:53:50 +0800
committerChris Lahey <clahey@src.gnome.org>2000-01-26 08:53:50 +0800
commit7ffbbe3692d4bf0f8b5919939881021eb2c907fb (patch)
treec53ae2105335aca48e4fec6834e9a0bff34421db /widgets
parent3d79779ce2cc9b1c00dc3081da2264f25e652ac4 (diff)
downloadgsoc2013-evolution-7ffbbe3692d4bf0f8b5919939881021eb2c907fb.tar
gsoc2013-evolution-7ffbbe3692d4bf0f8b5919939881021eb2c907fb.tar.gz
gsoc2013-evolution-7ffbbe3692d4bf0f8b5919939881021eb2c907fb.tar.bz2
gsoc2013-evolution-7ffbbe3692d4bf0f8b5919939881021eb2c907fb.tar.lz
gsoc2013-evolution-7ffbbe3692d4bf0f8b5919939881021eb2c907fb.tar.xz
gsoc2013-evolution-7ffbbe3692d4bf0f8b5919939881021eb2c907fb.tar.zst
gsoc2013-evolution-7ffbbe3692d4bf0f8b5919939881021eb2c907fb.zip
Handle shift-tab properly now.
2000-01-25 Christopher James Lahey <clahey@helixcode.com> * widgets/e-reflow.c, widgets/e-minicard.c: Handle shift-tab properly now. * widgets/e-minicard-label.c: Reindented some areas. * widgets/test-reflow.c: Use e-canvas. Set the back pixmap to NULL for the canvas so that scrolling won't flash grey. * widgets/e-canvas.c, widgets/e-canvas.h: These subclass GnomeCanvas to work around a few bugs so that evolution will work well with old versions of gnome-libs. * widgets/Makefile.am: Added e-canvas.c and e-canvas.h. * addressbook/contact-editor/contact-editor.glade: Not much change. Mostly internal reorganization by glade itself. svn path=/trunk/; revision=1638
Diffstat (limited to 'widgets')
-rw-r--r--widgets/Makefile.am2
-rw-r--r--widgets/e-canvas.c233
-rw-r--r--widgets/e-canvas.h66
-rw-r--r--widgets/e-minicard-label.c32
-rw-r--r--widgets/e-minicard.c4
-rw-r--r--widgets/e-minicard/e-minicard-label.c32
-rw-r--r--widgets/e-minicard/e-minicard.c4
-rw-r--r--widgets/e-minicard/e-reflow.c4
-rw-r--r--widgets/e-minicard/test-reflow.c4
-rw-r--r--widgets/e-reflow.c4
-rw-r--r--widgets/e-reflow/e-reflow.c4
-rw-r--r--widgets/misc/e-canvas.c233
-rw-r--r--widgets/misc/e-canvas.h66
-rw-r--r--widgets/misc/e-reflow.c4
-rw-r--r--widgets/test-reflow.c4
15 files changed, 652 insertions, 44 deletions
diff --git a/widgets/Makefile.am b/widgets/Makefile.am
index 1e2016ef3c..e2659cac03 100644
--- a/widgets/Makefile.am
+++ b/widgets/Makefile.am
@@ -11,6 +11,8 @@ noinst_LIBRARIES = \
libevolutionwidgets.a
libevolutionwidgets_a_SOURCES = \
+ e-canvas.c \
+ e-canvas.h \
e-canvas-utils.c \
e-canvas-utils.h \
e-cursors.c \
diff --git a/widgets/e-canvas.c b/widgets/e-canvas.c
new file mode 100644
index 0000000000..74af105b36
--- /dev/null
+++ b/widgets/e-canvas.c
@@ -0,0 +1,233 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * e-canvas.c
+ * Copyright (C) 2000 Helix Code, Inc.
+ * Author: Chris Lahey <clahey@helixcode.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gnome.h>
+#include "e-canvas.h"
+static void e_canvas_init (ECanvas *card);
+static void e_canvas_class_init (ECanvasClass *klass);
+static gint e_canvas_key (GtkWidget *widget,
+ GdkEventKey *event);
+
+static int emit_event (GnomeCanvas *canvas, GdkEvent *event);
+
+static GnomeCanvasClass *parent_class = NULL;
+
+GtkType
+e_canvas_get_type (void)
+{
+ static GtkType canvas_type = 0;
+
+ if (!canvas_type)
+ {
+ static const GtkTypeInfo canvas_info =
+ {
+ "ECanvas",
+ sizeof (ECanvas),
+ sizeof (ECanvasClass),
+ (GtkClassInitFunc) e_canvas_class_init,
+ (GtkObjectInitFunc) e_canvas_init,
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
+ (GtkClassInitFunc) NULL,
+ };
+
+ canvas_type = gtk_type_unique (gnome_canvas_get_type (), &canvas_info);
+ }
+
+ return canvas_type;
+}
+
+static void
+e_canvas_class_init (ECanvasClass *klass)
+{
+ GtkObjectClass *object_class;
+ GnomeCanvasClass *canvas_class;
+ GtkWidgetClass *widget_class;
+
+ object_class = (GtkObjectClass*) klass;
+ canvas_class = (GnomeCanvasClass *) klass;
+ widget_class = (GtkWidgetClass *) klass;
+
+ parent_class = gtk_type_class (gnome_canvas_get_type ());
+
+ widget_class->key_press_event = e_canvas_key;
+ widget_class->key_release_event = e_canvas_key;
+}
+
+static void
+e_canvas_init (ECanvas *canvas)
+{
+}
+
+GtkWidget *
+e_canvas_new()
+{
+ return GTK_WIDGET (gtk_type_new (e_canvas_get_type ()));
+}
+
+
+/* Returns whether the item is an inferior of or is equal to the parent. */
+static int
+is_descendant (GnomeCanvasItem *item, GnomeCanvasItem *parent)
+{
+ for (; item; item = item->parent)
+ if (item == parent)
+ return TRUE;
+
+ return FALSE;
+}
+
+/* Emits an event for an item in the canvas, be it the current item, grabbed
+ * item, or focused item, as appropriate.
+ */
+static int
+emit_event (GnomeCanvas *canvas, GdkEvent *event)
+{
+ GdkEvent ev;
+ gint finished;
+ GnomeCanvasItem *item;
+ GnomeCanvasItem *parent;
+ guint mask;
+
+ /* Perform checks for grabbed items */
+
+ if (canvas->grabbed_item && !is_descendant (canvas->current_item, canvas->grabbed_item))
+ return FALSE;
+
+ if (canvas->grabbed_item) {
+ switch (event->type) {
+ case GDK_ENTER_NOTIFY:
+ mask = GDK_ENTER_NOTIFY_MASK;
+ break;
+
+ case GDK_LEAVE_NOTIFY:
+ mask = GDK_LEAVE_NOTIFY_MASK;
+ break;
+
+ case GDK_MOTION_NOTIFY:
+ mask = GDK_POINTER_MOTION_MASK;
+ break;
+
+ case GDK_BUTTON_PRESS:
+ case GDK_2BUTTON_PRESS:
+ case GDK_3BUTTON_PRESS:
+ mask = GDK_BUTTON_PRESS_MASK;
+ break;
+
+ case GDK_BUTTON_RELEASE:
+ mask = GDK_BUTTON_RELEASE_MASK;
+ break;
+
+ case GDK_KEY_PRESS:
+ mask = GDK_KEY_PRESS_MASK;
+ break;
+
+ case GDK_KEY_RELEASE:
+ mask = GDK_KEY_RELEASE_MASK;
+ break;
+
+ default:
+ mask = 0;
+ break;
+ }
+
+ if (!(mask & canvas->grabbed_event_mask))
+ return FALSE;
+ }
+
+ /* Convert to world coordinates -- we have two cases because of diferent
+ * offsets of the fields in the event structures.
+ */
+
+ ev = *event;
+
+ switch (ev.type) {
+ case GDK_ENTER_NOTIFY:
+ case GDK_LEAVE_NOTIFY:
+ gnome_canvas_window_to_world (canvas,
+ ev.crossing.x, ev.crossing.y,
+ &ev.crossing.x, &ev.crossing.y);
+ break;
+
+ case GDK_MOTION_NOTIFY:
+ case GDK_BUTTON_PRESS:
+ case GDK_2BUTTON_PRESS:
+ case GDK_3BUTTON_PRESS:
+ case GDK_BUTTON_RELEASE:
+ gnome_canvas_window_to_world (canvas,
+ ev.motion.x, ev.motion.y,
+ &ev.motion.x, &ev.motion.y);
+ break;
+
+ default:
+ break;
+ }
+
+ /* Choose where we send the event */
+
+ item = canvas->current_item;
+
+ if (canvas->focused_item
+ && ((event->type == GDK_KEY_PRESS) || (event->type == GDK_KEY_RELEASE) || (event->type == GDK_FOCUS_CHANGE)))
+ item = canvas->focused_item;
+
+ /* The event is propagated up the hierarchy (for if someone connected to
+ * a group instead of a leaf event), and emission is stopped if a
+ * handler returns TRUE, just like for GtkWidget events.
+ */
+
+ finished = FALSE;
+
+ while (item && !finished) {
+ gtk_object_ref (GTK_OBJECT (item));
+
+ gtk_signal_emit_by_name (GTK_OBJECT (item), "event",
+ &ev,
+ &finished);
+
+ if (GTK_OBJECT_DESTROYED (item))
+ finished = TRUE;
+
+ parent = item->parent;
+ gtk_object_unref (GTK_OBJECT (item));
+
+ item = parent;
+ }
+
+ return finished;
+}
+
+/* Key event handler for the canvas */
+static gint
+e_canvas_key (GtkWidget *widget, GdkEventKey *event)
+{
+ GnomeCanvas *canvas;
+
+ g_return_val_if_fail (widget != NULL, FALSE);
+ g_return_val_if_fail (GNOME_IS_CANVAS (widget), FALSE);
+ g_return_val_if_fail (event != NULL, FALSE);
+
+ canvas = GNOME_CANVAS (widget);
+
+ return emit_event (canvas, (GdkEvent *) event);
+}
+
diff --git a/widgets/e-canvas.h b/widgets/e-canvas.h
new file mode 100644
index 0000000000..06c3625f3a
--- /dev/null
+++ b/widgets/e-canvas.h
@@ -0,0 +1,66 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* e-canvas.h
+ * Copyright (C) 2000 Helix Code, Inc.
+ * Author: Chris Lahey <clahey@helixcode.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef __E_CANVAS_H__
+#define __E_CANVAS_H__
+
+#include <gnome.h>
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+/* ECanvas - A class derived from canvas for the purpose of adding
+ * evolution specific canvas hacks.
+ */
+
+#define E_CANVAS_TYPE (e_canvas_get_type ())
+#define E_CANVAS(obj) (GTK_CHECK_CAST ((obj), E_CANVAS_TYPE, ECanvas))
+#define E_CANVAS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_CANVAS_TYPE, ECanvasClass))
+#define E_IS_CANVAS(obj) (GTK_CHECK_TYPE ((obj), E_CANVAS_TYPE))
+#define E_IS_CANVAS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_CANVAS_TYPE))
+
+
+typedef struct _ECanvas ECanvas;
+typedef struct _ECanvasClass ECanvasClass;
+
+struct _ECanvas
+{
+ GnomeCanvas parent;
+
+ /* item specific fields */
+};
+
+struct _ECanvasClass
+{
+ GnomeCanvasClass parent_class;
+};
+
+
+GtkType e_canvas_get_type (void);
+GtkWidget *e_canvas_new (void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __E_CANVAS_H__ */
diff --git a/widgets/e-minicard-label.c b/widgets/e-minicard-label.c
index 7e32acad59..0c4078f69f 100644
--- a/widgets/e-minicard-label.c
+++ b/widgets/e-minicard-label.c
@@ -188,26 +188,22 @@ e_minicard_label_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
GTK_VALUE_BOOL (*arg) = e_minicard_label->has_focus;
break;
case ARG_FIELD:
- if ( e_minicard_label->field )
- {
- gtk_object_get( GTK_OBJECT( e_minicard_label->field ), "text", &temp, NULL );
- GTK_VALUE_STRING (*arg) = temp;
- }
- else
- GTK_VALUE_STRING (*arg) = g_strdup( e_minicard_label->field_text );
- break;
+ if ( e_minicard_label->field ) {
+ gtk_object_get( GTK_OBJECT( e_minicard_label->field ), "text", &temp, NULL );
+ GTK_VALUE_STRING (*arg) = temp;
+ } else
+ GTK_VALUE_STRING (*arg) = g_strdup( e_minicard_label->field_text );
+ break;
case ARG_FIELDNAME:
- if ( e_minicard_label->fieldname )
- {
- gtk_object_get( GTK_OBJECT( e_minicard_label->fieldname ), "text", &temp, NULL );
- GTK_VALUE_STRING (*arg) = temp;
- }
- else
- GTK_VALUE_STRING (*arg) = g_strdup( e_minicard_label->fieldname_text );
- break;
+ if ( e_minicard_label->fieldname ) {
+ gtk_object_get( GTK_OBJECT( e_minicard_label->fieldname ), "text", &temp, NULL );
+ GTK_VALUE_STRING (*arg) = temp;
+ } else
+ GTK_VALUE_STRING (*arg) = g_strdup( e_minicard_label->fieldname_text );
+ break;
default:
- arg->type = GTK_TYPE_INVALID;
- break;
+ arg->type = GTK_TYPE_INVALID;
+ break;
}
}
diff --git a/widgets/e-minicard.c b/widgets/e-minicard.c
index f656d98b40..b6de4b2d0c 100644
--- a/widgets/e-minicard.c
+++ b/widgets/e-minicard.c
@@ -357,7 +357,9 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
}
break;
case GDK_KEY_PRESS:
- if (event->key.length == 1 && event->key.string[0] == '\t') {
+ if (event->key.keyval == GDK_Tab ||
+ event->key.keyval == GDK_KP_Tab ||
+ event->key.keyval == GDK_ISO_Left_Tab) {
GList *list;
for (list = e_minicard->fields; list; list = list->next) {
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (list->data);
diff --git a/widgets/e-minicard/e-minicard-label.c b/widgets/e-minicard/e-minicard-label.c
index 7e32acad59..0c4078f69f 100644
--- a/widgets/e-minicard/e-minicard-label.c
+++ b/widgets/e-minicard/e-minicard-label.c
@@ -188,26 +188,22 @@ e_minicard_label_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
GTK_VALUE_BOOL (*arg) = e_minicard_label->has_focus;
break;
case ARG_FIELD:
- if ( e_minicard_label->field )
- {
- gtk_object_get( GTK_OBJECT( e_minicard_label->field ), "text", &temp, NULL );
- GTK_VALUE_STRING (*arg) = temp;
- }
- else
- GTK_VALUE_STRING (*arg) = g_strdup( e_minicard_label->field_text );
- break;
+ if ( e_minicard_label->field ) {
+ gtk_object_get( GTK_OBJECT( e_minicard_label->field ), "text", &temp, NULL );
+ GTK_VALUE_STRING (*arg) = temp;
+ } else
+ GTK_VALUE_STRING (*arg) = g_strdup( e_minicard_label->field_text );
+ break;
case ARG_FIELDNAME:
- if ( e_minicard_label->fieldname )
- {
- gtk_object_get( GTK_OBJECT( e_minicard_label->fieldname ), "text", &temp, NULL );
- GTK_VALUE_STRING (*arg) = temp;
- }
- else
- GTK_VALUE_STRING (*arg) = g_strdup( e_minicard_label->fieldname_text );
- break;
+ if ( e_minicard_label->fieldname ) {
+ gtk_object_get( GTK_OBJECT( e_minicard_label->fieldname ), "text", &temp, NULL );
+ GTK_VALUE_STRING (*arg) = temp;
+ } else
+ GTK_VALUE_STRING (*arg) = g_strdup( e_minicard_label->fieldname_text );
+ break;
default:
- arg->type = GTK_TYPE_INVALID;
- break;
+ arg->type = GTK_TYPE_INVALID;
+ break;
}
}
diff --git a/widgets/e-minicard/e-minicard.c b/widgets/e-minicard/e-minicard.c
index f656d98b40..b6de4b2d0c 100644
--- a/widgets/e-minicard/e-minicard.c
+++ b/widgets/e-minicard/e-minicard.c
@@ -357,7 +357,9 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event)
}
break;
case GDK_KEY_PRESS:
- if (event->key.length == 1 && event->key.string[0] == '\t') {
+ if (event->key.keyval == GDK_Tab ||
+ event->key.keyval == GDK_KP_Tab ||
+ event->key.keyval == GDK_ISO_Left_Tab) {
GList *list;
for (list = e_minicard->fields; list; list = list->next) {
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (list->data);
diff --git a/widgets/e-minicard/e-reflow.c b/widgets/e-minicard/e-reflow.c
index e9ff1b6eaa..41be2ec533 100644
--- a/widgets/e-minicard/e-reflow.c
+++ b/widgets/e-minicard/e-reflow.c
@@ -238,7 +238,9 @@ e_reflow_event (GnomeCanvasItem *item, GdkEvent *event)
switch( event->type )
{
case GDK_KEY_PRESS:
- if (event->key.length == 1 && event->key.string[0] == '\t') {
+ if (event->key.keyval == GDK_Tab ||
+ event->key.keyval == GDK_KP_Tab ||
+ event->key.keyval == GDK_ISO_Left_Tab) {
GList *list;
for (list = e_reflow->items; list; list = list->next) {
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (list->data);
diff --git a/widgets/e-minicard/test-reflow.c b/widgets/e-minicard/test-reflow.c
index 067e520754..9efc2722dd 100644
--- a/widgets/e-minicard/test-reflow.c
+++ b/widgets/e-minicard/test-reflow.c
@@ -20,6 +20,7 @@
#include "config.h"
#include <gnome.h>
+#include "e-canvas.h"
#include "e-reflow.h"
#include "e-minicard.h"
@@ -99,7 +100,7 @@ int main( int argc, char *argv[] )
vbox = gtk_vbox_new(FALSE, 0);
- canvas = gnome_canvas_new();
+ canvas = e_canvas_new();
rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
gnome_canvas_rect_get_type(),
"x1", (double) 0,
@@ -147,6 +148,7 @@ int main( int argc, char *argv[] )
( gpointer ) app );
gtk_widget_show_all( app );
+ gdk_window_set_back_pixmap( GTK_LAYOUT(canvas)->bin_window, NULL, FALSE);
gtk_main();
diff --git a/widgets/e-reflow.c b/widgets/e-reflow.c
index e9ff1b6eaa..41be2ec533 100644
--- a/widgets/e-reflow.c
+++ b/widgets/e-reflow.c
@@ -238,7 +238,9 @@ e_reflow_event (GnomeCanvasItem *item, GdkEvent *event)
switch( event->type )
{
case GDK_KEY_PRESS:
- if (event->key.length == 1 && event->key.string[0] == '\t') {
+ if (event->key.keyval == GDK_Tab ||
+ event->key.keyval == GDK_KP_Tab ||
+ event->key.keyval == GDK_ISO_Left_Tab) {
GList *list;
for (list = e_reflow->items; list; list = list->next) {
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (list->data);
diff --git a/widgets/e-reflow/e-reflow.c b/widgets/e-reflow/e-reflow.c
index e9ff1b6eaa..41be2ec533 100644
--- a/widgets/e-reflow/e-reflow.c
+++ b/widgets/e-reflow/e-reflow.c
@@ -238,7 +238,9 @@ e_reflow_event (GnomeCanvasItem *item, GdkEvent *event)
switch( event->type )
{
case GDK_KEY_PRESS:
- if (event->key.length == 1 && event->key.string[0] == '\t') {
+ if (event->key.keyval == GDK_Tab ||
+ event->key.keyval == GDK_KP_Tab ||
+ event->key.keyval == GDK_ISO_Left_Tab) {
GList *list;
for (list = e_reflow->items; list; list = list->next) {
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (list->data);
diff --git a/widgets/misc/e-canvas.c b/widgets/misc/e-canvas.c
new file mode 100644
index 0000000000..74af105b36
--- /dev/null
+++ b/widgets/misc/e-canvas.c
@@ -0,0 +1,233 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * e-canvas.c
+ * Copyright (C) 2000 Helix Code, Inc.
+ * Author: Chris Lahey <clahey@helixcode.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <gnome.h>
+#include "e-canvas.h"
+static void e_canvas_init (ECanvas *card);
+static void e_canvas_class_init (ECanvasClass *klass);
+static gint e_canvas_key (GtkWidget *widget,
+ GdkEventKey *event);
+
+static int emit_event (GnomeCanvas *canvas, GdkEvent *event);
+
+static GnomeCanvasClass *parent_class = NULL;
+
+GtkType
+e_canvas_get_type (void)
+{
+ static GtkType canvas_type = 0;
+
+ if (!canvas_type)
+ {
+ static const GtkTypeInfo canvas_info =
+ {
+ "ECanvas",
+ sizeof (ECanvas),
+ sizeof (ECanvasClass),
+ (GtkClassInitFunc) e_canvas_class_init,
+ (GtkObjectInitFunc) e_canvas_init,
+ /* reserved_1 */ NULL,
+ /* reserved_2 */ NULL,
+ (GtkClassInitFunc) NULL,
+ };
+
+ canvas_type = gtk_type_unique (gnome_canvas_get_type (), &canvas_info);
+ }
+
+ return canvas_type;
+}
+
+static void
+e_canvas_class_init (ECanvasClass *klass)
+{
+ GtkObjectClass *object_class;
+ GnomeCanvasClass *canvas_class;
+ GtkWidgetClass *widget_class;
+
+ object_class = (GtkObjectClass*) klass;
+ canvas_class = (GnomeCanvasClass *) klass;
+ widget_class = (GtkWidgetClass *) klass;
+
+ parent_class = gtk_type_class (gnome_canvas_get_type ());
+
+ widget_class->key_press_event = e_canvas_key;
+ widget_class->key_release_event = e_canvas_key;
+}
+
+static void
+e_canvas_init (ECanvas *canvas)
+{
+}
+
+GtkWidget *
+e_canvas_new()
+{
+ return GTK_WIDGET (gtk_type_new (e_canvas_get_type ()));
+}
+
+
+/* Returns whether the item is an inferior of or is equal to the parent. */
+static int
+is_descendant (GnomeCanvasItem *item, GnomeCanvasItem *parent)
+{
+ for (; item; item = item->parent)
+ if (item == parent)
+ return TRUE;
+
+ return FALSE;
+}
+
+/* Emits an event for an item in the canvas, be it the current item, grabbed
+ * item, or focused item, as appropriate.
+ */
+static int
+emit_event (GnomeCanvas *canvas, GdkEvent *event)
+{
+ GdkEvent ev;
+ gint finished;
+ GnomeCanvasItem *item;
+ GnomeCanvasItem *parent;
+ guint mask;
+
+ /* Perform checks for grabbed items */
+
+ if (canvas->grabbed_item && !is_descendant (canvas->current_item, canvas->grabbed_item))
+ return FALSE;
+
+ if (canvas->grabbed_item) {
+ switch (event->type) {
+ case GDK_ENTER_NOTIFY:
+ mask = GDK_ENTER_NOTIFY_MASK;
+ break;
+
+ case GDK_LEAVE_NOTIFY:
+ mask = GDK_LEAVE_NOTIFY_MASK;
+ break;
+
+ case GDK_MOTION_NOTIFY:
+ mask = GDK_POINTER_MOTION_MASK;
+ break;
+
+ case GDK_BUTTON_PRESS:
+ case GDK_2BUTTON_PRESS:
+ case GDK_3BUTTON_PRESS:
+ mask = GDK_BUTTON_PRESS_MASK;
+ break;
+
+ case GDK_BUTTON_RELEASE:
+ mask = GDK_BUTTON_RELEASE_MASK;
+ break;
+
+ case GDK_KEY_PRESS:
+ mask = GDK_KEY_PRESS_MASK;
+ break;
+
+ case GDK_KEY_RELEASE:
+ mask = GDK_KEY_RELEASE_MASK;
+ break;
+
+ default:
+ mask = 0;
+ break;
+ }
+
+ if (!(mask & canvas->grabbed_event_mask))
+ return FALSE;
+ }
+
+ /* Convert to world coordinates -- we have two cases because of diferent
+ * offsets of the fields in the event structures.
+ */
+
+ ev = *event;
+
+ switch (ev.type) {
+ case GDK_ENTER_NOTIFY:
+ case GDK_LEAVE_NOTIFY:
+ gnome_canvas_window_to_world (canvas,
+ ev.crossing.x, ev.crossing.y,
+ &ev.crossing.x, &ev.crossing.y);
+ break;
+
+ case GDK_MOTION_NOTIFY:
+ case GDK_BUTTON_PRESS:
+ case GDK_2BUTTON_PRESS:
+ case GDK_3BUTTON_PRESS:
+ case GDK_BUTTON_RELEASE:
+ gnome_canvas_window_to_world (canvas,
+ ev.motion.x, ev.motion.y,
+ &ev.motion.x, &ev.motion.y);
+ break;
+
+ default:
+ break;
+ }
+
+ /* Choose where we send the event */
+
+ item = canvas->current_item;
+
+ if (canvas->focused_item
+ && ((event->type == GDK_KEY_PRESS) || (event->type == GDK_KEY_RELEASE) || (event->type == GDK_FOCUS_CHANGE)))
+ item = canvas->focused_item;
+
+ /* The event is propagated up the hierarchy (for if someone connected to
+ * a group instead of a leaf event), and emission is stopped if a
+ * handler returns TRUE, just like for GtkWidget events.
+ */
+
+ finished = FALSE;
+
+ while (item && !finished) {
+ gtk_object_ref (GTK_OBJECT (item));
+
+ gtk_signal_emit_by_name (GTK_OBJECT (item), "event",
+ &ev,
+ &finished);
+
+ if (GTK_OBJECT_DESTROYED (item))
+ finished = TRUE;
+
+ parent = item->parent;
+ gtk_object_unref (GTK_OBJECT (item));
+
+ item = parent;
+ }
+
+ return finished;
+}
+
+/* Key event handler for the canvas */
+static gint
+e_canvas_key (GtkWidget *widget, GdkEventKey *event)
+{
+ GnomeCanvas *canvas;
+
+ g_return_val_if_fail (widget != NULL, FALSE);
+ g_return_val_if_fail (GNOME_IS_CANVAS (widget), FALSE);
+ g_return_val_if_fail (event != NULL, FALSE);
+
+ canvas = GNOME_CANVAS (widget);
+
+ return emit_event (canvas, (GdkEvent *) event);
+}
+
diff --git a/widgets/misc/e-canvas.h b/widgets/misc/e-canvas.h
new file mode 100644
index 0000000000..06c3625f3a
--- /dev/null
+++ b/widgets/misc/e-canvas.h
@@ -0,0 +1,66 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* e-canvas.h
+ * Copyright (C) 2000 Helix Code, Inc.
+ * Author: Chris Lahey <clahey@helixcode.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+#ifndef __E_CANVAS_H__
+#define __E_CANVAS_H__
+
+#include <gnome.h>
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+/* ECanvas - A class derived from canvas for the purpose of adding
+ * evolution specific canvas hacks.
+ */
+
+#define E_CANVAS_TYPE (e_canvas_get_type ())
+#define E_CANVAS(obj) (GTK_CHECK_CAST ((obj), E_CANVAS_TYPE, ECanvas))
+#define E_CANVAS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_CANVAS_TYPE, ECanvasClass))
+#define E_IS_CANVAS(obj) (GTK_CHECK_TYPE ((obj), E_CANVAS_TYPE))
+#define E_IS_CANVAS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_CANVAS_TYPE))
+
+
+typedef struct _ECanvas ECanvas;
+typedef struct _ECanvasClass ECanvasClass;
+
+struct _ECanvas
+{
+ GnomeCanvas parent;
+
+ /* item specific fields */
+};
+
+struct _ECanvasClass
+{
+ GnomeCanvasClass parent_class;
+};
+
+
+GtkType e_canvas_get_type (void);
+GtkWidget *e_canvas_new (void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __E_CANVAS_H__ */
diff --git a/widgets/misc/e-reflow.c b/widgets/misc/e-reflow.c
index e9ff1b6eaa..41be2ec533 100644
--- a/widgets/misc/e-reflow.c
+++ b/widgets/misc/e-reflow.c
@@ -238,7 +238,9 @@ e_reflow_event (GnomeCanvasItem *item, GdkEvent *event)
switch( event->type )
{
case GDK_KEY_PRESS:
- if (event->key.length == 1 && event->key.string[0] == '\t') {
+ if (event->key.keyval == GDK_Tab ||
+ event->key.keyval == GDK_KP_Tab ||
+ event->key.keyval == GDK_ISO_Left_Tab) {
GList *list;
for (list = e_reflow->items; list; list = list->next) {
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (list->data);
diff --git a/widgets/test-reflow.c b/widgets/test-reflow.c
index 067e520754..9efc2722dd 100644
--- a/widgets/test-reflow.c
+++ b/widgets/test-reflow.c
@@ -20,6 +20,7 @@
#include "config.h"
#include <gnome.h>
+#include "e-canvas.h"
#include "e-reflow.h"
#include "e-minicard.h"
@@ -99,7 +100,7 @@ int main( int argc, char *argv[] )
vbox = gtk_vbox_new(FALSE, 0);
- canvas = gnome_canvas_new();
+ canvas = e_canvas_new();
rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ),
gnome_canvas_rect_get_type(),
"x1", (double) 0,
@@ -147,6 +148,7 @@ int main( int argc, char *argv[] )
( gpointer ) app );
gtk_widget_show_all( app );
+ gdk_window_set_back_pixmap( GTK_LAYOUT(canvas)->bin_window, NULL, FALSE);
gtk_main();