Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 25, 2025

This PR implements complete Linux support for the TrayManager class, providing system tray functionality on Linux platforms using GTK3.

What's implemented

TrayManager (src/platform/linux/tray_manager_linux.cpp)

  • Creates and manages system tray icons using GTK StatusIcon
  • Provides thread-safe unique ID generation for tray instances
  • Implements Create(), Get(TrayID), and GetAll() methods matching the existing interface

Tray (src/platform/linux/tray_linux.cpp)

  • Full system tray icon functionality using GTK StatusIcon APIs
  • Icon support for base64 encoded images, file paths, and stock GTK icons
  • Title and tooltip functionality with proper GTK widget integration
  • Context menu support with Menu object lifecycle management
  • Bounds detection using GTK geometry APIs
  • Proper resource cleanup using the pimpl pattern

Menu (src/platform/linux/menu_linux.cpp)

  • GTK menu and menu item implementations
  • Support for adding/removing items and separators
  • MenuItem creation with title, icon, and tooltip support
  • Native GTK menu widget access for integration

Example usage

#include "tray_manager.h"

// Create tray manager
nativeapi::TrayManager trayManager;

// Create a new tray
auto tray = trayManager.Create();
tray->SetTitle("My App");
tray->SetTooltip("Application running in background");
tray->SetIcon("gtk-info");  // Stock icon or file path

// Create context menu
nativeapi::Menu menu;
auto menuItem = menu.CreateItem("Exit");
menu.AddItem(menuItem);
tray->SetContextMenu(menu);

Technical details

  • Uses GTK3 StatusIcon (though deprecated, still widely supported across Linux desktop environments)
  • Implements proper base64 image decoding with automatic scaling to 24x24 pixels
  • Maintains API compatibility with existing macOS implementation
  • Follows the established pimpl pattern for clean platform abstraction
  • All implementations compile successfully and pass basic functionality tests

The implementation provides feature parity with the macOS TrayManager while leveraging native Linux desktop integration through GTK3.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits August 25, 2025 23:33
Co-authored-by: lijy91 <3889523+lijy91@users.noreply.github.com>
…ssful testing

Co-authored-by: lijy91 <3889523+lijy91@users.noreply.github.com>
Co-authored-by: lijy91 <3889523+lijy91@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] [Linux] Implement TrayManager class [Linux] Implement TrayManager class with full GTK3 support Aug 25, 2025
Copilot finished work on behalf of lijy91 August 25, 2025 23:38
@Copilot Copilot AI requested a review from lijy91 August 25, 2025 23:38
@lijy91 lijy91 marked this pull request as ready for review August 25, 2025 23:40
@lijy91 lijy91 merged commit 498f23b into main Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants