From eb3598e7e27619c759ef33bb9ec4ffb8898523de Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Fri, 20 Sep 2013 00:45:16 -0400 Subject: Refactor status-bar text for multiple items, was very broken Fixed bugs: - https://launchpad.net/bugs/1199192 (bzr r12550) --- src/box3d.cpp | 7 +-- src/box3d.h | 2 +- src/selection-describer.cpp | 108 ++++++++------------------------------------ src/sp-anchor.cpp | 8 +++- src/sp-anchor.h | 1 + src/sp-ellipse.cpp | 16 +++---- src/sp-ellipse.h | 6 +-- src/sp-flowregion.cpp | 15 ++---- src/sp-flowregion.h | 4 +- src/sp-flowtext.cpp | 15 +++--- src/sp-flowtext.h | 1 + src/sp-image.cpp | 8 +++- src/sp-image.h | 1 + src/sp-item-group.cpp | 8 ++-- src/sp-item-group.h | 1 + src/sp-item.cpp | 10 ++-- src/sp-item.h | 1 + src/sp-line.cpp | 4 +- src/sp-line.h | 2 +- src/sp-offset.cpp | 16 ++++--- src/sp-offset.h | 1 + src/sp-path.cpp | 16 ++++--- src/sp-path.h | 1 + src/sp-rect.cpp | 4 +- src/sp-rect.h | 2 +- src/sp-spiral.cpp | 10 ++-- src/sp-spiral.h | 1 + src/sp-star.cpp | 17 ++++--- src/sp-star.h | 1 + src/sp-switch.cpp | 8 ++-- src/sp-switch.h | 1 + src/sp-text.cpp | 7 ++- src/sp-text.h | 1 + src/sp-tref.cpp | 34 +++++++------- src/sp-tref.h | 1 + src/sp-tspan.cpp | 4 +- src/sp-tspan.h | 2 +- src/sp-use.cpp | 15 ++++-- src/sp-use.h | 1 + 39 files changed, 166 insertions(+), 195 deletions(-) (limited to 'src') diff --git a/src/box3d.cpp b/src/box3d.cpp index 0f528a592..193051ee5 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -255,11 +255,8 @@ Inkscape::XML::Node* SPBox3D::write(Inkscape::XML::Document *xml_doc, Inkscape:: return repr; } -gchar* SPBox3D::description() { - SPBox3D* item = this; - - g_return_val_if_fail(SP_IS_BOX3D(item), NULL); - return g_strdup(_("3D Box")); +const char* SPBox3D::display_name() { + return _("3D Box"); } void box3d_position_set(SPBox3D *box) diff --git a/src/box3d.h b/src/box3d.h index 18d99d60a..be5f1926c 100644 --- a/src/box3d.h +++ b/src/box3d.h @@ -58,7 +58,7 @@ public: virtual void update(SPCtx *ctx, guint flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual gchar *description(); + virtual const char* display_name(); virtual Geom::Affine set_transform(Geom::Affine const &transform); virtual void convert_to_guides(); }; diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index 4c2229667..fc6cb7f91 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -38,64 +38,22 @@ #include "sp-polyline.h" #include "sp-spiral.h" -// CPPIFY: this is ugly. -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; - return "Selektion-Describer ---"; -} - -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 ? "" : ", ") << "" << term << ""; + first = false; + } } - return r; + return ss.str().c_str(); } // Returns the number of filtered items in the list @@ -201,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, @@ -229,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("%i object selected", "%i 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("%i object of type %s", "%i objects of type %s", 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("%i object of types %s, %s", "%i objects of types %s, %s", 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("%i object of types %s, %s, %s", "%i objects of types %s, %s, %s", 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("%i object of %i types", "%i objects of %i types", object_count), - object_count, n_terms); - } - g_slist_free (terms); - + gchar *objects_str = + g_strdup_printf( "%i objects selected of types %s", + object_count, terms ); // indicate all, some, or none filtered gchar *filt_str = NULL; diff --git a/src/sp-anchor.cpp b/src/sp-anchor.cpp index d9a8c4142..3ed2c766c 100644 --- a/src/sp-anchor.cpp +++ b/src/sp-anchor.cpp @@ -115,14 +115,18 @@ Inkscape::XML::Node* SPAnchor::write(Inkscape::XML::Document *xml_doc, Inkscape: return repr; } +const char* SPAnchor::display_name() { + return _("Link"); +} + gchar* SPAnchor::description() { if (this->href) { char *quoted_href = xml_quote_strdup(this->href); - char *ret = g_strdup_printf(_("Link to %s"), quoted_href); + char *ret = g_strdup_printf(_("to %s"), quoted_href); g_free(quoted_href); return ret; } else { - return g_strdup (_("Link without URI")); + return g_strdup (_("without URI")); } } diff --git a/src/sp-anchor.h b/src/sp-anchor.h index cada9665e..a88778132 100644 --- a/src/sp-anchor.h +++ b/src/sp-anchor.h @@ -30,6 +30,7 @@ public: virtual void set(unsigned int key, gchar const* value); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual const char* display_name(); virtual gchar* description(); virtual gint event(SPEvent *event); }; diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 7c6066054..aad0336a7 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -427,8 +427,8 @@ void SPEllipse::set(unsigned int key, gchar const* value) { } } -gchar* SPEllipse::description() { - return g_strdup(_("Ellipse")); +const char* SPEllipse::display_name() { + return _("Ellipse"); } @@ -507,8 +507,8 @@ void SPCircle::set(unsigned int key, gchar const* value) { } } -gchar* SPCircle::description() { - return g_strdup(_("Circle")); +const char* SPCircle::display_name() { + return _("Circle"); } /* element */ @@ -681,7 +681,7 @@ void SPArc::modified(guint flags) { } -gchar* SPArc::description() { +const char* SPArc::display_name() { gdouble len = fmod(this->end - this->start, SP_2PI); if (len < 0.0) { @@ -690,12 +690,12 @@ gchar* SPArc::description() { if (!(fabs(len) < 1e-8 || fabs(len - SP_2PI) < 1e-8)) { if (this->closed) { - return g_strdup(_("Segment")); + return _("Segment"); } else { - return g_strdup(_("Arc")); + return _("Arc"); } } else { - return g_strdup(_("Ellipse")); + return _("Ellipse"); } } diff --git a/src/sp-ellipse.h b/src/sp-ellipse.h index 67e12006a..2b1a00af7 100644 --- a/src/sp-ellipse.h +++ b/src/sp-ellipse.h @@ -58,7 +58,7 @@ public: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); virtual void set(unsigned int key, gchar const* value); - virtual gchar* description(); + virtual const char* display_name(); }; void sp_ellipse_position_set (SPEllipse * ellipse, gdouble x, gdouble y, gdouble rx, gdouble ry); @@ -75,7 +75,7 @@ public: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); virtual void set(unsigned int key, gchar const* value); - virtual gchar* description(); + virtual const char* display_name(); }; /* element */ @@ -90,7 +90,7 @@ public: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); virtual void set(unsigned int key, gchar const* value); - virtual gchar* description(); + virtual const char* display_name(); virtual void modified(unsigned int flags); }; diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp index 3a0aef6be..caa6aef76 100644 --- a/src/sp-flowregion.cpp +++ b/src/sp-flowregion.cpp @@ -188,14 +188,11 @@ Inkscape::XML::Node *SPFlowregion::write(Inkscape::XML::Document *xml_doc, Inksc return repr; } -gchar* SPFlowregion::description() { +const char* SPFlowregion::display_name() { // TRANSLATORS: "Flow region" is an area where text is allowed to flow - return g_strdup_printf(_("Flow region")); + return _("Flow Region"); } -/* - * - */ SPFlowregionExclude::SPFlowregionExclude() : SPItem() { this->computed = NULL; } @@ -338,18 +335,14 @@ Inkscape::XML::Node *SPFlowregionExclude::write(Inkscape::XML::Document *xml_doc return repr; } -gchar* SPFlowregionExclude::description() { +const char* SPFlowregionExclude::display_name() { /* TRANSLATORS: A region "cut out of" a flow region; text is not allowed to flow inside the * flow excluded region. flowRegionExclude in SVG 1.2: see * http://www.w3.org/TR/2004/WD-SVG12-20041027/flow.html#flowRegion-elem and * http://www.w3.org/TR/2004/WD-SVG12-20041027/flow.html#flowRegionExclude-elem. */ - return g_strdup_printf(_("Flow excluded region")); + return _("Flow Excluded Region"); } -/* - * - */ - static void UnionShape(Shape **base_shape, Shape const *add_shape) { if (*base_shape == NULL) diff --git a/src/sp-flowregion.h b/src/sp-flowregion.h index 59818651a..600b2aa6e 100644 --- a/src/sp-flowregion.h +++ b/src/sp-flowregion.h @@ -31,7 +31,7 @@ public: virtual void update(SPCtx *ctx, unsigned int flags); virtual void modified(guint flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual gchar *description(); + virtual const char* display_name(); }; class SPFlowregionExclude : public SPItem { @@ -48,7 +48,7 @@ public: virtual void update(SPCtx *ctx, unsigned int flags); virtual void modified(guint flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual gchar *description(); + virtual const char* display_name(); }; #endif diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index c7ef579ac..9d54ad92b 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -280,17 +280,20 @@ void SPFlowtext::print(SPPrintContext *ctx) { this->layout.print(ctx, pbox, dbox, bbox, ctm); } +const char* SPFlowtext::display_name() { + if (SP_FLOWTEXT(this)->has_internal_frame()) { + return _("Flowed Text"); + } else { + return _("Linked Flowed Text"); + } +} + gchar* SPFlowtext::description() { Inkscape::Text::Layout const &layout = SP_FLOWTEXT(this)->layout; int const nChars = layout.iteratorToCharIndex(layout.end()); - char const *trunc = (layout.inputTruncated()) ? _(" [truncated]") : ""; - if (SP_FLOWTEXT(this)->has_internal_frame()) { - return g_strdup_printf(ngettext("Flowed text (%d character%s)", "Flowed text (%d characters%s)", nChars), nChars, trunc); - } else { - return g_strdup_printf(ngettext("Linked flowed text (%d character%s)", "Linked flowed text (%d characters%s)", nChars), nChars, trunc); - } + return g_strdup_printf(ngettext(_("(%d character%s)"), _("(%d characters%s)"), nChars), nChars, trunc); } void SPFlowtext::snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) { diff --git a/src/sp-flowtext.h b/src/sp-flowtext.h index bd7c5990a..1d3e30069 100644 --- a/src/sp-flowtext.h +++ b/src/sp-flowtext.h @@ -66,6 +66,7 @@ public: virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type); virtual void print(SPPrintContext *ctx); + virtual const char* display_name(); virtual gchar* description(); virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void hide(unsigned int key); diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 80daf33c3..c3352fcf0 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -613,6 +613,10 @@ void SPImage::print(SPPrintContext *ctx) { } } +const char* SPImage::display_name() { + return _("Image"); +} + gchar* SPImage::description() { char *href_desc; @@ -626,8 +630,8 @@ gchar* SPImage::description() { } char *ret = ( this->pixbuf == NULL - ? g_strdup_printf(_("Image with bad reference: %s"), href_desc) - : g_strdup_printf(_("Image %d × %d: %s"), + ? g_strdup_printf(_("[bad reference]: %s"), href_desc) + : g_strdup_printf(_("%d × %d: %s"), this->pixbuf->width(), this->pixbuf->height(), href_desc) ); diff --git a/src/sp-image.h b/src/sp-image.h index bfc10e7f2..85eceac20 100644 --- a/src/sp-image.h +++ b/src/sp-image.h @@ -64,6 +64,7 @@ public: virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type); virtual void print(SPPrintContext *ctx); + virtual const char* display_name(); virtual gchar* description(); virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 010cc5449..5c176d2dc 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -325,12 +325,14 @@ void SPGroup::print(SPPrintContext *ctx) { } } +const char *SPGroup::display_name() { + return _("Group"); +} + gchar *SPGroup::description() { gint len = this->getItemCount(); return g_strdup_printf( - ngettext("Group of %d object", - "Group of %d objects", - len), len); + ngettext(_("of %d object"), _("of %d objects"), len), len); } void SPGroup::set(unsigned int key, gchar const* value) { diff --git a/src/sp-item-group.h b/src/sp-item-group.h index 88ca9657a..e6357ddcc 100644 --- a/src/sp-item-group.h +++ b/src/sp-item-group.h @@ -75,6 +75,7 @@ public: virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype); virtual void print(SPPrintContext *ctx); + virtual const char* display_name(); virtual gchar *description(); virtual Inkscape::DrawingItem *show (Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void hide (unsigned int key); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index e6991a1fa..154169e79 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -931,9 +931,12 @@ void SPItem::invoke_print(SPPrintContext *ctx) } } -// CPPIFY: is it possible to combine this method with "SPItem::description()"? +const char* SPItem::display_name() { + return _("Object"); +} + gchar* SPItem::description() { - return g_strdup(_("Object")); + return g_strdup(""); } /** @@ -943,7 +946,8 @@ gchar* SPItem::description() { */ gchar *SPItem::getDetailedDescription() { - gchar* s = this->description(); + gchar* s = g_strdup_printf("%s %s", + this->display_name(), this->description()); if (s && clip_ref->getObject()) { gchar *snew = g_strdup_printf (_("%s; clipped"), s); diff --git a/src/sp-item.h b/src/sp-item.h index 8dfb4142a..769af229e 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -236,6 +236,7 @@ public: virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type); virtual void print(SPPrintContext *ctx); + virtual const char* display_name(); virtual gchar* description(); virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void hide(unsigned int key); diff --git a/src/sp-line.cpp b/src/sp-line.cpp index 3963007de..c3a0b13db 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -122,8 +122,8 @@ Inkscape::XML::Node* SPLine::write(Inkscape::XML::Document *xml_doc, Inkscape::X return repr; } -gchar* SPLine::description() { - return g_strdup(_("Line")); +const char* SPLine::display_name() { + return _("Line"); } void SPLine::convert_to_guides() { diff --git a/src/sp-line.h b/src/sp-line.h index ebdfc9f04..7184b9401 100644 --- a/src/sp-line.h +++ b/src/sp-line.h @@ -34,7 +34,7 @@ public: virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); virtual void set(unsigned int key, gchar const* value); - virtual gchar* description(); + virtual const char* display_name(); virtual Geom::Affine set_transform(Geom::Affine const &transform); virtual void convert_to_guides(); virtual void update(SPCtx* ctx, guint flags); diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index ef18acc8e..f9759cac1 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -339,18 +339,20 @@ void SPOffset::update(SPCtx *ctx, guint flags) { SPShape::update(ctx, flags); } -gchar* SPOffset::description() { +const char* SPOffset::display_name() { if ( this->sourceHref ) { - // TRANSLATORS COMMENT: %s is either "outset" or "inset" depending on sign - return g_strdup_printf(_("Linked offset, %s by %f pt"), - (this->rad >= 0)? _("outset") : _("inset"), fabs (this->rad)); + return _("Linked Offset"); } else { - // TRANSLATORS COMMENT: %s is either "outset" or "inset" depending on sign - return g_strdup_printf(_("Dynamic offset, %s by %f pt"), - (this->rad >= 0)? _("outset") : _("inset"), fabs (this->rad)); + return _("Dynamic Offset"); } } +gchar* SPOffset::description() { + // TRANSLATORS COMMENT: %s is either "outset" or "inset" depending on sign + return g_strdup_printf(_("%s by %f pt"), (this->rad >= 0) ? + _("outset") : _("inset"), fabs (this->rad)); +} + void SPOffset::set_shape() { if ( this->originalPath == NULL ) { // oops : no path?! (the offset object should do harakiri) diff --git a/src/sp-offset.h b/src/sp-offset.h index 7fe6a8a24..360bfbf94 100644 --- a/src/sp-offset.h +++ b/src/sp-offset.h @@ -82,6 +82,7 @@ public: virtual void release(); virtual void snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs); + virtual const char* display_name(); virtual gchar* description(); virtual void set_shape(); diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 105506d6e..49e40fd24 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -66,8 +66,13 @@ gint SPPath::nodesInPath() const return _curve ? _curve->nodes_in_path() : 0; } +const char* SPPath::display_name() { + return _("Path"); +} + gchar* SPPath::description() { int count = this->nodesInPath(); + char *lpe_desc = g_strdup(""); if (sp_lpe_item_has_path_effect(this)) { Glib::ustring s; @@ -87,13 +92,12 @@ gchar* SPPath::description() { s = s + ", " + lpeobj->get_lpe()->getName(); } } - - return g_strdup_printf(ngettext("Path (%i node, path effect: %s)", - "Path (%i nodes, path effect: %s)",count), count, s.c_str()); - } else { - return g_strdup_printf(ngettext("Path (%i node)", - "Path (%i nodes)",count), count); + lpe_desc = g_strdup_printf(_(", path effect: %s"), s.c_str()); } + char *ret = g_strdup_printf(ngettext( + _("%i node%s"), _("%i nodes%s"), count), count, lpe_desc); + g_free(lpe_desc); + return ret; } void SPPath::convert_to_guides() { diff --git a/src/sp-path.h b/src/sp-path.h index 42c0f22c8..ca25de33b 100644 --- a/src/sp-path.h +++ b/src/sp-path.h @@ -54,6 +54,7 @@ public: virtual void set(unsigned int key, gchar const* value); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); + virtual const char* display_name(); virtual gchar* description(); virtual Geom::Affine set_transform(Geom::Affine const &transform); virtual void convert_to_guides(); diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index 519b7ba6e..6d5119e4c 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -159,8 +159,8 @@ Inkscape::XML::Node * SPRect::write(Inkscape::XML::Document *xml_doc, Inkscape:: return repr; } -gchar* SPRect::description() { - return g_strdup(_("Rectangle")); +const char* SPRect::display_name() { + return _("Rectangle"); } #define C1 0.554 diff --git a/src/sp-rect.h b/src/sp-rect.h index 28f74f9f9..e06833916 100644 --- a/src/sp-rect.h +++ b/src/sp-rect.h @@ -55,7 +55,7 @@ public: virtual void update(SPCtx* ctx, unsigned int flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual gchar* description(); + virtual const char* display_name(); virtual void set_shape(); virtual Geom::Affine set_transform(Geom::Affine const& xform); diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index 8d2954c6e..ab7cc5c9d 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -227,12 +227,14 @@ void SPSpiral::update_patheffect(bool write) { shape->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } -gchar* SPSpiral::description() { - SPSpiral* item = this; +const char* SPSpiral::display_name() { + return _("Spiral"); +} - // TRANSLATORS: since turn count isn't an integer, please adjust the +gchar* SPSpiral::description() { + // TRANSLATORS: since turn count isn't an integer, please adjust the // string as needed to deal with an localized plural forms. - return g_strdup_printf (_("Spiral with %3f turns"), SP_SPIRAL(item)->revo); + return g_strdup_printf (_("with %3f turns"), SP_SPIRAL(this)->revo); } /** diff --git a/src/sp-spiral.h b/src/sp-spiral.h index 1e9c2d2b4..c108eb2d0 100644 --- a/src/sp-spiral.h +++ b/src/sp-spiral.h @@ -71,6 +71,7 @@ public: virtual void set(unsigned int key, gchar const* value); virtual void snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs); + virtual const char* display_name(); virtual gchar* description(); virtual void set_shape(); diff --git a/src/sp-star.cpp b/src/sp-star.cpp index 4a3a8cbe3..e5c5c7c25 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -251,19 +251,18 @@ void SPStar::update_patheffect(bool write) { this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } +const char* SPStar::display_name() { + if (this->flatsided == false) + return _("Star"); + return _("Polygon"); +} + gchar* SPStar::description() { // while there will never be less than 3 vertices, we still need to // make calls to ngettext because the pluralization may be different // for various numbers >=3. The singular form is used as the index. - if (this->flatsided == false) { - return g_strdup_printf (ngettext("Star with %d vertex", - "Star with %d vertices", - this->sides), this->sides); - } else { - return g_strdup_printf (ngettext("Polygon with %d vertex", - "Polygon with %d vertices", - this->sides), this->sides); - } + return g_strdup_printf (ngettext(_("with %d vertex"), _("with %d vertices"), + this->sides), this->sides); } /** diff --git a/src/sp-star.h b/src/sp-star.h index 0f1280139..9ff85cdca 100644 --- a/src/sp-star.h +++ b/src/sp-star.h @@ -50,6 +50,7 @@ public: virtual void set(unsigned int key, gchar const* value); virtual void update(SPCtx* ctx, guint flags); + virtual const char* display_name(); virtual gchar* description(); virtual void snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs); diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index cc50a8fef..c6dcf17e3 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -71,12 +71,14 @@ GSList *SPSwitch::_childList(bool add_ref, SPObject::Action action) { return g_slist_prepend (NULL, child); } +const char *SPSwitch::display_name() { + return _("Conditional Group"); +} + gchar *SPSwitch::description() { gint len = this->getItemCount(); return g_strdup_printf( - ngettext("Conditional group of %d object", - "Conditional group of %d objects", - len), len); + ngettext(_("of %d object"), _("of %d objects"), len), len); } void SPSwitch::child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref) { diff --git a/src/sp-switch.h b/src/sp-switch.h index 210cd0ddc..5627784cf 100644 --- a/src/sp-switch.h +++ b/src/sp-switch.h @@ -41,6 +41,7 @@ public: virtual void child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref); virtual void remove_child(Inkscape::XML::Node *child); virtual void order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref); + virtual const char* display_name(); virtual gchar *description(); }; diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 85137e58d..afd4e304e 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -321,6 +321,9 @@ void SPText::hide(unsigned int key) { // SPItem::onHide(key); } +const char* SPText::display_name() { + return _("Text"); +} gchar* SPText::description() { SPStyle *style = this->style; @@ -350,8 +353,8 @@ gchar* SPText::description() { } char *ret = ( SP_IS_TEXT_TEXTPATH(this) - ? g_strdup_printf(_("Text on path%s (%s, %s)"), trunc, n, xs->str) - : g_strdup_printf(_("Text%s (%s, %s)"), trunc, n, xs->str) ); + ? g_strdup_printf(_("on path%s (%s, %s)"), trunc, n, xs->str) + : g_strdup_printf(_("%s (%s, %s)"), trunc, n, xs->str) ); g_free(n); return ret; } diff --git a/src/sp-text.h b/src/sp-text.h index 12f773ded..3a897a594 100644 --- a/src/sp-text.h +++ b/src/sp-text.h @@ -78,6 +78,7 @@ public: virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type); virtual void print(SPPrintContext *ctx); + virtual const char* display_name(); virtual gchar* description(); virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void hide(unsigned int key); diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 1872cdf7c..f0a4af667 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -233,28 +233,30 @@ Geom::OptRect SPTRef::bbox(Geom::Affine const &transform, SPItem::BBoxType type) return bbox; } +const char* SPTRef::display_name() { + return _("Cloned Character Data"); +} + gchar* SPTRef::description() { - SPObject *referred = this->getObjectReferredTo(); + SPObject *referred = this->getObjectReferredTo(); - if (this->getObjectReferredTo()) { - char *child_desc; + if (this->getObjectReferredTo()) { + char *child_desc; - if (SP_IS_ITEM(referred)) { - child_desc = SP_ITEM(referred)->getDetailedDescription(); - } else { - child_desc = g_strdup(""); - } + if (SP_IS_ITEM(referred)) { + child_desc = SP_ITEM(referred)->getDetailedDescription(); + } else { + child_desc = g_strdup(""); + } - char *ret = g_strdup_printf( - _("Cloned character data%s%s"), - (SP_IS_ITEM(referred) ? _(" from ") : ""), - child_desc); - g_free(child_desc); + char *ret = g_strdup_printf("%s%s", + (SP_IS_ITEM(referred) ? _(" from ") : ""), child_desc); + g_free(child_desc); - return ret; - } + return ret; + } - return g_strdup(_("Orphaned cloned character data")); + return g_strdup(_("[orphaned]")); } diff --git a/src/sp-tref.h b/src/sp-tref.h index 451c6cb58..c82970a7f 100644 --- a/src/sp-tref.h +++ b/src/sp-tref.h @@ -58,6 +58,7 @@ public: virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type); + virtual const char* display_name(); virtual gchar* description(); }; diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 63dcd07d8..43a9faa5e 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -216,8 +216,8 @@ Inkscape::XML::Node* SPTSpan::write(Inkscape::XML::Document *xml_doc, Inkscape:: return repr; } -gchar* SPTSpan::description() { - return g_strdup(_("Text span")); +const char* SPTSpan::display_name() { + return _("Text Span"); } diff --git a/src/sp-tspan.h b/src/sp-tspan.h index d1c6ec4bc..ee05073cd 100644 --- a/src/sp-tspan.h +++ b/src/sp-tspan.h @@ -34,7 +34,7 @@ public: virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type); - virtual gchar* description(); + virtual const char* display_name(); }; #endif /* !INKSCAPE_SP_TSPAN_H */ diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 44935e61d..05e1f0e66 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -226,12 +226,17 @@ void SPUse::print(SPPrintContext* ctx) { } } +const char* SPUse::display_name() { + if(this->child && SP_IS_SYMBOL( this->child )) { + return _("Symbol"); + } + return _("Clone"); +} + gchar* SPUse::description() { if (this->child) { if( SP_IS_SYMBOL( this->child ) ) { - char *symbol_desc = SP_ITEM(this->child)->title(); - return g_strdup_printf(_("'%s' Symbol"), symbol_desc ); - g_free(symbol_desc); + return g_strdup_printf(_("called %s"), SP_ITEM(this->child)->title()); } static unsigned recursion_depth = 0; @@ -248,12 +253,12 @@ gchar* SPUse::description() { char *child_desc = SP_ITEM(this->child)->getDetailedDescription(); --recursion_depth; - char *ret = g_strdup_printf(_("Clone of: %s"), child_desc); + char *ret = g_strdup_printf(_("of: %s"), child_desc); g_free(child_desc); return ret; } else { - return g_strdup(_("Orphaned clone")); + return g_strdup(_("[orphaned]")); } } diff --git a/src/sp-use.h b/src/sp-use.h index 37ff2cf66..568b8f7da 100644 --- a/src/sp-use.h +++ b/src/sp-use.h @@ -57,6 +57,7 @@ public: virtual void modified(unsigned int flags); virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype); + virtual const char* display_name(); virtual gchar* description(); virtual void print(SPPrintContext *ctx); virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); -- cgit v1.2.3