kuuko pushed a commit to branch master.

http://git.enlightenment.org/apps/epour.git/commit/?id=14744a326b1e2fe57b45ed24e3a6554df6103290

commit 14744a326b1e2fe57b45ed24e3a6554df6103290
Author: Kai Huuhko <[email protected]>
Date:   Thu Jul 10 16:00:37 2014 +0300

    Fix encryption settings
---
 epour/gui/Preferences.py | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/epour/gui/Preferences.py b/epour/gui/Preferences.py
index abba72c..4dabc99 100644
--- a/epour/gui/Preferences.py
+++ b/epour/gui/Preferences.py
@@ -444,11 +444,9 @@ class EncryptionSettings(Frame):
         self.content = b
 
     def apply(self, btn):
-        # TODO: Use callbacks to set these?
         self.pes.in_enc_policy = self.inc.get_value()
         self.pes.out_enc_policy = self.out.get_value()
 
-        # FIXME: Find out why this isn't saved to the session.
         self.pes.allowed_enc_level = self.lvl.get_value()
         self.pes.prefer_rc4 = self.prf.state
 
@@ -460,11 +458,16 @@ class ActSWithLabel(Box):
     def __init__(self, parent, label_text, values, initial_value):
         Box.__init__(self, parent)
 
-        self.vd = {
+        self.pos_to_v = {
             ELM_ACTIONSLIDER_LEFT: values[0],
             ELM_ACTIONSLIDER_CENTER: values[1],
             ELM_ACTIONSLIDER_RIGHT: values[2],
         }
+        self.v_to_pos = {
+            values[0]: ELM_ACTIONSLIDER_LEFT,
+            values[1]: ELM_ACTIONSLIDER_CENTER,
+            values[2]: ELM_ACTIONSLIDER_RIGHT,
+        }
 
         self.horizontal = True
         self.size_hint_align = FILL_HORIZ
@@ -483,13 +486,20 @@ class ActSWithLabel(Box):
 
         for i, v in enumerate(values):
             w.part_text_set(parts[i], str(v))
-        w.indicator_pos = values.index(initial_value) + 1
+
+        init_v = self.v_to_pos[initial_value]
+        log.debug("Setting initial indicator pos to %d", init_v)
+        w.indicator_pos = init_v
 
         self.pack_end(l)
         self.pack_end(w)
 
     def get_value(self):
-        return self.vd[self.w.indicator_pos]
+        pos = self.w.indicator_pos
+        log.debug("Indicator pos is %d", pos)
+        value = self.vd[pos]
+        log.debug("Value is %d (%s)", int(value), str(value))
+        return value
 
 
 class PreferencesSession(PreferencesDialog):

-- 


Reply via email to