aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/text
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/text')
-rw-r--r--widgets/text/e-text-event-processor-emacs-like.c6
-rw-r--r--widgets/text/e-text-event-processor-types.h3
-rw-r--r--widgets/text/e-text.c44
3 files changed, 40 insertions, 13 deletions
diff --git a/widgets/text/e-text-event-processor-emacs-like.c b/widgets/text/e-text-event-processor-emacs-like.c
index d2bf524401..41bcd0c31d 100644
--- a/widgets/text/e-text-event-processor-emacs-like.c
+++ b/widgets/text/e-text-event-processor-emacs-like.c
@@ -146,6 +146,9 @@ e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, ETextEventPro
switch (event->type) {
case GDK_BUTTON_PRESS:
if (event->button.button == 1) {
+ command.action = E_TEP_GRAB;
+ command.time = event->button.time;
+ gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
if (event->button.state & GDK_SHIFT_MASK)
command.action = E_TEP_SELECT;
else
@@ -158,6 +161,9 @@ e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, ETextEventPro
break;
case GDK_BUTTON_RELEASE:
if (event->button.button == 1) {
+ command.action = E_TEP_UNGRAB;
+ command.time = event->button.time;
+ gtk_signal_emit_by_name (GTK_OBJECT (tep), "command", &command);
command.time = event->button.time;
tep_el->mouse_down = FALSE;
} else if (event->button.button == 2) {
diff --git a/widgets/text/e-text-event-processor-types.h b/widgets/text/e-text-event-processor-types.h
index eb8e0d4a50..32a39bf0c0 100644
--- a/widgets/text/e-text-event-processor-types.h
+++ b/widgets/text/e-text-event-processor-types.h
@@ -82,6 +82,9 @@ enum _ETextEventProcessorCommandAction {
E_TEP_GET_SELECTION,
E_TEP_SET_SELECT_BY_WORD,
E_TEP_ACTIVATE,
+
+ E_TEP_GRAB,
+ E_TEP_UNGRAB,
E_TEP_NOP
};
diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c
index 1aef2ded6c..bfff8e251a 100644
--- a/widgets/text/e-text.c
+++ b/widgets/text/e-text.c
@@ -1771,7 +1771,7 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event)
e_tep_event.button.position = _get_position_from_xy(text, button.x, button.y);
_get_tep(text);
return_val = e_text_event_processor_handle_event (text->tep,
- &e_tep_event);
+ &e_tep_event);
if (event->button.button == 1) {
if (event->type == GDK_BUTTON_PRESS)
text->button_down = TRUE;
@@ -1781,18 +1781,7 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event)
text->lastx = button.x;
text->lasty = button.y;
text->last_state = button.state;
- if (event->type == GDK_BUTTON_PRESS && text->timer) {
- g_timer_reset(text->timer);
- }
- if (event->type == GDK_BUTTON_PRESS) {
- gnome_canvas_item_grab (item,
- GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK,
- text->i_cursor,
- button.time);
- } else {
- gnome_canvas_item_ungrab (item, button.time);
- }
- } else if (text->editable && event->type == GDK_BUTTON_RELEASE) {
+ } else if (text->editable && event->type == GDK_BUTTON_RELEASE && event->button.button == 1) {
gnome_canvas_item_grab_focus (item);
return 1;
}
@@ -1972,6 +1961,9 @@ e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gp
case E_TEP_MOVE:
text->selection_start = _get_position(text, command);
text->selection_end = text->selection_start;
+ if (text->timer) {
+ g_timer_reset(text->timer);
+ }
break;
case E_TEP_SELECT:
text->selection_end = _get_position(text, command);
@@ -1979,6 +1971,8 @@ e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gp
sel_end = MAX(text->selection_start, text->selection_end);
if (sel_start != sel_end) {
e_text_supply_selection (text, command->time, GDK_SELECTION_PRIMARY, text->text + sel_start, sel_end - sel_start);
+ } else if (text->timer) {
+ g_timer_reset(text->timer);
}
break;
case E_TEP_DELETE:
@@ -1988,6 +1982,9 @@ e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gp
_delete_selection(text);
split_into_lines (text);
recalc_bounds (text);
+ if (text->timer) {
+ g_timer_reset(text->timer);
+ }
break;
case E_TEP_INSERT:
@@ -1997,6 +1994,9 @@ e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gp
_insert(text, command->string, command->value);
split_into_lines (text);
recalc_bounds (text);
+ if (text->timer) {
+ g_timer_reset(text->timer);
+ }
break;
case E_TEP_COPY:
sel_start = MIN(text->selection_start, text->selection_end);
@@ -2004,18 +2004,36 @@ e_text_command(ETextEventProcessor *tep, ETextEventProcessorCommand *command, gp
if (sel_start != sel_end) {
e_text_supply_selection (text, command->time, clipboard_atom, text->text + sel_start, sel_end - sel_start);
}
+ if (text->timer) {
+ g_timer_reset(text->timer);
+ }
break;
case E_TEP_PASTE:
e_text_get_selection (text, clipboard_atom, command->time);
+ if (text->timer) {
+ g_timer_reset(text->timer);
+ }
break;
case E_TEP_GET_SELECTION:
e_text_get_selection (text, GDK_SELECTION_PRIMARY, command->time);
break;
case E_TEP_ACTIVATE:
+ if (text->timer) {
+ g_timer_reset(text->timer);
+ }
break;
case E_TEP_SET_SELECT_BY_WORD:
text->select_by_word = command->value;
break;
+ case E_TEP_GRAB:
+ gnome_canvas_item_grab (GNOME_CANVAS_ITEM(text),
+ GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK,
+ text->i_cursor,
+ command->time);
+ break;
+ case E_TEP_UNGRAB:
+ gnome_canvas_item_ungrab (GNOME_CANVAS_ITEM(text), command->time);
+ break;
case E_TEP_NOP:
break;
}