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())
|
tweet_searches = list(default=list())
|
||||||
lists = list(default=list())
|
lists = list(default=list())
|
||||||
favourites_timelines = list(default=list())
|
favourites_timelines = list(default=list())
|
||||||
|
trending_topic_buffers = list(default=list())
|
||||||
muted_buffers = list(default=list())
|
muted_buffers = list(default=list())
|
||||||
autoread_buffers = list(default=list())
|
autoread_buffers = list(default=list())
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ class autocompletionUsers(object):
|
|||||||
try:
|
try:
|
||||||
pattern = text.split()[-1]
|
pattern = text.split()[-1]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
output.speak(_(u"You have to start to write"))
|
output.speak(_(u"You have to start writing"))
|
||||||
return
|
return
|
||||||
if pattern.startswith("@") == True:
|
if pattern.startswith("@") == True:
|
||||||
db = storage.storage()
|
db = storage.storage()
|
||||||
@ -26,6 +26,6 @@ class autocompletionUsers(object):
|
|||||||
self.window.PopupMenu(menu, self.window.text.GetPosition())
|
self.window.PopupMenu(menu, self.window.text.GetPosition())
|
||||||
menu.Destroy()
|
menu.Destroy()
|
||||||
else:
|
else:
|
||||||
output.speak(_(u"There is not results in your users database"))
|
output.speak(_(u"There are not results in your users database"))
|
||||||
else:
|
else:
|
||||||
output.speak(_(u"Autocompletion only works for users."))
|
output.speak(_(u"Autocompletion only works for users."))
|
@ -20,4 +20,4 @@ class autocompletionSettingsDialog(wx.Dialog):
|
|||||||
self.SetClientSize(sizer.CalcMin())
|
self.SetClientSize(sizer.CalcMin())
|
||||||
|
|
||||||
def show_success_dialog():
|
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 people import *
|
||||||
from tweet_searches import *
|
from tweet_searches import *
|
||||||
from user_searches import *
|
from user_searches import *
|
||||||
|
from trends import *
|
@ -20,18 +20,20 @@ import wx
|
|||||||
from multiplatform_widgets import widgets
|
from multiplatform_widgets import widgets
|
||||||
|
|
||||||
class accountPanel(wx.Panel):
|
class accountPanel(wx.Panel):
|
||||||
def __init__(self, parent):
|
def __init__(self, parent, name_buffer):
|
||||||
super(accountPanel, self).__init__(parent=parent)
|
super(accountPanel, self).__init__(parent=parent)
|
||||||
self.type = "account"
|
self.type = "account"
|
||||||
|
self.name_buffer = name_buffer
|
||||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
self.list = widgets.list(self, _(u"Announce"))
|
self.list = widgets.list(self, _(u"Announce"))
|
||||||
sizer.Add(self.list.list, 0, wx.ALL, 5)
|
sizer.Add(self.list.list, 0, wx.ALL, 5)
|
||||||
self.SetSizer(sizer)
|
self.SetSizer(sizer)
|
||||||
|
|
||||||
class emptyPanel(accountPanel):
|
|
||||||
def __init__(self, parent):
|
|
||||||
super(emptyPanel, self).__init__(parent=parent)
|
|
||||||
self.type = "empty"
|
|
||||||
|
|
||||||
def get_more_items(self):
|
def get_more_items(self):
|
||||||
output.speak(_(u"This action is not supported for this buffer"))
|
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 wx
|
||||||
import sound
|
|
||||||
import config
|
|
||||||
import twitter
|
|
||||||
import gui.dialogs
|
import gui.dialogs
|
||||||
|
import twitter
|
||||||
|
import config
|
||||||
|
import sound
|
||||||
import logging as original_logger
|
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")
|
log = original_logger.getLogger("buffers.base")
|
||||||
|
|
||||||
class trendPanel(basePanel):
|
class trendsPanel(wx.Panel):
|
||||||
def __init__(self, parent, window, name_buffer, *args, **kwargs):
|
|
||||||
super(searchPanel, self).__init__(parent, window, name_buffer, sound)
|
|
||||||
self.type = "trend"
|
|
||||||
self.args = kwargs
|
|
||||||
|
|
||||||
def start_streams(self):
|
def compose_function(self, trend):
|
||||||
num = twitter.starting.search(self.db, self.twitter, self.name_buffer, **self.args)
|
return [trend["name"]]
|
||||||
if num > 0: sound.player.play("search_updated.ogg")
|
|
||||||
self.put_items(num)
|
def bind_events(self):
|
||||||
return num
|
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):
|
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:
|
if dlg.ShowModal() == wx.ID_YES:
|
||||||
names = config.main["other_buffers"]["tweet_searches"]
|
topics = config.main["other_buffers"]["trending_topic_buffers"]
|
||||||
user = self.name_buffer[:-7]
|
topic = self.name_buffer
|
||||||
log.info(u"Deleting %s's search term" % user)
|
log.info(u"Deleting %s's trending topics buffer" % topic)
|
||||||
if user in names:
|
if topic in topics:
|
||||||
names.remove(user)
|
topics.remove(topic)
|
||||||
self.db.settings.pop(self.name_buffer)
|
return 0
|
||||||
pos = self.db.settings["buffers"].index(self.name_buffer)
|
|
||||||
self.db.settings["buffers"].remove(self.name_buffer)
|
def start_streams(self):
|
||||||
return pos
|
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
|
import wx
|
||||||
|
|
||||||
class trendingTopicsDialog(wx.Dialog):
|
class trendingTopicsDialog(wx.Dialog):
|
||||||
def __init__(self):
|
def __init__(self, information):
|
||||||
super(searchDialog, self).__init__(None, -1)
|
super(trendingTopicsDialog, self).__init__(None, -1)
|
||||||
|
self.countries = {}
|
||||||
|
self.cities = {}
|
||||||
|
self.information = information
|
||||||
|
self.split_information()
|
||||||
panel = wx.Panel(self)
|
panel = wx.Panel(self)
|
||||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
self.SetTitle(_(u"Search on Twitter"))
|
self.SetTitle(_(u"View trending topics"))
|
||||||
label = wx.StaticText(panel, -1, _(u"Search"))
|
label = wx.StaticText(panel, -1, _(u"Trending topics by"))
|
||||||
self.term = wx.TextCtrl(panel, -1,)
|
|
||||||
dc = wx.WindowDC(self.term)
|
|
||||||
dc.SetFont(self.term.GetFont())
|
|
||||||
self.term.SetSize(dc.GetTextExtent("0"*40))
|
|
||||||
sizer.Add(label, 0, wx.ALL, 5)
|
sizer.Add(label, 0, wx.ALL, 5)
|
||||||
sizer.Add(self.term, 0, wx.ALL, 5)
|
self.country = wx.RadioButton(panel, -1, _(u"Country"), style=wx.RB_GROUP)
|
||||||
self.tweets = wx.RadioButton(panel, -1, _(u"Tweets"), style=wx.RB_GROUP)
|
self.city = wx.RadioButton(panel, -1, _(u"City"))
|
||||||
self.users = wx.RadioButton(panel, -1, _(u"Users"))
|
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 = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
radioSizer.Add(self.tweets, 0, wx.ALL, 5)
|
radioSizer.Add(label, 0, wx.ALL, 5)
|
||||||
radioSizer.Add(self.users, 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)
|
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 = wx.Button(panel, wx.ID_OK, _(u"OK"))
|
||||||
ok.SetDefault()
|
ok.SetDefault()
|
||||||
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"Close"))
|
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"Close"))
|
||||||
@ -46,3 +56,23 @@ class trendingTopicsDialog(wx.Dialog):
|
|||||||
sizer.Add(btnsizer, 0, wx.ALL, 5)
|
sizer.Add(btnsizer, 0, wx.ALL, 5)
|
||||||
panel.SetSizer(sizer)
|
panel.SetSizer(sizer)
|
||||||
self.SetClientSize(sizer.CalcMin())
|
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:
|
try:
|
||||||
updater.update_manager.check_for_update()
|
updater.update_manager.check_for_update()
|
||||||
except:
|
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.SetMenuBar(self.makeMenus())
|
||||||
self.setup_twitter(panel)
|
self.setup_twitter(panel)
|
||||||
|
|
||||||
@ -241,7 +241,7 @@ class mainFrame(wx.Frame):
|
|||||||
# Gets the tabs for home, mentions, send and direct messages.
|
# Gets the tabs for home, mentions, send and direct messages.
|
||||||
log.debug("Creating buffers...")
|
log.debug("Creating buffers...")
|
||||||
self.db.settings["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.nb.AddPage(account, self.db.settings["user_name"])
|
||||||
self.db.settings["buffers"].append(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"])
|
account_index = self.db.settings["buffers"].index(self.db.settings["user_name"])
|
||||||
@ -1016,6 +1016,21 @@ class mainFrame(wx.Frame):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
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
|
### Close App
|
||||||
def Destroy(self):
|
def Destroy(self):
|
||||||
self.sysTray.Destroy()
|
self.sysTray.Destroy()
|
||||||
|
Loading…
Reference in New Issue
Block a user