summaryrefslogtreecommitdiffstats
path: root/src/widgets/gradient-vector.cpp
diff options
context:
space:
mode:
authorJohn Smith <john.smith7545@yahoo.com>2012-05-15 08:11:19 +0000
committerJohn Smith <removethis.john.q.public@bigmail.com>2012-05-15 08:11:19 +0000
commit3460685415e0e80474cb5ef9cb4b37dbc3aae705 (patch)
treefba643ca9b3b03d12bcda1bd0cbe7444677d940a /src/widgets/gradient-vector.cpp
parentpdf import. set a default line width, see http://thread.gmane.org/gmane.comp.... (diff)
downloadinkscape-3460685415e0e80474cb5ef9cb4b37dbc3aae705.tar.gz
inkscape-3460685415e0e80474cb5ef9cb4b37dbc3aae705.zip
Fix for 950677 : Ellipse text if gradient name too long
(bzr r11365)
Diffstat (limited to 'src/widgets/gradient-vector.cpp')
-rw-r--r--src/widgets/gradient-vector.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp
index 60436c404..f37455afc 100644
--- a/src/widgets/gradient-vector.cpp
+++ b/src/widgets/gradient-vector.cpp
@@ -265,8 +265,22 @@ gchar *gr_prepare_label (SPObject *obj)
{
const gchar *id = obj->defaultLabel();
if (strlen(id) > 15 && (!strncmp (id, "#linearGradient", 15) || !strncmp (id, "#radialGradient", 15)))
- return g_strdup_printf ("#%s", id+15);
- return g_strdup_printf ("%s", id);
+ return gr_ellipse_text (g_strdup_printf ("#%s", id+15), 35);
+ return gr_ellipse_text (id, 35);
+}
+
+/*
+ * Ellipse text if longer than maxlen, "30% start text + ... + ~70% end text"
+ * Text should be > length 8 or just return the original text
+ */
+gchar *gr_ellipse_text (gchar const *src, guint maxlen)
+{
+ guint start = (guint) maxlen / 3;
+ if (strlen(src) > maxlen && maxlen > 8)
+ return g_strdup_printf ("%s...%s", g_strndup(src, start), src+strlen(src)-(maxlen-start-3));
+
+ return g_strdup (src);
+
}
static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs)