[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 10/15: grc: validate params only on focus-o
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 10/15: grc: validate params only on focus-out |
Date: |
Thu, 10 Apr 2014 19:38:18 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch master
in repository gnuradio.
commit 9880ba4cd98925c9e5803847ff22af8038514fba
Author: Sebastian Koslowski <address@hidden>
Date: Wed Apr 9 18:32:10 2014 +0200
grc: validate params only on focus-out
---
grc/gui/Param.py | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/grc/gui/Param.py b/grc/gui/Param.py
index 7d59708..4fa8a5d 100644
--- a/grc/gui/Param.py
+++ b/grc/gui/Param.py
@@ -37,6 +37,7 @@ class InputParam(gtk.HBox):
self.pack_start(self.label, False)
self.set_markup = lambda m: self.label.set_markup(m)
self.tp = None
+ self._changed_but_unchecked = False
#connect events
self.connect('show', self._update_gui)
def set_color(self, color): pass
@@ -50,7 +51,9 @@ class InputParam(gtk.HBox):
has_cb = \
hasattr(self.param.get_parent(), 'get_callbacks') and \
filter(lambda c: self.param.get_key() in c,
self.param.get_parent()._callbacks)
- self.set_markup(Utils.parse_template(PARAM_LABEL_MARKUP_TMPL,
param=self.param, has_cb=has_cb))
+ self.set_markup(Utils.parse_template(PARAM_LABEL_MARKUP_TMPL,
+ param=self.param, has_cb=has_cb,
+ modified=self._changed_but_unchecked))
#set the color
self.set_color(self.param.get_color())
#set the tooltip
@@ -63,6 +66,13 @@ class InputParam(gtk.HBox):
def _handle_changed(self, *args):
"""
+ Mark this param as modified on change, but validate only on focus-lost
+ """
+ self._changed_but_unchecked = True
+ self._update_gui()
+
+ def _handle_focus_out(self, *args):
+ """
Handle a gui change by setting the new param value,
calling the callback (if applicable), and updating.
"""
@@ -72,6 +82,7 @@ class InputParam(gtk.HBox):
if self._callback: self._callback(*args)
else: self.param.validate()
#gui update
+ self._changed_but_unchecked = False
self._update_gui()
class EntryParam(InputParam):
@@ -82,6 +93,7 @@ class EntryParam(InputParam):
self._input = gtk.Entry()
self._input.set_text(self.param.get_value())
self._input.connect('changed', self._handle_changed)
+ self._input.connect('focus-out-event', self._handle_focus_out)
self.pack_start(self._input, True)
def get_text(self): return self._input.get_text()
def set_color(self, color):
@@ -98,6 +110,7 @@ class EnumParam(InputParam):
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._handle_changed)
+ self._input.connect('focus-out-event', self._handle_focus_out)
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): self._input.set_tooltip_text(text)
@@ -114,7 +127,9 @@ class EnumEntryParam(InputParam):
self._input.set_active(-1)
self._input.get_child().set_text(self.param.get_value())
self._input.connect('changed', self._handle_changed)
+ self._input.connect('focus-out-event', self._handle_focus_out)
self._input.get_child().connect('changed', self._handle_changed)
+ self._input.get_child().connect('focus-out-event',
self._handle_focus_out)
self.pack_start(self._input, False)
def get_text(self):
if self._input.get_active() == -1: return
self._input.get_child().get_text()
@@ -174,7 +189,7 @@ PARAM_MARKUP_TMPL="""\
<span foreground="$foreground" font_desc="Sans
7.5"><b>$encode($param.get_name()): </b>$encode(repr($param))</span>"""
PARAM_LABEL_MARKUP_TMPL="""\
-#set $foreground = $param.is_valid() and 'black' or 'red'
+#set $foreground = $modified and 'blue' or $param.is_valid() and 'black' or
'red'
#set $underline = $has_cb and 'low' or 'none'
<span underline="$underline" foreground="$foreground" font_desc="Sans
9">$encode($param.get_name())</span>"""
- [Commit-gnuradio] [gnuradio] branch master updated (cd06fdc -> 4b55c7f), git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 12/15: digital: white space removal., git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 10/15: grc: validate params only on focus-out,
git <=
- [Commit-gnuradio] [gnuradio] 11/15: Merge remote-tracking branch 'mmueller/pmt_to_python-py2.6-compat', git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 06/15: Merge branch 'master' of github:gnuradio/gnuradio into pmt_to_python-py2.6-compat, git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 02/15: qtgui: fixing up some minor parameters., git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 09/15: grc: move FileParam to gui module, git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 05/15: renamed and cleaned up a bit, git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 04/15: pmt_to_python: numpy_to_uvector and reverse works, QA added, git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 01/15: set numpy_mappings -> dict, to fix py2.6 incompatibility, git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 07/15: grc: adding param templates, git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 03/15: volk: changes QA code to use volk_malloc and volk_free., git, 2014/04/10
- [Commit-gnuradio] [gnuradio] 14/15: digital: fix for issue #663., git, 2014/04/10