commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r7624 - in grc/branches/grc_reloaded/src/grc: . elemen


From: jblum
Subject: [Commit-gnuradio] r7624 - in grc/branches/grc_reloaded/src/grc: . elements gui gui/elements
Date: Sat, 9 Feb 2008 22:37:21 -0700 (MST)

Author: jblum
Date: 2008-02-09 22:37:20 -0700 (Sat, 09 Feb 2008)
New Revision: 7624

Modified:
   grc/branches/grc_reloaded/src/grc/ActionHandler.py
   grc/branches/grc_reloaded/src/grc/Constants.py
   grc/branches/grc_reloaded/src/grc/Preferences.py
   grc/branches/grc_reloaded/src/grc/StateCache.py
   grc/branches/grc_reloaded/src/grc/__init__.py
   grc/branches/grc_reloaded/src/grc/elements/Element.py
   grc/branches/grc_reloaded/src/grc/elements/FlowGraph.py
   grc/branches/grc_reloaded/src/grc/elements/Platform.py
   grc/branches/grc_reloaded/src/grc/gui/Bars.py
   grc/branches/grc_reloaded/src/grc/gui/Dialogs.py
   grc/branches/grc_reloaded/src/grc/gui/DrawingArea.py
   grc/branches/grc_reloaded/src/grc/gui/FileDialogs.py
   grc/branches/grc_reloaded/src/grc/gui/MainWindow.py
   grc/branches/grc_reloaded/src/grc/gui/SignalBlockSelectionWindow.py
   grc/branches/grc_reloaded/src/grc/gui/USRPDiagnostics.py
   grc/branches/grc_reloaded/src/grc/gui/elements/Block.py
   grc/branches/grc_reloaded/src/grc/gui/elements/Element.py
   grc/branches/grc_reloaded/src/grc/gui/elements/FlowGraph.py
   grc/branches/grc_reloaded/src/grc/gui/elements/Param.py
   grc/branches/grc_reloaded/src/grc/gui/elements/Port.py
Log:
windows up

Modified: grc/branches/grc_reloaded/src/grc/ActionHandler.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/ActionHandler.py  2008-02-09 23:38:18 UTC 
(rev 7623)
+++ grc/branches/grc_reloaded/src/grc/ActionHandler.py  2008-02-10 05:37:20 UTC 
(rev 7624)
@@ -26,7 +26,7 @@
 import pygtk
 pygtk.require('2.0')
 import gtk
-import Graphics
+import gui
 import Preferences
 from threading import Thread
 import Messages
@@ -39,27 +39,27 @@
        and handle button presses and flow graph operations from the GUI.
        """
        
-       def __init__(self, file_paths): 
+       def __init__(self, file_paths, platform): 
                """!
                ActionHandler constructor.
                Create the main window, setup the message handler, import the 
preferences, 
                and connect all of the action handlers. Finally, enter the gtk 
main loop and block.
                @param file_paths a list of flow graph file passed from command 
line            
                """                             
-               if PY_GTK_ICON: 
gtk.window_set_default_icon_from_file(PY_GTK_ICON)
+               #TODO if PY_GTK_ICON: 
gtk.window_set_default_icon_from_file(PY_GTK_ICON)
                for action in ACTIONS_LIST: action.connect('activate', 
self._handle_actions)
                #setup the main window
-               self.main_window = Graphics.MainWindow(self.handle_states)
+               self.main_window = gui.MainWindow(self.handle_states, platform)
                self.main_window.connect('delete_event', self._quit)
                self.main_window.connect('key_press_event', 
self._handle_key_press)
+               self.get_page = self.main_window.get_page
                self.get_flow_graph = self.main_window.get_flow_graph
-               self.get_page = self.main_window.get_page
                #setup the messages
                Messages.register_messenger(self.main_window.add_report_line)
                Messages.register_messenger(sys.stdout.write)
                Messages.send_init()
                #flow graph settings    
-               Preferences.load(self.main_window)      
+               #Preferences.load(self.main_window)     
                self.init_file_paths = file_paths
                self.handle_states(APPLICATION_INITIALIZE)
                #enter the mainloop             
@@ -141,7 +141,7 @@
        def handle_states(self, state=''):
                """!
                Handle the state changes in the GUI.            
-               Handle all of the state changes that arise from the action 
handler or other Graphics and 
+               Handle all of the state changes that arise from the action 
handler or other gui and 
                inputs in the application. The state passed to the 
handle_states method is a string descriping 
                the change. A series of if/elif statements handle the state by 
greying out action buttons, causing 
                changes in the flow graph, saving/opening files...      The 
handle_states method is passed to the
@@ -154,13 +154,13 @@
                if state == APPLICATION_INITIALIZE:     
                        for action in ACTIONS_LIST: action.set_sensitive(False) 
#set all actions disabled
                        # enable a select few actions 
-                       Graphics.enable_usrp_diagnostics()      #try to enable 
usrp diagnostics
+                       gui.enable_usrp_diagnostics()   #try to enable usrp 
diagnostics
                        for action in (
                                APPLICATION_QUIT, FLOW_GRAPH_NEW, 
FLOW_GRAPH_OPEN, FLOW_GRAPH_SAVE_AS, FLOW_GRAPH_CLOSE,
                                ABOUT_WINDOW_DISPLAY, 
DATA_TYPES_WINDOW_DISPLAY, HOTKEYS_WINDOW_DISPLAY, MATH_EXPR_WINDOW_DISPLAY,
                                FLOW_GRAPH_WINDOW_RESIZE, PREFS_WINDOW_DISPLAY, 
FLOW_GRAPH_SCREEN_CAPTURE,
                        ): get_action_from_name(action).set_sensitive(True)     
        
-                       if not self.init_file_paths and 
Preferences.restore_files(): self.init_file_paths = Preferences.files_open()
+                       #TODO if not self.init_file_paths and 
Preferences.restore_files(): self.init_file_paths = Preferences.files_open()
                        if not self.init_file_paths: self.init_file_paths = ['']
                        for file_path in self.init_file_paths: 
self.main_window.new_page(file_path) #load pages from file paths
                        if not self.get_page(): self.main_window.new_page() 
#ensure that at least a blank page exists
@@ -226,20 +226,20 @@
                #       Window stuff
                
##############################################################################################
                elif state == USRP_DIAGNOSTICS_DISPLAY:
-                       Graphics.USRPDiagnosticsDialog()                
+                       gui.USRPDiagnosticsDialog()             
                elif state == PREFS_WINDOW_DISPLAY:
-                       Graphics.PreferencesDialog()
+                       gui.PreferencesDialog()
                        self.get_flow_graph().update()
                elif state == ABOUT_WINDOW_DISPLAY:
-                       Graphics.AboutDialog()
+                       gui.AboutDialog()
                elif state == DATA_TYPES_WINDOW_DISPLAY:
-                       Graphics.DataTypesDialog()
+                       gui.DataTypesDialog()
                elif state == HOTKEYS_WINDOW_DISPLAY:
-                       Graphics.HotKeysDialog()
+                       gui.HotKeysDialog()
                elif state == MATH_EXPR_WINDOW_DISPLAY:
-                       Graphics.MathExprDialog()
+                       gui.MathExprDialog()
                elif state == FLOW_GRAPH_WINDOW_RESIZE:
-                       dimensions = 
Graphics.FlowGraphWindowSizeDialog(self.get_flow_graph().get_size_request()).run()
+                       dimensions = 
gui.FlowGraphWindowSizeDialog(self.get_flow_graph().get_size_request()).run()
                        if dimensions:
                                
self.get_flow_graph().set_size_request(*dimensions)
                                
self.get_page().get_state_cache().save_new_state(self.get_flow_graph().to_nested_data())
                                        
@@ -279,7 +279,7 @@
                elif state == FLOW_GRAPH_NEW:
                        self.main_window.new_page()
                elif state == FLOW_GRAPH_OPEN:
-                       file_path = 
Graphics.OpenFlowGraphFileDialog(self.get_flow_graph() and 
self.get_page().get_file_path() or '').run()
+                       file_path = 
gui.OpenFlowGraphFileDialog(self.get_flow_graph() and 
self.get_page().get_file_path() or '').run()
                        if file_path != None: 
