Added 'manage accounts' option in the application menu
This commit is contained in:
@@ -14,10 +14,14 @@ from .config_utils import Configuration
|
||||
log = logging.getLogger("sessionmanager.sessionManager")
|
||||
|
||||
class sessionManagerController(object):
|
||||
def __init__(self):
|
||||
def __init__(self, starting=True):
|
||||
super(sessionManagerController, self).__init__()
|
||||
log.debug("Setting up the session manager.")
|
||||
self.view = view.sessionManagerWindow()
|
||||
if starting:
|
||||
title=_("Select an account")
|
||||
else:
|
||||
title = _("Manage accounts")
|
||||
self.view = view.sessionManagerWindow(starting=starting, title=title)
|
||||
widgetUtils.connect_event(self.view.new, widgetUtils.BUTTON_PRESSED, self.manage_new_account)
|
||||
widgetUtils.connect_event(self.view.remove, widgetUtils.BUTTON_PRESSED, self.remove)
|
||||
self.fill_list()
|
||||
@@ -50,6 +54,7 @@ class sessionManagerController(object):
|
||||
name = s.settings["vk"]["user"]
|
||||
self.sessions.append((location, name))
|
||||
self.view.list.insert_item(False, *[name])
|
||||
self.modified = True
|
||||
|
||||
def get_authorisation(self, c):
|
||||
log.debug("Starting the authorisation process...")
|
||||
@@ -87,4 +92,5 @@ class sessionManagerController(object):
|
||||
selected_session = self.sessions[self.view.list.get_selected()]
|
||||
shutil.rmtree(path=os.path.join(paths.config_path(), selected_session[0]), ignore_errors=True)
|
||||
self.sessions.remove(selected_session)
|
||||
self.view.list.remove_item(self.view.list.get_selected())
|
||||
self.view.list.remove_item(self.view.list.get_selected())
|
||||
self.modified = True
|
@@ -39,8 +39,8 @@ class newSessionDialog(widgetUtils.BaseDialog):
|
||||
return self.passw.GetValue()
|
||||
|
||||
class sessionManagerWindow(widgetUtils.BaseDialog):
|
||||
def __init__(self):
|
||||
super(sessionManagerWindow, self).__init__(parent=None, title=_("Select an account"), size=wx.DefaultSize)
|
||||
def __init__(self, title, starting=True):
|
||||
super(sessionManagerWindow, self).__init__(parent=None, title=title, size=wx.DefaultSize)
|
||||
panel = wx.Panel(self)
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
label = wx.StaticText(panel, -1, _(u"Accounts list"), size=wx.DefaultSize)
|
||||
@@ -51,13 +51,20 @@ class sessionManagerWindow(widgetUtils.BaseDialog):
|
||||
sizer.Add(listSizer, 0, wx.ALL, 5)
|
||||
self.new = wx.Button(panel, -1, _("New account"), size=wx.DefaultSize)
|
||||
self.remove = wx.Button(panel, -1, _(u"Remove account"))
|
||||
ok = wx.Button(panel, wx.ID_OK, size=wx.DefaultSize)
|
||||
if starting:
|
||||
id_ok = wx.ID_OK
|
||||
else:
|
||||
id_ok = wx.ID_CANCEL
|
||||
ok = wx.Button(panel, id_ok, size=wx.DefaultSize)
|
||||
ok.SetDefault()
|
||||
cancel = wx.Button(panel, wx.ID_CANCEL, size=wx.DefaultSize)
|
||||
if starting:
|
||||
cancel = wx.Button(panel, wx.ID_CANCEL, size=wx.DefaultSize)
|
||||
self.SetAffirmativeId(id_ok)
|
||||
buttons = wx.BoxSizer(wx.HORIZONTAL)
|
||||
buttons.Add(self.new, 0, wx.ALL, 5)
|
||||
buttons.Add(ok, 0, wx.ALL, 5)
|
||||
buttons.Add(cancel, 0, wx.ALL, 5)
|
||||
if starting:
|
||||
buttons.Add(cancel, 0, wx.ALL, 5)
|
||||
sizer.Add(buttons, 0, wx.ALL, 5)
|
||||
panel.SetSizer(sizer)
|
||||
min = sizer.CalcMin()
|
||||
|
Reference in New Issue
Block a user