mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-23 11:48:07 -06:00
Merge branch 'master' of https://github.com/manuelcortez/TWBlue
This commit is contained in:
commit
2b3e1099f6
@ -297,14 +297,21 @@ class basePanel(wx.Panel):
|
|||||||
ev.Skip()
|
ev.Skip()
|
||||||
return
|
return
|
||||||
if event == "audio" and len(urls) > 0:
|
if event == "audio" and len(urls) > 0:
|
||||||
|
if len(urls) == 1:
|
||||||
self.streamer(urls[0])
|
self.streamer(urls[0])
|
||||||
|
elif len(urls) > 1:
|
||||||
|
urlList = gui.dialogs.urlList.urlList(urls)
|
||||||
|
if urlList.ShowModal() == wx.ID_OK:
|
||||||
|
self.streamer(urls[urlList.lista.GetSelection()])
|
||||||
elif event == "url":
|
elif event == "url":
|
||||||
if len(urls) == 0: return
|
if len(urls) == 0: return
|
||||||
elif len(urls) == 1:
|
elif len(urls) == 1:
|
||||||
output.speak(_(u"Opening URL..."), True)
|
output.speak(_(u"Opening URL..."), True)
|
||||||
webbrowser.open(urls[0])
|
webbrowser.open(urls[0])
|
||||||
elif len(urls) > 1:
|
elif len(urls) > 1:
|
||||||
gui.dialogs.urlList.urlList(urls).ShowModal()
|
urlList = gui.dialogs.urlList.urlList(urls)
|
||||||
|
if urlList.ShowModal() == wx.ID_OK:
|
||||||
|
webbrowser.open_new_tab(urls[urlList.lista.GetSelection()])
|
||||||
elif event == "volume_down":
|
elif event == "volume_down":
|
||||||
if config.main["sound"]["volume"] > 0.05:
|
if config.main["sound"]["volume"] > 0.05:
|
||||||
config.main["sound"]["volume"] = config.main["sound"]["volume"]-0.05
|
config.main["sound"]["volume"] = config.main["sound"]["volume"]-0.05
|
||||||
|
@ -30,6 +30,7 @@ class dmPanel(basePanel):
|
|||||||
super(dmPanel, self).__init__(parent, window, name_buffer, function, argumento=argumento, sound=sound)
|
super(dmPanel, self).__init__(parent, window, name_buffer, function, argumento=argumento, sound=sound)
|
||||||
self.retweetBtn.Disable()
|
self.retweetBtn.Disable()
|
||||||
self.responseBtn.Disable()
|
self.responseBtn.Disable()
|
||||||
|
self.type = "direct_message"
|
||||||
|
|
||||||
def destroy_status(self, ev):
|
def destroy_status(self, ev):
|
||||||
index = self.list.get_selected()
|
index = self.list.get_selected()
|
||||||
|
@ -140,3 +140,9 @@ class peoplePanel(basePanel):
|
|||||||
def remove_buffer(self):
|
def remove_buffer(self):
|
||||||
pos = None
|
pos = None
|
||||||
return pos
|
return pos
|
||||||
|
|
||||||
|
def get_message(self, dialog=False):
|
||||||
|
if dialog == False: return " ".join(self.compose_function(self.db.settings[self.name_buffer][self.list.get_selected()], self.db))
|
||||||
|
else:
|
||||||
|
list = self.compose_function(self.db.settings[self.name_buffer][self.list.get_selected()], self.db)
|
||||||
|
return " ".join(list)
|
||||||
|
@ -40,7 +40,7 @@ class searchUsersPanel(peoplePanel):
|
|||||||
self.create_list()
|
self.create_list()
|
||||||
self.args = args
|
self.args = args
|
||||||
self.kwargs = kwargs
|
self.kwargs = kwargs
|
||||||
self.type = "timeline"
|
self.type = "user_search"
|
||||||
|
|
||||||
def start_streams(self):
|
def start_streams(self):
|
||||||
num = twitter.starting.search_users(self.db, self.twitter, self.name_buffer, **self.kwargs)
|
num = twitter.starting.search_users(self.db, self.twitter, self.name_buffer, **self.kwargs)
|
||||||
|
@ -342,10 +342,10 @@ class reply(tweet):
|
|||||||
class viewTweet(wx.Dialog):
|
class viewTweet(wx.Dialog):
|
||||||
def __init__(self, tweet):
|
def __init__(self, tweet):
|
||||||
super(viewTweet, self).__init__(None, size=(850,850))
|
super(viewTweet, self).__init__(None, size=(850,850))
|
||||||
self.SetTitle(_(u"Tweet - %i characters ") % (len(tweet)))
|
self.SetTitle(_(u"Tweet - %i characters ") % (len(tweet["text"])))
|
||||||
panel = wx.Panel(self)
|
panel = wx.Panel(self)
|
||||||
label = wx.StaticText(panel, -1, _(u"Tweet"))
|
label = wx.StaticText(panel, -1, _(u"Tweet"))
|
||||||
self.text = wx.TextCtrl(panel, -1, tweet, style=wx.TE_READONLY|wx.TE_MULTILINE, size=(250, 180))
|
self.text = wx.TextCtrl(panel, -1, tweet["text"], style=wx.TE_READONLY|wx.TE_MULTILINE, size=(250, 180))
|
||||||
dc = wx.WindowDC(self.text)
|
dc = wx.WindowDC(self.text)
|
||||||
dc.SetFont(self.text.GetFont())
|
dc.SetFont(self.text.GetFont())
|
||||||
(x, y, z) = dc.GetMultiLineTextExtent("0"*140)
|
(x, y, z) = dc.GetMultiLineTextExtent("0"*140)
|
||||||
@ -356,6 +356,20 @@ class viewTweet(wx.Dialog):
|
|||||||
textBox.Add(self.text, 1, wx.EXPAND, 5)
|
textBox.Add(self.text, 1, wx.EXPAND, 5)
|
||||||
mainBox = wx.BoxSizer(wx.VERTICAL)
|
mainBox = wx.BoxSizer(wx.VERTICAL)
|
||||||
mainBox.Add(textBox, 0, wx.ALL, 5)
|
mainBox.Add(textBox, 0, wx.ALL, 5)
|
||||||
|
rtCountLabel = wx.StaticText(panel, -1, _(u"Retweets: "))
|
||||||
|
rtCount = wx.TextCtrl(panel, -1, str(tweet["retweet_count"]), size=wx.DefaultSize, style=wx.TE_READONLY|wx.TE_MULTILINE)
|
||||||
|
rtBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
rtBox.Add(rtCountLabel, 0, wx.ALL, 5)
|
||||||
|
rtBox.Add(rtCount, 0, wx.ALL, 5)
|
||||||
|
favsCountLabel = wx.StaticText(panel, -1, _(u"Favourites: "))
|
||||||
|
favsCount = wx.TextCtrl(panel, -1, str(tweet["favorite_count"]), size=wx.DefaultSize, style=wx.TE_READONLY|wx.TE_MULTILINE)
|
||||||
|
favsBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
favsBox.Add(favsCountLabel, 0, wx.ALL, 5)
|
||||||
|
favsBox.Add(favsCount, 0, wx.ALL, 5)
|
||||||
|
infoBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
infoBox.Add(rtBox, 0, wx.ALL, 5)
|
||||||
|
infoBox.Add(favsBox, 0, wx.ALL, 5)
|
||||||
|
mainBox.Add(infoBox, 0, wx.ALL, 5)
|
||||||
if platform.system() != "Darwin":
|
if platform.system() != "Darwin":
|
||||||
spellcheck = wx.Button(panel, -1, _("Spelling correction"), size=wx.DefaultSize)
|
spellcheck = wx.Button(panel, -1, _("Spelling correction"), size=wx.DefaultSize)
|
||||||
spellcheck.Bind(wx.EVT_BUTTON, self.onCheck)
|
spellcheck.Bind(wx.EVT_BUTTON, self.onCheck)
|
||||||
@ -427,3 +441,87 @@ class viewTweet(wx.Dialog):
|
|||||||
urlList.unshorten(urls, self).ShowModal()
|
urlList.unshorten(urls, self).ShowModal()
|
||||||
self.text.SetFocus()
|
self.text.SetFocus()
|
||||||
|
|
||||||
|
class viewNonTweet(wx.Dialog):
|
||||||
|
def __init__(self, tweet):
|
||||||
|
super(viewNonTweet, self).__init__(None, size=(850,850))
|
||||||
|
self.SetTitle(_(u"View"))
|
||||||
|
panel = wx.Panel(self)
|
||||||
|
label = wx.StaticText(panel, -1, _(u"Item"))
|
||||||
|
self.text = wx.TextCtrl(parent=panel, id=-1, value=tweet, style=wx.TE_READONLY|wx.TE_MULTILINE, size=(250, 180))
|
||||||
|
dc = wx.WindowDC(self.text)
|
||||||
|
dc.SetFont(self.text.GetFont())
|
||||||
|
(x, y, z) = dc.GetMultiLineTextExtent("0"*140)
|
||||||
|
self.text.SetSize((x, y))
|
||||||
|
self.text.SetFocus()
|
||||||
|
textBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
textBox.Add(label, 0, wx.ALL, 5)
|
||||||
|
textBox.Add(self.text, 1, wx.EXPAND, 5)
|
||||||
|
mainBox = wx.BoxSizer(wx.VERTICAL)
|
||||||
|
mainBox.Add(textBox, 0, wx.ALL, 5)
|
||||||
|
spellcheck = wx.Button(panel, -1, _("Spelling correction"), size=wx.DefaultSize)
|
||||||
|
spellcheck.Bind(wx.EVT_BUTTON, self.onCheck)
|
||||||
|
self.unshortenButton = wx.Button(panel, -1, _(u"Expand URL"), size=wx.DefaultSize)
|
||||||
|
self.unshortenButton.Bind(wx.EVT_BUTTON, self.onUnshorten)
|
||||||
|
self.unshortenButton.Disable()
|
||||||
|
translateButton = wx.Button(panel, -1, _(u"Translate message"), size=wx.DefaultSize)
|
||||||
|
translateButton.Bind(wx.EVT_BUTTON, self.onTranslate)
|
||||||
|
cancelButton = wx.Button(panel, wx.ID_CANCEL, _(u"Close"), size=wx.DefaultSize)
|
||||||
|
cancelButton.SetDefault()
|
||||||
|
buttonsBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
buttonsBox.Add(spellcheck, 0, wx.ALL, 5)
|
||||||
|
buttonsBox.Add(self.unshortenButton, 0, wx.ALL, 5)
|
||||||
|
buttonsBox.Add(translateButton, 0, wx.ALL, 5)
|
||||||
|
buttonsBox.Add(cancelButton, 0, wx.ALL, 5)
|
||||||
|
mainBox.Add(buttonsBox, 0, wx.ALL, 5)
|
||||||
|
selectId = wx.NewId()
|
||||||
|
self.Bind(wx.EVT_MENU, self.onSelect, id=selectId)
|
||||||
|
self.accel_tbl = wx.AcceleratorTable([
|
||||||
|
(wx.ACCEL_CTRL, ord('A'), selectId),
|
||||||
|
])
|
||||||
|
self.SetAcceleratorTable(self.accel_tbl)
|
||||||
|
panel.SetSizer(mainBox)
|
||||||
|
self.SetClientSize(mainBox.CalcMin())
|
||||||
|
self.check_urls()
|
||||||
|
|
||||||
|
def check_urls(self):
|
||||||
|
if len(twitter.utils.find_urls_in_text(self.text.GetValue())) > 0:
|
||||||
|
self.unshortenButton.Enable()
|
||||||
|
|
||||||
|
def onCheck(self, ev):
|
||||||
|
text = self.text.GetValue()
|
||||||
|
dlg = spellCheckerGUI.spellCheckerDialog(text, "")
|
||||||
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
|
self.text.ChangeValue(dlg.checker.get_text())
|
||||||
|
dlg.Destroy()
|
||||||
|
|
||||||
|
def onTranslate(self, ev):
|
||||||
|
dlg = translator.gui.translateDialog()
|
||||||
|
selection = dlg.ShowModal()
|
||||||
|
if selection != wx.ID_CANCEL:
|
||||||
|
text_to_translate = self.text.GetValue().encode("utf-8")
|
||||||
|
source = [x[0] for x in translator.available_languages()][dlg.source_lang.GetSelection()]
|
||||||
|
dest = [x[0] for x in translator.available_languages()][dlg.dest_lang.GetSelection()]
|
||||||
|
t = translator.translator.Translator()
|
||||||
|
t.from_lang = source
|
||||||
|
t.to_lang = dest
|
||||||
|
msg = t.translate(text_to_translate)
|
||||||
|
self.text.ChangeValue(msg)
|
||||||
|
output.speak(_(u"Translated"))
|
||||||
|
self.text.SetFocus()
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
dlg.Destroy()
|
||||||
|
|
||||||
|
def onSelect(self, ev):
|
||||||
|
self.text.SelectAll()
|
||||||
|
|
||||||
|
def onUnshorten(self, ev):
|
||||||
|
urls = twitter.utils.find_urls_in_text(self.text.GetValue())
|
||||||
|
if len(urls) == 0:
|
||||||
|
output.speak(_(u"There's no URL to be expanded"))
|
||||||
|
elif len(urls) == 1:
|
||||||
|
self.text.SetValue(self.text.GetValue().replace(urls[0], url_shortener.unshorten(urls[0])))
|
||||||
|
output.speak(_(u"URL expanded"))
|
||||||
|
elif len(urls) > 1:
|
||||||
|
urlList.unshorten(urls, self).ShowModal()
|
||||||
|
self.text.SetFocus()
|
||||||
|
@ -46,8 +46,7 @@ class urlList(wx.Dialog):
|
|||||||
self.SetClientSize(sizer.CalcMin())
|
self.SetClientSize(sizer.CalcMin())
|
||||||
|
|
||||||
def onGo(self, ev):
|
def onGo(self, ev):
|
||||||
webbrowser.open(self.lista.GetStringSelection())
|
self.EndModal(wx.ID_OK)
|
||||||
self.Destroy()
|
|
||||||
|
|
||||||
def populate_list(self):
|
def populate_list(self):
|
||||||
for i in self.urls:
|
for i in self.urls:
|
||||||
|
@ -32,6 +32,7 @@ import output
|
|||||||
import platform
|
import platform
|
||||||
import urllib2
|
import urllib2
|
||||||
import sysTrayIcon
|
import sysTrayIcon
|
||||||
|
import switchModule
|
||||||
import languageHandler
|
import languageHandler
|
||||||
from sessionmanager import manager
|
from sessionmanager import manager
|
||||||
from mysc import event
|
from mysc import event
|
||||||
@ -56,6 +57,8 @@ class mainFrame(wx.Frame):
|
|||||||
|
|
||||||
# Application menu
|
# Application menu
|
||||||
app = wx.Menu()
|
app = wx.Menu()
|
||||||
|
switch_account = app.Append(wx.NewId(), _(u"S&witch account"))
|
||||||
|
self.Bind(wx.EVT_MENU, self.switch_account)
|
||||||
updateProfile = app.Append(wx.NewId(), _(u"&Update profile"))
|
updateProfile = app.Append(wx.NewId(), _(u"&Update profile"))
|
||||||
self.Bind(wx.EVT_MENU, self.update_profile, updateProfile)
|
self.Bind(wx.EVT_MENU, self.update_profile, updateProfile)
|
||||||
show_hide = app.Append(wx.NewId(), _(u"&Hide window"))
|
show_hide = app.Append(wx.NewId(), _(u"&Hide window"))
|
||||||
@ -501,7 +504,7 @@ class mainFrame(wx.Frame):
|
|||||||
dlg = dialogs.lists.removeUserListDialog(self)
|
dlg = dialogs.lists.removeUserListDialog(self)
|
||||||
if dlg.ShowModal() == wx.ID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
try:
|
try:
|
||||||
list = self.twitter.twitter.delete_list_member(list_id=self.db.settings["lists"][dlg.get_selected()]["id"], screen_name=user)
|
list = self.twitter.twitter.delete_list_member(list_id=self.db.settings["lists"][dlg.lista.get_selected()]["id"], screen_name=user)
|
||||||
older_list = twitter.utils.find_item(self.db.settings["lists"][dlg.get_selected()]["id"], self.db.settings["lists"])
|
older_list = twitter.utils.find_item(self.db.settings["lists"][dlg.get_selected()]["id"], self.db.settings["lists"])
|
||||||
if list["mode"] == "private":
|
if list["mode"] == "private":
|
||||||
self.db.settings["lists"].pop(older_list)
|
self.db.settings["lists"].pop(older_list)
|
||||||
@ -662,8 +665,18 @@ class mainFrame(wx.Frame):
|
|||||||
self.nb.GetCurrentPage().onRetweet(ev)
|
self.nb.GetCurrentPage().onRetweet(ev)
|
||||||
|
|
||||||
def view(self, ev=None):
|
def view(self, ev=None):
|
||||||
tweet = self.nb.GetCurrentPage().get_message(dialog=True)
|
tp = self.nb.GetCurrentPage().type
|
||||||
|
if tp == "buffer" or tp == "timeline" or tp == "favourites_timeline" or tp == "list" or tp == "search":
|
||||||
|
try:
|
||||||
|
id = self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["id"]
|
||||||
|
tweet = self.twitter.twitter.show_status(id=id)
|
||||||
dialogs.message.viewTweet(tweet).ShowModal()
|
dialogs.message.viewTweet(tweet).ShowModal()
|
||||||
|
except TwythonError as e:
|
||||||
|
non_tweet = self.nb.GetCurrentPage().get_message(dialog=True)
|
||||||
|
dialogs.message.viewNonTweet(non_tweet).ShowModal()
|
||||||
|
else:
|
||||||
|
non_tweet = self.nb.GetCurrentPage().get_message(dialog=True)
|
||||||
|
dialogs.message.viewNonTweet(non_tweet).ShowModal()
|
||||||
|
|
||||||
def fav(self, ev=None):
|
def fav(self, ev=None):
|
||||||
if self.nb.GetCurrentPage().name_buffer != "direct_messages" and self.nb.GetCurrentPage().name_buffer != "followers" and self.nb.GetCurrentPage().name_buffer != "friends":
|
if self.nb.GetCurrentPage().name_buffer != "direct_messages" and self.nb.GetCurrentPage().name_buffer != "followers" and self.nb.GetCurrentPage().name_buffer != "friends":
|
||||||
@ -960,6 +973,9 @@ class mainFrame(wx.Frame):
|
|||||||
return page
|
return page
|
||||||
return page
|
return page
|
||||||
|
|
||||||
|
def switch_account(self, ev):
|
||||||
|
switchModule.switcher(self)
|
||||||
|
|
||||||
### Close App
|
### Close App
|
||||||
def Destroy(self):
|
def Destroy(self):
|
||||||
self.sysTray.Destroy()
|
self.sysTray.Destroy()
|
||||||
|
23
src/gui/switchModule.py
Normal file
23
src/gui/switchModule.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import wx
|
||||||
|
import gui
|
||||||
|
import config
|
||||||
|
from sessionmanager import gui as sessionManagerUI
|
||||||
|
|
||||||
|
class switcher(object):
|
||||||
|
def __init__(self, window):
|
||||||
|
self.hold_window = window
|
||||||
|
self.hold_window.Hide()
|
||||||
|
sessionManagerWindow = sessionManagerUI.sessionManagerWindow()
|
||||||
|
if sessionManagerWindow.ShowModal() == wx.ID_OK:
|
||||||
|
self.hold_window.Destroy()
|
||||||
|
self.window = gui.main.mainFrame()
|
||||||
|
self.window.Show()
|
||||||
|
self.window.showing = True
|
||||||
|
if config.main != None and config.main["general"]["hide_gui"] == True:
|
||||||
|
self.window.show_hide()
|
||||||
|
self.window.Hide()
|
||||||
|
wx.GetApp().SetTopWindow(self.window)
|
||||||
|
else:
|
||||||
|
self.window.Show()
|
||||||
|
|
@ -55,7 +55,7 @@ class SysTrayIcon(wx.TaskBarIcon):
|
|||||||
if (self.frame.showing):
|
if (self.frame.showing):
|
||||||
self.frame.SetFocus()
|
self.frame.SetFocus()
|
||||||
else:
|
else:
|
||||||
self.frame.onShow_hide()
|
self.frame.show_hide()
|
||||||
|
|
||||||
def Destroy(self):
|
def Destroy(self):
|
||||||
self.menu.Destroy()
|
self.menu.Destroy()
|
||||||
|
55
src/main.py
55
src/main.py
@ -20,56 +20,53 @@ A twitter accessible, easy of use and cross platform application."""
|
|||||||
#
|
#
|
||||||
############################################################
|
############################################################
|
||||||
import wx
|
import wx
|
||||||
|
import os
|
||||||
ssmg = None
|
ssmg = None
|
||||||
import gui
|
import gui
|
||||||
import paths
|
import paths
|
||||||
import config
|
import config
|
||||||
import commandline
|
import commandline
|
||||||
import platform
|
import platform
|
||||||
if platform.system() == "Windows":
|
from logger import logger as logging
|
||||||
from logger import logger as logging
|
|
||||||
if platform.system() == "Darwin":
|
|
||||||
import osx_prepare
|
|
||||||
osx_prepare.setup()
|
|
||||||
from sessionmanager import manager
|
from sessionmanager import manager
|
||||||
from sessionmanager import gui as smGUI
|
from sessionmanager import gui as smGUI
|
||||||
manager.setup()
|
manager.setup()
|
||||||
import sys
|
import sys
|
||||||
|
import config
|
||||||
|
import output
|
||||||
|
import sound
|
||||||
|
import languageHandler
|
||||||
|
|
||||||
if hasattr(sys, 'frozen'):
|
if hasattr(sys, 'frozen'):
|
||||||
sys.stderr = open(paths.logs_path("stderr.log"), 'w')
|
sys.stderr = open(paths.logs_path("stderr.log"), 'w')
|
||||||
sys.stdout = open(paths.logs_path("stdout.log"), 'w')
|
sys.stdout = open(paths.logs_path("stdout.log"), 'w')
|
||||||
|
|
||||||
class app(wx.App):
|
app = wx.App()
|
||||||
def __init__(self, *args, **kwargs):
|
configured = False
|
||||||
super(app, self).__init__(*args, **kwargs)
|
configs = []
|
||||||
if platform.system() != "Darwin":
|
for i in os.listdir(paths.config_path()):
|
||||||
self.start()
|
if os.path.isdir(paths.config_path(i)): configs.append(i)
|
||||||
else:
|
if len(configs) == 1:
|
||||||
self.mac()
|
manager.manager.set_current_session(configs[0])
|
||||||
|
config.MAINFILE = "%s/session.conf" % (manager.manager.get_current_session())
|
||||||
def mac(self):
|
config.setup()
|
||||||
self.hold_frame = wx.Frame(title="None", parent=None)
|
lang=config.main['general']['language']
|
||||||
self.hold_frame.Show()
|
languageHandler.setLanguage(lang)
|
||||||
wx.CallLater(10, self.start)
|
sound.setup()
|
||||||
|
output.setup()
|
||||||
def start(self):
|
configured = True
|
||||||
|
else:
|
||||||
ssmg = smGUI.sessionManagerWindow()
|
ssmg = smGUI.sessionManagerWindow()
|
||||||
if ssmg.ShowModal() == wx.ID_OK:
|
if configured == True or ssmg.ShowModal() == wx.ID_OK:
|
||||||
frame = gui.main.mainFrame()
|
frame = gui.main.mainFrame()
|
||||||
frame.Show()
|
frame.Show()
|
||||||
frame.showing = True
|
frame.showing = True
|
||||||
if config.main != None and config.main["general"]["hide_gui"] == True and platform.system() == "Windows":
|
if config.main != None and config.main["general"]["hide_gui"] == True and platform.system() == "Windows":
|
||||||
frame.show_hide()
|
frame.show_hide()
|
||||||
frame.Hide()
|
frame.Hide()
|
||||||
self.SetTopWindow(frame)
|
app.SetTopWindow(frame)
|
||||||
if hasattr(self, "frame"): self.hold_frame.Hide()
|
else:
|
||||||
# If the user press on cancel.
|
app.Exit()
|
||||||
else:
|
|
||||||
self.Exit()
|
|
||||||
|
|
||||||
ap = app()
|
|
||||||
### I should uncomment this
|
### I should uncomment this
|
||||||
#if platform.system() != "Windows":
|
#if platform.system() != "Windows":
|
||||||
# local = wx.Locale(wx.LANGUAGE_DEFAULT)
|
# local = wx.Locale(wx.LANGUAGE_DEFAULT)
|
||||||
@ -77,5 +74,5 @@ ap = app()
|
|||||||
# local.AddCatalog("twblue")
|
# local.AddCatalog("twblue")
|
||||||
#ap = app(redirect=True, useBestVisual=True, filename=paths.logs_path('tracebacks.log'))
|
#ap = app(redirect=True, useBestVisual=True, filename=paths.logs_path('tracebacks.log'))
|
||||||
#wx.CallLater(10, start)
|
#wx.CallLater(10, start)
|
||||||
ap.MainLoop()
|
app.MainLoop()
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import shutil
|
||||||
import time
|
import time
|
||||||
import wx
|
import wx
|
||||||
import manager
|
import manager
|
||||||
@ -23,28 +24,26 @@ class sessionManagerWindow(wx.Dialog):
|
|||||||
label = wx.StaticText(panel, -1, _(u"Select a twitter account to start TW Blue"), size=wx.DefaultSize)
|
label = wx.StaticText(panel, -1, _(u"Select a twitter account to start TW Blue"), size=wx.DefaultSize)
|
||||||
listSizer = wx.BoxSizer(wx.HORIZONTAL)
|
listSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
self.list = widgets.list(panel, _(u"Account"), style=wx.LC_SINGLE_SEL|wx.LC_REPORT)
|
self.list = widgets.list(panel, _(u"Account"), style=wx.LC_SINGLE_SEL|wx.LC_REPORT)
|
||||||
self.fill_list()
|
|
||||||
listSizer.Add(label, 0, wx.ALL, 5)
|
listSizer.Add(label, 0, wx.ALL, 5)
|
||||||
listSizer.Add(self.list.list, 0, wx.ALL, 5)
|
listSizer.Add(self.list.list, 0, wx.ALL, 5)
|
||||||
sizer.Add(listSizer, 0, wx.ALL, 5)
|
sizer.Add(listSizer, 0, wx.ALL, 5)
|
||||||
new = wx.Button(panel, -1, _(u"New account"), size=wx.DefaultSize)
|
new = wx.Button(panel, -1, _(u"New account"), size=wx.DefaultSize)
|
||||||
new.Bind(wx.EVT_BUTTON, self.new_account)
|
new.Bind(wx.EVT_BUTTON, self.new_account)
|
||||||
|
self.removeSession = wx.Button(panel, -1, _(u"Remove session"))
|
||||||
|
self.removeSession.Disable()
|
||||||
|
self.removeSession.Bind(wx.EVT_BUTTON, self.remove)
|
||||||
ok = wx.Button(panel, wx.ID_OK, size=wx.DefaultSize)
|
ok = wx.Button(panel, wx.ID_OK, size=wx.DefaultSize)
|
||||||
ok.SetDefault()
|
ok.SetDefault()
|
||||||
ok.Bind(wx.EVT_BUTTON, self.ok)
|
ok.Bind(wx.EVT_BUTTON, self.ok)
|
||||||
cancel = wx.Button(panel, wx.ID_CANCEL, size=wx.DefaultSize)
|
cancel = wx.Button(panel, wx.ID_CANCEL, size=wx.DefaultSize)
|
||||||
buttons = wx.BoxSizer(wx.HORIZONTAL)
|
buttons = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
buttons.Add(new, 0, wx.ALL, 5)
|
buttons.Add(new, 0, wx.ALL, 5)
|
||||||
|
buttons.Add(self.removeSession, 0, wx.ALL, 5)
|
||||||
buttons.Add(ok, 0, wx.ALL, 5)
|
buttons.Add(ok, 0, wx.ALL, 5)
|
||||||
buttons.Add(cancel, 0, wx.ALL, 5)
|
buttons.Add(cancel, 0, wx.ALL, 5)
|
||||||
sizer.Add(buttons, 0, wx.ALL, 5)
|
sizer.Add(buttons, 0, wx.ALL, 5)
|
||||||
panel.SetSizer(sizer)
|
panel.SetSizer(sizer)
|
||||||
# sizer.Layout()
|
self.fill_list()
|
||||||
# self.Fit()
|
|
||||||
# self.SetSize(panel.GetBestSize())
|
|
||||||
# panelSizer.Add(panel)
|
|
||||||
# self.SetSizerAndFit(sizer)
|
|
||||||
# sizer.Layout()
|
|
||||||
min = sizer.CalcMin()
|
min = sizer.CalcMin()
|
||||||
self.SetClientSize(min)
|
self.SetClientSize(min)
|
||||||
|
|
||||||
@ -55,12 +54,16 @@ class sessionManagerWindow(wx.Dialog):
|
|||||||
strconfig = "%s/session.conf" % (paths.config_path(i))
|
strconfig = "%s/session.conf" % (paths.config_path(i))
|
||||||
config_test = Configuration(strconfig)
|
config_test = Configuration(strconfig)
|
||||||
name = config_test["twitter"]["user_name"]
|
name = config_test["twitter"]["user_name"]
|
||||||
if name != "" and config_test["twitter"]["user_key"] != "" and config_test["twitter"]["user_secret"] != "":
|
if name != "" or (config_test["twitter"]["user_key"] != "" and config_test["twitter"]["user_secret"] != ""):
|
||||||
self.list.insert_item(False, name)
|
self.list.insert_item(False, name)
|
||||||
self.sessions.append(i)
|
self.sessions.append(i)
|
||||||
|
else:
|
||||||
|
del config_test
|
||||||
|
shutil.rmtree(path=paths.config_path(i), ignore_errors=True)
|
||||||
if self.list.get_count() > 0:
|
if self.list.get_count() > 0:
|
||||||
self.list.select_item(0)
|
self.list.select_item(0)
|
||||||
self.list.list.SetSize(self.list.list.GetBestSize())
|
self.list.list.SetSize(self.list.list.GetBestSize())
|
||||||
|
self.removeSession.Enable()
|
||||||
|
|
||||||
def ok(self, ev):
|
def ok(self, ev):
|
||||||
if self.list.get_count() == 0:
|
if self.list.get_count() == 0:
|
||||||
@ -74,8 +77,6 @@ class sessionManagerWindow(wx.Dialog):
|
|||||||
languageHandler.setLanguage(lang)
|
languageHandler.setLanguage(lang)
|
||||||
sound.setup()
|
sound.setup()
|
||||||
output.setup()
|
output.setup()
|
||||||
# else:
|
|
||||||
# self.name = current_session
|
|
||||||
self.EndModal(wx.ID_OK)
|
self.EndModal(wx.ID_OK)
|
||||||
|
|
||||||
def new_account(self, ev):
|
def new_account(self, ev):
|
||||||
@ -99,3 +100,12 @@ class sessionManagerWindow(wx.Dialog):
|
|||||||
if self.list.get_count() == 1:
|
if self.list.get_count() == 1:
|
||||||
self.list.select_item(0)
|
self.list.select_item(0)
|
||||||
self.sessions.append(location)
|
self.sessions.append(location)
|
||||||
|
|
||||||
|
def remove(self, ev):
|
||||||
|
selected_item = self.list.get_selected()
|
||||||
|
selected_session = self.sessions[selected_item]
|
||||||
|
ask = wx.MessageDialog(self, _(u"Do you really want delete this account?"), _(u"Remove account"), wx.YES_NO)
|
||||||
|
if ask.ShowModal() == wx.ID_YES:
|
||||||
|
self.sessions.remove(selected_session)
|
||||||
|
shutil.rmtree(path=paths.config_path(selected_session), ignore_errors=True)
|
||||||
|
self.list.remove_item(selected_item)
|
@ -34,6 +34,10 @@ class streamer(TwythonStreamer):
|
|||||||
tweet_event.SetItem(data)
|
tweet_event.SetItem(data)
|
||||||
announce = _(u"One tweet from %s in the list %s") % (data["user"]["name"], self.parent.nb.GetPage(i).name_buffer[:-5])
|
announce = _(u"One tweet from %s in the list %s") % (data["user"]["name"], self.parent.nb.GetPage(i).name_buffer[:-5])
|
||||||
tweet_event.SetAnnounce(announce)
|
tweet_event.SetAnnounce(announce)
|
||||||
|
usr = data["in_reply_to_user_id"]
|
||||||
|
if (usr != None and usr in self.friends) or data.has_key("retweeted_status"):
|
||||||
|
wx.PostEvent(self.parent.nb.GetPage(i), tweet_event)
|
||||||
|
elif usr == None:
|
||||||
wx.PostEvent(self.parent.nb.GetPage(i), tweet_event)
|
wx.PostEvent(self.parent.nb.GetPage(i), tweet_event)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
@ -42,5 +46,7 @@ class streamer(TwythonStreamer):
|
|||||||
try:
|
try:
|
||||||
if data.has_key("text"):
|
if data.has_key("text"):
|
||||||
self.check_tls(data)
|
self.check_tls(data)
|
||||||
|
elif "friends" in data:
|
||||||
|
self.friends = data["friends"]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
@ -68,7 +68,7 @@ class streamer(TwythonStreamer):
|
|||||||
tweet_event.SetItem(data["direct_message"])
|
tweet_event.SetItem(data["direct_message"])
|
||||||
text = _(u"One direct message")
|
text = _(u"One direct message")
|
||||||
tweet_event.SetAnnounce(text)
|
tweet_event.SetAnnounce(text)
|
||||||
wx.PostEvent(self.parent.search_buffer("buffer", "direct_messages"), tweet_event)
|
wx.PostEvent(self.parent.search_buffer("direct_message", "direct_messages"), tweet_event)
|
||||||
|
|
||||||
def check_follower(self, data):
|
def check_follower(self, data):
|
||||||
if data["target"]["screen_name"] == self.db.settings["user_name"] and config.main["other_buffers"]["show_followers"] == True:
|
if data["target"]["screen_name"] == self.db.settings["user_name"] and config.main["other_buffers"]["show_followers"] == True:
|
||||||
|
Loading…
Reference in New Issue
Block a user