commit-gnuradio
[Top][All Lists]
Advanced

[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>"""
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]