mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 05:31:15 -07:00
Update system tray icon
This commit is contained in:
parent
00c9fc79f9
commit
cd5ed1d748
5 changed files with 39 additions and 32 deletions
|
@ -35,28 +35,28 @@ else:
|
|||
class MacOSSystemTray(object):
|
||||
def __init__(self):
|
||||
self.image_dir = os.path.join(plexpy.PROG_DIR, 'data/interfaces/', plexpy.CONFIG.INTERFACE, 'images')
|
||||
|
||||
if plexpy.UPDATE_AVAILABLE:
|
||||
self.icon = os.path.join(self.image_dir, 'logo-circle-update.ico')
|
||||
self.hover_text = common.PRODUCT + ' - Update Available!'
|
||||
else:
|
||||
self.icon = os.path.join(self.image_dir, 'logo-circle.ico')
|
||||
self.hover_text = common.PRODUCT
|
||||
|
||||
self.menu = [
|
||||
rumps.MenuItem('Open Tautulli', callback=self.tray_open),
|
||||
rumps.MenuItem('Start Tautulli at Login', callback=self.tray_startup),
|
||||
rumps.MenuItem('Check for Updates', callback=self.tray_check_update),
|
||||
rumps.MenuItem('Update', callback=self.tray_update),
|
||||
rumps.MenuItem('Restart', callback=self.tray_restart),
|
||||
rumps.MenuItem('Quit', callback=self.tray_quit)
|
||||
]
|
||||
if not plexpy.FROZEN:
|
||||
self.menu.insert(3, rumps.MenuItem('Update', callback=self.tray_update))
|
||||
self.menu[1].state = plexpy.CONFIG.LAUNCH_STARTUP
|
||||
|
||||
self.tray_icon = None
|
||||
self.tray_icon = rumps.App(common.PRODUCT, icon=self.icon, menu=self.menu, quit_button=None)
|
||||
|
||||
def start(self):
|
||||
logger.info("Launching MacOS system tray icon.")
|
||||
try:
|
||||
self.tray_icon = rumps.App(common.PRODUCT, icon=self.icon, menu=self.menu, quit_button=None)
|
||||
self.tray_icon.run()
|
||||
except Exception as e:
|
||||
logger.error("Unable to launch system tray icon: %s." % e)
|
||||
|
@ -65,8 +65,8 @@ class MacOSSystemTray(object):
|
|||
rumps.quit_application()
|
||||
|
||||
def update(self, **kwargs):
|
||||
#self.sys_tray_icon.update(**kwargs)
|
||||
pass
|
||||
if 'icon' in kwargs:
|
||||
self.tray_icon.icon = kwargs['icon']
|
||||
|
||||
def tray_open(self, tray_icon):
|
||||
plexpy.launch_browser(plexpy.CONFIG.HTTP_HOST, plexpy.HTTP_PORT, plexpy.HTTP_ROOT)
|
||||
|
@ -81,9 +81,6 @@ class MacOSSystemTray(object):
|
|||
def tray_update(self, tray_icon):
|
||||
if plexpy.UPDATE_AVAILABLE:
|
||||
plexpy.SIGNAL = 'update'
|
||||
else:
|
||||
hover_text = common.PRODUCT + ' - No Update Available'
|
||||
self.update(hover_text=hover_text)
|
||||
|
||||
def tray_restart(self, tray_icon):
|
||||
plexpy.SIGNAL = 'restart'
|
||||
|
@ -91,16 +88,22 @@ class MacOSSystemTray(object):
|
|||
def tray_quit(self, tray_icon):
|
||||
plexpy.SIGNAL = 'shutdown'
|
||||
|
||||
def change_tray_startup_icon(self):
|
||||
if plexpy.CONFIG.LAUNCH_STARTUP:
|
||||
start_icon = os.path.join(self.image_dir, 'check-solid.ico')
|
||||
def change_tray_update_icon(self):
|
||||
if plexpy.UPDATE_AVAILABLE:
|
||||
self.icon = os.path.join(self.image_dir, 'logo-circle-update.ico')
|
||||
else:
|
||||
start_icon = None
|
||||
#self.menu_options[2][1] = start_icon
|
||||
#self.update(menu_options=self.menu_options)
|
||||
self.icon = os.path.join(self.image_dir, 'logo-circle.ico')
|
||||
self.update(icon=self.icon)
|
||||
|
||||
def change_tray_startup_icon(self):
|
||||
self.menu[1].state = plexpy.CONFIG.LAUNCH_STARTUP
|
||||
self.tray_icon.menu = self.menu
|
||||
|
||||
|
||||
def set_startup():
|
||||
if plexpy.MAC_SYS_TRAY_ICON:
|
||||
plexpy.MAC_SYS_TRAY_ICON.change_tray_startup_icon()
|
||||
|
||||
if plexpy.INSTALL_TYPE == 'macos':
|
||||
if plexpy.CONFIG.LAUNCH_STARTUP:
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue