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
1=== modified file 'src/common/Widgets/AbstractWifiInterface.vala'
2--- src/common/Widgets/AbstractWifiInterface.vala 2015-08-04 19:34:32 +0000
3+++ src/common/Widgets/AbstractWifiInterface.vala 2015-08-05 15:09:47 +0000
4@@ -134,7 +134,7 @@
5 bool found = false;
6
7 foreach(var w in wifi_list.get_children()) {
8- var menu_item = (WifiMenuItem) ((Gtk.Bin)w).get_child();
9+ var menu_item = ((WifiMenuItem) w);
10
11 if(NM.Utils.same_ssid (ap.get_ssid (), menu_item.ssid, true)) {
12 found = true;
13@@ -149,16 +149,11 @@
14 if(!found && ap.get_ssid() != null) {
15 WifiMenuItem item = new WifiMenuItem(ap, previous_wifi_item);
16
17- var row = new Gtk.ListBoxRow ();
18-
19- row.add (item);
20- row.get_style_context ().add_class ("menuitem");
21-
22 previous_wifi_item = item;
23 item.set_visible(true);
24 item.user_action.connect(wifi_activate_cb);
25
26- wifi_list.add (row);
27+ wifi_list.add (item);
28
29 wifi_list.show_all ();
30
31@@ -187,7 +182,7 @@
32
33 bool found = false;
34 foreach(var w in wifi_list.get_children()) {
35- var menu_item = (WifiMenuItem) ((Gtk.Bin)w).get_child();
36+ var menu_item = ((WifiMenuItem) w);
37
38 if(NM.Utils.same_ssid (active_ap.get_ssid (), menu_item.ssid, true)) {
39 found = true;
40@@ -210,7 +205,7 @@
41 WifiMenuItem found_item = null;
42
43 foreach(var w in wifi_list.get_children()) {
44- var menu_item = (WifiMenuItem) ((Gtk.Bin)w).get_child();
45+ var menu_item = ((WifiMenuItem) w);
46
47 assert(menu_item != null);
48
49@@ -224,7 +219,7 @@
50 critical("Couldn't remove an access point which has not been added.");
51 } else {
52 if(!found_item.remove_ap(ap)) {
53- found_item.get_parent().destroy ();
54+ found_item.destroy ();
55 }
56 }
57
58@@ -330,8 +325,8 @@
59 return 0;
60 }
61
62- var w1 = (WifiMenuItem)r1.get_child ();
63- var w2 = (WifiMenuItem)r2.get_child ();
64+ var w1 = ((WifiMenuItem)r1);
65+ var w2 = ((WifiMenuItem)r2);
66
67 if (w1.ap.get_strength () > w2.ap.get_strength ()) {
68 return -1;
69
70=== modified file 'src/common/Widgets/WifiMenuItem.vala'
71--- src/common/Widgets/WifiMenuItem.vala 2015-08-02 12:30:11 +0000
72+++ src/common/Widgets/WifiMenuItem.vala 2015-08-05 15:09:47 +0000
73@@ -15,7 +15,7 @@
74 * along with this program. If not, see <http://www.gnu.org/licenses/>.
75 */
76
77-public class Network.WifiMenuItem : Gtk.Box {
78+public class Network.WifiMenuItem : Gtk.ListBoxRow {
79 private List<NM.AccessPoint> _ap;
80 public signal void user_action();
81 public GLib.ByteArray ssid {
82@@ -52,7 +52,7 @@
83 Gtk.Spinner spinner;
84
85 public WifiMenuItem (NM.AccessPoint ap, WifiMenuItem? previous = null) {
86-
87+ var main_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
88 radio_button = new Gtk.RadioButton(null);
89 radio_button.margin_start = 6;
90 if (previous != null) radio_button.set_group (previous.get_group ());
91@@ -74,15 +74,15 @@
92
93 error_img.set_tooltip_text (_("This wireless network could not be connected to."));
94
95- pack_start(radio_button, true, true);
96+ main_box.pack_start(radio_button, true, true);
97 spinner = new Gtk.Spinner();
98 spinner.start();
99 spinner.visible = false;
100 spinner.no_show_all = !spinner.visible;
101- pack_start(spinner, false, false);
102- pack_start(error_img, false, false);
103- pack_start(lock_img, false, false);
104- pack_start(img_strength, false, false);
105+ main_box.pack_start(spinner, false, false);
106+ main_box.pack_start(error_img, false, false);
107+ main_box.pack_start(lock_img, false, false);
108+ main_box.pack_start(img_strength, false, false);
109
110 _ap = new List<NM.AccessPoint>();
111
112@@ -91,6 +91,8 @@
113
114 notify["state"].connect (update);
115 radio_button.notify["active"].connect (update);
116+ this.add (main_box);
117+ this.get_style_context ().add_class ("menuitem");
118 }
119
120 /**

Subscribers

People subscribed via source and target branches

to all changes: