mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-23 03:38:08 -06:00
Allows to add content warnings when writing a toot
This commit is contained in:
parent
2c298577cc
commit
3a3cb3963c
@ -32,7 +32,9 @@ class toot(messages.basicTweet):
|
|||||||
def add_toot(self, event, update_gui=True, *args, **kwargs):
|
def add_toot(self, event, update_gui=True, *args, **kwargs):
|
||||||
text = self.message.text.GetValue()
|
text = self.message.text.GetValue()
|
||||||
attachments = self.attachments[::]
|
attachments = self.attachments[::]
|
||||||
tootdata = dict(text=text, attachments=attachments)
|
tootdata = dict(text=text, attachments=attachments, sensitive=self.message.sensitive.GetValue(), spoiler_text=None)
|
||||||
|
if tootdata.get("sensitive") == True:
|
||||||
|
tootdata.update(spoiler_text=self.message.spoiler.GetValue())
|
||||||
self.thread.append(tootdata)
|
self.thread.append(tootdata)
|
||||||
self.attachments = []
|
self.attachments = []
|
||||||
if update_gui:
|
if update_gui:
|
||||||
|
@ -148,7 +148,7 @@ class Session(base.baseSession):
|
|||||||
for obj in toots:
|
for obj in toots:
|
||||||
text = obj.get("text")
|
text = obj.get("text")
|
||||||
if len(obj["attachments"]) == 0:
|
if len(obj["attachments"]) == 0:
|
||||||
item = self.api_call(call_name="status_post", status=text, _sound="tweet_send.ogg", in_reply_to_id=in_reply_to_id, visibility=visibility)
|
item = self.api_call(call_name="status_post", status=text, _sound="tweet_send.ogg", in_reply_to_id=in_reply_to_id, visibility=visibility, sensitive=obj["sensitive"], spoiler_text=obj["spoiler_text"])
|
||||||
if item != None:
|
if item != None:
|
||||||
in_reply_to_id = item["id"]
|
in_reply_to_id = item["id"]
|
||||||
else:
|
else:
|
||||||
@ -160,6 +160,6 @@ class Session(base.baseSession):
|
|||||||
for i in obj["attachments"]:
|
for i in obj["attachments"]:
|
||||||
img = self.api_call("media_post", media_file=i["file"], description=i["description"])
|
img = self.api_call("media_post", media_file=i["file"], description=i["description"])
|
||||||
media_ids.append(img.id)
|
media_ids.append(img.id)
|
||||||
item = self.api_call(call_name="status_post", status=text, _sound="tweet_send.ogg", in_reply_to_id=in_reply_to_id, media_ids=media_ids, visibility=visibility, poll=poll)
|
item = self.api_call(call_name="status_post", status=text, _sound="tweet_send.ogg", in_reply_to_id=in_reply_to_id, media_ids=media_ids, visibility=visibility, poll=poll, sensitive=obj["sensitive"], spoiler_text=obj["spoiler_text"])
|
||||||
if item != None:
|
if item != None:
|
||||||
in_reply_to_id = item["id"]
|
in_reply_to_id = item["id"]
|
||||||
|
@ -48,6 +48,17 @@ class Toot(wx.Dialog):
|
|||||||
self.visibility.SetSelection(0)
|
self.visibility.SetSelection(0)
|
||||||
visibility_sizer.Add(self.visibility, 0, 0, 0)
|
visibility_sizer.Add(self.visibility, 0, 0, 0)
|
||||||
self.add = wx.Button(self, wx.ID_ANY, _("A&dd"))
|
self.add = wx.Button(self, wx.ID_ANY, _("A&dd"))
|
||||||
|
self.sensitive = wx.CheckBox(self, wx.ID_ANY, _("Sensitive content"))
|
||||||
|
self.sensitive.SetValue(False)
|
||||||
|
self.sensitive.Bind(wx.EVT_CHECKBOX, self.on_sensitivity_changed)
|
||||||
|
main_sizer.Add(self.sensitive, 0, wx.ALL, 5)
|
||||||
|
spoiler_box = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
spoiler_label = wx.StaticText(self, wx.ID_ANY, _("Content warning"))
|
||||||
|
self.spoiler = wx.TextCtrl(self, wx.ID_ANY)
|
||||||
|
self.spoiler.Enable(False)
|
||||||
|
spoiler_box.Add(spoiler_label, 0, wx.ALL, 5)
|
||||||
|
spoiler_box.Add(self.spoiler, 0, wx.ALL, 10)
|
||||||
|
main_sizer.Add(spoiler_box, 0, wx.ALL, 5)
|
||||||
toot_actions_sizer.Add(self.add, 0, 0, 0)
|
toot_actions_sizer.Add(self.add, 0, 0, 0)
|
||||||
self.add_toot = wx.Button(self, wx.ID_ANY, _("Add t&oot"))
|
self.add_toot = wx.Button(self, wx.ID_ANY, _("Add t&oot"))
|
||||||
toot_actions_sizer.Add(self.add_toot, 0, 0, 0)
|
toot_actions_sizer.Add(self.add_toot, 0, 0, 0)
|
||||||
@ -72,6 +83,9 @@ class Toot(wx.Dialog):
|
|||||||
self.SetEscapeId(self.close.GetId())
|
self.SetEscapeId(self.close.GetId())
|
||||||
self.Layout()
|
self.Layout()
|
||||||
|
|
||||||
|
def on_sensitivity_changed(self, *args, **kwargs):
|
||||||
|
self.spoiler.Enable(self.sensitive.GetValue())
|
||||||
|
|
||||||
def set_title(self, chars):
|
def set_title(self, chars):
|
||||||
self.SetTitle(_("Toot - {} characters").format(chars))
|
self.SetTitle(_("Toot - {} characters").format(chars))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user