self.main_window.new_page(file_path, manual_open=True)
                elif state == FLOW_GRAPH_CLOSE:
                        self.main_window.close_page()           
@@ -293,12 +293,12 @@
                                        
Messages.send_fail_save(self.get_page().get_file_path())
                                        self.get_page().set_saved(False)
                elif state == FLOW_GRAPH_SAVE_AS:
-                       file_path = 
Graphics.SaveFlowGraphFileDialog(self.get_page().get_file_path()).run()
+                       file_path = 
gui.SaveFlowGraphFileDialog(self.get_page().get_file_path()).run()
                        if file_path != None:                   
                                self.get_page().set_file_path(file_path)
                                self.handle_states(FLOW_GRAPH_SAVE)     
                elif state == FLOW_GRAPH_SCREEN_CAPTURE:
-                       file_path = 
Graphics.SaveImageFileDialog(self.get_page().get_file_path()).run()
+                       file_path = 
gui.SaveImageFileDialog(self.get_page().get_file_path()).run()
                        if file_path != None: 
                                pixmap = self.get_flow_graph().pixmap
                                width, height = pixmap.get_size()
@@ -336,7 +336,9 @@
                Lock and unlock the mutex for race conditions with exec flow 
graph threads.
                """
                MUTEX.lock()
-               
get_action_from_name(FLOW_GRAPH_EXEC).set_sensitive(self.get_flow_graph().is_valid()
 and not self.get_page().get_pid_file())
+               get_action_from_name(FLOW_GRAPH_EXEC).set_sensitive(
+                       self.get_flow_graph().is_valid() and not 
self.get_page().get_pid_file()
+               )
                
get_action_from_name(FLOW_GRAPH_STOP).set_sensitive(self.get_page().get_pid_file()
 != '')       
                MUTEX.unlock()
                        

Modified: grc/branches/grc_reloaded/src/grc/Constants.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/Constants.py      2008-02-09 23:38:18 UTC 
(rev 7623)
+++ grc/branches/grc_reloaded/src/grc/Constants.py      2008-02-10 05:37:20 UTC 
(rev 7624)
@@ -1 +1,209 @@
+"""
+Copyright 2007 Free Software Foundation, Inc.
+This file is part of GNU Radio
 
