aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2001-07-15 17:38:05 +0800
committerChris Lahey <clahey@src.gnome.org>2001-07-15 17:38:05 +0800
commit8b8193e3c0b12bc7cdceb0a9a05be02d4baebbfc (patch)
treecd9f4d589142f27c90184ae772ba45c31950c312 /widgets
parentbdc396c0012257c1d5a1bd78993dd42cdf52bdb8 (diff)
downloadgsoc2013-evolution-8b8193e3c0b12bc7cdceb0a9a05be02d4baebbfc.tar.gz
gsoc2013-evolution-8b8193e3c0b12bc7cdceb0a9a05be02d4baebbfc.tar.zst
gsoc2013-evolution-8b8193e3c0b12bc7cdceb0a9a05be02d4baebbfc.zip
Start editing immediately on a button_press that grabs the focus.
2001-07-15 Christopher James Lahey <clahey@ximian.com> * 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
Diffstat (limited to 'widgets')
-rw-r--r--widgets/text/e-text.c71
1 files changed, 44 insertions, 27 deletions
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