Reverse geocode is now in TWBlue. Ctrl+win+g and CTRL+Shift+Win+G and in the tweet menu on the menu bar

This commit is contained in:
2014-12-01 17:19:03 -06:00
parent fee7254d55
commit 79124810b0
6 changed files with 47 additions and 0 deletions

View File

@@ -88,3 +88,5 @@ 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")

View File

@@ -158,6 +158,8 @@ class basePanel(wx.Panel):
self.list.list.SetString(self.list.get_selected(), " ".join(self.compose_function(self.db.settings[self.name_buffer][self.list.get_selected()], self.db)))
if twitter.utils.is_audio(tweet):
sound.player.play("audio.ogg", False)
if twitter.utils.is_geocoded(tweet):
sound.player.play("geo.mp3", False)
def start_streams(self):
if self.name_buffer == "sent":

View File

@@ -34,6 +34,8 @@ import urllib2
import sysTrayIcon
import switchModule
import languageHandler
import pygeocoder
from pygeolib import GeocoderError
from sessionmanager import manager
from mysc import event
from mysc.thread_utils import call_threaded
@@ -47,6 +49,7 @@ from extra import SoundsTutorial
from keystrokeEditor import gui as keystrokeEditorGUI
log = original_logger.getLogger("gui.main")
geocoder = pygeocoder.Geocoder()
class mainFrame(wx.Frame):
""" Main class of the Frame. This is the Main Window."""
@@ -90,6 +93,8 @@ class mainFrame(wx.Frame):
self.Bind(wx.EVT_MENU, self.unfav, unfav)
view = tweet.Append(wx.NewId(), _(u"&Show tweet"))
self.Bind(wx.EVT_MENU, self.view, view)
view_coordinates = tweet.Append(wx.NewId(), _(u"View &address"))
self.Bind(wx.EVT_MENU, self.reverse_geocode, view_coordinates)
delete = tweet.Append(wx.NewId(), _(u"&Delete"))
self.Bind(wx.EVT_MENU, self.delete, delete)
@@ -976,6 +981,39 @@ class mainFrame(wx.Frame):
def switch_account(self, ev):
switchModule.switcher(self)
def reverse_geocode(self, event=None):
try:
if self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["coordinates"] != None:
x = self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["coordinates"]["coordinates"][0]
y = self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["coordinates"]["coordinates"][1]
address = geocoder.reverse_geocode(y, x)
if event == None: output.speak(address[0].__str__().decode("utf-8"))
else: wx.MessageDialog(self, address[0].__str__().decode("utf-8"), _(u"Address"), wx.OK).ShowModal()
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
def view_reverse_geocode(self, event=None):
try:
if self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["coordinates"] != None:
x = self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["coordinates"]["coordinates"][0]
y = self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["coordinates"]["coordinates"][1]
address = geocoder.reverse_geocode(y, x)
dialogs.message.viewNonTweet(address[0].__str__().decode("utf-8")).ShowModal()
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
### Close App
def Destroy(self):
self.sysTray.Destroy()

BIN
src/sounds/default/geo.mp3 Normal file

Binary file not shown.

View File

@@ -58,6 +58,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, config):
""" Gets all users that has been mentioned."""
if tweet.has_key("retweeted_status"): tweet = tweet["retweeted_status"]