From d01692fa60eb6b08b6b7b5369d2a08cee912395f Mon Sep 17 00:00:00 2001 From: jblum Date: Fri, 28 Nov 2008 06:51:21 +0000 Subject: [PATCH] new preferences git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10081 221aa14e-8319-0410-a670-987f0aec2ac5 --- grc/data/platforms/python/blocks/Makefile.am | 1 - .../platforms/python/blocks/preferences.xml | 133 ---------------- grc/data/platforms/python/flow_graph.tmpl | 3 +- grc/scripts/grc | 3 +- grc/src/gui/ActionHandler.py | 19 +-- grc/src/gui/Actions.py | 2 - grc/src/gui/Bars.py | 3 - grc/src/gui/Constants.py | 1 - grc/src/gui/Dialogs.py | 21 --- grc/src/gui/FileDialogs.py | 45 +++--- grc/src/gui/MainWindow.py | 20 ++- grc/src/gui/Preferences.py | 142 ++++++------------ grc/src/platforms/gui/Block.py | 14 +- grc/src/platforms/gui/FlowGraph.py | 20 --- grc/src/platforms/python/Platform.py | 4 +- grc/todo.txt | 1 - 16 files changed, 98 insertions(+), 334 deletions(-) delete mode 100644 grc/data/platforms/python/blocks/preferences.xml diff --git a/grc/data/platforms/python/blocks/Makefile.am b/grc/data/platforms/python/blocks/Makefile.am index de679260..7f5d0c13 100644 --- a/grc/data/platforms/python/blocks/Makefile.am +++ b/grc/data/platforms/python/blocks/Makefile.am @@ -183,7 +183,6 @@ dist_ourdata_DATA = \ pad_sink.xml \ pad_source.xml \ parameter.xml \ - preferences.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 index 366675c9..00000000 --- a/grc/data/platforms/python/blocks/preferences.xml +++ /dev/null @@ -1,133 +0,0 @@ - - - - Preferences - preferences - - - - Prefs File - prefs_file - .grc - string - - - Window Prefix - window_prefix - GRC - string - - - File Open - file_open - - string - - - Files Open - files_open - - string - - - Window Size - window_size - int_vector - - - - Snap to Grid - snap_to_grid - off - enum - - - - - Grid Size - grid_size - 20 - enum - - - - - - - Show Grid - show_grid - hide - enum - - - - - - Show Params Labels - show_params - show - enum - - - - - - Restore Open Files - restore_files - yes - enum - - - - - Reports Window Position - reports_window_position - string - - - Blocks Window Position - blocks_window_position - string - - diff --git a/grc/data/platforms/python/flow_graph.tmpl b/grc/data/platforms/python/flow_graph.tmpl index 6bf79fc8..98feb4a9 100644 --- a/grc/data/platforms/python/flow_graph.tmpl +++ b/grc/data/platforms/python/flow_graph.tmpl @@ -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' - #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): @@ -49,7 +48,7 @@ class $(class_name)(grc_wxgui.top_block_gui): 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 diff --git a/grc/scripts/grc b/grc/scripts/grc index 4073c92f..11f9c60d 100755 --- a/grc/scripts/grc +++ b/grc/scripts/grc @@ -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 """ -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__": - usage = 'usage: %%prog [options] [optional_flow_graphs%s]'%FLOW_GRAPH_FILE_EXTENSION + usage = 'usage: %prog [options] [saved flow graphs]' version = """ GNU Radio Companion %s diff --git a/grc/src/gui/ActionHandler.py b/grc/src/gui/ActionHandler.py index 85bfcb34..4c551631 100644 --- a/grc/src/gui/ActionHandler.py +++ b/grc/src/gui/ActionHandler.py @@ -32,7 +32,7 @@ from .. utils import ParseXML 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() @@ -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. - 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 """ - 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, @@ -97,9 +97,9 @@ class ActionHandler: '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 - #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): @@ -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.PREFS_WINDOW_DISPLAY, Actions.FLOW_GRAPH_SCREEN_CAPTURE, + Actions.FLOW_GRAPH_SCREEN_CAPTURE, ): 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: @@ -240,9 +240,6 @@ class ActionHandler: ################################################## # Window stuff ################################################## - elif state == Actions.PREFS_WINDOW_DISPLAY: - PreferencesDialog() - self.get_flow_graph().update() elif state == Actions.ABOUT_WINDOW_DISPLAY: AboutDialog() ################################################## diff --git a/grc/src/gui/Actions.py b/grc/src/gui/Actions.py index 818995a3..16f12dd4 100644 --- a/grc/src/gui/Actions.py +++ b/grc/src/gui/Actions.py @@ -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' -PREFS_WINDOW_DISPLAY = 'prefs window display' ###################################################################################################### # 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(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'), diff --git a/grc/src/gui/Bars.py b/grc/src/gui/Bars.py index 1416d4dd..c89aea58 100644 --- a/grc/src/gui/Bars.py +++ b/grc/src/gui/Bars.py @@ -86,9 +86,6 @@ MENU_BAR_LIST = ( 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, ]), diff --git a/grc/src/gui/Constants.py b/grc/src/gui/Constants.py index ccee7aa6..70e6b6b6 100644 --- a/grc/src/gui/Constants.py +++ b/grc/src/gui/Constants.py @@ -23,7 +23,6 @@ import os DEFAULT_FILE_PATH = os.getcwd() ##file extensions -FLOW_GRAPH_FILE_EXTENSION = '.grc' IMAGE_FILE_EXTENSION = '.png' ##name for new/unsaved flow graphs diff --git a/grc/src/gui/Dialogs.py b/grc/src/gui/Dialogs.py index 995fe462..e15f8c57 100644 --- a/grc/src/gui/Dialogs.py +++ b/grc/src/gui/Dialogs.py @@ -41,27 +41,6 @@ class TextDisplay(gtk.TextView): 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. diff --git a/grc/src/gui/FileDialogs.py b/grc/src/gui/FileDialogs.py index 2758e909..78c74c91 100644 --- a/grc/src/gui/FileDialogs.py +++ b/grc/src/gui/FileDialogs.py @@ -22,8 +22,9 @@ 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 + DEFAULT_FILE_PATH, IMAGE_FILE_EXTENSION, \ + NEW_FLOGRAPH_TITLE +import Preferences 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 -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 -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 -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): """ @@ -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) - 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.""" @@ -74,18 +81,18 @@ class FileDialog(FileDialogHelper): 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...') - 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.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.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 @@ -113,8 +120,8 @@ class FileDialog(FileDialogHelper): 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 diff --git a/grc/src/gui/MainWindow.py b/grc/src/gui/MainWindow.py index 474da4f3..ffb696a4 100644 --- a/grc/src/gui/MainWindow.py +++ b/grc/src/gui/MainWindow.py @@ -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.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() @@ -190,7 +190,7 @@ class MainWindow(gtk.Window): #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() @@ -231,16 +231,14 @@ class MainWindow(gtk.Window): 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(): diff --git a/grc/src/gui/Preferences.py b/grc/src/gui/Preferences.py index d6533586..1d89920d 100644 --- a/grc/src/gui/Preferences.py +++ b/grc/src/gui/Preferences.py @@ -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 """ -from .. platforms.base.Constants import FLOW_GRAPH_DTD -from .. utils import ParseXML -import Messages +import ConfigParser 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 ########################################################################### -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: - 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): - 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): - 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): - 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: - 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): - 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: - 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 - -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' diff --git a/grc/src/platforms/gui/Block.py b/grc/src/platforms/gui/Block.py index a2b5048e..ab6a6d0b 100644 --- a/grc/src/platforms/gui/Block.py +++ b/grc/src/platforms/gui/Block.py @@ -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 """ -from ... gui import Preferences 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 - 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 diff --git a/grc/src/platforms/gui/FlowGraph.py b/grc/src/platforms/gui/FlowGraph.py index e387ccc9..22113037 100644 --- a/grc/src/platforms/gui/FlowGraph.py +++ b/grc/src/platforms/gui/FlowGraph.py @@ -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 """ -from ... gui import Preferences 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 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 @@ -507,16 +497,6 @@ class FlowGraph(Element): 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() diff --git a/grc/src/platforms/python/Platform.py b/grc/src/platforms/python/Platform.py index d1c8a36a..9b0b3bb3 100644 --- a/grc/src/platforms/python/Platform.py +++ b/grc/src/platforms/python/Platform.py @@ -52,8 +52,8 @@ class Platform(_Platform): #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, diff --git a/grc/todo.txt b/grc/todo.txt index 6c10cc12..ef5914d9 100644 --- a/grc/todo.txt +++ b/grc/todo.txt @@ -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 --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 -- 2.30.2