Replace 'toot' term to follow mastodon changes

This commit is contained in:
Manuel Cortez 2022-11-16 13:28:45 -06:00
parent aebdcae9cf
commit 8f72ee97c9
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
16 changed files with 281 additions and 281 deletions

View File

@ -23,7 +23,7 @@ from wxUI.dialogs.mastodon import dialogs as mastodon_dialogs
log = logging.getLogger("controller.buffers.mastodon.base") log = logging.getLogger("controller.buffers.mastodon.base")
class BaseBuffer(base.Buffer): class BaseBuffer(base.Buffer):
def __init__(self, parent, function, name, sessionObject, account, sound=None, compose_func="compose_toot", *args, **kwargs): def __init__(self, parent, function, name, sessionObject, account, sound=None, compose_func="compose_post", *args, **kwargs):
super(BaseBuffer, self).__init__(parent, function, *args, **kwargs) super(BaseBuffer, self).__init__(parent, function, *args, **kwargs)
log.debug("Initializing buffer %s, account %s" % (name, account,)) log.debug("Initializing buffer %s, account %s" % (name, account,))
self.create_buffer(parent, name) self.create_buffer(parent, name)
@ -61,26 +61,26 @@ class BaseBuffer(base.Buffer):
return _(u"Unknown buffer") return _(u"Unknown buffer")
def post_status(self, *args, **kwargs): def post_status(self, *args, **kwargs):
title = _("Toot") title = _("Post")
caption = _("Write your toot here") caption = _("Write your post here")
toot = messages.toot(session=self.session, title=title, caption=caption) post = messages.post(session=self.session, title=title, caption=caption)
response = toot.message.ShowModal() response = post.message.ShowModal()
if response == wx.ID_OK: if response == wx.ID_OK:
toot_data = toot.get_data() post_data = post.get_data()
call_threaded(self.session.send_toot, toots=toot_data, visibility=toot.get_visibility(), **kwargs) call_threaded(self.session.send_post, posts=post_data, visibility=post.get_visibility(), **kwargs)
if hasattr(toot.message, "destroy"): if hasattr(post.message, "destroy"):
toot.message.destroy() post.message.destroy()
def get_formatted_message(self): def get_formatted_message(self):
return self.compose_function(self.get_item(), self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])[1] return self.compose_function(self.get_item(), self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])[1]
def get_message(self): def get_message(self):
toot = self.get_item() post = self.get_item()
if toot == None: if post == None:
return return
template = self.session.settings["templates"]["toot"] template = self.session.settings["templates"]["post"]
t = templates.render_toot(toot, template, relative_times=self.session.settings["general"]["relative_times"], offset_hours=self.session.db["utc_offset"]) t = templates.render_post(post, template, relative_times=self.session.settings["general"]["relative_times"], offset_hours=self.session.db["utc_offset"])
return t return t
def start_stream(self, mandatory=False, play_sound=True, avoid_autoreading=False): def start_stream(self, mandatory=False, play_sound=True, avoid_autoreading=False):
@ -89,7 +89,7 @@ class BaseBuffer(base.Buffer):
self.execution_time = current_time self.execution_time = current_time
log.debug("Starting stream for buffer %s, account %s and type %s" % (self.name, self.account, self.type)) log.debug("Starting stream for buffer %s, account %s and type %s" % (self.name, self.account, self.type))
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs)) log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
count = self.session.settings["general"]["max_toots_per_call"] count = self.session.settings["general"]["max_posts_per_call"]
min_id = None min_id = None
# toDo: Implement reverse timelines properly here. # toDo: Implement reverse timelines properly here.
if (self.name != "favorites" and self.name != "bookmarks") and self.name in self.session.db and len(self.session.db[self.name]) > 0: if (self.name != "favorites" and self.name != "bookmarks") and self.name in self.session.db and len(self.session.db[self.name]) > 0:
@ -103,7 +103,7 @@ class BaseBuffer(base.Buffer):
number_of_items = self.session.order_buffer(self.name, results) number_of_items = self.session.order_buffer(self.name, results)
log.debug("Number of items retrieved: %d" % (number_of_items,)) log.debug("Number of items retrieved: %d" % (number_of_items,))
self.put_items_on_list(number_of_items) self.put_items_on_list(number_of_items)
if number_of_items > 0 and self.name != "sent_toots" and self.name != "sent_direct_messages" and self.sound != None and self.session.settings["sound"]["session_mute"] == False and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and play_sound == True: if number_of_items > 0 and self.name != "sent_posts" and self.name != "sent_direct_messages" and self.sound != None and self.session.settings["sound"]["session_mute"] == False and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and play_sound == True:
self.session.sound.play(self.sound) self.session.sound.play(self.sound)
# Autoread settings # Autoread settings
if avoid_autoreading == False and mandatory == True and number_of_items > 0 and self.name in self.session.settings["other_buffers"]["autoread_buffers"]: if avoid_autoreading == False and mandatory == True and number_of_items > 0 and self.name in self.session.settings["other_buffers"]["autoread_buffers"]:
@ -113,13 +113,13 @@ class BaseBuffer(base.Buffer):
def auto_read(self, number_of_items): def auto_read(self, number_of_items):
if number_of_items == 1 and self.name in self.session.settings["other_buffers"]["autoread_buffers"] and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and self.session.settings["sound"]["session_mute"] == False: if number_of_items == 1 and self.name in self.session.settings["other_buffers"]["autoread_buffers"] and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and self.session.settings["sound"]["session_mute"] == False:
if self.session.settings["general"]["reverse_timelines"] == False: if self.session.settings["general"]["reverse_timelines"] == False:
toot = self.session.db[self.name][-1] post = self.session.db[self.name][-1]
else: else:
toot = self.session.db[self.name][0] post = self.session.db[self.name][0]
output.speak(_("New toot in {0}").format(self.get_buffer_name())) output.speak(_("New post in {0}").format(self.get_buffer_name()))
output.speak(" ".join(self.compose_function(toot, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]))) output.speak(" ".join(self.compose_function(post, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])))
elif number_of_items > 1 and self.name in self.session.settings["other_buffers"]["autoread_buffers"] and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and self.session.settings["sound"]["session_mute"] == False: elif number_of_items > 1 and self.name in self.session.settings["other_buffers"]["autoread_buffers"] and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and self.session.settings["sound"]["session_mute"] == False:
output.speak(_("{0} new toots in {1}.").format(number_of_items, self.get_buffer_name())) output.speak(_("{0} new posts in {1}.").format(number_of_items, self.get_buffer_name()))
def get_more_items(self): def get_more_items(self):
elements = [] elements = []
@ -128,7 +128,7 @@ class BaseBuffer(base.Buffer):
else: else:
max_id = self.session.db[self.name][-1].id max_id = self.session.db[self.name][-1].id
try: try:
items = getattr(self.session.api, self.function)(max_id=max_id, limit=self.session.settings["general"]["max_toots_per_call"], *self.args, **self.kwargs) items = getattr(self.session.api, self.function)(max_id=max_id, limit=self.session.settings["general"]["max_posts_per_call"], *self.args, **self.kwargs)
except Exception as e: except Exception as e:
log.exception("Error %s" % (str(e))) log.exception("Error %s" % (str(e)))
return return
@ -145,12 +145,12 @@ class BaseBuffer(base.Buffer):
log.debug("Retrieved %d items from cursored search in function %s." % (len(elements), self.function)) log.debug("Retrieved %d items from cursored search in function %s." % (len(elements), self.function))
if self.session.settings["general"]["reverse_timelines"] == False: if self.session.settings["general"]["reverse_timelines"] == False:
for i in elements: for i in elements:
toot = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]) post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
self.buffer.list.insert_item(True, *toot) self.buffer.list.insert_item(True, *post)
else: else:
for i in items: for i in items:
toot = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]) post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
self.buffer.list.insert_item(False, *toot) self.buffer.list.insert_item(False, *post)
self.buffer.list.select_item(selection) self.buffer.list.select_item(selection)
output.speak(_(u"%s items retrieved") % (str(len(elements))), True) output.speak(_(u"%s items retrieved") % (str(len(elements))), True)
@ -194,37 +194,37 @@ class BaseBuffer(base.Buffer):
log.debug("Putting %d items on the list" % (number_of_items,)) log.debug("Putting %d items on the list" % (number_of_items,))
if self.buffer.list.get_count() == 0: if self.buffer.list.get_count() == 0:
for i in list_to_use: for i in list_to_use:
toot = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]) post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
self.buffer.list.insert_item(False, *toot) self.buffer.list.insert_item(False, *post)
self.buffer.set_position(self.session.settings["general"]["reverse_timelines"]) self.buffer.set_position(self.session.settings["general"]["reverse_timelines"])
elif self.buffer.list.get_count() > 0 and number_of_items > 0: elif self.buffer.list.get_count() > 0 and number_of_items > 0:
if self.session.settings["general"]["reverse_timelines"] == False: if self.session.settings["general"]["reverse_timelines"] == False:
items = list_to_use[len(list_to_use)-number_of_items:] items = list_to_use[len(list_to_use)-number_of_items:]
for i in items: for i in items:
toot = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]) post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
self.buffer.list.insert_item(False, *toot) self.buffer.list.insert_item(False, *post)
else: else:
items = list_to_use[0:number_of_items] items = list_to_use[0:number_of_items]
items.reverse() items.reverse()
for i in items: for i in items:
toot = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]) post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
self.buffer.list.insert_item(True, *toot) self.buffer.list.insert_item(True, *post)
log.debug("Now the list contains %d items " % (self.buffer.list.get_count(),)) log.debug("Now the list contains %d items " % (self.buffer.list.get_count(),))
def add_new_item(self, item): def add_new_item(self, item):
toot = self.compose_function(item, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]) post = self.compose_function(item, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
if self.session.settings["general"]["reverse_timelines"] == False: if self.session.settings["general"]["reverse_timelines"] == False:
self.buffer.list.insert_item(False, *toot) self.buffer.list.insert_item(False, *post)
else: else:
self.buffer.list.insert_item(True, *toot) self.buffer.list.insert_item(True, *post)
if self.name in self.session.settings["other_buffers"]["autoread_buffers"] and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and self.session.settings["sound"]["session_mute"] == False: if self.name in self.session.settings["other_buffers"]["autoread_buffers"] and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and self.session.settings["sound"]["session_mute"] == False:
output.speak(" ".join(toot[:2]), speech=self.session.settings["reporting"]["speech_reporting"], braille=self.session.settings["reporting"]["braille_reporting"]) output.speak(" ".join(post[:2]), speech=self.session.settings["reporting"]["speech_reporting"], braille=self.session.settings["reporting"]["braille_reporting"])
def bind_events(self): def bind_events(self):
log.debug("Binding events...") log.debug("Binding events...")
self.buffer.set_focus_function(self.onFocus) self.buffer.set_focus_function(self.onFocus)
widgetUtils.connect_event(self.buffer.list.list, widgetUtils.KEYPRESS, self.get_event) widgetUtils.connect_event(self.buffer.list.list, widgetUtils.KEYPRESS, self.get_event)
widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.post_status, self.buffer.toot) widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.post_status, self.buffer.post)
widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.share_item, self.buffer.boost) widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.share_item, self.buffer.boost)
widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.send_message, self.buffer.dm) widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.send_message, self.buffer.dm)
widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.reply, self.buffer.reply) widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.reply, self.buffer.reply)
@ -285,8 +285,8 @@ class BaseBuffer(base.Buffer):
return self.session.db[self.name][index] return self.session.db[self.name][index]
def can_share(self): def can_share(self):
toot = self.get_item() post = self.get_item()
if toot.visibility == "direct": if post.visibility == "direct":
return False return False
return True return True
@ -308,15 +308,15 @@ class BaseBuffer(base.Buffer):
if "@{} ".format(item.account.acct) not in users and item.account.id != self.session.db["user_id"]: if "@{} ".format(item.account.acct) not in users and item.account.id != self.session.db["user_id"]:
users.insert(0, "@{} ".format(item.account.acct)) users.insert(0, "@{} ".format(item.account.acct))
users_str = "".join(users) users_str = "".join(users)
toot = messages.toot(session=self.session, title=title, caption=caption, text=users_str) post = messages.post(session=self.session, title=title, caption=caption, text=users_str)
visibility_settings = dict(public=0, unlisted=1, private=2, direct=3) visibility_settings = dict(public=0, unlisted=1, private=2, direct=3)
toot.message.visibility.SetSelection(visibility_settings.get(visibility)) post.message.visibility.SetSelection(visibility_settings.get(visibility))
response = toot.message.ShowModal() response = post.message.ShowModal()
if response == wx.ID_OK: if response == wx.ID_OK:
toot_data = toot.get_data() post_data = post.get_data()
call_threaded(self.session.send_toot, reply_to=item.id, toots=toot_data, visibility=visibility) call_threaded(self.session.send_post, reply_to=item.id, posts=post_data, visibility=visibility)
if hasattr(toot.message, "destroy"): if hasattr(post.message, "destroy"):
toot.message.destroy() post.message.destroy()
def send_message(self, *args, **kwargs): def send_message(self, *args, **kwargs):
item = self.get_item() item = self.get_item()
@ -331,20 +331,20 @@ class BaseBuffer(base.Buffer):
if item.account.acct not in users and item.account.id != self.session.db["user_id"]: if item.account.acct not in users and item.account.id != self.session.db["user_id"]:
users.insert(0, "@{} ".format(item.account.acct)) users.insert(0, "@{} ".format(item.account.acct))
users_str = "".join(users) users_str = "".join(users)
toot = messages.toot(session=self.session, title=title, caption=caption, text=users_str) post = messages.post(session=self.session, title=title, caption=caption, text=users_str)
toot.message.visibility.SetSelection(3) post.message.visibility.SetSelection(3)
response = toot.message.ShowModal() response = post.message.ShowModal()
if response == wx.ID_OK: if response == wx.ID_OK:
toot_data = toot.get_data() post_data = post.get_data()
call_threaded(self.session.send_toot, toots=toot_data, visibility="direct") call_threaded(self.session.send_post, posts=post_data, visibility="direct")
if hasattr(toot.message, "destroy"): if hasattr(post.message, "destroy"):
toot.message.destroy() post.message.destroy()
def share_item(self, *args, **kwargs): def share_item(self, *args, **kwargs):
if self.can_share() == False: if self.can_share() == False:
return output.speak(_("This action is not supported on conversation toots.")) return output.speak(_("This action is not supported on conversation posts."))
toot = self.get_item() post = self.get_item()
id = toot.id id = post.id
if self.session.settings["general"]["boost_mode"] == "ask": if self.session.settings["general"]["boost_mode"] == "ask":
answer = mastodon_dialogs.boost_question() answer = mastodon_dialogs.boost_question()
if answer == True: if answer == True:
@ -356,14 +356,14 @@ class BaseBuffer(base.Buffer):
item = self.session.api_call(call_name="status_reblog", _sound="retweet_send.ogg", id=id) item = self.session.api_call(call_name="status_reblog", _sound="retweet_send.ogg", id=id)
def onFocus(self, *args, **kwargs): def onFocus(self, *args, **kwargs):
toot = self.get_item() post = self.get_item()
if self.session.settings["general"]["relative_times"] == True: if self.session.settings["general"]["relative_times"] == True:
original_date = arrow.get(self.session.db[self.name][self.buffer.list.get_selected()].created_at) original_date = arrow.get(self.session.db[self.name][self.buffer.list.get_selected()].created_at)
ts = original_date.humanize(locale=languageHandler.getLanguage()) ts = original_date.humanize(locale=languageHandler.getLanguage())
self.buffer.list.list.SetItem(self.buffer.list.get_selected(), 2, ts) self.buffer.list.list.SetItem(self.buffer.list.get_selected(), 2, ts)
if self.session.settings['sound']['indicate_audio'] and utils.is_audio_or_video(toot): if self.session.settings['sound']['indicate_audio'] and utils.is_audio_or_video(post):
self.session.sound.play("audio.ogg") self.session.sound.play("audio.ogg")
if self.session.settings['sound']['indicate_img'] and utils.is_image(toot): if self.session.settings['sound']['indicate_img'] and utils.is_image(post):
self.session.sound.play("image.ogg") self.session.sound.play("image.ogg")
can_share = self.can_share() can_share = self.can_share()
pub.sendMessage("toggleShare", shareable=can_share) pub.sendMessage("toggleShare", shareable=can_share)
@ -392,11 +392,11 @@ class BaseBuffer(base.Buffer):
def url(self, url='', announce=True, *args, **kwargs): def url(self, url='', announce=True, *args, **kwargs):
if url == '': if url == '':
toot = self.get_item() post = self.get_item()
if toot.reblog != None: if post.reblog != None:
urls = utils.find_urls(toot.reblog) urls = utils.find_urls(post.reblog)
else: else:
urls = utils.find_urls(toot) urls = utils.find_urls(post)
if len(urls) == 1: if len(urls) == 1:
url=urls[0] url=urls[0]
elif len(urls) > 1: elif len(urls) > 1:
@ -420,9 +420,9 @@ class BaseBuffer(base.Buffer):
index = self.buffer.list.get_selected() index = self.buffer.list.get_selected()
item = self.session.db[self.name][index] item = self.session.db[self.name][index]
if item.account.id != self.session.db["user_id"] or item.reblog != None: if item.account.id != self.session.db["user_id"] or item.reblog != None:
output.speak(_("You can delete only your own toots.")) output.speak(_("You can delete only your own posts."))
return return
answer = mastodon_dialogs.delete_toot_dialog() answer = mastodon_dialogs.delete_post_dialog()
if answer == True: if answer == True:
items = self.session.db[self.name] items = self.session.db[self.name]
try: try:
@ -438,10 +438,10 @@ class BaseBuffer(base.Buffer):
pass pass
def get_item_url(self): def get_item_url(self):
toot = self.get_item() post = self.get_item()
if toot.reblog != None: if post.reblog != None:
return toot.reblog.url return post.reblog.url
return toot.url return post.url
def open_in_browser(self, *args, **kwargs): def open_in_browser(self, *args, **kwargs):
url = self.get_item_url() url = self.get_item_url()
@ -471,13 +471,13 @@ class BaseBuffer(base.Buffer):
call_threaded(self.session.api_call, call_name="status_unfavourite", preexec_message=_("Removing from favorites..."), _sound="favourite.ogg", id=item.id) call_threaded(self.session.api_call, call_name="status_unfavourite", preexec_message=_("Removing from favorites..."), _sound="favourite.ogg", id=item.id)
def view_item(self): def view_item(self):
toot = self.get_item() post = self.get_item()
# Update object so we can retrieve newer stats # Update object so we can retrieve newer stats
toot = self.session.api.status(id=toot.id) post = self.session.api.status(id=post.id)
print(toot) print(post)
msg = messages.viewToot(toot, offset_hours=self.session.db["utc_offset"], item_url=self.get_item_url()) msg = messages.viewPost(post, offset_hours=self.session.db["utc_offset"], item_url=self.get_item_url())
def ocr_image(self): def ocr_image(self):
toot = self.get_item() post = self.get_item()
media_list = [] media_list = []
pass pass

