Description: Launch to system tray without display app window Author: YOSHIOKA Takuma Origin: upstream Bug: https://github.com/jgke/connman-gtk/pull/39 Last-Update: 2022-02-11 --- --- a/src/main.c +++ b/src/main.c @@ -600,9 +600,11 @@ { g_bus_get(G_BUS_TYPE_SYSTEM, NULL, dbus_connected, NULL); - config_load(app); if(no_icon) status_icon_enabled = FALSE; + else if(launch_to_tray) + status_icon_enabled = TRUE; + no_icon = FALSE; main_window = gtk_application_window_new(app); g_signal_connect(app, "window-removed", @@ -614,13 +616,9 @@ create_content(); g_signal_connect(G_OBJECT(main_window), "key_press_event", G_CALLBACK(handle_keyboard_shortcut), NULL); - gtk_widget_show_all(main_window); #ifdef USE_STATUS_ICON if(status_icon_enabled && !no_icon) { - if(launch_to_tray) - gtk_widget_hide(main_window); - g_signal_connect(main_window, "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), main_window); @@ -632,8 +630,15 @@ static void activate(GtkApplication *app, gpointer user_data) { #ifdef USE_STATUS_ICON - if(!launch_to_tray) - gtk_widget_show(main_window); + static gboolean window_has_shown = FALSE; + if(!launch_to_tray || !status_icon_enabled || no_icon) { + if(window_has_shown) + gtk_widget_show(main_window); + else + gtk_widget_show_all(main_window); + + window_has_shown = TRUE; + } launch_to_tray = FALSE; #endif } @@ -687,6 +692,7 @@ (GDestroyNotify)remove_service_struct); app = gtk_application_new(NULL, G_APPLICATION_FLAGS_NONE); + config_load(app); g_application_add_main_option_entries(G_APPLICATION(app), options); g_signal_connect(app, "startup", G_CALLBACK(startup), NULL); g_signal_connect(app, "activate", G_CALLBACK(activate), NULL); --- a/data/net.connman.gtk.gschema.xml +++ b/data/net.connman.gtk.gschema.xml @@ -4,7 +4,7 @@ true - false + true false