kuuko pushed a commit to branch master.

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

commit e195ceaa016d80c77d317e6839c2c97709e73056
Author: Kai Huuhko <kai.huu...@gmail.com>
Date:   Fri Jan 17 11:06:05 2014 +0200

    Changed the preferences popups into windows to allow more room for them.
---
 epour/gui/Preferences.py | 149 +++++++++++++++++++++++------------------------
 1 file changed, 72 insertions(+), 77 deletions(-)

diff --git a/epour/gui/Preferences.py b/epour/gui/Preferences.py
index 7b24b8e..fc4f76b 100644
--- a/epour/gui/Preferences.py
+++ b/epour/gui/Preferences.py
@@ -26,40 +26,31 @@ log = logging.getLogger("epour")
 
 import libtorrent as lt
 
-try:
-    from efl.elementary.icon import Icon
-    from efl.elementary.box import Box
-    from efl.elementary.label import Label
-    from efl.elementary.button import Button
-    from efl.elementary.frame import Frame
-    from efl.elementary.entry import Entry
-    from efl.elementary.check import Check
-    from efl.elementary.spinner import Spinner
-    from efl.elementary.hoversel import Hoversel
-    from efl.elementary.popup import Popup
-    from efl.elementary.fileselector_button import FileselectorButton
-    from efl.elementary.scroller import Scroller, ELM_SCROLLER_POLICY_OFF, \
-        ELM_SCROLLER_POLICY_AUTO
-    from efl.elementary.separator import Separator
-    from efl.elementary.slider import Slider
-    from efl.elementary.actionslider import Actionslider, \
-        ELM_ACTIONSLIDER_LEFT, ELM_ACTIONSLIDER_CENTER, \
-        ELM_ACTIONSLIDER_RIGHT, ELM_ACTIONSLIDER_ALL
-    from efl.elementary.naviframe import Naviframe
-    from efl.elementary.table import Table
-    from efl.elementary.configuration import Configuration
-    from efl.evas import Rectangle
-    from efl.ecore import Timer
-except ImportError:
-    from elementary import Icon, Box, Label, Button, \
-        Popup, Frame, Entry, Check, Spinner, Hoversel, \
-        FileselectorButton, Scroller, ELM_SCROLLER_POLICY_OFF, \
-        ELM_SCROLLER_POLICY_AUTO, Separator, Slider, Actionslider, \
-        ELM_ACTIONSLIDER_LEFT, ELM_ACTIONSLIDER_CENTER, \
-        ELM_ACTIONSLIDER_RIGHT, ELM_ACTIONSLIDER_ALL, \
-        Naviframe, Table, Configuration
-    from evas import Rectangle
-    from ecore import Timer
+from efl.elementary.icon import Icon
+from efl.elementary.box import Box
+from efl.elementary.label import Label
+from efl.elementary.button import Button
+from efl.elementary.frame import Frame
+from efl.elementary.entry import Entry
+from efl.elementary.check import Check
+from efl.elementary.spinner import Spinner
+from efl.elementary.hoversel import Hoversel
+from efl.elementary.popup import Popup
+from efl.elementary.fileselector_button import FileselectorButton
+from efl.elementary.scroller import Scroller, ELM_SCROLLER_POLICY_OFF, \
+    ELM_SCROLLER_POLICY_AUTO
+from efl.elementary.separator import Separator
+from efl.elementary.slider import Slider
+from efl.elementary.actionslider import Actionslider, \
+    ELM_ACTIONSLIDER_LEFT, ELM_ACTIONSLIDER_CENTER, \
+    ELM_ACTIONSLIDER_RIGHT, ELM_ACTIONSLIDER_ALL
+from efl.elementary.naviframe import Naviframe
+from efl.elementary.table import Table
+from efl.elementary.configuration import Configuration
+from efl.evas import Rectangle
+from efl.ecore import Timer
+from efl.elementary.window import Window, ELM_WIN_BASIC
+from efl.elementary.background import Background
 
 import Notify
 
