mirror of
				https://github.com/MCV-Software/TWBlue.git
				synced 2025-11-03 21:37:05 +00:00 
			
		
		
		
	The session manager has a remove account button
This commit is contained in:
		@@ -24,28 +24,26 @@ class sessionManagerWindow(wx.Dialog):
 | 
				
			|||||||
  label = wx.StaticText(panel, -1, _(u"Select a twitter account to start TW Blue"), size=wx.DefaultSize)
 | 
					  label = wx.StaticText(panel, -1, _(u"Select a twitter account to start TW Blue"), size=wx.DefaultSize)
 | 
				
			||||||
  listSizer = wx.BoxSizer(wx.HORIZONTAL)
 | 
					  listSizer = wx.BoxSizer(wx.HORIZONTAL)
 | 
				
			||||||
  self.list = widgets.list(panel, _(u"Account"), style=wx.LC_SINGLE_SEL|wx.LC_REPORT)
 | 
					  self.list = widgets.list(panel, _(u"Account"), style=wx.LC_SINGLE_SEL|wx.LC_REPORT)
 | 
				
			||||||
  self.fill_list()
 | 
					 | 
				
			||||||
  listSizer.Add(label, 0, wx.ALL, 5)
 | 
					  listSizer.Add(label, 0, wx.ALL, 5)
 | 
				
			||||||
  listSizer.Add(self.list.list, 0, wx.ALL, 5)
 | 
					  listSizer.Add(self.list.list, 0, wx.ALL, 5)
 | 
				
			||||||
  sizer.Add(listSizer, 0, wx.ALL, 5)
 | 
					  sizer.Add(listSizer, 0, wx.ALL, 5)
 | 
				
			||||||
  new = wx.Button(panel, -1, _(u"New account"), size=wx.DefaultSize)
 | 
					  new = wx.Button(panel, -1, _(u"New account"), size=wx.DefaultSize)
 | 
				
			||||||
  new.Bind(wx.EVT_BUTTON, self.new_account)
 | 
					  new.Bind(wx.EVT_BUTTON, self.new_account)
 | 
				
			||||||
 | 
					  self.removeSession = wx.Button(panel, -1, _(u"Remove session"))
 | 
				
			||||||
 | 
					  self.removeSession.Disable()
 | 
				
			||||||
 | 
					  self.removeSession.Bind(wx.EVT_BUTTON, self.remove)
 | 
				
			||||||
  ok = wx.Button(panel, wx.ID_OK, size=wx.DefaultSize)
 | 
					  ok = wx.Button(panel, wx.ID_OK, size=wx.DefaultSize)
 | 
				
			||||||
  ok.SetDefault()
 | 
					  ok.SetDefault()
 | 
				
			||||||
  ok.Bind(wx.EVT_BUTTON, self.ok)
 | 
					  ok.Bind(wx.EVT_BUTTON, self.ok)
 | 
				
			||||||
  cancel = wx.Button(panel, wx.ID_CANCEL, size=wx.DefaultSize)
 | 
					  cancel = wx.Button(panel, wx.ID_CANCEL, size=wx.DefaultSize)
 | 
				
			||||||
  buttons = wx.BoxSizer(wx.HORIZONTAL)
 | 
					  buttons = wx.BoxSizer(wx.HORIZONTAL)
 | 
				
			||||||
  buttons.Add(new, 0, wx.ALL, 5)
 | 
					  buttons.Add(new, 0, wx.ALL, 5)
 | 
				
			||||||
 | 
					  buttons.Add(self.removeSession, 0, wx.ALL, 5)
 | 
				
			||||||
  buttons.Add(ok, 0, wx.ALL, 5)
 | 
					  buttons.Add(ok, 0, wx.ALL, 5)
 | 
				
			||||||
  buttons.Add(cancel, 0, wx.ALL, 5)
 | 
					  buttons.Add(cancel, 0, wx.ALL, 5)
 | 
				
			||||||
  sizer.Add(buttons, 0, wx.ALL, 5)
 | 
					  sizer.Add(buttons, 0, wx.ALL, 5)
 | 
				
			||||||
  panel.SetSizer(sizer)
 | 
					  panel.SetSizer(sizer)
 | 
				
			||||||
#  sizer.Layout()
 | 
					  self.fill_list()
 | 
				
			||||||
#  self.Fit()
 | 
					 | 
				
			||||||
#  self.SetSize(panel.GetBestSize())
 | 
					 | 
				
			||||||
#  panelSizer.Add(panel)
 | 
					 | 
				
			||||||
#  self.SetSizerAndFit(sizer)
 | 
					 | 
				
			||||||
#  sizer.Layout()
 | 
					 | 
				
			||||||
  min = sizer.CalcMin()
 | 
					  min = sizer.CalcMin()
 | 
				
			||||||
  self.SetClientSize(min)
 | 
					  self.SetClientSize(min)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -65,6 +63,7 @@ class sessionManagerWindow(wx.Dialog):
 | 
				
			|||||||
  if self.list.get_count() > 0:
 | 
					  if self.list.get_count() > 0:
 | 
				
			||||||
   self.list.select_item(0)
 | 
					   self.list.select_item(0)
 | 
				
			||||||
  self.list.list.SetSize(self.list.list.GetBestSize())
 | 
					  self.list.list.SetSize(self.list.list.GetBestSize())
 | 
				
			||||||
 | 
					  self.removeSession.Enable()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 def ok(self, ev):
 | 
					 def ok(self, ev):
 | 
				
			||||||
  if self.list.get_count() == 0:
 | 
					  if self.list.get_count() == 0:
 | 
				
			||||||
@@ -78,8 +77,6 @@ class sessionManagerWindow(wx.Dialog):
 | 
				
			|||||||
  languageHandler.setLanguage(lang)
 | 
					  languageHandler.setLanguage(lang)
 | 
				
			||||||
  sound.setup()
 | 
					  sound.setup()
 | 
				
			||||||
  output.setup()
 | 
					  output.setup()
 | 
				
			||||||
# else:
 | 
					 | 
				
			||||||
#   self.name = current_session
 | 
					 | 
				
			||||||
  self.EndModal(wx.ID_OK)
 | 
					  self.EndModal(wx.ID_OK)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 def new_account(self, ev):
 | 
					 def new_account(self, ev):
 | 
				
			||||||
@@ -103,3 +100,12 @@ class sessionManagerWindow(wx.Dialog):
 | 
				
			|||||||
   if self.list.get_count() == 1:
 | 
					   if self.list.get_count() == 1:
 | 
				
			||||||
    self.list.select_item(0)
 | 
					    self.list.select_item(0)
 | 
				
			||||||
   self.sessions.append(location)
 | 
					   self.sessions.append(location)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 def remove(self, ev):
 | 
				
			||||||
 | 
					  selected_item = self.list.get_selected()
 | 
				
			||||||
 | 
					  selected_session = self.sessions[selected_item]
 | 
				
			||||||
 | 
					  ask = wx.MessageDialog(self, _(u"Do you really want delete this account?"), _(u"Remove account"), wx.YES_NO)
 | 
				
			||||||
 | 
					  if ask.ShowModal() == wx.ID_YES:
 | 
				
			||||||
 | 
					   self.sessions.remove(selected_session)
 | 
				
			||||||
 | 
					   shutil.rmtree(path=paths.config_path(selected_session), ignore_errors=True)
 | 
				
			||||||
 | 
					   self.list.remove_item(selected_item)
 | 
				
			||||||
		Reference in New Issue
	
	Block a user