From 956c2cb14b2dd3d57936f0325d07abf6a408154b Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 11 May 2012 15:02:16 +0200 Subject: UI. Filtered objects count (patch by David Mathog). Translations. Inkscape.pot and French translation update. (bzr r11355) --- src/selection-describer.cpp | 27 ++++++++++++++++++++++++++- src/sp-item.cpp | 13 +++++++++++++ src/sp-item.h | 1 + 3 files changed, 40 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index 5d6f9288d..2fa7d078b 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -91,6 +91,18 @@ GSList *collect_terms (GSList *items) return r; } +// Returns the number of filtered items in the list +int count_filtered (GSList *items) +{ + int count=0; + SPItem *item=NULL; + for (GSList *i = items; i != NULL; i = i->next) { + item = SP_ITEM(i->data); + count += item->ifilt(); + } + return count; +} + namespace Inkscape { @@ -231,10 +243,23 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select } g_slist_free (terms); - _context.setF(Inkscape::NORMAL_MESSAGE, _("%s%s. %s."), objects_str, in_phrase, _when_selected); + // indicate all, some, or none filtered + const gchar *filt_str =NULL; + int n_filt = count_filtered ((GSList *)items); //all filtered + if(n_filt){ + filt_str = g_strdup_printf (ngettext("; %d filtered object ", + "; %d filtered objects ", n_filt), n_filt); + } + else { + filt_str = g_strdup_printf (""); + } + + _context.setF(Inkscape::NORMAL_MESSAGE, _("%s%s%s. %s."), objects_str, filt_str, in_phrase, _when_selected); if (objects_str) g_free ((gchar *) objects_str); + if (filt_str) + g_free ((gchar *) filt_str); } g_free(in_phrase); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index e0a9b97f2..d182c7d07 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -966,6 +966,19 @@ gchar *SPItem::description() return NULL; } +/** + * Returns 1 if the item is filtered, 0 otherwise. Used with groups/lists to determine how many, or if any, are filtered + * + */ +int SPItem::ifilt() +{ + int retval=0; + if (((SPItemClass *) G_OBJECT_GET_CLASS(this))->description) { + if ( style && style->filter.href && style->filter.href->getObject() ) { retval=1; } + } + return retval; +} + /** * Allocates unique integer keys. * \param numkeys Number of keys required. diff --git a/src/sp-item.h b/src/sp-item.h index 5cfd49446..62bde616a 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -192,6 +192,7 @@ public: unsigned pos_in_parent(); gchar *description(); + int ifilt(); void invoke_print(SPPrintContext *ctx); static unsigned int display_key_new(unsigned int numkeys); Inkscape::DrawingItem *invoke_show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); -- cgit v1.2.3