davemds pushed a commit to branch master. http://git.enlightenment.org/apps/epour.git/commit/?id=5b3c328dd497159110a22d43f7b4cb5b1657b337
commit 5b3c328dd497159110a22d43f7b4cb5b1657b337 Author: davemds <d...@gurumeditation.it> Date: Fri Nov 8 22:46:21 2013 +0100 Epuor: spit the preference in 3 different InnerWindow Next step is to factorize the creation of the windows and clanup all the preferences --- epour/gui/Main.py | 18 ++++----- epour/gui/Preferences.py | 99 +++++++++++++++++++----------------------------- epour/gui/__init__.py | 1 - 3 files changed, 49 insertions(+), 69 deletions(-) diff --git a/epour/gui/Main.py b/epour/gui/Main.py index ee7614a..6c3fba2 100644 --- a/epour/gui/Main.py +++ b/epour/gui/Main.py @@ -61,7 +61,7 @@ except ImportError: from efl.elementary.toolbar import Toolbar from TorrentInfo import TorrentInfo -from Preferences import Preferences +from Preferences import PreferencesGeneral, PreferencesProxy, PreferencesSession from Notify import ConfirmExit, Error, Information from intrepr import intrepr @@ -109,15 +109,15 @@ class MainInterface(object): item.state_add("media-playback-start", "Resume Session", lambda tb, it: resume_session(it)) - item = tb.item_append("preferences-system", "Preferences", - lambda tb, it: Preferences(self, self.session)) - # item = tb.item_append("preferences-system", "preferences") - # item.menu = True - # item.menu.item_add(None, "General", "clock") - # item.menu.item_add(None, "Proxy", "clock") - # item.menu.item_add(None, "Session", "clock") + item = tb.item_append("preferences-system", "Preferences") + item.menu = True + item.menu.item_add(None, "General", "preferences-system", + lambda o,i: PreferencesGeneral(self, self.session)) + item.menu.item_add(None, "Proxy", "preferences-system", + lambda o,i: PreferencesProxy(self, self.session)) + item.menu.item_add(None, "Session", "preferences-system", + lambda o,i: PreferencesSession(self, self.session)) - # item = tb.item_append("help-about", "About") item = tb.item_append("application-exit", "Exit", lambda tb, it: elm.exit()) diff --git a/epour/gui/Preferences.py b/epour/gui/Preferences.py index a681364..4014f90 100644 --- a/epour/gui/Preferences.py +++ b/epour/gui/Preferences.py @@ -68,22 +68,16 @@ EXPAND_HORIZ = 1.0, 0.0 FILL_BOTH = -1.0, -1.0 FILL_HORIZ = -1.0, 0.5 -class Preferences(InnerWindow): +class PreferencesGeneral(InnerWindow): def __init__(self, parent, session): self.session = session conf = session.conf InnerWindow.__init__(self, parent.win) - nf = Naviframe(self) - nf.size_hint_weight = 1.0, 1.0 - mbox = Box(self) mbox.size_hint_weight = 1.0, 1.0 mbox.size_hint_align = -1.0, -1.0 - #lbl = Label(self) - #lbl.text = "Click on a title to open/close configuration entry." - limits = Limits(self, session) ports = ListenPorts(self, session) pe = EncryptionSettings(self, session) @@ -113,20 +107,12 @@ class Preferences(InnerWindow): sep2 = Separator(self) sep2.horizontal = True - prox_btn = Button(self) - prox_btn.text = "Proxy settings ->" - prox_btn.callback_clicked_add(self.show_prox_set, nf, session) - - ses_btn = Button(self) - ses_btn.text = "Session settings ->" - ses_btn.callback_clicked_add(self.show_ses_set, nf, session) - xbtn = Button(self) xbtn.text_set("Close") xbtn.callback_clicked_add(lambda x: self.delete()) for w in ports, limits, dlsel, pe, pad, \ - sep1, chk1, chk2, sep2, prox_btn, ses_btn, xbtn: + sep1, chk1, chk2, sep2, xbtn: w.show() mbox.pack_end(w) @@ -134,20 +120,9 @@ class Preferences(InnerWindow): scr.policy = ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO scr.content = mbox - nf.item_simple_push(scr) - nf.show() - - self.content = nf + self.content = scr self.activate() - def show_ses_set(self, btn, nf, session): - ses_set = SessionSettings(self, session, nf) - nf.item_simple_push(ses_set) - - def show_prox_set(self, btn, nf, session): - prox_set = ProxyConfig(self, session, nf) - nf.item_simple_push(prox_set) - class DataStorageSelector(Frame): def __init__(self, parent, conf): Frame.__init__(self, parent) @@ -230,16 +205,12 @@ class ListenPorts(Frame): self.session.conf.set("Settings", "listen_low", str(low)) self.session.conf.set("Settings", "listen_high", str(high)) -class ProxyConfig(Scroller): - def __init__(self, parent, session, nf): - Scroller.__init__(self, parent) - +class PreferencesProxy(InnerWindow): + def __init__(self, parent, session): + InnerWindow.__init__(self, parent.win) self.session = session - self.size_hint_weight = (1.0, 0.0) - self.size_hint_align = (-1.0, 0.0) - - b = Box(parent) + b = Box(parent.win) b.size_hint_weight = 1.0, 1.0 proxies = [ @@ -254,11 +225,11 @@ class ProxyConfig(Scroller): ] xbtn = Button(self) - xbtn.text = "<- Back" - xbtn.callback_clicked_add(lambda x: nf.item_pop()) + xbtn.text_set("Close") + xbtn.callback_clicked_add(lambda x: self.delete()) for title, rfunc, wfunc in proxies: - pg = ProxyGroup(parent, title, rfunc, wfunc) + pg = ProxyGroup(parent.win, title, rfunc, wfunc) pg.show() b.pack_end(pg) @@ -266,7 +237,13 @@ class ProxyConfig(Scroller): xbtn.show() b.show() - self.content = b + + scr = Scroller(self) + scr.policy = ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO + scr.content = b + + self.content = scr + self.activate() class ProxyGroup(Frame): @@ -458,13 +435,13 @@ class ActSWithLabel(Box): def get_value(self): return self.vd[self.w.indicator_pos] -class SessionSettings(Scroller): - def __init__(self, parent, session, nf): - Scroller.__init__(self, parent) +class PreferencesSession(InnerWindow): + def __init__(self, parent, session): + InnerWindow.__init__(self, parent.win) # TODO: Construct and populate this with an Idler - self.canvas = parent + self.canvas = parent.win self.session = session widgets = {} @@ -473,7 +450,7 @@ class SessionSettings(Scroller): s = session.settings() - t = Table(parent) + t = Table(parent.win) t.padding = 5, 5 t.size_hint_weight = 1.0, 1.0 t.size_hint_align = -1.0, -1.0 @@ -488,7 +465,7 @@ class SessionSettings(Scroller): try: a = getattr(s, k) if isinstance(a, lt.disk_cache_algo_t): - w = Spinner(parent) + w = Spinner(parent.win) w.size_hint_align = 1.0, 0.0 # XXX: lt-rb python bindings don't have all values. w.min_max = 0, 2 #len(lt.disk_cache_algo_t.values.keys()) @@ -496,16 +473,16 @@ class SessionSettings(Scroller): w.special_value_add(val, name) w.value = a elif isinstance(a, bool): - w = Check(parent) + w = Check(parent.win) w.size_hint_align = 1.0, 0.0 w.style = "toggle" w.state = a elif isinstance(a, int): - w = Spinner(parent) + w = Spinner(parent.win) w.min_max = INT_MIN, INT_MAX w.value = a elif isinstance(a, float): - w = Slider(parent) + w = Slider(parent.win) w.size_hint_align = -1.0, 0.0 w.size_hint_weight = 1.0, 0.0 w.unit_format = "%1.2f" @@ -519,19 +496,19 @@ class SessionSettings(Scroller): # which doesn't have a python equivalent. continue elif k == "user_agent": - w = Entry(parent) + w = Entry(parent.win) w.size_hint_align = 1.0, 0.0 w.size_hint_weight = 1.0, 0.0 w.single_line = True w.editable = False w.entry = cgi.escape(a) else: - w = Entry(parent) + w = Entry(parent.win) w.size_hint_align = -1.0, 0.0 w.size_hint_weight = 1.0, 0.0 w.single_line = True w.entry = cgi.escape(a) - l = Label(parent) + l = Label(parent.win) l.text = k.replace("_", " ").capitalize() l.size_hint_align = 0.0, 0.0 l.size_hint_weight = 1.0, 0.0 @@ -548,22 +525,26 @@ class SessionSettings(Scroller): pass #print("Error {}".format(k)) - save_btn = Button(parent) + save_btn = Button(parent.win) save_btn.text = "Apply session settings" save_btn.callback_clicked_add(self.apply_settings, widgets, session) save_btn.show() t.pack(save_btn, 0, i, 2, 1) i += 1 - xbtn = Button(parent) - xbtn.text = "<- Back" - xbtn.callback_clicked_add(lambda x: nf.item_pop()) + xbtn = Button(self) + xbtn.text_set("Close") + xbtn.callback_clicked_add(lambda x: self.delete()) xbtn.show() t.pack(xbtn, 0, i, 2, 1) - i += 1 - self.content = t - t.show() + scr = Scroller(self) + scr.policy = ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO + scr.content = t + + self.content = scr + self.activate() + def apply_settings(self, btn, widgets, session): s = lt.session_settings() diff --git a/epour/gui/__init__.py b/epour/gui/__init__.py index a5e66da..527462d 100644 --- a/epour/gui/__init__.py +++ b/epour/gui/__init__.py @@ -1,5 +1,4 @@ from Main import MainInterface -from Preferences import Preferences try: from efl import elementary --