@@ -109,34 +109,53 @@ def start_indicator(self) -> None:
109109
110110 import gi
111111
112- # TODO(Martin): Get rid of this - https://github.com/Taiko2k/Tauon/issues/1316
113- gi .require_version ("Gtk" , "3.0" )
114- from gi .repository import Gtk
115-
116112 try :
117- gi .require_version ("AyatanaAppIndicator3" , "0.1" )
118- from gi .repository import AyatanaAppIndicator3 as AppIndicator3
113+ gi .require_version ("AyatanaAppIndicatorGlib" , "2.0" )
114+ from gi .repository import AyatanaAppIndicatorGlib , Gio
115+ self .loaded_indicator = "AyatanaAppIndicatorGlib"
119116 except Exception :
120- logging .exception ("Failed to load AyatanaAppIndicator3" )
121- gi .require_version ("AppIndicator3" , "0.1" )
122- from gi .repository import AppIndicator3
123-
124- self .indicator = AppIndicator3 .Indicator .new (
125- "Tauon" ,
126- self .tauon .get_tray_icon ("tray-indicator-default" ),
127- AppIndicator3 .IndicatorCategory .APPLICATION_STATUS ,
128- )
129- self .indicator .set_status (AppIndicator3 .IndicatorStatus .ACTIVE ) # 1
117+ logging .exception ("Failed to load AyatanaAppIndicatorGlib" )
118+ # TODO(Martin): Get rid of this - https://github.com/Taiko2k/Tauon/issues/1316
119+ gi .require_version ("Gtk" , "3.0" )
120+ from gi .repository import Gtk
121+ try :
122+ gi .require_version ("AyatanaAppIndicator3" , "0.1" )
123+ from gi .repository import AyatanaAppIndicator3 as AppIndicator3
124+ self .loaded_indicator = "AyatanaAppIndicator3"
125+ except Exception :
126+ logging .exception ("Failed to load AyatanaAppIndicator3" )
127+ gi .require_version ("AppIndicator3" , "0.1" )
128+ from gi .repository import AppIndicator3
129+ self .loaded_indicator = "AppIndicator3"
130+
131+ if self .loaded_indicator == "AyatanaAppIndicatorGlib" :
132+ self .indicator = AyatanaAppIndicatorGlib .Indicator .new (
133+ "Tauon" ,
134+ self .tauon .get_tray_icon ("tray-indicator-default" ),
135+ AyatanaAppIndicatorGlib .IndicatorCategory .APPLICATION_STATUS ,
136+ )
137+ self .indicator .set_status (AyatanaAppIndicatorGlib .IndicatorStatus .ACTIVE ) # 1
138+ self .menu = Gio .Menu .new ()
139+ else :
140+ self .indicator = AppIndicator3 .Indicator .new (
141+ "Tauon" ,
142+ self .tauon .get_tray_icon ("tray-indicator-default" ),
143+ AppIndicator3 .IndicatorCategory .APPLICATION_STATUS ,
144+ )
145+ self .indicator .set_status (AppIndicator3 .IndicatorStatus .ACTIVE ) # 1
146+ self .menu = Gtk .Menu ()
130147 self .indicator .set_title (tauon .t_title )
131- self .menu = Gtk .Menu ()
132148
133149 def restore (_ ) -> None :
134150 tauon .request_raise ()
135151
136152 def menu_quit (_ ) -> None :
137153 logging .info ("Exit via tray" )
138154 tauon .exit ("Exit received from app indicator" )
139- self .indicator .set_status (AppIndicator3 .IndicatorStatus .PASSIVE ) # 0
155+ if self .loaded_indicator == "AyatanaAppIndicatorGlib" :
156+ self .indicator .set_status (AyatanaAppIndicatorGlib .IndicatorStatus .PASSIVE ) # 0
157+ else :
158+ self .indicator .set_status (AppIndicator3 .IndicatorStatus .PASSIVE ) # 0
140159
141160 def play_pause (_ ) -> None :
142161 pctl .play_pause ()
@@ -192,12 +211,12 @@ def update() -> None:
192211 if self .loaded_indicator == "AyatanaAppIndicatorGlib" :
193212 pActions = Gio .SimpleActionGroup .new ()
194213# self.menu.append(tauon.strings.menu_open_tauon, restore)
195- pSimpleAction = Gio .SimpleAction .new ( "showlabel " , None )
214+ pSimpleAction = Gio .SimpleAction .new ( "restore " , None )
196215 pActions .add_action (pSimpleAction )
197216 pSimpleAction .connect ("activate" , restore , 6 )
198- pItem = Gio .MenuItem .new (tauon .strings .menu_open_tauon , "indicator.showlabel " )
217+ pItem = Gio .MenuItem .new (tauon .strings .menu_open_tauon , "indicator.restore " )
199218 self .menu .append_item (pItem )
200-
219+ # TODO(Martin): Add rest of actions
201220 # TODO(Martin): Separator
202221# self.menu.append(tauon.strings.menu_play_pause, play_pause)
203222# self.menu.append(tauon.strings.menu_next, next)
0 commit comments