summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/widgets/gradient-toolbar.cpp3
-rw-r--r--src/widgets/gradient-vector.cpp18
-rw-r--r--src/widgets/gradient-vector.h2
3 files changed, 19 insertions, 4 deletions
diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp
index f60705b6c..44b0c6c1c 100644
--- a/src/widgets/gradient-toolbar.cpp
+++ b/src/widgets/gradient-toolbar.cpp
@@ -835,9 +835,10 @@ static gboolean update_stop_list( GtkWidget *stop_combo, SPGradient *gradient, S
Inkscape::XML::Node *repr = reinterpret_cast<SPItem *>(sl->data)->getRepr();
Inkscape::UI::Widget::ColorPreview *cpv = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(sp_stop_get_rgba32(stop)));
GdkPixbuf *pb = cpv->toPixbuf(32, 16);
+ const gchar *label = gr_ellipse_text(repr->attribute("id"), 25);
gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter, 0, repr->attribute("id"), 1, pb, 2, stop, -1);
+ gtk_list_store_set(store, &iter, 0, label, 1, pb, 2, stop, -1);
sensitive = FALSE;
}
}
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)
diff --git a/src/widgets/gradient-vector.h b/src/widgets/gradient-vector.h
index 9858ce784..ee69a9318 100644
--- a/src/widgets/gradient-vector.h
+++ b/src/widgets/gradient-vector.h
@@ -78,7 +78,7 @@ GtkWidget *sp_gradient_vector_editor_new (SPGradient *gradient, SPStop *stop = N
guint32 sp_average_color(guint32 c1, guint32 c2, gdouble p = 0.5);
gchar *gr_prepare_label (SPObject *obj);
-
+gchar *gr_ellipse_text (gchar const *src, guint maxlen);
#endif // SEEN_GRADIENT_VECTOR_H