kuuko pushed a commit to branch master.

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

commit 0e4366e627983b9fe0fb15cb72ea9907935711bd
Author: Kai Huuhko <[email protected]>
Date:   Thu Jul 10 18:02:11 2014 +0300

    Move prefs widgets -> widgets, update TODO
---
 TODO                     |  12 +++-
 epour/gui/Preferences.py |  94 +----------------------------
 epour/gui/Widgets.py     | 150 +++++++++++++++++++++++++++++++++++++----------
 3 files changed, 132 insertions(+), 124 deletions(-)

diff --git a/TODO b/TODO
index 37a55c2..e97998d 100644
--- a/TODO
+++ b/TODO
@@ -34,11 +34,19 @@ Torrent status info:
 Add Torrent-dialog:
  ✔ Use dicts to hold torrent info between sessions. @done (15:57 30.06.2014)
    ✔ Migrate the old ihash->torrent_file dict to the new list of torrents 
@done (15:57 30.06.2014)
- ✔ Dialog window @done (15:57 30.06.2014)
+ ☐ Dialog window
    ✔ Options @done (15:57 30.06.2014)
    ✔ File selector @done (15:57 30.06.2014)
    ✔ Storage path @done (15:57 30.06.2014)
-   ☐ Add preferences for initial/automatic values for the above
+   ☐ Add preferences for initial/automatic values for options
+Preferences:
+ ☐ max uploads
+   ?
+ ☐ max conns
+   ?
+ ☐ max half open conns
+   ?
+ ☐ ip filter
 Misc:
  ✔ Torrent tooltips @done (21:17 01.07.2014)
    Using handle.status()
diff --git a/epour/gui/Preferences.py b/epour/gui/Preferences.py
index 4dabc99..cd12623 100644
--- a/epour/gui/Preferences.py
+++ b/epour/gui/Preferences.py
@@ -34,14 +34,9 @@ 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.fileselector import Fileselector
-from efl.elementary.fileselector_button import FileselectorButton
 from efl.elementary.scroller import Scroller, 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.table import Table
 from efl.elementary.configuration import Configuration
 from efl.elementary.window import StandardWindow
@@ -49,7 +44,8 @@ from efl.elementary.background import Background
 
 from efl.evas import Rectangle, EVAS_HINT_EXPAND, EVAS_HINT_FILL
 
-from Widgets import UnitSpinner, Error, Information
+from Widgets import UnitSpinner, Error, Information, ActSWithLabel, FsButton, \
+    RangeSpinners
 
 EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
 EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0
@@ -453,55 +449,6 @@ class EncryptionSettings(Frame):
         self.session.set_pe_settings(self.pes)
 
 
-class ActSWithLabel(Box):
-
-    def __init__(self, parent, label_text, values, initial_value):
-        Box.__init__(self, parent)
-
-        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
-        self.size_hint_weight = EXPAND_HORIZ
-
-        l = Label(parent)
-        l.text = label_text
-        l.show()
-        w = self.w = Actionslider(parent)
-        w.magnet_pos = ELM_ACTIONSLIDER_ALL
-        w.size_hint_align = FILL_HORIZ
-        w.size_hint_weight = EXPAND_HORIZ
-        w.show()
-
-        parts = "left", "center", "right"
-
-        for i, v in enumerate(values):
-            w.part_text_set(parts[i], str(v))
-
-        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):
-        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):
 
     """ Session preference dialog """
@@ -665,32 +612,6 @@ class PreferencesSession(PreferencesDialog):
         Information(self, "Session settings saved.")
 
 
-class RangeSpinners(Box):
-
-    def __init__(self, parent, low, high, minim, maxim):
-
-        Box.__init__(self, parent)
-        self.size_hint_weight = EXPAND_BOTH
-        self.size_hint_align = FILL_BOTH
-        self.horizontal = True
-
-        l = self.listenlow = Spinner(parent)
-        l.size_hint_weight = EXPAND_BOTH
-        l.size_hint_align = FILL_BOTH
-        l.min_max = minim, maxim
-        l.value = low
-        self.pack_end(l)
-        l.show()
-
-        h = self.listenhigh = Spinner(parent)
-        h.size_hint_weight = EXPAND_BOTH
-        h.size_hint_align = FILL_BOTH
-        h.min_max = minim, maxim
-        h.value = high
-        self.pack_end(h)
-        h.show()
-
-
 class Limits(Frame):
 
     def __init__(self, parent, session):
@@ -731,14 +652,3 @@ class Limits(Frame):
             usw.show()
 
         self.content = t
-
-
-class FsButton(Fileselector, FileselectorButton):
-
-    def __init__(self, parent, *args, **kwargs):
-        FileselectorButton.__init__(self, parent, *args, **kwargs)
-
-# TODO:
-# max uploads?, max conns?, max half open conns?
-
-# ip filter
diff --git a/epour/gui/Widgets.py b/epour/gui/Widgets.py
index 2495fb1..3409b80 100644
--- a/epour/gui/Widgets.py
+++ b/epour/gui/Widgets.py
@@ -8,6 +8,8 @@ from efl.elementary.notify import Notify
 from efl.elementary.popup import Popup
 from efl.elementary.button import Button
 from efl.elementary.grid import Grid