+GNU Radio Companion is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+GNU Radio Companion is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+"""
address@hidden Constants
+#Global constants
address@hidden Josh Blum
+
+import sys, os
+import mutex
+
+##mutex used when running a flow graph.
+MUTEX = mutex.mutex()  
+def lock(mutex):
+       while not mutex.testandset(): pass      #try to lock repeatedly until 
lock is aquired
+MUTEX.lock = lambda: lock(MUTEX)
+
+######################################################################################################
+## Global Titles @{
+######################################################################################################
+
+##The current version of this code
+VERSION = 'reloaded (alpha)'
+
+##The name to appear in the main window for a flow graph that has not been 
saved to file.
+NEW_FLOGRAPH_TITLE = 'untitled'
+
+##The prefix title on the main window.
+MAIN_WINDOW_PREFIX = "GRC"
address@hidden
+
+######################################################################################################
+## Signal block connector lengths
+######################################################################################################
+
+##The length that a connection must extend from the socket until the length 
depends on the index of the socket.
+CONNECTOR_EXTENSION_INITIAL_LENGTH = 11
+
+##The length that a connection must extend from the initial length times the 
index of the socket, after this length, the connection may have a bend.
+CONNECTOR_EXTENSION_LENGTH = 11
+
+######################################################################################################
+## Signal block rotations
+######################################################################################################
+
+##List of possible angles (in degrees) that a signal block and its parameters 
can be rotated to.
+POSSIBLE_ROTATIONS = (0, 90, 180, 270)
+
+##direction of rotation left.
+DIR_LEFT = 'left'
+
+##direction of rotation right.
+DIR_RIGHT = 'right'
+
+######################################################################################################
+## Dimension constraints for the various windows (in pixels)
+######################################################################################################
+
+##main window constraints      @{
+DEFAULT_MAIN_WINDOW_WIDTH = 750
+
+DEFAULT_MAIN_WINDOW_HEIGHT = 550
address@hidden
+
+##flow graph window constraints        @{
+MIN_WINDOW_WIDTH = 600
+MAX_WINDOW_WIDTH = 2400
+
+MIN_WINDOW_HEIGHT = 400
+MAX_WINDOW_HEIGHT = 1800
address@hidden
+
+##dialog constraints   @{
+MIN_DIALOG_WIDTH = 400
+MIN_DIALOG_HEIGHT = 500
address@hidden
+
+##misc window constraints      @{
+REPORTS_WINDOW_HEIGHT = 80
+
+SIGNAL_BLOCK_SELECTION_WINDOW_WIDTH = 250
+SIGNAL_BLOCK_SELECTION_WINDOW_HEIGHT = 250
+
+VARIABLE_MODIFICATION_WINDOW_WIDTH = 250
+VARIABLE_MODIFICATION_WINDOW_HEIGHT = 150
address@hidden
+
+######################################################################################################
+## Constraints for the sliders in the runnable flow graph @{
+######################################################################################################
+
+##The number of tics for a slider.
+DEFAULT_SLIDER_STEPS = 100
+
+##The max width that a row of sliders can use.
+MAX_SLIDERS_WIDTH = 600
+
+##Slider width in pixels
+DEFAULT_SLIDER_WIDTH = 200
+##Slider width in pixels
+MAX_SLIDER_WIDTH = 300
+##Slider width in pixels
+MIN_SLIDER_WIDTH = 100
+
+##The height in pixels.
+SLIDER_HEIGHT = 20
address@hidden
+
+######################################################################################################
+## Constraints on displayable labels and sockets @{
+######################################################################################################
+
+LABEL_SEPARATION = 4
+LABEL_PADDING_WIDTH=20
+LABEL_PADDING_HEIGHT=10
+
+SOCKET_SEPARATION = 20
+SOCKET_HEIGHT = 17
+SOCKET_WIDTH = 27
+SOCKET_BORDER_SEPARATION = 10
+
+PARAM_FONT = 'Sans 8'
+SIGNAL_BLOCK_FONT = 'Sans 9 Bold'
+SOCKET_FONT = 'Sans 8'
address@hidden
+
+######################################################################################################
+## Dragging, scrolling, and redrawing constants for the flow graph window in 
pixels @{
+######################################################################################################
+
+##How close can the mouse get to the window border before mouse events are 
ignored.
+BORDER_PROXIMITY_SENSITIVITY = 10
+
+##How close the mouse can get to the edge of the visible window before 
scrolling is invoked.
+SCROLL_PROXIMITY_SENSITIVITY = 30
+
+##When the window has to be scrolled, move it this distance in the required 
direction.
+SCROLL_DISTANCE = 15
+
+##The redrawing sensitivity, how many motion detection events must occur 
before a redraw?
+MOTION_DETECT_REDRAWING_SENSITIVITY = 3
+
+##How close the mouse click can be to a connection and register a connection 
select.
+CONNECTION_SELECT_SENSITIVITY = 5
address@hidden
+
+######################################################################################################
+#      A state is recorded for each change to the flow graph, the size 
dictates how many states we can record 
+######################################################################################################
+
+##The size of the state saving cache in the flow graph (for undo/redo 
functionality)
+STATE_CACHE_SIZE = 42
+
+######################################################################################################
+## Constansts dealing with File Paths @{
+######################################################################################################
+
+##Location of the python src directory.
+SRC_DIR = os.path.abspath(os.path.dirname(__file__))
+
+##Location of external data files.
+DATA_DIR = os.path.abspath(SRC_DIR+'/../data/')
+
+##The setting for a blank flow graph.
+INITIAL_FLOW_GRAPH_FILE = 
os.path.abspath(DATA_DIR+'/initial_flow_graph.grc.xml')
+
+##The default file extension for flow graphs.
+FLOW_GRAPH_FILE_EXTENSION = '.grc.xml'
+
+##The default file extension for saving flow graph snap shots.
+IMAGE_FILE_EXTENSION = '.png'
+
+##The default path for the open/save dialogs.
+DEFAULT_FILE_PATH = os.path.expanduser('~')+'/'
+
+##The default icon for the gtk windows.
+PY_GTK_ICON = os.path.abspath(DATA_DIR+'/grc-icon-256.png')
+
+##The default icon for the wx windows.
+WX_APP_ICON = os.path.abspath(DATA_DIR+'/grc-icon-32.png')
+#>>> platform dependency! wx under cygwin has issues with icon paths   #
+if sys.platform == 'cygwin': WX_APP_ICON = None
+
+##The default binary to execute python files.
+PYEXEC = 'python'
+#>>> platform dependency! MacOS requires pythonw to run wx apps        #
+if sys.platform == 'darwin': PYEXEC = 'pythonw'
+
+##The default command to run a flow graph file.
+DEFAULT_FLOW_GRAPH_EXEC = '%s %s/ExecFlowGraphGUI.py'%(PYEXEC, SRC_DIR)
+
+##The default user preferences file.
+PREFERENCES_FILE_PATH = os.path.abspath(DEFAULT_FILE_PATH + '/.grc.xml')
address@hidden
+

Modified: grc/branches/grc_reloaded/src/grc/Preferences.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/Preferences.py    2008-02-09 23:38:18 UTC 
(rev 7623)
+++ grc/branches/grc_reloaded/src/grc/Preferences.py    2008-02-10 05:37:20 UTC 
(rev 7624)
@@ -20,177 +20,10 @@
 #Holds global preferences stored as GraphicalParams.
 address@hidden Josh Blum
 
-from DataTypes import Bool,Enum,Int,String
-from Elements import GraphicalParam, Param
 import time,socket #for tagging saved files
 from Constants import *
 import ParseXML
 import Messages
+import os
 
-FILE_DELIMITER = '\n'
 
-PARAM_CHECKING_PREF = GraphicalParam('Parameter Checking', Bool(true='Verify 
Parameters', false='Ignore Invalid Params', default=True))
-CONNECTION_CHECKING_PREF = GraphicalParam('Connection Checking', 
Bool(true='Match Data Types', false='Ignore Data Types', default=True))
-SOCKET_CHECKING_PREF = GraphicalParam('Socket Checking', Bool(true='Require 
Connections', false='Allow Open Sockets', default=True))
-FILES_OPEN_PREF = Param('Files Open', String())
-RESTORE_FILES_PREF = GraphicalParam('Restore Files', Bool(true='Restore 
Previous Files', false='Restore Nothing', default=True))
-SNAP_TO_GRID_PREF = GraphicalParam('Snap to Grid', Bool(true='On', 
false='Off', default=False))
-GRID_SIZE_PREF = GraphicalParam('Grid Size (pixels)', Enum([
-       ('10 pixels', 10), 
-       ('20 pixels', 20), 
-       ('30 pixels', 30),
-       ('40 pixels', 40),
-       ('50 pixels', 50),
-       ('60 pixels', 60),
-       ('70 pixels', 70),
-       ('80 pixels', 80),
-       ('90 pixels', 90),
-       ('100 pixels', 100),], 2))
-SHOW_GRID_PREF = GraphicalParam('Grid Points', Bool(true='Show Grid', 
false='Hide Grid', default=False))
-REPORTS_WIN_SHOW_PREF = GraphicalParam('Reports Window', Bool(true='Show 
Reports Window', false='Hide Reports Window', default=True))
-MAIN_WINDOW_WIDTH_PREF = Param('Main Window Width', 
Int(DEFAULT_MAIN_WINDOW_WIDTH))
-MAIN_WINDOW_HEIGHT_PREF = Param('Main Window Height', 
Int(DEFAULT_MAIN_WINDOW_HEIGHT))
-
-###########################################################################
-#      List of Preferences
-###########################################################################
-
-PREFS_LIST = [ #(title, notes, list of preferences)
-       ("Verification", '''\
-Verification ensures that:
-       signal block parameters pass validation,
-       data types on either side of a connection match,
-       and input/output sockets connect.
-       
-You may disable any one of these validation checks. \
-However, the resulting flow graph may fail execution. \
-''', [ 
-                       (PARAM_CHECKING_PREF, 'param_check'),
-                       (CONNECTION_CHECKING_PREF, 'connection_check'),
-                       (SOCKET_CHECKING_PREF, 'socket_check'),
-               ]
-       ),
-       ("Grid Options", '''\
-Snap to Grid forces the upper right corner of the signal block to align with a 
grid point. \
-''', [
-                       (SNAP_TO_GRID_PREF, 'snap_to_grid'),
-                       (GRID_SIZE_PREF, 'grid_size'),
-                       (SHOW_GRID_PREF, 'show_grid'),
-               ]
-       ),
-       ("Misc Options", '', [
-                       (REPORTS_WIN_SHOW_PREF, 'show_reports_window'),
-                       (RESTORE_FILES_PREF, 'restore_files'),
-               ]
-       ),      
-       ('', '', [      #put hidden prefs here
-                       (FILES_OPEN_PREF, 'files_open'),
-                       (MAIN_WINDOW_WIDTH_PREF, 'window_width'),
-                       (MAIN_WINDOW_HEIGHT_PREF, 'window_height'),
-               ]
-       ),      
-]
-       
-PREFS_DICT = dict((key, param) for param, key in reduce(lambda l1, l2: l1 + 
l2, zip(*PREFS_LIST)[2]))
-
-###########################################################################
-#      Preference Access Methods
-###########################################################################
-
-def _get_value(param):
-       """!
-       Get the value of the given parameter.
-       If the param is valid, return the parsed value of the param, otherwise 
return a blank string.   
-       @param param the parameter
-       @return the value of the parameter
-       """
-       if param.get_data_type().is_valid(): return 
param.get_data_type().parse()
-       else: return ''
-       
-def _to_nested():
-       """!
-       Convert the param's data to nested format.
-       @return the nested format
-       """
-       prefs = [('pref', [('key', key), ('value', 
param.get_data_type().get_data())]) for key,param in PREFS_DICT.iteritems()]
-       nested_data = ('preferences', [
-                       ('timestamp', str(time.time())),
-                       ('hostname', socket.gethostname()),
-                       ('version', VERSION),                                   
                                                
-                       ('prefs', prefs),
-               ]
-       )       
-       return nested_data
-       
-def _from_nested(nested_data):
-       """!
-       Parse the nested data to retrieve each preference.
-       @param nested_data the nested data
-       """
-       find_data = ParseXML.find_data
-       preferences = find_data([nested_data], 'preferences')
-       prefs = find_data(preferences, 'prefs')
-       for pref in prefs:
-               pref = find_data([pref], 'pref')
-               key = find_data(pref, 'key')
-               value = find_data(pref, 'value')
-               try: PREFS_DICT[key].get_data_type().set_data(value)
-               except: pass
-               
-def load(window=None):
-       """!
-       Load the preferences from the preferences file.
-       @param window optional flow graph window
-       """
-       try: 
-               
_from_nested(ParseXML.from_xml(ParseXML.from_file(PREFERENCES_FILE_PATH)))
-               if window: window.resize(_get_value(MAIN_WINDOW_WIDTH_PREF), 
_get_value(MAIN_WINDOW_HEIGHT_PREF))
-       except: Messages.send_fail_load_preferences()           
-
-def save(window=None):
-       """!
-       Save the preferences to the preferences file.
-       @param window optional flow graph window
-       """
-       if window:
-               width,height = window.get_size()
-               MAIN_WINDOW_WIDTH_PREF.get_data_type().set_data(width)
-               MAIN_WINDOW_HEIGHT_PREF.get_data_type().set_data(height)
-       try: ParseXML.to_file(ParseXML.to_xml(_to_nested()), 
PREFERENCES_FILE_PATH)             
-       except IOError: Messages.send_fail_save_preferences()
-               
-###########################################################################
-#      Special methods for specific program functionalities
-###########################################################################
-       
-def restore_files():
-       return _get_value(RESTORE_FILES_PREF)   
-       
-def files_open():
-       return _get_value(FILES_OPEN_PREF).split(FILE_DELIMITER)
-       
-def save_files_open(files):
-       FILES_OPEN_PREF.get_data_type().set_data(FILE_DELIMITER.join(files))
-       
-def check_connections():
-       return _get_value(CONNECTION_CHECKING_PREF)
-       
-def check_sockets():
-       return _get_value(SOCKET_CHECKING_PREF)
-
-def check_params():
-       return _get_value(PARAM_CHECKING_PREF)
-       
-def show_reports_window():
-       return _get_value(REPORTS_WIN_SHOW_PREF)
-       
-def get_grid_size():
-       return _get_value(GRID_SIZE_PREF)       
-       
-def snap_to_grid():
-       return _get_value(SNAP_TO_GRID_PREF)
-       
-def show_grid():
-       return _get_value(SHOW_GRID_PREF)
-               
-       
\ No newline at end of file

Modified: grc/branches/grc_reloaded/src/grc/StateCache.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/StateCache.py     2008-02-09 23:38:18 UTC 
(rev 7623)
+++ grc/branches/grc_reloaded/src/grc/StateCache.py     2008-02-10 05:37:20 UTC 
(rev 7624)
@@ -21,21 +21,22 @@
 address@hidden Josh Blum
 
 from Actions import FLOW_GRAPH_UNDO, FLOW_GRAPH_REDO, get_action_from_name
-from Constants import STATE_CACHE_SIZE
 
-class StateCache:
+DEFAULT_STATE_CACHE_SIZE = 42
+
+class StateCache(object):
        """
        The state cache is an interface to a list to record data/states and to 
