diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-01-27 15:51:37 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-01-27 15:51:37 +0800 |
commit | 905f7de48f5c591caa340f099fff821e07bf82e4 (patch) | |
tree | 29848942ad019efff76c85c90234627392b8b93e /e-util/e-canvas.c | |
parent | 074aff3059b7d127a7670c65ed3f1ae542b1b1cb (diff) | |
download | gsoc2013-evolution-905f7de48f5c591caa340f099fff821e07bf82e4.tar.gz gsoc2013-evolution-905f7de48f5c591caa340f099fff821e07bf82e4.tar.zst gsoc2013-evolution-905f7de48f5c591caa340f099fff821e07bf82e4.zip |
Use e_canvas_item_grab_focus so that it will work with old versions of
2000-01-28 Christopher James Lahey <clahey@helixcode.com>
* widgets/e-minicard-label.c, widgets/e-minicard.c: Use
e_canvas_item_grab_focus so that it will work with old versions of
gnome-canvas.
* widgets/e-canvas.c, widgets/e-canvas.h: Finished working around
focus bugs.
svn path=/trunk/; revision=1649
Diffstat (limited to 'e-util/e-canvas.c')
-rw-r--r-- | e-util/e-canvas.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/e-util/e-canvas.c b/e-util/e-canvas.c index 74af105b36..850e438386 100644 --- a/e-util/e-canvas.c +++ b/e-util/e-canvas.c @@ -27,6 +27,11 @@ static void e_canvas_class_init (ECanvasClass *klass); static gint e_canvas_key (GtkWidget *widget, GdkEventKey *event); +static gint e_canvas_focus_in (GtkWidget *widget, + GdkEventFocus *event); +static gint e_canvas_focus_out (GtkWidget *widget, + GdkEventFocus *event); + static int emit_event (GnomeCanvas *canvas, GdkEvent *event); static GnomeCanvasClass *parent_class = NULL; @@ -71,6 +76,8 @@ e_canvas_class_init (ECanvasClass *klass) widget_class->key_press_event = e_canvas_key; widget_class->key_release_event = e_canvas_key; + widget_class->focus_in_event = e_canvas_focus_in; + widget_class->focus_out_event = e_canvas_focus_out; } static void @@ -231,3 +238,64 @@ e_canvas_key (GtkWidget *widget, GdkEventKey *event) return emit_event (canvas, (GdkEvent *) event); } + +/** + * e_canvas_item_grab_focus: + * @item: A canvas item. + * + * Makes the specified item take the keyboard focus, so all keyboard events will + * be sent to it. If the canvas widget itself did not have the focus, it grabs + * it as well. + **/ +void +e_canvas_item_grab_focus (GnomeCanvasItem *item) +{ + GnomeCanvasItem *focused_item; + GdkEvent ev; + + g_return_if_fail (item != NULL); + g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); + g_return_if_fail (GTK_WIDGET_CAN_FOCUS (GTK_WIDGET (item->canvas))); + + focused_item = item->canvas->focused_item; + + if (focused_item) { + ev.focus_change.type = GDK_FOCUS_CHANGE; + ev.focus_change.window = GTK_LAYOUT (item->canvas)->bin_window; + ev.focus_change.send_event = FALSE; + ev.focus_change.in = FALSE; + + emit_event (item->canvas, &ev); + } + + item->canvas->focused_item = item; + gtk_widget_grab_focus (GTK_WIDGET (item->canvas)); +} + +/* Focus in handler for the canvas */ +static gint +e_canvas_focus_in (GtkWidget *widget, GdkEventFocus *event) +{ + GnomeCanvas *canvas; + + canvas = GNOME_CANVAS (widget); + + if (canvas->focused_item) + return emit_event (canvas, (GdkEvent *) event); + else + return FALSE; +} + +/* Focus out handler for the canvas */ +static gint +e_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event) +{ + GnomeCanvas *canvas; + + canvas = GNOME_CANVAS (widget); + + if (canvas->focused_item) + return emit_event (canvas, (GdkEvent *) event); + else + return FALSE; +} |