commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 01/04: grc: Add 'Create Duplicate' feature


From: git
Subject: [Commit-gnuradio] [gnuradio] 01/04: grc: Add 'Create Duplicate' feature
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 b75e16ff8b20957512b660640eb6567c0395b89d
Author: Kartik Patel <address@hidden>
Date:   Wed Jan 25 16:03:25 2017 +0530

    grc: Add 'Create Duplicate' feature
---
 grc/gui/ActionHandler.py |  6 ++++--
 grc/gui/Actions.py       |  6 ++++++
 grc/gui/Bars.py          |  1 +
 grc/gui/MainWindow.py    |  8 ++++++--
 grc/gui/NotebookPage.py  | 20 +++++++++++++-------
 5 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index b9f534f..cab484d 100644
--- a/grc/gui/ActionHandler.py
+++ b/grc/gui/ActionHandler.py
@@ -30,7 +30,6 @@ 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()
@@ -130,7 +129,7 @@ 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_OPEN, Actions.FLOW_GRAPH_SAVE_AS, 
Actions.FLOW_GRAPH_DUPLICATE,
                 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 +560,9 @@ class ActionHandler:
                 Preferences.add_recent_file(file_path)
                 main.tool_bar.refresh_submenus()
                 main.menu_bar.refresh_submenus()
+        elif action == Actions.FLOW_GRAPH_DUPLICATE:
+            curr_flow_graph = main.get_flow_graph()
+            main.new_page(flow_graph = curr_flow_graph)
         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 9b2af36..a553c49 100644
--- a/grc/gui/Actions.py
+++ b/grc/gui/Actions.py
@@ -203,6 +203,12 @@ 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_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 a4819b9..2b182ea 100644
--- a/grc/gui/Bars.py
+++ b/grc/gui/Bars.py
@@ -69,6 +69,7 @@ MENU_BAR_LIST = (
         None,
         Actions.FLOW_GRAPH_SAVE,
         Actions.FLOW_GRAPH_SAVE_AS,
+        Actions.FLOW_GRAPH_DUPLICATE,
         None,
         Actions.FLOW_GRAPH_SCREEN_CAPTURE,
         None,
diff --git a/grc/gui/MainWindow.py b/grc/gui/MainWindow.py
index 686e73c..50ba383 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='', show=False):
+    def new_page(self, file_path='', flow_graph = None, show=False):
         """
         Create a new notebook page.
         Set the tab to be selected.
@@ -263,13 +263,17 @@ class MainWindow(gtk.Window):
             return
         try: #try to load from file
             if file_path: Messages.send_start_load(file_path)
-            flow_graph = self._platform.get_new_flow_graph()
+            is_blank = False
+            if not flow_graph:
+                flow_graph = self._platform.get_new_flow_graph()
+                is_blank = True
             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 c9e8d0f..417e724 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=''):
+    def __init__(self, main_window, flow_graph, file_path='', is_blank = True):
         """
         Page constructor.
 
@@ -38,16 +38,22 @@ class NotebookPage(gtk.HBox):
             main_window: main window
             file_path: path to a flow graph file
         """
-        self._flow_graph = flow_graph
+        self._flow_graph = FlowGraph(platform=flow_graph.platform)
         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
-        self.get_flow_graph().import_data(initial_state)
+        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
         #initialize page gui
         gtk.HBox.__init__(self, False, 0)
         self.show()



reply via email to

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