diff options
| -rw-r--r-- | src/menus-skeleton.h | 1 | ||||
| -rw-r--r-- | src/selection-chemistry.cpp | 32 | ||||
| -rw-r--r-- | src/selection-chemistry.h | 1 | ||||
| -rw-r--r-- | src/ui/interface.cpp | 12 | ||||
| -rw-r--r-- | src/ui/interface.h | 1 | ||||
| -rw-r--r-- | src/verbs.cpp | 5 | ||||
| -rw-r--r-- | src/verbs.h | 1 |
7 files changed, 53 insertions, 0 deletions
diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 8cdfbeb05..9e1c5c9f6 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -188,6 +188,7 @@ static char const menus_skeleton[] = " <separator/>\n" " <verb verb-id=\"SelectionGroup\" />\n" " <verb verb-id=\"SelectionUnGroup\" />\n" +" <verb verb-id=\"SelectionUnGroupPopSelection\" />\n" " <separator/>\n" " <submenu name=\"" N_("Cli_p") "\">\n" " <verb verb-id=\"ObjectSetClipPath\" />\n" diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index e9a3af83a..7d32477a1 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -791,6 +791,38 @@ static gint clone_depth_descending(gconstpointer a, gconstpointer b) { return -1; } } + +void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDesktop *desktop) +{ + if (selection->isEmpty()) { + selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("<b>No objects selected</b> to pop out of group.")); + return; + } + std::vector<SPItem*> selection_list = selection->itemList(); + + std::vector<SPItem*>::const_iterator item = selection_list.begin(); // leaving this because it will be useful for + // future implementation of complex pop ungrouping + SPItem *obj = *item; + SPItem *parent_group = static_cast<SPItem*>(obj->parent); + if (!SP_IS_GROUP(parent_group) || SP_IS_LAYER(parent_group)) { + desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Selection <b>not in a group</b>.")); + return; + } + if (parent_group->firstChild()->getNext() == NULL) { + std::vector<SPItem*> children; + sp_item_group_ungroup(static_cast<SPGroup*>(parent_group), children, false); + } + else { + sp_selection_to_next_layer(desktop, 1); // suppress done + } + + parent_group->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + + DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP_POP_SELECTION, + _("Pop selection from group")); + +} + void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) { diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index 4bfa2c0aa..82b91c617 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -76,6 +76,7 @@ void sp_selection_untile(SPDesktop *desktop); void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop); void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDesktop *desktop); void sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop); void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop); diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index a16bbc472..3e2a2004c 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -1523,6 +1523,12 @@ ContextMenu::ContextMenu(SPDesktop *desktop, SPItem *item) : MIParent.signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::LeaveGroup)); MIParent.show(); append(MIParent); + + /* Pop selection out of group */ + Gtk::MenuItem* miu = Gtk::manage(new Gtk::MenuItem(_("_Pop selection out of group"), 1)); + miu->signal_activate().connect(sigc::mem_fun(*this, &ContextMenu::ActivateUngroupPopSelection)); + miu->show(); + append(*miu); } } } @@ -1920,6 +1926,12 @@ void ContextMenu::ActivateUngroup(void) sp_item_group_ungroup(static_cast<SPGroup*>(_item), children); _desktop->selection->setList(children); } + +void ContextMenu::ActivateUngroupPopSelection(void) +{ + sp_selection_ungroup_pop_selection(_desktop->selection, _desktop); +} + void ContextMenu::MakeAnchorMenu(void) { diff --git a/src/ui/interface.h b/src/ui/interface.h index 6fb74046f..52074f0f0 100644 --- a/src/ui/interface.h +++ b/src/ui/interface.h @@ -194,6 +194,7 @@ class ContextMenu : public Gtk::Menu /** * callback, is executed on clicking the anchor "Group" and "Ungroup" menu entry */ + void ActivateUngroupPopSelection(void); void ActivateUngroup(void); void ActivateGroup(void); diff --git a/src/verbs.cpp b/src/verbs.cpp index 7b128c172..e3ba82e46 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1150,6 +1150,9 @@ void SelectionVerb::perform(SPAction *action, void *data) case SP_VERB_SELECTION_UNGROUP: sp_selection_ungroup(selection, dt); break; + case SP_VERB_SELECTION_UNGROUP_POP_SELECTION: + sp_selection_ungroup_pop_selection(selection, dt); + break; default: handled = false; break; @@ -2559,6 +2562,8 @@ Verb *Verb::_base_verbs[] = { N_("Group selected objects"), INKSCAPE_ICON("object-group")), new SelectionVerb(SP_VERB_SELECTION_UNGROUP, "SelectionUnGroup", N_("_Ungroup"), N_("Ungroup selected groups"), INKSCAPE_ICON("object-ungroup")), + new SelectionVerb(SP_VERB_SELECTION_UNGROUP_POP_SELECTION, "SelectionUnGroupPopSelection", N_("_Pop selected objects out of group"), + N_("Pop selected objects out of group"), INKSCAPE_ICON("object-ungroup-pop-selection")), new SelectionVerb(SP_VERB_SELECTION_TEXTTOPATH, "SelectionTextToPath", N_("_Put on Path"), N_("Put text on path"), INKSCAPE_ICON("text-put-on-path")), diff --git a/src/verbs.h b/src/verbs.h index 4f453761e..ffb9b23d8 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -116,6 +116,7 @@ enum { SP_VERB_SELECTION_LOWER, SP_VERB_SELECTION_GROUP, SP_VERB_SELECTION_UNGROUP, + SP_VERB_SELECTION_UNGROUP_POP_SELECTION, SP_VERB_SELECTION_TEXTTOPATH, SP_VERB_SELECTION_TEXTFROMPATH, SP_VERB_SELECTION_REMOVE_KERNS, |