@@ -67,45 +58,47 @@ EXPAND_BOTH = 1.0, 1.0
 EXPAND_HORIZ = 1.0, 0.0
 FILL_BOTH = -1.0, -1.0
 FILL_HORIZ = -1.0, 0.5
+SCROLL_BOTH = ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_AUTO
 
-class PreferencesDialog(Popup):
+class PreferencesDialog(Window):
     """ Base class for all preferences dialogs """
-    def __init__(self, parent, title):
-        Popup.__init__(self, parent)
+    def __init__(self, title):
 
-        bt = Button(self, text="Close")
-        bt.callback_clicked_add(lambda b: self.delete())
-        self.part_content_set("button1", bt)
-        self.part_text_set("title,text", title)
+        elm_conf = Configuration()
+        scale = elm_conf.scale
+
+        Window.__init__(self, title, ELM_WIN_BASIC, title=title, autodel=True)
+
+        self.size = scale * 480, scale * 320
+
+        bg = Background(self, size_hint_weight=EXPAND_BOTH)
+        self.resize_object_add(bg)
+        bg.show()
 
-        self.table = Table(self)
+        # bt = Button(self, text="Close")
+        # bt.callback_clicked_add(lambda b: self.delete())
 
-        self.scroller = Scroller(self)
-        self.scroller.policy = ELM_SCROLLER_POLICY_OFF, 
ELM_SCROLLER_POLICY_AUTO
-        self.scroller.size_hint_weight = EXPAND_BOTH
-        self.scroller.size_hint_align = FILL_BOTH
-        self.table.pack(self.scroller, 0, 0, 1, 1)
+        self.scroller = Scroller(self, policy=SCROLL_BOTH,
+            size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
+        self.resize_object_add(self.scroller)
         self.scroller.show()
 
         self.box = Box(self)
         self.box.size_hint_weight = EXPAND_BOTH
         self.scroller.content = self.box
 
-        self.content = self.table
-        self.parent_resize_cb(parent)
-        parent.on_resize_add(self.parent_resize_cb)
         self.show()
 
-    def parent_resize_cb(self, parent):
-        (pw, ph) = parent.size
-        self.table.size_hint_min =  pw * 0.7, ph * 0.7
+    # def parent_resize_cb(self, parent):
+    #     (pw, ph) = parent.size
+    #     self.table.size_hint_min =  pw * 0.7, ph * 0.7
 
 class PreferencesGeneral(PreferencesDialog):
     """ General preference dialog """
     def __init__(self, parent, session):
         self.session = session
         conf = session.conf
-        PreferencesDialog.__init__(self, parent.win, "General")
+        PreferencesDialog.__init__(self, "General")
 
         limits = Limits(self, session)
         ports = ListenPorts(self, session)
@@ -225,7 +218,7 @@ class ListenPorts(Frame):
 class PreferencesProxy(PreferencesDialog):
     """ Proxy preference dialog """
     def __init__(self, parent, session):
-        PreferencesDialog.__init__(self, parent.win, "Proxy")
+        PreferencesDialog.__init__(self, "Proxy")
 
         proxies = [
             ["Proxy for torrent peer connections",
@@ -444,11 +437,10 @@ class ActSWithLabel(Box):
 class PreferencesSession(PreferencesDialog):
     """ Session preference dialog """
     def __init__(self, parent, session):
-        PreferencesDialog.__init__(self, parent.win, "Session")
+        PreferencesDialog.__init__(self, "Session")
 
         # TODO: Construct and populate this with an Idler
 
-        self.canvas = parent.win
         self.session = session
 
         widgets = {}
@@ -457,7 +449,8 @@ class PreferencesSession(PreferencesDialog):
 
         s = session.settings()
 
-        t = Table(self, padding=(5,5))
+        t = Table(self, padding=(5,5), homogeneous=True,
+            size_hint_align=FILL_BOTH)
         self.box.pack_end(t)
         t.show()
 
@@ -466,31 +459,34 @@ class PreferencesSession(PreferencesDialog):
         INT_MIN = -2147483648
         INT_MAX =  2147483647
 
+        scale = elm_conf.scale
+
         for k in dir(s):
             if k.startswith("__"): continue
             try:
                 a = getattr(s, k)
                 if isinstance(a, lt.disk_cache_algo_t):
-                    w = Spinner(self)
-                    w.size_hint_align = 1.0, 0.0
+                    w = Spinner(t)
+                    w.size_hint_align = FILL_HORIZ
                     # XXX: lt-rb python bindings don't have all values.
                     w.min_max = 0, 2 #len(lt.disk_cache_algo_t.values.keys())
                     for name, val in lt.disk_cache_algo_t.names.items():
                         w.special_value_add(val, name)
                     w.value = a
                 elif isinstance(a, bool):
-                    w = Check(self)
+                    w = Check(t)
                     w.size_hint_align = 1.0, 0.0
                     w.style = "toggle"
                     w.state = a
                 elif isinstance(a, int):
-                    w = Spinner(self)
+                    w = Spinner(t)
+                    w.size_hint_align = FILL_HORIZ
                     w.min_max = INT_MIN, INT_MAX
                     w.value = a
                 elif isinstance(a, float):
-                    w = Slider(self)
-                    w.size_hint_align = -1.0, 0.0
-                    w.size_hint_weight = 1.0, 0.0
+                    w = Slider(t)
+                    w.size_hint_align = FILL_HORIZ
+                    w.size_hint_weight = EXPAND_HORIZ
                     w.unit_format = "%1.2f"
                     if k.startswith("peer_turnover"):
                         w.min_max = 0.0, 1.0
@@ -502,29 +498,28 @@ class PreferencesSession(PreferencesDialog):
                     #      which doesn't have a python equivalent.
                     continue
                 elif k == "user_agent":
-                    w = Entry(self)
+                    w = Entry(t)
                     w.size_hint_align = 1.0, 0.0
-                    w.size_hint_weight = 1.0, 0.0
+                    w.size_hint_weight = EXPAND_HORIZ
                     w.single_line = True
                     w.editable = False
                     w.entry = cgi.escape(a)
                 else:
-                    w = Entry(self)
-                    w.size_hint_align = -1.0, 0.0
-                    w.size_hint_weight = 1.0, 0.0
+                    w = Entry(t)
+                    w.part_text_set("guide", "Enter here")
+                    w.size_hint_align = FILL_HORIZ
+                    w.size_hint_weight = EXPAND_HORIZ
                     w.single_line = True
                     w.entry = cgi.escape(a)
-                l = Label(self)
+                l = Label(t)
                 l.text = k.replace("_", " ").capitalize()
                 l.size_hint_align = 0.0, 0.0
-                l.size_hint_weight = 1.0, 0.0
+                l.size_hint_weight = EXPAND_HORIZ
                 l.show()
                 t.pack(l, 0, i, 1, 1)
-                w.size_hint_min = elm_conf.scale * 150, elm_conf.scale * 25
-                w.size_hint_align = -1.0, 0.5
-                w.size_hint_weight = 1.0, 0.0
-                w.show()
+                #w.size_hint_min = scale * 150, scale * 25
                 t.pack(w, 1, i, 1, 1)
+                w.show()
                 widgets[k] = w
                 i += 1
             except TypeError:
@@ -557,7 +552,7 @@ class PreferencesSession(PreferencesDialog):
             setattr(s, k, v)
 
         session.set_settings(s)
-        Notify.Information(self.canvas, "Session settings saved.")
+        Notify.Information(self, "Session settings saved.")
 
 class UnitSpinner(Box):
     def __init__(self, parent, base, units):

-- 


Reply via email to