[gnumeric] GUI: use consistent and limited precision for auto-expr.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] GUI: use consistent and limited precision for auto-expr.
- Date: Mon, 7 May 2018 15:45:15 +0000 (UTC)
commit aaffcb51b6631ede85bb180d9d56b0a02406d28a
Author: Morten Welinder <terra gnome org>
Date: Mon May 7 11:43:21 2018 -0400
GUI: use consistent and limited precision for auto-expr.
ChangeLog | 4 ++++
NEWS | 1 +
src/auto-format.c | 9 +++++++++
src/gnm-format.c | 8 ++++----
src/wbc-gtk.c | 6 ++++--
5 files changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6099d52..d40e6a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
diff --git a/NEWS b/NEWS
index 9cedbcc..20d2a7a 100644
--- a/NEWS
+++ b/NEWS
@@ -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
diff --git a/src/auto-format.c b/src/auto-format.c
index 87d5087..096e2b8 100644
--- a/src/auto-format.c
+++ b/src/auto-format.c
@@ -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)
{
diff --git a/src/gnm-format.c b/src/gnm-format.c
index 7e70cd9..21f68cf 100644
--- a/src/gnm-format.c
+++ b/src/gnm-format.c
@@ -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.
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index 9ec30a4..510d247 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -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: {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]