new preferences
authorjblum <jblum@221aa14e-8319-0410-a670-987f0aec2ac5>
Fri, 28 Nov 2008 06:51:21 +0000 (06:51 +0000)
committerjblum <jblum@221aa14e-8319-0410-a670-987f0aec2ac5>
Fri, 28 Nov 2008 06:51:21 +0000 (06:51 +0000)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10081 221aa14e-8319-0410-a670-987f0aec2ac5

16 files changed:
grc/data/platforms/python/blocks/Makefile.am
grc/data/platforms/python/blocks/preferences.xml [deleted file]
grc/data/platforms/python/flow_graph.tmpl
grc/scripts/grc
grc/src/gui/ActionHandler.py
grc/src/gui/Actions.py
grc/src/gui/Bars.py
grc/src/gui/Constants.py
grc/src/gui/Dialogs.py
grc/src/gui/FileDialogs.py
grc/src/gui/MainWindow.py
grc/src/gui/Preferences.py
grc/src/platforms/gui/Block.py
grc/src/platforms/gui/FlowGraph.py
grc/src/platforms/python/Platform.py
grc/todo.txt

index de6792602e7794bf7b1d0c11747e90599f2bc7b1..7f5d0c13980bf934dc54ca8dd56c99761bb886ab 100644 (file)
@@ -183,7 +183,6 @@ dist_ourdata_DATA = \
        pad_sink.xml \
        pad_source.xml \
        parameter.xml \
        pad_sink.xml \
        pad_source.xml \
        parameter.xml \
-       preferences.xml \
        probe_function.xml \
        random_source_x.xml \
        trellis_encoder_xx.xml \
        probe_function.xml \
        random_source_x.xml \
        trellis_encoder_xx.xml \
diff --git a/grc/data/platforms/python/blocks/preferences.xml b/grc/data/platforms/python/blocks/preferences.xml
deleted file mode 100644 (file)
index 366675c..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##Global Preferences:
-##     This block should not appear in the tree.
-###################################################
- -->
-<block>
-       <name>Preferences</name>
-       <key>preferences</key>
-       <make></make>
-       <!-- Hidden Prefs -->
-       <param>
-               <name>Prefs File</name>
-               <key>prefs_file</key>
-               <value>.grc</value>
-               <type>string</type>
-       </param>
-       <param>
-               <name>Window Prefix</name>
-               <key>window_prefix</key>
-               <value>GRC</value>
-               <type>string</type>
-       </param>
-       <param>
-               <name>File Open</name>
-               <key>file_open</key>
-               <value></value>
-               <type>string</type>
-       </param>
-       <param>
-               <name>Files Open</name>
-               <key>files_open</key>
-               <value></value>
-               <type>string</type>
-       </param>
-       <param>
-               <name>Window Size</name>
-               <key>window_size</key>
-               <type>int_vector</type>
-       </param>
-       <!-- Snap to Grid -->
-       <param>
-               <name>Snap to Grid</name>
-               <key>snap_to_grid</key>
-               <value>off</value>
-               <type>enum</type>
-               <option>
-                       <name>Off</name>
-                       <key>off</key>
-               </option>
-               <option>
-                       <name>On</name>
-                       <key>on</key>
-               </option>
-       </param>
-       <param>
-               <name>Grid Size</name>
-               <key>grid_size</key>
-               <value>20</value>
-               <type>enum</type>
-               <option>
-                       <name>10 pixels</name>
-                       <key>10</key>
-               </option>
-               <option>
-                       <name>20 pixels</name>
-                       <key>20</key>
-               </option>
-               <option>
-                       <name>50 pixels</name>
-                       <key>50</key>
-               </option>
-               <option>
-                       <name>100 pixels</name>
-                       <key>100</key>
-               </option>
-       </param>
-       <param>
-               <name>Show Grid</name>
-               <key>show_grid</key>
-               <value>hide</value>
-               <type>enum</type>
-               <option>
-                       <name>Show</name>
-                       <key>show</key>
-               </option>
-               <option>
-                       <name>Hide</name>
-                       <key>hide</key>
-               </option>
-       </param>
-       <!-- Appearance Prefs -->
-       <param>
-               <name>Show Params Labels</name>
-               <key>show_params</key>
-               <value>show</value>
-               <type>enum</type>
-               <option>
-                       <name>Show</name>
-                       <key>show</key>
-               </option>
-               <option>
-                       <name>Hide</name>
-                       <key>hide</key>
-               </option>
-       </param>
-       <!-- Misc Prefs -->
-       <param>
-               <name>Restore Open Files</name>
-               <key>restore_files</key>
-               <value>yes</value>
-               <type>enum</type>
-               <option>
-                       <name>Yes</name>
-                       <key>yes</key>
-               </option>
-               <option>
-                       <name>No</name>
-                       <key>no</key>
-               </option>
-       </param>
-       <param>
-               <name>Reports Window Position</name>
-               <key>reports_window_position</key>
-               <type>string</type>
-       </param>
-       <param>
-               <name>Blocks Window Position</name>
-               <key>blocks_window_position</key>
-               <type>string</type>
-       </param>
-</block>
index 6bf79fc8b34e20b7d0662df861682bc705119c94..98feb4a95a2e013850942f8dd7a8ec64af455c9f 100644 (file)
@@ -41,7 +41,6 @@ $imp
 #set $class_name = $flow_graph.get_option('id')
 #set $param_str = ', '.join(['self'] + ['%s=%s'%(param.get_id(), param.get_make()) for param in $parameters])
 #if $generate_options == 'wx_gui'
 #set $class_name = $flow_graph.get_option('id')
 #set $param_str = ', '.join(['self'] + ['%s=%s'%(param.get_id(), param.get_make()) for param in $parameters])
 #if $generate_options == 'wx_gui'
-       #from gnuradio.grc.gui import Preferences
        #import gtk
        #set $icon = gtk.IconTheme().lookup_icon('gnuradio-grc', 32, 0)
 class $(class_name)(grc_wxgui.top_block_gui):
        #import gtk
        #set $icon = gtk.IconTheme().lookup_icon('gnuradio-grc', 32, 0)
 class $(class_name)(grc_wxgui.top_block_gui):
@@ -49,7 +48,7 @@ class $(class_name)(grc_wxgui.top_block_gui):
        def __init__($param_str):
                grc_wxgui.top_block_gui.__init__(
                        self,
        def __init__($param_str):
                grc_wxgui.top_block_gui.__init__(
                        self,
-                       title="$Preferences.window_prefix() - Executing: $flow_graph.get_option('title')",
+                       title="$flow_graph.get_parent().get_name() - Executing: $flow_graph.get_option('title')",
        #if $icon
                        icon="$icon.get_filename()",
        #end if
        #if $icon
                        icon="$icon.get_filename()",
        #end if
index 4073c92f88a9afb8a40494d94a6a7e61d00c36f5..11f9c60d365d68a5a8036f2f3406569a8aa29f6f 100755 (executable)
@@ -18,12 +18,11 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 """
 
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 """
 
-from gnuradio.grc.gui.Constants import FLOW_GRAPH_FILE_EXTENSION
 from gnuradio.grc.platforms.base.Constants import VERSION
 from optparse import OptionParser
 
 if __name__ == "__main__":
 from gnuradio.grc.platforms.base.Constants import VERSION
 from optparse import OptionParser
 
 if __name__ == "__main__":
-       usage = 'usage: %%prog [options] [optional_flow_graphs%s]'%FLOW_GRAPH_FILE_EXTENSION
+       usage = 'usage: %prog [options] [saved flow graphs]'
        version = """
 GNU Radio Companion %s
 
        version = """
 GNU Radio Companion %s
 
index 85bfcb34e0e5c21e10fdf3a0458b99f0bdc86b4d..4c5516311ffdb376ba76bec4fd37d59bbf5ea53a 100644 (file)
@@ -32,7 +32,7 @@ from .. utils import ParseXML
 import random
 from .. platforms.gui.Platform import Platform
 from MainWindow import MainWindow
 import random
 from .. platforms.gui.Platform import Platform
 from MainWindow import MainWindow
-from Dialogs import PreferencesDialog, AboutDialog
+from Dialogs import AboutDialog
 from FileDialogs import OpenFlowGraphFileDialog, SaveFlowGraphFileDialog, SaveImageFileDialog
 
 gobject.threads_init()
 from FileDialogs import OpenFlowGraphFileDialog, SaveFlowGraphFileDialog, SaveImageFileDialog
 
 gobject.threads_init()
@@ -77,13 +77,13 @@ class ActionHandler:
                """
                Handle key presses from the keyboard and translate key combos into actions.
                This key press handler is called before the gtk accelerators kick in.
                """
                Handle key presses from the keyboard and translate key combos into actions.
                This key press handler is called before the gtk accelerators kick in.
-               This handler ensures that key presses without a mod mask, only pass to the accelerators
-               if the flow graph is in focus and something is selected.
+               This handler ensures that key presses without a mod mask,
+               only pass to the accelerators if the flow graph is in focus.
                This function also handles keys that accelerators refuse to handle: left/right,
                and keys that are not registered with an accelerator: +/-.
                @return false to let the accelerators handle the key action
                """
                This function also handles keys that accelerators refuse to handle: left/right,
                and keys that are not registered with an accelerator: +/-.
                @return false to let the accelerators handle the key action
                """
-               if self.get_focus_flag() and self.get_flow_graph().is_selected():
+               if self.get_focus_flag():
                        try:
                                self.handle_states({
                                        'Left': Actions.BLOCK_ROTATE_LEFT,
                        try:
                                self.handle_states({
                                        'Left': Actions.BLOCK_ROTATE_LEFT,
@@ -97,9 +97,9 @@ class ActionHandler:
                                        'KP_Subtract': Actions.PORT_CONTROLLER_DEC,
                                }[gtk.gdk.keyval_name(event.keyval)])
                                return True
                                        'KP_Subtract': Actions.PORT_CONTROLLER_DEC,
                                }[gtk.gdk.keyval_name(event.keyval)])
                                return True
-                       #focus + selection: always return false for accelerator to handle
+                       #focus: always return false for accelerator to handle
                        except: return False
                        except: return False
-               #no focus + selection: only allow accelerator to handle when a mod is used
+               #no focus: only allow accelerator to handle when a mod is used
                return not event.state
 
        def _quit(self, window, event):
                return not event.state
 
        def _quit(self, window, event):
@@ -141,9 +141,9 @@ class ActionHandler:
                                Actions.APPLICATION_QUIT, Actions.FLOW_GRAPH_NEW,
                                Actions.FLOW_GRAPH_OPEN, Actions.FLOW_GRAPH_SAVE_AS,
                                Actions.FLOW_GRAPH_CLOSE, Actions.ABOUT_WINDOW_DISPLAY,
                                Actions.APPLICATION_QUIT, Actions.FLOW_GRAPH_NEW,
                                Actions.FLOW_GRAPH_OPEN, Actions.FLOW_GRAPH_SAVE_AS,
                                Actions.FLOW_GRAPH_CLOSE, Actions.ABOUT_WINDOW_DISPLAY,
-                               Actions.PREFS_WINDOW_DISPLAY, Actions.FLOW_GRAPH_SCREEN_CAPTURE,
+                               Actions.FLOW_GRAPH_SCREEN_CAPTURE,
                        ): Actions.get_action_from_name(action).set_sensitive(True)
                        ): Actions.get_action_from_name(action).set_sensitive(True)
-                       if not self.init_file_paths and Preferences.restore_files():
+                       if not self.init_file_paths:
                                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.init_file_paths = Preferences.files_open()
                        if not self.init_file_paths: self.init_file_paths = ['']
                        for file_path in self.init_file_paths:
@@ -240,9 +240,6 @@ class ActionHandler:
                ##################################################
                # Window stuff
                ##################################################
                ##################################################
                # Window stuff
                ##################################################
-               elif state == Actions.PREFS_WINDOW_DISPLAY:
-                       PreferencesDialog()
-                       self.get_flow_graph().update()
                elif state == Actions.ABOUT_WINDOW_DISPLAY:
                        AboutDialog()
                ##################################################
                elif state == Actions.ABOUT_WINDOW_DISPLAY:
                        AboutDialog()
                ##################################################
index 818995a32090f2f6c675a2cff68e616877e47665..16f12dd4c05e36d1d3833b29fccfe57056066fd1 100644 (file)
@@ -56,7 +56,6 @@ FLOW_GRAPH_EXEC = 'flow graph exec'
 FLOW_GRAPH_KILL = 'flow graph kill'
 FLOW_GRAPH_SCREEN_CAPTURE = 'flow graph screen capture'
 ABOUT_WINDOW_DISPLAY = 'about window display'
 FLOW_GRAPH_KILL = 'flow graph kill'
 FLOW_GRAPH_SCREEN_CAPTURE = 'flow graph screen capture'
 ABOUT_WINDOW_DISPLAY = 'about window display'
-PREFS_WINDOW_DISPLAY = 'prefs window display'
 
 ######################################################################################################
 # Action Key Map
 
 ######################################################################################################
 # Action Key Map
@@ -106,7 +105,6 @@ _actions_list = (
        gtk.Action(BLOCK_CUT, 'Cu_t', 'Cut', 'gtk-cut'),
        gtk.Action(BLOCK_COPY, '_Copy', 'Copy', 'gtk-copy'),
        gtk.Action(BLOCK_PASTE, '_Paste', 'Paste', 'gtk-paste'),
        gtk.Action(BLOCK_CUT, 'Cu_t', 'Cut', 'gtk-cut'),
        gtk.Action(BLOCK_COPY, '_Copy', 'Copy', 'gtk-copy'),
        gtk.Action(BLOCK_PASTE, '_Paste', 'Paste', 'gtk-paste'),
-       gtk.Action(PREFS_WINDOW_DISPLAY, '_Preferences', 'Configure Preferences', 'gtk-preferences'),
        gtk.Action(ABOUT_WINDOW_DISPLAY, '_About', 'About this program', 'gtk-about'),
        gtk.Action(FLOW_GRAPH_GEN, '_Generate', 'Generate the flow graph', 'gtk-convert'),
        gtk.Action(FLOW_GRAPH_EXEC, '_Execute', 'Execute the flow graph', 'gtk-execute'),
        gtk.Action(ABOUT_WINDOW_DISPLAY, '_About', 'About this program', 'gtk-about'),
        gtk.Action(FLOW_GRAPH_GEN, '_Generate', 'Generate the flow graph', 'gtk-convert'),
        gtk.Action(FLOW_GRAPH_EXEC, '_Execute', 'Execute the flow graph', 'gtk-execute'),
index 1416d4dd54b64f0ae7fc79088211d525755de169..c89aea580919b9afecb68df5c072ede9398e9ba3 100644 (file)
@@ -86,9 +86,6 @@ MENU_BAR_LIST = (
                Actions.FLOW_GRAPH_EXEC,
                Actions.FLOW_GRAPH_KILL,
        ]),
                Actions.FLOW_GRAPH_EXEC,
                Actions.FLOW_GRAPH_KILL,
        ]),
-       (gtk.Action('Options', '_Options', None, None), [
-               Actions.PREFS_WINDOW_DISPLAY,
-       ]),
        (gtk.Action('Help', '_Help', None, None), [
                Actions.ABOUT_WINDOW_DISPLAY,
        ]),
        (gtk.Action('Help', '_Help', None, None), [
                Actions.ABOUT_WINDOW_DISPLAY,
        ]),
index ccee7aa60bbc337b0d1f9b5ab229acf802293c66..70e6b6b6edcb5c8927b2cd6a403b99139aa8d366 100644 (file)
@@ -23,7 +23,6 @@ import os
 DEFAULT_FILE_PATH = os.getcwd()
 
 ##file extensions
 DEFAULT_FILE_PATH = os.getcwd()
 
 ##file extensions
-FLOW_GRAPH_FILE_EXTENSION = '.grc'
 IMAGE_FILE_EXTENSION = '.png'
 
 ##name for new/unsaved flow graphs
 IMAGE_FILE_EXTENSION = '.png'
 
 ##name for new/unsaved flow graphs
index 995fe46285853236a88e53af2a5ed866d9f8ca0e..e15f8c574123ebe56966ed3ceb70c3f6c746babb 100644 (file)
@@ -41,27 +41,6 @@ class TextDisplay(gtk.TextView):
                self.set_cursor_visible(False)
                self.set_wrap_mode(gtk.WRAP_WORD_CHAR)
 
                self.set_cursor_visible(False)
                self.set_wrap_mode(gtk.WRAP_WORD_CHAR)
 
-class PreferencesDialog(gtk.Dialog):
-       """A dialog box to display the preferences."""
-
-       def __init__(self):
-               """PreferencesDialog constructor."""
-               gtk.Dialog.__init__(self, buttons=('gtk-close', gtk.RESPONSE_CLOSE))
-               self.set_title("Preferences")
-               self.set_size_request(MIN_DIALOG_WIDTH, MIN_DIALOG_HEIGHT)
-               notebook = gtk.Notebook()
-               for title,desc,params in Preferences.get_preferences():
-                       vbox = gtk.VBox()
-                       vbox.pack_start(gtk.Label(''), False) #blank label for spacing
-                       for param in params: vbox.pack_start(param.get_input_object(), False)
-                       desc = desc.strip('\n')
-                       if desc: vbox.pack_start(TextDisplay(desc), False, padding=5)
-                       notebook.append_page(vbox, gtk.Label(title))
-               self.vbox.pack_start(notebook, True)
-               self.show_all()
-               self.run()
-               self.destroy()
-
 def MessageDialogHelper(type, buttons, title=None, markup=None):
        """
        Create a modal message dialog and run it.
 def MessageDialogHelper(type, buttons, title=None, markup=None):
        """
        Create a modal message dialog and run it.
index 2758e909b2d35b43894ba17356dff1f8ed21d4f4..78c74c91af3e4aa7ab81371b207e492509c36c69 100644 (file)
@@ -22,8 +22,9 @@ pygtk.require('2.0')
 import gtk
 from Dialogs import MessageDialogHelper
 from Constants import \
 import gtk
 from Dialogs import MessageDialogHelper
 from Constants import \
-       DEFAULT_FILE_PATH, FLOW_GRAPH_FILE_EXTENSION, \
-       IMAGE_FILE_EXTENSION, NEW_FLOGRAPH_TITLE
+       DEFAULT_FILE_PATH, IMAGE_FILE_EXTENSION, \
+       NEW_FLOGRAPH_TITLE
+import Preferences
 from os import path
 
 OPEN_FLOW_GRAPH = 'open flow graph'
 from os import path
 
 OPEN_FLOW_GRAPH = 'open flow graph'
@@ -31,20 +32,26 @@ SAVE_FLOW_GRAPH = 'save flow graph'
 SAVE_IMAGE = 'save image'
 
 ##the filter for flow graph files
 SAVE_IMAGE = 'save image'
 
 ##the filter for flow graph files
-FLOW_GRAPH_FILE_FILTER = gtk.FileFilter()
-FLOW_GRAPH_FILE_FILTER.set_name('GRC Files')
-FLOW_GRAPH_FILE_FILTER.add_pattern('*'+FLOW_GRAPH_FILE_EXTENSION)
-FLOW_GRAPH_FILE_FILTER.add_pattern('*.xml') #TEMP
+def get_flow_graph_files_filter():
+       filter = gtk.FileFilter()
+       filter.set_name('Flow Graph Files')
+       filter.add_pattern('*'+Preferences.file_extension())
+       filter.add_pattern('*.xml') #TEMP
+       return filter
 
 ##the filter for image files
 
 ##the filter for image files
-IMAGE_FILE_FILTER = gtk.FileFilter()
-IMAGE_FILE_FILTER.set_name('Image Files')
-IMAGE_FILE_FILTER.add_pattern('*'+IMAGE_FILE_EXTENSION)
+def get_image_files_filter():
+       filter = gtk.FileFilter()
+       filter.set_name('Image Files')
+       filter.add_pattern('*'+IMAGE_FILE_EXTENSION)
+       return filter
 
 ##the filter for all files
 
 ##the filter for all files
