summaryrefslogtreecommitdiffstats
path: root/src/selection-describer.cpp
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2014-03-27 01:33:44 +0000
committerMartin Owens <doctormo@gmail.com>2014-03-27 01:33:44 +0000
commit5a4fb2325f60d292b47330f540b26a3279341c90 (patch)
treed2aa7967be25450b83e625025366c618101ae49f /src/selection-describer.cpp
parentThe Polar Arrange Tab of the Arrange Dialog now hides the parametric (diff)
parentRemove Snap menu item and improve grid menu item text (diff)
downloadinkscape-5a4fb2325f60d292b47330f540b26a3279341c90.tar.gz
inkscape-5a4fb2325f60d292b47330f540b26a3279341c90.zip
Commit a merge to trunk, with probabal errors
(bzr r11073.1.36)
Diffstat (limited to 'src/selection-describer.cpp')
-rw-r--r--src/selection-describer.cpp166
1 files changed, 75 insertions, 91 deletions
diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp
index 5d6f9288d..88450dfdf 100644
--- a/src/selection-describer.cpp
+++ b/src/selection-describer.cpp
@@ -17,6 +17,7 @@
#include <glibmm/i18n.h>
#include "xml/quote.h"
+#include "layer-model.h"
#include "selection.h"
#include "selection-describer.h"
#include "desktop.h"
@@ -24,6 +25,7 @@
#include "sp-offset.h"
#include "sp-flowtext.h"
#include "sp-use.h"
+#include "sp-symbol.h"
#include "sp-rect.h"
#include "box3d.h"
#include "sp-ellipse.h"
@@ -36,59 +38,33 @@
#include "sp-polyline.h"
#include "sp-spiral.h"
-const gchar *
-type2term(GType type)
+// Returns a list of terms for the items to be used in the statusbar
+char* collect_terms (GSList *items)
{
- 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 _("Text"); }
- if (type == SP_TYPE_USE)
- // 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;
+ 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)->displayName();
+ if (term != NULL && g_slist_find (check, term) == NULL) {
+ check = g_slist_prepend (check, (void *) term);
+ ss << (first ? "" : ", ") << "<b>" << term << "</b>";
+ first = false;
+ }
+ }
+ return g_strdup(ss.str().c_str());
}
-GSList *collect_terms (GSList *items)
+// Returns the number of filtered items in the list
+static int count_filtered (GSList *items)
{
- GSList *r = NULL;
+ int count=0;
for (GSList *i = items; i != NULL; i = i->next) {
- const gchar *term = type2term (G_OBJECT_TYPE(i->data));
- if (term != NULL && g_slist_find (r, term) == NULL)
- r = g_slist_prepend (r, (void *) term);
+ SPItem *item = SP_ITEM(i->data);
+ count += item->isFiltered();
}
- return r;
+ return count;
}
@@ -128,13 +104,15 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select
_context.set(Inkscape::NORMAL_MESSAGE, _when_nothing);
} else {
SPItem *item = SP_ITEM(items->data);
- SPObject *layer = selection->desktop()->layerForObject(item);
- SPObject *root = selection->desktop()->currentRoot();
+ SPObject *layer = selection->layers()->layerForObject(item);
+ SPObject *root = selection->layers()->currentRoot();
// Layer name
gchar *layer_name;
if (layer == root) {
layer_name = g_strdup(_("root"));
+ } else if(!layer) {
+ layer_name = g_strdup(_("none"));
} else {
char const *layer_label;
bool is_label = false;
@@ -156,9 +134,12 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select
// Parent name
SPObject *parent = item->parent;
gchar const *parent_label = parent->getId();
- char *quoted_parent_label = xml_quote_strdup(parent_label);
- gchar *parent_name = g_strdup_printf(_("<i>%s</i>"), quoted_parent_label);
- g_free(quoted_parent_label);
+ gchar *parent_name = NULL;
+ if (parent_label) {
+ char *quoted_parent_label = xml_quote_strdup(parent_label);
+ parent_name = g_strdup_printf(_("<i>%s</i>"), quoted_parent_label);
+ g_free(quoted_parent_label);
+ }
gchar *in_phrase;
guint num_layers = selection->numberOfLayers();
@@ -167,20 +148,33 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select
if (num_parents == 1) {
if (layer == parent)
in_phrase = g_strdup_printf(_(" in %s"), layer_name);
- else
+ else if (!layer)
+ in_phrase = g_strdup_printf("%s", _(" hidden in definitions"));
+ else if (parent_name)
in_phrase = g_strdup_printf(_(" in group %s (%s)"), parent_name, layer_name);
+ else
+ in_phrase = g_strdup_printf(_(" in unnamed group (%s)"), layer_name);
} else {
- in_phrase = g_strdup_printf(ngettext(" in <b>%i</b> parents (%s)", " in <b>%i</b> parents (%s)", num_parents), num_parents, layer_name);
+ in_phrase = g_strdup_printf(ngettext(" in <b>%i</b> parent (%s)", " in <b>%i</b> parents (%s)", num_parents), num_parents, layer_name);
}
} else {
- in_phrase = g_strdup_printf(ngettext(" in <b>%i</b> layers", " in <b>%i</b> layers", num_layers), num_layers);
+ in_phrase = g_strdup_printf(ngettext(" in <b>%i</b> layer", " in <b>%i</b> layers", num_layers), num_layers);
}
g_free (layer_name);
g_free (parent_name);
if (!items->next) { // one item
- char *item_desc = item->description();
- if (SP_IS_USE(item) || (SP_IS_OFFSET(item) && SP_OFFSET (item)->sourceHref)) {
+ char *item_desc = item->detailedDescription();
+
+ if (SP_IS_USE(item) && SP_IS_SYMBOL(item->firstChild())) {
+ _context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.",
+ item_desc, in_phrase,
+ _("Convert symbol to group to edit"), _when_selected);
+ } else if (SP_IS_SYMBOL(item)) {
+ _context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s.",
+ item_desc, in_phrase,
+ _("Remove from symbols tray to edit symbol"));
+ } else if (SP_IS_USE(item) || (SP_IS_OFFSET(item) && SP_OFFSET(item)->sourceHref)) {
_context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.",
item_desc, in_phrase,
_("Use <b>Shift+D</b> to look up original"), _when_selected);
@@ -198,43 +192,33 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select
}
g_free(item_desc);
} else { // multiple items
- int object_count = g_slist_length((GSList *)items);
-
- const 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);
+ int objcount = g_slist_length((GSList *)items);
+ char *terms = collect_terms ((GSList *)items);
+
+ gchar *objects_str = g_strdup_printf(
+ "<b>%i</b> objects selected of types %s", objcount, terms);
+
+ g_free(terms);
+
+ // indicate all, some, or none filtered
+ gchar *filt_str = NULL;
+ int n_filt = count_filtered((GSList *)items); //all filtered
+ if (n_filt) {
+ filt_str = g_strdup_printf(ngettext("; <i>%d filtered object</i> ",
+ "; <i>%d filtered objects</i> ", n_filt), n_filt);
} 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);
+ filt_str = g_strdup("");
}
- g_slist_free (terms);
- _context.setF(Inkscape::NORMAL_MESSAGE, _("%s%s. %s."), objects_str, in_phrase, _when_selected);
-
- if (objects_str)
- g_free ((gchar *) objects_str);
+ _context.setF(Inkscape::NORMAL_MESSAGE, "%s%s%s. %s.", objects_str, filt_str, in_phrase, _when_selected);
+ if (objects_str) {
+ g_free(objects_str);
+ objects_str = 0;
+ }
+ if (filt_str) {
+ g_free(filt_str);
+ filt_str = 0;
+ }
}
g_free(in_phrase);