no icon for now
This commit is contained in:
parent
2713c17550
commit
269c6e511f
1 changed files with 21 additions and 26 deletions
|
@ -9,15 +9,9 @@ import webbrowser
|
||||||
import gi
|
import gi
|
||||||
gi.require_version('Gtk', '3.0')
|
gi.require_version('Gtk', '3.0')
|
||||||
from gi.repository import Gtk, GLib
|
from gi.repository import Gtk, GLib
|
||||||
try:
|
|
||||||
gi.require_version('AppIndicator3', '0.1')
|
|
||||||
from gi.repository import AppIndicator3 as appindicator
|
|
||||||
except:
|
|
||||||
appindicator = None
|
|
||||||
|
|
||||||
|
|
||||||
base = dirname(dirname(dirname(abspath(__file__))))
|
base = dirname(dirname(dirname(abspath(__file__))))
|
||||||
icon = os.path.join(base, 'openmedialibrary/static/png/oml.png')
|
icon = os.path.join(base, 'openmedialibrary/static/svg/oml.svg')
|
||||||
title = "Open Media Library"
|
title = "Open Media Library"
|
||||||
ctl = base + '/ctl'
|
ctl = base + '/ctl'
|
||||||
|
|
||||||
|
@ -34,26 +28,29 @@ def check_pid(pid):
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
class OMLIcon:
|
def preexec(): # Don't forward signals.
|
||||||
|
os.setpgrp()
|
||||||
|
|
||||||
|
|
||||||
|
class OMLStatus:
|
||||||
menu = None
|
menu = None
|
||||||
icon = None
|
icon = None
|
||||||
indicator = None
|
|
||||||
|
|
||||||
def __init__(self, autostart=False):
|
def __init__(self, autostart=False):
|
||||||
self.autostart = autostart
|
self.autostart = autostart
|
||||||
self.create_pid()
|
self.create_pid()
|
||||||
if appindicator:
|
self.win = Gtk.Window()
|
||||||
self.indicator = appindicator.Indicator.new("OML", icon,
|
self.win.set_icon_from_file(icon)
|
||||||
appindicator.IndicatorCategory.APPLICATION_STATUS)
|
self.win.set_title(title)
|
||||||
self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
|
#self.win.show_all()
|
||||||
self.menu = self.get_menu()
|
self.win.iconify()
|
||||||
self.indicator.set_menu(self.menu)
|
'''
|
||||||
else:
|
|
||||||
self.icon = Gtk.StatusIcon()
|
self.icon = Gtk.StatusIcon()
|
||||||
self.icon.set_from_file(icon)
|
self.icon.set_from_file(icon)
|
||||||
self.icon.set_title(title)
|
self.icon.set_title(title)
|
||||||
self.icon.connect("activate", self._click)
|
self.icon.connect("activate", self._click)
|
||||||
self.icon.connect("popup-menu", self._click)
|
self.icon.connect("popup-menu", self._click)
|
||||||
|
'''
|
||||||
subprocess.Popen([ctl, 'start'], close_fds=True, preexec_fn=preexec)
|
subprocess.Popen([ctl, 'start'], close_fds=True, preexec_fn=preexec)
|
||||||
if not self.autostart:
|
if not self.autostart:
|
||||||
GLib.timeout_add_seconds(1, self._open, None)
|
GLib.timeout_add_seconds(1, self._open, None)
|
||||||
|
@ -152,16 +149,14 @@ class OMLIcon:
|
||||||
url += '#%s' % port
|
url += '#%s' % port
|
||||||
webbrowser.open_new_tab(url)
|
webbrowser.open_new_tab(url)
|
||||||
|
|
||||||
def preexec(): # Don't forward signals.
|
|
||||||
os.setpgrp()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import signal
|
import signal
|
||||||
autostart = len(sys.argv) > 1 and sys.argv[1] == '--autostart'
|
autostart = len(sys.argv) > 1 and sys.argv[1] == '--autostart'
|
||||||
if OMLIcon.is_running():
|
if OMLStatus.is_running():
|
||||||
OMLIcon.load()
|
OMLStatus.load()
|
||||||
else:
|
else:
|
||||||
oml = OMLIcon(autostart)
|
oml = OMLStatus(autostart)
|
||||||
main_loop = GLib.MainLoop()
|
main_loop = GLib.MainLoop()
|
||||||
try:
|
try:
|
||||||
main_loop.run()
|
main_loop.run()
|
||||||
|
|
Loading…
Reference in a new issue