Skip to content

Commit

Permalink
[linux] add InitWidget() to run in external message loop
Browse files Browse the repository at this point in the history
  • Loading branch information
yapus committed Oct 16, 2019
1 parent 86a0290 commit 04779f7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions platform/darwin/tray.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ void native_loop() {
[NSApp run];
}

void external_main_loop() {
}

void exit_loop() {
// Clear all notifications.
[[NSUserNotificationCenter defaultUserNotificationCenter] removeAllDeliveredNotifications];
Expand Down
6 changes: 5 additions & 1 deletion platform/linux/tray.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void init(const char* title, struct image imageData)

void native_loop()
{
gtk_widget_show_all(menu);
external_main_loop();
gtk_main ();
}

Expand All @@ -157,5 +157,9 @@ void exit_loop()
gtk_main_quit();
}

void external_main_loop() {
gtk_widget_show_all(menu);
}


#endif // NATIVE_C
4 changes: 4 additions & 0 deletions platform/windows/tray.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ void clear_menu_items()
}
}

void external_main_loop ()
{
}

void native_loop()
{
MSG msg;
Expand Down
5 changes: 5 additions & 0 deletions trayhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ func Exit() {
C.exit_loop()
}

// init widget for running in other gtk_main loop
func InitWidget() {
C.external_main_loop()
}

// SeparatorMenuItem creates a separator MenuItem.
func SeparatorMenuItem() MenuItem { return MenuItem{Title: ""} }

Expand Down

0 comments on commit 04779f7

Please sign in to comment.