From 71fc222059abde1f31cbb5f25406491ba0ba48b3 Mon Sep 17 00:00:00 2001 From: Travis McLane Date: Thu, 21 Sep 2023 15:56:51 -0500 Subject: [PATCH] [v3 linux] systray: cleanup + add basic menu --- v3/pkg/application/linux_cgo.go | 17 +++-------------- v3/pkg/application/systemtray_linux.go | 5 +++++ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/v3/pkg/application/linux_cgo.go b/v3/pkg/application/linux_cgo.go index 49443ad5a..7413afff8 100644 --- a/v3/pkg/application/linux_cgo.go +++ b/v3/pkg/application/linux_cgo.go @@ -1157,9 +1157,9 @@ func systrayNew(label string) pointer { indicator := C.app_indicator_new(labelStr, labelStr, C.APP_INDICATOR_CATEGORY_APPLICATION_STATUS) trayMenu := C.gtk_menu_new() - // item := C.gtk_menu_item_new_with_label(labelStr) - // C.gtk_menu_shell_append((*C.GtkMenuShell)(unsafe.Pointer(trayMenu)), item) - // C.gtk_widget_show(item) + item := C.gtk_menu_item_new_with_label(labelStr) + C.gtk_menu_shell_append((*C.GtkMenuShell)(unsafe.Pointer(trayMenu)), item) + C.gtk_widget_show(item) C.app_indicator_set_status(indicator, C.APP_INDICATOR_STATUS_ACTIVE) C.app_indicator_set_menu(indicator, (*C.GtkMenu)(unsafe.Pointer(trayMenu))) iconStr := C.CString("wails-systray-icon") @@ -1187,17 +1187,6 @@ func systrayMenuSet(tray pointer, menu pointer) { // C.app_indicator_set_menu((*C.AppIndicator)(tray), (*C.GtkMenu)(unsafe.Pointer(menu))) } -/* -GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(icon_file_path, NULL); -int width, height; -gdk_pixbuf_get_file_info (icon_file_path, &width, &height); -gtk_icon_theme_add_builtin_icon ("custom_icon", width, pixbuf); -g_object_unref (G_OBJECT (pixbuf)); - -GtkToolItem *toolbar_item = gtk_toggle_tool_button_new(); -gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON(toolbar_item), "custom_icon"); -*/ - func systraySetTemplateIcon(tray pointer, icon []byte) { dirname, err := os.UserHomeDir() if err != nil { diff --git a/v3/pkg/application/systemtray_linux.go b/v3/pkg/application/systemtray_linux.go index 7503d451c..1a97b6504 100644 --- a/v3/pkg/application/systemtray_linux.go +++ b/v3/pkg/application/systemtray_linux.go @@ -95,6 +95,11 @@ func newSystemTrayImpl(s *SystemTray) systemTrayImpl { isTemplateIcon: s.isTemplateIcon, } } +func (s *linuxSystemTray) openMenu() { + if s.tray == nil { + return + } +} func (s *linuxSystemTray) openMenu() { }