~purejava/switchboard-plug-networking/mobile-broadband-devices

« back to all changes in this revision

Viewing changes to src/Widgets/ModemInfoBox.vala

  • Committer: Ralph Plawetzki
  • Date: 2016-10-14 10:34:09 UTC
  • mto: This revision was merged to the branch mainline in revision 320.
  • Revision ID: ralph@purejava.org-20161014103409-xk7dt5ufxn56ep65
Get InfoBox working.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
        private Gtk.Label ip4address;
28
28
        private Gtk.Label ip6address;
29
 
        private Gtk.Label mask;
30
 
        private Gtk.Label router;
31
 
        private Gtk.Label broadcast;
 
29
        private Gtk.Label default_route;
 
30
        private Gtk.Label dns;
32
31
        private Gtk.Label sent;
33
32
        private Gtk.Label received;
34
33
 
93
92
            ip6address.no_show_all = true;
94
93
            ip6address.xalign = 0;
95
94
 
96
 
            var mask_head = new Gtk.Label (_("Subnet mask:"));
97
 
            mask_head.halign = Gtk.Align.END;
98
 
 
99
 
            mask = new Gtk.Label ("");
100
 
            mask.selectable = true;
101
 
            mask.xalign = 0;
102
 
 
103
 
            var router_head = new Gtk.Label (_("Router:"));
104
 
            router_head.halign = Gtk.Align.END;
105
 
 
106
 
            router = new Gtk.Label ("");
107
 
            router.selectable = true;
108
 
            router.xalign = 0;
109
 
 
110
 
            var broadcast_head = new Gtk.Label (_("Broadcast:"));
111
 
            broadcast_head.halign = Gtk.Align.END;
112
 
 
113
 
            broadcast = new Gtk.Label ("");
114
 
            broadcast.selectable = true;
115
 
            broadcast.xalign = 0;
 
95
            var default_route_head = new Gtk.Label (_("Default Route:"));
 
96
            default_route_head.halign = Gtk.Align.END;
 
97
 
 
98
            default_route = new Gtk.Label ("");
 
99
            default_route.selectable = true;
 
100
            default_route.xalign = 0;
 
101
 
 
102
            var dns_head = new Gtk.Label (_("DNS:"));
 
103
            dns_head.halign = Gtk.Align.END;
 
104
 
 
105
            dns = new Gtk.Label ("");
 
106
            dns.selectable = true;
 
107
            dns.xalign = 0;
116
108
 
117
109
            attach (ip4address_head, 0, 0);
118
110
            attach_next_to (ip4address, ip4address_head, Gtk.PositionType.RIGHT);
120
112
            attach_next_to (ip6address_head, ip4address_head, Gtk.PositionType.BOTTOM);
121
113
            attach_next_to (ip6address, ip6address_head, Gtk.PositionType.RIGHT);
122
114
 
123
 
            attach_next_to (mask_head, ip6address_head, Gtk.PositionType.BOTTOM);
124
 
            attach_next_to (mask, mask_head, Gtk.PositionType.RIGHT);
125
 
 
126
 
            attach_next_to (router_head, mask_head, Gtk.PositionType.BOTTOM);
127
 
            attach_next_to (router, router_head, Gtk.PositionType.RIGHT);
128
 
 
129
 
            attach_next_to (broadcast_head, router_head, Gtk.PositionType.BOTTOM);
130
 
            attach_next_to (broadcast, broadcast_head, Gtk.PositionType.RIGHT);
131
 
 
132
 
            attach_next_to (send_receive_grid, broadcast_head, Gtk.PositionType.BOTTOM, 4, 1);
 
115
            attach_next_to (default_route_head, ip6address_head, Gtk.PositionType.BOTTOM);
 
116
            attach_next_to (default_route, default_route_head, Gtk.PositionType.RIGHT);
 
117
 
 
118
            attach_next_to (dns_head, default_route_head, Gtk.PositionType.BOTTOM);
 
119
            attach_next_to (dns, dns_head, Gtk.PositionType.RIGHT);
133
120
 
134
121
            device.state_changed.connect (() => { 
135
122
                update_status ();
150
137
            // Refresh IP4 info
151
138
            var ip4 = device.get_ip4_config ();
152
139
            if (ip4 != null) {
 
140
                ip4address.label = "";
153
141
                int i = 1;
154
142
                SList<NM.IP4Address> addresses = ip4.get_addresses ().copy ();
155
143
                addresses.@foreach ((addr) => {
162
150
                    }
163
151
 
164
152
                    i++;
165
 
                });         
 
153
                });
 
154
                default_route.label =  (ip4.get_gateway () ?? UNKNOWN_STR);
 
155
                Array<uint32> dns_nameservers = ip4.get_nameservers ();
 
156
                if (dns_nameservers != null ) {
 
157
                        var dnsaddr = Posix.InAddr () { s_addr = dns_nameservers.index (0) };
 
158
                        string dns_str = Posix.inet_ntoa (dnsaddr);
 
159
                        dns.label =  (dns_str ?? UNKNOWN_STR);
 
160
                }
166
161
            } else {
167
162
                ip4address.label = UNKNOWN_STR;
168
 
                mask.label =  UNKNOWN_STR;
169
 
                router.label = UNKNOWN_STR;
170
 
                broadcast.label = UNKNOWN_STR;
 
163
                default_route.label =  UNKNOWN_STR;
 
164
                dns.label = UNKNOWN_STR;
171
165
            }
172
166
 
173
167
            var ip6 = device.get_ip6_config ();