Merge lp:~donadigo/switchboard-plug-networking/wifimenuitem-to-listboxrow into lp:~elementary-pantheon/switchboard-plug-networking/trunk

Proposed by Adam Bieńkowski
Status: Merged
Merged at revision: 132
Proposed branch: lp:~donadigo/switchboard-plug-networking/wifimenuitem-to-listboxrow
Merge into: lp:~elementary-pantheon/switchboard-plug-networking/trunk
Diff against target: 120 lines (+16/-19)
2 files modified
src/common/Widgets/AbstractWifiInterface.vala (+7/-12)
src/common/Widgets/WifiMenuItem.vala (+9/-7)
To merge this branch: bzr merge lp:~donadigo/switchboard-plug-networking/wifimenuitem-to-listboxrow
Reviewer Review Type Date Requested Status
elementary Pantheon team Pending
Review via email: mp+267048@code.launchpad.net

Commit message

* Port WifiMenuItem to ListBoxRow.

Description of the change

This branch simplifies the way WifiMenuItem is created and shown. Instead of inheriting from Gtk.Box and packing it into a new ListBoxRow it directly inherits from ListBoxRow and there is no need to call get_child and get_parent anymore.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/common/Widgets/AbstractWifiInterface.vala'
--- src/common/Widgets/AbstractWifiInterface.vala 2015-08-04 19:34:32 +0000
+++ src/common/Widgets/AbstractWifiInterface.vala 2015-08-05 15:09:47 +0000
@@ -134,7 +134,7 @@
134 bool found = false;134 bool found = false;
135135
136 foreach(var w in wifi_list.get_children()) {136 foreach(var w in wifi_list.get_children()) {
137 var menu_item = (WifiMenuItem) ((Gtk.Bin)w).get_child();137 var menu_item = ((WifiMenuItem) w);
138138
139 if(NM.Utils.same_ssid (ap.get_ssid (), menu_item.ssid, true)) {139 if(NM.Utils.same_ssid (ap.get_ssid (), menu_item.ssid, true)) {
140 found = true;140 found = true;
@@ -149,16 +149,11 @@
149 if(!found && ap.get_ssid() != null) {149 if(!found && ap.get_ssid() != null) {
150 WifiMenuItem item = new WifiMenuItem(ap, previous_wifi_item);150 WifiMenuItem item = new WifiMenuItem(ap, previous_wifi_item);
151151
152 var row = new Gtk.ListBoxRow ();
153
154 row.add (item);
155 row.get_style_context ().add_class ("menuitem");
156
157 previous_wifi_item = item;152 previous_wifi_item = item;
158 item.set_visible(true);153 item.set_visible(true);
159 item.user_action.connect(wifi_activate_cb);154 item.user_action.connect(wifi_activate_cb);
160155
161 wifi_list.add (row);156 wifi_list.add (item);
162157
163 wifi_list.show_all ();158 wifi_list.show_all ();
164159
@@ -187,7 +182,7 @@
187 182
188 bool found = false;183 bool found = false;
189 foreach(var w in wifi_list.get_children()) {184 foreach(var w in wifi_list.get_children()) {
190 var menu_item = (WifiMenuItem) ((Gtk.Bin)w).get_child();185 var menu_item = ((WifiMenuItem) w);
191186
192 if(NM.Utils.same_ssid (active_ap.get_ssid (), menu_item.ssid, true)) {187 if(NM.Utils.same_ssid (active_ap.get_ssid (), menu_item.ssid, true)) {
193 found = true;188 found = true;
@@ -210,7 +205,7 @@
210 WifiMenuItem found_item = null;205 WifiMenuItem found_item = null;
211206
212 foreach(var w in wifi_list.get_children()) {207 foreach(var w in wifi_list.get_children()) {
213 var menu_item = (WifiMenuItem) ((Gtk.Bin)w).get_child();208 var menu_item = ((WifiMenuItem) w);
214209
215 assert(menu_item != null);210 assert(menu_item != null);
216211
@@ -224,7 +219,7 @@
224 critical("Couldn't remove an access point which has not been added.");219 critical("Couldn't remove an access point which has not been added.");
225 } else {220 } else {
226 if(!found_item.remove_ap(ap)) {221 if(!found_item.remove_ap(ap)) {
227 found_item.get_parent().destroy ();222 found_item.destroy ();
228 }223 }
229 }224 }
230 225
@@ -330,8 +325,8 @@
330 return 0;325 return 0;
331 }326 }
332327
333 var w1 = (WifiMenuItem)r1.get_child ();328 var w1 = ((WifiMenuItem)r1);
334 var w2 = (WifiMenuItem)r2.get_child ();329 var w2 = ((WifiMenuItem)r2);
335330
336 if (w1.ap.get_strength () > w2.ap.get_strength ()) {331 if (w1.ap.get_strength () > w2.ap.get_strength ()) {
337 return -1;332 return -1;
338333
=== modified file 'src/common/Widgets/WifiMenuItem.vala'
--- src/common/Widgets/WifiMenuItem.vala 2015-08-02 12:30:11 +0000
+++ src/common/Widgets/WifiMenuItem.vala 2015-08-05 15:09:47 +0000
@@ -15,7 +15,7 @@
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */16 */
1717
18public class Network.WifiMenuItem : Gtk.Box {18public class Network.WifiMenuItem : Gtk.ListBoxRow {
19 private List<NM.AccessPoint> _ap;19 private List<NM.AccessPoint> _ap;
20 public signal void user_action();20 public signal void user_action();
21 public GLib.ByteArray ssid {21 public GLib.ByteArray ssid {
@@ -52,7 +52,7 @@
52 Gtk.Spinner spinner;52 Gtk.Spinner spinner;
5353
54 public WifiMenuItem (NM.AccessPoint ap, WifiMenuItem? previous = null) {54 public WifiMenuItem (NM.AccessPoint ap, WifiMenuItem? previous = null) {
5555 var main_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
56 radio_button = new Gtk.RadioButton(null);56 radio_button = new Gtk.RadioButton(null);
57 radio_button.margin_start = 6;57 radio_button.margin_start = 6;
58 if (previous != null) radio_button.set_group (previous.get_group ());58 if (previous != null) radio_button.set_group (previous.get_group ());
@@ -74,15 +74,15 @@
7474
75 error_img.set_tooltip_text (_("This wireless network could not be connected to."));75 error_img.set_tooltip_text (_("This wireless network could not be connected to."));
76 76
77 pack_start(radio_button, true, true);77 main_box.pack_start(radio_button, true, true);
78 spinner = new Gtk.Spinner();78 spinner = new Gtk.Spinner();
79 spinner.start();79 spinner.start();
80 spinner.visible = false;80 spinner.visible = false;
81 spinner.no_show_all = !spinner.visible;81 spinner.no_show_all = !spinner.visible;
82 pack_start(spinner, false, false);82 main_box.pack_start(spinner, false, false);
83 pack_start(error_img, false, false);83 main_box.pack_start(error_img, false, false);
84 pack_start(lock_img, false, false);84 main_box.pack_start(lock_img, false, false);
85 pack_start(img_strength, false, false);85 main_box.pack_start(img_strength, false, false);
86 86
87 _ap = new List<NM.AccessPoint>();87 _ap = new List<NM.AccessPoint>();
8888
@@ -91,6 +91,8 @@
9191
92 notify["state"].connect (update);92 notify["state"].connect (update);
93 radio_button.notify["active"].connect (update);93 radio_button.notify["active"].connect (update);
94 this.add (main_box);
95 this.get_style_context ().add_class ("menuitem");
94 }96 }
9597
96 /**98 /**

Subscribers

People subscribed via source and target branches

to all changes: