Commit ceeb7904 authored by Morten Welinder's avatar Morten Welinder

Stf: truncate long items for display.

Something in the Gtk+ stack is clearly unhappy with really long strings.
parent 6411822e
...@@ -10,6 +10,7 @@ Morten: ...@@ -10,6 +10,7 @@ Morten:
* Plug leaks. * Plug leaks.
* Pay more attention to union access rules. * Pay more attention to union access rules.
* Attempt a fix for clipboard crash. [Redhat #1160975] * Attempt a fix for clipboard crash. [Redhat #1160975]
* Truncate long strings for display in stf import.
Thomas Kluyver: Thomas Kluyver:
* Fix import of extended floats from wk4 files. [#739697] * Fix import of extended floats from wk4 files. [#739697]
......
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> 2014-09-25 Morten Welinder <terra@gnome.org>
* Release 1.12.18 * Release 1.12.18
......
...@@ -65,6 +65,19 @@ render_get_value (gint row, gint column, gpointer _rd, GValue *value) ...@@ -65,6 +65,19 @@ render_get_value (gint row, gint column, gpointer _rd, GValue *value)
} while (tab); } while (tab);
text = copy; 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_value_set_string (value, text);
g_free (copy); g_free (copy);
} }
...@@ -231,7 +244,7 @@ stf_preview_set_lines (RenderData_t *renderdata, ...@@ -231,7 +244,7 @@ stf_preview_set_lines (RenderData_t *renderdata,
} }
ll = gnumeric_lazy_list_new (render_get_value, renderdata, ll = gnumeric_lazy_list_new (render_get_value, renderdata,
MIN (lines->len, LINE_DISPLAY_LIMIT), MIN (lines->len, STF_LINE_DISPLAY_LIMIT),
0); 0);
gnumeric_lazy_list_add_column (ll, colcount, G_TYPE_STRING); gnumeric_lazy_list_add_column (ll, colcount, G_TYPE_STRING);
gtk_tree_view_set_model (renderdata->tree_view, GTK_TREE_MODEL (ll)); gtk_tree_view_set_model (renderdata->tree_view, GTK_TREE_MODEL (ll));
......
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
#include <stf.h> #include <stf.h>
#include <gtk/gtk.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") #define COLUMN_CAPTION N_("Column %d")
typedef struct { typedef struct {
......
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