revert to previous states.
        States are recorded into the list in a circular fassion by using an 
index for the current state,
        and counters for the range where states are stored.
        """     
        
-       def __init__(self, initial_state):
+       def __init__(self, initial_state, size=DEFAULT_STATE_CACHE_SIZE):
                """!
                StateCache constructor.
                @param initial_state the intial state (nested data)
                """
-               self.states = [None for i in range(STATE_CACHE_SIZE)] #fill 
states
+               self.states = [None] * size #fill states
                self.current_state_index = 0
                self.num_prev_states = 0
                self.num_next_states = 0
@@ -94,4 +95,4 @@
                
get_action_from_name(FLOW_GRAPH_REDO).set_sensitive(self.num_next_states != 0)
                
get_action_from_name(FLOW_GRAPH_UNDO).set_sensitive(self.num_prev_states != 0)
                
-               
\ No newline at end of file
+               

Modified: grc/branches/grc_reloaded/src/grc/__init__.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/__init__.py       2008-02-09 23:38:18 UTC 
(rev 7623)
+++ grc/branches/grc_reloaded/src/grc/__init__.py       2008-02-10 05:37:20 UTC 
(rev 7624)
@@ -23,4 +23,14 @@
 from grc.platforms.gnuradio_python.Platform import Platform
 
 platform = Platform()
+
+from grc.gui.elements.Platform import Platform
+
+platform = Platform(platform)
+
 print platform.get_block_keys()
+
+from grc.ActionHandler import ActionHandler
+
+
+ActionHandler([], platform)

Modified: grc/branches/grc_reloaded/src/grc/elements/Element.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/elements/Element.py       2008-02-09 
23:38:18 UTC (rev 7623)
+++ grc/branches/grc_reloaded/src/grc/elements/Element.py       2008-02-10 
05:37:20 UTC (rev 7624)
@@ -44,7 +44,7 @@
        def is_valid(self):
                self._error_messages = []#reset err msgs
                self.validate()
-               return not self.get_error_message()
+               return not self.get_error_messages()
                
        def _add_error_message(self, msg):
                self._error_messages.append(msg)

Modified: grc/branches/grc_reloaded/src/grc/elements/FlowGraph.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/elements/FlowGraph.py     2008-02-09 
23:38:18 UTC (rev 7623)
+++ grc/branches/grc_reloaded/src/grc/elements/FlowGraph.py     2008-02-10 
05:37:20 UTC (rev 7624)
@@ -35,8 +35,7 @@
                @return the flow graph object
                """
                Element.__init__(self, platform)
-               self._file_path = ''
-               self._options_block = self.get_parent().get_new_block(self, 
'options')
+               self._options_block = self.get_parent().get_new_block(self, 
'options')          
                self._options_block.get_param('id').set_value('options')
                
        def __str__(self): return 'FlowGraph: "%s"' + self.get_option('name')

Modified: grc/branches/grc_reloaded/src/grc/elements/Platform.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/elements/Platform.py      2008-02-09 
23:38:18 UTC (rev 7623)
+++ grc/branches/grc_reloaded/src/grc/elements/Platform.py      2008-02-10 
05:37:20 UTC (rev 7624)
@@ -68,6 +68,8 @@
        
        def is_platform(self): return True
        
+       def get_new_flow_graph(self): return Platform.FlowGraph(self)
+       
        ##############################################
        # Access Blocks
        ##############################################

Modified: grc/branches/grc_reloaded/src/grc/gui/Bars.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/Bars.py       2008-02-09 23:38:18 UTC 
(rev 7623)
+++ grc/branches/grc_reloaded/src/grc/gui/Bars.py       2008-02-10 05:37:20 UTC 
(rev 7624)
@@ -20,7 +20,7 @@
 #Create the GUI's toolbar and menubar
 address@hidden Josh Blum
 
-from Actions import *
+from grc.Actions import *
 import pygtk
 pygtk.require('2.0')
 import gtk
@@ -127,4 +127,4 @@
                                else: main_menu.append(gtk.SeparatorMenuItem())
                        main_menu.show_all() #this show all is required for the 
separators to show
                                
-                               
\ No newline at end of file
+                               

Modified: grc/branches/grc_reloaded/src/grc/gui/Dialogs.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/Dialogs.py    2008-02-09 23:38:18 UTC 
(rev 7623)
+++ grc/branches/grc_reloaded/src/grc/gui/Dialogs.py    2008-02-10 05:37:20 UTC 
(rev 7624)
@@ -20,14 +20,13 @@
 #Misc dialogs.
 address@hidden Josh Blum
 
-import Colors
+#import Colors
 import pygtk
 pygtk.require('2.0')
 import gtk
-from DataTypes import *
-from Constants import *
-from Elements import GraphicalParam
-import Preferences
+#from DataTypes import *
+from grc.Constants import *
+#import Preferences
 
 class TextDisplay(gtk.TextView):
        """A non editable gtk text view."""
@@ -283,4 +282,4 @@
        def _handle_changed(self, param=None):
                """Handle changed in the param's entry box by updating the text 
box."""
                self.text_box.set_text(str(self.param.get_data_type())) 
-               
\ No newline at end of file
+               

Modified: grc/branches/grc_reloaded/src/grc/gui/DrawingArea.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/DrawingArea.py        2008-02-09 
23:38:18 UTC (rev 7623)
+++ grc/branches/grc_reloaded/src/grc/gui/DrawingArea.py        2008-02-10 
05:37:20 UTC (rev 7624)
@@ -30,15 +30,15 @@
        The drawing area also responds to mouse and key events.
        """     
                
-       def __init__(self, platform):
+       def __init__(self, main_window):
                """!
                DrawingArea contructor.
                Connect event handlers.
