diff --git a/lib/src/tray.dart b/lib/src/tray.dart index b1ed149..b5f64d4 100644 --- a/lib/src/tray.dart +++ b/lib/src/tray.dart @@ -43,13 +43,14 @@ class SystemTray { String? title, String? toolTip, bool isTemplate = false, + bool isInstalled = false, }) async { bool value = await _platformChannel.invokeMethod( _kInitSystemTray, { _kTrayIdKey: const Uuid().v1(), _kTitleKey: title, - _kIconPathKey: await Utils.getIcon(iconPath), + _kIconPathKey: isInstalled ? iconPath : await Utils.getIcon(iconPath), _kToolTipKey: toolTip, _kIsTemplateKey: isTemplate, }, @@ -63,12 +64,13 @@ class SystemTray { String? iconPath, String? toolTip, bool isTemplate = false, + bool isInstalled = false, }) async { bool value = await _platformChannel.invokeMethod( _kSetSystemTrayInfo, { _kTitleKey: title, - _kIconPathKey: await Utils.getIcon(iconPath), + _kIconPathKey: isInstalled ? iconPath : await Utils.getIcon(iconPath), _kToolTipKey: toolTip, _kIsTemplateKey: isTemplate, }, @@ -77,8 +79,8 @@ class SystemTray { } /// (Windows\macOS\Linux) Sets the image associated with this tray icon - Future setImage(String image, {bool isTemplate = false}) async { - await setSystemTrayInfo(iconPath: image, isTemplate: isTemplate); + Future setImage(String image, {bool isTemplate = false, bool isInstalled = false}) async { + await setSystemTrayInfo(iconPath: image, isTemplate: isTemplate, isInstalled: isInstalled); } /// (Windows\macOS) Sets the hover text for this tray icon. diff --git a/linux/menu.cc b/linux/menu.cc index 5fd53c4..4e73a50 100644 --- a/linux/menu.cc +++ b/linux/menu.cc @@ -325,7 +325,7 @@ GtkWidget* Menu::value_to_menu_item(int64_t menu_id, FlValue* value) { gtk_widget_show_all(menu_item); } else { - g_print("value_to_menu_item type:%s, label:%s\n", type, label); + // g_print("value_to_menu_item type:%s, label:%s\n", type, label); } if (!menu_item) { diff --git a/linux/system_tray_plugin.cc b/linux/system_tray_plugin.cc index 14b763a..a840a50 100644 --- a/linux/system_tray_plugin.cc +++ b/linux/system_tray_plugin.cc @@ -48,7 +48,7 @@ static void system_tray_plugin_handle_method_call(SystemTrayPlugin* self, const gchar* method = fl_method_call_get_name(method_call); - g_print("method call %s\n", method); + // g_print("method call %s\n", method); if (strcmp(method, kInitAppWindow) == 0 || strcmp(method, kShowAppWindow) == 0 || diff --git a/linux/tray.cc b/linux/tray.cc index 8f995a4..9656f3c 100644 --- a/linux/tray.cc +++ b/linux/tray.cc @@ -52,7 +52,11 @@ bool Tray::init_indicator_api() { break; } - void* handle = dlopen("libappindicator3.so.1", RTLD_LAZY); + void* handle = dlopen("libayatana-appindicator3.so.1", RTLD_LAZY); + if (!handle) { + handle = dlopen("libappindicator3.so.1", RTLD_LAZY); + } + if (!handle) { break; } @@ -79,8 +83,7 @@ bool Tray::init_indicator_api() { if (!app_indicator_new_ || !app_indicator_set_status_ || !app_indicator_set_icon_full_ || !app_indicator_set_attention_icon_full_ || !app_indicator_set_label_ || - !app_indicator_set_label_ || !app_indicator_get_label_ || - !app_indicator_set_menu_) { + !app_indicator_get_label_ || !app_indicator_set_menu_) { break; } @@ -93,8 +96,6 @@ bool Tray::init_indicator_api() { } bool Tray::create_indicator(const char* tray_id) { - // printf("SystemTray::create_indicator tray_id: %s\n", tray_id); - bool ret = false; do { @@ -144,8 +145,6 @@ void Tray::handle_method_call(FlMethodCall* method_call) { const gchar* method = fl_method_call_get_name(method_call); FlValue* args = fl_method_call_get_args(method_call); - // g_print("method call %s\n", method); - if (strcmp(method, kInitSystemTray) == 0) { response = init_tray(args); } else if (strcmp(method, kSetSystemTrayInfo) == 0) { @@ -335,11 +334,6 @@ bool Tray::init_tray(const char* tray_id) { bool Tray::set_tray_info(const char* title, const char* icon_path, const char* toolTip) { - printf( - "SystemTray::set_system_tray_info title: %s, icon_path: %s, toolTip: " - "%s\n", - title, icon_path, toolTip); - bool ret = false; do { @@ -396,4 +390,4 @@ int64_t Tray::get_context_menu_id() const { return context_menu_id_; } -#endif // NATIVE_C \ No newline at end of file +#endif // NATIVE_C