+from efl.elementary.fileselector import Fileselector
+from efl.elementary.fileselector_button import FileselectorButton
 
 EXPAND_BOTH = EVAS_HINT_EXPAND, EVAS_HINT_EXPAND
 EXPAND_HORIZ = EVAS_HINT_EXPAND, 0.0
@@ -92,42 +94,48 @@ class UnitSpinner(Box):
         self.hoversel.text = self.prefixes[i] + self.unit
 
 
-class Information(object):
-    def __init__(self, canvas, text):
-        n = Notify(canvas)
-        l = Label(canvas)
-        l.text = text
-        n.content = l
-        n.timeout = 3
-        n.show()
-
-
-class Error(object):
-    def __init__(self, canvas, title, text):
-        n = Popup(canvas)
-        n.part_text_set("title,text", title)
-        n.text = text
-        b = Button(canvas)
+class Information(Notify):
+    def __init__(self, parent, text, button=False, timeout=3, *args, **kwargs):
+        super(self.__class__, self).__init__(parent)
+        b = Box(self)
+        l = Label(b, text=text)
+        b.pack_end(l)
+        l.show()
+        self.content = l
+        if button:
+            xbtn = Button(b, text="Close")
+            xbtn.callback_clicked_add(lambda x: self.delete())
+            b.pack_end(xbtn)
+        self.timeout = timeout
+        self.show()
+
+
+class Error(Popup):
+    def __init__(self, parent, title, text):
+        super(self.__class__, self).__init__(parent)
+        self.part_text_set("title,text", title)
+        self.text = text
+        b = Button(self)
         b.text = "OK"
-        b.callback_clicked_add(lambda x: n.delete())
-        n.part_content_set("button1", b)
-        n.show()
+        b.callback_clicked_add(lambda x: self.delete())
+        self.part_content_set("button1", b)
+        self.show()
 
 
-class ConfirmExit(object):
-    def __init__(self, canvas, exit_func):
-        n = Popup(canvas)
-        n.part_text_set("title,text", "Confirm exit")
-        n.text = "Are you sure you wish to exit Epour?"
-        b = Button(canvas)
+class ConfirmExit(Popup):
+    def __init__(self, parent, exit_func):
+        super(self.__class__, self).__init__(parent)
+        self.part_text_set("title,text", "Confirm exit")
+        self.text = "Are you sure you wish to exit Epour?"
+        b = Button(self)
         b.text = "Yes"
         b.callback_clicked_add(lambda x: exit_func())
-        n.part_content_set("button1", b)
-        b = Button(canvas)
+        self.part_content_set("button1", b)
+        b = Button(self)
         b.text = "No"
-        b.callback_clicked_add(lambda x: n.delete())
-        n.part_content_set("button2", b)
-        n.show()
+        b.callback_clicked_add(lambda x: self.delete())
+        self.part_content_set("button2", b)
+        self.show()
 
 
 class BlockGraph(Grid):
@@ -231,3 +239,85 @@ class BlockGraph(Grid):
                 col += 1
 
         return True
+
+
+class ActSWithLabel(Box):
+
+    def __init__(self, parent, label_text, values, initial_value):
+        Box.__init__(self, parent)
+
+        from efl.elementary.actionslider import Actionslider, \
+            ELM_ACTIONSLIDER_LEFT, ELM_ACTIONSLIDER_CENTER, \
+            ELM_ACTIONSLIDER_RIGHT, ELM_ACTIONSLIDER_ALL
+
+        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
+        self.size_hint_weight = EXPAND_HORIZ
+
+        l = Label(parent)
+        l.text = label_text
+        l.show()
+        w = self.w = Actionslider(parent)
+        w.magnet_pos = ELM_ACTIONSLIDER_ALL
+        w.size_hint_align = FILL_HORIZ
+        w.size_hint_weight = EXPAND_HORIZ
+        w.show()
+
+        parts = "left", "center", "right"
+
+        for i, v in enumerate(values):
+            w.part_text_set(parts[i], str(v))
+
+        init_v = self.v_to_pos[initial_value]
+        w.indicator_pos = init_v
+
+        self.pack_end(l)
+        self.pack_end(w)
+
+    def get_value(self):
+        pos = self.w.indicator_pos
+        value = self.vd[pos]
+        return value
+
+
+class RangeSpinners(Box):
+
+    def __init__(self, parent, low, high, minim, maxim):
+
+        Box.__init__(self, parent)
+        self.size_hint_weight = EXPAND_BOTH
+        self.size_hint_align = FILL_BOTH
+        self.horizontal = True
+
+        l = self.listenlow = Spinner(parent)
+        l.size_hint_weight = EXPAND_BOTH
+        l.size_hint_align = FILL_BOTH
+        l.min_max = minim, maxim
+        l.value = low
+        self.pack_end(l)
+        l.show()
+
+        h = self.listenhigh = Spinner(parent)
+        h.size_hint_weight = EXPAND_BOTH
+        h.size_hint_align = FILL_BOTH
+        h.min_max = minim, maxim
+        h.value = high
+        self.pack_end(h)
+        h.show()
+
+
+class FsButton(Fileselector, FileselectorButton):
+
+    def __init__(self, parent, *args, **kwargs):
+        FileselectorButton.__init__(self, parent, *args, **kwargs)

-- 


Reply via email to