View File

@ -34,8 +34,8 @@ class ConversationListBuffer(BaseBuffer):
if conversation == None: if conversation == None:
return return
template = self.session.settings["templates"]["conversation"] template = self.session.settings["templates"]["conversation"]
toot_template = self.session.settings["templates"]["toot"] post_template = self.session.settings["templates"]["post"]
t = templates.render_conversation(conversation=conversation, template=template, toot_template=toot_template, relative_times=self.session.settings["general"]["relative_times"], offset_hours=self.session.db["utc_offset"]) t = templates.render_conversation(conversation=conversation, template=template, post_template=post_template, relative_times=self.session.settings["general"]["relative_times"], offset_hours=self.session.db["utc_offset"])
return t return t
def start_stream(self, mandatory=False, play_sound=True, avoid_autoreading=False): def start_stream(self, mandatory=False, play_sound=True, avoid_autoreading=False):
@ -44,7 +44,7 @@ class ConversationListBuffer(BaseBuffer):
self.execution_time = current_time self.execution_time = current_time
log.debug("Starting stream for buffer %s, account %s and type %s" % (self.name, self.account, self.type)) log.debug("Starting stream for buffer %s, account %s and type %s" % (self.name, self.account, self.type))
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs)) log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
count = self.session.settings["general"]["max_toots_per_call"] count = self.session.settings["general"]["max_posts_per_call"]
min_id = None min_id = None
# toDo: Implement reverse timelines properly here. # toDo: Implement reverse timelines properly here.
# if (self.name != "favorites" and self.name != "bookmarks") and self.name in self.session.db and len(self.session.db[self.name]) > 0: # if (self.name != "favorites" and self.name != "bookmarks") and self.name in self.session.db and len(self.session.db[self.name]) > 0:
@ -60,7 +60,7 @@ class ConversationListBuffer(BaseBuffer):
self.put_items_on_list(number_of_items) self.put_items_on_list(number_of_items)
if new_position > -1: if new_position > -1:
self.buffer.list.select_item(new_position) self.buffer.list.select_item(new_position)
if number_of_items > 0 and self.name != "sent_toots" and self.name != "sent_direct_messages" and self.sound != None and self.session.settings["sound"]["session_mute"] == False and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and play_sound == True: if number_of_items > 0 and self.name != "sent_posts" and self.name != "sent_direct_messages" and self.sound != None and self.session.settings["sound"]["session_mute"] == False and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and play_sound == True:
self.session.sound.play(self.sound) self.session.sound.play(self.sound)
# Autoread settings # Autoread settings
if avoid_autoreading == False and mandatory == True and number_of_items > 0 and self.name in self.session.settings["other_buffers"]["autoread_buffers"]: if avoid_autoreading == False and mandatory == True and number_of_items > 0 and self.name in self.session.settings["other_buffers"]["autoread_buffers"]:
@ -74,7 +74,7 @@ class ConversationListBuffer(BaseBuffer):
else: else:
max_id = self.session.db[self.name][-1].last_status.id max_id = self.session.db[self.name][-1].last_status.id
try: try:
items = getattr(self.session.api, self.function)(max_id=max_id, limit=self.session.settings["general"]["max_toots_per_call"], *self.args, **self.kwargs) items = getattr(self.session.api, self.function)(max_id=max_id, limit=self.session.settings["general"]["max_posts_per_call"], *self.args, **self.kwargs)
except Exception as e: except Exception as e:
log.exception("Error %s" % (str(e))) log.exception("Error %s" % (str(e)))
return return
@ -142,7 +142,7 @@ class ConversationListBuffer(BaseBuffer):
log.debug("Binding events...") log.debug("Binding events...")
self.buffer.set_focus_function(self.onFocus) self.buffer.set_focus_function(self.onFocus)
widgetUtils.connect_event(self.buffer.list.list, widgetUtils.KEYPRESS, self.get_event) widgetUtils.connect_event(self.buffer.list.list, widgetUtils.KEYPRESS, self.get_event)
widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.post_status, self.buffer.toot) widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.post_status, self.buffer.post)
widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.reply, self.buffer.reply) widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.reply, self.buffer.reply)
widgetUtils.connect_event(self.buffer.list.list, wx.EVT_LIST_ITEM_RIGHT_CLICK, self.show_menu) widgetUtils.connect_event(self.buffer.list.list, wx.EVT_LIST_ITEM_RIGHT_CLICK, self.show_menu)
widgetUtils.connect_event(self.buffer.list.list, wx.EVT_LIST_KEY_DOWN, self.show_menu_by_key) widgetUtils.connect_event(self.buffer.list.list, wx.EVT_LIST_KEY_DOWN, self.show_menu_by_key)
@ -160,10 +160,10 @@ class ConversationListBuffer(BaseBuffer):
return self.reply() return self.reply()
def onFocus(self, *args, **kwargs): def onFocus(self, *args, **kwargs):
toot = self.get_item() post = self.get_item()
if self.session.settings['sound']['indicate_audio'] and utils.is_audio_or_video(toot): if self.session.settings['sound']['indicate_audio'] and utils.is_audio_or_video(post):
self.session.sound.play("audio.ogg") self.session.sound.play("audio.ogg")
if self.session.settings['sound']['indicate_img'] and utils.is_image(toot): if self.session.settings['sound']['indicate_img'] and utils.is_image(post):
self.session.sound.play("image.ogg") self.session.sound.play("image.ogg")
def destroy_status(self): def destroy_status(self):
@ -177,20 +177,20 @@ class ConversationListBuffer(BaseBuffer):
caption = _("Write your message here") caption = _("Write your message here")
users = ["@{} ".format(user.acct) for user in conversation.accounts] users = ["@{} ".format(user.acct) for user in conversation.accounts]
users_str = "".join(users) users_str = "".join(users)
toot = messages.toot(session=self.session, title=title, caption=caption, text=users_str) post = messages.post(session=self.session, title=title, caption=caption, text=users_str)
visibility_settings = dict(public=0, unlisted=1, private=2, direct=3) visibility_settings = dict(public=0, unlisted=1, private=2, direct=3)
toot.message.visibility.SetSelection(visibility_settings.get(visibility)) post.message.visibility.SetSelection(visibility_settings.get(visibility))
response = toot.message.ShowModal() response = post.message.ShowModal()
if response == wx.ID_OK: if response == wx.ID_OK:
toot_data = toot.get_data() post_data = post.get_data()
call_threaded(self.session.send_toot, reply_to=item.id, toots=toot_data, visibility=visibility) call_threaded(self.session.send_post, reply_to=item.id, posts=post_data, visibility=visibility)
if hasattr(toot.message, "destroy"): if hasattr(post.message, "destroy"):
toot.message.destroy() post.message.destroy()
class ConversationBuffer(BaseBuffer): class ConversationBuffer(BaseBuffer):
def __init__(self, toot, *args, **kwargs): def __init__(self, post, *args, **kwargs):
self.toot = toot self.post = post
super(ConversationBuffer, self).__init__(*args, **kwargs) super(ConversationBuffer, self).__init__(*args, **kwargs)
def start_stream(self, mandatory=False, play_sound=True, avoid_autoreading=False): def start_stream(self, mandatory=False, play_sound=True, avoid_autoreading=False):
@ -199,13 +199,13 @@ class ConversationBuffer(BaseBuffer):
self.execution_time = current_time self.execution_time = current_time
log.debug("Starting stream for buffer %s, account %s and type %s" % (self.name, self.account, self.type)) log.debug("Starting stream for buffer %s, account %s and type %s" % (self.name, self.account, self.type))
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs)) log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
self.toot = self.session.api.status(id=self.toot.id) self.post = self.session.api.status(id=self.post.id)
# toDo: Implement reverse timelines properly here. # toDo: Implement reverse timelines properly here.
try: try:
results = [] results = []
items = getattr(self.session.api, self.function)(*self.args, **self.kwargs) items = getattr(self.session.api, self.function)(*self.args, **self.kwargs)
[results.append(item) for item in items.ancestors] [results.append(item) for item in items.ancestors]
results.append(self.toot) results.append(self.post)
[results.append(item) for item in items.descendants] [results.append(item) for item in items.descendants]
except Exception as e: except Exception as e:
log.exception("Error %s" % (str(e))) log.exception("Error %s" % (str(e)))
@ -213,7 +213,7 @@ class ConversationBuffer(BaseBuffer):
number_of_items = self.session.order_buffer(self.name, results) number_of_items = self.session.order_buffer(self.name, results)
log.debug("Number of items retrieved: %d" % (number_of_items,)) log.debug("Number of items retrieved: %d" % (number_of_items,))
self.put_items_on_list(number_of_items) self.put_items_on_list(number_of_items)
if number_of_items > 0 and self.name != "sent_toots" and self.name != "sent_direct_messages" and self.sound != None and self.session.settings["sound"]["session_mute"] == False and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and play_sound == True: if number_of_items > 0 and self.name != "sent_posts" and self.name != "sent_direct_messages" and self.sound != None and self.session.settings["sound"]["session_mute"] == False and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and play_sound == True:
self.session.sound.play(self.sound) self.session.sound.play(self.sound)
# Autoread settings # Autoread settings
if avoid_autoreading == False and mandatory == True and number_of_items > 0 and self.name in self.session.settings["other_buffers"]["autoread_buffers"]: if avoid_autoreading == False and mandatory == True and number_of_items > 0 and self.name in self.session.settings["other_buffers"]["autoread_buffers"]:

