diff options
Diffstat (limited to 'src/widgets')
| -rw-r--r-- | src/widgets/gradient-toolbar.cpp | 3 | ||||
| -rw-r--r-- | src/widgets/gradient-vector.cpp | 18 | ||||
| -rw-r--r-- | src/widgets/gradient-vector.h | 2 |
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 |
