diff options
-rw-r--r-- | grc/gui/Param.py | 30 | ||||
-rw-r--r-- | grc/gui/PropsDialog.py | 19 |
2 files changed, 11 insertions, 38 deletions
diff --git a/grc/gui/Param.py b/grc/gui/Param.py index 1efa56326e..2ef8603a83 100644 --- a/grc/gui/Param.py +++ b/grc/gui/Param.py @@ -72,31 +72,20 @@ class InputParam(gtk.HBox): self._changed_but_unchecked = True self._update_gui() - def apply_change(self, *args): + def _apply_change(self, *args): """ Handle a gui change by setting the new param value, calling the callback (if applicable), and updating. """ - if not self._changed_but_unchecked: - return #set the new value self.param.set_value(self.get_text()) #call the callback - if self._callback: - self._callback(*args) - else: - self.param.validate() + if self._callback: self._callback(*args) + else: self.param.validate() #gui update self._changed_but_unchecked = False self._update_gui() - def _handle_key_press(self, widget, event): - if event.keyval == gtk.keysyms.Return and event.state & gtk.gdk.CONTROL_MASK: - self.apply_change() - return True - return False - - class EntryParam(InputParam): """Provide an entry box for strings and numbers.""" @@ -105,8 +94,7 @@ class EntryParam(InputParam): self._input = gtk.Entry() self._input.set_text(self.param.get_value()) self._input.connect('changed', self._mark_changed) - self._input.connect('focus-out-event', self.apply_change) - self._input.connect('key-press-event', self._handle_key_press) + self._input.connect('focus-out-event', self._apply_change) self.pack_start(self._input, True) def get_text(self): return self._input.get_text() def set_color(self, color): @@ -126,7 +114,7 @@ class EnumParam(InputParam): 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.apply_change) + self._input.connect('changed', self._apply_change) self.pack_start(self._input, False) def get_text(self): return self.param.get_option_keys()[self._input.get_active()] def set_tooltip_text(self, text): @@ -135,7 +123,6 @@ class EnumParam(InputParam): except AttributeError: pass # no tooltips for old GTK - class EnumEntryParam(InputParam): """Provide an entry box and drop down menu for Raw Enum types.""" @@ -147,10 +134,9 @@ class EnumEntryParam(InputParam): except: self._input.set_active(-1) self._input.get_child().set_text(self.param.get_value()) - self._input.connect('changed', self.apply_change) + self._input.connect('changed', self._apply_change) self._input.get_child().connect('changed', self._mark_changed) - self._input.get_child().connect('focus-out-event', self.apply_change) - self._input.get_child().connect('key-press-event', self._handle_key_press) + self._input.get_child().connect('focus-out-event', self._apply_change) self.pack_start(self._input, False) def get_text(self): if self._input.get_active() == -1: return self._input.get_child().get_text() @@ -205,7 +191,7 @@ class FileParam(EntryParam): if gtk.RESPONSE_OK == file_dialog.run(): #run the dialog file_path = file_dialog.get_filename() #get the file path self._input.set_text(file_path) - self.apply_change() + self._apply_change() file_dialog.destroy() #destroy the dialog diff --git a/grc/gui/PropsDialog.py b/grc/gui/PropsDialog.py index d172175aba..d7ba8c51c9 100644 --- a/grc/gui/PropsDialog.py +++ b/grc/gui/PropsDialog.py @@ -65,9 +65,7 @@ class PropsDialog(gtk.Dialog): gtk.Dialog.__init__( self, title='Properties: %s' % block.get_name(), - buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT, - gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, - gtk.STOCK_APPLY, gtk.RESPONSE_APPLY) + 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) @@ -111,7 +109,6 @@ class PropsDialog(gtk.Dialog): # Connect events self.connect('key-press-event', self._handle_key_press) self.connect('show', self._update_gui) - self.connect('response', self._handle_response) self.show_all() # show all (performs initial gui update) def _params_changed(self): @@ -186,18 +183,11 @@ class PropsDialog(gtk.Dialog): Returns: false to forward the keypress """ - if event.keyval == gtk.keysyms.Return and event.state & gtk.gdk.CONTROL_MASK == 0: + if event.keyval == gtk.keysyms.Return: self.response(gtk.RESPONSE_ACCEPT) return True # handled here return False # forward the keypress - def _handle_response(self, widget, response): - if response == gtk.RESPONSE_APPLY: - for tab, label, vbox in self._params_boxes: - vbox.forall(lambda c: c.apply_change()) - return True - return False - def run(self): """ Run the dialog and get its response. @@ -205,9 +195,6 @@ class PropsDialog(gtk.Dialog): Returns: true if the response was accept """ - response = gtk.RESPONSE_APPLY - # don't close dialog on apply click - while response == gtk.RESPONSE_APPLY: - response = gtk.Dialog.run(self) + response = gtk.Dialog.run(self) self.destroy() return response == gtk.RESPONSE_ACCEPT |