View File

@ -14,7 +14,7 @@ class MentionsBuffer(BaseBuffer):
self.execution_time = current_time self.execution_time = current_time
log.debug("Starting stream for buffer %s, account %s and type %s" % (self.name, self.account, self.type)) log.debug("Starting stream for buffer %s, account %s and type %s" % (self.name, self.account, self.type))
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs)) log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
count = self.session.settings["general"]["max_toots_per_call"] count = self.session.settings["general"]["max_posts_per_call"]
min_id = None min_id = None
# toDo: Implement reverse timelines properly here. # toDo: Implement reverse timelines properly here.
# if self.name != "favorites" and self.name in self.session.db and len(self.session.db[self.name]) > 0: # if self.name != "favorites" and self.name in self.session.db and len(self.session.db[self.name]) > 0:
@ -29,7 +29,7 @@ class MentionsBuffer(BaseBuffer):
number_of_items = self.session.order_buffer(self.name, results) number_of_items = self.session.order_buffer(self.name, results)
log.debug("Number of items retrieved: %d" % (number_of_items,)) log.debug("Number of items retrieved: %d" % (number_of_items,))
self.put_items_on_list(number_of_items) self.put_items_on_list(number_of_items)
if number_of_items > 0 and self.name != "sent_toots" and self.name != "sent_direct_messages" and self.sound != None and self.session.settings["sound"]["session_mute"] == False and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and play_sound == True: if number_of_items > 0 and self.name != "sent_posts" and self.name != "sent_direct_messages" and self.sound != None and self.session.settings["sound"]["session_mute"] == False and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and play_sound == True:
self.session.sound.play(self.sound) self.session.sound.play(self.sound)
# Autoread settings # Autoread settings
if avoid_autoreading == False and mandatory == True and number_of_items > 0 and self.name in self.session.settings["other_buffers"]["autoread_buffers"]: if avoid_autoreading == False and mandatory == True and number_of_items > 0 and self.name in self.session.settings["other_buffers"]["autoread_buffers"]:
@ -43,7 +43,7 @@ class MentionsBuffer(BaseBuffer):
else: else:
max_id = self.session.db[self.name][-1].id max_id = self.session.db[self.name][-1].id
try: try:
items = getattr(self.session.api, self.function)(max_id=max_id, limit=self.session.settings["general"]["max_toots_per_call"], exclude_types=["follow", "favourite", "reblog", "poll", "follow_request"], *self.args, **self.kwargs) items = getattr(self.session.api, self.function)(max_id=max_id, limit=self.session.settings["general"]["max_posts_per_call"], exclude_types=["follow", "favourite", "reblog", "poll", "follow_request"], *self.args, **self.kwargs)
items = [item.status for item in items if item.get("status") and item.type == "mention"] items = [item.status for item in items if item.get("status") and item.type == "mention"]
except Exception as e: except Exception as e:
log.exception("Error %s" % (str(e))) log.exception("Error %s" % (str(e)))
@ -61,11 +61,11 @@ class MentionsBuffer(BaseBuffer):
log.debug("Retrieved %d items from cursored search in function %s." % (len(elements), self.function)) log.debug("Retrieved %d items from cursored search in function %s." % (len(elements), self.function))
if self.session.settings["general"]["reverse_timelines"] == False: if self.session.settings["general"]["reverse_timelines"] == False:
for i in elements: for i in elements:
toot = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]) post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
self.buffer.list.insert_item(True, *toot) self.buffer.list.insert_item(True, *post)
else: else:
for i in items: for i in items:
toot = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]) post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
self.buffer.list.insert_item(False, *toot) self.buffer.list.insert_item(False, *post)
self.buffer.list.select_item(selection) self.buffer.list.select_item(selection)
output.speak(_(u"%s items retrieved") % (str(len(elements))), True) output.speak(_(u"%s items retrieved") % (str(len(elements))), True)

