commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 02/04: grc: 'Save a copy' feature added


From: git
Subject: [Commit-gnuradio] [gnuradio] 02/04: grc: 'Save a copy' feature added
Date: Thu, 16 Mar 2017 04:17:02 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit 6dca1fb5af51fe508ce5e4ad7872cf468654c6bb
Author: Kartik Patel <address@hidden>
Date:   Thu Jan 26 02:34:44 2017 +0530

    grc: 'Save a copy' feature added
---
 grc/gui/ActionHandler.py | 20 +++++++++++++++++++-
 grc/gui/Actions.py       |  4 ++++
 grc/gui/Bars.py          |  1 +
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index cab484d..dc5f3e2 100644
--- a/grc/gui/ActionHandler.py
+++ b/grc/gui/ActionHandler.py
@@ -30,6 +30,7 @@ from .FileDialogs import (OpenFlowGraphFileDialog, 
SaveFlowGraphFileDialog,
 from .MainWindow import MainWindow
 from .ParserErrorsDialog import ParserErrorsDialog
 from .PropsDialog import PropsDialog
+
 from ..core import ParseXML, Messages
 
 gobject.threads_init()
@@ -129,7 +130,8 @@ class ActionHandler:
                 action.set_sensitive(False)  # set all actions disabled
             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_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,
@@ -560,6 +562,22 @@ 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
+                    ParseXML.to_file(flow_graph.export_data(), 
dup_file_path_temp)
+                    Messages.send("Successfully copied to " + 
dup_file_path_temp)
+            except IOError:
+                Messages.send_fail_save("Can not create a copy of the 
flowgraph")
         elif action == Actions.FLOW_GRAPH_DUPLICATE:
             curr_flow_graph = main.get_flow_graph()
             main.new_page(flow_graph = curr_flow_graph)
diff --git a/grc/gui/Actions.py b/grc/gui/Actions.py
index a553c49..6eccab7 100644
--- a/grc/gui/Actions.py
+++ b/grc/gui/Actions.py
@@ -203,6 +203,10 @@ 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',
diff --git a/grc/gui/Bars.py b/grc/gui/Bars.py
index 2b182ea..c17adf8 100644
--- a/grc/gui/Bars.py
+++ b/grc/gui/Bars.py
@@ -70,6 +70,7 @@ MENU_BAR_LIST = (
         Actions.FLOW_GRAPH_SAVE,
         Actions.FLOW_GRAPH_SAVE_AS,
         Actions.FLOW_GRAPH_DUPLICATE,
+        Actions.FLOW_GRAPH_SAVE_A_COPY,
         None,
         Actions.FLOW_GRAPH_SCREEN_CAPTURE,
         None,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]