Try to create tray with AppIndicator3
(self)
| 239 | print("⚠️ System tray support not found. Tray disabled.") |
| 240 | |
| 241 | def _try_appindicator(self) -> bool: |
| 242 | """Try to create tray with AppIndicator3""" |
| 243 | try: |
| 244 | import gi |
| 245 | |
| 246 | gi.require_version("Gtk", "3.0") |
| 247 | gi.require_version("AppIndicator3", "0.1") |
| 248 | from gi.repository import AppIndicator3, GLib, Gtk |
| 249 | |
| 250 | # Create menu |
| 251 | menu = Gtk.Menu() |
| 252 | |
| 253 | # Menu items |
| 254 | item_show = Gtk.MenuItem(label="📂 Show Window") |
| 255 | item_show.connect( |
| 256 | "activate", lambda w: GLib.idle_add(self.app._show_window) |
| 257 | ) |
| 258 | menu.append(item_show) |
| 259 | |
| 260 | menu.append(Gtk.SeparatorMenuItem()) |
| 261 | |
| 262 | item_start = Gtk.MenuItem(label="▶️ Start") |
| 263 | item_start.connect("activate", lambda w: GLib.idle_add(self.app._start)) |
| 264 | menu.append(item_start) |
| 265 | |
| 266 | item_stop = Gtk.MenuItem(label="⏹️ Stop") |
| 267 | item_stop.connect("activate", lambda w: GLib.idle_add(self.app._stop)) |
| 268 | menu.append(item_stop) |
| 269 | |
| 270 | menu.append(Gtk.SeparatorMenuItem()) |
| 271 | |
| 272 | item_test = Gtk.MenuItem(label="🔍 API Test") |
| 273 | item_test.connect("activate", lambda w: GLib.idle_add(self.app._api_test)) |
| 274 | menu.append(item_test) |
| 275 | |
| 276 | menu.append(Gtk.SeparatorMenuItem()) |
| 277 | |
| 278 | item_quit = Gtk.MenuItem(label="❌ Exit") |
| 279 | item_quit.connect( |
| 280 | "activate", lambda w: GLib.idle_add(self.app._close_completely) |
| 281 | ) |
| 282 | menu.append(item_quit) |
| 283 | |
| 284 | menu.show_all() |
| 285 | |
| 286 | # Create AppIndicator |
| 287 | self.indicator = AppIndicator3.Indicator.new( |
| 288 | "aistudio-proxy", |
| 289 | "network-server", # Use system icon |
| 290 | AppIndicator3.IndicatorCategory.APPLICATION_STATUS, |
| 291 | ) |
| 292 | self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE) |
| 293 | self.indicator.set_menu(menu) |
| 294 | self.indicator.set_title("AI Studio Proxy") |
| 295 | |
| 296 | # Run GTK main loop in separate thread |
| 297 | def gtk_main(): |
| 298 | try: |
no test coverage detected