close gtk menuitem if pid is gone

This commit is contained in:
j 2016-01-18 17:47:36 +05:30
parent 75fd720b19
commit 5a920ca053

View file

@ -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,12 +39,15 @@ 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')
if os.path.exists(pid):
GLib.timeout_add_seconds(60, self._check, None)
else:
self._quit(None) self._quit(None)
def get_menu(self): def get_menu(self):