-ALL_FILE_FILTER = gtk.FileFilter()
-ALL_FILE_FILTER.set_name('All Files')
-ALL_FILE_FILTER.add_pattern('*')
+def get_all_files_filter():
+       filter = gtk.FileFilter()
+       filter.set_name('All Files')
+       filter.add_pattern('*')
+       return filter
 
 class FileDialogHelper(gtk.FileChooserDialog):
        """
 
 class FileDialogHelper(gtk.FileChooserDialog):
        """
@@ -64,7 +71,7 @@ class FileDialogHelper(gtk.FileChooserDialog):
                gtk.FileChooserDialog.__init__(self, title, None, action, ('gtk-cancel', gtk.RESPONSE_CANCEL, ok_stock, gtk.RESPONSE_OK))
                self.set_select_multiple(False)
                self.set_local_only(True)
                gtk.FileChooserDialog.__init__(self, title, None, action, ('gtk-cancel', gtk.RESPONSE_CANCEL, ok_stock, gtk.RESPONSE_OK))
                self.set_select_multiple(False)
                self.set_local_only(True)
-               self.add_filter(ALL_FILE_FILTER)
+               self.add_filter(get_all_files_filter())
 
 class FileDialog(FileDialogHelper):
        """A dialog box to save or open flow graph files. This is a base class, do not use."""
 
 class FileDialog(FileDialogHelper):
        """A dialog box to save or open flow graph files. This is a base class, do not use."""
@@ -74,18 +81,18 @@ class FileDialog(FileDialogHelper):
                FileDialog constructor.
                @param current_file_path the current directory or path to the open flow graph
                """
                FileDialog constructor.
                @param current_file_path the current directory or path to the open flow graph
                """
-               if not current_file_path: current_file_path = path.join(DEFAULT_FILE_PATH, NEW_FLOGRAPH_TITLE + FLOW_GRAPH_FILE_EXTENSION)
+               if not current_file_path: current_file_path = path.join(DEFAULT_FILE_PATH, NEW_FLOGRAPH_TITLE + Preferences.file_extension())
                if self.type == OPEN_FLOW_GRAPH:
                        FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_OPEN, 'Open a Flow Graph from a File...')
                if self.type == OPEN_FLOW_GRAPH:
                        FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_OPEN, 'Open a Flow Graph from a File...')
-                       self.add_and_set_filter(FLOW_GRAPH_FILE_FILTER)
+                       self.add_and_set_filter(get_flow_graph_files_filter())
                        self.set_select_multiple(True)
                elif self.type == SAVE_FLOW_GRAPH:
                        FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_SAVE, 'Save a Flow Graph to a File...')
                        self.set_select_multiple(True)
                elif self.type == SAVE_FLOW_GRAPH:
                        FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_SAVE, 'Save a Flow Graph to a File...')
-                       self.add_and_set_filter(FLOW_GRAPH_FILE_FILTER)
+                       self.add_and_set_filter(get_flow_graph_files_filter())
                        self.set_current_name(path.basename(current_file_path)) #show the current filename
                elif self.type == SAVE_IMAGE:
                        FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_SAVE, 'Save a Flow Graph Screen Shot...')
                        self.set_current_name(path.basename(current_file_path)) #show the current filename
                elif self.type == SAVE_IMAGE:
                        FileDialogHelper.__init__(self, gtk.FILE_CHOOSER_ACTION_SAVE, 'Save a Flow Graph Screen Shot...')
-                       self.add_and_set_filter(IMAGE_FILE_FILTER)
+                       self.add_and_set_filter(get_image_files_filter())
                        current_file_path = current_file_path + IMAGE_FILE_EXTENSION
                        self.set_current_name(path.basename(current_file_path)) #show the current filename
                self.set_current_folder(path.dirname(current_file_path)) #current directory
                        current_file_path = current_file_path + IMAGE_FILE_EXTENSION
                        self.set_current_name(path.basename(current_file_path)) #show the current filename
                self.set_current_folder(path.dirname(current_file_path)) #current directory
@@ -113,8 +120,8 @@ class FileDialog(FileDialogHelper):
                if self.type in (SAVE_FLOW_GRAPH, SAVE_IMAGE):
                        filename = self.get_filename()
                        for extension, filter in (
                if self.type in (SAVE_FLOW_GRAPH, SAVE_IMAGE):
                        filename = self.get_filename()
                        for extension, filter in (
-                               (FLOW_GRAPH_FILE_EXTENSION, FLOW_GRAPH_FILE_FILTER),
-                               (IMAGE_FILE_EXTENSION, IMAGE_FILE_FILTER),
+                               (FLOW_GRAPH_FILE_EXTENSION, get_flow_graph_files_filter()),
+                               (IMAGE_FILE_EXTENSION, get_image_files_filter()),
                        ): #append the missing file extension if the filter matches
                                if filename[len(filename)-len(extension):] != extension \
                                        and filter == self.get_filter(): filename += extension
                        ): #append the missing file extension if the filter matches
                                if filename[len(filename)-len(extension):] != extension \
                                        and filter == self.get_filter(): filename += extension
index 474da4f33ebbf14cd4a2731e2ecbe843b5b1f956..ffb696a452c354dc44bdad71e25cdeb5240e01b6 100644 (file)
@@ -90,7 +90,7 @@ class MainWindow(gtk.Window):
                self.flow_graph_vpaned.pack2(self.reports_scrolled_window, False) #dont allow resize
                #load preferences and show the main window
                Preferences.load(platform)
                self.flow_graph_vpaned.pack2(self.reports_scrolled_window, False) #dont allow resize
                #load preferences and show the main window
                Preferences.load(platform)
-               self.resize(*Preferences.window_size())
+               self.resize(*Preferences.main_window_size())
                self.flow_graph_vpaned.set_position(Preferences.reports_window_position())
                self.hpaned.set_position(Preferences.blocks_window_position())
                self.show_all()
                self.flow_graph_vpaned.set_position(Preferences.reports_window_position())
                self.hpaned.set_position(Preferences.blocks_window_position())
                self.show_all()
@@ -190,7 +190,7 @@ class MainWindow(gtk.Window):
                #save state before closing
                Preferences.files_open(open_files)
                Preferences.file_open(open_file)
                #save state before closing
                Preferences.files_open(open_files)
                Preferences.file_open(open_file)
-               Preferences.window_size(self.get_size())
+               Preferences.main_window_size(self.get_size())
                Preferences.reports_window_position(self.flow_graph_vpaned.get_position())
                Preferences.blocks_window_position(self.hpaned.get_position())
                Preferences.save()
                Preferences.reports_window_position(self.flow_graph_vpaned.get_position())
                Preferences.blocks_window_position(self.hpaned.get_position())
                Preferences.save()
@@ -231,16 +231,14 @@ class MainWindow(gtk.Window):
                Show/hide the reports window.
                @param title the window title
                """
                Show/hide the reports window.
                @param title the window title
                """
-               if self.get_page():
-                       title = ''.join((
-                                       Preferences.window_prefix(),
-                                       ' - Editing: ',
-                                       (self.get_page().get_file_path() or NEW_FLOGRAPH_TITLE),
-                                       (self.get_page().get_saved() and ' ' or '*'), #blank must be non empty
-                                       (self.get_page().get_read_only() and ' (read-only)' or ''),
-                               )
+               title = ''.join((
+                               self._platform.get_name(),
+                               ' - Editing: ',
+                               (self.get_page().get_file_path() or NEW_FLOGRAPH_TITLE),
+                               (self.get_page().get_saved() and ' ' or '*'), #blank must be non empty
+                               (self.get_page().get_read_only() and ' (read-only)' or ''),
                        )
                        )
-               else: title = MAIN_WINDOW_PREFIX + ' - Editor '
+               )
                gtk.Window.set_title(self, title)
                #set tab titles
                for page in self._get_pages():
                gtk.Window.set_title(self, title)
                #set tab titles
                for page in self._get_pages():
index d6533586f191e02b48d69865d36a291107f397e6..1d89920dd59ccd838b586795624494ffd023ab10 100644 (file)
@@ -17,122 +17,70 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 """
 
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 """
 
-from .. platforms.base.Constants import FLOW_GRAPH_DTD
-from .. utils import ParseXML
-import Messages
+import ConfigParser
 import os
 
 import os
 
-##Access the loaded preferences in this module
-_prefs = list()
-def _set_prefs(prefs): _prefs.append(prefs)
-def _get_prefs(): return _prefs[0]
-def load(platform): _Preferences(platform)
-def save(): _get_prefs().save()
-def get_preferences(): return _get_prefs().get_preferences()
+_platform = None
+_config_parser = ConfigParser.ConfigParser()
 
 
-class _Preferences(object):
+def file_extension(): return '.'+_platform.get_key()
+def _prefs_file(): return os.path.join(os.path.expanduser('~'), file_extension())
 
 
-       def __init__(self, platform):
-               #make self available to module
-               _set_prefs(self)
-               #get prefs block
-               self._prefs_block = platform.get_prefs_block()
-               #prefs file path
-               self._prefs_file_path = os.path.join(os.path.expanduser('~'), self._prefs_block.get_param('prefs_file').get_value())
-               #load
-               try:
-                       ParseXML.validate_dtd(self._prefs_file_path, FLOW_GRAPH_DTD)
-                       n = ParseXML.from_file(self._prefs_file_path)
-                       self._prefs_block.import_data(n['block'])
-               except: Messages.send_fail_load_preferences(self._prefs_file_path)
-               ##all params
-               self.window_prefix_param = self._prefs_block.get_param('window_prefix')
-               self.snap_to_grid_param = self._prefs_block.get_param('snap_to_grid')
-               self.grid_size_param = self._prefs_block.get_param('grid_size')
-               self.show_grid_param = self._prefs_block.get_param('show_grid')
-               self.reports_window_position_param = self._prefs_block.get_param('reports_window_position')
-               self.blocks_window_position_param = self._prefs_block.get_param('blocks_window_position')
-               self.restore_files_param = self._prefs_block.get_param('restore_files')
-               self.window_size_param = self._prefs_block.get_param('window_size')
-               self.file_open_param = self._prefs_block.get_param('file_open')
-               self.files_open_param = self._prefs_block.get_param('files_open')
-               self.show_params_param = self._prefs_block.get_param('show_params')
-
-       def save(self):
-               try: ParseXML.to_file({'block': self._prefs_block.export_data()}, self._prefs_file_path)
-               except IOError: Messages.send_fail_save_preferences(self._prefs_file_path)
-
-       def get_preferences(self):
-               ##Preferences: title, notes, params
-               return [
-                       (
-                               'Grid',
-                               '''
-Show grid will draw a square grid onto the flow graph with grid points separated by grid size pixels. \
-Snap to Grid forces the upper right corner of the signal block to align with a grid point.
-''',
-                               [self.snap_to_grid_param, self.grid_size_param, self.show_grid_param],
-                       ),
-                       (
-                               'Appearance',
-                               '''
-Show or hide all paramater labels in the signal blocks.
-''',
-                               [self.show_params_param],
-                       ),
-                       (
-                               'Misc',
-                               '''
-Restore previously opened files on start-up.
-''',
-                               [self.restore_files_param],
-                       ),
-               ]
+def load(platform):
+       global _platform
+       _platform = platform
+       #create sections
+       _config_parser.add_section('main')
+       _config_parser.add_section('files_open')
+       try: _config_parser.read(_prefs_file())
+       except: pass
+def save():
+       try: _config_parser.write(open(_prefs_file(), 'w'))
+       except: pass
 
 ###########################################################################
 # Special methods for specific program functionalities
 ###########################################################################
 
 
 ###########################################################################
 # Special methods for specific program functionalities
 ###########################################################################
 
-def window_prefix():
-       return _get_prefs().window_prefix_param.get_value()
-
-def window_size(size=None):
-       if size: _get_prefs().window_size_param.set_value(size)
+def main_window_size(size=None):
+       if size is not None:
+               _config_parser.set('main', 'main_window_width', size[0])
+               _config_parser.set('main', 'main_window_height', size[1])
        else:
        else:
-               try: return eval(_get_prefs().window_size_param.get_value())
-               except: return (-1, -1)
-
-def restore_files():
-       return _get_prefs().restore_files_param.get_value() == 'yes'
+               try: return (
+                       _config_parser.getint('main', 'main_window_width'),
+                       _config_parser.getint('main', 'main_window_height'),
+               )
+               except: return (1, 1)
 
 def file_open(file=None):
 
 def file_open(file=None):
-       if file is not None: _get_prefs().file_open_param.set_value(file)
-       else: return _get_prefs().file_open_param.get_value()
+       if file is not None: _config_parser.set('main', 'file_open', file)
+       else:
+               try: return _config_parser.get('main', 'file_open')
+               except: return ''
 
 def files_open(files=None):
 
 def files_open(files=None):
-       if files is not None: _get_prefs().files_open_param.set_value('\n'.join(files))
-       else: return _get_prefs().files_open_param.get_value().split('\n')
+       if files is not None:
+               _config_parser.remove_section('files_open') #clear section
+               _config_parser.add_section('files_open')
+               for i, file in enumerate(files):
+                       _config_parser.set('files_open', 'file_open_%d'%i, file)
+       else:
+               files = list()
+               i = 0
+               while True:
+                       try: files.append(_config_parser.get('files_open', 'file_open_%d'%i))
+                       except: return files
+                       i = i + 1
 
 def reports_window_position(pos=None):
 
 def reports_window_position(pos=None):
-       if pos is not None: _get_prefs().reports_window_position_param.set_value('%d'%pos)
+       if pos is not None: _config_parser.set('main', 'reports_window_position', pos)
        else:
        else:
-               try: return int(_get_prefs().reports_window_position_param.get_value()) or 1 #greater than 0
+               try: return _config_parser.getint('main', 'reports_window_position') or 1 #greater than 0
                except: return -1
 
 def blocks_window_position(pos=None):
                except: return -1
 
 def blocks_window_position(pos=None):
-       if pos is not None: _get_prefs().blocks_window_position_param.set_value('%d'%pos)
+       if pos is not None: _config_parser.set('main', 'blocks_window_position', pos)
        else:
        else:
-               try: return int(_get_prefs().blocks_window_position_param.get_value()) or 1 #greater than 0
+               try: return _config_parser.getint('main', 'blocks_window_position') or 1 #greater than 0
                except: return -1
                except: return -1
-
-def get_grid_size():
-       return int(_get_prefs().grid_size_param.get_value())
-
-def snap_to_grid():
-       return _get_prefs().snap_to_grid_param.get_value() == 'on'
-
-def show_grid():
-       return _get_prefs().show_grid_param.get_value() == 'show'
-
-def show_params():
-       return _get_prefs().show_params_param.get_value() == 'show'
index a2b5048ecac3f492d488a56c6f273be17f7af88a..ab6a6d0b2242168317fc9f1b5cf2354ed008d459 100644 (file)
@@ -17,7 +17,6 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 """
 
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 """
 
-from ... gui import Preferences
 from Element import Element
 import Utils
 import Colors
 from Element import Element
 import Utils
 import Colors
@@ -137,13 +136,12 @@ class Block(Element):
                layout.set_font_description(desc)
                self.label_width, self.label_height = layout.get_pixel_size()
                #display the params
                layout.set_font_description(desc)
                self.label_width, self.label_height = layout.get_pixel_size()
                #display the params
