diff --git a/src/widgets/ChangeLog b/src/widgets/ChangeLog index 44b7193a37cc80b338952bd66e2a5796af67e327..45c7796f2f151a3fbbcadcc7c77538934bf7b893 100644 --- a/src/widgets/ChangeLog +++ b/src/widgets/ChangeLog @@ -1,3 +1,8 @@ +2002-02-21 Jody Goldberg + + * gnumeric-expr-entry.c (gnm_expr_entry_load_from_expr) : add new + convenience routine. + 2002-02-21 Morten Welinder * widget-font-selector.c (styles): Constify. diff --git a/src/widgets/gnumeric-expr-entry.c b/src/widgets/gnumeric-expr-entry.c index 1676421e52b59250221c5dded7175ff8f947820e..1dc5ed80136230c1114a0e3e6ee259ffa65be986 100644 --- a/src/widgets/gnumeric-expr-entry.c +++ b/src/widgets/gnumeric-expr-entry.c @@ -788,6 +788,33 @@ gnm_expr_entry_load_from_dep (GnumericExprEntry *gee, Dependent const *dep) gnm_expr_entry_load_from_text (gee, ""); } +/** + * gnm_expr_entry_load_from_expr + * @gee: a #GnumericExprEntry + * @expr: An expression + * @pp : The parse position + * + * Sets the text of the entry, and removes saved information about earlier + * range selections. + **/ +void +gnm_expr_entry_load_from_expr (GnumericExprEntry *gee, + ExprTree const *expr, ParsePos const *pp) +{ + g_return_if_fail (IS_GNUMERIC_EXPR_ENTRY (gee)); + /* We have nowhere to store the text while frozen. */ + g_return_if_fail (gee->freeze_count == 0); + + if (expr != NULL) { + char *text = expr_tree_as_string (expr, pp); + gee_rangesel_reset (gee); + gtk_entry_set_text (gee->entry, text); + gee->rangesel.text_end = strlen (text); + g_free (text); + } else + gnm_expr_entry_load_from_text (gee, ""); +} + /** * gnm_expr_entry_load_from_range * @gee: a #GnumericExprEntry diff --git a/src/widgets/gnumeric-expr-entry.h b/src/widgets/gnumeric-expr-entry.h index 17ea5425f032009bafc01cbfc653ad34b5e884f4..4827b76332324d6fd22102ab2487ac0bb602b766 100644 --- a/src/widgets/gnumeric-expr-entry.h +++ b/src/widgets/gnumeric-expr-entry.h @@ -50,9 +50,12 @@ GSList *gnm_expr_entry_parse_as_list (GnumericExprEntry *ee, Sheet *sheet); ExprTree *gnm_expr_entry_parse (GnumericExprEntry *e, ParsePos const *pp, ParseError *perr, gboolean start_sel); -void gnm_expr_entry_load_from_text (GnumericExprEntry *e, char const *str); -void gnm_expr_entry_load_from_dep (GnumericExprEntry *e, +void gnm_expr_entry_load_from_text (GnumericExprEntry *e, char const *str); +void gnm_expr_entry_load_from_dep (GnumericExprEntry *e, Dependent const *dep); +void gnm_expr_entry_load_from_expr (GnumericExprEntry *e, + ExprTree const *expr, + ParsePos const *pp); gboolean gnm_expr_entry_load_from_range (GnumericExprEntry *e, Sheet *sheet, Range const *r);