summaryrefslogtreecommitdiff
path: root/grc/gui
diff options
context:
space:
mode:
Diffstat (limited to 'grc/gui')
-rw-r--r--grc/gui/ActionHandler.py27
-rw-r--r--grc/gui/Actions.py10
-rw-r--r--grc/gui/Bars.py2
3 files changed, 39 insertions, 0 deletions
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index b9f534fdf0..5d48485238 100644
--- a/grc/gui/ActionHandler.py
+++ b/grc/gui/ActionHandler.py
@@ -131,6 +131,7 @@ class ActionHandler:
for action in (
Actions.APPLICATION_QUIT, Actions.FLOW_GRAPH_NEW,
Actions.FLOW_GRAPH_OPEN, Actions.FLOW_GRAPH_SAVE_AS,
+ Actions.FLOW_GRAPH_DUPLICATE, Actions.FLOW_GRAPH_SAVE_A_COPY,
Actions.FLOW_GRAPH_CLOSE, Actions.ABOUT_WINDOW_DISPLAY,
Actions.FLOW_GRAPH_SCREEN_CAPTURE, Actions.HELP_WINDOW_DISPLAY,
Actions.TYPES_WINDOW_DISPLAY, Actions.TOGGLE_BLOCKS_WINDOW,
@@ -561,6 +562,32 @@ class ActionHandler:
Preferences.add_recent_file(file_path)
main.tool_bar.refresh_submenus()
main.menu_bar.refresh_submenus()
+ elif action == Actions.FLOW_GRAPH_SAVE_A_COPY:
+ try:
+ if not page.get_file_path():
+ Actions.FLOW_GRAPH_SAVE_AS()
+ else:
+ dup_file_path = page.get_file_path()
+ dup_file_name = '.'.join(dup_file_path.split('.')[:-1]) + "_copy" # Assuming .grc extension at the end of file_path
+ dup_file_path_temp = dup_file_name+'.grc'
+ count = 1
+ while os.path.exists(dup_file_path_temp):
+ dup_file_path_temp = dup_file_name+'('+str(count)+').grc'
+ count += 1
+ dup_file_path_user = SaveFlowGraphFileDialog(dup_file_path_temp).run()
+ if dup_file_path_user is not None:
+ ParseXML.to_file(flow_graph.export_data(), dup_file_path_user)
+ Messages.send('Saved Copy to: "' + dup_file_path_user + '"\n')
+ except IOError:
+ Messages.send_fail_save("Can not create a copy of the flowgraph\n")
+ elif action == Actions.FLOW_GRAPH_DUPLICATE:
+ flow_graph = main.get_flow_graph()
+ main.new_page()
+ curr_page = main.get_page()
+ new_flow_graph = main.get_flow_graph()
+ new_flow_graph.import_data(flow_graph.export_data())
+ flow_graph_update(new_flow_graph)
+ curr_page.set_saved(False)
elif action == Actions.FLOW_GRAPH_SCREEN_CAPTURE:
file_path, background_transparent = SaveScreenShotDialog(page.get_file_path()).run()
if file_path is not None:
diff --git a/grc/gui/Actions.py b/grc/gui/Actions.py
index 9b2af36b93..6eccab75fb 100644
--- a/grc/gui/Actions.py
+++ b/grc/gui/Actions.py
@@ -203,6 +203,16 @@ FLOW_GRAPH_SAVE_AS = Action(
stock_id=gtk.STOCK_SAVE_AS,
keypresses=(gtk.keysyms.s, gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK),
)
+FLOW_GRAPH_SAVE_A_COPY = Action(
+ label='Save A Copy',
+ tooltip='Save the copy of current flowgraph',
+)
+FLOW_GRAPH_DUPLICATE = Action(
+ label='_Duplicate',
+ tooltip='Create a duplicate of current flowgraph',
+ stock_id=gtk.STOCK_COPY,
+ keypresses=(gtk.keysyms.d, gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK),
+)
FLOW_GRAPH_CLOSE = Action(
label='_Close',
tooltip='Close the current flow graph',
diff --git a/grc/gui/Bars.py b/grc/gui/Bars.py
index a4819b973c..d9bc2aedb7 100644
--- a/grc/gui/Bars.py
+++ b/grc/gui/Bars.py
@@ -64,11 +64,13 @@ TOOLBAR_LIST = (
MENU_BAR_LIST = (
(gtk.Action('File', '_File', None, None), [
'flow_graph_new',
+ Actions.FLOW_GRAPH_DUPLICATE,
Actions.FLOW_GRAPH_OPEN,
'flow_graph_recent',
None,
Actions.FLOW_GRAPH_SAVE,
Actions.FLOW_GRAPH_SAVE_AS,
+ Actions.FLOW_GRAPH_SAVE_A_COPY,
None,
Actions.FLOW_GRAPH_SCREEN_CAPTURE,
None,