-               @param platform the platform containing all flow graphs
+               @param main_window the main_window containing all flow graphs
                """     
-               self._platform = platform
-               #inject drawing area into platform
-               self._platform.drawing_area = self
+               self._main_window = main_window
+               #inject drawing area into main_window
+               self._main_window.drawing_area = self
                gtk.DrawingArea.__init__(self)
                self.connect('expose-event', self._handle_window_expose)
                self.connect('motion-notify-event', self._handle_mouse_motion)
@@ -72,7 +72,7 @@
                """!
                Forward button click information to the flow graph.
                """     
-               self._platform.get_flow_graph().handle_mouse_button_click(
+               self._main_window.get_flow_graph().handle_mouse_button_click(
                        left_click=(event.button == 1),
                        double_click=(event.type == gtk.gdk._2BUTTON_PRESS),
                ) 
@@ -82,7 +82,7 @@
                """!
                Forward button release information to the flow graph.
                """
-               self._platform.get_flow_graph().handle_mouse_button_release(
+               self._main_window.get_flow_graph().handle_mouse_button_release(
                        left_click=(event.button == 1),
                ) 
                return True
@@ -91,7 +91,7 @@
                """!
                Forward mouse motion information to the flow graph.
                """
-               self._platform.get_flow_graph().handle_mouse_motion(
+               self._main_window.get_flow_graph().handle_mouse_motion(
                        coordinate=(event.x, event.y),
                ) 
                return True
@@ -102,5 +102,5 @@
                width, height = self.get_size_request()
                if self._pixmap == None or (width, height) != 
self._pixmap.get_size():          
                        self._pixmap = gtk.gdk.Pixmap(self.window, width, 
height, -1)
-               self._platform.get_flow_graph().draw()
+               self._main_window.get_flow_graph().draw()
 

Modified: grc/branches/grc_reloaded/src/grc/gui/FileDialogs.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/FileDialogs.py        2008-02-09 
23:38:18 UTC (rev 7623)
+++ grc/branches/grc_reloaded/src/grc/gui/FileDialogs.py        2008-02-10 
05:37:20 UTC (rev 7624)
@@ -24,7 +24,7 @@
 pygtk.require('2.0')
 import gtk
 from Dialogs import MessageDialogHelper
-from Constants import 
DEFAULT_FILE_PATH,FLOW_GRAPH_FILE_EXTENSION,IMAGE_FILE_EXTENSION,NEW_FLOGRAPH_TITLE
+from grc.Constants import 
DEFAULT_FILE_PATH,FLOW_GRAPH_FILE_EXTENSION,IMAGE_FILE_EXTENSION,NEW_FLOGRAPH_TITLE
 from os import path
 
 OPEN_FLOW_GRAPH = 'open flow graph'

Modified: grc/branches/grc_reloaded/src/grc/gui/MainWindow.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/MainWindow.py 2008-02-09 23:38:18 UTC 
(rev 7623)
+++ grc/branches/grc_reloaded/src/grc/gui/MainWindow.py 2008-02-10 05:37:20 UTC 
(rev 7624)
@@ -20,20 +20,19 @@
 #The main window, containing all windows, tool bars, and menu bars.
 address@hidden Josh Blum
 
-from Constants import *
-from Actions import *
+from grc.Constants import *
+from grc.Actions import *
 import pygtk
 pygtk.require('2.0')
 import gtk
 import Bars
-from FlowGraph import FlowGraph
 from SignalBlockSelectionWindow import SignalBlockSelectionWindow
-from VariableModificationWindow import VariableModificationWindow
 from Dialogs import TextDisplay,MessageDialogHelper
-from StateCache import StateCache
-import Preferences
-import Messages
-import ParseXML
+from DrawingArea import DrawingArea
+from grc.StateCache import StateCache
+#import Preferences
+from grc import Messages
+from grc import ParseXML
 import os
 
 ############################################################
@@ -43,17 +42,19 @@
 class Page(gtk.HBox):
        """A page in the notebook."""
        
-       def __init__(self, main_window, file_path=''):
+       def __init__(self, main_window, flow_graph, file_path=''):
                """
                Page constructor.
                @param main_window main window
                @param file_path path to a flow graph file
                """             
+               self._flow_graph = flow_graph
+               self.set_pid_file('')
                #import the file
                self.main_window = main_window
-               initial_state = ParseXML.from_xml(ParseXML.from_file(file_path 
or INITIAL_FLOW_GRAPH_FILE))
+               #TODO initial_state = 
ParseXML.from_xml(ParseXML.from_file(file_path or INITIAL_FLOW_GRAPH_FILE))
+               initial_state = None
                self.state_cache = StateCache(initial_state)
-               self.set_pid_file('')
                self.set_file_path(file_path)           
                self.set_saved(True)    
                #parse xml success, initialize page             
@@ -117,6 +118,13 @@
                @param pid_file file path string
                """
                self.pid_file = pid_file
+               
+       def get_flow_graph(self):
+               """!
+               Get the flow graph.
+               @return the flow graph
+               """
+               return self._flow_graph
        
        def get_file_path(self):
                """!
@@ -161,11 +169,12 @@
 class MainWindow(gtk.Window):
        """The topmost window with menus, the tool bar, and other major 
windows."""
        
-       def __init__(self, handle_states):
+       def __init__(self, handle_states, platform):
                """!
                MainWindow contructor.
                @param handle_states the callback function
-               """     
+               """
+               self._platform = platform
                #setup window
                self.handle_states = handle_states
                gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)          
@@ -174,15 +183,13 @@
                self.add(vbox)
                #create the menu bar    and toolbar     
                vbox.pack_start(Bars.MenuBar(), False)  
-               vbox.pack_start(Bars.Toolbar(), False)                  
-               # create variable modification window   #
-               self.variable_modification_window = 
VariableModificationWindow(self.handle_states)
-               self.flow_graph = FlowGraph(self.handle_states, 
self.variable_modification_window)              
+               vbox.pack_start(Bars.Toolbar(), False)          
                #setup scrolled window
                self.scrolled_window = gtk.ScrolledWindow()
                self.scrolled_window.set_size_request(MIN_WINDOW_WIDTH, 
MIN_WINDOW_HEIGHT)      
                self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, 
gtk.POLICY_AUTOMATIC)
-               self.scrolled_window.add_with_viewport(self.flow_graph)
+               self._drawing_area = DrawingArea(self)
+               self.scrolled_window.add_with_viewport(self._drawing_area)
                # create the notebook #         
                self.notebook = gtk.Notebook()
                self.page_to_be_closed = None
@@ -198,8 +205,8 @@
                #create the side windows
                side_box = gtk.VBox()
                hbox.pack_start(side_box, False)
-               side_box.pack_start(self.variable_modification_window, False)   
        #dont allow resize
-               
side_box.pack_start(SignalBlockSelectionWindow(self.get_flow_graph)) #all 
resize, selection window can have more space
+               #TODO side_box.pack_start(self.variable_modification_window, 
False)             #dont allow resize
+               #TODO 
side_box.pack_start(SignalBlockSelectionWindow(self.get_flow_graph)) #all 
resize, selection window can have more space
                #create the reports window              
                self.text_display = TextDisplay()
                #house the reports in a scrolled window
@@ -212,7 +219,7 @@
                vbox.show_all()                 
                self._show_reports_window(False) 
                # load preferences and show the main window 
-               Preferences.load(self)
+               #Preferences.load(self)
                self.show()#show after resize in preferences
 
        ############################################################
@@ -284,7 +291,11 @@
                        return          
                try: #try to load from file
                        if file_path: Messages.send_start_load(file_path)
-                       page = Page(self, file_path)
+                       page = Page(
+                               self, 
+                               flow_graph=self._platform.get_new_flow_graph(),
+                               file_path=file_path,
+                       )
                        if file_path: Messages.send_end_load()
                except Exception, e: #return on failure
                        Messages.send_fail_load(e)
@@ -365,14 +376,7 @@
                                )
                        )
                #reports window
-               self._show_reports_window(Preferences.show_reports_window())
-                       
-       def get_flow_graph(self):
-               """
-               Get the flow graph in this main window.
-               @return the flow graph
-               """
-               return self.flow_graph
+               #TODO 
self._show_reports_window(Preferences.show_reports_window())
                
        def get_page(self):
                """!
@@ -381,6 +385,13 @@
                """
                return self.current_page
 
+       def get_flow_graph(self):
+               """!
+               Get the selected flow graph.
+               @return the selected flow graph
+               """
+               return self.current_page.get_flow_graph()
+
        ############################################################
        ##      Helpers
        ############################################################

Modified: grc/branches/grc_reloaded/src/grc/gui/SignalBlockSelectionWindow.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/SignalBlockSelectionWindow.py 
2008-02-09 23:38:18 UTC (rev 7623)
+++ grc/branches/grc_reloaded/src/grc/gui/SignalBlockSelectionWindow.py 
2008-02-10 05:37:20 UTC (rev 7624)
@@ -20,12 +20,11 @@
 #The signal block selection window gives the user a tree selection to choose a 
signal block.
 address@hidden Josh Blum
 
