Core: Keystroke editor will show actions available for current session. Changed wording to use correct terms forh both networks

This commit is contained in:
Manuel Cortez 2022-12-20 13:02:27 -06:00
parent 250b248d25
commit ca40103df7
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
7 changed files with 69 additions and 10 deletions

View File

@ -3,6 +3,7 @@ TWBlue Changelog
## changes in this version
* In the graphical interface, TWBlue will update menu items, in the menu bar, depending on whether you are focusing a Twitter or Mastodon session. This makes it possible for TWBlue to display the correct terms in each social network. Take into account that there might be unavailable items for the currently active session.
* in the keystroke editor for the invisible interface, TWBlue displays the available shortcuts for the currently active session. Descriptions of those keystrokes are also different for Twitter and mastodon sessions to use correct terms for both networks.
* In the invisible interface, TWBlue will skip sessions that have not been started when using the keyboard shortcut to switch between different accounts.
* Mastodon:
* Added basic support to notifications buffer. This buffer shows mastodon notifications in real time. Every notification is attached to a kind of object (posts, users, relationships or polls). At the moment, the only supported action for notification is dismissing, which allows you to remove the notification from the buffer (take into account, though, that mention notifications will remove also the mention in its corresponding buffer, due to the way TWBlue reads mentions from mastodon instances).

View File

@ -433,7 +433,8 @@ class Controller(object):
output.speak("Unable to seek.",True)
def edit_keystrokes(self, *args, **kwargs):
editor = keystrokeEditor.KeystrokeEditor()
buffer = self.get_best_buffer()
editor = keystrokeEditor.KeystrokeEditor(buffer.session.type)
if editor.changed == True:
config.keymap.write()
register = False
@ -685,7 +686,7 @@ class Controller(object):
if new_account != old_account:
self.current_account = buffer.account
new_first_buffer = self.get_first_buffer(new_account)
if new_first_buffer.session.type != self.menubar_current_handler:
if new_first_buffer != None and new_first_buffer.session.type != self.menubar_current_handler:
handler = self.get_handler(new_first_buffer.session.type)
self.menubar_current_handler = new_first_buffer.session.type
self.update_menus(handler)

View File

@ -1,3 +1 @@
from __future__ import absolute_import
from __future__ import unicode_literals
from .keystrokeEditor import KeystrokeEditor

View File

@ -0,0 +1 @@
from . import twitter, mastodon

View File

@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
actions = {
"up": _(u"Go up in the current buffer"),
"down": _(u"Go down in the current buffer"),
"left": _(u"Go to the previous buffer"),
"right": _(u"Go to the next buffer"),
"next_account": _(u"Focus the next session"),
"previous_account": _(u"Focus the previous session"),
"show_hide": _(u"Show or hide the GUI"),
"post_tweet": _("Make a new post"),
"post_reply": _(u"Reply"),
"post_retweet": _(u"Boost"),
"send_dm": _(u"Send direct message"),
"add_to_favourites": _("Add post to favorites"),
"remove_from_favourites": _(u"Remove post from favorites"),
"toggle_like": _("Add/remove post from favorites"),
"follow": _(u"Open the user actions dialogue"),
# "user_details": _(u"See user details"),
"view_item": _(u"Show post"),
"exit": _(u"Quit"),
"open_timeline": _(u"Open user timeline"),
"remove_buffer": _(u"Destroy buffer"),
"interact": _(u"Interact with the currently focused post."),
"url": _(u"Open URL"),
"open_in_browser": _(u"View in browser"),
"volume_up": _(u"Increase volume by 5%"),
"volume_down": _(u"Decrease volume by 5%"),
"go_home": _(u"Jump to the first element of a buffer"),
"go_end": _(u"Jump to the last element of the current buffer"),
"go_page_up": _(u"Jump 20 elements up in the current buffer"),
"go_page_down": _(u"Jump 20 elements down in the current buffer"),
# "update_profile": _(u"Edit profile"),
"delete": _("Delete post"),
"clear_buffer": _(u"Empty the current buffer"),
"repeat_item": _(u"Repeat last item"),
"copy_to_clipboard": _(u"Copy to clipboard"),
# "add_to_list": _(u"Add to list"),
# "remove_from_list": _(u"Remove from list"),
"toggle_buffer_mute": _(u"Mute/unmute the active buffer"),
"toggle_session_mute": _(u"Mute/unmute the current session"),
"toggle_autoread": _(u"toggle the automatic reading of incoming tweets in the active buffer"),
"search": _(u"Search on instance"),
"find": _(u"Find a string in the currently focused buffer"),
"edit_keystrokes": _(u"Show the keystroke editor"),
# "view_user_lists": _(u"Show lists for a specified user"),
"get_more_items": _(u"load previous items"),
# "get_trending_topics": _(u"Create a trending topics buffer"),
"open_conversation": _(u"View conversation"),
"check_for_updates": _(u"Check and download updates"),
"configuration": _(u"Opens the global settings dialogue"),
# "list_manager": _(u"Opens the list manager"),
"accountConfiguration": _(u"Opens the account settings dialogue"),
"audio": _(u"Try to play a media file"),
"update_buffer": _(u"Updates the buffer and retrieves possible lost items there."),
# "ocr_image": _(u"Extracts the text from a picture and displays the result in a dialog."),
# "add_alias": _("Adds an alias to an user"),
}