View File

@ -27,7 +27,7 @@ class UserBuffer(BaseBuffer):
def bind_events(self): def bind_events(self):
widgetUtils.connect_event(self.buffer.list.list, widgetUtils.KEYPRESS, self.get_event) widgetUtils.connect_event(self.buffer.list.list, widgetUtils.KEYPRESS, self.get_event)
widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.post_status, self.buffer.toot) widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.post_status, self.buffer.post)
widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.send_message, self.buffer.message) widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.send_message, self.buffer.message)
widgetUtils.connect_event(self.buffer.list.list, wx.EVT_LIST_ITEM_RIGHT_CLICK, self.show_menu) widgetUtils.connect_event(self.buffer.list.list, wx.EVT_LIST_ITEM_RIGHT_CLICK, self.show_menu)
widgetUtils.connect_event(self.buffer.list.list, wx.EVT_LIST_KEY_DOWN, self.show_menu_by_key) widgetUtils.connect_event(self.buffer.list.list, wx.EVT_LIST_KEY_DOWN, self.show_menu_by_key)
@ -49,14 +49,14 @@ class UserBuffer(BaseBuffer):
title = _("New conversation with {}").format(item.username) title = _("New conversation with {}").format(item.username)
caption = _("Write your message here") caption = _("Write your message here")
users_str = "@{} ".format(item.acct) users_str = "@{} ".format(item.acct)
toot = messages.toot(session=self.session, title=title, caption=caption, text=users_str) post = messages.post(session=self.session, title=title, caption=caption, text=users_str)
toot.message.visibility.SetSelection(3) post.message.visibility.SetSelection(3)
response = toot.message.ShowModal() response = post.message.ShowModal()
if response == wx.ID_OK: if response == wx.ID_OK:
toot_data = toot.get_data() post_data = post.get_data()
call_threaded(self.session.send_toot, toots=toot_data, visibility="direct") call_threaded(self.session.send_post, posts=post_data, visibility="direct")
if hasattr(toot.message, "destroy"): if hasattr(post.message, "destroy"):
toot.message.destroy() post.message.destroy()
def audio(self): def audio(self):
pass pass
@ -73,7 +73,7 @@ class UserBuffer(BaseBuffer):
self.execution_time = current_time self.execution_time = current_time
log.debug("Starting stream for buffer %s, account %s and type %s" % (self.name, self.account, self.type)) log.debug("Starting stream for buffer %s, account %s and type %s" % (self.name, self.account, self.type))
log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs)) log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs))
count = self.session.settings["general"]["max_toots_per_call"] count = self.session.settings["general"]["max_posts_per_call"]
# toDo: Implement reverse timelines properly here. # toDo: Implement reverse timelines properly here.
try: try:
results = getattr(self.session.api, self.function)(limit=count, *self.args, **self.kwargs) results = getattr(self.session.api, self.function)(limit=count, *self.args, **self.kwargs)
@ -86,7 +86,7 @@ class UserBuffer(BaseBuffer):
number_of_items = self.session.order_buffer(self.name, results) number_of_items = self.session.order_buffer(self.name, results)
log.debug("Number of items retrieved: %d" % (number_of_items,)) log.debug("Number of items retrieved: %d" % (number_of_items,))
self.put_items_on_list(number_of_items) self.put_items_on_list(number_of_items)
if number_of_items > 0 and self.name != "sent_toots" and self.name != "sent_direct_messages" and self.sound != None and self.session.settings["sound"]["session_mute"] == False and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and play_sound == True: if number_of_items > 0 and self.name != "sent_posts" and self.name != "sent_direct_messages" and self.sound != None and self.session.settings["sound"]["session_mute"] == False and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and play_sound == True:
self.session.sound.play(self.sound) self.session.sound.play(self.sound)
# Autoread settings # Autoread settings
if avoid_autoreading == False and mandatory == True and number_of_items > 0 and self.name in self.session.settings["other_buffers"]["autoread_buffers"]: if avoid_autoreading == False and mandatory == True and number_of_items > 0 and self.name in self.session.settings["other_buffers"]["autoread_buffers"]:
@ -119,12 +119,12 @@ class UserBuffer(BaseBuffer):
log.debug("Retrieved %d items from cursored search in function %s." % (len(elements), self.function)) log.debug("Retrieved %d items from cursored search in function %s." % (len(elements), self.function))
if self.session.settings["general"]["reverse_timelines"] == False: if self.session.settings["general"]["reverse_timelines"] == False:
for i in elements: for i in elements:
toot = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]) post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
self.buffer.list.insert_item(True, *toot) self.buffer.list.insert_item(True, *post)
else: else:
for i in items: for i in items:
toot = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]) post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
self.buffer.list.insert_item(False, *toot) self.buffer.list.insert_item(False, *post)
self.buffer.list.select_item(selection) self.buffer.list.select_item(selection)
output.speak(_(u"%s items retrieved") % (str(len(elements))), True) output.speak(_(u"%s items retrieved") % (str(len(elements))), True)

View File

@ -76,11 +76,11 @@ class Handler(object):
log.exception("Error %s starting buffer %s on account %s, with args %r and kwargs %r." % (str(err), buffer.name, buffer.account, buffer.args, buffer.kwargs)) log.exception("Error %s starting buffer %s on account %s, with args %r and kwargs %r." % (str(err), buffer.name, buffer.account, buffer.args, buffer.kwargs))
def open_conversation(self, controller, buffer): def open_conversation(self, controller, buffer):
toot = buffer.get_item() post = buffer.get_item()
if toot.reblog != None: if post.reblog != None:
toot = toot.reblog post = post.reblog
conversations_position =controller.view.search("direct_messages", buffer.session.get_name()) conversations_position =controller.view.search("direct_messages", buffer.session.get_name())
pub.sendMessage("createBuffer", buffer_type="ConversationBuffer", session_type=buffer.session.type, buffer_title=_("Conversation with {0}").format(toot.account.acct), parent_tab=conversations_position, start=True, kwargs=dict(parent=controller.view.nb, function="status_context", name="%s-conversation" % (toot.id,), sessionObject=buffer.session, account=buffer.session.get_name(), sound="search_updated.ogg", toot=toot, id=toot.id)) pub.sendMessage("createBuffer", buffer_type="ConversationBuffer", session_type=buffer.session.type, buffer_title=_("Conversation with {0}").format(post.account.acct), parent_tab=conversations_position, start=True, kwargs=dict(parent=controller.view.nb, function="status_context", name="%s-conversation" % (post.id,), sessionObject=buffer.session, account=buffer.session.get_name(), sound="search_updated.ogg", post=post, id=post.id))
def follow(self, buffer): def follow(self, buffer):
if not hasattr(buffer, "get_item"): if not hasattr(buffer, "get_item"):

View File