-from Constants import *
+from grc.Constants import *
 import pygtk
 pygtk.require('2.0')
 import gtk
 import gobject
-from SignalBlockDefs import SB_TREE
 
 class SignalBlockSelectionWindow(gtk.VBox):
        """The signal block selection window."""
@@ -101,4 +100,4 @@
                        model, iter = selection.get_selected()
                        if iter != None and not model.iter_has_child(iter): 
self.get_flow_graph().add_signal_block(model.get_value(iter, 0))
                
-               
\ No newline at end of file
+               

Modified: grc/branches/grc_reloaded/src/grc/gui/USRPDiagnostics.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/USRPDiagnostics.py    2008-02-09 
23:38:18 UTC (rev 7623)
+++ grc/branches/grc_reloaded/src/grc/gui/USRPDiagnostics.py    2008-02-10 
05:37:20 UTC (rev 7624)
@@ -23,9 +23,7 @@
 import pygtk
 pygtk.require('2.0')
 import gtk
-from Actions import USRP_DIAGNOSTICS_DISPLAY,get_action_from_name
-from Elements import GraphicalParam
-from DataTypes import *
+from grc.Actions import USRP_DIAGNOSTICS_DISPLAY,get_action_from_name
 from Dialogs import TextDisplay
 
 def enable_usrp_diagnostics():
@@ -102,4 +100,4 @@
 If the problem persists, there may be a problem with you gnuradio installation 
or USB 2.0.
 '''%str(e))            
                
-               
\ No newline at end of file
+               

Modified: grc/branches/grc_reloaded/src/grc/gui/elements/Block.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/elements/Block.py     2008-02-09 
23:38:18 UTC (rev 7623)
+++ grc/branches/grc_reloaded/src/grc/gui/elements/Block.py     2008-02-10 
05:37:20 UTC (rev 7624)
@@ -21,9 +21,9 @@
 address@hidden Josh Blum
 
 from Element import Element
-import Element
+import Element as Utils
 import Colors
-from Constants import *
+from grc.Constants import *
 import pygtk
 pygtk.require('2.0')
 import gtk
@@ -40,8 +40,8 @@
                self.W = self.label_width + 2*LABEL_PADDING_WIDTH
                max_ports = max(self.get_num_input_ports(), 
self.get_num_output_ports(), 1)
                self.H = max(self.label_height+2*LABEL_PADDING_HEIGHT, 
2*SOCKET_BORDER_SEPARATION + max_ports*SOCKET_HEIGHT + 
(max_ports-1)*SOCKET_SEPARATION)          
-               if Element.is_horizontal(self.get_rotation()): 
self.add_area((0,0),(self.W,self.H))
-               elif Element.is_vertical(self.get_rotation()): 
self.add_area((0,0),(self.H,self.W))                                     
+               if Utils.is_horizontal(self.get_rotation()): 
self.add_area((0,0),(self.W,self.H))
+               elif Utils.is_vertical(self.get_rotation()): 
self.add_area((0,0),(self.H,self.W))                                       
                for port in self.get_ports(): port.update()                     
        
        def _create_labels(self):
@@ -79,7 +79,7 @@
                        h_off = h + h_off + LABEL_SEPARATION
                #       create vertical and horizontal images   #               
        
                self.horizontal_label = image = pixmap.get_image(0, 0, width, 
height)
-               if Element.is_vertical(self.get_rotation()):
+               if Utils.is_vertical(self.get_rotation()):
                        self.vertical_label = vimage = 
gtk.gdk.Image(gtk.gdk.IMAGE_NORMAL, pixmap.get_visual(), height, width)
                        for i in range(width):
                                for j in range(height): vimage.put_pixel(j, 
width-i-1, image.get_pixel(i, j))
@@ -89,13 +89,13 @@
                Draw the signal block with label and inputs/outputs.
                @param window the gtk window to draw on
                """
-               Element.draw(self, window)              
+               Utils.draw(self, window)                
                gc = self.gc            
                gc.foreground = Colors.TXT_COLOR
                X,Y = self.get_coordinate()             
-               if Element.is_horizontal(self.get_rotation()):
+               if Utils.is_horizontal(self.get_rotation()):
                        window.draw_image(gc, self.horizontal_label, 0, 0, 
X+LABEL_PADDING_WIDTH, Y+(self.H-self.label_height)/2, -1, -1)
-               elif Element.is_vertical(self.get_rotation()):
+               elif Utils.is_vertical(self.get_rotation()):
                        window.draw_image(gc, self.vertical_label, 0, 0, 
X+(self.H-self.label_height)/2, Y+LABEL_PADDING_WIDTH, -1, -1)
                for port in self.get_ports(): port.draw(window)
                

Modified: grc/branches/grc_reloaded/src/grc/gui/elements/Element.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/elements/Element.py   2008-02-09 
23:38:18 UTC (rev 7623)
+++ grc/branches/grc_reloaded/src/grc/gui/elements/Element.py   2008-02-10 
05:37:20 UTC (rev 7624)
@@ -53,7 +53,7 @@
        It contains an X,Y coordinate, a list of rectangular areas that the 
element occupies, 
        and methods to detect selection of those areas.
        """             
-       
+
        def draw(self, window, BG_color=Colors.BG_COLOR, 
FG_color=Colors.FG_COLOR):
                """!
                Draw in the given window.

Modified: grc/branches/grc_reloaded/src/grc/gui/elements/FlowGraph.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/elements/FlowGraph.py 2008-02-09 
23:38:18 UTC (rev 7623)
+++ grc/branches/grc_reloaded/src/grc/gui/elements/FlowGraph.py 2008-02-10 
05:37:20 UTC (rev 7624)
@@ -24,28 +24,24 @@
 from grc.Actions import *
 from Colors import BACKGROUND_COLOR, TXT_COLOR
 
-from Elements import Utils
+import Element
 
 import pygtk
 pygtk.require('2.0')
 import gtk
-import time,socket #for tagging saved files
 
-
-from SignalBlockParamsDialog import SignalBlockParamsDialog
 import random
-import Messages
-import ParseXML
-import Messages
+from grc import ParseXML
+from grc import Messages
 
-class FlowGraph(gtk.DrawingArea):
+class FlowGraph(object):
        """
        FlowGraph is the data structure to store graphical signal blocks, 
        graphical inputs and outputs, 
        and the connections between inputs and outputs.
        """     
                
-       def __init__(self, handle_states, variable_modification_window):
+       def __init__TODO(self, handle_states, variable_modification_window):
                """!
                FlowGraph contructor.
                Create a list for signal blocks and connections. Connect mouse 
handlers.
@@ -87,10 +83,6 @@
 ###########################################################################
 #      Flow Graph Access Methods
 ###########################################################################    
-       
-       def _handle_focus_event(self, widget, event, focus_flag):
-               """Record the focus state of the flow graph window."""
-               self.focus_flag = focus_flag
                                
        def add_signal_block(self, tag):        
                """!
@@ -102,7 +94,7 @@
                        id = tag+str(index)
                        index = index + 1       
                        if not [
-                               None for element in self.elements if 
Utils.is_signal_block(element) and id == element.get_id()
+                               None for element in self.elements if 
Element.is_signal_block(element) and id == element.get_id()
                        ]:              #make sure that the id is not used by 
another signal block
                                rot = 0
                                vAdj = 
self.get_parent().get_vadjustment().get_value()
@@ -122,8 +114,8 @@
                @param direction +1 or -1
                @return true for success
                """
-               if Utils.is_socket(self.selected_element): 
self.selected_element = self.selected_element.get_parent()
-               if Utils.is_signal_block(self.selected_element): return 
self.selected_element.modify_type_controller(direction)
+               if Element.is_socket(self.selected_element): 
self.selected_element = self.selected_element.get_parent()
+               if Element.is_signal_block(self.selected_element): return 
self.selected_element.modify_type_controller(direction)
                return False
                
        def socket_controller_modify_selected(self, direction):
@@ -132,8 +124,8 @@
                @param direction +1 or -1
                @return true for success
                """
-               if Utils.is_socket(self.selected_element): 
self.selected_element = self.selected_element.get_parent()
-               if Utils.is_signal_block(self.selected_element): return 
self.selected_element.modify_socket_controller(direction)
+               if Element.is_socket(self.selected_element): 
self.selected_element = self.selected_element.get_parent()
+               if Element.is_signal_block(self.selected_element): return 
self.selected_element.modify_socket_controller(direction)
                return False
 
        def param_modify_selected(self):
@@ -141,8 +133,8 @@
                Create and show a param modification dialog for the selected 
element (socket and signal block only).
                @return true if parameters were changed
                """
-               if Utils.is_socket(self.selected_element): 
self.selected_element = self.selected_element.get_parent()
-               if Utils.is_signal_block(self.selected_element):
+               if Element.is_socket(self.selected_element): 
self.selected_element = self.selected_element.get_parent()
+               if Element.is_signal_block(self.selected_element):
                        signal_block_params_dialog = 
SignalBlockParamsDialog(self.selected_element)
                        changed = signal_block_params_dialog.run()      
                        self.update()   
@@ -181,7 +173,7 @@
                @param direction DIR_LEFT or DIR_RIGHT
                @return         true if rotated, otherwise false. 
                """
-               if self.selected_element != None and 
(Utils.is_signal_block(self.selected_element) or 
Utils.is_socket(self.selected_element)):                                  
+               if self.selected_element != None and 
(Element.is_signal_block(self.selected_element) or 
Element.is_socket(self.selected_element)):                                      
                        self.selected_element.rotate(direction) 
                        self.draw()
                        return True
@@ -193,13 +185,13 @@
                @return true if the element was deleted, otherwise false.
                """
                if self.selected_element != None:
-                       if Utils.is_socket(self.selected_element):      # found 
a socket, set to parent signal block
+                       if Element.is_socket(self.selected_element):    # found 
a socket, set to parent signal block
                                self.selected_element = 
self.selected_element.get_parent()                                              
-                       if Utils.is_signal_block(self.selected_element):        
# delete a signal block
+                       if Element.is_signal_block(self.selected_element):      
# delete a signal block
                                connections = 
self.selected_element.get_connections()
                                for connection in connections: 
connection.disconnect()
                                self.remove_element(self.selected_element)
-                       elif Utils.is_connection(self.selected_element):        
# delete a connection
+                       elif Element.is_connection(self.selected_element):      
# delete a connection
                                self.selected_element.disconnect()              
                        
                        self.selected_element = None                            
                        self.update()   
@@ -248,7 +240,7 @@
                                self.gc.foreground = TXT_COLOR                  
                
                                self.pixmap.draw_points(self.gc, points)        
                        #       draw the foreground     #
-                       for element in filter(Utils.is_signal_block, 
self.elements) + filter(Utils.is_connection, self.elements): 
+                       for element in filter(Element.is_signal_block, 
self.elements) + filter(Element.is_connection, self.elements): 
                                element.draw(self.pixmap)       # draw signal 
blocks first, then connections on the top                 
                        if self.mouse_pressed and self.selected_element != None:
                                self.selected_element.draw(self.pixmap)
@@ -273,12 +265,10 @@
        ##      Handlers
        
##########################################################################      
                
-       def _handle_mouse_button_press(self, widget, event):
+       def handle_mouse_button_press(self, left_click, double_click):
                """ A mouse button is pressed. Record the state of the mouse, 
find the selected element,
                set the Element highlighted, handle the state change, and 
redraw the FlowGraph."""              
-               #       unselect anything in the vars mod window        #
-               self.variable_modification_window.unselect_all()
-               if event.button == 1:
+               if left_click:
                        if self.selected_element != None: 
self.selected_element.set_highlighted(False)
                        self.count = 0
                        self.mouse_pressed = True
@@ -286,25 +276,25 @@
                        old_selection = self.selected_element
                        self.selected_element = self.what_is_selected((event.x, 
event.y))
                        #       handle the state change with the new selection  
#
-                       if Utils.is_connection(self.selected_element): 
self.handle_states(CONNECTION_SELECT)    
-                       elif Utils.is_socket(self.selected_element): 
self.handle_states(SOCKET_SELECT)  
-                       elif Utils.is_signal_block(self.selected_element): 
self.handle_states(SIGNAL_BLOCK_SELECT)      
+                       if Element.is_connection(self.selected_element): 
self.handle_states(CONNECTION_SELECT)  
+                       elif Element.is_socket(self.selected_element): 
self.handle_states(SOCKET_SELECT)        
+                       elif Element.is_signal_block(self.selected_element): 
self.handle_states(SIGNAL_BLOCK_SELECT)    
                        elif self.selected_element == None: 
self.handle_states(NOTHING_SELECT)                                          
                        #       this selection and the last were Sockets, try 
to connect them   #
-                       if Utils.is_socket(old_selection) and 
Utils.is_socket(self.selected_element) and\
+                       if Element.is_socket(old_selection) and 
Element.is_socket(self.selected_element) and\
                                old_selection is not self.selected_element: 
#cannot be the same socket
                                self.connect_sockets(old_selection, 
self.selected_element)                                              
                        if self.selected_element != None: 
self.selected_element.set_highlighted(True)                                     
                              
                        #       double click detected, bring up params dialog 
if possible       #
-                       if event.type == gtk.gdk._2BUTTON_PRESS and 
Utils.is_signal_block(self.selected_element):
+                       if double_click and 
Element.is_signal_block(self.selected_element):
                                self.mouse_pressed = False
                                self.handle_states(SIGNAL_BLOCK_PARAM_MODIFY)   
                        
                        self.draw()
                return True
                
-       def _handle_mouse_button_release(self, widget, event):
+       def handle_mouse_button_release(self, left_click):
                """A mouse button is released, record the state."""
-               if event.button == 1:
+               if left_click:
                        self.mouse_pressed = False
                        if self.has_moved:
                                if Preferences.snap_to_grid():
@@ -321,7 +311,7 @@
                                self.has_moved = False
                return True
                
-       def _handle_mouse_motion(self, widget, event):          
+       def handle_mouse_motion(self, coordinate):              
                """The mouse has moved. If mouse_pressed is true, react to the 
motions: 
                -       if an Element is highlighted, this will move the 
Element by redrawing it at the new position."""
                fgW,fgH = self.get_size_request()
@@ -331,12 +321,11 @@
                        self.count == 0 and\
                        self.selected_element != None:
                        #       The event coordinates must be within 10 pixels 
away from the bounds of the flow graph.  #
-                       x = event.x
+                       x,y = coordinate
                        if x <= BORDER_PROXIMITY_SENSITIVITY:
                                x = BORDER_PROXIMITY_SENSITIVITY
                        if      x >= fgW - BORDER_PROXIMITY_SENSITIVITY:
                                x = fgW - BORDER_PROXIMITY_SENSITIVITY          
                        
-                       y = event.y
                        if y <= BORDER_PROXIMITY_SENSITIVITY:
                                y = BORDER_PROXIMITY_SENSITIVITY
                        if      y >= fgH - BORDER_PROXIMITY_SENSITIVITY:        
@@ -364,138 +353,3 @@
                        # move the selected element and record the new 
coordinate       #                       
                        self.move_selected((deltaX, deltaY))    
                        self.coordinate = (x, y)        
-                                       
-       def _handle_window_expose(self, widget, event): 
-               """Called when the window initially appears or is resized: 
create a new pixmap, draw the flow graph."""
-               self.gc = self.window.new_gc()
-               width, height = self.get_size_request()
-               if self.pixmap == None or (width, height) != 
self.pixmap.get_size():            
-                       self.pixmap = gtk.gdk.Pixmap(self.window, width, 
height, -1)
-               self.draw()
-
-##########################################################################
-##
-##                     Export the Flow Graph
-##
-##########################################################################     
                                        
-       def to_nested_data(self):
-               """!
-               Dump all the values in this flow graph into a nested data 
format.
-               @return nested data representing a flow graph
-               """
-               vars_list = list()
-               signal_blocks_list = list()
-               connections_list = list()
-               W,H = self.get_size_request()
-               nested_data = ('flow_graph', [
-                       ('timestamp', str(time.time())),
-                       ('hostname', socket.gethostname()),
-                       ('version', VERSION),
-                       ('valid', str(self.is_valid())),
-                       ('window_width', str(W)),
-                       ('window_height', str(H)),
-                       ('vars', vars_list),
-                       ('signal_blocks', signal_blocks_list),
-                       ('connections', connections_list)
-               ])      
-       
##########################################################################
-       ##      Export the Variables
-       
##########################################################################      
-               for key in self.variable_modification_window.to_key_list():
-                       row = (key,) + Variables.get_values(key)
-                       vars_list.append(('var', [
-                               ('key', row[0]), 
-                               ('value', row[1]),
-                               ('min', row[2]),
-                               ('max', row[3]),
-                               ('step', row[4]),
-                       ]))
-       
##########################################################################
-       ##      Export the Signal Blocks
-       
##########################################################################
-               for element in filter(Utils.is_signal_block, self.elements):
-                       params_list = list()
-                       signal_blocks_list.append(('signal_block', [
-                               ('tag', element.get_tag()), 
-                               ('id', element.get_id()),
-                               ('x_coordinate', 
str(element.get_coordinate()[0])),
-                               ('y_coordinate', 
str(element.get_coordinate()[1])),
-                               ('rotation', str(element.get_rotation())),
-                               ('params', params_list)
-                       ]))
-                       for param in element.get_params():
-                               params_list.append(('param', 
str(param.get_data_type().get_data()))     )       
-       
##########################################################################
-       ##      Export the Connections
-       
##########################################################################
-               for element in filter(Utils.is_connection, self.elements):
-                       connections_list.append(('connection', [
-                               ('input_signal_block_id', 
str(element.get_input_socket().get_parent().get_id())), 
-                               ('input_socket_index', 
str(element.get_input_socket().get_index())),
-                               ('output_signal_block_id', 
str(element.get_output_socket().get_parent().get_id())), 
-                               ('output_socket_index', 
str(element.get_output_socket().get_index()))
-                       ]))
-               #print 'To',nested_data
-               return nested_data
-
-##########################################################################
-##     
-##                     Import the Flow Graph
-##
-##########################################################################     
        
-       def from_nested_data(self, nested_data):
-               """!
-               Set all the values in this flow graph using the nested data.
-               @param nested_data nested data representing a flow graph
-               """
-               #print 'From',nested_data
-               #TODO: use a non-destructive method to clear the elements list
-               self.elements = list()  #clear the elements
-               find_data = ParseXML.find_data
-               flow_graph = find_data([nested_data], 'flow_graph')
-               #       window width and height are optional    #
-               window_width = find_data(flow_graph, 'window_width')
-               if window_width == None: window_width = MAX_WINDOW_WIDTH
-               window_height = find_data(flow_graph, 'window_height')
-               if window_height == None: window_height = MAX_WINDOW_HEIGHT
-               self.set_size_request(int(window_width),int(window_height))
-               vars = find_data(flow_graph, 'vars')
-               signal_blocks = find_data(flow_graph, 'signal_blocks')
-               connections = find_data(flow_graph, 'connections')
-       
##########################################################################
-       ##      Import the Variables
-       
##########################################################################
-               keys = Variables.from_nested_data(vars)
-               self.variable_modification_window.from_key_list(keys)
-       
##########################################################################
-       ##      Import the Signal Blocks
-       
##########################################################################
-               for signal_block in signal_blocks:
-                       signal_block = 
GraphicalSignalBlock.from_nested_data(self, signal_block, 
GraphicalSignalBlock)[0]       #index 0 for just signal block  
-                       if signal_block: self.elements.append(signal_block)     
                
-       
##########################################################################
-       ##      Import the Connections
-       
##########################################################################
-               for connection in connections:
-                       connection = find_data([connection], 'connection')
-                       input_signal_block_id = find_data(connection, 
'input_signal_block_id')
-                       input_socket_index = int(find_data(connection, 
'input_socket_index'))
-                       output_signal_block_id = find_data(connection, 
'output_signal_block_id')
-                       output_socket_index = int(find_data(connection, 
'output_socket_index'))
-                       input_socket = output_socket = None                     
                                                        
-                       for element in filter(Utils.is_signal_block, 
self.elements):
-                               if element.get_id() == input_signal_block_id: 
input_socket = element.get_input_socket(input_socket_index)
-                               if element.get_id() == output_signal_block_id: 
output_socket = element.get_output_socket(output_socket_index)
-                       try: self.elements.append(GraphicalConnection(self, 
input_socket, output_socket))
-                       except ConnectionException: 
-                               Messages.send_error_load('Could not connect 
"%s" input[%d] and "%s" output[%d].'%(
-                                               input_signal_block_id, 
-                                               input_socket_index, 
-                                               output_signal_block_id, 
-                                               output_socket_index,
-                                       )
-                               )       
-               self.selected_element = None            
-               self.update()
-               # done importing the flow graph #
-

Modified: grc/branches/grc_reloaded/src/grc/gui/elements/Param.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/elements/Param.py     2008-02-09 
23:38:18 UTC (rev 7623)
+++ grc/branches/grc_reloaded/src/grc/gui/elements/Param.py     2008-02-10 
05:37:20 UTC (rev 7624)
@@ -26,7 +26,7 @@
 import gtk
 import pango
 import gobject
-from Constants import *
+from grc.Constants import *
 from os import path
 
 
######################################################################################################

Modified: grc/branches/grc_reloaded/src/grc/gui/elements/Port.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/elements/Port.py      2008-02-09 
23:38:18 UTC (rev 7623)
+++ grc/branches/grc_reloaded/src/grc/gui/elements/Port.py      2008-02-10 
05:37:20 UTC (rev 7624)
@@ -20,9 +20,9 @@
 #The graphical input/output sockets of the signal block.
 address@hidden Josh Blum
 
-import Element
+import Element as Utils
 from Element import Element
-from Constants import *
+from grc.Constants import *
 import Colors
 import pygtk
 pygtk.require('2.0')
@@ -84,7 +84,7 @@
                pixmap.draw_layout(gc, 0, 0, layout)
                #       create the images       #
                self.horizontal_label = image = pixmap.get_image(0, 0, w, h)    
-               if Element.is_vertical(self.get_rotation()):    
+               if Utils.is_vertical(self.get_rotation()):      
                        self.vertical_label = vimage = 
gtk.gdk.Image(gtk.gdk.IMAGE_NORMAL, pixmap.get_visual(), h, w)
                        for i in range(w):
                                for j in range(h): vimage.put_pixel(j, w-i-1, 
image.get_pixel(i, j))
@@ -94,13 +94,13 @@
                Draw the socket with a label.
                @param window the gtk window to draw on
                """
-               GraphicalElement.GraphicalElement.draw(self, window, 
BG_color=self.BG_color)                            
+               GraphicalUtils.GraphicalUtils.draw(self, window, 
BG_color=self.BG_color)                                
                gc = self.gc                            
                gc.foreground = Colors.TXT_COLOR
                X,Y = self.get_coordinate()
                (x,y),(w,h) = self.areas_dict[self.get_rotation()][0] #use the 
first area's sizes to place the labels
-               if Element.is_horizontal(self.get_rotation()): 
window.draw_image(gc, self.horizontal_label, 0, 0, x+X+(PORT_WIDTH-self.w)/2, 
y+Y+(PORT_HEIGHT-self.h)/2, -1, -1)
-               elif Element.is_vertical(self.get_rotation()): 
window.draw_image(gc, self.vertical_label, 0, 0, x+X+(PORT_HEIGHT-self.h)/2, 
y+Y+(PORT_WIDTH-self.w)/2, -1, -1)
+               if Utils.is_horizontal(self.get_rotation()): 
window.draw_image(gc, self.horizontal_label, 0, 0, x+X+(PORT_WIDTH-self.w)/2, 
y+Y+(PORT_HEIGHT-self.h)/2, -1, -1)
+               elif Utils.is_vertical(self.get_rotation()): 
window.draw_image(gc, self.vertical_label, 0, 0, x+X+(PORT_HEIGHT-self.h)/2, 
y+Y+(PORT_WIDTH-self.w)/2, -1, -1)
        
        def __set_connector_coordinates(self, coor_inner, coor_outer, 
rotation=None):
                """!





reply via email to

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