Basic update profile function, some minor bugfixes, sound playback improvements

This commit is contained in:
2015-03-06 21:37:08 -06:00
parent 373ca24a96
commit e65c8ec4a6
8 changed files with 128 additions and 29 deletions

View File

@@ -7,6 +7,7 @@ import output
import config
import sound
import messages
import updateProfile
import languageHandler
import logging
from twitter import compose, utils
@@ -370,12 +371,12 @@ class baseBufferController(bufferController):
if tweet == None: return
urls = utils.find_urls(tweet)
if len(urls) == 1:
sound.URLPlayer.play(urls[0])
sound.URLPlayer.play(urls[0], self.session.settings["sound"]["volume"])
else:
urls_list = dialogs.urlList.urlList()
urls_list.populate_list(urls)
if urls_list.get_response() == widgetUtils.OK:
sound.URLPlayer.play(urls_list.get_string())
sound.URLPlayer.play(urls_list.get_string(), self.session.settings["sound"]["volume"])
@_tweets_exist
def url(self):
@@ -543,6 +544,9 @@ class peopleBufferController(baseBufferController):
self.session.db[self.name]["cursor"] = -1
self.buffer.list.clear()
def url(self):
updateProfile.updateProfileController(self.session, user=self.get_right_tweet()["screen_name"])
class searchBufferController(baseBufferController):
def start_stream(self):
log.debug("Starting stream for %s buffer, %s account and %s type" % (self.name, self.account, self.type))

View File

@@ -28,6 +28,7 @@ if platform.system() == "Windows":
from keyboard_handler.wx_handler import WXKeyboardHandler
import userActionsController
import trendingTopics
import updateProfile
import webbrowser
log = logging.getLogger("mainController")
@@ -149,6 +150,7 @@ class Controller(object):
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.visit_website, menuitem=self.view.visit_website)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.edit_keystrokes, menuitem=self.view.keystroke_editor)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.manage_accounts, self.view.manage_accounts)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.update_profile, menuitem=self.view.updateProfile)
widgetUtils.connect_event(self.view.nb, widgetUtils.NOTEBOOK_PAGE_CHANGED, self.buffer_changed)
def __init__(self):
@@ -1068,5 +1070,8 @@ class Controller(object):
self.accounts.remove(session_.sessions[i].settings["twitter"]["user_name"])
session_.sessions.pop(i)
def update_profile(self, *args, **kwargs):
r = updateProfile.updateProfileController(self.get_best_buffer().session)
def __del__(self):
config.app.write()

View File

@@ -79,7 +79,7 @@ class accountSettingsController(globalSettingsController):
self.soundpacks = []
[self.soundpacks.append(i) for i in os.listdir(paths.sound_path()) if os.path.isdir(paths.sound_path(i)) == True ]
self.dialog.create_sound(self.input_devices, self.output_devices, self.soundpacks)
self.dialog.set_value("sound", "volumeCtrl", self.config["sound"]["volume"])
self.dialog.set_value("sound", "volumeCtrl", self.config["sound"]["volume"]*100)
self.dialog.set_value("sound", "input", self.config["sound"]["input_device"])
self.dialog.set_value("sound", "output", self.config["sound"]["output_device"])
self.dialog.set_value("sound", "global_mute", self.config["sound"]["global_mute"])
@@ -136,7 +136,9 @@ class accountSettingsController(globalSettingsController):
self.config["sound"]["output_device"] = "default"
self.config["sound"]["volume"] = self.dialog.get_value("sound", "volumeCtrl")/100.0
self.config["sound"]["global_mute"] = self.dialog.get_value("sound", "global_mute")
print self.dialog.sound.get("soundpack")
self.config["sound"]["soundpack"] = self.dialog.sound.get("soundpack")
self.buffer.session.sound.config = self.config["sound"]
self.buffer.session.sound.check_soundpack()
self.config["sound"]["sndup_api_key"] = self.dialog.get_value("services", "apiKey")

View File

@@ -0,0 +1,67 @@
# -*- coding: utf-8 -*-
import widgetUtils
import output
from wxUI.dialogs import update_profile
from twython import TwythonError
class updateProfileController(object):
def __init__(self, session, user=None):
super(updateProfileController, self).__init__()
self.file = None
self.session = session
self.user = user
self.dialog = update_profile.updateProfileDialog()
if user == None:
self.get_data(screen_name=self.session.db["user_name"])
self.uploaded = False
widgetUtils.connect_event(self.dialog.upload_image, widgetUtils.BUTTON_PRESSED, self.upload_image)
else:
self.get_data(screen_name=self.user)
self.dialog.set_readonly()
if self.dialog.get_response() == widgetUtils.OK and self.user == None:
self.do_update()
def get_data(self, screen_name):
data = self.session.twitter.twitter.show_user(screen_name=screen_name)
self.dialog.set_name(data["name"])
if data["url"] != None:
self.dialog.set_url(data["url"])
if len(data["location"]) > 0:
self.dialog.set_location(data["location"])
if len(data["description"]) > 0:
self.dialog.set_description(data["description"])
def get_image(self):
file = self.dialog.upload_picture()
if file != None:
self.file = open(file, "rb")
self.uploaded = True
self.dialog.change_upload_button(self.uploaded)
def discard_image(self):
self.file = None
output.speak(_(u"Discarded"))
self.uploaded = False
self.dialog.change_upload_button(self.uploaded)
def upload_image(self, *args, **kwargs):
if self.uploaded == False:
self.get_image()
elif self.uploaded == True:
self.discard_image()
def do_update(self):
name = self.dialog.get("name")
description = self.dialog.get("description")
location = self.dialog.get("location")
url = self.dialog.get("url")
if self.file != None:
try:
self.session.twitter.twitter.update_profile_image(image=self.file)
except TwythonError as e:
output.speak(u"Error %s. %s" % (e.error_code, e.msg))
try:
self.session.twitter.twitter.update_profile(name=name, description=description, location=location, url=url)
except TwythonError as e:
output.speak(u"Error %s. %s" % (e.error_code, e.msg))