@ -6,15 +6,15 @@ import config
import output import output
from controller.twitter import messages from controller.twitter import messages
from sessions.mastodon import templates from sessions.mastodon import templates
from wxUI.dialogs.mastodon import tootDialogs from wxUI.dialogs.mastodon import postDialogs
class toot(messages.basicTweet): class post(messages.basicTweet):
def __init__(self, session, title, caption, text="", *args, **kwargs): def __init__(self, session, title, caption, text="", *args, **kwargs):
# take max character limit from session as this might be different for some instances. # take max character limit from session as this might be different for some instances.
self.max = session.char_limit self.max = session.char_limit
self.title = title self.title = title
self.session = session self.session = session
self.message = tootDialogs.Toot(caption=caption, text=text, *args, **kwargs) self.message = postDialogs.Post(caption=caption, text=text, *args, **kwargs)
self.message.SetTitle(title) self.message.SetTitle(title)
self.message.text.SetInsertionPoint(len(self.message.text.GetValue())) self.message.text.SetInsertionPoint(len(self.message.text.GetValue()))
widgetUtils.connect_event(self.message.spellcheck, widgetUtils.BUTTON_PRESSED, self.spellcheck) widgetUtils.connect_event(self.message.spellcheck, widgetUtils.BUTTON_PRESSED, self.spellcheck)
@ -24,39 +24,39 @@ class toot(messages.basicTweet):
widgetUtils.connect_event(self.message.remove_attachment, widgetUtils.BUTTON_PRESSED, self.remove_attachment) widgetUtils.connect_event(self.message.remove_attachment, widgetUtils.BUTTON_PRESSED, self.remove_attachment)
# ToDo: Add autocomplete feature to mastodon and uncomment this. # ToDo: Add autocomplete feature to mastodon and uncomment this.
# widgetUtils.connect_event(self.message.autocomplete_users, widgetUtils.BUTTON_PRESSED, self.autocomplete_users) # widgetUtils.connect_event(self.message.autocomplete_users, widgetUtils.BUTTON_PRESSED, self.autocomplete_users)
widgetUtils.connect_event(self.message.add_toot, widgetUtils.BUTTON_PRESSED, self.add_toot) widgetUtils.connect_event(self.message.add_post, widgetUtils.BUTTON_PRESSED, self.add_post)
widgetUtils.connect_event(self.message.remove_toot, widgetUtils.BUTTON_PRESSED, self.remove_toot) widgetUtils.connect_event(self.message.remove_post, widgetUtils.BUTTON_PRESSED, self.remove_post)
self.attachments = [] self.attachments = []
self.thread = [] self.thread = []
self.text_processor() self.text_processor()
def add_toot(self, event, update_gui=True, *args, **kwargs): def add_post(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, sensitive=self.message.sensitive.GetValue(), spoiler_text=None) postdata = dict(text=text, attachments=attachments, sensitive=self.message.sensitive.GetValue(), spoiler_text=None)
if tootdata.get("sensitive") == True: if postdata.get("sensitive") == True:
tootdata.update(spoiler_text=self.message.spoiler.GetValue()) postdata.update(spoiler_text=self.message.spoiler.GetValue())
self.thread.append(tootdata) self.thread.append(postdata)
self.attachments = [] self.attachments = []
if update_gui: if update_gui:
self.message.reset_controls() self.message.reset_controls()
self.message.add_item(item=[text, len(attachments)], list_type="toot") self.message.add_item(item=[text, len(attachments)], list_type="post")
self.message.text.SetFocus() self.message.text.SetFocus()
self.text_processor() self.text_processor()
def get_toot_data(self): def get_post_data(self):
self.add_toot(event=None, update_gui=False) self.add_post(event=None, update_gui=False)
return self.thread return self.thread
def text_processor(self, *args, **kwargs): def text_processor(self, *args, **kwargs):
super(toot, self).text_processor(*args, **kwargs) super(post, self).text_processor(*args, **kwargs)
if len(self.thread) > 0: if len(self.thread) > 0:
if hasattr(self.message, "toots"): if hasattr(self.message, "posts"):
self.message.toots.Enable(True) self.message.posts.Enable(True)
self.message.remove_toot.Enable(True) self.message.remove_post.Enable(True)
else: else:
self.message.toots.Enable(False) self.message.posts.Enable(False)
self.message.remove_toot.Enable(False) self.message.remove_post.Enable(False)
if len(self.attachments) > 0: if len(self.attachments) > 0:
self.message.attachments.Enable(True) self.message.attachments.Enable(True)
self.message.remove_attachment.Enable(True) self.message.remove_attachment.Enable(True)
@ -64,15 +64,15 @@ class toot(messages.basicTweet):
self.message.attachments.Enable(False) self.message.attachments.Enable(False)
self.message.remove_attachment.Enable(False) self.message.remove_attachment.Enable(False)
if len(self.message.text.GetValue()) > 0 or len(self.attachments) > 0: if len(self.message.text.GetValue()) > 0 or len(self.attachments) > 0:
self.message.add_toot.Enable(True) self.message.add_post.Enable(True)
else: else:
self.message.add_toot.Enable(False) self.message.add_post.Enable(False)
def remove_toot(self, *args, **kwargs): def remove_post(self, *args, **kwargs):
toot = self.message.toots.GetFocusedItem() post = self.message.posts.GetFocusedItem()
if toot > -1 and len(self.thread) > toot: if post > -1 and len(self.thread) > post:
self.thread.pop(toot) self.thread.pop(post)
self.message.remove_item(list_type="toot") self.message.remove_item(list_type="post")
self.text_processor() self.text_processor()
self.message.text.SetFocus() self.message.text.SetFocus()
@ -163,7 +163,7 @@ class toot(messages.basicTweet):
break break
if can_attach == False or big_media_present == True: if can_attach == False or big_media_present == True:
return self.message.unable_to_attach_file() return self.message.unable_to_attach_file()
dlg = tootDialogs.poll() dlg = postDialogs.poll()
if dlg.ShowModal() == wx.ID_OK: if dlg.ShowModal() == wx.ID_OK:
day = 86400 day = 86400
periods = [300, 1800, 3600, 21600, day, day*2, day*3, day*4, day*5, day*6, day*7] periods = [300, 1800, 3600, 21600, day, day*2, day*3, day*4, day*5, day*6, day*7]
@ -178,33 +178,33 @@ class toot(messages.basicTweet):
dlg.Destroy() dlg.Destroy()
def get_data(self): def get_data(self):
self.add_toot(event=None, update_gui=False) self.add_post(event=None, update_gui=False)
return self.thread return self.thread
def get_visibility(self): def get_visibility(self):
visibility_settings = ["public", "unlisted", "private", "direct"] visibility_settings = ["public", "unlisted", "private", "direct"]
return visibility_settings[self.message.visibility.GetSelection()] return visibility_settings[self.message.visibility.GetSelection()]
class viewToot(toot): class viewPost(post):
def __init__(self, toot, offset_hours=0, date="", item_url=""): def __init__(self, post, offset_hours=0, date="", item_url=""):
if toot.reblog != None: if post.reblog != None:
toot = toot.reblog post = post.reblog
author = toot.account.display_name if toot.account.display_name != "" else toot.account.username author = post.account.display_name if post.account.display_name != "" else post.account.username
title = _(u"Toot from {}").format(author) title = _(u"Post from {}").format(author)
image_description = templates.process_image_descriptions(toot.media_attachments) image_description = templates.process_image_descriptions(post.media_attachments)
text = templates.process_text(toot, safe=False) text = templates.process_text(post, safe=False)
date = templates.process_date(toot.created_at, relative_times=False, offset_hours=offset_hours) date = templates.process_date(post.created_at, relative_times=False, offset_hours=offset_hours)
privacy_settings = dict(public=_("Public"), unlisted=_("Not listed"), private=_("followers only"), direct=_("Direct")) privacy_settings = dict(public=_("Public"), unlisted=_("Not listed"), private=_("followers only"), direct=_("Direct"))
privacy = privacy_settings.get(toot.visibility) privacy = privacy_settings.get(post.visibility)
boost_count = str(toot.reblogs_count) boost_count = str(post.reblogs_count)
favs_count = str(toot.favourites_count) favs_count = str(post.favourites_count)
# Gets the client from where this toot was made. # Gets the client from where this post was made.
source_obj = toot.get("application") source_obj = post.get("application")
if source_obj == None: if source_obj == None:
source = _("Remote instance") source = _("Remote instance")
else: else:
source = source_obj.get("name") source = source_obj.get("name")
self.message = tootDialogs.viewToot(text=text, boosts_count=boost_count, favs_count=favs_count, source=source, date=date, privacy=privacy) self.message = postDialogs.viewPost(text=text, boosts_count=boost_count, favs_count=favs_count, source=source, date=date, privacy=privacy)
self.message.SetTitle(title) self.message.SetTitle(title)
if image_description != "": if image_description != "":
self.message.image_description.Enable(True) self.message.image_description.Enable(True)

View File

@ -6,7 +6,7 @@ ignored_clients = list(default=list())
[general] [general]
relative_times = boolean(default=True) relative_times = boolean(default=True)
max_toots_per_call = integer(default=40) max_posts_per_call = integer(default=40)
reverse_timelines = boolean(default=False) reverse_timelines = boolean(default=False)
persist_size = integer(default=0) persist_size = integer(default=0)
load_cache_in_memory=boolean(default=True) load_cache_in_memory=boolean(default=True)
@ -44,9 +44,9 @@ braille_reporting = boolean(default=True)
speech_reporting = boolean(default=True) speech_reporting = boolean(default=True)
[templates] [templates]
toot = string(default="$display_name, $safe_text $image_descriptions $date. $visibility. $source") post = string(default="$display_name, $safe_text $image_descriptions $date. $visibility. $source")
person = string(default="$display_name (@$screen_name). $followers followers, $following following, $toots toots. Joined $created_at.") person = string(default="$display_name (@$screen_name). $followers followers, $following following, $toots toots. Joined $created_at.")
conversation = string(default="Conversation with $users. Last message: $last_toot") conversation = string(default="Conversation with $users. Last message: $last_post")
[filters] [filters]

View File

@ -3,23 +3,23 @@ import arrow
import languageHandler import languageHandler
from . import utils, templates from . import utils, templates
def compose_toot(toot, db, relative_times, show_screen_names): def compose_post(post, db, relative_times, show_screen_names):
if show_screen_names == False: if show_screen_names == False:
user = toot.account.get("display_name") user = post.account.get("display_name")
if user == "": if user == "":
user = toot.account.get("username") user = post.account.get("username")
else: else:
user = toot.account.get("acct") user = post.account.get("acct")
original_date = arrow.get(toot.created_at) original_date = arrow.get(post.created_at)
if relative_times: if relative_times:
ts = original_date.humanize(locale=languageHandler.curLang[:2]) ts = original_date.humanize(locale=languageHandler.curLang[:2])
else: else:
ts = original_date.shift(hours=db["utc_offset"]).format(_("dddd, MMMM D, YYYY H:m"), locale=languageHandler.curLang[:2]) ts = original_date.shift(hours=db["utc_offset"]).format(_("dddd, MMMM D, YYYY H:m"), locale=languageHandler.curLang[:2])
if toot.reblog != None: if post.reblog != None:
text = _("Boosted from @{}: {}").format(toot.reblog.account.acct, templates.process_text(toot.reblog)) text = _("Boosted from @{}: {}").format(post.reblog.account.acct, templates.process_text(post.reblog))
else: else:
text = templates.process_text(toot) text = templates.process_text(post)
source = toot.get("application", "") source = post.get("application", "")
# "" means remote user, None for legacy apps so we should cover both sides. # "" means remote user, None for legacy apps so we should cover both sides.
if source != None and source != "": if source != None and source != "":
source = source.get("name", "") source = source.get("name", "")
@ -36,7 +36,7 @@ def compose_user(user, db, relative_times=True, show_screen_names=False):
name = user.display_name name = user.display_name
if name == "": if name == "":
name = user.get("username") name = user.get("username")
return [_("%s (@%s). %s followers, %s following, %s toots. Joined %s") % (name, user.acct, user.followers_count, user.following_count, user.statuses_count, ts)] return [_("%s (@%s). %s followers, %s following, %s posts. Joined %s") % (name, user.acct, user.followers_count, user.following_count, user.statuses_count, ts)]
def compose_conversation(conversation, db, relative_times, show_screen_names): def compose_conversation(conversation, db, relative_times, show_screen_names):
users = [] users = []
@ -46,6 +46,6 @@ def compose_conversation(conversation, db, relative_times, show_screen_names):
else: else:
users.append(account.username) users.append(account.username)
users = ", ".join(users) users = ", ".join(users)
last_toot = compose_toot(conversation.last_status, db, relative_times, show_screen_names) last_post = compose_post(conversation.last_status, db, relative_times, show_screen_names)
text = _("Last message from {}: {}").format(last_toot[0], last_toot[1]) text = _("Last message from {}: {}").format(last_post[0], last_post[1])
return [users, text, last_toot[-2], last_toot[-1]] return [users, text, last_post[-2], last_post[-1]]

