mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Geo support has been implemented
This commit is contained in:
parent
3b1d8eb48a
commit
1fbee07de2
@ -55,3 +55,6 @@ search = string(default="control+win+-")
|
||||
edit_keystrokes = string(default="control+win+k")
|
||||
view_user_lists = string(default="control+win+l")
|
||||
get_more_items = string(default="alt+win+pageup")
|
||||
reverse_geocode = string(default="control+win+g")
|
||||
view_reverse_geocode = string(default="control+win+shift+g")
|
||||
get_trending_topics = string(default="control+win+t")
|
@ -276,6 +276,8 @@ class baseBufferController(bufferController):
|
||||
self.buffer.list.list.SetStringItem(self.buffer.list.get_selected(), 2, ts)
|
||||
if utils.is_audio(tweet):
|
||||
self.session.sound.play("audio.ogg")
|
||||
if utils.is_geocoded(tweet):
|
||||
self.session.sound.play("geo.ogg")
|
||||
|
||||
def audio(self):
|
||||
tweet = self.get_tweet()
|
||||
|
@ -111,6 +111,7 @@ class Controller(object):
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.add_to_favourites, self.view.fav)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.remove_from_favourites, self.view.unfav)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.view_item, self.view.view)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.reverse_geocode, menuitem=self.view.view_coordinates)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.delete, self.view.delete)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.follow, menuitem=self.view.follow)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.send_dm, self.view.dm)
|
||||
@ -501,6 +502,45 @@ class Controller(object):
|
||||
timer.start()
|
||||
buffer.session.settings["other_buffers"]["trending_topic_buffers"].append(woeid)
|
||||
|
||||
def reverse_geocode(self, event=None):
|
||||
try:
|
||||
tweet = self.get_current_buffer().get_right_tweet()
|
||||
if tweet["coordinates"] != None:
|
||||
x = tweet["coordinates"]["coordinates"][0]
|
||||
y = tweet["coordinates"]["coordinates"][1]
|
||||
address = geocoder.reverse_geocode(y, x)
|
||||
if event == None: output.speak(address[0].__str__().decode("utf-8"))
|
||||
else: self.view.show_address(address[0].__str__().decode("utf-8"))
|
||||
else:
|
||||
output.speak(_(u"There are no coordinates in this tweet"))
|
||||
except GeocoderError:
|
||||
output.speak(_(u"There are no results for the coordinates in this tweet"))
|
||||
except ValueError:
|
||||
output.speak(_(u"Error decoding coordinates. Try again later."))
|
||||
except KeyError:
|
||||
pass
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def view_reverse_geocode(self, event=None):
|
||||
try:
|
||||
tweet = self.get_current_buffer().get_right_tweet()
|
||||
if tweet["coordinates"] != None:
|
||||
x = tweet["coordinates"]["coordinates"][0]
|
||||
y = tweet["coordinates"]["coordinates"][1]
|
||||
address = geocoder.reverse_geocode(y, x)
|
||||
dlg = messages.viewTweet(address[0].__str__(), False)
|
||||
else:
|
||||
output.speak(_(u"There are no coordinates in this tweet"))
|
||||
except GeocoderError:
|
||||
output.speak(_(u"There are no results for the coordinates in this tweet"))
|
||||
except ValueError:
|
||||
output.speak(_(u"Error decoding coordinates. Try again later."))
|
||||
except KeyError:
|
||||
pass
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def skip_buffer(self, forward=True):
|
||||
buff = self.get_current_buffer()
|
||||
if buff.invisible == False:
|
||||
|
@ -46,6 +46,10 @@ def is_audio(tweet):
|
||||
return True
|
||||
return False
|
||||
|
||||
def is_geocoded(tweet):
|
||||
if tweet.has_key("coordinates") and tweet["coordinates"] != None:
|
||||
return True
|
||||
|
||||
def get_all_mentioned(tweet, conf):
|
||||
""" Gets all users that has been mentioned."""
|
||||
string = []
|
||||
|
@ -32,6 +32,7 @@ class mainFrame(wx.Frame):
|
||||
self.fav = tweet.Append(wx.NewId(), _(u"Add to &favourites"))
|
||||
self.unfav = tweet.Append(wx.NewId(), _(u"Remove from favo&urites"))
|
||||
self.view = tweet.Append(wx.NewId(), _(u"&Show tweet"))
|
||||
self.view_coordinates = tweet.Append(wx.NewId(), _(u"View &address"))
|
||||
self.delete = tweet.Append(wx.NewId(), _(u"&Delete"))
|
||||
|
||||
# User menu
|
||||
@ -167,3 +168,5 @@ class mainFrame(wx.Frame):
|
||||
def show(self):
|
||||
self.Show()
|
||||
|
||||
def show_address(self, address):
|
||||
wx.MessageDialog(self, address, _(u"Address"), wx.OK).ShowModal()
|
Loading…
Reference in New Issue
Block a user