Blame SOURCES/0001-network-Update-VPN-empty-label-status-after-removing.patch

cee2d4
From 3f089ddbd8cc304c563b4ed8cfbc59d27ffadc00 Mon Sep 17 00:00:00 2001
cee2d4
From: Carlos Garnacho <carlosg@gnome.org>
cee2d4
Date: Thu, 12 Dec 2019 22:43:15 +0100
cee2d4
Subject: [PATCH] network: Update VPN empty label status after removing VPN
cee2d4
 connection
cee2d4
cee2d4
Being the VPN list actually a collection of listboxes, this function
cee2d4
ensures it looks alright in other places. However the case of removing
cee2d4
all VPN connections till we're back empty was missed.
cee2d4
---
cee2d4
 panels/network/cc-network-panel.c | 29 +++++++++++++++++++++++++++++
cee2d4
 1 file changed, 29 insertions(+)
cee2d4
cee2d4
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
cee2d4
index 1a072a65a..f08d9b939 100644
cee2d4
--- a/panels/network/cc-network-panel.c
cee2d4
+++ b/panels/network/cc-network-panel.c
cee2d4
@@ -761,6 +761,33 @@ notify_connection_added_cb (NMClient           *client,
cee2d4
         add_connection (panel, NM_CONNECTION (connection));
cee2d4
 }
cee2d4
 
cee2d4
+static void
cee2d4
+notify_connection_removed_cb (NMClient           *client,
cee2d4
+                              NMRemoteConnection *connection,
cee2d4
+                              CcNetworkPanel     *panel)
cee2d4
+{
cee2d4
+        guint i;
cee2d4
+
cee2d4
+        for (i = 0; i < panel->devices->len; i++) {
cee2d4
+                NetObject *object = g_ptr_array_index (panel->devices, i);
cee2d4
+                NMConnection *vpn_conn;
cee2d4
+                gboolean equal;
cee2d4
+
cee2d4
+                if (!NET_IS_VPN (object))
cee2d4
+                        continue;
cee2d4
+
cee2d4
+                g_object_get (object, "connection", &vpn_conn, NULL);
cee2d4
+                equal = vpn_conn == NM_CONNECTION (connection);
cee2d4
+                g_object_unref (vpn_conn);
cee2d4
+
cee2d4
+                if (equal) {
cee2d4
+                        g_ptr_array_remove (panel->devices, object);
cee2d4
+                        update_vpn_section (panel);
cee2d4
+                        return;
cee2d4
+                }
cee2d4
+        }
cee2d4
+}
cee2d4
+
cee2d4
 static void
cee2d4
 panel_check_network_manager_version (CcNetworkPanel *panel)
cee2d4
 {
cee2d4
@@ -912,6 +939,8 @@ cc_network_panel_init (CcNetworkPanel *panel)
cee2d4
         /* add remote settings such as VPN settings as virtual devices */
cee2d4
         g_signal_connect (panel->client, NM_CLIENT_CONNECTION_ADDED,
cee2d4
                           G_CALLBACK (notify_connection_added_cb), panel);
cee2d4
+        g_signal_connect (panel->client, NM_CLIENT_CONNECTION_REMOVED,
cee2d4
+                          G_CALLBACK (notify_connection_removed_cb), panel);
cee2d4
 
cee2d4
         toplevel = gtk_widget_get_toplevel (GTK_WIDGET (panel));
cee2d4
         g_signal_connect_after (toplevel, "map", G_CALLBACK (on_toplevel_map), panel);
cee2d4
-- 
cee2d4
2.23.0
cee2d4