diff options
author | Josh Blum | 2009-09-06 01:17:35 -0700 |
---|---|---|
committer | Josh Blum | 2009-09-06 01:17:35 -0700 |
commit | e39507bf32666f9b17d2249106aac0d6cbcacc58 (patch) | |
tree | ce86aefabac458a9e8599ebd26249521437a4f59 /grc | |
parent | a6cb9eceeb62593e852b6dea0f640436381ec947 (diff) | |
download | gnuradio-e39507bf32666f9b17d2249106aac0d6cbcacc58.tar.gz gnuradio-e39507bf32666f9b17d2249106aac0d6cbcacc58.tar.bz2 gnuradio-e39507bf32666f9b17d2249106aac0d6cbcacc58.zip |
propsdialog tweaks
Diffstat (limited to 'grc')
-rw-r--r-- | grc/gui/Param.py | 13 | ||||
-rw-r--r-- | grc/gui/PropsDialog.py | 39 | ||||
-rw-r--r-- | grc/python/Param.py | 6 | ||||
-rw-r--r-- | grc/todo.txt | 1 |
4 files changed, 29 insertions, 30 deletions
diff --git a/grc/gui/Param.py b/grc/gui/Param.py index 9cd31b8a4..b84598e61 100644 --- a/grc/gui/Param.py +++ b/grc/gui/Param.py @@ -39,7 +39,7 @@ class InputParam(gtk.HBox): def update(self): """ - Set the markup, color, and tooltip. + Set the markup, color, tooltip, show/hide. """ #set the markup has_cb = \ @@ -53,6 +53,9 @@ class InputParam(gtk.HBox): self.entry, Utils.parse_template(TIP_MARKUP_TMPL, param=self.param).strip(), ) + #show/hide + if self.param.get_hide() == 'all': self.hide_all() + else: self.show_all() def _handle_changed(self, *args): """ @@ -144,7 +147,7 @@ class Param(Element): def __init__(self): Element.__init__(self) - def get_input_class(self): + def get_input(self, *args, **kwargs): """ Get the graphical gtk class to represent this parameter. An enum requires and combo parameter. @@ -152,9 +155,9 @@ class Param(Element): 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 + if self.is_enum(): return EnumParam(*args, **kwargs) + if self.get_options(): return EnumEntryParam(*args, **kwargs) + return EntryParam(*args, **kwargs) def get_layout(self): """ diff --git a/grc/gui/PropsDialog.py b/grc/gui/PropsDialog.py index 9be0400fe..aa86f7214 100644 --- a/grc/gui/PropsDialog.py +++ b/grc/gui/PropsDialog.py @@ -47,13 +47,13 @@ class PropsDialog(gtk.Dialog): Properties dialog contructor. @param block a block instance """ - self._hash = '' + self._hash = 0 LABEL_SPACING = 7 gtk.Dialog.__init__(self, title='Properties: %s'%block.get_name(), buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE), ) - self.block = block + self._block = block self.set_size_request(MIN_DIALOG_WIDTH, MIN_DIALOG_HEIGHT) vbox = gtk.VBox() #Create the scrolled window to hold all the parameters @@ -90,17 +90,15 @@ class PropsDialog(gtk.Dialog): def _params_changed(self): """ Have the params in this dialog changed? - Ex: Added, removed, type change, hidden, shown? + Ex: Added, removed, type change... Make a hash that uniquely represents the params state. @return true if changed """ old_hash = self._hash - str_accum = '' - for param in self.block.get_params(): - str_accum += param.get_key() - str_accum += param.get_type() - str_accum += param.get_hide() - self._hash = hash(str_accum) + self._hash = 0 + for param in self._block.get_params(): + self._hash ^= hash(param) + self._hash ^= hash(param.get_type()) return self._hash != old_hash def _update(self): @@ -113,33 +111,32 @@ class PropsDialog(gtk.Dialog): Hide the box if there are no docs. """ #update for the block - self.block.rewrite() - self.block.validate() + self._block.rewrite() + self._block.validate() #update the params box if self._params_changed(): #empty the params box for io_param in list(self._input_object_params): + io_param.hide_all() self._params_box.remove(io_param) self._input_object_params.remove(io_param) io_param.destroy() #repopulate the params box - for param in self.block.get_params(): - if param.get_hide() == 'all': continue - io_param = param.get_input_class()(param, callback=self._update) + for param in self._block.get_params(): + io_param = param.get_input(param, callback=self._update) self._input_object_params.append(io_param) self._params_box.pack_start(io_param, False) - self._params_box.show_all() #update the gui inputs for io_param in self._input_object_params: io_param.update() #update the errors box - if self.block.is_valid(): self._error_box.hide() + if self._block.is_valid(): self._error_box.hide() else: self._error_box.show() - messages = '\n\n'.join(self.block.get_error_messages()) + messages = '\n\n'.join(self._block.get_error_messages()) self._error_messages_text_display.set_text(messages) #update the docs box - if self.block.get_doc(): self._docs_box.show() + if self._block.get_doc(): self._docs_box.show() else: self._docs_box.hide() - self._docs_text_display.set_text(self.block.get_doc()) + self._docs_text_display.set_text(self._block.get_doc()) def _handle_key_press(self, widget, event): """ @@ -157,11 +154,11 @@ class PropsDialog(gtk.Dialog): @return true if a change occured. """ original_data = list() - for param in self.block.get_params(): + for param in self._block.get_params(): original_data.append(param.get_value()) gtk.Dialog.run(self) self.destroy() new_data = list() - for param in self.block.get_params(): + for param in self._block.get_params(): new_data.append(param.get_value()) return original_data != new_data diff --git a/grc/python/Param.py b/grc/python/Param.py index e61779136..c64659a08 100644 --- a/grc/python/Param.py +++ b/grc/python/Param.py @@ -153,9 +153,9 @@ class Param(_Param, _GUIParam): dt_str = dt_str[:max_len-3] + '...' return dt_str - def get_input_class(self): - if self.get_type() in ('file_open', 'file_save'): return FileParam - return _GUIParam.get_input_class(self) + def get_input(self, *args, **kwargs): + if self.get_type() in ('file_open', 'file_save'): return FileParam(*args, **kwargs) + return _GUIParam.get_input(self, *args, **kwargs) def get_color(self): """ diff --git a/grc/todo.txt b/grc/todo.txt index 2735ff2af..c675859d1 100644 --- a/grc/todo.txt +++ b/grc/todo.txt @@ -69,7 +69,6 @@ * threads dont die on exit in probe and variable sink * align param titles in properties dialog * weird grid params misbehaving -* properties dialog needs to show connection errors * fix param input stuff for usrp probes ################################################## |