network: Remove net_object_emit_removed
This commit is contained in:
parent
577762b60c
commit
2752f38a72
4 changed files with 22 additions and 49 deletions
|
@ -234,17 +234,6 @@ cc_network_panel_get_help_uri (CcPanel *self)
|
||||||
return "help:gnome-help/net";
|
return "help:gnome-help/net";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
object_removed_cb (CcNetworkPanel *self, NetObject *object)
|
|
||||||
{
|
|
||||||
GtkWidget *widget;
|
|
||||||
|
|
||||||
/* remove device */
|
|
||||||
widget = g_hash_table_lookup (self->device_to_widget, object);
|
|
||||||
if (widget != NULL)
|
|
||||||
gtk_widget_destroy (widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
panel_refresh_device_titles (CcNetworkPanel *self)
|
panel_refresh_device_titles (CcNetworkPanel *self)
|
||||||
{
|
{
|
||||||
|
@ -483,22 +472,22 @@ panel_add_device (CcNetworkPanel *self, NMDevice *device)
|
||||||
* be handled by the future Mobile Broadband panel */
|
* be handled by the future Mobile Broadband panel */
|
||||||
if (NET_IS_DEVICE_BLUETOOTH (net_device))
|
if (NET_IS_DEVICE_BLUETOOTH (net_device))
|
||||||
update_bluetooth_section (self);
|
update_bluetooth_section (self);
|
||||||
|
|
||||||
g_signal_connect_object (net_device, "removed",
|
|
||||||
G_CALLBACK (object_removed_cb), self, G_CONNECT_SWAPPED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
panel_remove_device (CcNetworkPanel *self, NMDevice *device)
|
panel_remove_device (CcNetworkPanel *self, NMDevice *device)
|
||||||
{
|
{
|
||||||
NetObject *net_device = NULL;
|
NetObject *net_device = NULL;
|
||||||
|
GtkWidget *widget;
|
||||||
|
|
||||||
net_device = g_hash_table_lookup (self->nm_device_to_device, device);
|
net_device = g_hash_table_lookup (self->nm_device_to_device, device);
|
||||||
if (net_device == NULL)
|
if (net_device == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* NMObject will not fire the "removed" signal, so handle the UI removal explicitly */
|
widget = g_hash_table_lookup (self->device_to_widget, device);
|
||||||
object_removed_cb (self, net_device);
|
if (widget != NULL)
|
||||||
|
gtk_widget_destroy (widget);
|
||||||
|
|
||||||
g_ptr_array_remove (self->bluetooth_devices, net_device);
|
g_ptr_array_remove (self->bluetooth_devices, net_device);
|
||||||
g_ptr_array_remove (self->ethernet_devices, net_device);
|
g_ptr_array_remove (self->ethernet_devices, net_device);
|
||||||
g_ptr_array_remove (self->mobile_devices, net_device);
|
g_ptr_array_remove (self->mobile_devices, net_device);
|
||||||
|
@ -620,8 +609,7 @@ panel_add_vpn_device (CcNetworkPanel *self, NMConnection *connection)
|
||||||
/* add as a VPN object */
|
/* add as a VPN object */
|
||||||
net_vpn = net_vpn_new (connection,
|
net_vpn = net_vpn_new (connection,
|
||||||
self->client);
|
self->client);
|
||||||
g_signal_connect_object (net_vpn, "removed",
|
|
||||||
G_CALLBACK (object_removed_cb), self, G_CONNECT_SWAPPED);
|
|
||||||
|
|
||||||
/* add as a panel */
|
/* add as a panel */
|
||||||
add_object (self, NET_OBJECT (net_vpn), GTK_CONTAINER (self->box_vpn));
|
add_object (self, NET_OBJECT (net_vpn), GTK_CONTAINER (self->box_vpn));
|
||||||
|
@ -636,8 +624,7 @@ panel_add_vpn_device (CcNetworkPanel *self, NMConnection *connection)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_connection (CcNetworkPanel *self,
|
add_connection (CcNetworkPanel *self, NMConnection *connection)
|
||||||
NMConnection *connection)
|
|
||||||
{
|
{
|
||||||
NMSettingConnection *s_con;
|
NMSettingConnection *s_con;
|
||||||
const gchar *type, *iface;
|
const gchar *type, *iface;
|
||||||
|
@ -661,9 +648,19 @@ add_connection (CcNetworkPanel *self,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
notify_connection_added_cb (CcNetworkPanel *self, NMRemoteConnection *connection)
|
client_connection_removed_cb (CcNetworkPanel *self, NMConnection *connection)
|
||||||
{
|
{
|
||||||
add_connection (self, NM_CONNECTION (connection));
|
guint i;
|
||||||
|
|
||||||
|
for (i = 0; i < self->vpns->len; i++) {
|
||||||
|
NetVpn *vpn = g_ptr_array_index (self->vpns, i);
|
||||||
|
if (net_vpn_get_connection (vpn) == connection) {
|
||||||
|
GtkWidget *widget = g_hash_table_lookup (self->device_to_widget, vpn);
|
||||||
|
if (widget != NULL)
|
||||||
|
gtk_widget_destroy (widget);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -813,7 +810,9 @@ cc_network_panel_init (CcNetworkPanel *self)
|
||||||
|
|
||||||
/* add remote settings such as VPN settings as virtual devices */
|
/* add remote settings such as VPN settings as virtual devices */
|
||||||
g_signal_connect_object (self->client, NM_CLIENT_CONNECTION_ADDED,
|
g_signal_connect_object (self->client, NM_CLIENT_CONNECTION_ADDED,
|
||||||
G_CALLBACK (notify_connection_added_cb), self, G_CONNECT_SWAPPED);
|
G_CALLBACK (add_connection), self, G_CONNECT_SWAPPED);
|
||||||
|
g_signal_connect_object (self->client, NM_CLIENT_CONNECTION_REMOVED,
|
||||||
|
G_CALLBACK (client_connection_removed_cb), self, G_CONNECT_SWAPPED);
|
||||||
|
|
||||||
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
|
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
|
||||||
g_signal_connect_after (toplevel, "map", G_CALLBACK (on_toplevel_map), self);
|
g_signal_connect_after (toplevel, "map", G_CALLBACK (on_toplevel_map), self);
|
||||||
|
|
|
@ -39,7 +39,6 @@ enum {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SIGNAL_CHANGED,
|
SIGNAL_CHANGED,
|
||||||
SIGNAL_REMOVED,
|
|
||||||
SIGNAL_LAST
|
SIGNAL_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -53,13 +52,6 @@ net_object_emit_changed (NetObject *self)
|
||||||
g_signal_emit (self, signals[SIGNAL_CHANGED], 0);
|
g_signal_emit (self, signals[SIGNAL_CHANGED], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
net_object_emit_removed (NetObject *self)
|
|
||||||
{
|
|
||||||
g_return_if_fail (NET_IS_OBJECT (self));
|
|
||||||
g_signal_emit (self, signals[SIGNAL_REMOVED], 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
net_object_get_title (NetObject *self)
|
net_object_get_title (NetObject *self)
|
||||||
{
|
{
|
||||||
|
@ -165,12 +157,6 @@ net_object_class_init (NetObjectClass *klass)
|
||||||
0,
|
0,
|
||||||
NULL, NULL, g_cclosure_marshal_VOID__VOID,
|
NULL, NULL, g_cclosure_marshal_VOID__VOID,
|
||||||
G_TYPE_NONE, 0);
|
G_TYPE_NONE, 0);
|
||||||
signals[SIGNAL_REMOVED] =
|
|
||||||
g_signal_new ("removed",
|
|
||||||
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
|
|
||||||
0,
|
|
||||||
NULL, NULL, g_cclosure_marshal_VOID__VOID,
|
|
||||||
G_TYPE_NONE, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -46,7 +46,6 @@ const gchar *net_object_get_title (NetObject *object)
|
||||||
void net_object_set_title (NetObject *object,
|
void net_object_set_title (NetObject *object,
|
||||||
const gchar *title);
|
const gchar *title);
|
||||||
void net_object_emit_changed (NetObject *object);
|
void net_object_emit_changed (NetObject *object);
|
||||||
void net_object_emit_removed (NetObject *object);
|
|
||||||
GtkWidget *net_object_get_widget (NetObject *object,
|
GtkWidget *net_object_get_widget (NetObject *object,
|
||||||
GtkSizeGroup *heading_size_group);
|
GtkSizeGroup *heading_size_group);
|
||||||
|
|
||||||
|
|
|
@ -60,13 +60,6 @@ connection_changed_cb (NetVpn *self)
|
||||||
nm_device_refresh_vpn_ui (self);
|
nm_device_refresh_vpn_ui (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
connection_removed_cb (NetVpn *self, NMConnection *connection)
|
|
||||||
{
|
|
||||||
if (self->connection == connection)
|
|
||||||
net_object_emit_removed (NET_OBJECT (self));
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
vpn_proxy_get_widget (NetObject *object,
|
vpn_proxy_get_widget (NetObject *object,
|
||||||
GtkSizeGroup *heading_size_group)
|
GtkSizeGroup *heading_size_group)
|
||||||
|
@ -261,10 +254,6 @@ net_vpn_new (NMConnection *connection,
|
||||||
self->client = g_object_ref (client);
|
self->client = g_object_ref (client);
|
||||||
self->connection = g_object_ref (connection);
|
self->connection = g_object_ref (connection);
|
||||||
|
|
||||||
g_signal_connect_object (self->client,
|
|
||||||
NM_CLIENT_CONNECTION_REMOVED,
|
|
||||||
G_CALLBACK (connection_removed_cb),
|
|
||||||
self, G_CONNECT_SWAPPED);
|
|
||||||
g_signal_connect_object (connection,
|
g_signal_connect_object (connection,
|
||||||
NM_CONNECTION_CHANGED,
|
NM_CONNECTION_CHANGED,
|
||||||
G_CALLBACK (connection_changed_cb),
|
G_CALLBACK (connection_changed_cb),
|
||||||
|
|
Loading…
Add table
Reference in a new issue