[gnumeric] GUI: Make backspace work as delete on the pane.



commit bbf9d96225b893626c1b73ec3042abac728beab3
Author: Morten Welinder <terra gnome org>
Date:   Thu Jun 24 10:46:32 2010 -0400

    GUI: Make backspace work as delete on the pane.

 ChangeLog      |    4 +++
 NEWS           |    1 +
 src/gnm-pane.c |   71 +++++++++++++++++++++++++++++--------------------------
 3 files changed, 42 insertions(+), 34 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d72101e..15c09f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2010-06-24  Morten Welinder  <terra gnome org>
 
+	* src/gnm-pane.c (gnm_pane_key_mode_sheet): Untangle old
+	fall-through mess and make BackSpace work as delete when we are
+	not editing a cell.
+
 	* src/func.c (gnm_func_convert_markup_to_pango): Remove reference
 	to g_string_overwrite which wouldn't work right.
 
diff --git a/NEWS b/NEWS
index 0da992d..896b9f2 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ Jean:
 Morten:
 	* Improve function syntax tooltips.
 	* Fix excessive memory use problem with xlsx.  [#622365]
+	* Make BackSpace work as Delete on pane.  [#622599]
 
 --------------------------------------------------------------------------
 Gnumeric 1.10.6
diff --git a/src/gnm-pane.c b/src/gnm-pane.c
index 841a5d8..699fa90 100644
--- a/src/gnm-pane.c
+++ b/src/gnm-pane.c
@@ -338,6 +338,17 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
 			cmd_paste_to_selection (WORKBOOK_CONTROL (wbcg), sv, PASTE_DEFAULT);
 		break;
 
+	case GDK_BackSpace:
+		if (wbcg_is_editing (wbcg))
+			goto forward;
+		else if (!wbcg_is_editing (wbcg) && (event->state & GDK_CONTROL_MASK) != 0) {
+			/* Re-center the view on the active cell */
+			scg_make_cell_visible (scg, sv->edit_pos.col,
+					       sv->edit_pos.row, FALSE, TRUE);
+			break;
+		}
+		/* Fall through */
+
 	case GDK_KP_Delete:
 	case GDK_Delete:
 		if (wbcg_is_editing (wbcg)) {
@@ -436,47 +447,39 @@ gnm_pane_key_mode_sheet (GnmPane *pane, GdkEventKey *event,
 		return TRUE;
 
 	case GDK_F2:
-	if (gnm_pane_guru_key (wbcg, event))
-		break;
+		if (gnm_pane_guru_key (wbcg, event))
+			break;
 
-	if (wbcg_is_editing (wbcg)) {
-		GtkWidget *entry = (GtkWidget *) wbcg_get_entry (wbcg);
-		GtkWindow *top   = wbcg_toplevel (wbcg);
-		if (entry != gtk_window_get_focus (top)) {
-			gtk_window_set_focus (top, entry);
-			return TRUE;
+		if (wbcg_is_editing (wbcg)) {
+			GtkWidget *entry = (GtkWidget *) wbcg_get_entry (wbcg);
+			GtkWindow *top   = wbcg_toplevel (wbcg);
+			if (entry != gtk_window_get_focus (top)) {
+				gtk_window_set_focus (top, entry);
+				return TRUE;
+			}
 		}
-	}
-	if (!wbcg_edit_start (wbcg, FALSE, FALSE))
-		return FALSE; /* attempt to edit failed */
-	/* fall through */
-
-	case GDK_BackSpace:
-	/* Re-center the view on the active cell */
-	if (!wbcg_is_editing (wbcg) && (event->state & GDK_CONTROL_MASK) != 0) {
-		scg_make_cell_visible (scg, sv->edit_pos.col,
-				       sv->edit_pos.row, FALSE, TRUE);
-		break;
-	}
-	/* fall through */
+		if (!wbcg_edit_start (wbcg, FALSE, FALSE))
+			return FALSE; /* attempt to edit failed */
+		/* fall through */
 
 	default:
-	if (!wbcg_is_editing (wbcg)) {
-		if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0)
-			return FALSE;
+		if (!wbcg_is_editing (wbcg)) {
+			if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0)
+				return FALSE;
 
-		/* If the character is not printable do not start editing */
-		if (event->length == 0)
-			return FALSE;
+			/* If the character is not printable do not start editing */
+			if (event->length == 0)
+				return FALSE;
 
-		if (!wbcg_edit_start (wbcg, TRUE, TRUE))
-			return FALSE; /* attempt to edit failed */
-	}
-	scg_rangesel_stop (scg, FALSE);
+			if (!wbcg_edit_start (wbcg, TRUE, TRUE))
+				return FALSE; /* attempt to edit failed */
+		}
+		scg_rangesel_stop (scg, FALSE);
 
-	/* Forward the keystroke to the input line */
-	return gtk_widget_event (
-		wbcg_get_entry_underlying (wbcg), (GdkEvent *) event);
+	forward:
+		/* Forward the keystroke to the input line */
+		return gtk_widget_event (wbcg_get_entry_underlying (wbcg),
+					 (GdkEvent *) event);
 	}
 
 	if (!delayed_movement) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]