diff options
-rw-r--r-- | grc/gui/ActionHandler.py | 19 | ||||
-rw-r--r-- | grc/gui/Bars.py | 2 | ||||
-rw-r--r-- | grc/gui/MainWindow.py | 8 | ||||
-rw-r--r-- | grc/gui/NotebookPage.py | 20 |
4 files changed, 23 insertions, 26 deletions
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py index dc5f3e287d..5d48485238 100644 --- a/grc/gui/ActionHandler.py +++ b/grc/gui/ActionHandler.py @@ -571,16 +571,23 @@ class ActionHandler: 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)): + 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) + 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") + Messages.send_fail_save("Can not create a copy of the flowgraph\n") elif action == Actions.FLOW_GRAPH_DUPLICATE: - curr_flow_graph = main.get_flow_graph() - main.new_page(flow_graph = curr_flow_graph) + 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/Bars.py b/grc/gui/Bars.py index c17adf83a4..d9bc2aedb7 100644 --- a/grc/gui/Bars.py +++ b/grc/gui/Bars.py @@ -64,12 +64,12 @@ 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_DUPLICATE, Actions.FLOW_GRAPH_SAVE_A_COPY, None, Actions.FLOW_GRAPH_SCREEN_CAPTURE, diff --git a/grc/gui/MainWindow.py b/grc/gui/MainWindow.py index 50ba3839e2..686e73cfa3 100644 --- a/grc/gui/MainWindow.py +++ b/grc/gui/MainWindow.py @@ -247,7 +247,7 @@ class MainWindow(gtk.Window): # Pages: create and close ############################################################ - def new_page(self, file_path='', flow_graph = None, show=False): + def new_page(self, file_path='', show=False): """ Create a new notebook page. Set the tab to be selected. @@ -263,17 +263,13 @@ class MainWindow(gtk.Window): return try: #try to load from file if file_path: Messages.send_start_load(file_path) - is_blank = False - if not flow_graph: - flow_graph = self._platform.get_new_flow_graph() - is_blank = True + flow_graph = self._platform.get_new_flow_graph() flow_graph.grc_file_path = file_path #print flow_graph page = NotebookPage( self, flow_graph=flow_graph, file_path=file_path, - is_blank = is_blank ) if file_path: Messages.send_end_load() except Exception, e: #return on failure diff --git a/grc/gui/NotebookPage.py b/grc/gui/NotebookPage.py index 417e7245ba..c9e8d0f186 100644 --- a/grc/gui/NotebookPage.py +++ b/grc/gui/NotebookPage.py @@ -25,12 +25,12 @@ from StateCache import StateCache from Constants import MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT from DrawingArea import DrawingArea import os -from FlowGraph import FlowGraph + class NotebookPage(gtk.HBox): """A page in the notebook.""" - def __init__(self, main_window, flow_graph, file_path='', is_blank = True): + def __init__(self, main_window, flow_graph, file_path=''): """ Page constructor. @@ -38,22 +38,16 @@ class NotebookPage(gtk.HBox): main_window: main window file_path: path to a flow graph file """ - self._flow_graph = FlowGraph(platform=flow_graph.platform) + self._flow_graph = flow_graph self.process = None #import the file self.main_window = main_window self.file_path = file_path + initial_state = flow_graph.get_parent().parse_flow_graph(file_path) + self.state_cache = StateCache(initial_state) + self.saved = True #import the data to the flow graph - if is_blank: - initial_state = flow_graph.get_parent().parse_flow_graph(file_path) - self.state_cache = StateCache(initial_state) - self.get_flow_graph().import_data(initial_state) - self.saved = True - else: - initial_state = flow_graph.export_data() - self.state_cache = StateCache(initial_state) - self.get_flow_graph().import_data(initial_state) - self.saved = False + self.get_flow_graph().import_data(initial_state) #initialize page gui gtk.HBox.__init__(self, False, 0) self.show() |