Skip to content

Commit

Permalink
indicator: Enable the use of AyatanaAppIndicator
Browse files Browse the repository at this point in the history
This uses the newer successor to AppIndicator3 for the tray icon implementation, with a fallback to the older AppIndicator3 if the Ayatana version is not found. AyatanaAppIndicator is backwards compatible with AppIndicator3, so the API remains the same. The icon is also fixed.

Tested on Solus 4.4 with Budgie Desktop 10.8.

Ref BuddiesOfBudgie/budgie-desktop#446
Fixes Guake#433

Signed-off-by: Evan Maddock <[email protected]>
  • Loading branch information
EbonJaeger committed Sep 7, 2023
1 parent dcbf64c commit 701ed34
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions guake/guake_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,25 @@ def load_schema():
# trayicon!
img = pixmapfile("guake-tray.png")
try:
import appindicator # pylint: disable=import-outside-toplevel
except ImportError:
try:
gi.require_version("AyatanaAppIndicator3", "0.1")
from gi.repository import AyatanaAppIndicator3 as appindicator # pylint: disable=import-outside-toplevel
except (ValueError, ImportError):
gi.require_version("AppIndicator3", "0.1")
from gi.repository import AppIndicator3 as appindicator # pylint: disable=import-outside-toplevel
except (ValueError, ImportError):
self.tray_icon = Gtk.StatusIcon()
self.tray_icon.set_from_file(img)
self.tray_icon.set_tooltip_text(_("Guake Terminal"))
self.tray_icon.connect("popup-menu", self.show_menu)
self.tray_icon.connect("activate", self.show_hide)
else:
# TODO PORT test this on a system with app indicator
self.tray_icon = appindicator.Indicator(
_("guake-indicator"), _("guake-tray"), appindicator.CATEGORY_OTHER
self.tray_icon = appindicator.Indicator.new(
"guake-indicator", "guake-tray", appindicator.IndicatorCategory.APPLICATION_STATUS
)
self.tray_icon.set_icon(img)
self.tray_icon.set_status(appindicator.STATUS_ACTIVE)
self.tray_icon.set_icon_full("guake-tray", _("Guake Terminal"))
self.tray_icon.set_status(appindicator.IndicatorStatus.ACTIVE)
menu = self.get_widget("tray-menu")
show = Gtk.MenuItem(_("Show"))
show.set_sensitive(True)
Expand Down

0 comments on commit 701ed34

Please sign in to comment.