gnumeric r16510 - in trunk: . src/widgets
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r16510 - in trunk: . src/widgets
- Date: Sat, 12 Apr 2008 17:19:40 +0100 (BST)
Author: mortenw
Date: Sat Apr 12 17:19:39 2008
New Revision: 16510
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16510&view=rev
Log:
2008-04-12 Morten Welinder <terra gnome org>
* gnumeric-expr-entry.c (cb_gee_key_press_event): Handle F9.
Fixes #56169.
Modified:
trunk/NEWS
trunk/src/widgets/ChangeLog
trunk/src/widgets/gnumeric-expr-entry.c
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Sat Apr 12 17:19:39 2008
@@ -70,6 +70,7 @@
* Fix date pasting problems to/from 1904 workbooks. [#490419]
* Fix problems editing times. [#527392]
* Implement IFERROR. [#445591]
+ * Implement F9 for evaluating a selected subexpression.
Nick Lamb:
* Honour detachable-toolbar preference. [#321867]
Modified: trunk/src/widgets/gnumeric-expr-entry.c
==============================================================================
--- trunk/src/widgets/gnumeric-expr-entry.c (original)
+++ trunk/src/widgets/gnumeric-expr-entry.c Sat Apr 12 17:19:39 2008
@@ -526,6 +526,47 @@
return TRUE;
}
+ case GDK_F9: {
+ /* Replace selection by its evaluated result. */
+ GtkEditable *editable = GTK_EDITABLE (entry);
+ gint start, end;
+ char *str;
+ GnmExprTop const *texpr;
+ Sheet *sheet = gee->pp.sheet;
+
+ gtk_editable_get_selection_bounds (editable, &start, &end);
+ if (end <= start)
+ return FALSE;
+ str = gtk_editable_get_chars (editable, start, end);
+
+ texpr = gnm_expr_parse_str_simple (str, &gee->pp);
+ if (texpr) {
+ GnmValue *v;
+ GnmEvalPos ep;
+ char *cst;
+ GnmExpr const *expr;
+
+ eval_pos_init_pos (&ep, sheet, &gee->pp.eval);
+ v = gnm_expr_top_eval (texpr, &ep, GNM_EXPR_EVAL_SCALAR_NON_EMPTY);
+ gnm_expr_top_unref (texpr);
+
+ /* Turn the value into an expression so we get the right syntax. */
+ expr = gnm_expr_new_constant (v);
+ cst = gnm_expr_as_string (expr, &gee->pp,
+ sheet_get_conventions (sheet));
+ gnm_expr_free (expr);
+
+ gtk_editable_delete_text (editable, start, end);
+ gtk_editable_insert_text (editable, cst, -1, &start);
+ gtk_editable_set_position (editable, start);
+
+ g_free (cst);
+ }
+
+ g_free (str);
+ return TRUE;
+ }
+
default:
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]