From 09a3ee6506efdb623581b43494a76c843ed5a379 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sat, 26 Nov 2011 11:39:25 +0000 Subject: [PATCH] #43: when it comes to system trays, Ubuntu is a disaster: detect the os version and only use their "appindicator" API if we really have to (that is release 11.10 - and later?) git-svn-id: https://xpra.org/svn/Xpra/trunk@310 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/xposix/gui.py | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/xpra/xposix/gui.py b/src/xpra/xposix/gui.py index 02739c06d5..ea324e5f7c 100644 --- a/src/xpra/xposix/gui.py +++ b/src/xpra/xposix/gui.py @@ -116,9 +116,39 @@ def hide_tray(self): (if one succeeds) """ pass + def _is_ubuntu_11_10_or_later(self): + lsb = "/etc/lsb-release" + if not os.path.exists(lsb): + return False + try: + try: + f = open(lsb, mode='rb') + data = f.read() + finally: + f.close() + props = {} + for l in data.splitlines(): + parts = l.split("=", 1) + if len(parts)!=2: + continue + props[parts[0].strip()] = parts[1].strip() + log("found lsb properties: %s", props) + if props.get("DISTRIB_ID")=="Ubuntu": + version = [int(x) for x in props.get("DISTRIB_RELEASE", "0").split(".")] + log("detected Ubuntu release %s", version) + return version>=[11,10] + except: + return False + def setup_tray(self, tray_icon_filename): - if not self.setup_appindicator(tray_icon_filename) and not self.setup_statusicon(tray_icon_filename): - log.error("failed to setup gtk.StatusIcon and appindicator, there will be no system-tray icon") + """ choose the most appropriate tray implementation + Ubuntu is a disaster in this area, see: + http://xpra.org/trac/ticket/43#comment:8 + """ + if self._is_ubuntu_11_10_or_later() and self.setup_appindicator(tray_icon_filename): + return + if not self.setup_statusicon(tray_icon_filename): + log.error("failed to setup system-tray") def setup_pynotify(self): self.dbus_id = os.environ.get("DBUS_SESSION_BUS_ADDRESS", "")