Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/src/tray.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ class SystemTray {
String? title,
String? toolTip,
bool isTemplate = false,
bool isInstalled = false,
}) async {
bool value = await _platformChannel.invokeMethod(
_kInitSystemTray,
<String, dynamic>{
_kTrayIdKey: const Uuid().v1(),
_kTitleKey: title,
_kIconPathKey: await Utils.getIcon(iconPath),
_kIconPathKey: isInstalled ? iconPath : await Utils.getIcon(iconPath),
_kToolTipKey: toolTip,
_kIsTemplateKey: isTemplate,
},
Expand All @@ -63,12 +64,13 @@ class SystemTray {
String? iconPath,
String? toolTip,
bool isTemplate = false,
bool isInstalled = false,
}) async {
bool value = await _platformChannel.invokeMethod(
_kSetSystemTrayInfo,
<String, dynamic>{
_kTitleKey: title,
_kIconPathKey: await Utils.getIcon(iconPath),
_kIconPathKey: isInstalled ? iconPath : await Utils.getIcon(iconPath),
_kToolTipKey: toolTip,
_kIsTemplateKey: isTemplate,
},
Expand All @@ -77,8 +79,8 @@ class SystemTray {
}

/// (Windows\macOS\Linux) Sets the image associated with this tray icon
Future<void> setImage(String image, {bool isTemplate = false}) async {
await setSystemTrayInfo(iconPath: image, isTemplate: isTemplate);
Future<void> 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.
Expand Down
2 changes: 1 addition & 1 deletion linux/menu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion linux/system_tray_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down
20 changes: 7 additions & 13 deletions linux/tray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}

Expand All @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -396,4 +390,4 @@ int64_t Tray::get_context_menu_id() const {
return context_menu_id_;
}

#endif // NATIVE_C
#endif // NATIVE_C