View File

@ -53,7 +53,7 @@ actions = {
"configuration": _(u"Opens the global settings dialogue"),
"list_manager": _(u"Opens the list manager"),
"accountConfiguration": _(u"Opens the account settings dialogue"),
"audio": _(u"Try to play an audio file"),
"audio": _(u"Try to play a media file"),
"update_buffer": _(u"Updates the buffer and retrieves possible lost items there."),
"ocr_image": _(u"Extracts the text from a picture and displays the result in a dialog."),
"add_alias": _("Adds an alias to an user"),

View File

@ -2,18 +2,19 @@
import widgetUtils
import config
from . import wx_ui
from . import constants
from . import actions
from pubsub import pub
class KeystrokeEditor(object):
def __init__(self):
def __init__(self, session_type="twitter"):
super(KeystrokeEditor, self).__init__()
self.actions = getattr(actions, session_type).actions
self.changed = False # Change it if the keyboard shorcuts are reassigned.
self.dialog = wx_ui.keystrokeEditorDialog()
self.map = config.keymap["keymap"]
# we need to copy the keymap before modify it, for unregistering the old keystrokes if is needed.
self.hold_map = self.map.copy()
self.dialog.put_keystrokes(constants.actions, self.map)
self.dialog.put_keystrokes(self.actions, self.map)
widgetUtils.connect_event(self.dialog.edit, widgetUtils.BUTTON_PRESSED, self.edit_keystroke)
widgetUtils.connect_event(self.dialog.undefine, widgetUtils.BUTTON_PRESSED, self.undefine_keystroke)
widgetUtils.connect_event(self.dialog.execute, widgetUtils.BUTTON_PRESSED, self.execute_action)
@ -29,7 +30,7 @@ class KeystrokeEditor(object):
if new_keystroke != self.map[action]:
self.changed = True
self.map[action] = new_keystroke
self.dialog.put_keystrokes(constants.actions, self.map)
self.dialog.put_keystrokes(self.actions, self.map)
def undefine_keystroke(self, *args, **kwargs):
action = self.dialog.actions[self.dialog.get_action()]
@ -40,7 +41,7 @@ class KeystrokeEditor(object):
if answer == widgetUtils.YES:
self.map[action] = ""
self.changed = True
self.dialog.put_keystrokes(constants.actions, self.map)
self.dialog.put_keystrokes(self.actions, self.map)
def set_keystroke(self, keystroke, dialog):
for i in keystroke.split("+"):