Epour: Use a Popup insted of the InnerWin for preferences dialogs
It looks better, has a title and the Close button is always visible. Only drawback I had to change the fileselector in_win mode because the inwin is going stacked BELOW the popup :/
This commit is contained in:
parent
a473d92f51
commit
38c1c74f0f
|
@ -28,7 +28,7 @@ import libtorrent as lt
|
|||
|
||||
try:
|
||||
from elementary import Icon, Box, Label, Button, \
|
||||
InnerWindow, Frame, Entry, Check, Spinner, Hoversel, \
|
||||
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, \
|
||||
|
@ -41,12 +41,12 @@ except ImportError:
|
|||
from efl.elementary.box import Box
|
||||
from efl.elementary.label import Label
|
||||
from efl.elementary.button import Button
|
||||
from efl.elementary.innerwindow import InnerWindow
|
||||
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
|
||||
|
@ -68,33 +68,44 @@ EXPAND_HORIZ = 1.0, 0.0
|
|||
FILL_BOTH = -1.0, -1.0
|
||||
FILL_HORIZ = -1.0, 0.5
|
||||
|
||||
class PreferencesDialog(InnerWindow):
|
||||
class PreferencesDialog(Popup):
|
||||
""" Base class for all preferences dialogs """
|
||||
def __init__(self, parent):
|
||||
InnerWindow.__init__(self, parent)
|
||||
def __init__(self, parent, title):
|
||||
Popup.__init__(self, parent)
|
||||
|
||||
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)
|
||||
|
||||
self.table = Table(self)
|
||||
|
||||
self.scroller = Scroller(self)
|
||||
self.scroller.policy = ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO
|
||||
self.content = self.scroller
|
||||
|
||||
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.show()
|
||||
|
||||
self.box = Box(self)
|
||||
self.box.size_hint_weight = 1.0, 1.0
|
||||
self.box.size_hint_weight = EXPAND_BOTH
|
||||
self.scroller.content = self.box
|
||||
|
||||
def activate(self):
|
||||
btn = Button(self, text="Close")
|
||||
btn.callback_clicked_add(lambda x: self.delete())
|
||||
self.box.pack_end(btn)
|
||||
btn.show()
|
||||
|
||||
InnerWindow.activate(self)
|
||||
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
|
||||
|
||||
class PreferencesGeneral(PreferencesDialog):
|
||||
""" General preference dialog """
|
||||
def __init__(self, parent, session):
|
||||
self.session = session
|
||||
conf = session.conf
|
||||
PreferencesDialog.__init__(self, parent.win)
|
||||
PreferencesDialog.__init__(self, parent.win, "General")
|
||||
|
||||
limits = Limits(self, session)
|
||||
ports = ListenPorts(self, session)
|
||||
|
@ -129,8 +140,6 @@ class PreferencesGeneral(PreferencesDialog):
|
|||
w.show()
|
||||
self.box.pack_end(w)
|
||||
|
||||
self.activate()
|
||||
|
||||
class DataStorageSelector(Frame):
|
||||
def __init__(self, parent, conf):
|
||||
Frame.__init__(self, parent)
|
||||
|
@ -148,7 +157,7 @@ class DataStorageSelector(Frame):
|
|||
|
||||
self.dlsel = dlsel = FileselectorButton(self)
|
||||
dlsel.size_hint_align = -1.0, 0.0
|
||||
dlsel.inwin_mode = True
|
||||
dlsel.inwin_mode = False
|
||||
dlsel.folder_only = True
|
||||
dlsel.expandable = False
|
||||
dlsel.text = "Change path"
|
||||
|
@ -216,7 +225,7 @@ class ListenPorts(Frame):
|
|||
class PreferencesProxy(PreferencesDialog):
|
||||
""" Proxy preference dialog """
|
||||
def __init__(self, parent, session):
|
||||
PreferencesDialog.__init__(self, parent.win)
|
||||
PreferencesDialog.__init__(self, parent.win, "Proxy")
|
||||
|
||||
proxies = [
|
||||
["Proxy for torrent peer connections",
|
||||
|
@ -234,8 +243,6 @@ class PreferencesProxy(PreferencesDialog):
|
|||
pg.show()
|
||||
self.box.pack_end(pg)
|
||||
|
||||
self.activate()
|
||||
|
||||
class ProxyGroup(Frame):
|
||||
|
||||
proxy_types = {
|
||||
|
@ -429,7 +436,7 @@ class ActSWithLabel(Box):
|
|||
class PreferencesSession(PreferencesDialog):
|
||||
""" Session preference dialog """
|
||||
def __init__(self, parent, session):
|
||||
PreferencesDialog.__init__(self, parent.win)
|
||||
PreferencesDialog.__init__(self, parent.win, "Session")
|
||||
|
||||
# TODO: Construct and populate this with an Idler
|
||||
|
||||
|
@ -521,8 +528,6 @@ class PreferencesSession(PreferencesDialog):
|
|||
save_btn.show()
|
||||
self.box.pack_end(save_btn)
|
||||
|
||||
self.activate()
|
||||
|
||||
def apply_settings(self, btn, widgets, session):
|
||||
s = lt.session_settings()
|
||||
|
||||
|
|
Loading…
Reference in New Issue