mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-26 12:53:12 -06:00
Save configs when they change. Fixes #95
This commit is contained in:
parent
6bb534d250
commit
4d5de6ca69
@ -74,6 +74,7 @@ class bufferController(object):
|
||||
if hasattr(sound.URLPlayer, "stream"):
|
||||
sound.URLPlayer.stream.volume = self.session.settings["sound"]["volume"]
|
||||
self.session.sound.play("volume_changed.ogg")
|
||||
self.session.settings.write()
|
||||
|
||||
def volume_up(self):
|
||||
if self.session.settings["sound"]["volume"] < 1.0:
|
||||
@ -84,6 +85,7 @@ class bufferController(object):
|
||||
if hasattr(sound.URLPlayer, "stream"):
|
||||
sound.URLPlayer.stream.volume = self.session.settings["sound"]["volume"]
|
||||
self.session.sound.play("volume_changed.ogg")
|
||||
self.session.settings.write()
|
||||
|
||||
def start_stream(self, mandatory=False):
|
||||
if mandatory == True:
|
||||
@ -148,6 +150,7 @@ class bufferController(object):
|
||||
else:
|
||||
call_threaded(self.post_with_media, text=text, attachments=tweet.attachments)
|
||||
if hasattr(tweet.message, "destroy"): tweet.message.destroy()
|
||||
self.session.settings.write()
|
||||
|
||||
def post_with_media(self, text, attachments):
|
||||
media_ids = []
|
||||
@ -209,6 +212,7 @@ class accountPanel(bufferController):
|
||||
else:
|
||||
self.buffer.change_autostart(False)
|
||||
config.app["sessions"]["ignored_sessions"].append(self.account_id)
|
||||
config.app.write()
|
||||
|
||||
class emptyPanel(bufferController):
|
||||
def __init__(self, parent, name, account):
|
||||
@ -356,6 +360,7 @@ class baseBufferController(bufferController):
|
||||
if dlg == widgetUtils.YES:
|
||||
if self.name[:-9] in self.session.settings["other_buffers"]["timelines"]:
|
||||
self.session.settings["other_buffers"]["timelines"].remove(self.name[:-9])
|
||||
self.session.settings.write()
|
||||
self.session.db.pop(self.name)
|
||||
return True
|
||||
elif dlg == widgetUtils.NO:
|
||||
@ -366,6 +371,7 @@ class baseBufferController(bufferController):
|
||||
if self.name[:-9] in self.session.settings["other_buffers"]["favourites_timelines"]:
|
||||
self.session.settings["other_buffers"]["favourites_timelines"].remove(self.name[:-9])
|
||||
self.session.db.pop(self.name)
|
||||
self.session.settings.write()
|
||||
return True
|
||||
elif dlg == widgetUtils.NO:
|
||||
return False
|
||||
@ -525,6 +531,7 @@ class baseBufferController(bufferController):
|
||||
params["media"] = message.file
|
||||
call_threaded(self.session.api_call, **params)
|
||||
if hasattr(message.message, "destroy"): message.message.destroy()
|
||||
self.session.settings.write()
|
||||
|
||||
@_tweets_exist
|
||||
def direct_message(self, *args, **kwargs):
|
||||
@ -720,6 +727,7 @@ class listBufferController(baseBufferController):
|
||||
if self.name[:-5] in self.session.settings["other_buffers"]["lists"]:
|
||||
self.session.settings["other_buffers"]["lists"].remove(self.name[:-5])
|
||||
self.session.db.pop(self.name)
|
||||
self.session.settings.write()
|
||||
return True
|
||||
elif dlg == widgetUtils.NO:
|
||||
return False
|
||||
@ -802,6 +810,7 @@ class peopleBufferController(baseBufferController):
|
||||
if self.name[:-10] in self.session.settings["other_buffers"]["followers_timelines"]:
|
||||
self.session.settings["other_buffers"]["followers_timelines"].remove(self.name[:-10])
|
||||
self.session.db.pop(self.name)
|
||||
self.session.settings.write()
|
||||
return True
|
||||
elif dlg == widgetUtils.NO:
|
||||
return False
|
||||
@ -811,6 +820,7 @@ class peopleBufferController(baseBufferController):
|
||||
if self.name[:-8] in self.session.settings["other_buffers"]["friends_timelines"]:
|
||||
self.session.settings["other_buffers"]["friends_timelines"].remove(self.name[:-8])
|
||||
self.session.db.pop(self.name)
|
||||
self.session.settings.write()
|
||||
return True
|
||||
elif dlg == widgetUtils.NO:
|
||||
return False
|
||||
@ -963,6 +973,7 @@ class searchBufferController(baseBufferController):
|
||||
if dlg == widgetUtils.YES:
|
||||
if self.name[:-11] in self.session.settings["other_buffers"]["tweet_searches"]:
|
||||
self.session.settings["other_buffers"]["tweet_searches"].remove(self.name[:-11])
|
||||
self.session.settings.write()
|
||||
self.timer.cancel()
|
||||
self.session.db.pop(self.name)
|
||||
return True
|
||||
@ -1004,6 +1015,7 @@ class searchPeopleBufferController(peopleBufferController):
|
||||
if dlg == widgetUtils.YES:
|
||||
if self.name[:-11] in self.session.settings["other_buffers"]["tweet_searches"]:
|
||||
self.session.settings["other_buffers"]["tweet_searches"].remove(self.name[:-11])
|
||||
self.session.settings.write()
|
||||
self.timer.cancel()
|
||||
self.session.db.pop(self.name)
|
||||
return True
|
||||
@ -1072,6 +1084,7 @@ class trendsBufferController(bufferController):
|
||||
if dlg == widgetUtils.YES:
|
||||
if self.name[:-3] in self.session.settings["other_buffers"]["trending_topic_buffers"]:
|
||||
self.session.settings["other_buffers"]["trending_topic_buffers"].remove(self.name[:-3])
|
||||
self.session.settings.write()
|
||||
self.timer.cancel()
|
||||
self.session.db.pop(self.name)
|
||||
return True
|
||||
|
@ -438,6 +438,7 @@ class Controller(object):
|
||||
if dlg.get("tweets") == True:
|
||||
if term not in buffer.session.settings["other_buffers"]["tweet_searches"]:
|
||||
buffer.session.settings["other_buffers"]["tweet_searches"].append(term)
|
||||
buffer.session.settings.write()
|
||||
args = {"lang": dlg.get_language(), "result_type": dlg.get_result_type()}
|
||||
search = buffersController.searchBufferController(self.view.nb, "search", "%s-searchterm" % (term,), buffer.session, buffer.session.db["user_name"], bufferType="searchPanel", q=term, count=buffer.session.settings["general"]["max_tweets_per_call"], **args)
|
||||
else:
|
||||
@ -496,6 +497,7 @@ class Controller(object):
|
||||
def edit_keystrokes(self, *args, **kwargs):
|
||||
editor = keystrokeEditor.KeystrokeEditor()
|
||||
if editor.changed == True:
|
||||
config.keymap.write()
|
||||
register = False
|
||||
# determines if we need to reassign the keymap.
|
||||
if self.showing == False:
|
||||
@ -637,12 +639,8 @@ class Controller(object):
|
||||
for i in self.buffers: i.save_positions()
|
||||
log.debug("Exiting...")
|
||||
log.debug("Saving global configuration...")
|
||||
config.app.write()
|
||||
config.keymap.write()
|
||||
for item in session_.sessions:
|
||||
if session_.sessions[item].logged == False: continue
|
||||
log.debug("Saving config for %s session" % (session_.sessions[item].session_id,))
|
||||
session_.sessions[item].settings.write()
|
||||
log.debug("Disconnecting streams for %s session" % (session_.sessions[item].session_id,))
|
||||
if hasattr(session_.sessions[item], "main_stream"): session_.sessions[item].main_stream.disconnect()
|
||||
if hasattr(session_.sessions[item], "timelinesStream"): session_.sessions[item].timelinesStream.disconnect()
|
||||
@ -866,6 +864,7 @@ class Controller(object):
|
||||
buff.session.sound.play("create_timeline.ogg")
|
||||
else:
|
||||
commonMessageDialogs.user_not_exist()
|
||||
buff.session.settings.write()
|
||||
|
||||
def open_conversation(self, *args, **kwargs):
|
||||
buffer = self.get_current_buffer()
|
||||
@ -910,6 +909,7 @@ class Controller(object):
|
||||
timer = RepeatingTimer(300, buffer.start_stream)
|
||||
timer.start()
|
||||
buffer.session.settings["other_buffers"]["trending_topic_buffers"].append(woeid)
|
||||
buffer.session.settings.write()
|
||||
|
||||
def reverse_geocode(self, event=None):
|
||||
try:
|
||||
@ -1384,6 +1384,7 @@ class Controller(object):
|
||||
self.view.insert_buffer(tl.buffer, name=_(u"List for {}").format(create), pos=self.view.search("lists", buff.session.db["user_name"]))
|
||||
tl.start_stream()
|
||||
buff.session.settings["other_buffers"]["lists"].append(create)
|
||||
buff.session.settings.write()
|
||||
pub.sendMessage("restart-streams", streams=["timelinesStream"], session=buff.session)
|
||||
|
||||
def restart_streams(self, streams=[], session=None):
|
||||
@ -1438,6 +1439,7 @@ class Controller(object):
|
||||
elif buffer.name in buffer.session.settings["other_buffers"]["autoread_buffers"]:
|
||||
buffer.session.settings["other_buffers"]["autoread_buffers"].remove(buffer.name)
|
||||
output.speak(_(u"The auto-reading of new tweets is disabled for this buffer"), True)
|
||||
buffer.session.settings.write()
|
||||
|
||||
def toggle_session_mute(self, *args, **kwargs):
|
||||
buffer = self.get_best_buffer()
|
||||
@ -1447,6 +1449,7 @@ class Controller(object):
|
||||
elif buffer.session.settings["sound"]["session_mute"] == True:
|
||||
buffer.session.settings["sound"]["session_mute"] = False
|
||||
output.speak(_(u"Session mute off"), True)
|
||||
buffer.session.settings.write()
|
||||
|
||||
def toggle_buffer_mute(self, *args, **kwargs):
|
||||
buffer = self.get_current_buffer()
|
||||
@ -1457,6 +1460,7 @@ class Controller(object):
|
||||
elif buffer.name in buffer.session.settings["other_buffers"]["muted_buffers"]:
|
||||
buffer.session.settings["other_buffers"]["muted_buffers"].remove(buffer.name)
|
||||
output.speak(_(u"Buffer mute off"), True)
|
||||
buffer.session.settings.write()
|
||||
|
||||
def view_documentation(self, *args, **kwargs):
|
||||
lang = localization.get("documentation")
|
||||
@ -1488,9 +1492,6 @@ class Controller(object):
|
||||
if i.session != None and i.session.session_id == session:
|
||||
i.start_stream()
|
||||
|
||||
def __del__(self):
|
||||
config.app.write()
|
||||
|
||||
def update_buffer(self, *args, **kwargs):
|
||||
bf = self.get_current_buffer()
|
||||
if not hasattr(bf, "start_stream"):
|
||||
|
@ -234,6 +234,7 @@ class accountSettingsController(globalSettingsController):
|
||||
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")
|
||||
self.config.write()
|
||||
|
||||
def toggle_state(self,*args,**kwargs):
|
||||
return self.dialog.buffers.change_selected_item()
|
||||
|
@ -77,3 +77,4 @@ class userActionsController(object):
|
||||
client = re.sub(r"(?s)<.*?>", "", tweet["source"])
|
||||
if client not in self.session.settings["twitter"]["ignored_clients"]:
|
||||
self.session.settings["twitter"]["ignored_clients"].append(client)
|
||||
self.session.settings.write()
|
@ -95,6 +95,8 @@ class sessionManagerController(object):
|
||||
s.authorise()
|
||||
self.sessions.append(location)
|
||||
self.view.add_new_session_to_list()
|
||||
s.settings.write()
|
||||
config.write()
|
||||
# except:
|
||||
# log.exception("Error authorising the session")
|
||||
# self.view.show_unauthorised_error()
|
||||
|
Loading…
Reference in New Issue
Block a user