diff options
author | Johnathan Corgan | 2009-09-04 15:47:49 -0700 |
---|---|---|
committer | Johnathan Corgan | 2009-09-04 15:47:49 -0700 |
commit | d80add605536891da950126b25b16ab89d8e7cae (patch) | |
tree | 10777578472d39e25a821284e1409be7a6caae89 /grc/gui | |
parent | 20006003431d7260b04964eb684b1746ffb0a85f (diff) | |
parent | 6b47cc3dc64d86cb19eb28ab4843a0f278db6d0a (diff) | |
download | gnuradio-d80add605536891da950126b25b16ab89d8e7cae.tar.gz gnuradio-d80add605536891da950126b25b16ab89d8e7cae.tar.bz2 gnuradio-d80add605536891da950126b25b16ab89d8e7cae.zip |
Merge branch 'grc' from http://gnuradio.org/git/jblum.git into master
we dont use test() -> remove it
Made the window for the pass band filters integers (take firdes.WIN_XXX).
Evaluation fix in param.to_code().
Removed the flagging api and usage from the base classes.
added ref scale param to fft and waterfall
Switched the python classes to inherit from the base and gui classes.
port and param types from an overloaded method
todo
Replaced TYPES in Port and Param with types parameter.
made is_virtual_xxx a block level function, used by port and param classes
added stream id type and checking in evaluate
avoid loops
Recursive resolution of virtual sources.
added virtual source and added stream ids, logic to clone in port
added rewrite methods to element to separate from validation logic
Added virtual sink and logic to clone port.
removed repurposing of pads
Work on command line options for generated code.
renamed the colors dialog to types
use pkgpythondir
...
Diffstat (limited to 'grc/gui')
-rw-r--r-- | grc/gui/ActionHandler.py | 10 | ||||
-rw-r--r-- | grc/gui/Actions.py | 4 | ||||
-rw-r--r-- | grc/gui/Bars.py | 2 | ||||
-rw-r--r-- | grc/gui/Block.py | 8 | ||||
-rw-r--r-- | grc/gui/Dialogs.py | 4 | ||||
-rw-r--r-- | grc/gui/FlowGraph.py | 2 | ||||
-rw-r--r-- | grc/gui/Param.py | 77 | ||||
-rw-r--r-- | grc/gui/Platform.py | 32 | ||||
-rw-r--r-- | grc/gui/Port.py | 2 |
9 files changed, 95 insertions, 46 deletions
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py index ff137f669..8f317d6a8 100644 --- a/grc/gui/ActionHandler.py +++ b/grc/gui/ActionHandler.py @@ -30,7 +30,6 @@ from threading import Thread import Messages from .. base import ParseXML import random -from Platform import Platform from MainWindow import MainWindow from ParamsDialog import ParamsDialog import Dialogs @@ -53,7 +52,6 @@ class ActionHandler: @param platform platform module """ self.clipboard = None - platform = Platform(platform) for action in Actions.get_all_actions(): action.connect('activate', self._handle_actions) #setup the main window self.main_window = MainWindow(self.handle_states, platform) @@ -133,7 +131,7 @@ class ActionHandler: Actions.FLOW_GRAPH_OPEN, Actions.FLOW_GRAPH_SAVE_AS, Actions.FLOW_GRAPH_CLOSE, Actions.ABOUT_WINDOW_DISPLAY, Actions.FLOW_GRAPH_SCREEN_CAPTURE, Actions.HELP_WINDOW_DISPLAY, - Actions.COLORS_WINDOW_DISPLAY, + Actions.TYPES_WINDOW_DISPLAY, ): Actions.get_action_from_name(action).set_sensitive(True) if not self.init_file_paths: self.init_file_paths = Preferences.files_open() @@ -221,13 +219,11 @@ class ActionHandler: elif state == Actions.PORT_CONTROLLER_INC: if self.get_flow_graph().port_controller_modify_selected(1): self.get_flow_graph().update() - self.get_flow_graph().update() #2 times self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data()) self.get_page().set_saved(False) elif state == Actions.PORT_CONTROLLER_DEC: if self.get_flow_graph().port_controller_modify_selected(-1): self.get_flow_graph().update() - self.get_flow_graph().update() #2 times self.get_page().get_state_cache().save_new_state(self.get_flow_graph().export_data()) self.get_page().set_saved(False) ################################################## @@ -237,8 +233,8 @@ class ActionHandler: Dialogs.AboutDialog(self.get_flow_graph().get_parent()) elif state == Actions.HELP_WINDOW_DISPLAY: Dialogs.HelpDialog() - elif state == Actions.COLORS_WINDOW_DISPLAY: - Dialogs.ColorsDialog(self.get_flow_graph().get_parent()) + elif state == Actions.TYPES_WINDOW_DISPLAY: + Dialogs.TypesDialog(self.get_flow_graph().get_parent()) ################################################## # Param Modifications ################################################## diff --git a/grc/gui/Actions.py b/grc/gui/Actions.py index 3695e09ef..c3ef2711a 100644 --- a/grc/gui/Actions.py +++ b/grc/gui/Actions.py @@ -57,7 +57,7 @@ FLOW_GRAPH_KILL = 'flow graph kill' FLOW_GRAPH_SCREEN_CAPTURE = 'flow graph screen capture' ABOUT_WINDOW_DISPLAY = 'about window display' HELP_WINDOW_DISPLAY = 'help window display' -COLORS_WINDOW_DISPLAY = 'colors window display' +TYPES_WINDOW_DISPLAY = 'types window display' ###################################################################################################### # Action Key Map @@ -132,7 +132,7 @@ _actions_list = ( gtk.Action(BLOCK_PASTE, '_Paste', 'Paste', gtk.STOCK_PASTE), gtk.Action(ABOUT_WINDOW_DISPLAY, '_About', 'About this program', gtk.STOCK_ABOUT), gtk.Action(HELP_WINDOW_DISPLAY, '_Help', 'Usage Tips', gtk.STOCK_HELP), - gtk.Action(COLORS_WINDOW_DISPLAY, '_Colors', 'Color Mapping', gtk.STOCK_DIALOG_INFO), + gtk.Action(TYPES_WINDOW_DISPLAY, '_Types', 'Types Color Mapping', gtk.STOCK_DIALOG_INFO), gtk.Action(FLOW_GRAPH_GEN, '_Generate', 'Generate the flow graph', gtk.STOCK_CONVERT), gtk.Action(FLOW_GRAPH_EXEC, '_Execute', 'Execute the flow graph', gtk.STOCK_EXECUTE), gtk.Action(FLOW_GRAPH_KILL, '_Kill', 'Kill the flow graph', gtk.STOCK_STOP), diff --git a/grc/gui/Bars.py b/grc/gui/Bars.py index e0c547eba..697d48a3c 100644 --- a/grc/gui/Bars.py +++ b/grc/gui/Bars.py @@ -88,7 +88,7 @@ MENU_BAR_LIST = ( ]), (gtk.Action('Help', '_Help', None, None), [ Actions.HELP_WINDOW_DISPLAY, - Actions.COLORS_WINDOW_DISPLAY, + Actions.TYPES_WINDOW_DISPLAY, None, Actions.ABOUT_WINDOW_DISPLAY, ]), diff --git a/grc/gui/Block.py b/grc/gui/Block.py index 4add3aa19..0f3e511d8 100644 --- a/grc/gui/Block.py +++ b/grc/gui/Block.py @@ -44,8 +44,8 @@ class Block(Element): """ #add the position param self.get_params().append(self.get_parent().get_parent().Param( - self, - odict({ + block=self, + n=odict({ 'name': 'GUI Coordinate', 'key': '_coordinate', 'type': 'raw', @@ -54,8 +54,8 @@ class Block(Element): }) )) self.get_params().append(self.get_parent().get_parent().Param( - self, - odict({ + block=self, + n=odict({ 'name': 'GUI Rotation', 'key': '_rotation', 'type': 'raw', diff --git a/grc/gui/Dialogs.py b/grc/gui/Dialogs.py index 8d764e28e..3cf617b92 100644 --- a/grc/gui/Dialogs.py +++ b/grc/gui/Dialogs.py @@ -98,8 +98,8 @@ COLORS_DIALOG_MARKUP_TMPL = """\ #end if """ -def ColorsDialog(platform): MessageDialogHelper( +def TypesDialog(platform): MessageDialogHelper( type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_CLOSE, - title='Colors', + title='Types', markup=Utils.parse_template(COLORS_DIALOG_MARKUP_TMPL, colors=platform.get_colors())) diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py index f8028f199..5e645be72 100644 --- a/grc/gui/FlowGraph.py +++ b/grc/gui/FlowGraph.py @@ -291,8 +291,10 @@ class FlowGraph(Element): def update(self): """ + Do a global rewrite and validate. Call update on all elements. """ + self.rewrite() self.validate() for element in self.get_elements(): element.update() diff --git a/grc/gui/Param.py b/grc/gui/Param.py index a11fd9065..4955d3336 100644 --- a/grc/gui/Param.py +++ b/grc/gui/Param.py @@ -23,6 +23,71 @@ import pygtk pygtk.require('2.0') import gtk +class InputParam(gtk.HBox): + """The base class for an input parameter inside the input parameters dialog.""" + + def __init__(self, param, _handle_changed): + gtk.HBox.__init__(self) + self.param = param + self._handle_changed = _handle_changed + self.label = gtk.Label('') #no label, markup is added by set_markup + self.label.set_size_request(150, -1) + self.pack_start(self.label, False) + self.set_markup = lambda m: self.label.set_markup(m) + self.tp = None + def set_color(self, color): pass + +class EntryParam(InputParam): + """Provide an entry box for strings and numbers.""" + + def __init__(self, *args, **kwargs): + InputParam.__init__(self, *args, **kwargs) + self.entry = input = gtk.Entry() + input.set_text(self.param.get_value()) + input.connect('changed', self._handle_changed) + self.pack_start(input, True) + self.get_text = input.get_text + #tool tip + self.tp = gtk.Tooltips() + self.tp.set_tip(self.entry, '') + self.tp.enable() + def set_color(self, color): self.entry.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) + +class EnumParam(InputParam): + """Provide an entry box for Enum types with a drop down menu.""" + + def __init__(self, *args, **kwargs): + InputParam.__init__(self, *args, **kwargs) + self._input = gtk.combo_box_new_text() + for option in self.param.get_options(): self._input.append_text(option.get_name()) + self._input.set_active(self.param.get_option_keys().index(self.param.get_value())) + self._input.connect('changed', self._handle_changed) + self.pack_start(self._input, False) + def get_text(self): return self.param.get_option_keys()[self._input.get_active()] + +class EnumEntryParam(InputParam): + """Provide an entry box and drop down menu for Raw Enum types.""" + + def __init__(self, *args, **kwargs): + InputParam.__init__(self, *args, **kwargs) + self._input = gtk.combo_box_entry_new_text() + for option in self.param.get_options(): self._input.append_text(option.get_name()) + try: self._input.set_active(self.param.get_option_keys().index(self.param.get_value())) + except: + self._input.set_active(-1) + self._input.get_child().set_text(self.param.get_value()) + self._input.connect('changed', self._handle_changed) + self._input.get_child().connect('changed', self._handle_changed) + self.pack_start(self._input, False) + def get_text(self): + if self._input.get_active() == -1: return self._input.get_child().get_text() + return self.param.get_option_keys()[self._input.get_active()] + def set_color(self, color): + if self._input.get_active() == -1: #custom entry, use color + self._input.get_child().modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) + else: #from enum, make white background + self._input.get_child().modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ffffff')) + PARAM_MARKUP_TMPL="""\ #set $foreground = $param.is_valid() and 'black' or 'red' <span foreground="$foreground" font_desc="Sans 7.5"><b>$encode($param.get_name()): </b>$encode(repr($param))</span>""" @@ -49,6 +114,18 @@ Error: class Param(Element): """The graphical parameter.""" + def get_input_class(self): + """ + Get the graphical gtk class to represent this parameter. + An enum requires and combo parameter. + A non-enum with options gets a combined entry/combo parameter. + All others get a standard entry parameter. + @return gtk input class + """ + if self.is_enum(): return EnumParam + if self.get_options(): return EnumEntryParam + return EntryParam + def update(self): """ Called when an external change occurs. diff --git a/grc/gui/Platform.py b/grc/gui/Platform.py index a32b0209f..8f0aa533d 100644 --- a/grc/gui/Platform.py +++ b/grc/gui/Platform.py @@ -1,5 +1,5 @@ """ -Copyright 2008 Free Software Foundation, Inc. +Copyright 2008, 2009 Free Software Foundation, Inc. This file is part of GNU Radio GNU Radio Companion is free software; you can redistribute it and/or @@ -17,32 +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 FlowGraph import FlowGraph -from Connection import Connection -from Block import Block -from Port import Port -from Param import Param +from Element import Element -def conjoin_classes(name, c1, c2): - exec(""" -class %s(c1, c2): - def __init__(self, *args, **kwargs): - c1.__init__(self, *args, **kwargs) - c2.__init__(self, *args, **kwargs) -"""%name, locals()) - return locals()[name] - -def Platform(platform): - #combine with gui class - for attr, value in ( - ('FlowGraph', FlowGraph), - ('Connection', Connection), - ('Block', Block), - ('Source', Port), - ('Sink', Port), - ('Param', Param), - ): - old_value = getattr(platform, attr) - c = conjoin_classes(attr, old_value, value) - setattr(platform, attr, c) - return platform +class Platform(Element): pass diff --git a/grc/gui/Port.py b/grc/gui/Port.py index d1f36f8b9..6fc2c4b15 100644 --- a/grc/gui/Port.py +++ b/grc/gui/Port.py @@ -1,5 +1,5 @@ """ -Copyright 2007 Free Software Foundation, Inc. +Copyright 2007, 2008, 2009 Free Software Foundation, Inc. This file is part of GNU Radio GNU Radio Companion is free software; you can redistribute it and/or |