Commit f4bd2d99 authored by Morten Welinder's avatar Morten Welinder

Much improved cancel-cell-editing behaviour.

parent 1ae8e0a9
1999-06-20 Morten Welinder <terra@diku.dk>
* src/workbook.c (wb_edit_key_pressed): New function to handle
Escape.
(workbook_setup_edit_area): Activate wb_edit_key_pressed.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet): Call
sheet_start_editing_at_cursor for F2.
* src/sheet.c (sheet_cancel_pending_input): Fix last change. Also
update entry box.
(sheet_start_editing_at_cursor): New args blankp and cursorp. All
callers changed.
* src/fn-math.c (gnumeric_mod): Another try.
(gnumeric_int): Fix for negative numbers.
......
1999-06-20 Morten Welinder <terra@diku.dk>
* src/workbook.c (wb_edit_key_pressed): New function to handle
Escape.
(workbook_setup_edit_area): Activate wb_edit_key_pressed.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet): Call
sheet_start_editing_at_cursor for F2.
* src/sheet.c (sheet_cancel_pending_input): Fix last change. Also
update entry box.
(sheet_start_editing_at_cursor): New args blankp and cursorp. All
callers changed.
* src/fn-math.c (gnumeric_mod): Another try.
(gnumeric_int): Fix for negative numbers.
......
1999-06-20 Morten Welinder <terra@diku.dk>
* src/workbook.c (wb_edit_key_pressed): New function to handle
Escape.
(workbook_setup_edit_area): Activate wb_edit_key_pressed.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet): Call
sheet_start_editing_at_cursor for F2.
* src/sheet.c (sheet_cancel_pending_input): Fix last change. Also
update entry box.
(sheet_start_editing_at_cursor): New args blankp and cursorp. All
callers changed.
* src/fn-math.c (gnumeric_mod): Another try.
(gnumeric_int): Fix for negative numbers.
......
1999-06-20 Morten Welinder <terra@diku.dk>
* src/workbook.c (wb_edit_key_pressed): New function to handle
Escape.
(workbook_setup_edit_area): Activate wb_edit_key_pressed.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet): Call
sheet_start_editing_at_cursor for F2.
* src/sheet.c (sheet_cancel_pending_input): Fix last change. Also
update entry box.
(sheet_start_editing_at_cursor): New args blankp and cursorp. All
callers changed.
* src/fn-math.c (gnumeric_mod): Another try.
(gnumeric_int): Fix for negative numbers.
......
......@@ -789,7 +789,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
case GDK_F2:
gtk_window_set_focus (GTK_WINDOW (wb->toplevel), wb->ea_input);
sheet->editing = TRUE;
sheet_start_editing_at_cursor (sheet, FALSE, FALSE);
/* fall down */
default:
......@@ -799,7 +799,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
if ((event->keyval >= 0x20 && event->keyval <= 0xff) ||
(event->keyval >= GDK_KP_Add && event->keyval <= GDK_KP_9))
sheet_start_editing_at_cursor (sheet);
sheet_start_editing_at_cursor (sheet, TRUE, TRUE);
}
gnumeric_sheet_stop_cell_selection (gsheet);
......
......@@ -789,7 +789,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
case GDK_F2:
gtk_window_set_focus (GTK_WINDOW (wb->toplevel), wb->ea_input);
sheet->editing = TRUE;
sheet_start_editing_at_cursor (sheet, FALSE, FALSE);
/* fall down */
default:
......@@ -799,7 +799,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
if ((event->keyval >= 0x20 && event->keyval <= 0xff) ||
(event->keyval >= GDK_KP_Add && event->keyval <= GDK_KP_9))
sheet_start_editing_at_cursor (sheet);
sheet_start_editing_at_cursor (sheet, TRUE, TRUE);
}
gnumeric_sheet_stop_cell_selection (gsheet);
......
......@@ -829,17 +829,18 @@ sheet_cancel_pending_input (Sheet *sheet)
if (!sheet->editing)
return;
if (sheet->editing_cell){
cell_set_text (sheet->editing_cell, sheet->editing_saved_text->str);
sheet_stop_editing (sheet);
if (sheet->editing_cell) {
const char *oldtext = sheet->editing_saved_text->str;
gtk_entry_set_text (GTK_ENTRY (sheet->workbook->ea_input), oldtext);
cell_set_text (sheet->editing_cell, oldtext);
}
sheet_stop_editing (sheet);
for (l = sheet->sheet_views; l; l = l->next){
GnumericSheet *gsheet = GNUMERIC_SHEET_VIEW (l->data);
gnumeric_sheet_destroy_editing_cursor (gsheet);
}
sheet->editing = FALSE;
}
void
......@@ -865,7 +866,7 @@ sheet_load_cell_val (Sheet *sheet)
}
void
sheet_start_editing_at_cursor (Sheet *sheet)
sheet_start_editing_at_cursor (Sheet *sheet, gboolean blankp, gboolean cursorp)
{
GList *l;
Cell *cell;
......@@ -873,13 +874,14 @@ sheet_start_editing_at_cursor (Sheet *sheet)
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
gtk_entry_set_text (GTK_ENTRY (sheet->workbook->ea_input), "");
for (l = sheet->sheet_views; l; l = l->next){
GnumericSheet *gsheet = GNUMERIC_SHEET_VIEW (l->data);
if (blankp)
gtk_entry_set_text (GTK_ENTRY (sheet->workbook->ea_input), "");
gnumeric_sheet_create_editing_cursor (gsheet);
}
if (cursorp)
for (l = sheet->sheet_views; l; l = l->next){
GnumericSheet *gsheet = GNUMERIC_SHEET_VIEW (l->data);
gnumeric_sheet_create_editing_cursor (gsheet);
}
sheet->editing = TRUE;
cell = sheet_cell_get (sheet, sheet->cursor_col, sheet->cursor_row);
......@@ -891,7 +893,8 @@ sheet_start_editing_at_cursor (Sheet *sheet)
g_free (text);
sheet->editing_cell = cell;
cell_set_text (cell, "");
if (blankp)
cell_set_text (cell, "");
}
}
......
......@@ -358,7 +358,7 @@ Sheet *sheet_lookup_by_name (Sheet *base, const char *name);
/*
* Sheet visual editing
*/
void sheet_start_editing_at_cursor (Sheet *sheet);
void sheet_start_editing_at_cursor (Sheet *sheet, gboolean blankp, gboolean cursorp);
void sheet_set_current_value (Sheet *sheet);
void sheet_accept_pending_input (Sheet *sheet);
void sheet_cancel_pending_input (Sheet *sheet);
......
......@@ -1122,6 +1122,20 @@ wb_input_finished (GtkEntry *entry, Workbook *wb)
workbook_focus_current_sheet (wb);
}
static int
wb_edit_key_pressed (GtkEntry *entry, GdkEventKey *event, Workbook *wb)
{
switch (event->keyval) {
case GDK_Escape:
sheet_cancel_pending_input (workbook_get_current_sheet (wb));
workbook_focus_current_sheet (wb);
return TRUE;
default:
return FALSE;
}
}
int
workbook_parse_and_jump (Workbook *wb, const char *text)
{
......@@ -1328,11 +1342,9 @@ workbook_setup_edit_area (Workbook *wb)
gtk_signal_connect (GTK_OBJECT (wb->ea_input), "activate",
GTK_SIGNAL_FUNC(wb_input_finished),
wb);
#if 0
gtk_signal_connect (GTK_OBJECT (wb->ea_input), "key_press_event",
GTK_SIGNAL_FUNC(wb_edit_key_pressed),
wb);
#endif
/* Do signal setup for the status input line */
gtk_signal_connect (GTK_OBJECT (wb->ea_status), "activate",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment