| 1 |
Description: Launch to system tray without display app window |
| 2 |
Author: YOSHIOKA Takuma |
| 3 |
Origin: upstream |
| 4 |
Bug: https://github.com/jgke/connman-gtk/pull/39 |
| 5 |
Last-Update: 2022-02-11 |
| 6 |
--- |
| 7 |
--- a/src/main.c |
| 8 |
+++ b/src/main.c |
| 9 |
@@ -600,9 +600,11 @@ |
| 10 |
{ |
| 11 |
g_bus_get(G_BUS_TYPE_SYSTEM, NULL, dbus_connected, NULL); |
| 12 |
|
| 13 |
|
| 14 |
if(no_icon) |
| 15 |
status_icon_enabled = FALSE; |
| 16 |
+ else if(launch_to_tray) |
| 17 |
+ status_icon_enabled = TRUE; |
| 18 |
+ no_icon = FALSE; |
| 19 |
|
| 20 |
main_window = gtk_application_window_new(app); |
| 21 |
g_signal_connect(app, "window-removed", |
| 22 |
@@ -614,13 +616,9 @@ |
| 23 |
create_content(); |
| 24 |
|
| 25 |
g_signal_connect(G_OBJECT(main_window), "key_press_event", G_CALLBACK(handle_keyboard_shortcut), NULL); |
| 26 |
|
| 27 |
|
| 28 |
#ifdef USE_STATUS_ICON |
| 29 |
if(status_icon_enabled && !no_icon) { |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
g_signal_connect(main_window, "delete-event", |
| 34 |
G_CALLBACK(gtk_widget_hide_on_delete), |
| 35 |
main_window); |
| 36 |
@@ -632,8 +630,15 @@ |
| 37 |
static void activate(GtkApplication *app, gpointer user_data) |
| 38 |
{ |
| 39 |
#ifdef USE_STATUS_ICON |
| 40 |
|
| 41 |
|
| 42 |
+ static gboolean window_has_shown = FALSE; |
| 43 |
+ if(!launch_to_tray || !status_icon_enabled || no_icon) { |
| 44 |
+ if(window_has_shown) |
| 45 |
+ gtk_widget_show(main_window); |
| 46 |
+ else |
| 47 |
+ gtk_widget_show_all(main_window); |
| 48 |
+ |
| 49 |
+ window_has_shown = TRUE; |
| 50 |
+ } |
| 51 |
launch_to_tray = FALSE; |
| 52 |
#endif |
| 53 |
} |
| 54 |
@@ -687,6 +692,7 @@ |
| 55 |
(GDestroyNotify)remove_service_struct); |
| 56 |
|
| 57 |
app = gtk_application_new(NULL, G_APPLICATION_FLAGS_NONE); |
| 58 |
+ config_load(app); |
| 59 |
g_application_add_main_option_entries(G_APPLICATION(app), options); |
| 60 |
g_signal_connect(app, "startup", G_CALLBACK(startup), NULL); |
| 61 |
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL); |
| 62 |
--- a/data/net.connman.gtk.gschema.xml |
| 63 |
+++ b/data/net.connman.gtk.gschema.xml |
| 64 |
@@ -4,7 +4,7 @@ |
| 65 |
<default>true</default> |
| 66 |
</key> |
| 67 |
<key name="launch-to-tray" type="b"> |
| 68 |
|
| 69 |
+ <default>true</default> |
| 70 |
</key> |
| 71 |
<key name="openconnect-use-fsid-by-default" type="b"> |
| 72 |
<default>false</default> |