systray: Appindicator tweaks

- Prefer ayatana if it's available, since that's the modern library
- Fix some pylint and code coverage issues

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2020-11-16 10:22:34 -05:00
parent ac7e6a0966
commit 7541065d09

View File

@ -6,6 +6,7 @@
import os import os
import gi
from gi.repository import Gio from gi.repository import Gio
from gi.repository import Gtk from gi.repository import Gtk
@ -16,16 +17,22 @@ from . import vmmenu
from .baseclass import vmmGObject from .baseclass import vmmGObject
from .connmanager import vmmConnectionManager from .connmanager import vmmConnectionManager
try:
# pylint: disable=ungrouped-imports # pylint: disable=ungrouped-imports
import gi # Prefer AyatantaAppIndicator3 which is the modern maintained
gi.require_version('AppIndicator3', '0.1') # appindicator library.
from gi.repository import AppIndicator3 try: # pragma: no cover
# pylint: disable=no-name-in-module
gi.require_version('AyatanaAppIndicator3', '0.1')
from gi.repository import AyatanaAppIndicator3 as AppIndicator3
except Exception: # pragma: no cover except Exception: # pragma: no cover
AppIndicator3 = None AppIndicator3 = None
try:
gi.require_version('AyatanaAppIndicator3', '0.1') if not AppIndicator3:
from gi.repository import AyatanaAppIndicator3 as AppIndicator3 try: # pragma: no cover
# pylint: disable=no-name-in-module
gi.require_version('AppIndicator3', '0.1')
from gi.repository import AppIndicator3
except Exception: # pragma: no cover except Exception: # pragma: no cover
AppIndicator3 = None AppIndicator3 = None
@ -74,6 +81,7 @@ def _has_appindicator_dbus(): # pragma: no cover
_USING_APPINDICATOR = False _USING_APPINDICATOR = False
if AppIndicator3: # pragma: no cover if AppIndicator3: # pragma: no cover
log.debug("Imported AppIndicator3=%s", AppIndicator3)
if not _has_appindicator_dbus(): if not _has_appindicator_dbus():
log.debug("AppIndicator3 is available, but didn't " log.debug("AppIndicator3 is available, but didn't "
"find any dbus watcher.") "find any dbus watcher.")