preferences: Disable systray option if we know it won't work

Basically on wayland, if appindicator isn't available

https://bugzilla.redhat.com/show_bug.cgi?id=1666597
This commit is contained in:
Cole Robinson 2019-06-14 20:04:35 -04:00
parent aabde5bbe6
commit 147a3b4790
2 changed files with 27 additions and 10 deletions

View File

@ -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):

View File

@ -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()