summaryrefslogtreecommitdiffstats
path: root/src/selection-describer.cpp
diff options
context:
space:
mode:
authorMatthew Petroff <matthew@mpetroff.net>2013-09-20 17:05:24 +0000
committerMatthew Petroff <matthew@mpetroff.net>2013-09-20 17:05:24 +0000
commit48b4ee48e518d65c3c5e49369a747c2aa4b0081b (patch)
tree7159f8bc67d3f96ae43c42c32cacec6f7813f6fa /src/selection-describer.cpp
parentFix bug in rectangle toolbar. (diff)
parentFix grids after C++ification. Patch from Markus Engel (diff)
downloadinkscape-48b4ee48e518d65c3c5e49369a747c2aa4b0081b.tar.gz
inkscape-48b4ee48e518d65c3c5e49369a747c2aa4b0081b.zip
Merge from trunk.
(bzr r12475.1.29)
Diffstat (limited to 'src/selection-describer.cpp')
-rw-r--r--src/selection-describer.cpp106
1 files changed, 20 insertions, 86 deletions
diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp
index b5704bb76..fc6cb7f91 100644
--- a/src/selection-describer.cpp
+++ b/src/selection-describer.cpp
@@ -38,62 +38,22 @@
#include "sp-polyline.h"
#include "sp-spiral.h"
-static const gchar *
-type2term(SPItem *item)
+// Returns a list of terms for the items to be used in the statusbar
+const char* collect_terms (GSList *items)
{
- GType type = G_OBJECT_TYPE( item );
- if (type == SP_TYPE_ANCHOR)
- //TRANSLATORS: "Link" means internet link (anchor)
- { return C_("Web", "Link"); }
- if (type == SP_TYPE_CIRCLE)
- { return _("Circle"); }
- if (type == SP_TYPE_ELLIPSE)
- { return _("Ellipse"); }
- if (type == SP_TYPE_FLOWTEXT)
- { return _("Flowed text"); }
- if (type == SP_TYPE_GROUP)
- { return _("Group"); }
- if (type == SP_TYPE_IMAGE)
- { return _("Image"); }
- if (type == SP_TYPE_LINE)
- { return _("Line"); }
- if (type == SP_TYPE_PATH)
- { return _("Path"); }
- if (type == SP_TYPE_POLYGON)
- { return _("Polygon"); }
- if (type == SP_TYPE_POLYLINE)
- { return _("Polyline"); }
- if (type == SP_TYPE_RECT)
- { return _("Rectangle"); }
- if (type == SP_TYPE_BOX3D)
- { return _("3D Box"); }
- if (type == SP_TYPE_TEXT)
- { return C_("Object", "Text"); }
- if (type == SP_TYPE_USE)
- if (SP_IS_SYMBOL(item->firstChild()))
- { return C_("Object", "Symbol"); }
- // TRANSLATORS: "Clone" is a noun, type of object
- { return C_("Object", "Clone"); }
- if (type == SP_TYPE_ARC)
- { return _("Ellipse"); }
- if (type == SP_TYPE_OFFSET)
- { return _("Offset path"); }
- if (type == SP_TYPE_SPIRAL)
- { return _("Spiral"); }
- if (type == SP_TYPE_STAR)
- { return _("Star"); }
- return NULL;
-}
-
-static GSList *collect_terms (GSList *items)
-{
- GSList *r = NULL;
- for (GSList *i = items; i != NULL; i = i->next) {
- const gchar *term = type2term ( SP_ITEM(i->data) );
- if (term != NULL && g_slist_find (r, term) == NULL)
- r = g_slist_prepend (r, (void *) term);
+ GSList *check = NULL;
+ std::stringstream ss;
+ bool first = true;
+
+ for (GSList *i = (GSList *)items; i != NULL; i = i->next) {
+ const char *term = SP_ITEM(i->data)->display_name();
+ if (term != NULL && g_slist_find (check, term) == NULL) {
+ check = g_slist_prepend (check, (void *) term);
+ ss << (first ? "" : ", ") << "<b>" << term << "</b>";
+ first = false;
+ }
}
- return r;
+ return ss.str().c_str();
}
// Returns the number of filtered items in the list
@@ -199,7 +159,8 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select
g_free (parent_name);
if (!items->next) { // one item
- char *item_desc = item->description();
+ char *item_desc = item->getDetailedDescription();
+
if (SP_IS_USE(item) && SP_IS_SYMBOL(item->firstChild())) {
_context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.",
item_desc, in_phrase,
@@ -227,38 +188,11 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select
g_free(item_desc);
} else { // multiple items
int object_count = g_slist_length((GSList *)items);
+ const char *terms = collect_terms ((GSList *)items);
- gchar *objects_str = NULL;
- GSList *terms = collect_terms ((GSList *)items);
- int n_terms = g_slist_length(terms);
- if (n_terms == 0) {
- objects_str = g_strdup_printf (
- // this is only used with 2 or more objects
- ngettext("<b>%i</b> object selected", "<b>%i</b> objects selected", object_count),
- object_count);
- } else if (n_terms == 1) {
- objects_str = g_strdup_printf (
- // this is only used with 2 or more objects
- ngettext("<b>%i</b> object of type <b>%s</b>", "<b>%i</b> objects of type <b>%s</b>", object_count),
- object_count, (gchar *) terms->data);
- } else if (n_terms == 2) {
- objects_str = g_strdup_printf (
- // this is only used with 2 or more objects
- ngettext("<b>%i</b> object of types <b>%s</b>, <b>%s</b>", "<b>%i</b> objects of types <b>%s</b>, <b>%s</b>", object_count),
- object_count, (gchar *) terms->data, (gchar *) terms->next->data);
- } else if (n_terms == 3) {
- objects_str = g_strdup_printf (
- // this is only used with 2 or more objects
- ngettext("<b>%i</b> object of types <b>%s</b>, <b>%s</b>, <b>%s</b>", "<b>%i</b> objects of types <b>%s</b>, <b>%s</b>, <b>%s</b>", object_count),
- object_count, (gchar *) terms->data, (gchar *) terms->next->data, (gchar *) terms->next->next->data);
- } else {
- objects_str = g_strdup_printf (
- // this is only used with 2 or more objects
- ngettext("<b>%i</b> object of <b>%i</b> types", "<b>%i</b> objects of <b>%i</b> types", object_count),
- object_count, n_terms);
- }
- g_slist_free (terms);
-
+ gchar *objects_str =
+ g_strdup_printf( "<b>%i</b> objects selected of types %s",
+ object_count, terms );
// indicate all, some, or none filtered
gchar *filt_str = NULL;