KnotHolder *createKnotHolder(SPItem *item, SPDesktop *desktop) { KnotHolder *knotholder = NULL; if (SP_IS_LPE_ITEM(item) && SP_LPE_ITEM(item)->getCurrentLPE() && SP_LPE_ITEM(item)->getCurrentLPE()->isVisible() && SP_LPE_ITEM(item)->getCurrentLPE()->providesKnotholder()) { knotholder = sp_lpe_knot_holder(item, desktop); } else if (SP_IS_RECT(item)) { knotholder = new RectKnotHolder(desktop, item, NULL); } else if (SP_IS_BOX3D(item)) { knotholder = new Box3DKnotHolder(desktop, item, NULL); } else if (SP_IS_GENERICELLIPSE(item)) { knotholder = new ArcKnotHolder(desktop, item, NULL); } else if (SP_IS_STAR(item)) { knotholder = new StarKnotHolder(desktop, item, NULL); } else if (SP_IS_SPIRAL(item)) { knotholder = new SpiralKnotHolder(desktop, item, NULL); } else if (SP_IS_OFFSET(item)) { knotholder = new OffsetKnotHolder(desktop, item, NULL); } else if (SP_IS_FLOWTEXT(item) && SP_FLOWTEXT(item)->has_internal_frame()) { knotholder = new FlowtextKnotHolder(desktop, SP_FLOWTEXT(item)->get_frame(NULL), NULL); } else if ((item->style->fill.isPaintserver()) && SP_IS_PATTERN(item->style->getFillPaintServer())) { knotholder = new KnotHolder(desktop, item, NULL); knotholder->add_pattern_knotholder(); } return knotholder; }
bool item_type_match (SPItem *item, GtkWidget *widget) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (SP_IS_RECT(item)) { return (type_checkbox (widget, "shapes") || type_checkbox (widget, "rects")); } else if (SP_IS_GENERICELLIPSE(item) || SP_IS_ELLIPSE(item) || SP_IS_ARC(item) || SP_IS_CIRCLE(item)) { return (type_checkbox (widget, "shapes") || type_checkbox (widget, "ellipses")); } else if (SP_IS_STAR(item) || SP_IS_POLYGON(item)) { return (type_checkbox (widget, "shapes") || type_checkbox (widget, "stars")); } else if (SP_IS_SPIRAL(item)) { return (type_checkbox (widget, "shapes") || type_checkbox (widget, "spirals")); } else if (SP_IS_PATH(item) || SP_IS_LINE(item) || SP_IS_POLYLINE(item)) { return (type_checkbox (widget, "paths")); } else if (SP_IS_TEXT(item) || SP_IS_TSPAN(item) || SP_IS_TREF(item) || SP_IS_STRING(item)) { return (type_checkbox (widget, "texts")); } else if (SP_IS_GROUP(item) && !desktop->isLayer(item) ) { // never select layers! return (type_checkbox (widget, "groups")); } else if (SP_IS_USE(item)) { return (type_checkbox (widget, "clones")); } else if (SP_IS_IMAGE(item)) { return (type_checkbox (widget, "images")); } else if (SP_IS_OFFSET(item)) { return (type_checkbox (widget, "offsets")); } return false; }
void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *selection) { GSList const *items = selection->itemList(); if (!items) { // no items _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(); // Layer name gchar *layer_name; if (layer == root) { layer_name = g_strdup(_("root")); } else { char const *layer_label; bool is_label = false; if (layer->label()) { layer_label = layer->label(); is_label = true; } else { layer_label = layer->defaultLabel(); } char *quoted_layer_label = xml_quote_strdup(layer_label); if (is_label) { layer_name = g_strdup_printf(_("layer <b>%s</b>"), quoted_layer_label); } else { layer_name = g_strdup_printf(_("layer <b><i>%s</i></b>"), quoted_layer_label); } g_free(quoted_layer_label); } // 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 *in_phrase; guint num_layers = selection->numberOfLayers(); guint num_parents = selection->numberOfParents(); if (num_layers == 1) { if (num_parents == 1) { if (layer == parent) in_phrase = g_strdup_printf(_(" in %s"), layer_name); else in_phrase = g_strdup_printf(_(" in group %s (%s)"), parent_name, 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); } } else { in_phrase = g_strdup_printf(ngettext(" in <b>%i</b> layers", " 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_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_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); } else if (SP_IS_TEXT_TEXTPATH(item)) { _context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.", item_desc, in_phrase, _("Use <b>Shift+D</b> to look up path"), _when_selected); } else if (SP_IS_FLOWTEXT(item) && !SP_FLOWTEXT(item)->has_internal_frame()) { _context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s. %s.", item_desc, in_phrase, _("Use <b>Shift+D</b> to look up frame"), _when_selected); } else { _context.setF(Inkscape::NORMAL_MESSAGE, "%s%s. %s.", item_desc, in_phrase, _when_selected); } g_free(item_desc); } else { // multiple items int object_count = g_slist_length((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); // 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 { filt_str = g_strdup_printf("%s", ""); } _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); objects_str = 0; } } g_free(in_phrase); } }