Merge lp:~cyphermox/unity-control-center/rfkill-switch into lp:unity-control-center

Proposed by Mathieu Trudel-Lapierre on 2016-01-19
Status: Needs review
Proposed branch: lp:~cyphermox/unity-control-center/rfkill-switch
Merge into: lp:unity-control-center
Diff against target: 169 lines (+0/-124)
1 file modified
panels/network/cc-network-panel.c (+0/-124)
To merge this branch: bzr merge lp:~cyphermox/unity-control-center/rfkill-switch
Reviewer Review Type Date Requested Status
Iain Lane 2016-01-19 Needs Information on 2016-01-19
Review via email: mp+283107@code.launchpad.net

Commit message

Remove rfkill switch code.

Description of the change

Remove rfkill switch code.

To post a comment you must log in.
Iain Lane (laney) wrote :

This kind of comes out of the blue.

Please provide an explanation, preferably in the form of a bug report.

review: Needs Information
Mathieu Trudel-Lapierre (cyphermox) wrote :

Right, that addresses https://bugs.launchpad.net/oem-priority/+bug/1318875; which has been a long discussed topic already. Will Cooke also knows all about it.

The issue is that the existence of multiple ways of toggling Flight Mode or otherwise disabling and enabling wifi is very confusing to users. To add to that, flight mode has been an issue in the gnome-control-center codebase in the past, and used to break in fun ways. I suspect it's no longer the case, but since it doesn't actually really do flight mode properly (toggles various things with rfkill, but that isn't necessarily saved across reboots), the least bad option seems to be to get rid of the toggle.

Users will still be able to disable networking from nm-applet.

As an alternative, we'd have to figure out how to correctly save rfkill states across reboots (perhaps using urfkill, which we've carefully iterated on to do just that on phones). It will remain that multiple rfkill UI points is confusing.

Unmerged revisions

12844. By Mathieu Trudel-Lapierre on 2016-01-19

