[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 31/43: grc: PropsDialog: apply button and h
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 31/43: grc: PropsDialog: apply button and hotkey (Ctrl+Enter) |
Date: |
Thu, 2 Apr 2015 19:15:52 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 9b57c33393dda48933fd5968070a4a7cac1290ca
Author: Sebastian Koslowski <address@hidden>
Date: Thu Apr 2 15:52:18 2015 +0200
grc: PropsDialog: apply button and hotkey (Ctrl+Enter)
---
grc/gui/Param.py | 30 ++++++++++++++++++++++--------
grc/gui/PropsDialog.py | 19 ++++++++++++++++---
2 files changed, 38 insertions(+), 11 deletions(-)
diff --git a/grc/gui/Param.py b/grc/gui/Param.py
index 2ef8603..1efa563 100644
--- a/grc/gui/Param.py
+++ b/grc/gui/Param.py
@@ -72,20 +72,31 @@ 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."""
@@ -94,7 +105,8 @@ 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('focus-out-event', self.apply_change)
+ self._input.connect('key-press-event', self._handle_key_press)
self.pack_start(self._input, True)
def get_text(self): return self._input.get_text()
def set_color(self, color):
@@ -114,7 +126,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):
@@ -123,6 +135,7 @@ 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."""
@@ -134,9 +147,10 @@ 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('focus-out-event', self.apply_change)
+ self._input.get_child().connect('key-press-event',
self._handle_key_press)
self.pack_start(self._input, False)
def get_text(self):
if self._input.get_active() == -1: return
self._input.get_child().get_text()
@@ -191,7 +205,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 d7ba8c5..d172175 100644
--- a/grc/gui/PropsDialog.py
+++ b/grc/gui/PropsDialog.py
@@ -65,7 +65,9 @@ class PropsDialog(gtk.Dialog):
gtk.Dialog.__init__(
self,
title='Properties: %s' % block.get_name(),
- buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK,
gtk.RESPONSE_ACCEPT),
+ buttons=(gtk.STOCK_OK, gtk.RESPONSE_ACCEPT,
+ gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
+ gtk.STOCK_APPLY, gtk.RESPONSE_APPLY)
)
self._block = block
self.set_size_request(MIN_DIALOG_WIDTH, MIN_DIALOG_HEIGHT)
@@ -109,6 +111,7 @@ 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):
@@ -183,11 +186,18 @@ class PropsDialog(gtk.Dialog):
Returns:
false to forward the keypress
"""
- if event.keyval == gtk.keysyms.Return:
+ if event.keyval == gtk.keysyms.Return and event.state &
gtk.gdk.CONTROL_MASK == 0:
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.
@@ -195,6 +205,9 @@ class PropsDialog(gtk.Dialog):
Returns:
true if the response was accept
"""
- response = gtk.Dialog.run(self)
+ response = gtk.RESPONSE_APPLY
+ # don't close dialog on apply click
+ while response == gtk.RESPONSE_APPLY:
+ response = gtk.Dialog.run(self)
self.destroy()
return response == gtk.RESPONSE_ACCEPT
- [Commit-gnuradio] [gnuradio] 19/43: gnuradio-runtime: added logger to flat_flowgraph and print out a warning for when the max_output_buffer isn't set to the requested value, (continued)
- [Commit-gnuradio] [gnuradio] 19/43: gnuradio-runtime: added logger to flat_flowgraph and print out a warning for when the max_output_buffer isn't set to the requested value, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 28/43: grc: don't try to open missing files, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 01/43: gnuradio-runtime: trying to see if this will handle the output buffer size of hier blocks; trying to find the proper casting methods, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 10/43: fec: cleaning up LDPC warnings, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 18/43: fec: ldpc works, add iterations meta tag, etc, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 34/43: Merge remote-tracking branch 'saikwolf/logging_flat_flowgraph', git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 03/43: gnuradio-runtime:: removed the individual port setting on hier_block2, current operation assuming the buffers are being set for latency and therefore all blocks are being set to a small amount, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 11/43: fec: LDPC cleaning up comments, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 30/43: grc: clean-up 'gnuradio-companion', add mode 'run from source', git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 12/43: fec: re-shuffling LDPC make helper, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 31/43: grc: PropsDialog: apply button and hotkey (Ctrl+Enter),
git <=
- [Commit-gnuradio] [gnuradio] 40/43: fec: Move the definition of yp_kernel from the class into a temp variable in the main code. This variable is used just to find the actual Volk kernel, and its current use is not c++11 complaint. Moving it makes the code c++11 complaint on both GCC / libstdc++ and Clang / libc++., git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 35/43: Merge remote-tracking branch 'osh/ldpc_add', git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 20/43: grc: Reworked save confirmation dialog to allow cancel option, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 42/43: Merge remote-tracking branch 'michaelld/misc_fixes', git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 29/43: grc: move context def into Bars.py and add submenu, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 14/43: gnuradio-runtime: modified buffer length types to size_t, moved buffer length vectors into detail, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 22/43: grc: close unsaved pages first (for cancel save option), git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 13/43: fec: ldpc GRC compat cleanup, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 36/43: Merge remote-tracking branch 'fengzhe/chunks_to_symbols_update', git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 25/43: grc: set permissions for generated files, git, 2015/04/02