diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2018-01-19 12:10:05 +0000 |
|---|---|---|
| committer | Tavmjong Bah <tavmjong@free.fr> | 2018-01-19 12:10:05 +0000 |
| commit | 78b5478136fa43a7c225ef5aa433ec9c0926667d (patch) | |
| tree | 1ccf14209b9980ca8b78482bdfd3664a61cd71f6 /src | |
| parent | Don't allow dragging path at cap or line join (diff) | |
| download | inkscape-78b5478136fa43a7c225ef5aa433ec9c0926667d.tar.gz inkscape-78b5478136fa43a7c225ef5aa433ec9c0926667d.zip | |
Move general ellipsize text function out of gradient files.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ui/CMakeLists.txt | 10 | ||||
| -rw-r--r-- | src/ui/util.cpp | 37 | ||||
| -rw-r--r-- | src/ui/util.h | 30 | ||||
| -rw-r--r-- | src/ui/widget/color-icc-selector.cpp | 4 | ||||
| -rw-r--r-- | src/ui/widget/layer-selector.cpp | 4 | ||||
| -rw-r--r-- | src/widgets/gradient-toolbar.cpp | 1 | ||||
| -rw-r--r-- | src/widgets/mesh-toolbar.cpp | 1 | ||||
| -rw-r--r-- | src/widgets/stroke-marker-selector.cpp | 5 |
8 files changed, 81 insertions, 11 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index cb120806a..1de3d1354 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -5,13 +5,14 @@ set(ui_SRC dialog-events.cpp draw-anchor.cpp interface.cpp - monitor.cpp + monitor.cpp previewholder.cpp selected-color.cpp shape-editor.cpp shape-editor-knotholders.cpp tool-factory.cpp tools-switch.cpp + util.cpp uxmanager.cpp cache/svg_preview_cache.cpp @@ -59,7 +60,7 @@ set(ui_SRC dialog/calligraphic-profile-rename.cpp dialog/clonetiler.cpp dialog/color-item.cpp - dialog/cssdialog.cpp + dialog/cssdialog.cpp dialog/debug.cpp dialog/desktop-tracker.cpp dialog/dialog-manager.cpp @@ -187,13 +188,14 @@ set(ui_SRC event-debug.h icon-names.h interface.h - monitor.h + monitor.h previewable.h previewholder.h selected-color.h shape-editor.h tool-factory.h tools-switch.h + util.h uxmanager.h cache/svg_preview_cache.h @@ -205,7 +207,7 @@ set(ui_SRC dialog/calligraphic-profile-rename.h dialog/clonetiler.h dialog/color-item.h - dialog/cssdialog.h + dialog/cssdialog.h dialog/debug.h dialog/desktop-tracker.h dialog/dialog-manager.h diff --git a/src/ui/util.cpp b/src/ui/util.cpp new file mode 100644 index 000000000..f37a9ea78 --- /dev/null +++ b/src/ui/util.cpp @@ -0,0 +1,37 @@ +/* + * Utility functions for UI + * + * Authors: + * Tavmjong Bah + * John Smith + * + * Copyright (C) 2004, 2013, 2018 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "util.h" + +/* + * Ellipse text if longer than maxlen, "50% start text + ... + ~50% end text" + * Text should be > length 8 or just return the original text + */ +Glib::ustring ink_ellipsize_text(Glib::ustring const &src, size_t maxlen) +{ + if (src.length() > maxlen && maxlen > 8) { + size_t p1 = (size_t) maxlen / 2; + size_t p2 = (size_t) src.length() - (maxlen - p1 - 1); + return src.substr(0, p1) + "…" + src.substr(p2); + } + return src; +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/util.h b/src/ui/util.h new file mode 100644 index 000000000..11999e310 --- /dev/null +++ b/src/ui/util.h @@ -0,0 +1,30 @@ +/* + * Utility functions for UI + * + * Authors: + * Tavmjong Bah + * John Smith + * + * Copyright (C) 2013, 2018 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef UI_UTIL_SEEN +#define UI_UTIL_SEEN + +#include <glibmm/ustring.h> + +Glib::ustring ink_ellipsize_text (Glib::ustring const &src, size_t maxlen); + +#endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/widget/color-icc-selector.cpp b/src/ui/widget/color-icc-selector.cpp index 5fba36867..aaf5ba5c2 100644 --- a/src/ui/widget/color-icc-selector.cpp +++ b/src/ui/widget/color-icc-selector.cpp @@ -8,6 +8,7 @@ #include <set> #include "ui/dialog-events.h" +#include "ui/util.h" #include "ui/widget/color-icc-selector.h" #include "ui/widget/color-scales.h" #include "ui/widget/color-slider.h" @@ -16,7 +17,6 @@ #include "document.h" #include "inkscape.h" #include "profile-manager.h" -#include "widgets/gradient-vector.h" #define noDEBUG_LCMS @@ -685,7 +685,7 @@ void ColorICCSelectorImpl::_profilesChanged(std::string const &name) Inkscape::ColorProfile *prof = it; gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, 0, gr_ellipsize_text(prof->name, 25).c_str(), 1, prof->name, -1); + gtk_list_store_set(store, &iter, 0, ink_ellipsize_text(prof->name, 25).c_str(), 1, prof->name, -1); if (name == prof->name) { gtk_combo_box_set_active(combo, index); diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index 7a0312192..e0a52a868 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -28,11 +28,11 @@ #include "document-undo.h" #include "layer-manager.h" #include "ui/icon-names.h" +#include "ui/util.h" #include "util/filter-list.h" #include "util/reverse-list.h" #include "verbs.h" #include "xml/node-event-vector.h" -#include "widgets/gradient-vector.h" namespace Inkscape { namespace Widgets { @@ -573,7 +573,7 @@ void LayerSelector::_prepareLabelRenderer( label = _("(root)"); } - gchar *text = g_markup_printf_escaped(format, gr_ellipsize_text (label, 50).c_str()); + gchar *text = g_markup_printf_escaped(format, ink_ellipsize_text (label, 50).c_str()); _label_renderer.property_markup() = text; g_free(text); g_free(format); diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 976423aaf..6f2f6a06c 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -39,6 +39,7 @@ #include "style.h" #include "toolbox.h" #include "ui/icon-names.h" +#include "ui/util.h" #include "ui/tools/gradient-tool.h" #include "verbs.h" #include "widgets/gradient-image.h" diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index 61b41f58f..93be77556 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -27,7 +27,6 @@ #include "verbs.h" #include "widgets/spinbutton-events.h" -#include "widgets/gradient-vector.h" #include "widgets/gradient-image.h" #include "style.h" diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index 9ddcf993d..51377fd41 100644 --- a/src/widgets/stroke-marker-selector.cpp +++ b/src/widgets/stroke-marker-selector.cpp @@ -32,10 +32,11 @@ #include "sp-root.h" #include "ui/cache/svg_preview_cache.h" #include "helper/stock-items.h" -#include "gradient-vector.h" #include <gtkmm/icontheme.h> #include "ui/widget/spinbutton.h" +#include "ui/util.h" + #include "stroke-style.h" static Inkscape::UI::Cache::SvgPreview svg_preview_cache; @@ -389,7 +390,7 @@ void MarkerComboBox::add_markers (std::vector<SPMarker *> const& marker_list, SP else row = *(marker_store->append()); - row[marker_columns.label] = gr_ellipsize_text(markid, 20); + row[marker_columns.label] = ink_ellipsize_text(markid, 20); // Non "stock" markers can also have "inkscape:stockid" (when using extension ColorMarkers), // So use !is_history instead to determine is it is "stock" (ie in the markers.svg file) row[marker_columns.stock] = !history; |
