def __init__(self, parent=None): QtGui.QSystemTrayIcon.__init__(self, parent) self.title = 'Time Synchronisation Monitor' self.right_click_menu = RightClickMenu() self.setContextMenu(self.right_click_menu) self.path = '/var/run/sdwdate' self.status_path = '/var/run/sdwdate/status' self.popup_path = '/usr/lib/sdwdate-gui/show_message' self.popup_pid = 0 self.update = Update(self) self.update.update_tip.connect(self.update_tip) self.activated.connect(self.mouse_event) self.message_showing = False self.clicked_once = False self.pos_x = 0 self.pos_y = 0 self.message = '' self.previous_message = '' self.stripped_message = '' if os.path.exists(self.status_path): ## Read status when GUI is loaded. self.status_changed() self.watcher = watcher([self.status_path]) self.watcher.fileChanged.connect(self.status_changed) else: self.setIcon(QtGui.QIcon('/usr/share/icons/oxygen/16x16/status/dialog-error.png')) error_msg = '''<b>sdwdate is not running</b><br> Try to restart it: Right click -> Restart sdwdate<br> If the icon stays red, please report this bug.''' self.message = error_msg self.setToolTip(error_msg) self.watcher_2 = watcher([self.path]) self.watcher_2.directoryChanged.connect(self.watch_folder)
def __init__(self, parent=None): QtGui.QSystemTrayIcon.__init__(self, parent) self.title = 'Time Synchronisation Monitor' self.right_click_menu = RightClickMenu() self.setContextMenu(self.right_click_menu) self.path = '/var/run/sdwdate' self.status_path = '/var/run/sdwdate/status' self.popup_path = '/usr/lib/sdwdate-gui/show_message' self.popup_pid = 0 self.update = Update(self) self.update.update_tip.connect(self.update_tip) self.activated.connect(self.mouse_event) self.message_showing = False self.clicked_once = False self.pos_x = 0 self.pos_y = 0 self.message = '' self.previous_message = '' self.stripped_message = '' if os.path.exists(self.status_path): ## Read status when GUI is loaded. self.status_changed() self.watch_file() else: self.setIcon(QtGui.QIcon('/usr/share/icons/sdwdate-gui/620px-Ambox_outdated.svg.png')) error_msg = 'sdwdate will probably start in a few moments.' self.message = error_msg self.setToolTip(error_msg) self.watcher_2 = watcher([self.path]) self.watcher_2.directoryChanged.connect(self.watch_folder)
def watch_folder(self): self.watcher = watcher([self.status_path]) self.watcher.fileChanged.connect(self.status_changed)