Added run at startup option for installed version

This commit is contained in:
Manuel Cortez 2016-08-05 15:31:22 -05:00
parent b2ebbf5b7a
commit 05a8cb7a28
4 changed files with 13 additions and 6 deletions

View File

@ -8,6 +8,7 @@ language = string(default="system")
hide_gui = boolean(default=False)
voice_enabled = boolean(default=False)
ask_at_exit = boolean(default=True)
autostart = boolean(default=False)
handle_longtweets = boolean(default=True)
use_invisible_keyboard_shorcuts = boolean(default=True)
play_ready_sound = boolean(default=True)

View File

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
import os
import webbrowser
#import pocket
import sound_lib
import paths
import widgetUtils
@ -15,11 +14,10 @@ from extra.autocompletionUsers import settings
from pubsub import pub
import logging
import config_utils
#from pocket_utils import authorisationHandler
import BaseHTTPServer
log = logging.getLogger("Settings")
import keys
from collections import OrderedDict
from platform_utils.autostart import windows as autostart_windows
class globalSettingsController(object):
def __init__(self):
@ -57,8 +55,11 @@ class globalSettingsController(object):
self.dialog.create_general(langs,self.kmfriendlies)
self.dialog.general.language.SetSelection(id)
self.dialog.general.km.SetSelection(self.kmid)
if paths.mode == "installed":
self.dialog.set_value("general", "autostart", config.app["app-settings"]["autostart"])
else:
self.dialog.general.autostart.Enable(False)
self.dialog.set_value("general", "ask_at_exit", config.app["app-settings"]["ask_at_exit"])
self.dialog.set_value("general", "play_ready_sound", config.app["app-settings"]["play_ready_sound"])
self.dialog.set_value("general", "speak_ready_msg", config.app["app-settings"]["speak_ready_msg"])
self.dialog.set_value("general", "handle_longtweets", config.app["app-settings"]["handle_longtweets"])
@ -86,6 +87,9 @@ class globalSettingsController(object):
kmFile.close()
self.needs_restart = True
if config.app["app-settings"]["autostart"] != self.dialog.get_value("general", "autostart") and paths.mode == "installed":
config.app["app-settings"]["autostart"] = self.dialog.get_value("general", "autostart")
autostart_windows.setAutoStart(application.name, enable=self.dialog.get_value("general", "autostart"))
if config.app["app-settings"]["use_invisible_keyboard_shorcuts"] != self.dialog.get_value("general", "use_invisible_shorcuts"):
config.app["app-settings"]["use_invisible_keyboard_shorcuts"] = self.dialog.get_value("general", "use_invisible_shorcuts")
pub.sendMessage("invisible-shorcuts-changed", registered=self.dialog.get_value("general", "use_invisible_shorcuts"))

View File

@ -31,11 +31,11 @@ def getAutoStart(app_name):
def setAutoStart(app_name, enable=True):
"""Configures automatic startup for the application, if the enable argument is set to True. If set to False, deletes the application AutoStart value."""
print paths.get_executable()
if getAutoStart(app_name) == enable:
return
key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, RUN_REGKEY, 0, _winreg.KEY_WRITE)
if enable:
_winreg.SetValueEx(key, unicode(app_name), None, _winreg.REG_SZ, sys.argv[0])
_winreg.SetValueEx(key, unicode(app_name), None, _winreg.REG_SZ, paths.get_executable())
else:
_winreg.DeleteValue(key, unicode(app_name))

View File

@ -18,7 +18,9 @@ class general(wx.Panel, baseDialog.BaseWXDialog):
langBox.Add(language, 0, wx.ALL, 5)
langBox.Add(self.language, 0, wx.ALL, 5)
sizer.Add(langBox, 0, wx.ALL, 5)
self.autostart = wx.CheckBox(self, -1, _(u"Run {0} at Windows startup").format(application.name,))
self.ask_at_exit = wx.CheckBox(self, -1, _(U"ask before exiting {0}").format(application.name,))
sizer.Add(self.autostart, 0, wx.ALL, 5)
sizer.Add(self.ask_at_exit, 0, wx.ALL, 5)
self.play_ready_sound = wx.CheckBox(self, -1, _(U"Play a sound when {0} launches").format(application.name,))
sizer.Add(self.play_ready_sound, 0, wx.ALL, 5)