[gnumeric] Stf: truncate long items for display.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Stf: truncate long items for display.
- Date: Fri, 14 Nov 2014 14:29:11 +0000 (UTC)
commit ceeb7904c3af38c178dbc5a789b8c122c35e5b90
Author: Morten Welinder <terra gnome org>
Date: Fri Nov 14 09:28:23 2014 -0500
Stf: truncate long items for display.
Something in the Gtk+ stack is clearly unhappy with really long strings.
NEWS | 1 +
src/dialogs/ChangeLog | 4 ++++
src/dialogs/dialog-stf-preview.c | 15 ++++++++++++++-
src/dialogs/dialog-stf-preview.h | 3 ++-
4 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/NEWS b/NEWS
index 2a0e4cc..1b7c6a1 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ Morten:
* Plug leaks.
* Pay more attention to union access rules.
* Attempt a fix for clipboard crash. [Redhat #1160975]
+ * Truncate long strings for display in stf import.
Thomas Kluyver:
* Fix import of extended floats from wk4 files. [#739697]
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 66b2220..d16eb2b 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,7 @@
+2014-11-14 Morten Welinder <terra gnome org>
+
+ * dialog-stf-preview.c (render_get_value): Truncate long items.
+
2014-09-25 Morten Welinder <terra gnome org>
* Release 1.12.18
diff --git a/src/dialogs/dialog-stf-preview.c b/src/dialogs/dialog-stf-preview.c
index 41eea64..af823a5 100644
--- a/src/dialogs/dialog-stf-preview.c
+++ b/src/dialogs/dialog-stf-preview.c
@@ -65,6 +65,19 @@ render_get_value (gint row, gint column, gpointer _rd, GValue *value)
} while (tab);
text = copy;
}
+
+ /*
+ * Throwing really long strings at Gtk+ is known to cause
+ * trouble, so cut long strings and hope no-one notices.
+ */
+ if (g_utf8_strlen (text, -1) > STF_LINE_LENGTH_LIMIT) {
+ char *cut = g_strdup (text);
+ strcpy (g_utf8_offset_to_pointer (cut, STF_LINE_LENGTH_LIMIT - 3),
+ "...");
+ g_free (copy);
+ text = copy = cut;
+ }
+
g_value_set_string (value, text);
g_free (copy);
}
@@ -231,7 +244,7 @@ stf_preview_set_lines (RenderData_t *renderdata,
}
ll = gnumeric_lazy_list_new (render_get_value, renderdata,
- MIN (lines->len, LINE_DISPLAY_LIMIT),
+ MIN (lines->len, STF_LINE_DISPLAY_LIMIT),
0);
gnumeric_lazy_list_add_column (ll, colcount, G_TYPE_STRING);
gtk_tree_view_set_model (renderdata->tree_view, GTK_TREE_MODEL (ll));
diff --git a/src/dialogs/dialog-stf-preview.h b/src/dialogs/dialog-stf-preview.h
index 976b7b8..f31b90c 100644
--- a/src/dialogs/dialog-stf-preview.h
+++ b/src/dialogs/dialog-stf-preview.h
@@ -20,7 +20,8 @@
#include <stf.h>
#include <gtk/gtk.h>
-#define LINE_DISPLAY_LIMIT 500
+#define STF_LINE_LENGTH_LIMIT 1000
+#define STF_LINE_DISPLAY_LIMIT 500
#define COLUMN_CAPTION N_("Column %d")
typedef struct {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]