View File

@ -76,8 +76,8 @@ class Session(base.baseSession):
self.get_muted_users() self.get_muted_users()
# determine instance custom characters limit. # determine instance custom characters limit.
instance = self.api.instance() instance = self.api.instance()
if hasattr(instance, "max_toot_chars"): if hasattr(instance, "max_post_chars"):
self.char_limit = instance.max_toot_chars self.char_limit = instance.max_post_chars
self.settings.write() self.settings.write()
def get_lists(self): def get_lists(self):
@ -150,10 +150,10 @@ class Session(base.baseSession):
if _sound != None: self.sound.play(_sound) if _sound != None: self.sound.play(_sound)
return val return val
def send_toot(self, reply_to=None, users=None, visibility=None, toots=[]): def send_post(self, reply_to=None, users=None, visibility=None, posts=[]):
""" Convenience function to send a thread. """ """ Convenience function to send a thread. """
in_reply_to_id = reply_to in_reply_to_id = reply_to
for obj in toots: for obj in posts:
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, sensitive=obj["sensitive"], spoiler_text=obj["spoiler_text"]) 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"])

View File

@ -7,16 +7,16 @@ from . import utils, compose
# Define variables that would be available for all template objects. # Define variables that would be available for all template objects.
# This will be used for the edit template dialog. # This will be used for the edit template dialog.
# Available variables for toot objects. # Available variables for post objects.
# safe_text will be the content warning in case a toot contains one, text will always be the full text, no matter if has a content warning or not. # safe_text will be the content warning in case a post contains one, text will always be the full text, no matter if has a content warning or not.
toot_variables = ["date", "display_name", "screen_name", "source", "lang", "safe_text", "text", "image_descriptions", "visibility"] post_variables = ["date", "display_name", "screen_name", "source", "lang", "safe_text", "text", "image_descriptions", "visibility"]
person_variables = ["display_name", "screen_name", "description", "followers", "following", "favorites", "toots", "created_at"] person_variables = ["display_name", "screen_name", "description", "followers", "following", "favorites", "posts", "created_at"]
conversation_variables = ["users", "last_toot"] conversation_variables = ["users", "last_post"]
# Default, translatable templates. # Default, translatable templates.
toot_default_template = _("$display_name, $text $image_descriptions $date. $source") post_default_template = _("$display_name, $text $image_descriptions $date. $source")
dm_sent_default_template = _("Dm to $recipient_display_name, $text $date") dm_sent_default_template = _("Dm to $recipient_display_name, $text $date")
person_default_template = _("$display_name (@$screen_name). $followers followers, $following following, $toots toots. Joined $created_at.") person_default_template = _("$display_name (@$screen_name). $followers followers, $following following, $posts posts. Joined $created_at.")
def process_date(field, relative_times=True, offset_hours=0): def process_date(field, relative_times=True, offset_hours=0):
original_date = arrow.get(field) original_date = arrow.get(field)
@ -26,11 +26,11 @@ def process_date(field, relative_times=True, offset_hours=0):
ts = original_date.shift(hours=offset_hours).format(_("dddd, MMMM D, YYYY H:m:s"), locale=languageHandler.curLang[:2]) ts = original_date.shift(hours=offset_hours).format(_("dddd, MMMM D, YYYY H:m:s"), locale=languageHandler.curLang[:2])
return ts return ts
def process_text(toot, safe=True): def process_text(post, safe=True):
# text = utils.clean_mentions(utils.StripChars(text)) # text = utils.clean_mentions(utils.StripChars(text))
if safe == True and toot.sensitive == True and toot.spoiler_text != "": if safe == True and post.sensitive == True and post.spoiler_text != "":
return _("Content warning: {}").format(toot.spoiler_text) return _("Content warning: {}").format(post.spoiler_text)
return utils.html_filter(toot.content) return utils.html_filter(post.content)
def process_image_descriptions(media_attachments): def process_image_descriptions(media_attachments):
""" Attempt to extract information for image descriptions. """ """ Attempt to extract information for image descriptions. """
@ -48,51 +48,51 @@ def remove_unneeded_variables(template, variables):
template = re.sub("\$"+variable, "", template) template = re.sub("\$"+variable, "", template)
return template return template
def render_toot(toot, template, relative_times=False, offset_hours=0): def render_post(post, template, relative_times=False, offset_hours=0):
""" Renders any given toot according to the passed template. """ Renders any given post according to the passed template.
Available data for toots will be stored in the following variables: Available data for posts will be stored in the following variables:
$date: Creation date. $date: Creation date.
$display_name: User profile name. $display_name: User profile name.
$screen_name: User screen name, this is the same name used to reference the user in Twitter. $screen_name: User screen name, this is the same name used to reference the user in Twitter.
$ source: Source client from where the current tweet was sent. $ source: Source client from where the current tweet was sent.
$lang: Two letter code for the automatically detected language for the tweet. This detection is performed by Twitter. $lang: Two letter code for the automatically detected language for the tweet. This detection is performed by Twitter.
$safe_text: Safe text to display. If a content warning is applied in toots, display those instead of the whole toot. $safe_text: Safe text to display. If a content warning is applied in posts, display those instead of the whole post.
$text: Toot text. This always displays the full text, even if there is a content warning present. $text: Toot text. This always displays the full text, even if there is a content warning present.
$image_descriptions: Information regarding image descriptions added by twitter users. $image_descriptions: Information regarding image descriptions added by twitter users.
$visibility: toot's visibility: public, not listed, followers only or direct. $visibility: post's visibility: public, not listed, followers only or direct.
""" """
global toot_variables global post_variables
available_data = dict() available_data = dict()
created_at = process_date(toot.created_at, relative_times, offset_hours) created_at = process_date(post.created_at, relative_times, offset_hours)
available_data.update(date=created_at) available_data.update(date=created_at)
# user. # user.
display_name = toot.account.display_name display_name = post.account.display_name
if display_name == "": if display_name == "":
display_name = toot.account.username display_name = post.account.username
available_data.update(display_name=display_name, screen_name=toot.account.acct) available_data.update(display_name=display_name, screen_name=post.account.acct)
# Source client from where tweet was originated. # Source client from where tweet was originated.
source = "" source = ""
if hasattr(toot, "application") and toot.application != None: if hasattr(post, "application") and post.application != None:
available_data.update(source=toot.application.get("name")) available_data.update(source=post.application.get("name"))
if toot.reblog != None: if post.reblog != None:
text = _("Boosted from @{}: {}").format(toot.reblog.account.acct, process_text(toot.reblog, safe=False), ) text = _("Boosted from @{}: {}").format(post.reblog.account.acct, process_text(post.reblog, safe=False), )
safe_text = _("Boosted from @{}: {}").format(toot.reblog.account.acct, process_text(toot.reblog), ) safe_text = _("Boosted from @{}: {}").format(post.reblog.account.acct, process_text(post.reblog), )
else: else:
text = process_text(toot, safe=False) text = process_text(post, safe=False)
safe_text = process_text(toot) safe_text = process_text(post)
visibility_settings = dict(public=_("Public"), unlisted=_("Not listed"), private=_("Followers only"), direct=_("Direct")) visibility_settings = dict(public=_("Public"), unlisted=_("Not listed"), private=_("Followers only"), direct=_("Direct"))
visibility = visibility_settings.get(toot.visibility) visibility = visibility_settings.get(post.visibility)
available_data.update(lang=toot.language, text=text, safe_text=safe_text, visibility=visibility) available_data.update(lang=post.language, text=text, safe_text=safe_text, visibility=visibility)
# process image descriptions # process image descriptions
image_descriptions = "" image_descriptions = ""
if toot.reblog != None: if post.reblog != None:
image_descriptions = process_image_descriptions(toot.reblog.media_attachments) image_descriptions = process_image_descriptions(post.reblog.media_attachments)
else: else:
image_descriptions = process_image_descriptions(toot.media_attachments) image_descriptions = process_image_descriptions(post.media_attachments)
if image_descriptions != "": if image_descriptions != "":
available_data.update(image_descriptions=image_descriptions) available_data.update(image_descriptions=image_descriptions)
result = Template(_(template)).safe_substitute(**available_data) result = Template(_(template)).safe_substitute(**available_data)
result = remove_unneeded_variables(result, toot_variables) result = remove_unneeded_variables(result, post_variables)
return result return result
def render_user(user, template, relative_times=True, offset_hours=0): def render_user(user, template, relative_times=True, offset_hours=0):
@ -103,14 +103,14 @@ def render_user(user, template, relative_times=True, offset_hours=0):
$description: The user-defined UTF-8 string describing their account. $description: The user-defined UTF-8 string describing their account.
$followers: The number of followers this account currently has. This value might be inaccurate. $followers: The number of followers this account currently has. This value might be inaccurate.
$following: The number of users this account is following (AKA their followings). This value might be inaccurate. $following: The number of users this account is following (AKA their followings). This value might be inaccurate.
$toots: The number of Tweets (including retweets) issued by the user. This value might be inaccurate. $posts: The number of Tweets (including retweets) issued by the user. This value might be inaccurate.
$created_at: The date and time that the user account was created on Twitter. $created_at: The date and time that the user account was created on Twitter.
""" """
global person_variables global person_variables
display_name = user.display_name display_name = user.display_name
if display_name == "": if display_name == "":
display_name = user.username display_name = user.username
available_data = dict(display_name=display_name, screen_name=user.acct, followers=user.followers_count, following=user.following_count, toots=user.statuses_count) available_data = dict(display_name=display_name, screen_name=user.acct, followers=user.followers_count, following=user.following_count, posts=user.statuses_count)
# Nullable values. # Nullable values.
nullables = ["description"] nullables = ["description"]
for nullable in nullables: for nullable in nullables:
@ -122,7 +122,7 @@ def render_user(user, template, relative_times=True, offset_hours=0):
result = remove_unneeded_variables(result, person_variables) result = remove_unneeded_variables(result, person_variables)
return result return result
def render_conversation(conversation, template, toot_template, relative_times=False, offset_hours=0): def render_conversation(conversation, template, post_template, relative_times=False, offset_hours=0):
users = [] users = []
for account in conversation.accounts: for account in conversation.accounts:
if account.display_name != "": if account.display_name != "":
@ -130,8 +130,8 @@ def render_conversation(conversation, template, toot_template, relative_times=Fa
else: else:
users.append(account.username) users.append(account.username)
users = ", ".join(users) users = ", ".join(users)
last_toot = render_toot(conversation.last_status, toot_template, relative_times=relative_times, offset_hours=offset_hours) last_post = render_post(conversation.last_status, post_template, relative_times=relative_times, offset_hours=offset_hours)
available_data = dict(users=users, last_toot=last_toot) available_data = dict(users=users, last_post=last_post)
result = Template(_(template)).safe_substitute(**available_data) result = Template(_(template)).safe_substitute(**available_data)
result = remove_unneeded_variables(result, conversation_variables) result = remove_unneeded_variables(result, conversation_variables)
return result return result

View File

@ -25,33 +25,33 @@ def find_item(item, listItems):
return i return i
return None return None
def is_audio_or_video(toot): def is_audio_or_video(post):
if toot.reblog != None: if post.reblog != None:
return is_audio_or_video(toot.reblog) return is_audio_or_video(post.reblog)
# Checks firstly for Mastodon native videos and audios. # Checks firstly for Mastodon native videos and audios.
for media in toot.media_attachments: for media in post.media_attachments:
if media["type"] == "video" or media["type"] == "audio": if media["type"] == "video" or media["type"] == "audio":
return True return True
def is_image(toot): def is_image(post):
if toot.reblog != None: if post.reblog != None:
return is_audio_or_video(toot.reblog) return is_audio_or_video(post.reblog)
# Checks firstly for Mastodon native videos and audios. # Checks firstly for Mastodon native videos and audios.
for media in toot.media_attachments: for media in post.media_attachments:
if media["type"] == "gifv" or media["type"] == "image": if media["type"] == "gifv" or media["type"] == "image":
return True return True
def get_media_urls(toot): def get_media_urls(post):
urls = [] urls = []
for media in toot.media_attachments: for media in post.media_attachments:
if media.get("type") == "audio" or media.get("type") == "video": if media.get("type") == "audio" or media.get("type") == "video":
urls.append(media.get("url")) urls.append(media.get("url"))
return urls return urls
def find_urls(toot, include_tags=False): def find_urls(post, include_tags=False):
urls = url_re.findall(toot.content) urls = url_re.findall(post.content)
if include_tags == False: if include_tags == False:
for tag in toot.tags: for tag in post.tags:
for url in urls[::]: for url in urls[::]:
if url.lower().endswith("/tags/"+tag["name"]): if url.lower().endswith("/tags/"+tag["name"]):
urls.remove(url) urls.remove(url)

View File

@ -21,12 +21,12 @@ class basePanel(wx.Panel):
self.type = "baseBuffer" self.type = "baseBuffer"
self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer = wx.BoxSizer(wx.VERTICAL)
self.create_list() self.create_list()
self.toot = wx.Button(self, -1, _("Toot")) self.post = wx.Button(self, -1, _("Post"))
self.boost = wx.Button(self, -1, _("Boost")) self.boost = wx.Button(self, -1, _("Boost"))
self.reply = wx.Button(self, -1, _(u"Reply")) self.reply = wx.Button(self, -1, _(u"Reply"))
self.dm = wx.Button(self, -1, _(u"Direct message")) self.dm = wx.Button(self, -1, _(u"Direct message"))
btnSizer = wx.BoxSizer(wx.HORIZONTAL) btnSizer = wx.BoxSizer(wx.HORIZONTAL)
btnSizer.Add(self.toot, 0, wx.ALL, 5) btnSizer.Add(self.post, 0, wx.ALL, 5)
btnSizer.Add(self.boost, 0, wx.ALL, 5) btnSizer.Add(self.boost, 0, wx.ALL, 5)
btnSizer.Add(self.reply, 0, wx.ALL, 5) btnSizer.Add(self.reply, 0, wx.ALL, 5)
btnSizer.Add(self.dm, 0, wx.ALL, 5) btnSizer.Add(self.dm, 0, wx.ALL, 5)

View File

@ -21,10 +21,10 @@ class conversationListPanel(wx.Panel):
self.type = "baseBuffer" self.type = "baseBuffer"
self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer = wx.BoxSizer(wx.VERTICAL)
self.create_list() self.create_list()
self.toot = wx.Button(self, -1, _("Toot")) self.post = wx.Button(self, -1, _("Post"))
self.reply = wx.Button(self, -1, _(u"Reply")) self.reply = wx.Button(self, -1, _(u"Reply"))
btnSizer = wx.BoxSizer(wx.HORIZONTAL) btnSizer = wx.BoxSizer(wx.HORIZONTAL)
btnSizer.Add(self.toot, 0, wx.ALL, 5) btnSizer.Add(self.post, 0, wx.ALL, 5)
btnSizer.Add(self.reply, 0, wx.ALL, 5) btnSizer.Add(self.reply, 0, wx.ALL, 5)
self.sizer.Add(btnSizer, 0, wx.ALL, 5) self.sizer.Add(btnSizer, 0, wx.ALL, 5)
self.sizer.Add(self.list.list, 0, wx.ALL|wx.EXPAND, 5) self.sizer.Add(self.list.list, 0, wx.ALL|wx.EXPAND, 5)

View File

@ -15,11 +15,11 @@ class userPanel(wx.Panel):
self.type = "user" self.type = "user"
self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer = wx.BoxSizer(wx.VERTICAL)
self.create_list() self.create_list()
self.toot = wx.Button(self, -1, _("Toot")) self.post = wx.Button(self, -1, _("Post"))
self.actions = wx.Button(self, -1, _("Actions")) self.actions = wx.Button(self, -1, _("Actions"))
self.message = wx.Button(self, -1, _("Message")) self.message = wx.Button(self, -1, _("Message"))
btnSizer = wx.BoxSizer(wx.HORIZONTAL) btnSizer = wx.BoxSizer(wx.HORIZONTAL)
btnSizer.Add(self.toot, 0, wx.ALL, 5) btnSizer.Add(self.post, 0, wx.ALL, 5)
btnSizer.Add(self.actions, 0, wx.ALL, 5) btnSizer.Add(self.actions, 0, wx.ALL, 5)
btnSizer.Add(self.message, 0, wx.ALL, 5) btnSizer.Add(self.message, 0, wx.ALL, 5)
self.sizer.Add(btnSizer, 0, wx.ALL, 5) self.sizer.Add(btnSizer, 0, wx.ALL, 5)

View File

@ -4,15 +4,15 @@ import application
def boost_question(): def boost_question():
result = False result = False
dlg = wx.MessageDialog(None, _("Would you like to share this toot?"), _("Boost"), wx.YES_NO|wx.ICON_QUESTION) dlg = wx.MessageDialog(None, _("Would you like to share this post?"), _("Boost"), wx.YES_NO|wx.ICON_QUESTION)
if dlg.ShowModal() == wx.ID_YES: if dlg.ShowModal() == wx.ID_YES:
result = True result = True
dlg.Destroy() dlg.Destroy()
return result return result
def delete_toot_dialog(): def delete_post_dialog():
result = False result = False
dlg = wx.MessageDialog(None, _("Do you really want to delete this toot? It will be deleted from the instance as well."), _("Delete"), wx.ICON_QUESTION|wx.YES_NO) dlg = wx.MessageDialog(None, _("Do you really want to delete this post? It will be deleted from the instance as well."), _("Delete"), wx.ICON_QUESTION|wx.YES_NO)
if dlg.ShowModal() == wx.ID_YES: if dlg.ShowModal() == wx.ID_YES:
result = True result = True
dlg.Destroy() dlg.Destroy()
@ -26,13 +26,13 @@ def clear_list():
dlg.Destroy() dlg.Destroy()
return result return result
def no_toots(): def no_posts():
dlg = wx.MessageDialog(None, _("This user has no toots. {0} can't create a timeline.").format(application.name), _(u"Error"), wx.ICON_ERROR) dlg = wx.MessageDialog(None, _("This user has no posts. {0} can't create a timeline.").format(application.name), _(u"Error"), wx.ICON_ERROR)
dlg.ShowModal() dlg.ShowModal()
dlg.Destroy() dlg.Destroy()
def no_favs(): def no_favs():
dlg = wx.MessageDialog(None, _(u"This user has no favorited toots. {0} can't create a timeline.").format(application.name), _(u"Error"), wx.ICON_ERROR) dlg = wx.MessageDialog(None, _(u"This user has no favorited posts. {0} can't create a timeline.").format(application.name), _(u"Error"), wx.ICON_ERROR)
dlg.ShowModal() dlg.ShowModal()
dlg.Destroy() dlg.Destroy()

View File

@ -1,17 +1,17 @@
import wx import wx
class Toot(wx.Dialog): class Post(wx.Dialog):
def __init__(self, caption=_("toot"), text="", *args, **kwds): def __init__(self, caption=_("Post"), text="", *args, **kwds):
super(Toot, self).__init__(parent=None, id=wx.ID_ANY, *args, **kwds) super(Post, self).__init__(parent=None, id=wx.ID_ANY, *args, **kwds)
main_sizer = wx.BoxSizer(wx.VERTICAL) main_sizer = wx.BoxSizer(wx.VERTICAL)
toot_sizer = wx.WrapSizer(wx.VERTICAL) post_sizer = wx.WrapSizer(wx.VERTICAL)
main_sizer.Add(toot_sizer, 1, wx.EXPAND, 0) main_sizer.Add(post_sizer, 1, wx.EXPAND, 0)
toot_label = wx.StaticText(self, wx.ID_ANY, caption) post_label = wx.StaticText(self, wx.ID_ANY, caption)
toot_sizer.Add(toot_label, 0, 0, 0) post_sizer.Add(post_label, 0, 0, 0)
self.text = wx.TextCtrl(self, wx.ID_ANY, text, style=wx.TE_MULTILINE) self.text = wx.TextCtrl(self, wx.ID_ANY, text, style=wx.TE_MULTILINE)
self.Bind(wx.EVT_CHAR_HOOK, self.handle_keys, self.text) self.Bind(wx.EVT_CHAR_HOOK, self.handle_keys, self.text)
self.text.SetMinSize((350, -1)) self.text.SetMinSize((350, -1))
toot_sizer.Add(self.text, 0, 0, 0) post_sizer.Add(self.text, 0, 0, 0)
lists_sizer = wx.BoxSizer(wx.HORIZONTAL) lists_sizer = wx.BoxSizer(wx.HORIZONTAL)
main_sizer.Add(lists_sizer, 1, wx.EXPAND, 0) main_sizer.Add(lists_sizer, 1, wx.EXPAND, 0)
attachments_sizer = wx.WrapSizer(wx.VERTICAL) attachments_sizer = wx.WrapSizer(wx.VERTICAL)
@ -27,22 +27,22 @@ class Toot(wx.Dialog):
self.remove_attachment = wx.Button(self, wx.ID_ANY, _("Remove Attachment")) self.remove_attachment = wx.Button(self, wx.ID_ANY, _("Remove Attachment"))
self.remove_attachment.Enable(False) self.remove_attachment.Enable(False)
attachments_sizer.Add(self.remove_attachment, 0, 0, 0) attachments_sizer.Add(self.remove_attachment, 0, 0, 0)
toots_sizer = wx.WrapSizer(wx.VERTICAL) posts_sizer = wx.WrapSizer(wx.VERTICAL)
lists_sizer.Add(toots_sizer, 1, wx.EXPAND, 0) lists_sizer.Add(posts_sizer, 1, wx.EXPAND, 0)
toots_label = wx.StaticText(self, wx.ID_ANY, _("Toots in the thread")) posts_label = wx.StaticText(self, wx.ID_ANY, _("Post in the thread"))
toots_sizer.Add(toots_label, 0, 0, 0) posts_sizer.Add(posts_label, 0, 0, 0)
self.toots = wx.ListCtrl(self, wx.ID_ANY, style=wx.LC_HRULES | wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_VRULES) self.posts = wx.ListCtrl(self, wx.ID_ANY, style=wx.LC_HRULES | wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_VRULES)
self.toots.Enable(False) self.posts.Enable(False)
self.toots.AppendColumn(_("Text"), format=wx.LIST_FORMAT_LEFT, width=-1) self.posts.AppendColumn(_("Text"), format=wx.LIST_FORMAT_LEFT, width=-1)
self.toots.AppendColumn(_("Attachments"), format=wx.LIST_FORMAT_LEFT, width=-1) self.posts.AppendColumn(_("Attachments"), format=wx.LIST_FORMAT_LEFT, width=-1)
toots_sizer.Add(self.toots, 1, wx.EXPAND, 0) posts_sizer.Add(self.posts, 1, wx.EXPAND, 0)
self.remove_toot = wx.Button(self, wx.ID_ANY, _("Remove toot")) self.remove_post = wx.Button(self, wx.ID_ANY, _("Remove post"))
self.remove_toot.Enable(False) self.remove_post.Enable(False)
toots_sizer.Add(self.remove_toot, 0, 0, 0) posts_sizer.Add(self.remove_post, 0, 0, 0)
toot_actions_sizer = wx.BoxSizer(wx.HORIZONTAL) post_actions_sizer = wx.BoxSizer(wx.HORIZONTAL)
main_sizer.Add(toot_actions_sizer, 1, wx.EXPAND, 0) main_sizer.Add(post_actions_sizer, 1, wx.EXPAND, 0)
visibility_sizer = wx.BoxSizer(wx.HORIZONTAL) visibility_sizer = wx.BoxSizer(wx.HORIZONTAL)
toot_actions_sizer.Add(visibility_sizer, 1, wx.EXPAND, 0) post_actions_sizer.Add(visibility_sizer, 1, wx.EXPAND, 0)
label_1 = wx.StaticText(self, wx.ID_ANY, _("Visibility")) label_1 = wx.StaticText(self, wx.ID_ANY, _("Visibility"))
visibility_sizer.Add(label_1, 0, 0, 0) visibility_sizer.Add(label_1, 0, 0, 0)
self.visibility = wx.ComboBox(self, wx.ID_ANY, choices=[_("Public"), _("Not listed"), _("Followers only"), _("Direct")], style=wx.CB_DROPDOWN | wx.CB_READONLY | wx.CB_SIMPLE) self.visibility = wx.ComboBox(self, wx.ID_ANY, choices=[_("Public"), _("Not listed"), _("Followers only"), _("Direct")], style=wx.CB_DROPDOWN | wx.CB_READONLY | wx.CB_SIMPLE)
@ -60,9 +60,9 @@ class Toot(wx.Dialog):
spoiler_box.Add(spoiler_label, 0, wx.ALL, 5) spoiler_box.Add(spoiler_label, 0, wx.ALL, 5)
spoiler_box.Add(self.spoiler, 0, wx.ALL, 10) spoiler_box.Add(self.spoiler, 0, wx.ALL, 10)
main_sizer.Add(spoiler_box, 0, wx.ALL, 5) main_sizer.Add(spoiler_box, 0, wx.ALL, 5)
toot_actions_sizer.Add(self.add, 0, 0, 0) post_actions_sizer.Add(self.add, 0, 0, 0)
self.add_toot = wx.Button(self, wx.ID_ANY, _("Add t&oot")) self.add_post = wx.Button(self, wx.ID_ANY, _("Add p&ost"))
toot_actions_sizer.Add(self.add_toot, 0, 0, 0) post_actions_sizer.Add(self.add_post, 0, 0, 0)
text_actions_sizer = wx.BoxSizer(wx.HORIZONTAL) text_actions_sizer = wx.BoxSizer(wx.HORIZONTAL)
main_sizer.Add(text_actions_sizer, 1, wx.EXPAND, 0) main_sizer.Add(text_actions_sizer, 1, wx.EXPAND, 0)
self.autocomplete_users = wx.Button(self, wx.ID_ANY, _("Auto&complete users")) self.autocomplete_users = wx.Button(self, wx.ID_ANY, _("Auto&complete users"))
@ -96,7 +96,7 @@ class Toot(wx.Dialog):
self.spoiler.Enable(self.sensitive.GetValue()) self.spoiler.Enable(self.sensitive.GetValue())
def set_title(self, chars): def set_title(self, chars):
self.SetTitle(_("Toot - {} characters").format(chars)) self.SetTitle(_("Post - {} characters").format(chars))
def reset_controls(self): def reset_controls(self):
self.text.ChangeValue("") self.text.ChangeValue("")
@ -106,7 +106,7 @@ class Toot(wx.Dialog):
if list_type == "attachment": if list_type == "attachment":
self.attachments.Append(item) self.attachments.Append(item)
else: else:
self.toots.Append(item) self.posts.Append(item)
def remove_item(self, list_type="attachment"): def remove_item(self, list_type="attachment"):
if list_type == "attachment": if list_type == "attachment":
@ -114,9 +114,9 @@ class Toot(wx.Dialog):
if item > -1: if item > -1:
self.attachments.DeleteItem(item) self.attachments.DeleteItem(item)
else: else:
item = self.toots.GetFocusedItem() item = self.posts.GetFocusedItem()
if item > -1: if item > -1:
self.toots.DeleteItem(item) self.posts.DeleteItem(item)
def attach_menu(self, event=None, enabled=True, *args, **kwargs): def attach_menu(self, event=None, enabled=True, *args, **kwargs):
menu = wx.Menu() menu = wx.Menu()
@ -157,19 +157,19 @@ class Toot(wx.Dialog):
return openFileDialog.GetPath() return openFileDialog.GetPath()
def unable_to_attach_file(self, *args, **kwargs): def unable_to_attach_file(self, *args, **kwargs):
return wx.MessageDialog(self, _("It is not possible to add more attachments. Please take into account that You can add only a maximum of 4 images, or one audio, video or poll per toot. Please remove other attachments before continuing."), _("Error adding attachment"), wx.ICON_ERROR).ShowModal() return wx.MessageDialog(self, _("It is not possible to add more attachments. Please take into account that You can add only a maximum of 4 images, or one audio, video or poll per post. Please remove other attachments before continuing."), _("Error adding attachment"), wx.ICON_ERROR).ShowModal()
def unable_to_attach_poll(self, *args, **kwargs): def unable_to_attach_poll(self, *args, **kwargs):
return wx.MessageDialog(self, _("You can add a poll or media files. In order to add your poll, please remove other attachments first."), _("Error adding poll"), wx.ICON_ERROR).ShowModal() return wx.MessageDialog(self, _("You can add a poll or media files. In order to add your poll, please remove other attachments first."), _("Error adding poll"), wx.ICON_ERROR).ShowModal()
class viewToot(wx.Dialog): class viewPost(wx.Dialog):
def set_title(self, lenght): def set_title(self, lenght):
self.SetTitle(_("Toot - %i characters ") % (lenght,)) self.SetTitle(_("Post - %i characters ") % (lenght,))
def __init__(self, text="", boosts_count=0, favs_count=0, source="", date="", privacy="", *args, **kwargs): def __init__(self, text="", boosts_count=0, favs_count=0, source="", date="", privacy="", *args, **kwargs):
super(viewToot, self).__init__(parent=None, id=wx.ID_ANY, size=(850,850)) super(viewPost, self).__init__(parent=None, id=wx.ID_ANY, size=(850,850))
panel = wx.Panel(self) panel = wx.Panel(self)
label = wx.StaticText(panel, -1, _("Toot")) label = wx.StaticText(panel, -1, _("Post"))
self.text = wx.TextCtrl(panel, -1, text, style=wx.TE_READONLY|wx.TE_MULTILINE, size=(250, 180)) self.text = wx.TextCtrl(panel, -1, text, style=wx.TE_READONLY|wx.TE_MULTILINE, size=(250, 180))
self.text.SetFocus() self.text.SetFocus()
textBox = wx.BoxSizer(wx.HORIZONTAL) textBox = wx.BoxSizer(wx.HORIZONTAL)