Skip to content

Commit

Permalink
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.

Ref BuddiesOfBudgie/budgie-desktop#446
Fixes #433

sem-ver: bug-fix

Signed-off-by: Evan Maddock <[email protected]>
  • Loading branch information
EbonJaeger committed Sep 7, 2023
1 parent dcbf64c commit adf86e4
Show file tree
Hide file tree
Showing 2 changed files with 17 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
release_summary: >
Enables the use of AyatanaAppIndicator for the tray icon
fixes:
- |
- tray icon broken with AppIndicator #433

0 comments on commit adf86e4

Please sign in to comment.