Added 'open in Twitter' for tweets and users

This commit is contained in:
Manuel Cortez 2019-02-19 17:41:34 -06:00
parent 720e0e6c24
commit d7132ecaf6
9 changed files with 44 additions and 5 deletions

View File

@ -2,6 +2,7 @@
## changes in this version
* TWBlue can open a Tweet or user directly in Twitter. There is a new option in the context menu for people and tweet buffers, and also, the shortcut control+win+alt+Enter will open the focused item in Twitter.
* Fixed an error that was preventing TWBlue to load the direct messages buffer if an user who sent a message has been deleted.
* Added support for playing audios posted in [AnyAudio.net](http://anyaudio.net) directly from TWBlue. Thanks to [Sam Tupy](http://www.samtupy.com/)
* Custom buffer ordering will not be reset every time the application restarts after an account setting has been modified.

View File

@ -344,6 +344,8 @@ class baseBufferController(baseBuffers.buffer):
widgetUtils.connect_event(menu, widgetUtils.MENU, self.view, menuitem=menu.view)
widgetUtils.connect_event(menu, widgetUtils.MENU, self.copy, menuitem=menu.copy)
widgetUtils.connect_event(menu, widgetUtils.MENU, self.destroy_status, menuitem=menu.remove)
if hasattr(menu, "openInBrowser"):
widgetUtils.connect_event(menu, widgetUtils.MENU, self.open_in_browser, menuitem=menu.openInBrowser)
if pos != 0:
self.buffer.PopupMenu(menu, pos)
else:
@ -627,6 +629,12 @@ class baseBufferController(baseBuffers.buffer):
except IndexError: pass
return compose.compose_quoted_tweet(quoted_tweet, original_tweet, self.session.db, self.session.settings["general"]["relative_times"])
def open_in_browser(self, *args, **kwargs):
tweet = self.get_tweet()
output.speak(_(u"Opening item in web browser..."))
url = "https://twitter.com/{screen_name}/status/{tweet_id}".format(screen_name=tweet["user"]["screen_name"], tweet_id=tweet["id"])
webbrowser.open(url)
class directMessagesController(baseBufferController):
def get_more_items(self):
@ -719,6 +727,9 @@ class directMessagesController(baseBufferController):
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(_(u"{0} new direct messages.").format(number_of_items,))
def open_in_browser(self, *args, **kwargs):
output.speak(_(u"This action is not supported in the buffer yet."))
class sentDirectMessagesController(directMessagesController):
def __init__(self, *args, **kwargs):
@ -951,6 +962,8 @@ class peopleBufferController(baseBufferController):
# widgetUtils.connect_event(menu, widgetUtils.MENU, self.lists, menuitem=menu.lists)
widgetUtils.connect_event(menu, widgetUtils.MENU, self.view, menuitem=menu.view)
widgetUtils.connect_event(menu, widgetUtils.MENU, self.copy, menuitem=menu.copy)
if hasattr(menu, "openInBrowser"):
widgetUtils.connect_event(menu, widgetUtils.MENU, self.open_in_browser, menuitem=menu.openInBrowser)
if pos != 0:
self.buffer.PopupMenu(menu, pos)
else:
@ -969,6 +982,12 @@ class peopleBufferController(baseBufferController):
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(_(u"{0} new followers.").format(number_of_items))
def open_in_browser(self, *args, **kwargs):
tweet = self.get_tweet()
output.speak(_(u"Opening item in web browser..."))
url = "https://twitter.com/{screen_name}".format(screen_name=tweet["screen_name"])
webbrowser.open(url)
class searchBufferController(baseBufferController):
def start_stream(self, mandatory=False, play_sound=True, avoid_autoreading=False):
# starts stream every 3 minutes.
@ -1243,6 +1262,9 @@ class trendsBufferController(baseBuffers.buffer):
if ev.GetKeyCode() == wx.WXK_WINDOWS_MENU:
self.show_menu(widgetUtils.MENU, pos=self.buffer.list.list.GetPosition())
def open_in_browser(self, *args, **kwargs):
output.speak(_(u"This action is not supported in the buffer, yet."))
class conversationBufferController(searchBufferController):
def start_stream(self, start=False, mandatory=False, play_sound=True, avoid_autoreading=False):

View File

@ -812,6 +812,11 @@ class Controller(object):
non_tweet = buffer.get_formatted_message()
msg = messages.viewTweet(non_tweet, [], False)
def view_in_browser(self, *args, **kwargs):
buffer = self.get_current_buffer()
if hasattr(buffer, "open_in_browser"):
buffer.open_in_browser()
def open_favs_timeline(self, *args, **kwargs):
self.open_timeline(default="favourites")

View File

@ -33,4 +33,5 @@ list_manager = string(default="control+win+shift+l")
configuration = string(default="control+win+o")
accountConfiguration = string(default="control+win+shift+o")
update_buffer = string(default="control+win+shift+u")
ocr_image = string(default="win+alt+o")
ocr_image = string(default="win+alt+o")
open_in_browser = string(default="alt+control+win+return")

View File

@ -52,4 +52,5 @@ list_manager = string(default="control+win+shift+l")
configuration = string(default="control+win+o")
accountConfiguration = string(default="control+win+shift+o")
update_buffer = string(default="control+win+shift+u")
ocr_image = string(default="win+alt+o")
ocr_image = string(default="win+alt+o")
open_in_browser = string(default="alt+control+win+return")

View File

@ -53,4 +53,5 @@ list_manager = string(default="alt+win+shift+l")
configuration = string(default="control+win+alt+o")
accountConfiguration = string(default="control+win+shift+o")
update_buffer = string(default="control+alt+shift+u")
ocr_image = string(default="win+alt+o")
ocr_image = string(default="win+alt+o")
open_in_browser = string(default="alt+control+win+return")

View File

@ -54,4 +54,5 @@ check_for_updates = string(default="control+win+u")
list_manager = string(default="control+win+shift+l")
configuration = string(default="control+win+o")
accountConfiguration = string(default="control+win+shift+o")
update_buffer = string(default="control+win+shift+u")
update_buffer = string(default="control+win+shift+u")
open_in_browser = string(default="alt+control+win+return")

View File

@ -55,4 +55,5 @@ list_manager = string(default="control+win+shift+l")
configuration = string(default="control+win+o")
accountConfiguration = string(default="control+win+shift+o")
update_buffer = string(default="control+win+shift+u")
ocr_image = string(default="win+alt+o")
ocr_image = string(default="win+alt+o")
open_in_browser = string(default="alt+control+win+return")

View File

@ -14,6 +14,8 @@ class basePanelMenu(wx.Menu):
self.Append(self.unfav)
self.openUrl = wx.MenuItem(self, wx.ID_ANY, _(u"&Open URL"))
self.Append(self.openUrl)
self.openInBrowser = wx.MenuItem(self, wx.ID_ANY, _(u"&Open in Twitter"))
self.Append(self.openInBrowser)
self.play = wx.MenuItem(self, wx.ID_ANY, _(u"&Play audio"))
self.Append(self.play)
self.view = wx.MenuItem(self, wx.ID_ANY, _(u"&Show tweet"))
@ -48,6 +50,8 @@ class sentPanelMenu(wx.Menu):
super(sentPanelMenu, self).__init__()
self.openUrl = wx.MenuItem(self, wx.ID_ANY, _(u"&Open URL"))
self.Append(self.openUrl)
self.openInBrowser = wx.MenuItem(self, wx.ID_ANY, _(u"&Open in Twitter"))
self.Append(self.openInBrowser)
self.play = wx.MenuItem(self, wx.ID_ANY, _(u"&Play audio"))
self.Append(self.play)
self.view = wx.MenuItem(self, wx.ID_ANY, _(u"&Show tweet"))
@ -79,6 +83,8 @@ class peoplePanelMenu(wx.Menu):
self.Append(self.details)
self.view = wx.MenuItem(self, wx.ID_ANY, _(u"&Show user"))
self.Append(self.view)
self.openInBrowser = wx.MenuItem(self, wx.ID_ANY, _(u"&Open in Twitter"))
self.Append(self.openInBrowser)
self.copy = wx.MenuItem(self, wx.ID_ANY, _(u"&Copy to clipboard"))
self.Append(self.copy)
self.userActions = wx.MenuItem(self, wx.ID_ANY, _(u"&User actions..."))