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
from os.path import dirname, abspath
import subprocess
import time
import webbrowser
import _thread
import gi
gi.require_version('Gtk', '3.0')
@ -39,13 +39,16 @@ class OMLIcon:
self.icon.set_title(title)
self.icon.connect("activate", 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)
_thread.start_new_thread(self._wait, ())
GLib.timeout_add_seconds(60, self._check, None)
def _wait(self):
self._p.wait()
self._quit(None)
def _check(self, *args, **kwargs):
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)
def get_menu(self):
menu = Gtk.Menu()