Remove rfkill switch code, since the Airplane Mode switch confuses people.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'panels/network/cc-network-panel.c'
2--- panels/network/cc-network-panel.c 2015-09-15 17:00:16 +0000
3+++ panels/network/cc-network-panel.c 2016-01-19 12:41:30 +0000
4@@ -38,8 +38,6 @@
5 #include "net-proxy.h"
6 #include "net-vpn.h"
7
8-#include "rfkill-glib.h"
9-
10 #include "panel-common.h"
11
12 #include "network-dialogs.h"
13@@ -70,12 +68,6 @@
14 guint nm_warning_idle;
15 guint refresh_idle;
16
17- /* Killswitch stuff */
18- GtkWidget *kill_switch_header;
19- CcRfkillGlib *rfkill;
20- GtkSwitch *rfkill_switch;
21- GHashTable *killswitches;
22-
23 /* wireless dialog stuff */
24 CmdlineOperation arg_operation;
25 gchar *arg_device;
26@@ -208,10 +200,6 @@
27 g_clear_object (&priv->builder);
28 g_clear_object (&priv->client);
29 g_clear_object (&priv->remote_settings);
30- g_clear_object (&priv->kill_switch_header);
31- g_clear_object (&priv->rfkill);
32- g_clear_pointer (&priv->killswitches, g_hash_table_destroy);
33- priv->rfkill_switch = NULL;
34
35 if (priv->refresh_idle != 0) {
36 g_source_remove (priv->refresh_idle);
37@@ -660,25 +648,6 @@
38 }
39
40 static void
41-cc_network_panel_notify_enable_active_cb (GtkSwitch *sw,
42- GParamSpec *pspec,
43- CcNetworkPanel *panel)
44-{
45- gboolean enable;
46- struct rfkill_event event;
47-
48- enable = gtk_switch_get_active (sw);
49- g_debug ("Setting killswitch to %d", enable);
50-
51- memset (&event, 0, sizeof(event));
52- event.op = RFKILL_OP_CHANGE_ALL;
53- event.type = RFKILL_TYPE_ALL;
54- event.soft = enable ? 1 : 0;
55- if (cc_rfkill_glib_send_event (panel->priv->rfkill, &event) < 0)
56- g_warning ("Setting the killswitch %s failed", enable ? "on" : "off");
57-}
58-
59-static void
60 connection_state_changed (NMActiveConnection *c, GParamSpec *pspec, CcNetworkPanel *panel)
61 {
62 }
63@@ -1017,96 +986,6 @@
64 }
65
66 static void
67-rfkill_changed (CcRfkillGlib *rfkill,
68- GList *events,
69- CcNetworkPanel *panel)
70-{
71- gboolean enabled;
72- GList *l;
73- GHashTableIter iter;
74- gpointer key, value;
75-
76- enabled = TRUE;
77-
78- for (l = events; l != NULL; l = l->next) {
79- struct rfkill_event *event = l->data;
80-
81- if (event->op == RFKILL_OP_ADD)
82- g_hash_table_insert (panel->priv->killswitches,
83- GINT_TO_POINTER (event->idx),
84- GINT_TO_POINTER (event->soft || event->hard));
85- else if (event->op == RFKILL_OP_CHANGE)
86- g_hash_table_insert (panel->priv->killswitches,
87- GINT_TO_POINTER (event->idx),
88- GINT_TO_POINTER (event->soft || event->hard));
89- else if (event->op == RFKILL_OP_DEL)
90- g_hash_table_remove (panel->priv->killswitches,
91- GINT_TO_POINTER (event->idx));
92- }
93-
94- g_hash_table_iter_init (&iter, panel->priv->killswitches);
95- while (g_hash_table_iter_next (&iter, &key, &value)) {
96- int idx, state;
97-
98- idx = GPOINTER_TO_INT (key);
99- state = GPOINTER_TO_INT (value);
100- g_debug ("Killswitch %d is %s", idx, state ? "enabled" : "disabled");
101-
102- /* A single device that's enabled? airplane mode is off */
103- if (state == FALSE) {
104- enabled = FALSE;
105- break;
106- }
107- }
108-
109- if (enabled != gtk_switch_get_active (panel->priv->rfkill_switch)) {
110- g_signal_handlers_block_by_func (panel->priv->rfkill_switch,
111- cc_network_panel_notify_enable_active_cb,
112- panel);
113- gtk_switch_set_active (panel->priv->rfkill_switch, enabled);
114- g_signal_handlers_unblock_by_func (panel->priv->rfkill_switch,
115- cc_network_panel_notify_enable_active_cb,
116- panel);
117- }
118-}
119-
120-static gboolean
121-network_add_shell_header_widgets_cb (gpointer user_data)
122-{
123- CcNetworkPanel *panel = CC_NETWORK_PANEL (user_data);
124- GtkWidget *box;
125- GtkWidget *label;
126- GtkWidget *widget;
127-
128- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
129- /* TRANSLATORS: this is to disable the radio hardware in the
130- * network panel */
131- label = gtk_label_new_with_mnemonic (_("Air_plane Mode"));
132- gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
133- gtk_widget_set_visible (label, TRUE);
134- widget = gtk_switch_new ();
135- gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
136- gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0);
137- gtk_widget_show_all (box);
138- panel->priv->rfkill_switch = GTK_SWITCH (widget);
139- cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (panel)), box);
140- panel->priv->kill_switch_header = g_object_ref (box);
141-
142- panel->priv->killswitches = g_hash_table_new (g_direct_hash, g_direct_equal);
143- panel->priv->rfkill = cc_rfkill_glib_new ();
144- g_signal_connect (G_OBJECT (panel->priv->rfkill), "changed",
145- G_CALLBACK (rfkill_changed), panel);
146- if (cc_rfkill_glib_open (panel->priv->rfkill) < 0)
147- gtk_widget_hide (box);
148-
149- g_signal_connect (panel->priv->rfkill_switch, "notify::active",
150- G_CALLBACK (cc_network_panel_notify_enable_active_cb),
151- panel);
152-
153- return FALSE;
154-}
155-
156-static void
157 cc_network_panel_init (CcNetworkPanel *panel)
158 {
159 DBusGConnection *bus = NULL;
160@@ -1198,9 +1077,6 @@
161 widget = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder,
162 "vbox1"));
163 gtk_widget_reparent (widget, (GtkWidget *) panel);
164-
165- /* add kill switch widgets when dialog activated */
166- panel->priv->add_header_widgets_idle = g_idle_add (network_add_shell_header_widgets_cb, panel);
167 }
168
169 void

Subscribers

People subscribed via source and target branches