diff --git a/virtManager/preferences.py b/virtManager/preferences.py index 5e55ce7b4..e55262ea3 100644 --- a/virtManager/preferences.py +++ b/virtManager/preferences.py @@ -14,6 +14,7 @@ from virtinst import DomainCpu from . import uiutil from .baseclass import vmmGObjectUI from .inspection import vmmInspection +from .systray import vmmSystray class vmmPreferences(vmmGObjectUI): @@ -202,7 +203,12 @@ class vmmPreferences(vmmGObjectUI): ######################### def refresh_view_system_tray(self): + errmsg = vmmSystray.systray_disabled_message() val = self.config.get_view_system_tray() + if errmsg: + val = False + self.widget("prefs-system-tray").set_sensitive(not bool(errmsg)) + self.widget("prefs-system-tray").set_tooltip_text(errmsg) self.widget("prefs-system-tray").set_active(bool(val)) def refresh_xmleditor(self): diff --git a/virtManager/systray.py b/virtManager/systray.py index efbe8d56f..70e0a0633 100644 --- a/virtManager/systray.py +++ b/virtManager/systray.py @@ -5,6 +5,7 @@ # See the COPYING file in the top-level directory. import logging +import os from gi.repository import Gio from gi.repository import Gtk @@ -64,6 +65,16 @@ def _has_appindicator_dbus(): return False +_USING_APPINDICATOR = False +if AppIndicator3: + if not _has_appindicator_dbus(): + logging.debug("AppIndicator3 is available, but didn't " + "find any dbus watcher.") + else: + _USING_APPINDICATOR = True + logging.debug("Using AppIndicator3 for systray") + + ########################### # systray backend classes # ########################### @@ -143,21 +154,21 @@ class vmmSystray(vmmGObject): cls._instance = vmmSystray() return cls._instance + @staticmethod + def systray_disabled_message(): + if "WAYLAND_DISPLAY" not in os.environ: + return + if _USING_APPINDICATOR: + return + return ("No appindicator listener found, which is required " + "on wayland.") + def __init__(self): vmmGObject.__init__(self) self._cleanup_on_app_close() self.topwin = None # Need this for error callbacks from VMActionMenu self._systray = None - self._using_appindicator = False - - if AppIndicator3: - if not _has_appindicator_dbus(): - logging.debug("AppIndicator3 is available, but didn't " - "find any dbus watcher.") - else: - self._using_appindicator = True - logging.debug("Using AppIndicator3 for systray") connmanager = vmmConnectionManager.get_instance() connmanager.connect("conn-added", self._conn_added_cb) @@ -185,7 +196,7 @@ class vmmSystray(vmmGObject): def _show_systray(self): if not self._systray: - if self._using_appindicator: + if _USING_APPINDICATOR: self._systray = _SystrayIndicator() else: self._systray = _SystrayStatusIcon()