X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=grc%2Fgui%2FPropsDialog.py;h=cc84fd0888007f14d768b13d71ba7792fcc58818;hb=refs%2Fheads%2Fdfsg-orig;hp=49650041690554d9d2ddf099afa5b11c2cd53acb;hpb=b8f69ad7ba49aa85239f6de611ddfd040344f66b;p=debian%2Fgnuradio diff --git a/grc/gui/PropsDialog.py b/grc/gui/PropsDialog.py index 49650041..cc84fd08 100644 --- a/grc/gui/PropsDialog.py +++ b/grc/gui/PropsDialog.py @@ -51,7 +51,7 @@ class PropsDialog(gtk.Dialog): LABEL_SPACING = 7 gtk.Dialog.__init__(self, title='Properties: %s'%block.get_name(), - buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE), + buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT), ) self._block = block self.set_size_request(MIN_DIALOG_WIDTH, MIN_DIALOG_HEIGHT) @@ -82,7 +82,7 @@ class PropsDialog(gtk.Dialog): vbox.pack_start(self._error_box, False) vbox.pack_start(self._docs_box, False) #connect events - self.connect('key_press_event', self._handle_key_press) + self.connect('key-press-event', self._handle_key_press) self.connect('show', self._update_gui) #show all (performs initial gui update) self.show_all() @@ -91,15 +91,16 @@ class PropsDialog(gtk.Dialog): """ Have the params in this dialog changed? Ex: Added, removed, type change, hide change... - Make a hash that uniquely represents the params state. + To the props dialog, the hide setting of 'none' and 'part' are identical. + Therfore, the props dialog only cares if the hide setting is/not 'all'. + Make a hash that uniquely represents the params' state. @return true if changed """ old_hash = self._hash - self._hash = 0 - for param in self._block.get_params(): - self._hash ^= hash(param) - self._hash ^= hash(param.get_type()) - self._hash ^= hash(param.get_hide()) + #create a tuple of things from each param that affects the params box + self._hash = hash(tuple([( + hash(param), param.get_type(), param.get_hide() == 'all', + ) for param in self._block.get_params()])) return self._hash != old_hash def _handle_changed(self, *args): @@ -154,21 +155,16 @@ class PropsDialog(gtk.Dialog): Call the ok response when enter is pressed. @return false to forward the keypress """ - keyname = gtk.gdk.keyval_name(event.keyval) - if keyname == 'Return': self.response(gtk.RESPONSE_OK) + if event.keyval == gtk.keysyms.Return: + self.response(gtk.RESPONSE_ACCEPT) + return True #handled here return False #forward the keypress def run(self): """ - Call run(). - @return true if a change occured. + Run the dialog and get its response. + @return true if the response was accept """ - original_data = list() - for param in self._block.get_params(): - original_data.append(param.get_value()) - gtk.Dialog.run(self) + response = gtk.Dialog.run(self) self.destroy() - new_data = list() - for param in self._block.get_params(): - new_data.append(param.get_value()) - return original_data != new_data + return response == gtk.RESPONSE_ACCEPT