mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 11:18:08 -06:00
Multiline in tweets, searches improvements and visual changes
This commit is contained in:
parent
ee006eeb66
commit
a63d6eceb1
@ -231,7 +231,7 @@ class baseBufferController(bufferController):
|
||||
if self.session.settings["general"]["reverse_timelines"] == False:
|
||||
last_id = self.session.db[self.name][0]["id"]
|
||||
else:
|
||||
last_id = self.session.db[self.name_buffer][-1]["id"]
|
||||
last_id = self.session.db[self.name][-1]["id"]
|
||||
try:
|
||||
items = self.session.get_more_items(self.function, count=self.session.settings["general"]["max_tweets_per_call"], max_id=last_id, *self.args, **self.kwargs)
|
||||
except TwythonError as e:
|
||||
|
@ -30,6 +30,7 @@ import userActionsController
|
||||
import trendingTopics
|
||||
import user
|
||||
import webbrowser
|
||||
from long_tweets import twishort
|
||||
|
||||
log = logging.getLogger("mainController")
|
||||
|
||||
@ -375,12 +376,12 @@ class Controller(object):
|
||||
if dlg.get("tweets") == True:
|
||||
if term not in buffer.session.settings["other_buffers"]["tweet_searches"]:
|
||||
buffer.session.settings["other_buffers"]["tweet_searches"].append(term)
|
||||
search = buffersController.searchBufferController(self.view.nb, "search", "%s-searchterm" % (term,), buffer.session, buffer.session.db["user_name"], bufferType="searchPanel", q=term, count=buffer.settings["general"]["max_tweets_per_call"])
|
||||
search = buffersController.searchBufferController(self.view.nb, "search", "%s-searchterm" % (term,), buffer.session, buffer.session.db["user_name"], bufferType="searchPanel", q=term, count=buffer.session.settings["general"]["max_tweets_per_call"])
|
||||
else:
|
||||
log.error("A buffer for the %s search term is already created. You can't create a duplicate buffer." % (term,))
|
||||
return
|
||||
elif dlg.get("users") == True:
|
||||
search = buffersController.searchPeopleBufferController(self.view.nb, "search_users", "%s-searchUser" % (term,), buffer.session, buffer.session.db["user_name"], bufferType=None, q=term, count=buffer.settings["general"]["max_tweets_per_call"])
|
||||
search = buffersController.searchPeopleBufferController(self.view.nb, "search_users", "%s-searchUser" % (term,), buffer.session, buffer.session.db["user_name"], bufferType=None, q=term, count=buffer.session.settings["general"]["max_tweets_per_call"])
|
||||
self.buffers.append(search)
|
||||
search.start_stream()
|
||||
self.view.insert_buffer(search.buffer, name=_(u"Search for {}".format(term)), pos=self.view.search("searches", buffer.session.db["user_name"]))
|
||||
@ -597,8 +598,14 @@ class Controller(object):
|
||||
buffer = self.get_current_buffer()
|
||||
if buffer.type == "baseBuffer" or buffer.type == "favourites_timeline" or buffer.type == "list" or buffer.type == "search":
|
||||
try:
|
||||
tweet_id = buffer.get_right_tweet()["id"]
|
||||
tweet = buffer.get_right_tweet()
|
||||
tweet_id = tweet["id"]
|
||||
uri = None
|
||||
if tweet.has_key("long_uri"):
|
||||
uri = tweet["long_uri"]
|
||||
tweet = buffer.session.twitter.twitter.show_status(id=tweet_id)
|
||||
if uri != None:
|
||||
tweet["text"] = twishort.get_full_text(uri)
|
||||
msg = messages.viewTweet(tweet, )
|
||||
except TwythonError:
|
||||
non_tweet = buffer.get_formatted_message()
|
||||
|
@ -95,7 +95,7 @@ class audioUploader(object):
|
||||
self.file = tempfile.mktemp(suffix='.wav')
|
||||
self.recording = sound.recording(self.file)
|
||||
self.recording.play()
|
||||
self.dialog.set("record", _(u"Stop recording"))
|
||||
self.dialog.set("record", _(u"Stop"))
|
||||
output.speak(_(u"Recording"))
|
||||
|
||||
def stop_recording(self):
|
||||
|
@ -28,6 +28,9 @@ class audioDialog(widgetUtils.BaseDialog):
|
||||
super(audioDialog, self).__init__(None, -1, _(u"Attach audio"))
|
||||
panel = wx.Panel(self)
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
btnSizer2 = wx.BoxSizer(wx.HORIZONTAL)
|
||||
|
||||
self.play = wx.Button(panel, -1, _(u"Play"))
|
||||
self.play.Disable()
|
||||
self.pause = wx.Button(panel, -1, _(u"Pause"))
|
||||
@ -40,17 +43,23 @@ class audioDialog(widgetUtils.BaseDialog):
|
||||
label = wx.StaticText(panel, -1, _(u"Upload to"))
|
||||
self.services = wx.ComboBox(panel, -1, choices=services, value=services[0], style=wx.CB_READONLY)
|
||||
servicesBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
servicesBox.Add(label)
|
||||
servicesBox.Add(self.services)
|
||||
servicesBox.Add(label, 0, wx.ALL, 5)
|
||||
servicesBox.Add(self.services, 0, wx.ALL, 5)
|
||||
self.attach = wx.Button(panel, wx.ID_OK, _(u"Attach"))
|
||||
self.attach.Disable()
|
||||
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"Cancel"))
|
||||
sizer.Add(self.play)
|
||||
sizer.Add(self.pause)
|
||||
sizer.Add(self.record)
|
||||
sizer.Add(self.attach_exists)
|
||||
sizer.Add(self.discard)
|
||||
sizer.Add(self.attach)
|
||||
btnSizer.Add(self.play, 0, wx.ALL, 5)
|
||||
btnSizer.Add(self.pause, 0, wx.ALL, 5)
|
||||
btnSizer.Add(self.record, 0, wx.ALL, 5)
|
||||
btnSizer2.Add(self.attach_exists, 0, wx.ALL, 5)
|
||||
btnSizer2.Add(self.discard, 0, wx.ALL, 5)
|
||||
btnSizer2.Add(self.attach, 0, wx.ALL, 5)
|
||||
btnSizer2.Add(cancel, 0, wx.ALL, 5)
|
||||
sizer.Add(servicesBox, 0, wx.ALL, 5)
|
||||
sizer.Add(btnSizer, 0, wx.ALL, 5)
|
||||
sizer.Add(btnSizer2, 0, wx.ALL, 5)
|
||||
panel.SetSizer(sizer)
|
||||
self.SetClientSize(sizer.CalcMin())
|
||||
|
||||
def enable_control(self, control):
|
||||
log.debug("Enabling control %s" % (control,))
|
||||
|
@ -26,34 +26,35 @@ class spellCheckerDialog(wx.Dialog):
|
||||
word = wx.StaticText(panel, -1, _(u"Mis-spelled word"))
|
||||
self.word = wx.TextCtrl(panel, -1)
|
||||
wordBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
wordBox.Add(word)
|
||||
wordBox.Add(self.word)
|
||||
wordBox.Add(word, 0, wx.ALL, 5)
|
||||
wordBox.Add(self.word, 0, wx.ALL, 5)
|
||||
context = wx.StaticText(panel, -1, _(u"Context"))
|
||||
self.context = wx.TextCtrl(panel, -1)
|
||||
contextBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
contextBox.Add(context)
|
||||
contextBox.Add(self.context)
|
||||
contextBox.Add(context, 0, wx.ALL, 5)
|
||||
contextBox.Add(self.context, 0, wx.ALL, 5)
|
||||
suggest = wx.StaticText(panel, -1, _(u"Suggestions"))
|
||||
self.suggestions = wx.ListBox(panel, -1, choices=[], style=wx.LB_SINGLE)
|
||||
suggestionsBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
suggestionsBox.Add(suggest)
|
||||
suggestionsBox.Add(self.suggestions)
|
||||
suggestionsBox.Add(suggest, 0, wx.ALL, 5)
|
||||
suggestionsBox.Add(self.suggestions, 0, wx.ALL, 5)
|
||||
self.ignore = wx.Button(panel, -1, _(u"Ignore"))
|
||||
self.ignoreAll = wx.Button(panel, -1, _(u"Ignore all"))
|
||||
self.replace = wx.Button(panel, -1, _(u"Replace"))
|
||||
self.replaceAll = wx.Button(panel, -1, _(u"Replace all"))
|
||||
close = wx.Button(panel, wx.ID_CANCEL)
|
||||
btnBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
btnBox.Add(self.ignore)
|
||||
btnBox.Add(self.ignoreAll)
|
||||
btnBox.Add(self.replace)
|
||||
btnBox.Add(self.replaceAll)
|
||||
btnBox.Add(close)
|
||||
sizer.Add(wordBox)
|
||||
sizer.Add(contextBox)
|
||||
sizer.Add(suggestionsBox)
|
||||
sizer.Add(btnBox)
|
||||
panel.SetSizerAndFit(sizer)
|
||||
btnBox.Add(self.ignore, 0, wx.ALL, 5)
|
||||
btnBox.Add(self.ignoreAll, 0, wx.ALL, 5)
|
||||
btnBox.Add(self.replace, 0, wx.ALL, 5)
|
||||
btnBox.Add(self.replaceAll, 0, wx.ALL, 5)
|
||||
btnBox.Add(close, 0, wx.ALL, 5)
|
||||
sizer.Add(wordBox, 0, wx.ALL, 5)
|
||||
sizer.Add(contextBox, 0, wx.ALL, 5)
|
||||
sizer.Add(suggestionsBox, 0, wx.ALL, 5)
|
||||
sizer.Add(btnBox, 0, wx.ALL, 5)
|
||||
panel.SetSizer(sizer)
|
||||
self.SetClientSize(sizer.CalcMin())
|
||||
|
||||
|
||||
def get_response(self):
|
||||
|
@ -17,4 +17,22 @@
|
||||
#
|
||||
############################################################
|
||||
import requests
|
||||
import keys
|
||||
from twitter import utils
|
||||
|
||||
def get_twishort_uri(url):
|
||||
return url.split("twishort.com/")[1]
|
||||
|
||||
def is_long(tweet):
|
||||
long = False
|
||||
for url in range(0, len(tweet["entities"]["urls"])):
|
||||
if "twishort.com" in tweet["entities"]["urls"][url]["expanded_url"]:
|
||||
long = get_twishort_uri(tweet["entities"]["urls"][url]["expanded_url"])
|
||||
return long
|
||||
|
||||
def get_full_text(uri):
|
||||
# try:
|
||||
r = requests.get("http://api.twishort.com/1.1/get.json", params={"uri": uri, "api_key": keys.keyring.get("twishort_api_key")})
|
||||
return r.json()["text"]
|
||||
# except:
|
||||
# return False
|
@ -14,16 +14,15 @@ class list(object):
|
||||
# self.set_size()
|
||||
|
||||
def set_windows_size(self, column, characters_max):
|
||||
it = wx.ListItem()
|
||||
dc = wx.WindowDC(self.list)
|
||||
dc.SetFont(it.GetFont())
|
||||
(x, y) = dc.GetTextExtent("r"*characters_max)
|
||||
self.list.SetColumnWidth(column, x)
|
||||
# it = wx.ListItem()
|
||||
# dc = wx.WindowDC(self.list)
|
||||
# dc.SetFont(it.GetFont())
|
||||
# (x, y) = dc.GetTextExtent("r"*characters_max)
|
||||
self.list.SetColumnWidth(column, characters_max*2)
|
||||
|
||||
def set_size(self):
|
||||
# self.list.SetSize(self.list.GetBestSize())
|
||||
# print self.list.GetBestSize()
|
||||
self.list.SetSize((1439, 1000))
|
||||
self.list.SetSize((self.list.GetBestSize()[0], 728))
|
||||
# self.list.SetSize((1439, 1000))
|
||||
|
||||
def create_list(self, parent):
|
||||
if self.system == "Windows":
|
||||
|
@ -7,6 +7,7 @@ import output
|
||||
import languageHandler
|
||||
import arrow
|
||||
import logging
|
||||
from long_tweets import twishort
|
||||
log = logging.getLogger("compose")
|
||||
|
||||
def StripChars(s):
|
||||
@ -26,6 +27,9 @@ chars = "abcdefghijklmnopqrstuvwxyz"
|
||||
|
||||
def compose_tweet(tweet, db, relative_times):
|
||||
""" It receives a tweet and returns a list with the user, text for the tweet or message, date and the client where user is."""
|
||||
long = twishort.is_long(tweet)
|
||||
if long != False:
|
||||
tweet["long_uri"] = long
|
||||
original_date = arrow.get(tweet["created_at"], "ddd MMM D H:m:s Z YYYY", locale="en")
|
||||
if relative_times == True:
|
||||
ts = original_date.humanize(locale=languageHandler.getLanguage())
|
||||
|
@ -6,10 +6,10 @@ class basePanel(wx.Panel):
|
||||
|
||||
def create_list(self):
|
||||
self.list = widgets.list(self, _(u"User"), _(u"Text"), _(u"Date"), _(u"Client"), style=wx.LC_REPORT|wx.LC_SINGLE_SEL|wx.LC_VRULES)
|
||||
self.list.set_windows_size(0, 30)
|
||||
self.list.set_windows_size(1, 160)
|
||||
self.list.set_windows_size(2, 55)
|
||||
self.list.set_windows_size(3, 42)
|
||||
self.list.set_windows_size(0, 60)
|
||||
self.list.set_windows_size(1, 320)
|
||||
self.list.set_windows_size(2, 110)
|
||||
self.list.set_windows_size(3, 84)
|
||||
self.list.set_size()
|
||||
|
||||
def __init__(self, parent, name):
|
||||
|
@ -10,12 +10,12 @@ class textLimited(widgetUtils.BaseDialog):
|
||||
self.panel = wx.Panel(self)
|
||||
self.label = wx.StaticText(self.panel, -1, message)
|
||||
self.SetTitle(str(len(text)))
|
||||
self.text = wx.TextCtrl(self.panel, -1, text)
|
||||
font = self.text.GetFont()
|
||||
dc = wx.WindowDC(self.text)
|
||||
dc.SetFont(font)
|
||||
x, y = dc.GetTextExtent("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
|
||||
self.text.SetSize((x, y))
|
||||
self.text = wx.TextCtrl(self.panel, -1, text, size=(439, -1), style=wx.TE_MULTILINE)
|
||||
# font = self.text.GetFont()
|
||||
# dc = wx.WindowDC(self.text)
|
||||
# dc.SetFont(font)
|
||||
# x, y = dc.GetTextExtent("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
|
||||
# self.text.SetSize((x, y))
|
||||
self.text.SetFocus()
|
||||
self.textBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
self.textBox.Add(self.label, 0, wx.ALL, 5)
|
||||
@ -74,19 +74,19 @@ class tweet(textLimited):
|
||||
self.okButton.SetDefault()
|
||||
cancelButton = wx.Button(self.panel, wx.ID_CANCEL, _(u"Close"), size=wx.DefaultSize)
|
||||
self.buttonsBox1 = wx.BoxSizer(wx.HORIZONTAL)
|
||||
self.buttonsBox1.Add(self.upload_image, 0, wx.ALL, 5)
|
||||
self.buttonsBox1.Add(self.spellcheck, 0, wx.ALL, 5)
|
||||
self.buttonsBox1.Add(self.attach, 0, wx.ALL, 5)
|
||||
self.mainBox.Add(self.buttonsBox1, 0, wx.ALL, 5)
|
||||
self.buttonsBox1.Add(self.upload_image, 0, wx.ALL, 10)
|
||||
self.buttonsBox1.Add(self.spellcheck, 0, wx.ALL, 10)
|
||||
self.buttonsBox1.Add(self.attach, 0, wx.ALL, 10)
|
||||
self.mainBox.Add(self.buttonsBox1, 0, wx.ALL, 10)
|
||||
self.buttonsBox2 = wx.BoxSizer(wx.HORIZONTAL)
|
||||
self.buttonsBox2.Add(self.shortenButton, 0, wx.ALL, 5)
|
||||
self.buttonsBox2.Add(self.unshortenButton, 0, wx.ALL, 5)
|
||||
self.buttonsBox2.Add(self.translateButton, 0, wx.ALL, 5)
|
||||
self.mainBox.Add(self.buttonsBox2, 0, wx.ALL, 5)
|
||||
self.buttonsBox2.Add(self.shortenButton, 0, wx.ALL, 10)
|
||||
self.buttonsBox2.Add(self.unshortenButton, 0, wx.ALL, 10)
|
||||
self.buttonsBox2.Add(self.translateButton, 0, wx.ALL, 10)
|
||||
self.mainBox.Add(self.buttonsBox2, 0, wx.ALL, 10)
|
||||
self.ok_cancelSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
self.ok_cancelSizer.Add(self.autocompletionButton, 0, wx.ALL, 5)
|
||||
self.ok_cancelSizer.Add(self.okButton, 0, wx.ALL, 5)
|
||||
self.ok_cancelSizer.Add(cancelButton, 0, wx.ALL, 5)
|
||||
self.ok_cancelSizer.Add(self.autocompletionButton, 0, wx.ALL, 10)
|
||||
self.ok_cancelSizer.Add(self.okButton, 0, wx.ALL, 10)
|
||||
self.ok_cancelSizer.Add(cancelButton, 0, wx.ALL, 10)
|
||||
self.mainBox.Add(self.ok_cancelSizer)
|
||||
selectId = wx.NewId()
|
||||
self.Bind(wx.EVT_MENU, self.onSelect, id=selectId)
|
||||
|
@ -136,6 +136,8 @@ class mainFrame(wx.Frame):
|
||||
# self.Maximize()
|
||||
self.sizer.Layout()
|
||||
self.SetClientSize(self.sizer.CalcMin())
|
||||
# print self.GetSize()
|
||||
|
||||
|
||||
def search(self, name_, account):
|
||||
for i in range(0, self.nb.GetPageCount()):
|
||||
|
Loading…
Reference in New Issue
Block a user