propsdialog tweaks
authorJosh Blum <josh@joshknows.com>
Sun, 6 Sep 2009 08:17:35 +0000 (01:17 -0700)
committerJosh Blum <josh@joshknows.com>
Sun, 6 Sep 2009 08:17:35 +0000 (01:17 -0700)
grc/gui/Param.py
grc/gui/PropsDialog.py
grc/python/Param.py
grc/todo.txt

index 9cd31b8a4dc90f74d49adeaaaf853473ace0af34..b84598e61c7ea87d2fff8102d2afd480450f1a1b 100644 (file)
@@ -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):
                """
index 9be0400fe802f32dfd46d822d215d8f84c1db3c3..aa86f7214bb8bb4cce1a826fcb1ad22a66574756 100644 (file)
@@ -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
index e61779136c0698b5104f04c3d9e4b50a1e6c4326..c64659a080690583a9de36441af90485bdbfca50 100644 (file)
@@ -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):
                """
index 2735ff2af24b578708d349d01f9e50743bb08407..c675859d169f436835d56e5a6706db4bdcfe38b9 100644 (file)
@@ -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
 
 ##################################################