2014-11-12 20:41:29 -06:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import wx
|
|
|
|
|
2015-02-01 00:49:03 -06:00
|
|
|
class UserActionsDialog(wx.Dialog):
|
|
|
|
def __init__(self, users=[], default="follow", *args, **kwargs):
|
|
|
|
super(UserActionsDialog, self).__init__(parent=None, *args, **kwargs)
|
2014-11-12 20:41:29 -06:00
|
|
|
panel = wx.Panel(self)
|
|
|
|
userSizer = wx.BoxSizer()
|
|
|
|
self.SetTitle(_(u"Action"))
|
2016-03-20 08:26:05 -06:00
|
|
|
userLabel = wx.StaticText(panel, -1, _(u"&User"))
|
2015-02-01 00:49:03 -06:00
|
|
|
self.cb = wx.ComboBox(panel, -1, choices=users, value=users[0])
|
2014-11-12 20:41:29 -06:00
|
|
|
self.cb.SetFocus()
|
2015-08-06 13:16:55 -05:00
|
|
|
self.autocompletion = wx.Button(panel, -1, _(u"&Autocomplete users"))
|
2015-02-07 13:55:52 -06:00
|
|
|
userSizer.Add(userLabel, 0, wx.ALL, 5)
|
|
|
|
userSizer.Add(self.cb, 0, wx.ALL, 5)
|
2015-08-06 13:16:55 -05:00
|
|
|
userSizer.Add(self.autocompletion, 0, wx.ALL, 5)
|
2014-11-12 20:41:29 -06:00
|
|
|
actionSizer = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
label2 = wx.StaticText(panel, -1, _(u"Action"))
|
2016-03-24 22:18:51 -06:00
|
|
|
self.follow = wx.RadioButton(panel, -1, _(u"&Follow"), name=_(u"Action"), style=wx.RB_GROUP)
|
2016-03-20 08:26:05 -06:00
|
|
|
self.unfollow = wx.RadioButton(panel, -1, _(u"U&nfollow"))
|
|
|
|
self.mute = wx.RadioButton(panel, -1, _(u"&Mute"))
|
|
|
|
self.unmute = wx.RadioButton(panel, -1, _(u"Unmu&te"))
|
|
|
|
self.block = wx.RadioButton(panel, -1, _(u"&Block"))
|
|
|
|
self.unblock = wx.RadioButton(panel, -1, _(u"Unbl&ock"))
|
|
|
|
self.reportSpam = wx.RadioButton(panel, -1, _(u"&Report as spam"))
|
|
|
|
self.ignore_client = wx.RadioButton(panel, -1, _(u"&Ignore tweets from this client"))
|
2014-11-12 20:41:29 -06:00
|
|
|
self.setup_default(default)
|
2015-02-07 13:55:52 -06:00
|
|
|
hSizer = wx.BoxSizer(wx.HORIZONTAL)
|
|
|
|
hSizer.Add(label2, 0, wx.ALL, 5)
|
|
|
|
actionSizer.Add(self.follow, 0, wx.ALL, 5)
|
|
|
|
actionSizer.Add(self.unfollow, 0, wx.ALL, 5)
|
|
|
|
actionSizer.Add(self.mute, 0, wx.ALL, 5)
|
|
|
|
actionSizer.Add(self.unmute, 0, wx.ALL, 5)
|
|
|
|
actionSizer.Add(self.block, 0, wx.ALL, 5)
|
|
|
|
actionSizer.Add(self.unblock, 0, wx.ALL, 5)
|
|
|
|
actionSizer.Add(self.reportSpam, 0, wx.ALL, 5)
|
|
|
|
actionSizer.Add(self.ignore_client, 0, wx.ALL, 5)
|
|
|
|
hSizer.Add(actionSizer, 0, wx.ALL, 5)
|
2014-11-12 20:41:29 -06:00
|
|
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
2016-03-20 08:26:05 -06:00
|
|
|
ok = wx.Button(panel, wx.ID_OK, _(u"&OK"))
|
2014-11-12 20:41:29 -06:00
|
|
|
ok.SetDefault()
|
2016-03-20 08:26:05 -06:00
|
|
|
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"&Close"))
|
2014-11-12 20:41:29 -06:00
|
|
|
btnsizer = wx.BoxSizer()
|
|
|
|
btnsizer.Add(ok)
|
|
|
|
btnsizer.Add(cancel)
|
|
|
|
sizer.Add(userSizer)
|
2015-02-07 13:55:52 -06:00
|
|
|
sizer.Add(hSizer, 0, wx.ALL, 5)
|
2014-11-12 20:41:29 -06:00
|
|
|
sizer.Add(btnsizer)
|
|
|
|
panel.SetSizer(sizer)
|
|
|
|
|
|
|
|
def get_action(self):
|
|
|
|
if self.follow.GetValue() == True: return "follow"
|
|
|
|
elif self.unfollow.GetValue() == True: return "unfollow"
|
|
|
|
elif self.mute.GetValue() == True: return "mute"
|
|
|
|
elif self.unmute.GetValue() == True: return "unmute"
|
|
|
|
elif self.reportSpam.GetValue() == True: return "report"
|
|
|
|
elif self.block.GetValue() == True: return "block"
|
|
|
|
elif self.unblock.GetValue() == True: return "unblock"
|
2015-02-01 00:49:03 -06:00
|
|
|
elif self.ignore_client.GetValue() == True: return "ignore_client"
|
2014-11-12 20:41:29 -06:00
|
|
|
|
|
|
|
def setup_default(self, default):
|
|
|
|
if default == "follow":
|
|
|
|
self.follow.SetValue(True)
|
|
|
|
elif default == "unfollow":
|
|
|
|
self.unfollow.SetValue(True)
|
|
|
|
elif default == "mute":
|
|
|
|
self.mute.SetValue(True)
|
|
|
|
elif default == "unmute":
|
|
|
|
self.unmute.SetValue(True)
|
|
|
|
elif default == "report":
|
|
|
|
self.reportSpam.SetValue(True)
|
|
|
|
elif default == "block":
|
|
|
|
self.block.SetValue(True)
|
|
|
|
elif default == "unblock":
|
2015-02-01 00:49:03 -06:00
|
|
|
self.unblock.SetValue(True)
|
|
|
|
elif default == "ignore_client":
|
|
|
|
self.ignore_client.SetValue(True)
|
|
|
|
|
|
|
|
def get_response(self):
|
|
|
|
return self.ShowModal()
|
|
|
|
|
|
|
|
def get_user(self):
|
2015-08-06 13:16:55 -05:00
|
|
|
return self.cb.GetValue()
|
|
|
|
|
|
|
|
def get_position(self):
|
|
|
|
return self.cb.GetPosition()
|
|
|
|
|
|
|
|
def popup_menu(self, menu):
|
|
|
|
self.PopupMenu(menu, self.cb.GetPosition())
|