summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2008-06-14 08:08:21 +0000
committerjoncruz <joncruz@users.sourceforge.net>2008-06-14 08:08:21 +0000
commit44f1e9c042015ddc34c6d56555460fa30f9ee427 (patch)
tree68076b654a45edfc2fbca1fe77dee6ca852c64ca /src
parentname update (diff)
downloadinkscape-44f1e9c042015ddc34c6d56555460fa30f9ee427.tar.gz
inkscape-44f1e9c042015ddc34c6d56555460fa30f9ee427.zip
Added duplicate layer command. Fixes bug #171246.
(bzr r5927)
Diffstat (limited to 'src')
-rw-r--r--src/dialogs/layers-panel.cpp8
-rw-r--r--src/menus-skeleton.h1
-rw-r--r--src/selection-chemistry.cpp24
-rw-r--r--src/selection-chemistry.h6
-rw-r--r--src/verbs.cpp30
-rw-r--r--src/verbs.h1
6 files changed, 56 insertions, 14 deletions
diff --git a/src/dialogs/layers-panel.cpp b/src/dialogs/layers-panel.cpp
index ebb6d989d..d54fb6fc7 100644
--- a/src/dialogs/layers-panel.cpp
+++ b/src/dialogs/layers-panel.cpp
@@ -62,7 +62,7 @@ enum {
BUTTON_BOTTOM,
BUTTON_UP,
BUTTON_DOWN,
-// BUTTON_DUPLICATE,
+ BUTTON_DUPLICATE,
BUTTON_DELETE,
BUTTON_SOLO
};
@@ -350,6 +350,11 @@ bool LayersPanel::_executeAction()
_fireAction( SP_VERB_LAYER_LOWER );
}
break;
+ case BUTTON_DUPLICATE:
+ {
+ _fireAction( SP_VERB_LAYER_DUPLICATE );
+ }
+ break;
case BUTTON_DELETE:
{
_fireAction( SP_VERB_LAYER_DELETE );
@@ -781,6 +786,7 @@ LayersPanel::LayersPanel() :
// -------------------------------------------------------
{
_watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_RENAME, 0, "Rename", (int)BUTTON_RENAME ) );
+ _watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_DUPLICATE, 0, "Duplicate", (int)BUTTON_DUPLICATE ) );
_watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_NEW, 0, "New", (int)BUTTON_NEW ) );
_watching.push_back( &_addPopupItem( targetDesktop, SP_VERB_LAYER_SOLO, 0, "Solo", (int)BUTTON_SOLO ) );
diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h
index 02c81adcf..4ae213bc0 100644
--- a/src/menus-skeleton.h
+++ b/src/menus-skeleton.h
@@ -136,6 +136,7 @@ static char const menus_skeleton[] =
" </submenu>\n"
" <submenu name=\"" N_("_Layer") "\">\n"
" <verb verb-id=\"LayerNew\" />\n"
+" <verb verb-id=\"LayerDuplicate\" />\n"
" <verb verb-id=\"LayerRename\" />\n"
" <separator/>\n"
" <verb verb-id=\"LayerNext\" />\n"
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index f35e28f9a..0f92f9680 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -221,7 +221,7 @@ void sp_selection_delete()
}
/* fixme: sequencing */
-void sp_selection_duplicate()
+void sp_selection_duplicate(bool suppressDone)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if (desktop == NULL)
@@ -256,8 +256,10 @@ void sp_selection_duplicate()
Inkscape::GC::release(copy);
}
- sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_DUPLICATE,
- _("Duplicate"));
+ if ( !suppressDone ) {
+ sp_document_done(sp_desktop_document(desktop), SP_VERB_EDIT_DUPLICATE,
+ _("Duplicate"));
+ }
selection->setReprList(newsel);
@@ -960,7 +962,7 @@ void sp_selection_paste_size_separately (bool apply_x, bool apply_y)
_("Paste size separately"));
}
-void sp_selection_to_next_layer ()
+void sp_selection_to_next_layer(bool suppressDone)
{
SPDesktop *dt = SP_ACTIVE_DESKTOP;
@@ -992,8 +994,10 @@ void sp_selection_to_next_layer ()
g_slist_free (copied);
if (temp_clip) g_slist_free (temp_clip);
if (next) dt->setCurrentLayer(next);
- sp_document_done(sp_desktop_document (dt), SP_VERB_LAYER_MOVE_TO_NEXT,
- _("Raise to next layer"));
+ if ( !suppressDone ) {
+ sp_document_done(sp_desktop_document (dt), SP_VERB_LAYER_MOVE_TO_NEXT,
+ _("Raise to next layer"));
+ }
} else {
no_more = true;
}
@@ -1005,7 +1009,7 @@ void sp_selection_to_next_layer ()
g_slist_free ((GSList *) items);
}
-void sp_selection_to_prev_layer ()
+void sp_selection_to_prev_layer(bool suppressDone)
{
SPDesktop *dt = SP_ACTIVE_DESKTOP;
@@ -1037,8 +1041,10 @@ void sp_selection_to_prev_layer ()
g_slist_free (copied);
if (temp_clip) g_slist_free (temp_clip);
if (next) dt->setCurrentLayer(next);
- sp_document_done(sp_desktop_document (dt), SP_VERB_LAYER_MOVE_TO_PREV,
- _("Lower to previous layer"));
+ if ( !suppressDone ) {
+ sp_document_done(sp_desktop_document (dt), SP_VERB_LAYER_MOVE_TO_PREV,
+ _("Lower to previous layer"));
+ }
} else {
no_more = true;
}
diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h
index e5b2d9ef1..aa3c2b100 100644
--- a/src/selection-chemistry.h
+++ b/src/selection-chemistry.h
@@ -29,7 +29,7 @@ namespace LivePathEffect {
class SPCSSAttr;
void sp_selection_delete();
-void sp_selection_duplicate();
+void sp_selection_duplicate(bool suppressDone = false);
void sp_edit_clear_all();
void sp_edit_select_all();
@@ -71,8 +71,8 @@ void sp_set_style_clipboard (SPCSSAttr *css);
void sp_selection_paste_size(bool apply_x, bool apply_y);
void sp_selection_paste_size_separately(bool apply_x, bool apply_y);
-void sp_selection_to_next_layer ();
-void sp_selection_to_prev_layer ();
+void sp_selection_to_next_layer( bool suppressDone = false );
+void sp_selection_to_prev_layer( bool suppressDone = false );
void sp_selection_apply_affine(Inkscape::Selection *selection, NR::Matrix const &affine, bool set_i2d = true);
void sp_selection_remove_transform (void);
diff --git a/src/verbs.cpp b/src/verbs.cpp
index a362d3c0f..4d859bab7 100644
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
@@ -37,6 +37,7 @@
#include <gtkmm/filechooserdialog.h>
#include <gtkmm/stock.h>
+#include "layer-manager.h"
#include "dialogs/text-edit.h"
#include "dialogs/xml-tree.h"
#include "dialogs/item-properties.h"
@@ -1219,6 +1220,31 @@ LayerVerb::perform(SPAction *action, void *data, void */*pdata*/)
break;
}
+ case SP_VERB_LAYER_DUPLICATE: {
+ if ( dt->currentLayer() != dt->currentRoot() ) {
+ SPObject *new_layer = Inkscape::create_layer(dt->currentRoot(), dt->currentLayer(), LPOS_BELOW);
+ if ( dt->currentLayer()->label() ) {
+ gchar* name = g_strdup_printf(_("%s copy"), dt->currentLayer()->label());
+ dt->layer_manager->renameLayer( new_layer, name );
+ g_free(name);
+ }
+
+ sp_edit_select_all();
+ sp_selection_duplicate(true);
+ sp_selection_to_prev_layer(true);
+ dt->setCurrentLayer(new_layer);
+ sp_edit_select_all();
+
+ sp_document_done(sp_desktop_document(dt), SP_VERB_LAYER_DUPLICATE,
+ _("Duplicate layer"));
+
+ // TRANSLATORS: this means "The layer has been duplicated."
+ dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Duplicated layer."));
+ } else {
+ dt->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("No current layer."));
+ }
+ break;
+ }
case SP_VERB_LAYER_DELETE: {
if ( dt->currentLayer() != dt->currentRoot() ) {
sp_desktop_selection(dt)->clear();
@@ -2379,9 +2405,11 @@ Verb *Verb::_base_verbs[] = {
N_("Raise the current layer"), "raise_layer"),
new LayerVerb(SP_VERB_LAYER_LOWER, "LayerLower", N_("_Lower Layer"),
N_("Lower the current layer"), "lower_layer"),
+ new LayerVerb(SP_VERB_LAYER_DUPLICATE, "LayerDuplicate", N_("Duplicate Current Layer..."),
+ N_("Duplicate an existing layer"), 0),
new LayerVerb(SP_VERB_LAYER_DELETE, "LayerDelete", N_("_Delete Current Layer"),
N_("Delete the current layer"), "delete_layer"),
- new LayerVerb(SP_VERB_LAYER_SOLO, "LayerSolo", N_("_Solo Current Layer"),
+ new LayerVerb(SP_VERB_LAYER_SOLO, "LayerSolo", N_("_Show/hide other layers"),
N_("Solo the current layer"), 0),
/* Object */
diff --git a/src/verbs.h b/src/verbs.h
index 198a25521..c16110922 100644
--- a/src/verbs.h
+++ b/src/verbs.h
@@ -128,6 +128,7 @@ enum {
SP_VERB_LAYER_TO_BOTTOM,
SP_VERB_LAYER_RAISE,
SP_VERB_LAYER_LOWER,
+ SP_VERB_LAYER_DUPLICATE,
SP_VERB_LAYER_DELETE,
SP_VERB_LAYER_SOLO,
/* Object */