close gtk menuitem if pid is gone
This commit is contained in:
parent
75fd720b19
commit
5a920ca053
1 changed files with 9 additions and 6 deletions
|
@ -2,8 +2,8 @@
|
||||||
import os
|
import os
|
||||||
from os.path import dirname, abspath
|
from os.path import dirname, abspath
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import time
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import _thread
|
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
gi.require_version('Gtk', '3.0')
|
gi.require_version('Gtk', '3.0')
|
||||||
|
@ -39,13 +39,16 @@ class OMLIcon:
|
||||||
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)
|
||||||
self._p = subprocess.Popen([ctl, 'start'])
|
subprocess.Popen([ctl, 'start'])
|
||||||
GLib.timeout_add_seconds(1, self._open, None)
|
GLib.timeout_add_seconds(1, self._open, None)
|
||||||
_thread.start_new_thread(self._wait, ())
|
GLib.timeout_add_seconds(60, self._check, None)
|
||||||
|
|
||||||
def _wait(self):
|
def _check(self, *args, **kwargs):
|
||||||
self._p.wait()
|
pid = os.path.join(base, 'data', 'openmedialibrary.pid')
|
||||||
self._quit(None)
|
if os.path.exists(pid):
|
||||||
|
GLib.timeout_add_seconds(60, self._check, None)
|
||||||
|
else:
|
||||||
|
self._quit(None)
|
||||||
|
|
||||||
def get_menu(self):
|
def get_menu(self):
|
||||||
menu = Gtk.Menu()
|
menu = Gtk.Menu()
|
||||||
|
|
Loading…
Reference in a new issue