14#include <glibmm/i18n.h>
46 auto tokens = Glib::Regex::split_simple(
"\\s*,\\s*", ids);
47 for (
auto id : tokens) {
50 selection->
add(
object);
52 show_output(Glib::ustring(
"select_by_id: Did not find object with id: ") +
id.raw());
66 auto tokens = Glib::Regex::split_simple(
"\\s*,\\s*", ids);
67 for (
auto id : tokens) {
72 show_output(Glib::ustring(
"unselect_by_id: Did not find object with id: ") +
id.raw());
87 selection->
add(objects.begin(), objects.end());
99 selection->
add(objects.begin(), objects.end());
112 selection->
add(objects.begin(), objects.end());
120 for (
auto &o :
object->childList(
false)) {
122 auto group = cast<SPGroup>(o);
123 if (condition ==
"layers") {
125 objects.emplace_back(o);
128 }
else if (condition ==
"no-layers") {
132 objects.emplace_back(o);
135 }
else if (condition ==
"groups") {
137 objects.emplace_back(o);
139 }
else if (condition ==
"all") {
140 objects.emplace_back(o);
144 objects.emplace_back(o);
166 if (condition !=
"" && condition !=
"layers" && condition !=
"no-layers" &&
167 condition !=
"groups" && condition !=
"no-groups" && condition !=
"all") {
168 show_output(
"select_all: allowed options are '', 'all', 'layers', 'no-layers', 'groups', and 'no-groups'" );
178 std::vector<SPObject *> objects;
187 if (condition !=
"" && condition !=
"layers" && condition !=
"no-layers" &&
188 condition !=
"groups" && condition !=
"no-groups" && condition !=
"all") {
189 show_output(
"select_all: allowed options are '', 'all', 'layers', 'no-layers', 'groups', and 'no-groups'" );
200 std::vector<SPObject *> objects;
204 std::vector<SPObject *>
current(selection->
items().begin(), selection->
items().end());
208 std::remove_if(std::begin(objects), std::end(objects), [&
current](
const SPObject *x)
227 for (
auto obj : selection->
objects()) {
228 std::stringstream buffer;
234const Glib::ustring
SECTION = NC_(
"Action Section",
"Select");
239 {
"app.select-clear", N_(
"Clear Selection"),
SECTION, N_(
"Clear selection")},
240 {
"app.select", N_(
"Select"),
SECTION, N_(
"Select by ID (deprecated)")},
241 {
"app.unselect", N_(
"Deselect"),
SECTION, N_(
"Deselect by ID (deprecated)")},
242 {
"app.select-by-id", N_(
"Select by ID"),
SECTION, N_(
"Select by ID")},
243 {
"app.unselect-by-id", N_(
"Deselect by ID"),
SECTION, N_(
"Deselect by ID")},
244 {
"app.select-by-class", N_(
"Select by Class"),
SECTION, N_(
"Select by class")},
245 {
"app.select-by-element", N_(
"Select by Element"),
SECTION, N_(
"Select by SVG element (e.g. 'rect')")},
246 {
"app.select-by-selector", N_(
"Select by Selector"),
SECTION, N_(
"Select by CSS selector")},
247 {
"app.select-all", N_(
"Select All Objects"),
SECTION, N_(
"Select all; options: 'all' (every object including groups), 'layers', 'no-layers' (top level objects in layers), 'groups' (all groups including layers), 'no-groups' (all objects other than groups and layers, default)")},
248 {
"app.select-list", N_(
"List Selection"),
SECTION, N_(
"Print a list of objects in current selection")},
258 gapp->add_action(
"select-clear", sigc::bind(sigc::ptr_fun(&
select_clear), app) );
259 gapp->add_action_radio_string(
"select", sigc::bind(sigc::ptr_fun(&
select_by_id), app),
"null");
260 gapp->add_action_radio_string(
"unselect", sigc::bind(sigc::ptr_fun(&
unselect_by_id), app),
"null");
261 gapp->add_action_radio_string(
"select-by-id", sigc::bind(sigc::ptr_fun(&
select_by_id), app),
"null");
262 gapp->add_action_radio_string(
"unselect-by-id", sigc::bind(sigc::ptr_fun(&
unselect_by_id), app),
"null");
263 gapp->add_action_radio_string(
"select-by-class", sigc::bind(sigc::ptr_fun(&
select_by_class), app),
"null");
264 gapp->add_action_radio_string(
"select-by-element", sigc::bind(sigc::ptr_fun(&
select_by_element), app),
"null");
265 gapp->add_action_radio_string(
"select-by-selector", sigc::bind(sigc::ptr_fun(&
select_by_selector), app),
"null");
266 gapp->add_action_radio_string(
"select-all", sigc::bind(sigc::ptr_fun(&
select_all), app),
"null");
267 gapp->add_action_radio_string(
"select-invert", sigc::bind(sigc::ptr_fun(&
select_invert), app),
"null");
268 gapp->add_action(
"select-list", sigc::bind(sigc::ptr_fun(&
select_list), app) );
void show_output(Glib::ustring const &data, bool const is_cerr)
bool get_document_and_selection(InkscapeApplication *app, SPDocument **document, Inkscape::Selection **selection)
void select_by_selector(Glib::ustring selector, InkscapeApplication *app)
void select_by_class(Glib::ustring klass, InkscapeApplication *app)
void select_by_element(Glib::ustring element, InkscapeApplication *app)
void select_list(InkscapeApplication *app)
void add_actions_selection(InkscapeApplication *app)
const Glib::ustring SECTION
void select_invert(Glib::ustring condition, InkscapeApplication *app)
std::vector< std::vector< Glib::ustring > > raw_data_selection
void select_all(Glib::ustring condition, InkscapeApplication *app)
void unselect_by_id(Glib::ustring ids, InkscapeApplication *app)
void get_all_items_recursive(std::vector< SPObject * > &objects, SPObject *object, Glib::ustring &condition)
void select_by_id(Glib::ustring ids, InkscapeApplication *app)
void select_clear(InkscapeApplication *app)
InkActionExtraData & get_action_extra_data()
Gio::Application * gio_app()
The Gio application instance, never NULL.
SPItemRange items()
Returns a range of selected SPItems.
boost::enable_if< boost::is_base_of< SPObject, T >, void >::type setList(const std::vector< T * > &objs)
Selects exactly the specified objects.
void clear()
Unselects all selected objects.
SPObjectRange objects()
Returns the list of selected objects.
The set of selected SPObjects for a given document and layer model.
void add(XML::Node *repr)
Add an XML node's SPObject to the set of selected objects.
void remove(XML::Node *repr)
Removes an item from the set of selected objects.
Typed SVG document implementation.
std::vector< SPObject * > getObjectsByClass(Glib::ustring const &klass) const
SPRoot * getRoot()
Returns our SPRoot.
SPObject * getObjectById(std::string const &id) const
std::vector< SPObject * > getObjectsByElement(Glib::ustring const &element, bool custom=false) const
std::vector< SPObject * > getObjectsBySelector(Glib::ustring const &selector) const
SPObject is an abstract base class of all of the document nodes at the SVG document level.
static char const *const current
SPRoot: SVG <svg> implementation.