Commit aaffcb51 authored by Morten Welinder's avatar Morten Welinder

GUI: use consistent and limited precision for auto-expr.

parent c11c3156
......@@ -2,6 +2,10 @@
* src/wbc-gtk.c (wbc_gtk_init): Use a resource for the default ui
definition.
(wbcg_auto_expr_value_changed): Limit the width of numbers
formatted as General to something independent of function name.
This avoids the 10.10000...002 situation unless maximum precision
is requested.
2018-05-06 Morten Welinder <terra@gnome.org>
......
......@@ -5,6 +5,7 @@ Morten:
* Fix undo problem for cell comments. [#732653]
* Exit with non-zero with we fail to load file on command line.
* Fix undo crash. [#795861]
* Introspection fixes.
--------------------------------------------------------------------------
Gnumeric 1.12.40
......
......@@ -241,6 +241,15 @@ do_af_suggest_list (int argc, GnmExprConstPtr const *argv,
GNM_BEGIN_KILL_SWITCH_WARNING
/**
* gnm_auto_style_format_suggest:
* @texpr: A #GnmExprTop
* @epos: A #GnmEvalPos
*
* Suggest a format for @texpr.
*
* Returns: (transfer full) (nullable): Suggested format.
*/
GOFormat const *
gnm_auto_style_format_suggest (GnmExprTop const *texpr, GnmEvalPos const *epos)
{
......
......@@ -198,9 +198,9 @@ gnm_format_layout (PangoLayout *layout,
/**
* format_value_gstring:
* @str: append the result here.
* @format: #GOFormat.
* @format: (nullable): #GOFormat.
* @value: #GnmValue to convert
* @col_width: optional
* @col_width: maximum width in characters, -1 for unlimited
* @date_conv: #GODateConventions.
*
**/
......@@ -232,8 +232,8 @@ format_value_gstring (GString *str,
/**
* format_value_layout:
* @layout:
* @format: #GOFormat.
* @layout: A PangoLayout
* @format: (nullable): #GOFormat.
* @value: #GnmValue to convert
* @col_width: optional limit on width, -1 for unlimited
* @date_conv: #GODateConventions.
......
......@@ -1438,10 +1438,12 @@ wbcg_auto_expr_value_changed (WorkbookView *wbv,
PangoLayout *layout = gtk_widget_create_pango_layout (GTK_WIDGET (wbcg->toplevel), NULL);
gsize old_len = str->len;
GODateConventions const *date_conv = workbook_date_conv (wb_view_get_workbook (wbv));
int max_width = go_format_is_general (format) && VALUE_IS_NUMBER (v)
? 14
: strlen (AUTO_EXPR_SAMPLE) - g_utf8_strlen (str->str, -1);
GOFormatNumberError err =
format_value_layout (layout, format, v,
strlen (AUTO_EXPR_SAMPLE) - g_utf8_strlen (str->str, -1),
date_conv);
max_width, date_conv);
switch (err) {
case GO_FORMAT_NUMBER_OK:
case GO_FORMAT_NUMBER_DATE_ERROR: {
......
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