mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-23 11:48:07 -06:00
Basic tt support, fixed some English mistakes reported by @sukiletxe
This commit is contained in:
parent
ada6f1fb0d
commit
7137d437bd
@ -35,6 +35,7 @@ timelines = list(default=list())
|
||||
tweet_searches = list(default=list())
|
||||
lists = list(default=list())
|
||||
favourites_timelines = list(default=list())
|
||||
trending_topic_buffers = list(default=list())
|
||||
muted_buffers = list(default=list())
|
||||
autoread_buffers = list(default=list())
|
||||
|
||||
|
@ -15,7 +15,7 @@ class autocompletionUsers(object):
|
||||
try:
|
||||
pattern = text.split()[-1]
|
||||
except IndexError:
|
||||
output.speak(_(u"You have to start to write"))
|
||||
output.speak(_(u"You have to start writing"))
|
||||
return
|
||||
if pattern.startswith("@") == True:
|
||||
db = storage.storage()
|
||||
@ -26,6 +26,6 @@ class autocompletionUsers(object):
|
||||
self.window.PopupMenu(menu, self.window.text.GetPosition())
|
||||
menu.Destroy()
|
||||
else:
|
||||
output.speak(_(u"There is not results in your users database"))
|
||||
output.speak(_(u"There are not results in your users database"))
|
||||
else:
|
||||
output.speak(_(u"Autocompletion only works for users."))
|
@ -20,4 +20,4 @@ class autocompletionSettingsDialog(wx.Dialog):
|
||||
self.SetClientSize(sizer.CalcMin())
|
||||
|
||||
def show_success_dialog():
|
||||
wx.MessageDialog(None, _(u"Users TwBlue-database has been updated with new users."), _(u"Done"), wx.OK).ShowModal()
|
||||
wx.MessageDialog(None, _(u"TWBlue's database of users has been updated."), _(u"Done"), wx.OK).ShowModal()
|
@ -8,3 +8,4 @@ from lists import *
|
||||
from people import *
|
||||
from tweet_searches import *
|
||||
from user_searches import *
|
||||
from trends import *
|
@ -20,18 +20,20 @@ import wx
|
||||
from multiplatform_widgets import widgets
|
||||
|
||||
class accountPanel(wx.Panel):
|
||||
def __init__(self, parent):
|
||||
def __init__(self, parent, name_buffer):
|
||||
super(accountPanel, self).__init__(parent=parent)
|
||||
self.type = "account"
|
||||
self.name_buffer = name_buffer
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
self.list = widgets.list(self, _(u"Announce"))
|
||||
sizer.Add(self.list.list, 0, wx.ALL, 5)
|
||||
self.SetSizer(sizer)
|
||||
|
||||
class emptyPanel(accountPanel):
|
||||
def __init__(self, parent):
|
||||
super(emptyPanel, self).__init__(parent=parent)
|
||||
self.type = "empty"
|
||||
|
||||
def get_more_items(self):
|
||||
output.speak(_(u"This action is not supported for this buffer"))
|
||||
|
||||
class emptyPanel(accountPanel):
|
||||
def __init__(self, parent):
|
||||
super(emptyPanel, self).__init__(parent=parent, name_buffer="")
|
||||
self.type = "empty"
|
||||
|
||||
|
@ -17,35 +17,162 @@
|
||||
#
|
||||
############################################################
|
||||
import wx
|
||||
import sound
|
||||
import config
|
||||
import twitter
|
||||
import gui.dialogs
|
||||
import twitter
|
||||
import config
|
||||
import sound
|
||||
import logging as original_logger
|
||||
from base import basePanel
|
||||
import output
|
||||
import platform
|
||||
import menus
|
||||
from multiplatform_widgets import widgets
|
||||
from mysc.thread_utils import call_threaded
|
||||
log = original_logger.getLogger("buffers.base")
|
||||
|
||||
class trendPanel(basePanel):
|
||||
def __init__(self, parent, window, name_buffer, *args, **kwargs):
|
||||
super(searchPanel, self).__init__(parent, window, name_buffer, sound)
|
||||
self.type = "trend"
|
||||
self.args = kwargs
|
||||
class trendsPanel(wx.Panel):
|
||||
|
||||
def start_streams(self):
|
||||
num = twitter.starting.search(self.db, self.twitter, self.name_buffer, **self.args)
|
||||
if num > 0: sound.player.play("search_updated.ogg")
|
||||
self.put_items(num)
|
||||
return num
|
||||
def compose_function(self, trend):
|
||||
return [trend["name"]]
|
||||
|
||||
def bind_events(self):
|
||||
self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.showMenu, self.list.list)
|
||||
self.Bind(wx.EVT_LIST_KEY_DOWN, self.showMenuByKey, self.list.list)
|
||||
self.list.list.Bind(wx.EVT_CHAR_HOOK, self.interact)
|
||||
|
||||
def get_message(self, dialog=False):
|
||||
return self.compose_function(self.trends[self.list.get_selected()])[0]
|
||||
|
||||
|
||||
def create_list(self):
|
||||
self.list = widgets.list(self, _(u"Trending topic"), style=wx.LC_REPORT|wx.LC_SINGLE_SEL|wx.LC_VRULES)
|
||||
if self.system == "Windows":
|
||||
self.list.set_windows_size(0, 30)
|
||||
self.list.set_size()
|
||||
|
||||
def __init__(self, parent, window, name_buffer, argumento=None, sound=""):
|
||||
self.type = "trends"
|
||||
self.twitter = window.twitter
|
||||
self.name_buffer = name_buffer
|
||||
self.argumento = argumento
|
||||
self.sound = sound
|
||||
self.parent = window
|
||||
self.system = platform.system()
|
||||
wx.Panel.__init__(self, parent)
|
||||
self.trends = []
|
||||
self.sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
self.create_list()
|
||||
self.btn = wx.Button(self, -1, _(u"Tweet"))
|
||||
self.btn.Bind(wx.EVT_BUTTON, self.post_status)
|
||||
self.tweetTrendBtn = wx.Button(self, -1, _(u"Tweet about this trend"))
|
||||
self.tweetTrendBtn.Bind(wx.EVT_BUTTON, self.onResponse)
|
||||
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
btnSizer.Add(self.btn, 0, wx.ALL, 5)
|
||||
btnSizer.Add(self.tweetTrendBtn, 0, wx.ALL, 5)
|
||||
self.sizer.Add(btnSizer, 0, wx.ALL, 5)
|
||||
self.sizer.Add(self.list.list, 0, wx.ALL, 5)
|
||||
self.bind_events()
|
||||
self.SetSizer(self.sizer)
|
||||
|
||||
def remove_buffer(self):
|
||||
dlg = wx.MessageDialog(self, _(u"Do you really want to delete this search term?"), _(u"Attention"), style=wx.ICON_QUESTION|wx.YES_NO)
|
||||
dlg = wx.MessageDialog(self, _(u"Do you really want to delete this buffer?"), _(u"Attention"), style=wx.ICON_QUESTION|wx.YES_NO)
|
||||
if dlg.ShowModal() == wx.ID_YES:
|
||||
names = config.main["other_buffers"]["tweet_searches"]
|
||||
user = self.name_buffer[:-7]
|
||||
log.info(u"Deleting %s's search term" % user)
|
||||
if user in names:
|
||||
names.remove(user)
|
||||
self.db.settings.pop(self.name_buffer)
|
||||
pos = self.db.settings["buffers"].index(self.name_buffer)
|
||||
self.db.settings["buffers"].remove(self.name_buffer)
|
||||
return pos
|
||||
topics = config.main["other_buffers"]["trending_topic_buffers"]
|
||||
topic = self.name_buffer
|
||||
log.info(u"Deleting %s's trending topics buffer" % topic)
|
||||
if topic in topics:
|
||||
topics.remove(topic)
|
||||
return 0
|
||||
|
||||
def start_streams(self):
|
||||
data = self.twitter.twitter.get_place_trends(id=self.argumento)
|
||||
self.trends = data[0]["trends"]
|
||||
sound.player.play(self.sound)
|
||||
return len(self.trends)
|
||||
|
||||
def get_more_items(self):
|
||||
output.speak(_(u"This action is not supported for this buffer"))
|
||||
|
||||
def put_items(self, num):
|
||||
selected_item = self.list.get_selected()
|
||||
if self.list.get_count() == 0:
|
||||
for i in self.trends:
|
||||
tweet = self.compose_function(i)
|
||||
self.list.insert_item(False, *tweet)
|
||||
self.set_list_position()
|
||||
elif self.list.get_count() > 0:
|
||||
if config.main["general"]["reverse_timelines"] == False:
|
||||
for i in self.trends:
|
||||
tweet = self.compose_function(i)
|
||||
self.list.insert_item(False, *tweet)
|
||||
else:
|
||||
for i in self.trends:
|
||||
tweet = self.compose_function(i)
|
||||
self.list.insert_item(True, *tweet)
|
||||
self.list.select_item(selected_item)
|
||||
|
||||
def post_status(self, ev=None):
|
||||
text = gui.dialogs.message.tweet(_(u"Write the tweet here"), _(u"Tweet"), "", self)
|
||||
if text.ShowModal() == wx.ID_OK:
|
||||
if text.image == None:
|
||||
call_threaded(self.twitter.api_call, call_name="update_status", _sound="tweet_send.ogg", status=text.text.GetValue())
|
||||
else:
|
||||
call_threaded(self.twitter.api_call, call_name="update_status_with_media", _sound="tweet_send.ogg", status=text.text.GetValue(), media=text.file)
|
||||
if ev != None: self.list.list.SetFocus()
|
||||
|
||||
def onRetweet(self, event=None): pass
|
||||
|
||||
def onResponse(self, ev):
|
||||
trend = self.trends[self.list.get_selected()]["name"]
|
||||
text = gui.dialogs.message.tweet(_(u"Write the tweet here"), _(u"Tweet"), trend, self)
|
||||
if text.ShowModal() == wx.ID_OK:
|
||||
if text.image == None:
|
||||
call_threaded(self.twitter.api_call, call_name="update_status", _sound="tweet_send.ogg", status=text.text.GetValue())
|
||||
else:
|
||||
call_threaded(self.twitter.api_call, call_name="update_status_with_media", _sound="tweet_send.ogg", status=text.text.GetValue(), media=text.file)
|
||||
if ev != None: self.list.list.SetFocus()
|
||||
|
||||
def interact(self, ev):
|
||||
if type(ev) is str: event = ev
|
||||
else:
|
||||
if ev.GetKeyCode() == wx.WXK_F5: event = "volume_down"
|
||||
elif ev.GetKeyCode() == wx.WXK_F6: event = "volume_up"
|
||||
elif ev.GetKeyCode() == wx.WXK_DELETE and ev.ShiftDown(): event = "clear_list"
|
||||
else:
|
||||
ev.Skip()
|
||||
return
|
||||
if event == "volume_down":
|
||||
if config.main["sound"]["volume"] > 0.05:
|
||||
config.main["sound"]["volume"] = config.main["sound"]["volume"]-0.05
|
||||
sound.player.play("volume_changed.ogg", False)
|
||||
if hasattr(self.parent, "audioStream"):
|
||||
self.parent.audioStream.stream.volume = config.main["sound"]["volume"]
|
||||
elif event == "volume_up":
|
||||
if config.main["sound"]["volume"] < 0.95:
|
||||
config.main["sound"]["volume"] = config.main["sound"]["volume"]+0.05
|
||||
sound.player.play("volume_changed.ogg", False)
|
||||
if hasattr(self.parent, "audioStream"):
|
||||
self.parent.audioStream.stream.volume = config.main["sound"]["volume"]
|
||||
elif event == "clear_list" and self.list.get_count() > 0:
|
||||
dlg = wx.MessageDialog(self, _(u"Do you really want to empty this buffer? It's items will be removed from the list"), _(u"Empty buffer"), wx.ICON_QUESTION|wx.YES_NO)
|
||||
if dlg.ShowModal() == wx.ID_YES:
|
||||
self.trends = []
|
||||
self.list.clear()
|
||||
try:
|
||||
ev.Skip()
|
||||
except:
|
||||
pass
|
||||
|
||||
def set_list_position(self):
|
||||
if config.main["general"]["reverse_timelines"] == False:
|
||||
self.list.select_item(len(self.trends)-1)
|
||||
else:
|
||||
self.list.select_item(0)
|
||||
|
||||
def showMenu(self, ev):
|
||||
if self.list.get_count() == 0: return
|
||||
self.PopupMenu(menus.trendsPanelMenu(self), ev.GetPosition())
|
||||
|
||||
def showMenuByKey(self, ev):
|
||||
if self.list.get_count() == 0: return
|
||||
if ev.GetKeyCode() == wx.WXK_WINDOWS_MENU:
|
||||
self.PopupMenu(menus.trendsPanelMenu(self), self.list.list.GetPosition())
|
||||
|
@ -1 +1 @@
|
||||
import message, urlList, follow, utils, show_user, update_profile, configuration, lists, search
|
||||
import message, urlList, follow, utils, show_user, update_profile, configuration, lists, search, trending
|
@ -19,24 +19,34 @@
|
||||
import wx
|
||||
|
||||
class trendingTopicsDialog(wx.Dialog):
|
||||
def __init__(self):
|
||||
super(searchDialog, self).__init__(None, -1)
|
||||
def __init__(self, information):
|
||||
super(trendingTopicsDialog, self).__init__(None, -1)
|
||||
self.countries = {}
|
||||
self.cities = {}
|
||||
self.information = information
|
||||
self.split_information()
|
||||
panel = wx.Panel(self)
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
self.SetTitle(_(u"Search on Twitter"))
|
||||
label = wx.StaticText(panel, -1, _(u"Search"))
|
||||
self.term = wx.TextCtrl(panel, -1,)
|
||||
dc = wx.WindowDC(self.term)
|
||||
dc.SetFont(self.term.GetFont())
|
||||
self.term.SetSize(dc.GetTextExtent("0"*40))
|
||||
self.SetTitle(_(u"View trending topics"))
|
||||
label = wx.StaticText(panel, -1, _(u"Trending topics by"))
|
||||
sizer.Add(label, 0, wx.ALL, 5)
|
||||
sizer.Add(self.term, 0, wx.ALL, 5)
|
||||
self.tweets = wx.RadioButton(panel, -1, _(u"Tweets"), style=wx.RB_GROUP)
|
||||
self.users = wx.RadioButton(panel, -1, _(u"Users"))
|
||||
self.country = wx.RadioButton(panel, -1, _(u"Country"), style=wx.RB_GROUP)
|
||||
self.city = wx.RadioButton(panel, -1, _(u"City"))
|
||||
self.Bind(wx.EVT_RADIOBUTTON, self.get_places, self.country)
|
||||
self.Bind(wx.EVT_RADIOBUTTON, self.get_places, self.city)
|
||||
|
||||
radioSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
radioSizer.Add(self.tweets, 0, wx.ALL, 5)
|
||||
radioSizer.Add(self.users, 0, wx.ALL, 5)
|
||||
radioSizer.Add(label, 0, wx.ALL, 5)
|
||||
radioSizer.Add(self.country, 0, wx.ALL, 5)
|
||||
radioSizer.Add(self.city, 0, wx.ALL, 5)
|
||||
sizer.Add(radioSizer, 0, wx.ALL, 5)
|
||||
label = wx.StaticText(panel, -1, _(u"Location"))
|
||||
self.location = wx.ListBox(panel, -1, choices=[], style=wx.CB_READONLY)
|
||||
self.get_places()
|
||||
locationBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
locationBox.Add(label, 0, wx.ALL, 5)
|
||||
locationBox.Add(self.location, 0, wx.ALL, 5)
|
||||
sizer.Add(locationBox, 0, wx.ALL, 5)
|
||||
ok = wx.Button(panel, wx.ID_OK, _(u"OK"))
|
||||
ok.SetDefault()
|
||||
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"Close"))
|
||||
@ -46,3 +56,23 @@ class trendingTopicsDialog(wx.Dialog):
|
||||
sizer.Add(btnsizer, 0, wx.ALL, 5)
|
||||
panel.SetSizer(sizer)
|
||||
self.SetClientSize(sizer.CalcMin())
|
||||
|
||||
def split_information(self):
|
||||
for i in self.information:
|
||||
if i["placeType"]["name"] == "Country":
|
||||
self.countries[i["name"]] = i["woeid"]
|
||||
else:
|
||||
self.cities[i["name"]] = i["woeid"]
|
||||
|
||||
def get_places(self, event=None):
|
||||
values = []
|
||||
if self.country.GetValue() == True:
|
||||
for i in self.information:
|
||||
if i["placeType"]["name"] == "Country":
|
||||
values.append(i["name"])
|
||||
elif self.city.GetValue() == True:
|
||||
for i in self.information:
|
||||
if i["placeType"]["name"] != "Country":
|
||||
values.append(i["name"])
|
||||
self.location.Set(values)
|
||||
|
@ -226,7 +226,7 @@ class mainFrame(wx.Frame):
|
||||
try:
|
||||
updater.update_manager.check_for_update()
|
||||
except:
|
||||
pass
|
||||
wx.MessageDialog(self, _(u"An error occurred while looking for an update. It may be due to any problem either on our server or on your DNS servers. Please, try again later."), _(u"Error!"), wx.OK|wx.ICON_ERROR).ShowModal()
|
||||
self.SetMenuBar(self.makeMenus())
|
||||
self.setup_twitter(panel)
|
||||
|
||||
@ -241,7 +241,7 @@ class mainFrame(wx.Frame):
|
||||
# Gets the tabs for home, mentions, send and direct messages.
|
||||
log.debug("Creating buffers...")
|
||||
self.db.settings["buffers"] = []
|
||||
account = buffers.accountPanel(self.nb)
|
||||
account = buffers.accountPanel(self.nb, self.db.settings["user_name"])
|
||||
self.nb.AddPage(account, self.db.settings["user_name"])
|
||||
self.db.settings["buffers"].append(self.db.settings["user_name"])
|
||||
account_index = self.db.settings["buffers"].index(self.db.settings["user_name"])
|
||||
@ -1016,6 +1016,21 @@ class mainFrame(wx.Frame):
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
def get_trending_topics(self, event=None):
|
||||
info = self.twitter.twitter.get_available_trends()
|
||||
trendingDialog = dialogs.trending.trendingTopicsDialog(info)
|
||||
if trendingDialog.ShowModal() == wx.ID_OK:
|
||||
if trendingDialog.country.GetValue() == True:
|
||||
woeid = trendingDialog.countries[trendingDialog.location.GetStringSelection()]
|
||||
elif trendingDialog.city.GetValue() == True:
|
||||
woeid = trendingDialog.cities[trendingDialog.location.GetStringSelection()]
|
||||
buff = buffers.trendsPanel(self.nb, self, "%s_tt" % (woeid,), argumento=woeid, sound="tweet_timeline.ogg")
|
||||
self.nb.InsertSubPage(self.db.settings["buffers"].index(self.db.settings["user_name"]), buff, _(u"Trending topics for %s") % (trendingDialog.location.GetStringSelection(),))
|
||||
timer = RepeatingTimer(180, buff.start_streams)
|
||||
timer.start()
|
||||
num = buff.start_streams()
|
||||
buff.put_items(num)
|
||||
|
||||
### Close App
|
||||
def Destroy(self):
|
||||
self.sysTray.Destroy()
|
||||
|
Loading…
Reference in New Issue
Block a user