From 8b8193e3c0b12bc7cdceb0a9a05be02d4baebbfc Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Sun, 15 Jul 2001 09:38:05 +0000 Subject: Start editing immediately on a button_press that grabs the focus. 2001-07-15 Christopher James Lahey * gal/e-text/e-text.c (e_text_event): Start editing immediately on a button_press that grabs the focus. e_canvas_item_grab_focus doesn't seem to get us the focus event until the event loop. Fixes Ximian bug #1766. svn path=/trunk/; revision=11111 --- widgets/text/e-text.c | 71 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 27 deletions(-) (limited to 'widgets/text') diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c index db67f83067..f56e9fea55 100644 --- a/widgets/text/e-text.c +++ b/widgets/text/e-text.c @@ -2912,6 +2912,47 @@ _do_tooltip (gpointer data) return FALSE; } +static void +start_editing (EText *text) +{ + if (text->editing) + return; + + text->editing = TRUE; + if (text->pointer_in) { + if (text->default_cursor_shown && (!text->draw_borders)) { + gdk_window_set_cursor (GTK_WIDGET (GNOME_CANVAS_ITEM (text)->canvas)->window, text->i_cursor); + text->default_cursor_shown = FALSE; + } + } + text->select_by_word = FALSE; + text->xofs_edit = 0; + text->yofs_edit = 0; + if (text->timeout_id == 0) + text->timeout_id = g_timeout_add(10, _blink_scroll_timeout, text); + text->timer = g_timer_new(); + g_timer_elapsed(text->timer, &(text->scroll_start)); + g_timer_start(text->timer); +} + +static void +stop_editing (EText *text) +{ + if (!text->editing) + return; + + text->editing = FALSE; + if ( (!text->default_cursor_shown) && (!text->draw_borders) ) { + gdk_window_set_cursor (GTK_WIDGET (GNOME_CANVAS_ITEM (text)->canvas)->window, text->default_cursor); + text->default_cursor_shown = TRUE; + } + if (text->timer) { + g_timer_stop(text->timer); + g_timer_destroy(text->timer); + text->timer = NULL; + } +} + static gboolean _click (gpointer data) { @@ -2937,38 +2978,13 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event) GdkEventFocus *focus_event; focus_event = (GdkEventFocus *) event; if (focus_event->in) { - if(!text->editing) { - text->editing = TRUE; - if ( text->pointer_in ) { - if ( text->default_cursor_shown && (!text->draw_borders)) { - gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, text->i_cursor); - text->default_cursor_shown = FALSE; - } - } - text->select_by_word = FALSE; - text->xofs_edit = 0; - text->yofs_edit = 0; - if (text->timeout_id == 0) - text->timeout_id = g_timeout_add(10, _blink_scroll_timeout, text); - text->timer = g_timer_new(); - g_timer_elapsed(text->timer, &(text->scroll_start)); - g_timer_start(text->timer); - } + start_editing (text); } else { - text->editing = FALSE; - if ( (!text->default_cursor_shown) && (!text->draw_borders) ) { - gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, text->default_cursor); - text->default_cursor_shown = TRUE; - } + stop_editing (text); if (text->timeout_id) { g_source_remove(text->timeout_id); text->timeout_id = 0; } - if (text->timer) { - g_timer_stop(text->timer); - g_timer_destroy(text->timer); - text->timer = NULL; - } } if ( text->line_wrap ) text->needs_split_into_lines = 1; @@ -3051,6 +3067,7 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event) && (event->button.button == 1 || event->button.button == 2)) { e_canvas_item_grab_focus (item, TRUE); + start_editing (text); } #endif -- cgit v1.2.3