mirror of https://github.com/borgbase/vorta
Implement selecting update channel (appcast.xml).
This commit is contained in:
parent
ab60a0785d
commit
96103a97e3
|
@ -197,7 +197,7 @@ def init_db(con):
|
|||
if sys.platform == 'darwin':
|
||||
settings += [
|
||||
{'key': 'autostart', 'value': False, 'type': 'checkbox',
|
||||
'label': 'Add Vorta to Login Items in Preferences > Users and Groups > Login Items. (not implemented)'},
|
||||
'label': 'Add Vorta to Login Items in Preferences > Users and Groups > Login Items.'},
|
||||
{'key': 'enable_notifications', 'value': True, 'type': 'checkbox',
|
||||
'label': 'Display notifications when background tasks fail.'},
|
||||
{'key': 'check_for_updates', 'value': True, 'type': 'checkbox',
|
||||
|
@ -206,7 +206,7 @@ def init_db(con):
|
|||
'label': 'Include pre-release versions when checking for updates.'},
|
||||
]
|
||||
|
||||
for setting in settings: # Create missing settings and update labels.
|
||||
for setting in settings: # Create missing settings and update labels. Leave setting values untouched.
|
||||
s, created = SettingsModel.get_or_create(key=setting['key'], defaults=setting)
|
||||
s.label = setting['label']
|
||||
s.save()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import sys
|
||||
from vorta.models import SettingsModel
|
||||
|
||||
|
||||
class VortaNotifications:
|
||||
|
@ -20,15 +21,16 @@ class VortaNotifications:
|
|||
|
||||
class DarwinNotifications(VortaNotifications):
|
||||
def deliver(self, title, text):
|
||||
from Foundation import NSUserNotification
|
||||
from Foundation import NSUserNotificationCenter
|
||||
if SettingsModel.get(key='enable_notifications').value:
|
||||
from Foundation import NSUserNotification
|
||||
from Foundation import NSUserNotificationCenter
|
||||
|
||||
notification = NSUserNotification.alloc().init()
|
||||
notification.setTitle_(title)
|
||||
notification.setInformativeText_(text)
|
||||
center = NSUserNotificationCenter.defaultUserNotificationCenter()
|
||||
if center is not None: # Only works when run from app bundle.
|
||||
center.deliverNotification_(notification)
|
||||
notification = NSUserNotification.alloc().init()
|
||||
notification.setTitle_(title)
|
||||
notification.setInformativeText_(text)
|
||||
center = NSUserNotificationCenter.defaultUserNotificationCenter()
|
||||
if center is not None: # Only works when run from app bundle.
|
||||
center.deliverNotification_(notification)
|
||||
|
||||
|
||||
class LinuxNotifications(VortaNotifications):
|
||||
|
|
|
@ -5,14 +5,30 @@ from vorta.models import SettingsModel
|
|||
|
||||
def get_updater():
|
||||
if sys.platform == 'darwin' and getattr(sys, 'frozen', False):
|
||||
# Use sparkle framework on macOS.
|
||||
# Examples: https://programtalk.com/python-examples/objc.loadBundle/
|
||||
"""
|
||||
Use Sparkle framework on macOS.
|
||||
|
||||
Settings: https://sparkle-project.org/documentation/customization/
|
||||
Examples: https://programtalk.com/python-examples/objc.loadBundle/
|
||||
|
||||
To debug:
|
||||
$ defaults read com.borgbase.client.macos
|
||||
"""
|
||||
|
||||
import objc
|
||||
import Cocoa
|
||||
bundle_path = os.path.join(os.path.dirname(sys.executable), os.pardir, 'Frameworks', 'Sparkle.framework')
|
||||
objc.loadBundle('Sparkle', globals(), bundle_path)
|
||||
sparkle = SUUpdater.sharedUpdater() # noqa: F821
|
||||
|
||||
# A default Appcast URL is set in vorta.spec, when setting it here it's saved to defaults,
|
||||
# so we need both cases.
|
||||
if SettingsModel.get(key='updates_include_beta').value:
|
||||
sparkle.SharedUpdater.FeedURL = 'https://borgbase.github.io/vorta/appcast-pre.xml'
|
||||
appcast_nsurl = Cocoa.NSURL.URLWithString_('https://borgbase.github.io/vorta/appcast-pre.xml')
|
||||
else:
|
||||
appcast_nsurl = Cocoa.NSURL.URLWithString_('https://borgbase.github.io/vorta/appcast.xml')
|
||||
|
||||
sparkle.setFeedURL_(appcast_nsurl)
|
||||
|
||||
if SettingsModel.get(key='check_for_updates').value:
|
||||
sparkle.setAutomaticallyChecksForUpdates_(True)
|
||||
|
|
|
@ -46,7 +46,7 @@ app = BUNDLE(exe,
|
|||
'CFBundleShortVersionString': '0.5.4',
|
||||
'CFBundleVersion': '0.5.4',
|
||||
'NSAppleEventsUsageDescription': 'Please allow',
|
||||
'SUFeedURL': 'https://borgbase.github.io/vorta/appcast-pre.xml'
|
||||
'SUFeedURL': 'https://borgbase.github.io/vorta/appcast.xml'
|
||||
},
|
||||
)
|
||||
if False:
|
||||
|
|
Loading…
Reference in New Issue