-               if Preferences.show_params():
-                       for param in filter(lambda p: p.get_hide() not in ('all', 'part'), self.get_params()):
-                               layout = param.get_layout()
-                               layouts.append(layout)
-                               w,h = layout.get_pixel_size()
-                               self.label_width = max(w, self.label_width)
-                               self.label_height = self.label_height + h + LABEL_SEPARATION
+               for param in filter(lambda p: p.get_hide() not in ('all', 'part'), self.get_params()):
+                       layout = param.get_layout()
+                       layouts.append(layout)
+                       w,h = layout.get_pixel_size()
+                       self.label_width = max(w, self.label_width)
+                       self.label_height = self.label_height + h + LABEL_SEPARATION
                width = self.label_width
                height = self.label_height
                #setup the pixmap
                width = self.label_width
                height = self.label_height
                #setup the pixmap
index e387ccc9bcd54222b28dadb14c23a24edb799fb9..22113037eb889074126a01cf6d5f552899ef9b91 100644 (file)
@@ -17,7 +17,6 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 """
 
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 """
 
-from ... gui import Preferences
 from ... gui.Constants import \
        DIR_LEFT, DIR_RIGHT, \
        SCROLL_PROXIMITY_SENSITIVITY, SCROLL_DISTANCE, \
 from ... gui.Constants import \
        DIR_LEFT, DIR_RIGHT, \
        SCROLL_PROXIMITY_SENSITIVITY, SCROLL_DISTANCE, \
@@ -302,15 +301,6 @@ class FlowGraph(Element):
                        #draw the background
                        self.get_gc().foreground = Colors.BACKGROUND_COLOR
                        self.get_pixmap().draw_rectangle(self.get_gc(), True, 0, 0, W, H)
                        #draw the background
                        self.get_gc().foreground = Colors.BACKGROUND_COLOR
                        self.get_pixmap().draw_rectangle(self.get_gc(), True, 0, 0, W, H)
-                       #draw grid (depends on prefs)
-                       if Preferences.show_grid():
-                               grid_size = Preferences.get_grid_size()
-                               points = list()
-                               for i in range(W/grid_size):
-                                       for j in range(H/grid_size):
-                                               points.append((i*grid_size, j*grid_size))
-                               self.get_gc().foreground = Colors.TXT_COLOR
-                               self.get_pixmap().draw_points(self.get_gc(), points)
                        #draw multi select rectangle
                        if self.mouse_pressed and (not self.get_selected_elements() or self.get_ctrl_mask()):
                                #coordinates
                        #draw multi select rectangle
                        if self.mouse_pressed and (not self.get_selected_elements() or self.get_ctrl_mask()):
                                #coordinates
@@ -507,16 +497,6 @@ class FlowGraph(Element):
                self.time = 0
                self.mouse_pressed = False
                if self.element_moved:
                self.time = 0
                self.mouse_pressed = False
                if self.element_moved:
-                       if Preferences.snap_to_grid():
-                               grid_size = Preferences.get_grid_size()
-                               X,Y = self.get_selected_element().get_coordinate()
-                               deltaX = X%grid_size
-                               if deltaX < grid_size/2: deltaX = -1 * deltaX
-                               else: deltaX = grid_size - deltaX
-                               deltaY = Y%grid_size
-                               if deltaY < grid_size/2: deltaY = -1 * deltaY
-                               else: deltaY = grid_size - deltaY
-                               self.move_selected((deltaX, deltaY))
                        self.handle_states(BLOCK_MOVE)
                        self.element_moved = False
                self.update_selected_elements()
                        self.handle_states(BLOCK_MOVE)
                        self.element_moved = False
                self.update_selected_elements()
index d1c8a36a8027e2fd9a18f0398878c2a7238d34e8..9b0b3bb309bcfb6fa804b0de9666d4e5ae43acb9 100644 (file)
@@ -52,8 +52,8 @@ class Platform(_Platform):
                #init
                _Platform.__init__(
                        self,
                #init
                _Platform.__init__(
                        self,
-                       name='GNURadio Python',
-                       key='gnuradio_python',
+                       name='GRC',
+                       key='grc',
                        block_paths=block_paths,
                        block_dtd=BLOCK_DTD,
                        block_tree=BLOCK_TREE,
                        block_paths=block_paths,
                        block_dtd=BLOCK_DTD,
                        block_tree=BLOCK_TREE,
index 6c10cc12678cfa6a681a11ad17de517eaa3fcf15..ef5914d95f7f670f6b9c5ab6fd79fbc23e11b8c9 100644 (file)
@@ -19,7 +19,6 @@
 -zoom in/out (cairo vector graphics) (use scroll wheel as control)
 -search for blocks
 -click and drag on whitespace to scroll
 -zoom in/out (cairo vector graphics) (use scroll wheel as control)
 -search for blocks
 -click and drag on whitespace to scroll
--expand preferences, allow for custom prefs, prefs dialog should infer structure
 -gui grid editor for configuring grid params/placing wxgui plots and controls
 -grid param chooser gui
 -histogram plot
 -gui grid editor for configuring grid params/placing wxgui plots and controls
 -grid param chooser gui
 -histogram plot