Merge lp:~kvalo/indicator-network/settings-vala-convert into lp:indicator-network/0.1

Proposed by Kalle Valo on 2011-01-05
Status: Merged
Merged at revision: 127
Proposed branch: lp:~kvalo/indicator-network/settings-vala-convert
Merge into: lp:indicator-network/0.1
Diff against target: 5821 lines (+2864/-2574) 63 files modified
To merge this branch: bzr merge lp:~kvalo/indicator-network/settings-vala-convert
Reviewer Review Type Date Requested Status
Andrew (community) 2011-01-05 Approve on 2011-01-07
Mikkel Kamstrup Erlandsen (community) code review 2011-01-05 Approve on 2011-01-05
Review via email: mp+45244@code.launchpad.net

Description of the Change

Replace pygtk version of indicator-network-settings with a similar vala version. Currently frontend only works, backend needs to be implemented still. The backend will use libconnman.

Original author of the vala code is and471. I did the merge to indicator-network and autotools part.

To post a comment you must log in.

* src/settings/app.vala:

 - Can NetworkSettings.get_widgets() check that this.builder is a Gtk.Builder, as this kinda code always tends to regress when you refactor it...

 - Why is [CCode (instance_pos = -1)] needed on the callbacks? If it's really needed, can it get a comment in the code?

* src/settings/backend/connection.vala:

 - Why are all the fields on WifiConnection not properties? That would give change notifications for free.

* src/settings/backend/device.vala

 - Why does the Device class not use properties for it's two fields - given that, it would need the change notification signal, but could just you the standard GObject 'notify' signal (with details for the state).

* src/settings/frontend/utils.vala

 - Please make sure that you (Andrew) have the copyrights on this code (and not the Clutter project), so that you can legally contribute it

* ToggleSwitch and InfoBox. Can you add a quick comment in the class headers on why you are not using the Gtk counterparts?

Approved conditionally - given that there are good answers to the questions.

Super impressive work Andrew! This is an awesome first stab at a network dialog! :-D

review: Approve (code review)

I just went over the points with Andrew on IRC and everything should be cleared up. About the copyright issue we need some sort of reimplementation as Andrew said it was mostly copy-paste. I gathered from other discussions today that we may have something in lp:unity we can replace it with.

So; kvalo should merge and471's newest changes and pull in the unity color stuff and we should be good

Kalle Valo (kvalo) wrote :

Mikkel Kamstrup Erlandsen <email address hidden> writes:

> I just went over the points with Andrew on IRC and everything should
> be cleared up.

Excellent, thank you for that.

> About the copyright issue we need some sort of reimplementation as
> Andrew said it was mostly copy-paste. I gathered from other
> discussions today that we may have something in lp:unity we can
> replace it with.
>
> So; kvalo should merge and471's newest changes and pull in the unity
> color stuff and we should be good

Ok. I'll do so that I'll find a replacement implementation and update
this merge request.

Thanks.

--
Kalle Valo

135. By Kalle Valo on 2011-01-07

settings: replace rgb to hsl functions with copies from libunity

The author for the functions is Gordon Allot.

The original implementation used hsl, but the new functions use instead hsv.
Hopefully this isn't a problem, at least I didn't notice any difference
in testing.

Kalle Valo (kvalo) wrote :

I now pushed new functions for the rgb transformations. Please note the hsv/hsl difference, I hope I didn't break anything.

136. By Kalle Valo on 2011-01-07

settings: add missing glade files to potfiles to fix distcheck

Andrew (and471) wrote :

All looks good I approve!

review: Approve

Preview Diff

1=== modified file '.bzrignore'
2--- .bzrignore 2010-12-09 09:03:43 +0000
3+++ .bzrignore 2011-01-07 16:06:25 +0000
4@@ -89,3 +89,24 @@
5 tests/libconnman-tool
6 src/libconnman/libconnman_la-connman-service.lo
7 py-compile
8+src/settings/app.c
9+src/settings/enums.c
10+src/settings/indicator-network-settings-2
11+src/settings/indicator_network_settings_2_vala.stamp
12+src/settings/logger.c
13+src/settings/main.c
14+src/settings/backend/connection.c
15+src/settings/backend/device.c
16+src/settings/frontend/utils.c
17+src/settings/frontend/pages/connections.c
18+src/settings/frontend/widgets/cellrenderers.c
19+src/settings/frontend/widgets/infobox.c
20+src/settings/frontend/widgets/stores.c
21+src/settings/frontend/widgets/toggleswitch.c
22+src/settings/frontend/widgets/treeviews.c
23+src/settings/frontend/widgets/device-boxes/base.c
24+src/settings/frontend/widgets/device-boxes/bluetooth.c
25+src/settings/frontend/widgets/device-boxes/mobile.c
26+src/settings/frontend/widgets/device-boxes/wired.c
27+src/settings/frontend/widgets/device-boxes/wireless.c
28+src/settings/frontend/widgets/dialogs/edit-connection.c
29
30=== modified file 'configure.ac'
31--- configure.ac 2010-12-16 19:30:22 +0000
32+++ configure.ac 2011-01-07 16:06:25 +0000
33@@ -17,9 +17,9 @@
34 AM_PROG_CC_C_O
35 AC_STDC_HEADERS
36 AC_PROG_LIBTOOL
37-AM_PATH_PYTHON
38 AC_PROG_LN_S
39 AC_PROG_MKDIR_P
40+AM_PROG_VALAC
41
42 AC_SUBST(VERSION)
43 AC_CONFIG_MACRO_DIR([m4])
44@@ -154,12 +154,6 @@
45 src/agent/Makefile
46 src/settings/Makefile
47 src/settings/ui/Makefile
48-src/settings/indicatorNetworkSettings/Makefile
49-src/settings/indicatorNetworkSettings/backend/Makefile
50-src/settings/indicatorNetworkSettings/frontend/Makefile
51-src/settings/indicatorNetworkSettings/frontend/pages/Makefile
52-src/settings/indicatorNetworkSettings/frontend/widgets/Makefile
53-src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/Makefile
54 data/Makefile
55 po/Makefile.in
56 scripts/Makefile
57
58=== modified file 'po/POTFILES.in'
59--- po/POTFILES.in 2010-12-13 14:04:06 +0000
60+++ po/POTFILES.in 2011-01-07 16:06:25 +0000
61@@ -8,9 +8,8 @@
62 src/agent/pin-dialog.c
63 scripts/indicator-network-settings
64 scripts/indicator-network-mobile-wizard
65-src/settings/indicatorNetworkSettings/enums.py
66-src/settings/indicatorNetworkSettings/frontend/widgets/connectionview.py
67-src/settings/indicatorNetworkSettings/frontend/widgets/deviceview.py
68-src/settings/ui/indicator-network-settings.ui
69+src/settings/ui/edit_connection_dialog.ui
70+src/settings/ui/main.ui
71 src/settings/ui/mobile_box.ui
72+src/settings/ui/sample.ui
73 src/settings/ui/wireless_box.ui
74
75=== modified file 'src/settings/Makefile.am'
76--- src/settings/Makefile.am 2010-12-13 13:55:55 +0000
77+++ src/settings/Makefile.am 2011-01-07 16:06:25 +0000
78@@ -1,16 +1,47 @@
79 SUBDIRS = \
80- indicatorNetworkSettings \
81 ui
82
83-dist_pkgdata_SCRIPTS = \
84- indicator-network-settings
85-
86-# create a symbolic link to bindir
87-# FIXME: it will have suffix -2 until new settings window is usable
88-#
89-# Note: ln -f is not portable
90-install-exec-hook:
91- $(MKDIR_P) $(DESTDIR)$(bindir) && \
92- cd $(DESTDIR)$(bindir) && \
93- $(LN_S) -f $(pkgdatadir)/indicator-network-settings \
94- indicator-network-settings-2
95+bin_PROGRAMS = indicator-network-settings-2
96+
97+indicator_network_settings_2_SOURCES = \
98+ main.vala \
99+ app.vala \
100+ enums.vala \
101+ logger.vala \
102+ backend/device.vala \
103+ backend/connection.vala \
104+ frontend/utils.vala \
105+ frontend/pages/connections.vala \
106+ frontend/widgets/cellrenderers.vala \
107+ frontend/widgets/stores.vala \
108+ frontend/widgets/treeviews.vala \
109+ frontend/widgets/infobox.vala \
110+ frontend/widgets/toggleswitch.vala \
111+ frontend/widgets/device-boxes/base.vala \
112+ frontend/widgets/device-boxes/mobile.vala \
113+ frontend/widgets/device-boxes/bluetooth.vala \
114+ frontend/widgets/device-boxes/wired.vala \
115+ frontend/widgets/device-boxes/wireless.vala \
116+ frontend/widgets/dialogs/edit-connection.vala
117+
118+VALAFLAGS = \
119+ --vapidir=$(srcdir)/vapi \
120+ --pkg=gmodule-2.0 \
121+ --pkg=gtk+-2.0 \
122+ --pkg=gdk-2.0 \
123+ --pkg=gio-2.0 \
124+ --pkg=gee-1.0 \
125+ --pkg=pango \
126+ --pkg=cairo \
127+ --pkg=config \
128+ --fatal-warnings
129+
130+# -w is needed to disable gcc warnings because of valac
131+indicator_network_settings_2_CFLAGS = \
132+ $(GTK_CFLAGS) \
133+ -w \
134+ -DLOCALEDIR=\""$(localedir)"\" \
135+ -DPKGDATADIR=\""$(pkgdatadir)"\"
136+
137+indicator_network_settings_2_LDADD = \
138+ $(GTK_LIBS)
139
140=== added file 'src/settings/app.vala'
141--- src/settings/app.vala 1970-01-01 00:00:00 +0000
142+++ src/settings/app.vala 2011-01-07 16:06:25 +0000
143@@ -0,0 +1,76 @@
144+/*
145+ * indicator-network - user interface for connman
146+ * Copyright 2010-2011 Canonical Ltd.
147+ *
148+ * Authors:
149+ * Andrew Higginson
150+ *
151+ * This program is free software: you can redistribute it and/or modify it
152+ * under the terms of the GNU General Public License version 3, as published
153+ * by the Free Software Foundation.
154+ *
155+ * This program is distributed in the hope that it will be useful, but
156+ * WITHOUT ANY WARRANTY; without even the implied warranties of
157+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
158+ * PURPOSE. See the GNU General Public License for more details.
159+ *
160+ * You should have received a copy of the GNU General Public License along
161+ * with this program. If not, see <http://www.gnu.org/licenses/>.
162+ */
163+
164+public class NetworkSettings : Object {
165+
166+ // Widgets from GTKBuilder
167+ private Gtk.Window window_main;
168+ private Gtk.Notebook notebook_main;
169+ private Gtk.Alignment alignment_connections;
170+ private Gtk.ScrolledWindow scrolledwindow_c_devices;
171+ private Gtk.Notebook notebook_c_right;
172+
173+ private Gtk.IconTheme icons = Gtk.IconTheme.get_default();
174+ private ConnectionsPage[] pages;
175+ public Gtk.Builder builder;
176+
177+ public NetworkSettings(string datadir) {
178+ this.builder = Utils.Gui.new_builder(datadir + "/ui/main.ui");
179+
180+ this.get_widgets();
181+
182+ var page_connection = new ConnectionsPage(datadir, this.icons,
183+ this.alignment_connections,
184+ this.scrolledwindow_c_devices,
185+ this.notebook_c_right);
186+
187+ this.pages = {page_connection};
188+
189+ this.window_main.show_all();
190+ this.on_notebook_main_page_switched(null, 0);
191+ }
192+
193+ /* Private Functions */
194+ private void get_widgets() {
195+ this.window_main = this.builder.get_object("window_main") as Gtk.Window;
196+ this.notebook_main = this.builder.get_object("notebook_main") as Gtk.Notebook;
197+ this.alignment_connections = this.builder.get_object("alignment_connections") as Gtk.Alignment;
198+ this.scrolledwindow_c_devices = this.builder.get_object("scrolledwindow_c_devices") as Gtk.ScrolledWindow;
199+ this.notebook_c_right = this.builder.get_object("notebook_c_right") as Gtk.Notebook;
200+ }
201+
202+ /* Callbacks */
203+ [CCode (instance_pos = -1)]
204+ public bool on_window_main_delete_event(Gdk.Event event) {
205+ Gtk.main_quit();
206+ return true;
207+ }
208+
209+ [CCode (instance_pos = -1)]
210+ public void on_notebook_main_page_switched(Gtk.NotebookPage? notebook_page, int page_num) {
211+ var page_alignment = this.notebook_main.get_nth_page(page_num);
212+
213+ foreach (ConnectionsPage page in this.pages) {
214+ if (page.alignment == page_alignment && page.viewed == false) {
215+ page.on_first_expose();
216+ }
217+ }
218+ }
219+}
220
221=== added directory 'src/settings/backend'
222=== added file 'src/settings/backend/connection.vala'
223--- src/settings/backend/connection.vala 1970-01-01 00:00:00 +0000
224+++ src/settings/backend/connection.vala 2011-01-07 16:06:25 +0000
225@@ -0,0 +1,63 @@
226+/*
227+ * indicator-network - user interface for connman
228+ * Copyright 2010-2011 Canonical Ltd.
229+ *
230+ * Authors:
231+ * Andrew Higginson
232+ *
233+ * This program is free software: you can redistribute it and/or modify it
234+ * under the terms of the GNU General Public License version 3, as published
235+ * by the Free Software Foundation.
236+ *
237+ * This program is distributed in the hope that it will be useful, but
238+ * WITHOUT ANY WARRANTY; without even the implied warranties of
239+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
240+ * PURPOSE. See the GNU General Public License for more details.
241+ *
242+ * You should have received a copy of the GNU General Public License along
243+ * with this program. If not, see <http://www.gnu.org/licenses/>.
244+ */
245+
246+public class WifiConnection : GLib.Object {
247+ public string network;
248+ public double signal;
249+ public string last_used;
250+ public string name;
251+ public string ssid;
252+ public string? bssid;
253+ public WirelessMode mode = WirelessMode.INFRASTRUCTURE;
254+ public bool autoconnect = false;
255+ public bool share_settings = false;
256+
257+ public void connect_(string key) {
258+ var network = this.network;
259+ stdout.printf(@"Connecting to $network\n");
260+ }
261+}
262+
263+public WifiConnection[] get_remembered_wireless_connections(Device device) {
264+ // Dummy Connections (temporary)
265+ var connection1 = new WifiConnection();
266+ connection1.name = "Downstairs Router (above the biscuit tin)";
267+ connection1.signal = (double) 0.75;
268+ connection1.last_used = "1/1/1";
269+ connection1.ssid = "BTHomeHub-193209";
270+ connection1.bssid = "BBTHomeHub-193209";
271+ connection1.mode = WirelessMode.INFRASTRUCTURE;
272+ connection1.autoconnect = true;
273+ connection1.share_settings = true;
274+
275+ var connection2 = new WifiConnection();
276+ connection2.name = "SKY-001";
277+ connection2.signal = (double) 0.55;
278+ connection2.last_used = "1/1/1";
279+ connection2.ssid = "SKY-001";
280+
281+ var connection3 = new WifiConnection();
282+ connection3.name = "Starbucks OpenAccess";
283+ connection3.signal = (double) 0.2;
284+ connection3.last_used = "1/1/1";
285+ connection3.ssid = "Starbucks-1223Open";
286+ //
287+ return {connection1, connection2, connection3};
288+}
289
290=== added file 'src/settings/backend/device.vala'
291--- src/settings/backend/device.vala 1970-01-01 00:00:00 +0000
292+++ src/settings/backend/device.vala 2011-01-07 16:06:25 +0000
293@@ -0,0 +1,78 @@
294+/*
295+ * indicator-network - user interface for connman
296+ * Copyright 2010-2011 Canonical Ltd.
297+ *
298+ * Authors:
299+ * Andrew Higginson
300+ *
301+ * This program is free software: you can redistribute it and/or modify it
302+ * under the terms of the GNU General Public License version 3, as published
303+ * by the Free Software Foundation.
304+ *
305+ * This program is distributed in the hope that it will be useful, but
306+ * WITHOUT ANY WARRANTY; without even the implied warranties of
307+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
308+ * PURPOSE. See the GNU General Public License for more details.
309+ *
310+ * You should have received a copy of the GNU General Public License along
311+ * with this program. If not, see <http://www.gnu.org/licenses/>.
312+ */
313+
314+public class Device : GLib.Object {
315+
316+ public signal void state_changed(DeviceState selected);
317+
318+ public DeviceType type;
319+ public DeviceState state;
320+
321+ public Device() {
322+ }
323+
324+ public void set_state(DeviceState state) {
325+ this.state = state;
326+ this.state_changed(this.state);
327+ }
328+
329+ public DeviceState get_state() {
330+ return this.state;
331+ }
332+}
333+
334+public static Device[] get_wired_devices() {
335+ // Populate Device View (temporary)
336+ var device1 = new Device();
337+ device1.type = DeviceType.WIRED;
338+ device1.state = DeviceState.OFFLINE;
339+ //
340+ return {device1};
341+}
342+
343+public static Device[] get_wireless_devices() {
344+ // Populate Device View (temporary)
345+ var device1 = new Device();
346+ device1.type = DeviceType.WIRELESS;
347+ device1.state = DeviceState.ONLINE;
348+ var device2 = new Device();
349+ device2.type = DeviceType.WIRELESS;
350+ device2.state = DeviceState.OFF;
351+ //
352+ return {device1, device2};
353+}
354+
355+public static Device[] get_mobile_devices() {
356+ // Populate Device View (temporary)
357+ var device3 = new Device();
358+ device3.type = DeviceType.MOBILE;
359+ device3.state = DeviceState.CONNECTED;
360+ //
361+ return {device3};
362+}
363+
364+public static Device[] get_bluetooth_devices() {
365+ // Populate Device View (temporary)
366+ var device4 = new Device();
367+ device4.type = DeviceType.BLUETOOTH;
368+ device4.state = DeviceState.OFF;
369+ //
370+ return {device4};
371+}
372
373=== added file 'src/settings/enums.vala'
374--- src/settings/enums.vala 1970-01-01 00:00:00 +0000
375+++ src/settings/enums.vala 2011-01-07 16:06:25 +0000
376@@ -0,0 +1,115 @@
377+/*
378+ * indicator-network - user interface for connman
379+ * Copyright 2010-2011 Canonical Ltd.
380+ *
381+ * Authors:
382+ * Andrew Higginson
383+ *
384+ * This program is free software: you can redistribute it and/or modify it
385+ * under the terms of the GNU General Public License version 3, as published
386+ * by the Free Software Foundation.
387+ *
388+ * This program is distributed in the hope that it will be useful, but
389+ * WITHOUT ANY WARRANTY; without even the implied warranties of
390+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
391+ * PURPOSE. See the GNU General Public License for more details.
392+ *
393+ * You should have received a copy of the GNU General Public License along
394+ * with this program. If not, see <http://www.gnu.org/licenses/>.
395+ */
396+
397+public enum DeviceType {
398+ WIRED,
399+ WIRELESS,
400+ BLUETOOTH,
401+ MOBILE,
402+ GENERIC; // Shouldn't be used manually
403+
404+ public string get_name() {
405+ switch (this) {
406+ case WIRED:
407+ return ("Wired");
408+ case WIRELESS:
409+ return ("Wireless");
410+ case BLUETOOTH:
411+ return ("Bluetooth");
412+ case MOBILE:
413+ return ("Mobile Broadband");
414+ case GENERIC:
415+ return ("Wired");
416+ default:
417+ assert_not_reached();
418+ }
419+ }
420+
421+ public string get_lname() {
422+ switch (this) {
423+ case WIRED:
424+ return "wired";
425+ case WIRELESS:
426+ return "wireless";
427+ case BLUETOOTH:
428+ return "bluetooth";
429+ case MOBILE:
430+ return "mobile";
431+ default:
432+ assert_not_reached();
433+ }
434+ }
435+
436+ public string get_icon_name() {
437+ switch (this) {
438+ case WIRED:
439+ return "network-wired";
440+ case WIRELESS:
441+ return "network-wireless";
442+ case BLUETOOTH:
443+ return "bluetooth-active";
444+ case MOBILE:
445+ return "gsm-3g-high";
446+ case GENERIC:
447+ return "network-wired";
448+ default:
449+ assert_not_reached();
450+ }
451+ }
452+}
453+
454+public enum DeviceState {
455+ OFF,
456+ OFFLINE,
457+ CONNECTED,
458+ ONLINE;
459+
460+ public string get_name() {
461+ switch (this) {
462+ case OFF:
463+ return ("Off");
464+ case OFFLINE:
465+ return ("Offline");
466+ case CONNECTED:
467+ return ("Connected");
468+ case ONLINE:
469+ return ("Online");
470+ default:
471+ assert_not_reached();
472+ }
473+ }
474+}
475+
476+public enum WirelessMode {
477+ INFRASTRUCTURE,
478+ ADHOC;
479+
480+ public string get_name() {
481+ switch (this) {
482+ case INFRASTRUCTURE:
483+ return ("Infrastructure");
484+ case ADHOC:
485+ return ("Ad-hoc");
486+ default:
487+ assert_not_reached();
488+ }
489+ }
490+
491+}
492
493=== added directory 'src/settings/frontend'
494=== added directory 'src/settings/frontend/pages'
495=== added file 'src/settings/frontend/pages/connections.vala'
496--- src/settings/frontend/pages/connections.vala 1970-01-01 00:00:00 +0000
497+++ src/settings/frontend/pages/connections.vala 2011-01-07 16:06:25 +0000
498@@ -0,0 +1,120 @@
499+/*
500+ * indicator-network - user interface for connman
501+ * Copyright 2010-2011 Canonical Ltd.
502+ *
503+ * Authors:
504+ * Andrew Higginson
505+ *
506+ * This program is free software: you can redistribute it and/or modify it
507+ * under the terms of the GNU General Public License version 3, as published
508+ * by the Free Software Foundation.
509+ *
510+ * This program is distributed in the hope that it will be useful, but
511+ * WITHOUT ANY WARRANTY; without even the implied warranties of
512+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
513+ * PURPOSE. See the GNU General Public License for more details.
514+ *
515+ * You should have received a copy of the GNU General Public License along
516+ * with this program. If not, see <http://www.gnu.org/licenses/>.
517+ */
518+
519+public class ConnectionsPage : Object {
520+
521+ public Gtk.Alignment alignment;
522+ public Gtk.Notebook notebook_right;
523+ public bool viewed = false;
524+
525+ private DeviceView treeview_devices;
526+
527+ public ConnectionsPage(string datadir, Gtk.IconTheme icons,
528+ Gtk.Alignment alignment,
529+ Gtk.ScrolledWindow scrolledwindow_devices,
530+ Gtk.Notebook notebook_right) {
531+
532+ this.alignment = alignment;
533+ this.notebook_right = notebook_right;
534+
535+ // Create LHS
536+ /// Create device view
537+ var device_store = new DeviceStore(icons);
538+ this.treeview_devices = new DeviceView(device_store);
539+ /// Pack it
540+ scrolledwindow_devices.add(this.treeview_devices);
541+ /// Connect signals to callbacks
542+ this.treeview_devices.get_selection().changed.connect(
543+ this.on_treeview_devices_selection_changed);
544+ this.treeview_devices.reordered.connect(
545+ this.on_treeview_devices_reordered);
546+
547+ Device[] wired_devices = get_wired_devices();
548+ Device[] wireless_devices = get_wireless_devices();
549+ Device[] mobile_devices = get_mobile_devices();
550+ Device[] bluetooth_devices = get_bluetooth_devices();
551+
552+ foreach (var device in wireless_devices) {
553+ var box = new WirelessBox(device, datadir);
554+ notebook_right.append_page(box, null);
555+ this.add_device(device, box);
556+ }
557+
558+ foreach (var device in mobile_devices) {
559+ var box = new MobileBox(device, datadir);
560+ notebook_right.append_page(box, null);
561+ this.add_device(device, box);
562+ }
563+
564+ foreach (var device in wired_devices) {
565+ var box = new WiredBox(device, datadir);
566+ notebook_right.append_page(box, null);
567+ this.add_device(device, box);
568+ }
569+
570+ foreach (var device in bluetooth_devices) {
571+ var box = new BluetoothBox(device, datadir);
572+ notebook_right.append_page(box, null);
573+ this.add_device(device, box);
574+ }
575+
576+ // Order the RHS notebook pages inaccordance with the deviceview
577+ this.on_treeview_devices_reordered();
578+
579+ }
580+
581+ public void add_device(Device device, DeviceBox box) {
582+ var liststore = this.treeview_devices.get_model() as DeviceStore;
583+ liststore.add_device(device, box);
584+ }
585+
586+ public void on_first_expose() {
587+ if (!this.viewed) {
588+ this.treeview_devices.get_selection().select_path(new Gtk.TreePath.first());
589+ this.viewed = true;
590+ }
591+ }
592+
593+ private void on_treeview_devices_selection_changed() {
594+ var selection = this.treeview_devices.get_selection();
595+ Gtk.TreeModel model;
596+ Gtk.TreeIter? iter;
597+ selection.get_selected(out model, out iter);
598+
599+ if (iter != null) {
600+ int i = model.get_path(iter).get_indices()[0];
601+ this.notebook_right.set_current_page(i);
602+ }
603+ }
604+
605+ private void on_treeview_devices_reordered() {
606+ var i = 0;
607+ var model = this.treeview_devices.get_model();
608+ model.foreach((model, path, iter) => {
609+ GLib.Value value;
610+ model.get_value(iter, DeviceStoreCol.SETTINGS_BOX, out value);
611+ Gtk.VBox page = value.get_object() as Gtk.VBox;
612+ this.notebook_right.reorder_child(page, i);
613+ i += 1;
614+ return false;
615+ });
616+ }
617+
618+}
619
620=== added file 'src/settings/frontend/utils.vala'
621--- src/settings/frontend/utils.vala 1970-01-01 00:00:00 +0000
622+++ src/settings/frontend/utils.vala 2011-01-07 16:06:25 +0000
623@@ -0,0 +1,199 @@
624+/*
625+ * indicator-network - user interface for connman
626+ * Copyright 2010-2011 Canonical Ltd.
627+ *
628+ * Authors:
629+ * Andrew Higginson
630+ * Gordon Allott <gord.allott@canonical.com>
631+ *
632+ * This program is free software: you can redistribute it and/or modify it
633+ * under the terms of the GNU General Public License version 3, as published
634+ * by the Free Software Foundation.
635+ *
636+ * This program is distributed in the hope that it will be useful, but
637+ * WITHOUT ANY WARRANTY; without even the implied warranties of
638+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
639+ * PURPOSE. See the GNU General Public License for more details.
640+ *
641+ * You should have received a copy of the GNU General Public License along
642+ * with this program. If not, see <http://www.gnu.org/licenses/>.
643+ */
644+
645+namespace Utils.Color {
646+ /* from libunity */
647+ public static void rgb_to_hsv (float r, float g, float b,
648+ out float hue, out float sat, out float val)
649+ {
650+ float min, max = 0.0f;
651+ if (r > g)
652+ max = (r > b) ? r : b;
653+ else
654+ max = (g > b) ? g : b;
655+ if (r < g)
656+ min = (r < b) ? r : b;
657+ else
658+ min = (g < b) ? g : b;
659+
660+ val = max;
661+
662+ float delta = max - min;
663+ if (delta > 0.000001)
664+ {
665+ sat = delta / max;
666+ hue = 0.0f;
667+ if (r == max)
668+ {
669+ hue = (g - b) / delta;
670+ if (hue < 0.0f)
671+ hue += 6.0f;
672+ }
673+ else if (g == max)
674+ {
675+ hue = 2.0f + (b - r) / delta;
676+ }
677+ else if (b == max)
678+ {
679+ hue = 4.0f + (r - g) / delta;
680+ }
681+ hue /= 6.0f;
682+ }
683+ else
684+ {
685+ sat = 0.0f;
686+ hue = 0.0f;
687+ }
688+ }
689+
690+ /* from libunity */
691+ public static void hsv_to_rgb (float hue, float sat, float val,
692+ out float r, out float g, out float b)
693+ {
694+ int i;
695+ float f, w, q, t;
696+
697+ if (sat == 0.0)
698+ {
699+ r = g = b = val;
700+ }
701+ else
702+ {
703+ if (hue == 1.0)
704+ hue = 0.0f;
705+
706+ hue *= 6.0f;
707+
708+ i = (int) hue;
709+ f = hue - i;
710+ w = val * (1.0f - sat);
711+ q = val * (1.0f - (sat * f));
712+ t = val * (1.0f - (sat * (1.0f - f)));
713+
714+ switch (i)
715+ {
716+ case 0:
717+ r = val;
718+ g = t;
719+ b = w;
720+ break;
721+ case 1:
722+ r = q;
723+ g = val;
724+ b = w;
725+ break;
726+ case 2:
727+ r = w;
728+ g = val;
729+ b = t;
730+ break;
731+ case 3:
732+ r = w;
733+ g = q;
734+ b = val;
735+ break;
736+ case 4:
737+ r = t;
738+ g = w;
739+ b = val;
740+ break;
741+ case 5:
742+ r = val;
743+ g = w;
744+ b = q;
745+ break;
746+ }
747+ }
748+ }
749+
750+ static void color_to_hls(Gdk.Color color, out float hue, out float luminance, out float saturation) {
751+ float red, green, blue;
752+ float h, l, v;
753+
754+ red = color.red / 65535.0f;
755+ green = color.green / 65535.0f;
756+ blue = color.blue / 65535.0f;
757+
758+ rgb_to_hsv(red, green, blue, out h, out l, out v);
759+
760+ hue = h;
761+ luminance = l;
762+ saturation = v;
763+ }
764+
765+ static void color_from_hls(float hue, float luminance, float saturation, out Gdk.Color color) {
766+ float red, green, blue;
767+
768+ hsv_to_rgb(hue, luminance, saturation, out red, out green, out blue);
769+
770+ color.red = (uint16) Math.floorf(red * 65535.0f + 0.5f);
771+ color.green = (uint16) Math.floorf(green * 65535.0f + 0.5f);
772+ color.blue = (uint16) Math.floorf(blue * 65535.0f + 0.5f);
773+ }
774+
775+ static Gdk.Color shade(Gdk.Color color) {
776+ float h;
777+ float l;
778+ float s;
779+ float factor;
780+ Utils.Color.color_to_hls(color, out h, out l, out s);
781+
782+ if (l > 0.5) {
783+ // Colour is light, lets darken it
784+ factor = 0.6f;
785+ } else {
786+ // Colour is dark, lets lighten it
787+ factor = 1.4f;
788+ }
789+
790+ l *= factor;
791+ if (l > 1.0f) {
792+ l = 1.0f;
793+ } else if (l < 0) {
794+ l = 0;
795+ }
796+
797+ s*= factor;
798+ if (s > 1.0f) {
799+ s= 1.0f;
800+ } else if (s < 0) {
801+ s = 0;
802+ }
803+
804+ Gdk.Color new_color;
805+ Utils.Color.color_from_hls(h, l, s, out new_color);
806+
807+ return new_color;
808+ }
809+}
810+
811+namespace Utils.Gui {
812+ static Gtk.Builder new_builder(string path) {
813+ var builder = new Gtk.Builder();
814+ try {
815+ builder.add_from_file(path);
816+ } catch (Error e) {
817+ logger.debug(@"Can't find $path.");
818+ }
819+ builder.set_translation_domain("indicator-network-settings");
820+ return builder;
821+ }
822+}
823
824=== added directory 'src/settings/frontend/widgets'
825=== added file 'src/settings/frontend/widgets/cellrenderers.vala'
826--- src/settings/frontend/widgets/cellrenderers.vala 1970-01-01 00:00:00 +0000
827+++ src/settings/frontend/widgets/cellrenderers.vala 2011-01-07 16:06:25 +0000
828@@ -0,0 +1,224 @@
829+/*
830+ * indicator-network - user interface for connman
831+ * Copyright 2010-2011 Canonical Ltd.
832+ *
833+ * Authors:
834+ * Andrew Higginson
835+ *
836+ * This program is free software: you can redistribute it and/or modify it
837+ * under the terms of the GNU General Public License version 3, as published
838+ * by the Free Software Foundation.
839+ *
840+ * This program is distributed in the hope that it will be useful, but
841+ * WITHOUT ANY WARRANTY; without even the implied warranties of
842+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
843+ * PURPOSE. See the GNU General Public License for more details.
844+ *
845+ * You should have received a copy of the GNU General Public License along
846+ * with this program. If not, see <http://www.gnu.org/licenses/>.
847+ */
848+
849+public const double PI = 3.1415926535897931;
850+public const double PI_OVER_180 = 0.017453292519943295;
851+
852+class PinCellRenderer : Gtk.CellRenderer {
853+
854+ public string color { get; set; }
855+
856+ private const string RED_FILL = "#ef2929";
857+ private const string RED_STROKE = "#a40000";
858+ private const string GREEN_FILL = "#8ae234";
859+ private const string GREEN_STROKE = "#4e9a06";
860+ private const string YELLOW_FILL = "#fce94f";
861+ private const string YELLOW_STROKE = "#c4a000";
862+ private const string GREY_FILL = "#d3d7cf";
863+ private const string GREY_STROKE = "#555753";
864+
865+ // Minimum size + (minimum padding times 2)
866+ private const int MIN_CELL_WIDTH = 8 + (4 * 2);
867+ private const int MIN_CELL_HEIGHT = 8 + (4 * 2);
868+
869+ // Ratio of radius of pin to width/height of cell
870+ private const double PIN_RADIUS = 0.5;
871+
872+ public PinCellRenderer() {
873+ GLib.Object ();
874+ }
875+
876+ public override void get_size(Gtk.Widget widget, Gdk.Rectangle? cell_area,
877+ out int x_offset, out int y_offset,
878+ out int width, out int height) {
879+ if (&x_offset != null) x_offset = 0;
880+ if (&y_offset != null) y_offset = 0;
881+ if (&width != null) width = this.MIN_CELL_WIDTH;
882+ if (&height != null) height = this.MIN_CELL_HEIGHT;
883+ }
884+
885+ public override void render(Gdk.Window window, Gtk.Widget widget,
886+ Gdk.Rectangle background_area,
887+ Gdk.Rectangle cell_area,
888+ Gdk.Rectangle expose_area,
889+ Gtk.CellRendererState flags) {
890+
891+ var cr = Gdk.cairo_create(window);
892+
893+ var x = cell_area.x;
894+ var y = cell_area.y;
895+ var width = cell_area.width;
896+ var height = cell_area.height;
897+
898+ var lower_dimension = this.get_lower_dimension(width, height);
899+ var pin_radius = (int) lower_dimension * this.PIN_RADIUS;
900+
901+ var x_offset = (width - lower_dimension) / 2;
902+ var y_offset = (height - lower_dimension) / 2;
903+
904+ cr.arc(x+x_offset+pin_radius, y+y_offset+pin_radius, pin_radius/2, 0, 2 * Math.PI);
905+
906+ var stroke_string = "";
907+ var fill_string = "";
908+
909+ switch (this.color) {
910+ case "red":
911+ stroke_string = this.RED_STROKE;
912+ fill_string = this.RED_FILL;
913+ break;
914+ case "green":
915+ stroke_string = this.GREEN_STROKE;
916+ fill_string = this.GREEN_FILL;
917+ break;
918+ case "yellow":
919+ stroke_string = this.YELLOW_STROKE;
920+ fill_string = this.YELLOW_FILL;
921+ break;
922+ case "grey":
923+ stroke_string = this.GREY_STROKE;
924+ fill_string = this.GREY_FILL;
925+ break;
926+ }
927+
928+ var stroke = Gdk.Color();
929+ stroke.parse(stroke_string, out stroke);
930+ var fill = Gdk.Color();
931+ fill.parse(fill_string, out fill);
932+
933+ cr.set_source_rgb((double) stroke.red / 65535.0,
934+ (double) stroke.green / 65535.0,
935+ (double) stroke.blue / 65535.0);
936+ cr.stroke_preserve();
937+
938+ cr.set_source_rgb((double) fill.red / 65535.0,
939+ (double) fill.green / 65535.0,
940+ (double) fill.blue / 65535.0);
941+ cr.fill();
942+ }
943+
944+ private float get_lower_dimension(float n1, float n2) {
945+ if (n1 > n2) {
946+ return n2;
947+ }
948+ return n1;
949+ }
950+}
951+
952+
953+class SignalStrengthCellRenderer : Gtk.CellRenderer {
954+
955+ public double strength { get; set; }
956+
957+ private Gtk.Widget style_widget;
958+ private Gtk.Widget state_widget;
959+
960+ // Minimum size + (minimum padding times 2)
961+ private const int MIN_CELL_WIDTH = 20 + (5 * 2);
962+ private const int MIN_CELL_HEIGHT = 8 + (6 * 2);
963+
964+ // Ratio of width/height of bar to width/height of cell
965+ private const double BAR_WIDTH = 0.8;
966+ private const double BAR_HEIGHT = 0.45;
967+
968+ private const int CORNER_RADIUS = 3;
969+
970+ public SignalStrengthCellRenderer(Gtk.Widget style_widget, Gtk.Widget state_widget) {
971+ GLib.Object();
972+ this.style_widget = style_widget;
973+ this.state_widget = state_widget;
974+ }
975+
976+ public override void get_size(Gtk.Widget widget, Gdk.Rectangle? cell_area,
977+ out int x_offset, out int y_offset,
978+ out int width, out int height) {
979+ if (&x_offset != null) x_offset = 0;
980+ if (&y_offset != null) y_offset = 0;
981+ if (&width != null) width = this.MIN_CELL_WIDTH;
982+ if (&height != null) height = this.MIN_CELL_HEIGHT;
983+ }
984+
985+ public override void render(Gdk.Window window, Gtk.Widget widget,
986+ Gdk.Rectangle background_area,
987+ Gdk.Rectangle cell_area,
988+ Gdk.Rectangle expose_area,
989+ Gtk.CellRendererState flags) {
990+
991+ var cr = Gdk.cairo_create(window);
992+
993+ var x = (int) cell_area.x;
994+ var y = (int) cell_area.y;
995+ var width = (int) cell_area.width;
996+ var height = (int) cell_area.height;
997+
998+ var bar_width = (int) (width * this.BAR_WIDTH);
999+ var bar_height = (int) (height * this.BAR_HEIGHT);
1000+
1001+ var x_offset = (int) ((width - bar_width) / 2);
1002+ var y_offset = (int) ((height - bar_height) / 2);
1003+
1004+ var state = this.state_widget.state;
1005+
1006+ var bg_fill = this.style_widget.style.bg[state];
1007+ var bg_stroke = this.style_widget.style.dark[state];
1008+
1009+ var fg_fill = this.style_widget.style.mid[state];
1010+ var fg_stroke = this.style_widget.style.dark[state];
1011+
1012+ this.draw_rounded_rectangle(cr, x+x_offset, y+y_offset,
1013+ x+x_offset+bar_width, y+y_offset+bar_height,
1014+ bg_fill, bg_stroke);
1015+
1016+ if (this.strength == 0) {
1017+ stdout.printf("strength = 0\n\n");
1018+ }
1019+
1020+
1021+ this.draw_rounded_rectangle(cr, x+x_offset, y+y_offset,
1022+ x+x_offset+((int) (bar_width*this.strength)), y+y_offset+bar_height,
1023+ fg_fill, fg_stroke);
1024+ }
1025+
1026+ private void draw_rounded_rectangle(Cairo.Context cr, int x, int y,
1027+ int w, int h, Gdk.Color fill, Gdk.Color stroke) {
1028+ this.layout_rounded_rectangle(cr, x, y, w, h);
1029+
1030+ cr.set_source_rgb((double) stroke.red / 65535.0,
1031+ (double) stroke.green / 65535.0,
1032+ (double) stroke.blue / 65535.0);
1033+ cr.stroke_preserve();
1034+
1035+ cr.set_source_rgb((double) fill.red / 65535.0,
1036+ (double) fill.green / 65535.0,
1037+ (double) fill.blue / 65535.0);
1038+ cr.fill();
1039+ }
1040+
1041+ private void layout_rounded_rectangle(Cairo.Context cr, int x, int y,
1042+ int w, int h) {
1043+ var r = this.CORNER_RADIUS;
1044+
1045+ cr.new_sub_path();
1046+ cr.arc(r+x, r+y, r, PI, 270*PI_OVER_180);
1047+ cr.arc(w-r, r+y, r, 270*PI_OVER_180, 0);
1048+ cr.arc(w-r, h-r, r, 0, 90*PI_OVER_180);
1049+ cr.arc(r+x, h-r, r, 90*PI_OVER_180, PI);
1050+ cr.close_path();
1051+ }
1052+}
1053
1054=== added directory 'src/settings/frontend/widgets/device-boxes'
1055=== added file 'src/settings/frontend/widgets/device-boxes/base.vala'
1056--- src/settings/frontend/widgets/device-boxes/base.vala 1970-01-01 00:00:00 +0000
1057+++ src/settings/frontend/widgets/device-boxes/base.vala 2011-01-07 16:06:25 +0000
1058@@ -0,0 +1,26 @@
1059+/*
1060+ * indicator-network - user interface for connman
1061+ * Copyright 2010-2011 Canonical Ltd.
1062+ *
1063+ * Authors:
1064+ * Andrew Higginson
1065+ *
1066+ * This program is free software: you can redistribute it and/or modify it
1067+ * under the terms of the GNU General Public License version 3, as published
1068+ * by the Free Software Foundation.
1069+ *
1070+ * This program is distributed in the hope that it will be useful, but
1071+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1072+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1073+ * PURPOSE. See the GNU General Public License for more details.
1074+ *
1075+ * You should have received a copy of the GNU General Public License along
1076+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1077+ */
1078+
1079+public abstract class DeviceBox : Gtk.VBox {
1080+ /* A gtk.VBox which holds all of the widgets to control a device */
1081+
1082+ public DeviceBox() {}
1083+ public abstract void on_device_state_changed(DeviceState state);
1084+}
1085
1086=== added file 'src/settings/frontend/widgets/device-boxes/bluetooth.vala'
1087--- src/settings/frontend/widgets/device-boxes/bluetooth.vala 1970-01-01 00:00:00 +0000
1088+++ src/settings/frontend/widgets/device-boxes/bluetooth.vala 2011-01-07 16:06:25 +0000
1089@@ -0,0 +1,35 @@
1090+/*
1091+ * indicator-network - user interface for connman
1092+ * Copyright 2010-2011 Canonical Ltd.
1093+ *
1094+ * Authors:
1095+ * Andrew Higginson
1096+ *
1097+ * This program is free software: you can redistribute it and/or modify it
1098+ * under the terms of the GNU General Public License version 3, as published
1099+ * by the Free Software Foundation.
1100+ *
1101+ * This program is distributed in the hope that it will be useful, but
1102+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1103+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1104+ * PURPOSE. See the GNU General Public License for more details.
1105+ *
1106+ * You should have received a copy of the GNU General Public License along
1107+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1108+ */
1109+
1110+class BluetoothBox : DeviceBox {
1111+
1112+ /* A Gtk.VBox which holds all of the widgets to control a bluetooth
1113+ device. */
1114+
1115+ private Device device;
1116+
1117+ public BluetoothBox(Device device, string datadir) {
1118+ this.set_spacing(12);
1119+ this.device = device;
1120+ this.device.state_changed.connect(this.on_device_state_changed);
1121+ }
1122+
1123+ public override void on_device_state_changed(DeviceState state) {}
1124+}
1125
1126=== added file 'src/settings/frontend/widgets/device-boxes/mobile.vala'
1127--- src/settings/frontend/widgets/device-boxes/mobile.vala 1970-01-01 00:00:00 +0000
1128+++ src/settings/frontend/widgets/device-boxes/mobile.vala 2011-01-07 16:06:25 +0000
1129@@ -0,0 +1,151 @@
1130+/*
1131+ * indicator-network - user interface for connman
1132+ * Copyright 2010-2011 Canonical Ltd.
1133+ *
1134+ * Authors:
1135+ * Andrew Higginson
1136+ *
1137+ * This program is free software: you can redistribute it and/or modify it
1138+ * under the terms of the GNU General Public License version 3, as published
1139+ * by the Free Software Foundation.
1140+ *
1141+ * This program is distributed in the hope that it will be useful, but
1142+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1143+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1144+ * PURPOSE. See the GNU General Public License for more details.
1145+ *
1146+ * You should have received a copy of the GNU General Public License along
1147+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1148+ */
1149+
1150+class MobileBox : DeviceBox {
1151+
1152+ /* A Gtk.VBox which holds all of the widgets to control a mobile
1153+ device. It contains an InfoBox and ToggleSwitch to control and
1154+ monitor the state of the mobile device, and a set of widgets
1155+ to enter details about the mobile network to connect to. */
1156+
1157+ private Device device;
1158+ private InfoBox infobox;
1159+ private ToggleSwitch toggleswitch;
1160+ private Gtk.Label label_status;
1161+ private Gtk.Builder builder;
1162+ private Gtk.Table table_settings;
1163+ private Gtk.Entry entry_pin;
1164+ private Gtk.CheckButton checkbutton_show_pin;
1165+
1166+ private bool device_editable;
1167+ private bool settings_editable;
1168+
1169+ private const string[] sensitive_widgets = {"label_apn_place", "label_apn",
1170+ "label_pin_auth", "checkbutton_show_pin"};
1171+
1172+ public MobileBox(Device device, string datadir) {
1173+ this.set_spacing(12);
1174+ this.device = device;
1175+ this.device.state_changed.connect(this.on_device_state_changed);
1176+
1177+ // Infobox and Togglswitch
1178+ /// Creation
1179+ this.infobox = new InfoBox(false, 12);
1180+ this.toggleswitch = new ToggleSwitch();
1181+ this.label_status = new Gtk.Label(null);
1182+ /// Padding and alignment
1183+ this.label_status.set_alignment(0, 0.5f);
1184+ this.infobox.set_border_width(10);
1185+ /// Packing
1186+ this.infobox.pack_start(this.label_status, true, true);
1187+ this.infobox.pack_start(this.toggleswitch, false, true);
1188+ this.pack_start(this.infobox, false, false);
1189+ /// Connect signals;
1190+ this.toggleswitch.toggled.connect(this.on_toggleswitch_toggled);
1191+
1192+ // Network Settings
1193+ /// Creation
1194+ this.builder = Utils.Gui.new_builder(datadir+"ui/mobile_box.ui");
1195+ this.get_widgets();
1196+ this.connect_signals();
1197+ /// Packing
1198+ this.pack_start(this.table_settings, true, true);
1199+
1200+ this.update_widget_states(this.device.get_state());
1201+ this.on_checkbutton_show_pin_toggled();
1202+ }
1203+
1204+ private void get_widgets() {
1205+ this.table_settings = this.builder.get_object("table_settings") as Gtk.Table;
1206+ this.entry_pin = this.builder.get_object("entry_pin") as Gtk.Entry;
1207+ this.checkbutton_show_pin = this.builder.get_object("checkbutton_show_pin") as Gtk.CheckButton;
1208+ }
1209+
1210+ private void connect_signals() {
1211+ this.checkbutton_show_pin.toggled.connect(this.on_checkbutton_show_pin_toggled);
1212+ }
1213+
1214+ private void update_widget_states(DeviceState state) {
1215+ bool toggleswitch_state = false;
1216+ string status_text = "";
1217+
1218+ switch (state) {
1219+ case DeviceState.CONNECTED:
1220+ this.device_editable = true;
1221+ this.settings_editable = false;
1222+ toggleswitch_state = true;
1223+ status_text = ("Connected to “Vodafone UK”.");
1224+ break;
1225+ case DeviceState.ONLINE:
1226+ this.device_editable = true;
1227+ this.settings_editable = false;
1228+ toggleswitch_state = true;
1229+ status_text = ("Connected to the Internet on “Vodafone UK”.");
1230+ break;
1231+ case DeviceState.OFF:
1232+ this.device_editable = false;
1233+ this.settings_editable = true;
1234+ toggleswitch_state = false;
1235+ status_text = ("The Mobile Broadband device is powered off.");
1236+ break;
1237+ case DeviceState.OFFLINE:
1238+ this.device_editable = true;
1239+ this.settings_editable = true;
1240+ toggleswitch_state = false;
1241+ status_text = ("Mobile Broadband is offline.");
1242+ break;
1243+ }
1244+
1245+ this.toggleswitch.set_sensitive(this.device_editable);
1246+ this.toggleswitch.set_active(toggleswitch_state);
1247+ this.label_status.set_text(status_text);
1248+
1249+ this.table_settings.foreach(this.sensitise_widgets);
1250+ }
1251+
1252+ private void sensitise_widgets(Gtk.Widget widget) {
1253+
1254+ var name = widget.get_name();
1255+ if (name in this.sensitive_widgets) {
1256+ widget.set_sensitive(this.device_editable);
1257+ } else if (!(widget is Gtk.Box)) {
1258+ widget.set_sensitive(this.settings_editable);
1259+ } else {
1260+ var container = widget as Gtk.Container;
1261+ container.foreach(this.sensitise_widgets);
1262+ }
1263+ }
1264+
1265+ public override void on_device_state_changed(DeviceState state) {
1266+ this.update_widget_states(state);
1267+ }
1268+
1269+ private void on_toggleswitch_toggled() {
1270+ if (this.toggleswitch.get_active()) {
1271+ this.device.set_state(DeviceState.CONNECTED);
1272+ } else {
1273+ this.device.set_state(DeviceState.OFFLINE);
1274+ }
1275+ }
1276+
1277+ private void on_checkbutton_show_pin_toggled() {
1278+ this.entry_pin.set_visibility(this.checkbutton_show_pin.get_active());
1279+ }
1280+}
1281
1282=== added file 'src/settings/frontend/widgets/device-boxes/wired.vala'
1283--- src/settings/frontend/widgets/device-boxes/wired.vala 1970-01-01 00:00:00 +0000
1284+++ src/settings/frontend/widgets/device-boxes/wired.vala 2011-01-07 16:06:25 +0000
1285@@ -0,0 +1,35 @@
1286+/*
1287+ * indicator-network - user interface for connman
1288+ * Copyright 2010-2011 Canonical Ltd.
1289+ *
1290+ * Authors:
1291+ * Andrew Higginson
1292+ *
1293+ * This program is free software: you can redistribute it and/or modify it
1294+ * under the terms of the GNU General Public License version 3, as published
1295+ * by the Free Software Foundation.
1296+ *
1297+ * This program is distributed in the hope that it will be useful, but
1298+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1299+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1300+ * PURPOSE. See the GNU General Public License for more details.
1301+ *
1302+ * You should have received a copy of the GNU General Public License along
1303+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1304+ */
1305+
1306+class WiredBox : DeviceBox {
1307+
1308+ /* A Gtk.VBox which holds all of the widgets to control a wired
1309+ device. */
1310+
1311+ private Device device;
1312+
1313+ public WiredBox(Device device, string datadir) {
1314+ this.set_spacing(12);
1315+ this.device = device;
1316+ this.device.state_changed.connect(this.on_device_state_changed);
1317+ }
1318+
1319+ public override void on_device_state_changed(DeviceState state) {}
1320+}
1321
1322=== added file 'src/settings/frontend/widgets/device-boxes/wireless.vala'
1323--- src/settings/frontend/widgets/device-boxes/wireless.vala 1970-01-01 00:00:00 +0000
1324+++ src/settings/frontend/widgets/device-boxes/wireless.vala 2011-01-07 16:06:25 +0000
1325@@ -0,0 +1,183 @@
1326+/*
1327+ * indicator-network - user interface for connman
1328+ * Copyright 2010-2011 Canonical Ltd.
1329+ *
1330+ * Authors:
1331+ * Andrew Higginson
1332+ *
1333+ * This program is free software: you can redistribute it and/or modify it
1334+ * under the terms of the GNU General Public License version 3, as published
1335+ * by the Free Software Foundation.
1336+ *
1337+ * This program is distributed in the hope that it will be useful, but
1338+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1339+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1340+ * PURPOSE. See the GNU General Public License for more details.
1341+ *
1342+ * You should have received a copy of the GNU General Public License along
1343+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1344+ */
1345+
1346+public class WirelessBox : DeviceBox {
1347+
1348+ /* A Gtk.VBox which holds all of the widgets to control a wireless
1349+ device. It contains an InfoBox and ToggleSwitch to control and
1350+ monitor the state of the wireless device, and a
1351+ WirelessConnectionView to connect to and remember details for
1352+ wireless networks. */
1353+
1354+ private string datadir;
1355+ private Device device;
1356+ private InfoBox infobox;
1357+ private ToggleSwitch toggleswitch;
1358+ private Gtk.Label label_status;
1359+ private Gtk.Builder builder;
1360+ private WirelessConnectionView treeview_connections;
1361+ private Gtk.VBox vbox_connections;
1362+ private Gtk.Button button_connect;
1363+ private Gtk.Button button_forget;
1364+ private Gtk.Button button_edit;
1365+ private Gtk.ScrolledWindow scrolledwindow_connections;
1366+
1367+ public WirelessBox(Device device, string datadir) {
1368+ this.set_spacing(12);
1369+ this.datadir = datadir;
1370+ this.device = device;
1371+ this.device.state_changed.connect(this.on_device_state_changed);
1372+
1373+ // Infobox and Togglswitch
1374+ /// Creation
1375+ this.infobox = new InfoBox(false, 12);
1376+ this.toggleswitch = new ToggleSwitch();
1377+ this.label_status = new Gtk.Label(null);
1378+ /// Padding and alignment
1379+ this.label_status.set_alignment(0, 0.5f);
1380+ this.infobox.set_border_width(10);
1381+ /// Packing
1382+ this.infobox.pack_start(this.label_status, true, true);
1383+ this.infobox.pack_start(this.toggleswitch, false, true);
1384+ this.pack_start(this.infobox, false, false);
1385+ /// Connect signals;
1386+ this.toggleswitch.toggled.connect(this.on_toggleswitch_toggled);
1387+
1388+ // Network Settings
1389+ /// Creation
1390+ this.builder = Utils.Gui.new_builder(datadir+"ui/wireless_box.ui");
1391+ this.get_widgets();
1392+ this.connect_signals();
1393+ /// Packing
1394+ this.pack_start(this.vbox_connections, true, true);
1395+
1396+ // Connection View
1397+ /// Creation
1398+ var connection_store = new WirelessConnectionStore();
1399+ this.treeview_connections = new WirelessConnectionView(connection_store,
1400+ this.button_connect);
1401+ /// Packing
1402+ this.scrolledwindow_connections.add(this.treeview_connections);
1403+ /// Connect signals
1404+ this.treeview_connections.get_selection().changed.connect(this.on_treeview_connections_selection_changed);
1405+ /// Population
1406+ var connections = get_remembered_wireless_connections(device);
1407+ foreach (var connection in connections) {
1408+ this.add_connection(connection);
1409+ }
1410+
1411+ this.update_widget_states(this.device.get_state());
1412+ this.on_treeview_connections_selection_changed();
1413+ }
1414+
1415+ private void get_widgets() {
1416+ this.vbox_connections = this.builder.get_object("vbox_connections") as Gtk.VBox;
1417+ this.button_connect = this.builder.get_object("button_connect") as Gtk.Button;
1418+ this.button_forget = this.builder.get_object("button_forget") as Gtk.Button;
1419+ this.button_edit = this.builder.get_object("button_edit") as Gtk.Button;
1420+ this.scrolledwindow_connections = this.builder.get_object("scrolledwindow_connections") as Gtk.ScrolledWindow;
1421+ }
1422+
1423+ private void connect_signals() {
1424+ this.button_connect.clicked.connect(this.on_button_connect_clicked);
1425+ this.button_edit.clicked.connect(this.on_button_edit_clicked);
1426+ }
1427+
1428+ private void update_widget_states(DeviceState state) {
1429+ bool device_editable = false;
1430+ bool settings_editable = false;
1431+ bool toggleswitch_state = false;
1432+ string status_text = "";
1433+
1434+ switch (state) {
1435+ case DeviceState.CONNECTED:
1436+ device_editable = true;
1437+ settings_editable = true;
1438+ toggleswitch_state = true;
1439+ status_text = ("Wi-fi is on but not connected to the Internet.");
1440+ break;
1441+ case DeviceState.ONLINE:
1442+ device_editable = true;
1443+ settings_editable = true;
1444+ toggleswitch_state = true;
1445+ status_text = ("Wi-fi is on and connected to the Internet.");
1446+ break;
1447+ case DeviceState.OFF:
1448+ device_editable = false;
1449+ settings_editable = false;
1450+ toggleswitch_state = false;
1451+ status_text = ("The Wi-fi device is powered off.");
1452+ break;
1453+ case DeviceState.OFFLINE:
1454+ device_editable = true;
1455+ settings_editable = false;
1456+ toggleswitch_state = false;
1457+ status_text = ("Wi-fi is offline.");
1458+ break;
1459+ }
1460+
1461+ this.vbox_connections.set_sensitive(settings_editable);
1462+ this.toggleswitch.set_sensitive(device_editable);
1463+ this.toggleswitch.set_active(toggleswitch_state);
1464+ this.label_status.set_text(status_text);
1465+ }
1466+
1467+ private void add_connection(WifiConnection connection) {
1468+ var name = connection.name;
1469+ var signal = connection.signal;
1470+ var last_used = connection.last_used;
1471+
1472+ var liststore = this.treeview_connections.get_model() as WirelessConnectionStore;
1473+ liststore.add_connection(connection, name, signal, last_used);
1474+ }
1475+
1476+ public override void on_device_state_changed(DeviceState state) {
1477+ this.update_widget_states(state);
1478+ }
1479+
1480+ private void on_toggleswitch_toggled() {
1481+ if (this.toggleswitch.get_active()) {
1482+ this.device.set_state(DeviceState.CONNECTED);
1483+ } else {
1484+ this.device.set_state(DeviceState.OFFLINE);
1485+ }
1486+ }
1487+
1488+ private void on_button_connect_clicked() {
1489+ var connection = this.treeview_connections.get_selected_connection();
1490+ connection.connect_("password");
1491+ }
1492+
1493+ private void on_button_edit_clicked() {
1494+ var connection = this.treeview_connections.get_selected_connection();
1495+ var dialog = new EditConnectionDialog(connection, this.datadir);
1496+ //FIXME: make this work
1497+ //dialog.response.connect(() => { delete dialog; });
1498+ dialog.run();
1499+ }
1500+
1501+ private void on_treeview_connections_selection_changed() {
1502+ bool path_is_selected = (this.treeview_connections.get_selected_connection() != null);
1503+
1504+ this.button_connect.set_sensitive(path_is_selected);
1505+ this.button_forget.set_sensitive(path_is_selected);
1506+ this.button_edit.set_sensitive(path_is_selected);
1507+ }
1508+}
1509
1510=== added directory 'src/settings/frontend/widgets/dialogs'
1511=== added file 'src/settings/frontend/widgets/dialogs/edit-connection.vala'
1512--- src/settings/frontend/widgets/dialogs/edit-connection.vala 1970-01-01 00:00:00 +0000
1513+++ src/settings/frontend/widgets/dialogs/edit-connection.vala 2011-01-07 16:06:25 +0000
1514@@ -0,0 +1,165 @@
1515+/*
1516+ * indicator-network - user interface for connman
1517+ * Copyright 2010-2011 Canonical Ltd.
1518+ *
1519+ * Authors:
1520+ * Andrew Higginson
1521+ *
1522+ * This program is free software: you can redistribute it and/or modify it
1523+ * under the terms of the GNU General Public License version 3, as published
1524+ * by the Free Software Foundation.
1525+ *
1526+ * This program is distributed in the hope that it will be useful, but
1527+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1528+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1529+ * PURPOSE. See the GNU General Public License for more details.
1530+ *
1531+ * You should have received a copy of the GNU General Public License along
1532+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1533+ */
1534+
1535+public class EditConnectionDialog : GLib.Object {
1536+
1537+ public signal void response(int type);
1538+
1539+ private WifiConnection connection;
1540+ private Gtk.Builder builder;
1541+
1542+ private Gtk.Window dialog;
1543+ private Gtk.Table table_main;
1544+ private Gtk.Button button_save;
1545+ private Gtk.Button button_cancel;
1546+ private Gtk.Entry entry_name;
1547+ private Gtk.Entry entry_ssid;
1548+ private Gtk.Entry entry_bssid;
1549+ private Gtk.ComboBox combobox_mode;
1550+ private Gtk.CheckButton checkbutton_autoconnect;
1551+ private Gtk.CheckButton checkbutton_share_settings;
1552+
1553+ private string[] hint_labels = {"label_hint_name", "label_hint_ssid",
1554+ "label_hint_bssid","label_hint_mode"};
1555+
1556+ public EditConnectionDialog(WifiConnection connection, string datadir) {
1557+ this.connection = connection;
1558+
1559+ /// Creation
1560+ this.builder = Utils.Gui.new_builder(datadir+"ui/edit_connection_dialog.ui");
1561+ this.get_widgets();
1562+ this.create_extra_widgets();
1563+
1564+ this.connect_signals();
1565+ this.update_widget_values();
1566+ }
1567+
1568+ private void create_extra_widgets() {
1569+ // Creation
1570+ this.combobox_mode = new Gtk.ComboBox.text();
1571+
1572+ // Population
1573+ WirelessMode[] wireless_modes = {WirelessMode.INFRASTRUCTURE, WirelessMode.ADHOC};
1574+ foreach (var mode in wireless_modes) {
1575+ this.combobox_mode.append_text(mode.get_name());
1576+ }
1577+
1578+ // Packing
1579+ this.table_main.attach(this.combobox_mode, 1, 2, 6, 7, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL, 0, 0);
1580+
1581+ // Setup hint labels
1582+ foreach (var hint_label in this.hint_labels) {
1583+ var hint_label_widget = this.builder.get_object(hint_label) as Gtk.Label;
1584+ hint_label_widget.realize.connect(() => {
1585+ var state = hint_label_widget.get_state();
1586+ var color = hint_label_widget.style.fg[state];
1587+ var new_color = Utils.Color.shade(color);
1588+ hint_label_widget.modify_fg(state, new_color);
1589+ });
1590+ }
1591+ }
1592+
1593+ private void get_widgets() {
1594+ this.dialog = this.builder.get_object("window_main") as Gtk.Window;
1595+ this.table_main = this.builder.get_object("table_main") as Gtk.Table;
1596+ this.button_save = this.builder.get_object("button_save") as Gtk.Button;
1597+ this.button_cancel = this.builder.get_object("button_cancel") as Gtk.Button;
1598+
1599+ this.entry_name = this.builder.get_object("entry_name") as Gtk.Entry;
1600+ this.entry_ssid = this.builder.get_object("entry_ssid") as Gtk.Entry;
1601+ this.entry_bssid = this.builder.get_object("entry_bssid") as Gtk.Entry;
1602+ this.checkbutton_autoconnect = this.builder.get_object("checkbutton_autoconnect") as Gtk.CheckButton;
1603+ this.checkbutton_share_settings = this.builder.get_object("checkbutton_share_settings") as Gtk.CheckButton;
1604+ }
1605+
1606+ private void connect_signals() {
1607+ this.button_save.clicked.connect(this.on_button_save_clicked);
1608+ this.button_cancel.clicked.connect(this.on_button_cancel_clicked);
1609+ }
1610+
1611+ private void update_widget_values() {
1612+ var name = this.connection.name;
1613+ var ssid = this.connection.ssid;
1614+ var bssid = this.connection.bssid;
1615+ var mode = this.connection.mode;
1616+ var autoconnect = this.connection.autoconnect;
1617+ var share_settings = this.connection.share_settings;
1618+
1619+ if (name == null) {
1620+ this.entry_name.set_text("");
1621+ } else {
1622+ this.entry_name.set_text(name);
1623+ }
1624+ if (ssid == null) {
1625+ this.entry_ssid.set_text("");
1626+ } else {
1627+ this.entry_ssid.set_text(ssid);
1628+ }
1629+ if (bssid == null) {
1630+ this.entry_bssid.set_text("");
1631+ } else {
1632+ this.entry_bssid.set_text(bssid);
1633+ }
1634+
1635+ this.combobox_mode.set_active(mode);
1636+ this.checkbutton_autoconnect.set_active(autoconnect);
1637+ this.checkbutton_share_settings.set_active(share_settings);
1638+ }
1639+
1640+ private void save_widget_values() {
1641+ string? name = this.entry_name.get_text();
1642+ string? ssid = this.entry_ssid.get_text();
1643+ string? bssid = this.entry_bssid.get_text();
1644+ WirelessMode mode = (WirelessMode) this.combobox_mode.get_active();
1645+ var autoconnect = this.checkbutton_autoconnect.get_active();
1646+ var share_settings = this.checkbutton_share_settings.get_active();
1647+
1648+ if (name == "") {
1649+ name = null;
1650+ } if (ssid == "") {
1651+ ssid = null;
1652+ } if (bssid == "") {
1653+ bssid = null;
1654+ }
1655+
1656+ this.connection.name = name;
1657+ this.connection.ssid = ssid;
1658+ this.connection.bssid = bssid;
1659+ this.connection.mode = mode;
1660+ this.connection.autoconnect = autoconnect;
1661+ this.connection.share_settings = share_settings;
1662+ }
1663+
1664+ private void on_button_save_clicked() {
1665+ this.save_widget_values();
1666+ this.dialog.destroy();
1667+ this.response(Gtk.ResponseType.APPLY);
1668+ }
1669+
1670+ private void on_button_cancel_clicked() {
1671+ this.dialog.destroy();
1672+ this.response(Gtk.ResponseType.CANCEL);
1673+ }
1674+
1675+ public int run() {
1676+ this.dialog.show_all();
1677+ return 0;
1678+ }
1679+}
1680
1681=== added file 'src/settings/frontend/widgets/infobox.vala'
1682--- src/settings/frontend/widgets/infobox.vala 1970-01-01 00:00:00 +0000
1683+++ src/settings/frontend/widgets/infobox.vala 2011-01-07 16:06:25 +0000
1684@@ -0,0 +1,63 @@
1685+/*
1686+ * indicator-network - user interface for connman
1687+ * Copyright 2010-2011 Canonical Ltd.
1688+ *
1689+ * Authors:
1690+ * Andrew Higginson
1691+ *
1692+ * This program is free software: you can redistribute it and/or modify it
1693+ * under the terms of the GNU General Public License version 3, as published
1694+ * by the Free Software Foundation.
1695+ *
1696+ * This program is distributed in the hope that it will be useful, but
1697+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1698+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1699+ * PURPOSE. See the GNU General Public License for more details.
1700+ *
1701+ * You should have received a copy of the GNU General Public License along
1702+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1703+ */
1704+
1705+class InfoBox : Gtk.HBox {
1706+
1707+ /* A gtk.HBox that is filled with the mid-colour and stroked with
1708+ the dark colour from a user's gtk theme so that it stands out. */
1709+
1710+ private const int YPAD = 1;
1711+ private const int XPAD = 1;
1712+
1713+ public InfoBox(bool homogeneous=false, int spacing=0) {
1714+ this.set_homogeneous(homogeneous);
1715+ this.set_spacing(spacing);
1716+ this.expose_event.connect(this.on_expose_event);
1717+ }
1718+
1719+ public bool on_expose_event(Gdk.EventExpose event) {
1720+ var cr = Gdk.cairo_create(window);
1721+
1722+ // Get geometry
1723+ var x = (int) (this.allocation.x + this.XPAD);
1724+ var y = (int) (this.allocation.y + this.YPAD);
1725+ var width = (int) (this.allocation.width - (this.XPAD * 2));
1726+ var height = (int) (this.allocation.height - (this.YPAD * 2));
1727+
1728+ // Fill with the mid color from the current gtk theme
1729+ var fill = this.style.mid[this.state];
1730+ // Fill with the dark color from the current gtk theme
1731+ var stroke = this.style.dark[this.state];
1732+
1733+ // Layout the rectangle
1734+ cr.rectangle(x, y, width, height);
1735+ // Stroke the outline
1736+ cr.set_source_rgb((double) stroke.red / 65535.0,
1737+ (double) stroke.green / 65535.0,
1738+ (double) stroke.blue / 65535.0);
1739+ cr.stroke_preserve();
1740+ // Fill it in
1741+ cr.set_source_rgb((double) fill.red / 65535.0,
1742+ (double) fill.green / 65535.0,
1743+ (double) fill.blue / 65535.0);
1744+ cr.fill();
1745+ return false;
1746+ }
1747+}
1748
1749=== added file 'src/settings/frontend/widgets/stores.vala'
1750--- src/settings/frontend/widgets/stores.vala 1970-01-01 00:00:00 +0000
1751+++ src/settings/frontend/widgets/stores.vala 2011-01-07 16:06:25 +0000
1752@@ -0,0 +1,143 @@
1753+/*
1754+ * indicator-network - user interface for connman
1755+ * Copyright 2010-2011 Canonical Ltd.
1756+ *
1757+ * Authors:
1758+ * Andrew Higginson
1759+ *
1760+ * This program is free software: you can redistribute it and/or modify it
1761+ * under the terms of the GNU General Public License version 3, as published
1762+ * by the Free Software Foundation.
1763+ *
1764+ * This program is distributed in the hope that it will be useful, but
1765+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1766+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1767+ * PURPOSE. See the GNU General Public License for more details.
1768+ *
1769+ * You should have received a copy of the GNU General Public License along
1770+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1771+ */
1772+
1773+public enum DeviceStoreCol {
1774+ DEVICE_OBJ,
1775+ SETTINGS_BOX,
1776+ PIN,
1777+ ICON,
1778+ LABEL
1779+}
1780+
1781+class DeviceStore : Gtk.ListStore {
1782+
1783+ private Gtk.IconTheme icons;
1784+
1785+ private Gtk.TreeIter? device_iter;
1786+
1787+ public DeviceStore(Gtk.IconTheme icons) {
1788+ Type[] column_types;
1789+ column_types = {typeof(Device), typeof(Gtk.VBox),
1790+ typeof(string), typeof(Gdk.Pixbuf),
1791+ typeof(string)};
1792+ this.set_column_types(column_types);
1793+ this.icons = icons;
1794+ }
1795+
1796+ public void add_device(Device device, Gtk.VBox settings_box) {
1797+ device.state_changed.connect(this.on_device_state_changed);
1798+
1799+ var pin_color = this.get_pin_color(device.state);
1800+ var caption = device.state.get_name();
1801+ var label = device.type.get_name();
1802+ var icon = device.type.get_icon_name();
1803+ var markup = this.get_markup(label, caption);
1804+
1805+ Gdk.Pixbuf icon_pixbuf = null;
1806+ try {
1807+ icon_pixbuf = this.icons.load_icon(icon, 16, Gtk.IconLookupFlags.USE_BUILTIN);
1808+ } catch (Error e) {
1809+ var fallback_icon = DeviceType.GENERIC.get_icon_name();
1810+ logger.debug(@"Can't find '$icon' icon in your Gtk IconTheme, using '$fallback_icon' instead.");
1811+ try {
1812+ icon_pixbuf = this.icons.load_icon(fallback_icon, 16,
1813+ Gtk.IconLookupFlags.USE_BUILTIN);
1814+ } catch (Error e) {
1815+ logger.info("Failed to load fallback icon.");
1816+ }
1817+ }
1818+
1819+ Gtk.TreeIter iter;
1820+ this.append(out iter);
1821+ this.set(iter, 0, device, 1, settings_box, 2, pin_color, 3, icon_pixbuf, 4, markup);
1822+ }
1823+
1824+ private void on_device_state_changed(Device device, DeviceState state) {
1825+ var iter = this.get_iter_for_device(device);
1826+ var pin_color = this.get_pin_color(state);
1827+ var caption = state.get_name();
1828+ var label = device.type.get_name();
1829+
1830+ var markup = this.get_markup(label, caption);
1831+
1832+ this.set_value(iter, DeviceStoreCol.PIN, pin_color);
1833+ this.set_value(iter, DeviceStoreCol.LABEL, markup);
1834+ }
1835+
1836+ private Gtk.TreeIter get_iter_for_device(Device device) {
1837+ this.device_iter = null;
1838+ this.foreach((model, path, iter) => {
1839+ GLib.Value value;
1840+ model.get_value(iter, DeviceStoreCol.DEVICE_OBJ, out value);
1841+ if ((value.get_object() as Device) == device) {
1842+ this.device_iter = iter;
1843+ return true;
1844+ }
1845+ return false;
1846+ });
1847+ return this.device_iter;
1848+ }
1849+
1850+ private string get_pin_color(DeviceState state) {
1851+ switch (state) {
1852+ case DeviceState.OFF:
1853+ return "grey";
1854+ case DeviceState.OFFLINE:
1855+ return "red";
1856+ case DeviceState.CONNECTED:
1857+ return "yellow";
1858+ case DeviceState.ONLINE:
1859+ return "green";
1860+ default:
1861+ assert_not_reached();
1862+ }
1863+ }
1864+
1865+ private string get_markup(string label, string caption) {
1866+ return @"$label\n<span font_size='small'>$caption</span>";
1867+ }
1868+}
1869+
1870+
1871+public enum WirelessConnectionStoreCol {
1872+ CONNECTION_OBJ,
1873+ NETWORK,
1874+ SIGNAL,
1875+ LAST_USED
1876+}
1877+
1878+class WirelessConnectionStore : Gtk.ListStore {
1879+
1880+ public WirelessConnectionStore() {
1881+ Type[] column_types;
1882+ column_types = {typeof(WifiConnection), typeof(string),
1883+ typeof(double), typeof(string)};
1884+ this.set_column_types(column_types);
1885+ }
1886+
1887+ public void add_connection(WifiConnection obj, string network,
1888+ double signal, string last_used) {
1889+ Gtk.TreeIter iter;
1890+ this.append(out iter);
1891+ this.set(iter, 0, obj, 1, network, 2, signal, 3, last_used);
1892+ }
1893+}
1894+
1895+
1896
1897=== added file 'src/settings/frontend/widgets/toggleswitch.vala'
1898--- src/settings/frontend/widgets/toggleswitch.vala 1970-01-01 00:00:00 +0000
1899+++ src/settings/frontend/widgets/toggleswitch.vala 2011-01-07 16:06:25 +0000
1900@@ -0,0 +1,356 @@
1901+/*
1902+ * indicator-network - user interface for connman
1903+ * Copyright 2010-2011 Canonical Ltd.
1904+ *
1905+ * Authors:
1906+ * Andrew Higginson
1907+ *
1908+ * This program is free software: you can redistribute it and/or modify it
1909+ * under the terms of the GNU General Public License version 3, as published
1910+ * by the Free Software Foundation.
1911+ *
1912+ * This program is distributed in the hope that it will be useful, but
1913+ * WITHOUT ANY WARRANTY; without even the implied warranties of
1914+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1915+ * PURPOSE. See the GNU General Public License for more details.
1916+ *
1917+ * You should have received a copy of the GNU General Public License along
1918+ * with this program. If not, see <http://www.gnu.org/licenses/>.
1919+ */
1920+
1921+public class ToggleSwitch : Gtk.EventBox {
1922+
1923+ // A switch containing the values ON and OFF (or user-inputed) that
1924+ // hides the inactive value. It can be clicked or dragged to change
1925+ // state, or through an enter/return keypress.
1926+
1927+ public signal void clicked();
1928+ public signal void toggled();
1929+
1930+ // (In relation to the height of the slider)
1931+ private double LINE_HEIGHT_RATIO = 9.0/25.0;
1932+ private double LINE_SPACING_RATIO = 5.0/38.0;
1933+ private double CORNER_RADIUS = 3.0;
1934+
1935+ // (In relation to the width/height of the text)
1936+ private double TEXT_XPAD = 0.4;
1937+ private double TEXT_YPAD = 0.35;
1938+
1939+ private string[] values={"ON", "OFF"};
1940+ private Pango.Layout? layout = null;
1941+ private Atk.Object? atk = null;
1942+
1943+ public bool active = false;
1944+
1945+ public ToggleSwitch() {
1946+ this.set_visible_window(false);
1947+ this.app_paintable = true;
1948+ this.double_buffered = false;
1949+
1950+ // Set events for the widget to receive
1951+ this.set_can_focus(true);
1952+ this.set_events(Gdk.EventMask.KEY_PRESS_MASK|
1953+ Gdk.EventMask.ENTER_NOTIFY_MASK|
1954+ Gdk.EventMask.LEAVE_NOTIFY_MASK|
1955+ Gdk.EventMask.BUTTON_PRESS_MASK|
1956+ Gdk.EventMask.BUTTON_RELEASE_MASK);
1957+
1958+ // Connect signls and callbacks
1959+ this.style_set.connect(this.on_style_set);
1960+ this.expose_event.connect(this.on_expose_event);
1961+ this.button_press_event.connect(this.on_press);
1962+ this.button_release_event.connect(this.on_release);
1963+ this.key_release_event.connect(this.on_key_release);
1964+ this.enter_notify_event.connect(this.on_enter);
1965+ this.leave_notify_event.connect(this.on_leave);
1966+ this.motion_notify_event.connect(this.on_motion_notify_event);
1967+
1968+ // Calculate the best size
1969+ int calc_width;
1970+ int calc_height;
1971+ this.calculate_size(out calc_width, out calc_height);
1972+ this.set_size_request(calc_width, calc_height);
1973+
1974+ this.update_atk();
1975+ }
1976+
1977+ private void calculate_size(out int width, out int height) {
1978+ // Calculate the best size for the toggleswitch based on the
1979+ // dimensions of the user's default font.
1980+ this.layout = this.create_pango_layout(null);
1981+
1982+ this.layout.set_text(this.values[0], -1);
1983+
1984+ Pango.Rectangle extents;
1985+
1986+ this.layout.get_pixel_extents(null, out extents);
1987+ var text_width = extents.width;
1988+ var text_height = extents.height;
1989+
1990+ width = (int) ((text_width+(text_width*this.TEXT_XPAD*2))*2);
1991+ height = (int) (text_height+(text_height*this.TEXT_YPAD*2));
1992+ }
1993+
1994+
1995+ private void draw_widget() {
1996+ // Do the drawing of the actual widget.
1997+ var cr = Gdk.cairo_create(this.window);
1998+
1999+ // Draw the main background
2000+ this.draw_background(cr);
2001+
2002+ // Draw the text
2003+ this.draw_text();
2004+
2005+ // Draw the slider
2006+ this.draw_slider(cr);
2007+ }
2008+
2009+ private void draw_background(Cairo.Context cr) {
2010+ int x = this.allocation.x;
2011+ int y = this.allocation.y;
2012+ int width = this.allocation.width;
2013+ int height = this.allocation.height;
2014+
2015+ var state = this.state;
2016+ // Don't change colour of main background on hover or press
2017+ if ((this.state == Gtk.StateType.PRELIGHT) | (this.state == Gtk.StateType.ACTIVE)) {
2018+ state = Gtk.StateType.NORMAL;
2019+ }
2020+
2021+ // Get colours from theme
2022+ var bg_fill = this.style.base[state];
2023+ var bg_stroke = this.style.dark[state];
2024+ var left_fill = this.style.light[Gtk.StateType.SELECTED];
2025+ var left_stroke = this.style.mid[Gtk.StateType.SELECTED];
2026+ var right_fill = this.style.base[state];
2027+ var right_stroke = this.style.dark[state];
2028+
2029+ // Draw the background of the whole widget
2030+ this.draw_flat_rounded_rectangle(cr, x, y, width, height, bg_stroke, bg_fill);
2031+
2032+ // Draw the left (highlighted) part
2033+ this.draw_flat_rounded_rectangle(cr, x, y, width/2, height, left_stroke, left_fill);
2034+
2035+ // Draw the right (normal) part
2036+ this.draw_flat_rounded_rectangle(cr, x+width/2, y, width/2, height, right_stroke, right_fill);
2037+ }
2038+
2039+ private void draw_slider(Cairo.Context cr) {
2040+ int x = this.allocation.x;
2041+ int y = this.allocation.y;
2042+ int width = this.allocation.width;
2043+ int height = this.allocation.height;
2044+ int x_offset = 0;
2045+
2046+ if (this.active) {
2047+ x_offset = width/2;
2048+ }
2049+
2050+ var stroke = this.style.dark[this.state];
2051+ Gdk.Color fill1_rectangle;
2052+ Gdk.Color fill2_rectangle;
2053+
2054+ // Don't draw a gradient if insensitive
2055+ if (this.state == Gtk.StateType.INSENSITIVE) {
2056+ fill1_rectangle = this.style.bg[this.state];
2057+ fill2_rectangle = this.style.bg[this.state];
2058+ } else {
2059+ fill1_rectangle = this.style.light[this.state];
2060+ fill2_rectangle = this.style.mid[this.state];
2061+ }
2062+
2063+ // Draw the slider
2064+ this.draw_rounded_rectangle(cr, x+x_offset, y, width/2, height, stroke, fill1_rectangle, fill2_rectangle);
2065+
2066+ // Draw the vertical lines
2067+ this.draw_vertical_lines(cr, x+x_offset, y, width, height);
2068+
2069+ }
2070+
2071+ private void draw_vertical_lines(Cairo.Context cr, int x, int y, int width, int height) {
2072+ var fill_line_dark = this.style.dark[this.state];
2073+ var fill_line_light = this.style.light[this.state];
2074+ var line_height = (int) height*this.LINE_HEIGHT_RATIO;
2075+ var line_spacing = (int) (this.LINE_SPACING_RATIO * (width / 2));
2076+
2077+ var x_offset = ((width / 2) - (6+(line_spacing*2)))/2 + 2;
2078+ var y_offset = (height - line_height)/2;
2079+
2080+ double c_spacing = 0;
2081+ for (int i=0; i<3; i++) {
2082+ cr.rectangle(x+x_offset+c_spacing+1, y+y_offset, 1, line_height);
2083+ cr.set_source_rgb((double) fill_line_dark.red / 65535.0,
2084+ (double) fill_line_dark.green / 65535.0,
2085+ (double) fill_line_dark.blue / 65535.0);
2086+ cr.fill();
2087+ cr.rectangle(x+x_offset+c_spacing, y+y_offset, 1, line_height);
2088+ cr.set_source_rgb((double) fill_line_light.red / 65535.0,
2089+ (double) fill_line_light.green / 65535.0,
2090+ (double) fill_line_light.blue / 65535.0);
2091+ cr.fill();
2092+ c_spacing += line_spacing;
2093+ }
2094+ }
2095+
2096+ private void draw_text() {
2097+ this.draw_centered_text(this.values[0], "left");
2098+ this.draw_centered_text(this.values[1], "right");
2099+ }
2100+
2101+ private void draw_centered_text(string text, string gravity) {
2102+ if (this.layout == null) {
2103+ this.layout = this.create_pango_layout(null);
2104+ }
2105+
2106+ int x = this.allocation.x;
2107+ int y = this.allocation.y;
2108+ int width = this.allocation.width;
2109+ int height = this.allocation.height;
2110+
2111+ int x_offset;
2112+ int y_offset;
2113+ Pango.Rectangle extents;
2114+
2115+ this.layout.set_text(text, -1);
2116+ this.layout.get_pixel_extents(null, out extents);
2117+ var text_width = extents.width;
2118+ var text_height = extents.height;
2119+
2120+ x_offset = (width/2 - text_width) / 2;
2121+
2122+ if (gravity == "right") {
2123+ x_offset += width/2;
2124+ }
2125+
2126+ y_offset = (height - text_height) / 2;
2127+
2128+ this.style.draw_layout(this.window, this.get_state(), true,
2129+ {x, y, width, height},
2130+ this, "", x+x_offset, y+y_offset,
2131+ this.layout);
2132+ }
2133+
2134+
2135+ private void draw_rounded_rectangle(Cairo.Context cr, double x,
2136+ double y, double w, double h, Gdk.Color stroke, Gdk.Color fill1, Gdk.Color fill2) {
2137+
2138+ var r = this.CORNER_RADIUS;
2139+ cr.new_sub_path();
2140+ cr.arc(r+x, r+y, r, PI, 270*PI_OVER_180);
2141+ cr.arc(x+w-r, r+y, r, 270*PI_OVER_180, 0);
2142+ cr.arc(x+w-r, y+h-r, r, 0, 90*PI_OVER_180);
2143+ cr.arc(r+x, y+h-r, r, 90*PI_OVER_180, PI);
2144+ cr.close_path();
2145+
2146+ cr.set_source_rgb((double) stroke.red / 65535.0,
2147+ (double) stroke.green / 65535.0,
2148+ (double) stroke.blue / 65535.0);
2149+ cr.stroke_preserve();
2150+
2151+ var linear = new Cairo.Pattern.linear(x, y, x, y+h);
2152+ linear.add_color_stop_rgba(0.00, (double) fill1.red / 65535.0,
2153+ (double) fill1.green / 65535.0, (double) fill1.blue / 65535.0, 1);
2154+ linear.add_color_stop_rgba(0.8, (double) fill2.red / 65535.0,
2155+ (double) fill2.green / 65535.0, (double) fill2.blue / 65535.0, 1);
2156+ cr.set_source(linear);
2157+ cr.fill();
2158+ }
2159+
2160+ private void draw_flat_rounded_rectangle(Cairo.Context cr, double x,
2161+ double y, double w, double h, Gdk.Color stroke, Gdk.Color fill) {
2162+
2163+ var r = this.CORNER_RADIUS;
2164+ cr.new_sub_path();
2165+ cr.arc(r+x, r+y, r, PI, 270*PI_OVER_180);
2166+ cr.arc(x+w-r, r+y, r, 270*PI_OVER_180, 0);
2167+ cr.arc(x+w-r, y+h-r, r, 0, 90*PI_OVER_180);
2168+ cr.arc(r+x, y+h-r, r, 90*PI_OVER_180, PI);
2169+ cr.close_path();
2170+
2171+ cr.set_source_rgb((double) stroke.red / 65535.0,
2172+ (double) stroke.green / 65535.0,
2173+ (double) stroke.blue / 65535.0);
2174+ cr.stroke_preserve();
2175+
2176+ cr.set_source_rgb((double) fill.red / 65535.0,
2177+ (double) fill.green / 65535.0,
2178+ (double) fill.blue / 65535.0);
2179+ cr.fill();
2180+ }
2181+
2182+ private void update_atk() {
2183+ // Accessibility info
2184+ if (this.atk == null) {
2185+ this.atk = this.get_accessible();
2186+ this.atk.set_role(Atk.Role.CHECK_BOX);
2187+ }
2188+
2189+ // Update ATK description, based on state
2190+ if (this.active) {
2191+ this.atk.set_name(this.values[0]);
2192+ } else {
2193+ this.atk.set_name(this.values[1]);
2194+ }
2195+ }
2196+
2197+ private void on_style_set(Gtk.Style? style) {
2198+ int calc_width;
2199+ int calc_height;
2200+
2201+ this.calculate_size(out calc_width, out calc_height);
2202+ this.set_size_request(calc_width, calc_height);
2203+ }
2204+
2205+ private bool on_expose_event(Gdk.EventExpose event) {
2206+ this.draw_widget();
2207+ return true;
2208+ }
2209+
2210+ private bool on_press(Gdk.EventButton event) {
2211+ this.set_state(Gtk.StateType.ACTIVE);
2212+ this.grab_focus();
2213+ return false;
2214+ }
2215+
2216+ private bool on_release(Gdk.EventButton event) {
2217+ this.set_state(Gtk.StateType.PRELIGHT);
2218+ this.active = !this.active;
2219+ this.toggled();
2220+ return false;
2221+ }
2222+
2223+ private bool on_motion_notify_event(Gdk.EventMotion event) {
2224+ this.queue_draw();
2225+ return false;
2226+ }
2227+
2228+ private bool on_key_release(Gdk.EventKey event) {
2229+ if (this.has_focus) {
2230+ if ((Gdk.keyval_name(event.keyval) == "Return") | (Gdk.keyval_name(event.keyval) == "Enter")) {
2231+ this.toggled();
2232+ }
2233+ }
2234+ return false;
2235+ }
2236+
2237+ private bool on_enter(Gdk.EventCrossing event) {
2238+ this.set_state(Gtk.StateType.PRELIGHT);
2239+ return false;
2240+ }
2241+
2242+ private bool on_leave(Gdk.EventCrossing event) {
2243+ this.set_state(Gtk.StateType.NORMAL);
2244+ return false;
2245+ }
2246+
2247+ public bool get_active() {
2248+ return this.active;
2249+ }
2250+
2251+ public void set_active(bool active) {
2252+ this.active = active;
2253+ this.queue_draw();
2254+ }
2255+
2256+}
2257
2258=== added file 'src/settings/frontend/widgets/treeviews.vala'
2259--- src/settings/frontend/widgets/treeviews.vala 1970-01-01 00:00:00 +0000
2260+++ src/settings/frontend/widgets/treeviews.vala 2011-01-07 16:06:25 +0000
2261@@ -0,0 +1,133 @@
2262+/*
2263+ * indicator-network - user interface for connman
2264+ * Copyright 2010-2011 Canonical Ltd.
2265+ *
2266+ * Authors:
2267+ * Andrew Higginson
2268+ *
2269+ * This program is free software: you can redistribute it and/or modify it
2270+ * under the terms of the GNU General Public License version 3, as published
2271+ * by the Free Software Foundation.
2272+ *
2273+ * This program is distributed in the hope that it will be useful, but
2274+ * WITHOUT ANY WARRANTY; without even the implied warranties of
2275+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2276+ * PURPOSE. See the GNU General Public License for more details.
2277+ *
2278+ * You should have received a copy of the GNU General Public License along
2279+ * with this program. If not, see <http://www.gnu.org/licenses/>.
2280+ */
2281+
2282+class DeviceView : Gtk.TreeView {
2283+
2284+ public signal void reordered();
2285+
2286+ private bool dragging = false;
2287+
2288+ public DeviceView (DeviceStore store) {
2289+ this.set_model(store);
2290+
2291+ // Device (main) Column (contains pin icon, type icon and label)
2292+ var column = new Gtk.TreeViewColumn();
2293+ column.set_title(("Device"));
2294+ var cr_pin = new PinCellRenderer();
2295+ var cr_icon = new Gtk.CellRendererPixbuf();
2296+ var cr_label = new Gtk.CellRendererText();
2297+ column.pack_start(cr_pin, false);
2298+ column.set_attributes(cr_pin, "color", DeviceStoreCol.PIN);
2299+ column.pack_start(cr_icon, false);
2300+ column.set_attributes(cr_icon, "pixbuf", DeviceStoreCol.ICON);
2301+ column.pack_start(cr_label, true);
2302+ column.set_attributes(cr_label, "markup", DeviceStoreCol.LABEL);
2303+ cr_label.set_property("ellipsize", Pango.EllipsizeMode.END);
2304+ this.append_column(column);
2305+
2306+ this.set_headers_visible(false);
2307+ /* FIXME: when get gtk errors if we enable reordering and
2308+ try to get the selected path
2309+ this.set_reorderable(true);*/
2310+
2311+ this.drag_begin.connect(this.on_drag_begin);
2312+ this.drag_end.connect(this.on_drag_end);
2313+ this.drag_failed.connect(this.on_drag_failed);
2314+ }
2315+
2316+ private void on_drag_begin(Gdk.DragContext drag_context) {
2317+ this.dragging = true;
2318+ }
2319+
2320+ private bool on_drag_failed(Gdk.DragContext drag_context, Gtk.DragResult drag_result) {
2321+ this.dragging = false;
2322+ return true;
2323+ }
2324+
2325+ private void on_drag_end(Gdk.DragContext drag_context) {
2326+ if (this.dragging) {
2327+ this.reordered();
2328+ }
2329+ }
2330+
2331+/* FIXME: unused for now so comment it out
2332+
2333+ public Device? get_selected_device() {
2334+ Gtk.TreeModel model;
2335+ Gtk.TreeIter? iter;
2336+ this.get_selection().get_selected(out model, out iter);
2337+ if (iter == null) {
2338+ return null;
2339+ } else {
2340+ GLib.Value value;
2341+ model.get_value(iter, 0, out value);
2342+ return value.get_object() as Device;
2343+ }
2344+
2345+ }
2346+*/
2347+
2348+}
2349+
2350+class WirelessConnectionView : Gtk.TreeView {
2351+
2352+ public WirelessConnectionView(WirelessConnectionStore store, Gtk.Widget style_widget) {
2353+ this.set_model(store);
2354+
2355+ // Network Column (contains label)
2356+ var network_column = new Gtk.TreeViewColumn();
2357+ network_column.set_title(("Network"));
2358+ var cr_label_network = new Gtk.CellRendererText();
2359+ network_column.pack_start(cr_label_network, true);
2360+ network_column.set_attributes(cr_label_network, "markup", WirelessConnectionStoreCol.NETWORK);
2361+ network_column.set_expand(true);
2362+ this.append_column(network_column);
2363+
2364+ // Signal Column (contains signal indicator)
2365+ var signal_column = new Gtk.TreeViewColumn();
2366+ signal_column.set_title(("Signal"));
2367+ var cr_signal = new SignalStrengthCellRenderer(style_widget, this);
2368+ signal_column.pack_start(cr_signal, true);
2369+ signal_column.set_attributes(cr_signal, "strength", 2);
2370+ signal_column.set_clickable(true);
2371+ signal_column.set_sort_column_id(2);
2372+ this.append_column(signal_column);
2373+
2374+ // Last Used Column (contains label)
2375+ var last_used_column = new Gtk.TreeViewColumn();
2376+ last_used_column.set_title(("Last Used"));
2377+ var cr_label_last_used = new Gtk.CellRendererText();
2378+ last_used_column.pack_start(cr_label_last_used, true);
2379+ last_used_column.set_attributes(cr_label_last_used, "markup", WirelessConnectionStoreCol.LAST_USED);
2380+ this.append_column(last_used_column);
2381+ }
2382+
2383+ public WifiConnection? get_selected_connection() {
2384+ Gtk.TreeModel model;
2385+ Gtk.TreeIter? iter;
2386+ this.get_selection().get_selected(out model, out iter);
2387+ if (iter != null) {
2388+ GLib.Value value;
2389+ model.get_value(iter, WirelessConnectionStoreCol.CONNECTION_OBJ, out value);
2390+ return value.get_object() as WifiConnection;
2391+ }
2392+ return null;
2393+ }
2394+}
2395
2396=== removed file 'src/settings/indicator-network-settings'
2397--- src/settings/indicator-network-settings 2010-12-13 13:44:21 +0000
2398+++ src/settings/indicator-network-settings 1970-01-01 00:00:00 +0000
2399@@ -1,61 +0,0 @@
2400-#!/usr/bin/python
2401-# Copyright (C) 2010 Canonical
2402-#
2403-# Authors:
2404-# Andrew Higginson
2405-#
2406-# This program is free software; you can redistribute it and/or modify it under
2407-# the terms of the GNU General Public License as published by the Free Software
2408-# Foundation; version 3.
2409-#
2410-# This program is distributed in the hope that it will be useful, but WITHOUT
2411-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2412-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
2413-# details.
2414-#
2415-# You should have received a copy of the GNU General Public License along with
2416-# this program; if not, write to the Free Software Foundation, Inc.,
2417-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2418-
2419-import pygtk
2420-pygtk.require ("2.0")
2421-import gtk
2422-
2423-import gettext
2424-import logging
2425-import os
2426-import sys
2427-
2428-from optparse import OptionParser
2429-from indicatorNetworkSettings.enums import *
2430-from indicatorNetworkSettings.version import *
2431-
2432-if __name__ == "__main__":
2433- parser = OptionParser("usage: %prog [options]", version="%prog "+VERSION)
2434- parser.add_option("--debug", action="store_true",
2435- help="enable debug mode", default=False)
2436- parser.add_option("--force-rtl", action="store_true",
2437- help="force rtl mode (useful for debugging)",
2438- default=False)
2439- (options, args) = parser.parse_args()
2440-
2441- if options.debug:
2442- logging.basicConfig(level=logging.DEBUG)
2443- else:
2444- logging.basicConfig(level=logging.INFO)
2445-
2446- # Override text direction for testing purposes
2447- if options.force_rtl:
2448- gtk.widget_set_default_direction(gtk.TEXT_DIR_RTL)
2449-
2450- if os.path.exists("./ui/indicator-network-settings.ui"):
2451- logging.info("Running locally")
2452- datadir = "./"
2453- else:
2454- datadir = "/usr/share/indicator-network/"
2455-
2456- from indicatorNetworkSettings.app import NetworkSettingsApp
2457-
2458- app = NetworkSettingsApp(datadir)
2459- app.run()
2460-
2461
2462=== removed directory 'src/settings/indicatorNetworkSettings'
2463=== removed file 'src/settings/indicatorNetworkSettings/Makefile.am'
2464--- src/settings/indicatorNetworkSettings/Makefile.am 2010-12-13 13:55:55 +0000
2465+++ src/settings/indicatorNetworkSettings/Makefile.am 1970-01-01 00:00:00 +0000
2466@@ -1,13 +0,0 @@
2467-SUBDIRS = \
2468- backend \
2469- frontend
2470-
2471-# indicator-network-settings
2472-insdir = $(pkgdatadir)/indicatorNetworkSettings
2473-ins_PYTHON = \
2474- app.py \
2475- enums.py \
2476- __init__.py \
2477- SimpleGtkbuilderApp.py \
2478- utils.py \
2479- version.py
2480
2481=== removed file 'src/settings/indicatorNetworkSettings/SimpleGtkbuilderApp.py'
2482--- src/settings/indicatorNetworkSettings/SimpleGtkbuilderApp.py 2010-12-13 13:45:08 +0000
2483+++ src/settings/indicatorNetworkSettings/SimpleGtkbuilderApp.py 1970-01-01 00:00:00 +0000
2484@@ -1,58 +0,0 @@
2485-"""
2486- SimpleGtkbuilderApp.py
2487- Module that provides an object oriented abstraction to pygtk and gtkbuilder
2488- Copyright (C) 2009 Canonical
2489- Author Michael Vogt
2490- based on ideas from SimpleGladeBuilder by Sandino Flores Moreno
2491-"""
2492-
2493-# This library is free software; you can redistribute it and/or
2494-# modify it under the terms of the GNU Lesser General Public
2495-# License as published by the Free Software Foundation; version 3.
2496-#
2497-# This library is distributed in the hope that it will be useful,
2498-# but WITHOUT ANY WARRANTY; without even the implied warranty of
2499-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2500-# Lesser General Public License for more details.
2501-#
2502-# You should have received a copy of the GNU Lesser General Public
2503-# License along with this library; if not, write to the Free Software
2504-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
2505-# USA
2506-
2507-import sys
2508-import gtk
2509-
2510-class SimpleGtkbuilderApp(object):
2511- def __init__(self, path, domain):
2512- self.builder = gtk.Builder()
2513- self.builder.set_translation_domain(domain)
2514- self.builder.add_from_file(path)
2515- self.builder.connect_signals(self)
2516- for o in self.builder.get_objects():
2517- if issubclass(type(o), gtk.Buildable):
2518- name = gtk.Buildable.get_name(o)
2519- setattr(self, name, o)
2520- else:
2521- print >> sys.stderr, "WARNING: can not get name for '%s'" % o
2522-
2523- def run(self):
2524- """
2525- Starts the main loop of processing events checking for Control-C.
2526-
2527- The default implementation checks wheter a Control-C is pressed,
2528- then calls on_keyboard_interrupt().
2529-
2530- Use this method for starting programs.
2531- """
2532- try:
2533- gtk.main()
2534- except KeyboardInterrupt:
2535- self.on_keyboard_interrupt()
2536-
2537- def on_keyboard_interrupt(self):
2538- """
2539- This method is called by the default implementation of run()
2540- after a program is finished by pressing Control-C.
2541- """
2542- pass
2543
2544=== removed file 'src/settings/indicatorNetworkSettings/__init__.py'
2545--- src/settings/indicatorNetworkSettings/__init__.py 2010-12-07 15:07:37 +0000
2546+++ src/settings/indicatorNetworkSettings/__init__.py 1970-01-01 00:00:00 +0000
2547@@ -1,1 +0,0 @@
2548-
2549
2550=== removed file 'src/settings/indicatorNetworkSettings/app.py'
2551--- src/settings/indicatorNetworkSettings/app.py 2010-12-13 14:18:58 +0000
2552+++ src/settings/indicatorNetworkSettings/app.py 1970-01-01 00:00:00 +0000
2553@@ -1,78 +0,0 @@
2554-# Copyright (C) 2010 Canonical
2555-#
2556-# Authors:
2557-# Andrew Higginson
2558-#
2559-# This program is free software; you can redistribute it and/or modify it under
2560-# the terms of the GNU General Public License as published by the Free Software
2561-# Foundation; version 3.
2562-#
2563-# This program is distributed in the hope that it will be useful, but WITHOUT
2564-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2565-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
2566-# details.
2567-#
2568-# You should have received a copy of the GNU General Public License along with
2569-# this program; if not, write to the Free Software Foundation, Inc.,
2570-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2571-
2572-import locale
2573-import gtk
2574-import os
2575-import gettext
2576-
2577-from indicatorNetworkSettings.enums import *
2578-from indicatorNetworkSettings.version import *
2579-from indicatorNetworkSettings.frontend.pages.connections import \
2580- ConnectionsPage
2581-from indicatorNetworkSettings.backend.devicemanager import \
2582- DeviceManager
2583-from indicatorNetworkSettings.SimpleGtkbuilderApp import \
2584- SimpleGtkbuilderApp
2585-
2586-class NetworkSettingsApp(SimpleGtkbuilderApp):
2587- def __init__(self, datadir):
2588- SimpleGtkbuilderApp.__init__(self,
2589- os.path.join(datadir, "ui", "indicator-network-settings.ui"),
2590- "indicator-network-settings")
2591-
2592- # Useful variables
2593- self.datadir = datadir
2594- self.icons = gtk.icon_theme_get_default()
2595-
2596- # Setup Translations
2597- self._setup_translations()
2598-
2599- self.devicemanager = DeviceManager()
2600-
2601- # Setup Pages
2602- self.page_connections = ConnectionsPage(self, datadir)
2603- self.pages = [self.page_connections]
2604-
2605- self.on_notebook_main_page_switched(None, None, 0)
2606-
2607- # Callbacks
2608- def on_window_main_delete_event(self, widget, event):
2609- gtk.main_quit()
2610-
2611- def on_notebook_main_page_switched(self, widget, move_focus, page_num):
2612- page_alignment = self.notebook_main.get_nth_page(page_num)
2613-
2614- for page in self.pages:
2615- if page.alignment == page_alignment:
2616- page.on_first_expose()
2617-
2618- # Private Functions
2619- def _setup_translations(self):
2620- gettext.bindtextdomain("indicator-network-settings",
2621- "/usr/share/locale")
2622- gettext.textdomain("indicator-network-settings")
2623- try:
2624- locale.setlocale(locale.LC_ALL, "")
2625- except Exception:
2626- print "setlocale failed"
2627-
2628- # Public Functions
2629- def run(self):
2630- self.window_main.show_all()
2631- super(NetworkSettingsApp, self).run()
2632
2633=== removed directory 'src/settings/indicatorNetworkSettings/backend'
2634=== removed file 'src/settings/indicatorNetworkSettings/backend/Makefile.am'
2635--- src/settings/indicatorNetworkSettings/backend/Makefile.am 2010-12-13 13:55:55 +0000
2636+++ src/settings/indicatorNetworkSettings/backend/Makefile.am 1970-01-01 00:00:00 +0000
2637@@ -1,6 +0,0 @@
2638-# indicator-network-settings
2639-insdir = $(pkgdatadir)/indicatorNetworkSettings/backend
2640-ins_PYTHON = \
2641- connection.py \
2642- device.py \
2643- __init__.py
2644
2645=== removed file 'src/settings/indicatorNetworkSettings/backend/__init__.py'
2646--- src/settings/indicatorNetworkSettings/backend/__init__.py 2010-12-07 15:07:37 +0000
2647+++ src/settings/indicatorNetworkSettings/backend/__init__.py 1970-01-01 00:00:00 +0000
2648@@ -1,1 +0,0 @@
2649-
2650
2651=== removed file 'src/settings/indicatorNetworkSettings/backend/connection.py'
2652--- src/settings/indicatorNetworkSettings/backend/connection.py 2010-12-13 14:18:58 +0000
2653+++ src/settings/indicatorNetworkSettings/backend/connection.py 1970-01-01 00:00:00 +0000
2654@@ -1,31 +0,0 @@
2655-#!/usr/bin/env python
2656-# -*- coding: utf-8 -*-
2657-#
2658-# Copyright (C) 2010 Canonical
2659-#
2660-# Authors:
2661-# Andrew Higginson
2662-#
2663-# This program is free software; you can redistribute it and/or modify it under
2664-# the terms of the GNU General Public License as published by the Free Software
2665-# Foundation; version 3.
2666-#
2667-# This program is distributed in the hope that it will be useful, but WITHOUT
2668-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2669-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
2670-# details.
2671-#
2672-# You should have received a copy of the GNU General Public License along with
2673-# this program; if not, write to the Free Software Foundation, Inc.,
2674-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2675-
2676-import datetime
2677-
2678-class WifiConnection(object):
2679- def __init__(self):
2680- self.network = None
2681- self.signal = None
2682- self.last_used = None
2683-
2684- def connect_(self, key):
2685- print "Connecting to %s" % self.network
2686
2687=== removed file 'src/settings/indicatorNetworkSettings/backend/connmanmanager.py'
2688--- src/settings/indicatorNetworkSettings/backend/connmanmanager.py 2010-12-13 18:48:43 +0000
2689+++ src/settings/indicatorNetworkSettings/backend/connmanmanager.py 1970-01-01 00:00:00 +0000
2690@@ -1,160 +0,0 @@
2691-#!/usr/bin/env python
2692-# -*- coding: utf-8 -*-
2693-#
2694-# Copyright (C) 2010 Canonical
2695-#
2696-# Authors:
2697-# Kalle Valo
2698-#
2699-# This program is free software; you can redistribute it and/or modify it under
2700-# the terms of the GNU General Public License as published by the Free Software
2701-# Foundation; version 3.
2702-#
2703-# This program is distributed in the hope that it will be useful, but WITHOUT
2704-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2705-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
2706-# details.
2707-#
2708-# You should have received a copy of the GNU General Public License along with
2709-# this program; if not, write to the Free Software Foundation, Inc.,
2710-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2711-
2712-import gobject
2713-import dbus
2714-import dbus.mainloop.glib
2715-
2716-from indicatorNetworkSettings.backend.service import create_service
2717-
2718-class ConnmanManager(gobject.GObject):
2719- def get_properties(self):
2720- return self.properties
2721-
2722- def is_available(self, technology):
2723- if technology in self.properties["AvailableTechnologies"]:
2724- return True
2725-
2726- return False
2727-
2728- def is_enabled(self, technology):
2729- if technology in self.properties["EnabledTechnologies"]:
2730- return True
2731-
2732- return False
2733-
2734- def is_connected(self, technology):
2735- if technology in self.properties["ConnectedTechnologies"]:
2736- return True
2737-
2738- return False
2739-
2740- def enable_technology(self, technology):
2741- if not self.is_available(technology):
2742- return
2743-
2744- if self.is_enabled(technology):
2745- return
2746-
2747- self.manager.EnableTechnology(technology)
2748-
2749- def disable_technology(self, technology):
2750- if not self.is_available(technology):
2751- return
2752-
2753- if not self.is_enabled(technology):
2754- return
2755-
2756- self.manager.DisableTechnology(technology)
2757-
2758- def get_available_technologies(self):
2759- return self.properties["AvailableTechnologies"]
2760-
2761- def get_enabled_technologies(self):
2762- return self.properties["EnabledTechnologies"]
2763-
2764- def get_connected_technologies(self):
2765- return self.properties["ConnectedTechnologies"]
2766-
2767- def request_scan(self, technology=""):
2768- self.manager.RequestScan(technology)
2769-
2770- def service_property_changed(self, name, value, path, interface):
2771- service = self.get_service(path)
2772-
2773- if not service:
2774- return
2775-
2776- service.update_property(name, value)
2777-
2778- def manager_property_changed(self, name, value, path, interface):
2779- self.properties[name] = value
2780-
2781- if name == "Services":
2782- self.update_services()
2783- self.emit("services-changed")
2784- elif name in ["AvailableTechnologies", "EnabledTechnologies",
2785- "ConnectedTechnologies"]:
2786- self.emit("technologies-changed")
2787-
2788- def add_service(self, service):
2789- self.services[service.get_path()] = service
2790-
2791- def get_services(self):
2792- return self.services.values()
2793-
2794- def get_services_by_technology(self, technology):
2795- result = []
2796- for service in self.get_services():
2797- if service.get_type() == technology:
2798- result.append(service)
2799-
2800- return result
2801-
2802- def get_service(self, path):
2803- if path not in self.services:
2804- return None
2805-
2806- return self.services[path]
2807-
2808- def update_services(self):
2809- self.services = {}
2810-
2811- for path in self.properties["Services"]:
2812- service = create_service(path)
2813- self.add_service(service)
2814-
2815- def __init__(self):
2816- self.__gobject_init__()
2817- self.services = {}
2818- dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
2819- self.bus = dbus.SystemBus()
2820-
2821- self.bus.add_signal_receiver(self.service_property_changed,
2822- bus_name="net.connman",
2823- dbus_interface="net.connman.Service",
2824- signal_name = "PropertyChanged",
2825- path_keyword="path",
2826- interface_keyword="interface")
2827-
2828- self.manager = dbus.Interface(self.bus.get_object("net.connman",
2829- "/"),
2830- "net.connman.Manager")
2831- self.bus.add_signal_receiver(self.manager_property_changed,
2832- bus_name="net.connman",
2833- dbus_interface="net.connman.Manager",
2834- signal_name = "PropertyChanged",
2835- path_keyword="path",
2836- interface_keyword="interface")
2837-
2838- self.properties = self.manager.GetProperties()
2839-
2840- # FIXME: handle if connmand disappears
2841- # FIXME: how to handle ordering and other changes in service list?
2842-
2843- self.update_services()
2844-
2845-
2846-gobject.type_register(ConnmanManager)
2847-gobject.signal_new("technologies-changed", ConnmanManager,
2848- gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
2849-gobject.signal_new("services-changed", ConnmanManager,
2850- gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ())
2851
2852=== removed file 'src/settings/indicatorNetworkSettings/backend/device.py'
2853--- src/settings/indicatorNetworkSettings/backend/device.py 2010-12-13 21:12:32 +0000
2854+++ src/settings/indicatorNetworkSettings/backend/device.py 1970-01-01 00:00:00 +0000
2855@@ -1,75 +0,0 @@
2856-#!/usr/bin/env python
2857-# -*- coding: utf-8 -*-
2858-#
2859-# Copyright (C) 2010 Canonical
2860-#
2861-# Authors:
2862-# Andrew Higginson
2863-#
2864-# This program is free software; you can redistribute it and/or modify it under
2865-# the terms of the GNU General Public License as published by the Free Software
2866-# Foundation; version 3.
2867-#
2868-# This program is distributed in the hope that it will be useful, but WITHOUT
2869-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2870-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
2871-# details.
2872-#
2873-# You should have received a copy of the GNU General Public License along with
2874-# this program; if not, write to the Free Software Foundation, Inc.,
2875-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2876-
2877-import gobject
2878-
2879-from indicatorNetworkSettings.enums import *
2880-
2881-class UnknownDeviceTypeError(Exception):
2882- def __init__(self, devicetype):
2883- self.devicetype
2884-
2885- def __str__(self):
2886- return self.devicetype
2887-
2888-class Device(gobject.GObject):
2889-
2890- __gsignals__ = {
2891- "state-changed" : (gobject.SIGNAL_RUN_LAST,
2892- gobject.TYPE_NONE,
2893- ([gobject.TYPE_PYOBJECT]),
2894- ),
2895- }
2896-
2897-
2898- def __init__(self, devicetype, connman):
2899- super(Device, self).__init__()
2900- self.type = devicetype
2901- self.state = DEVICE_STATE_OFF
2902- self.connman = connman
2903-
2904- if self.type == DEVICE_TYPE_WIRED:
2905- self.typestring = "ethernet"
2906- elif self.type == DEVICE_TYPE_WIRELESS:
2907- self.typestring = "wifi"
2908- elif self.type == DEVICE_TYPE_MOBILE:
2909- self.typestring = "cellular"
2910- elif self.type == DEVICE_TYPE_BLUETOOTH:
2911- self.typestring = "bluetooth"
2912- else:
2913- raise UnknownDeviceTypeError(self.type)
2914-
2915- def set_state(self, state):
2916-
2917- if self.state == state:
2918- return
2919-
2920- self.state = state
2921- self.emit("state-changed", self.state)
2922-
2923- def get_state(self):
2924- return self.state
2925-
2926- def enable(self):
2927- self.connman.enable_technology(self.typestring)
2928-
2929- def disable(self):
2930- self.connman.disable_technology(self.typestring)
2931
2932=== removed file 'src/settings/indicatorNetworkSettings/backend/devicemanager.py'
2933--- src/settings/indicatorNetworkSettings/backend/devicemanager.py 2010-12-14 12:24:54 +0000
2934+++ src/settings/indicatorNetworkSettings/backend/devicemanager.py 1970-01-01 00:00:00 +0000
2935@@ -1,153 +0,0 @@
2936-#!/usr/bin/env python
2937-# -*- coding: utf-8 -*-
2938-#
2939-# Copyright (C) 2010 Canonical
2940-#
2941-# Authors:
2942-# Andrew Higginson
2943-# Kalle Valo
2944-#
2945-# This program is free software; you can redistribute it and/or modify it under
2946-# the terms of the GNU General Public License as published by the Free Software
2947-# Foundation; version 3.
2948-#
2949-# This program is distributed in the hope that it will be useful, but WITHOUT
2950-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2951-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
2952-# details.
2953-#
2954-# You should have received a copy of the GNU General Public License along with
2955-# this program; if not, write to the Free Software Foundation, Inc.,
2956-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2957-
2958-import gobject
2959-
2960-from indicatorNetworkSettings.backend.device import Device
2961-from indicatorNetworkSettings.backend.connmanmanager import ConnmanManager
2962-from indicatorNetworkSettings.enums import *
2963-
2964-class DeviceManager(gobject.GObject):
2965-
2966- __gsignals__ = {
2967- "devices-changed" : (gobject.SIGNAL_RUN_LAST,
2968- gobject.TYPE_NONE,
2969- (),
2970- ),
2971- }
2972-
2973- def __init__(self):
2974- super(DeviceManager, self).__init__()
2975- self.connman = ConnmanManager()
2976-
2977- self.ethernet_device = Device(DEVICE_TYPE_WIRED, self.connman)
2978- self.wifi_device = Device(DEVICE_TYPE_WIRELESS, self.connman)
2979- self.cellular_device = Device(DEVICE_TYPE_MOBILE, self.connman)
2980- self.bluetooth_device = Device(DEVICE_TYPE_BLUETOOTH, self.connman)
2981-
2982- self.ethernet_available = False
2983- self.wifi_available = False
2984- self.cellular_available = False
2985- self.bluetooth_available = False
2986-
2987- self.connman.connect("technologies-changed", self.technologies_updated)
2988- self.technologies_updated(self.connman)
2989-
2990- def update_availability(self):
2991- techs = self.connman.get_available_technologies()
2992- changed = False
2993-
2994- avail = "ethernet" in techs
2995- if avail != self.ethernet_available:
2996- self.ethernet_available = avail
2997- changed = True
2998-
2999- avail = "wifi" in techs
3000- if avail != self.wifi_available:
3001- self.wifi_available = avail
3002- changed = True
3003-
3004- avail = "cellular" in techs
3005- if avail != self.cellular_available:
3006- self.cellular_available = avail
3007- changed = True
3008-
3009- avail = "bluetooth" in techs
3010- if avail != self.bluetooth_available:
3011- self.bluetooth_available = avail
3012- changed = True
3013-
3014- if not changed:
3015- return
3016-
3017- self.emit("devices-changed")
3018-
3019- def update_state(self):
3020- enabled = self.connman.get_enabled_technologies()
3021- connected = self.connman.get_connected_technologies()
3022-
3023- if "ethernet" in connected:
3024- self.ethernet_device.set_state(DEVICE_STATE_CONNECTED)
3025- elif "ethernet" in enabled:
3026- self.ethernet_device.set_state(DEVICE_STATE_ON)
3027- else:
3028- self.ethernet_device.set_state(DEVICE_STATE_OFF)
3029-
3030- if "wifi" in connected:
3031- self.wifi_device.set_state(DEVICE_STATE_CONNECTED)
3032- elif "wifi" in enabled:
3033- self.wifi_device.set_state(DEVICE_STATE_ON)
3034- else:
3035- self.wifi_device.set_state(DEVICE_STATE_OFF)
3036-
3037- if "cellular" in connected:
3038- self.cellular_device.set_state(DEVICE_STATE_CONNECTED)
3039- elif "cellular" in enabled:
3040- self.cellular_device.set_state(DEVICE_STATE_ON)
3041- else:
3042- self.cellular_device.set_state(DEVICE_STATE_OFF)
3043-
3044- if "bluetooth" in connected:
3045- self.bluetooth_device.set_state(DEVICE_STATE_CONNECTED)
3046- elif "bluetooth" in enabled:
3047- self.bluetooth_device.set_state(DEVICE_STATE_ON)
3048- else:
3049- self.bluetooth_device.set_state(DEVICE_STATE_OFF)
3050-
3051- def technologies_updated(self, connman):
3052- self.update_availability()
3053- self.update_state()
3054-
3055- def get_wired_devices(self):
3056- devices = []
3057-
3058- if self.ethernet_available:
3059- devices.append(self.ethernet_device)
3060-
3061- return devices
3062-
3063- def get_wireless_devices(self):
3064- devices = []
3065-
3066- if self.wifi_available:
3067- devices.append(self.wifi_device)
3068-
3069- return devices
3070-
3071- def get_mobile_devices(self):
3072- devices = []
3073-
3074- if self.cellular_available:
3075- devices.append(self.cellular_device)
3076-
3077- return devices
3078-
3079- def get_bluetooth_devices(self):
3080- devices = []
3081-
3082- if self.bluetooth_available:
3083- devices.append(self.bluetooth_device)
3084-
3085- return devices
3086-
3087- def get_remembered_wireless_connections(self):
3088- return self.connman.get_services_by_technology("wifi")
3089
3090=== removed file 'src/settings/indicatorNetworkSettings/backend/service.py'
3091--- src/settings/indicatorNetworkSettings/backend/service.py 2010-12-13 18:48:43 +0000
3092+++ src/settings/indicatorNetworkSettings/backend/service.py 1970-01-01 00:00:00 +0000
3093@@ -1,195 +0,0 @@
3094-#!/usr/bin/env python
3095-# -*- coding: utf-8 -*-
3096-#
3097-# Copyright (C) 2010 Canonical
3098-#
3099-# Authors:
3100-# Kalle Valo
3101-#
3102-# This program is free software; you can redistribute it and/or modify it under
3103-# the terms of the GNU General Public License as published by the Free Software
3104-# Foundation; version 3.
3105-#
3106-# This program is distributed in the hope that it will be useful, but WITHOUT
3107-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3108-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3109-# details.
3110-#
3111-# You should have received a copy of the GNU General Public License along with
3112-# this program; if not, write to the Free Software Foundation, Inc.,
3113-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3114-
3115-import dbus
3116-
3117-# FIXME: translate these
3118-IPV4_METHOD_DHCP = "dhcp"
3119-IPV4_METHOD_MANUAL = "manual"
3120-
3121-def create_service(path):
3122- bus = dbus.SystemBus()
3123- proxy = dbus.Interface(bus.get_object("net.connman", path),
3124- "net.connman.Service")
3125-
3126- try:
3127- properties = proxy.GetProperties()
3128- except dbus.exceptions.DBusException as e:
3129- print "GetProperties failed for service %s: %s" % (path, e)
3130- return
3131-
3132- service_type = properties["Type"]
3133- if service_type == "ethernet":
3134- service = EthernetService(proxy, path, properties)
3135- elif service_type == "wifi":
3136- service = WifiService(proxy, path, properties)
3137- elif service_type == "bluetooth":
3138- service = BluetoothService(proxy, path, properties)
3139- elif service_type == "cellular":
3140- service = CellularService(proxy, path, properties)
3141- else:
3142- s = "unknown service type '%s': %s" % (service_type, path)
3143- raise Exception(s)
3144-
3145- return service
3146-
3147-class Service():
3148-
3149- def get_name(self):
3150- return self.properties["Name"]
3151-
3152- def get_path(self):
3153- return self.path
3154-
3155- def get_strength(self):
3156- if "Strength" not in self.properties:
3157- return 0
3158-
3159- return int(self.properties["Strength"])
3160-
3161- def get_autoconnect(self):
3162- return self.properties["AutoConnect"] == dbus.Boolean(1)
3163-
3164- def set_autoconnect(self, autoconnect):
3165- if autoconnect:
3166- value = dbus.Boolean(True)
3167- else:
3168- value = dbus.Boolean(False)
3169-
3170- self.service.SetProperty("AutoConnect", value);
3171-
3172- def get_nameservers_configuration(self):
3173- val = self.properties["Nameservers.Configuration"]
3174- if val != None:
3175- return " ".join(val)
3176- else:
3177- return ""
3178-
3179- def set_nameservers_configuration(self, nameservers):
3180- value = nameservers.split()
3181- self.service.SetProperty("Nameservers.Configuration",
3182- dbus.Array(value, signature="s"))
3183-
3184- def get_domains_configuration(self):
3185- val = self.properties["Domains.Configuration"]
3186- if val != None:
3187- return " ".join(val)
3188- else:
3189- return ""
3190-
3191- def set_domains_configuration(self, domains):
3192- value = domains.split()
3193- self.service.SetProperty("Domains.Configuration",
3194- dbus.Array(value, signature="s"))
3195-
3196- def get_ipv4_configuration_method(self):
3197- d = self.properties["IPv4.Configuration"]
3198- if d.has_key('Method'):
3199- return d['Method']
3200- else:
3201- return ""
3202-
3203- def get_ipv4_configuration_address(self):
3204- d = self.properties["IPv4.Configuration"]
3205- if d.has_key('Address'):
3206- return d['Address']
3207- else:
3208- return ""
3209-
3210- def get_ipv4_configuration_netmask(self):
3211- d = self.properties["IPv4.Configuration"]
3212- if d.has_key('Netmask'):
3213- return d['Netmask']
3214- else:
3215- return ""
3216-
3217- def get_ipv4_configuration_gateway(self):
3218- d = self.properties["IPv4.Configuration"]
3219- if d.has_key('Gateway'):
3220- return d['Gateway']
3221- else:
3222- return ""
3223-
3224- def set_ipv4_configuration(self, ipv4):
3225- self.service.SetProperty("IPv4.Configuration", ipv4)
3226-
3227- def remove(self):
3228- if not self.is_favorite():
3229- return
3230-
3231- self.service.Remove()
3232-
3233- def is_favorite(self):
3234- if not "Favorite" in self.properties:
3235- return False
3236-
3237- return self.properties["Favorite"] == dbus.Boolean(1)
3238-
3239- def connect(self):
3240- self.service.Connect()
3241-
3242- def update_property(self, name, value):
3243- self.properties[name] = value
3244- # FIXME: emit property-changed signal
3245-
3246- def __init__(self, service, path, properties):
3247- self.service = service
3248- self.path = path
3249- self.properties = properties
3250-
3251-class EthernetService(Service):
3252-
3253- def get_type(self):
3254- return "ethernet"
3255-
3256-class WifiService(Service):
3257-
3258- def get_type(self):
3259- return "wifi"
3260-
3261- def uses_passphrase(self):
3262- return self.properties["Security"] != "none"
3263-
3264- def get_passphrase(self):
3265- if "Passphrase" not in self.properties:
3266- return ""
3267-
3268- return self.properties["Passphrase"]
3269-
3270- def set_passphrase(self, passphrase):
3271- self.service.SetProperty("Passphrase", passphrase);
3272-
3273-class BluetoothService(Service):
3274-
3275- def get_type(self):
3276- return "bluetooth"
3277-
3278-class CellularService(Service):
3279-
3280- def get_type(self):
3281- return "cellular"
3282-
3283- def get_apn(self):
3284- return self.properties["APN"]
3285-
3286- def set_apn(self, apn):
3287- self.service.SetProperty("APN", apn);
3288-
3289
3290=== removed file 'src/settings/indicatorNetworkSettings/enums.py'
3291--- src/settings/indicatorNetworkSettings/enums.py 2010-12-13 19:38:26 +0000
3292+++ src/settings/indicatorNetworkSettings/enums.py 1970-01-01 00:00:00 +0000
3293@@ -1,42 +0,0 @@
3294-# Copyright (C) 2010 Canonical
3295-#
3296-# Authors:
3297-# Andrew Higginson
3298-#
3299-# This program is free software; you can redistribute it and/or modify it under
3300-# the terms of the GNU General Public License as published by the Free Software
3301-# Foundation; version 3.
3302-#
3303-# This program is distributed in the hope that it will be useful, but WITHOUT
3304-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3305-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3306-# details.
3307-#
3308-# You should have received a copy of the GNU General Public License along with
3309-# this program; if not, write to the Free Software Foundation, Inc.,
3310-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3311-
3312-from gettext import gettext as _
3313-
3314-DEVICE_TYPES = (DEVICE_TYPE_WIRED, DEVICE_TYPE_WIRELESS, \
3315- DEVICE_TYPE_BLUETOOTH, DEVICE_TYPE_MOBILE) = range(4)
3316-
3317-DEVICE_TYPE_NAMES = {DEVICE_TYPE_WIRED:_("Wired"),
3318- DEVICE_TYPE_WIRELESS:_("Wireless"),
3319- DEVICE_TYPE_BLUETOOTH:_("Bluetooth"),
3320- DEVICE_TYPE_MOBILE:_("Mobile Broadband")}
3321-
3322-DEVICE_TYPE_LNAMES = {DEVICE_TYPE_WIRED:"wired",
3323- DEVICE_TYPE_WIRELESS:"wireless",
3324- DEVICE_TYPE_BLUETOOTH:"bluetooth",
3325- DEVICE_TYPE_MOBILE:"mobile"}
3326-
3327-DEVICE_TYPE_ICONS = {DEVICE_TYPE_WIRED:"network-wired",
3328- DEVICE_TYPE_WIRELESS:"network-wireless",
3329- DEVICE_TYPE_BLUETOOTH:"bluetooth-active",
3330- DEVICE_TYPE_MOBILE:"gsm-3g-high"}
3331-
3332-DEVICE_STATE_OFF, DEVICE_STATE_ON, DEVICE_STATE_CONNECTED, = range(3)
3333-
3334-
3335-GENERIC_DEVICE_ICON = DEVICE_TYPE_ICONS[DEVICE_TYPE_WIRED]
3336
3337=== removed directory 'src/settings/indicatorNetworkSettings/frontend'
3338=== removed file 'src/settings/indicatorNetworkSettings/frontend/Makefile.am'
3339--- src/settings/indicatorNetworkSettings/frontend/Makefile.am 2010-12-13 13:55:55 +0000
3340+++ src/settings/indicatorNetworkSettings/frontend/Makefile.am 1970-01-01 00:00:00 +0000
3341@@ -1,9 +0,0 @@
3342-SUBDIRS = \
3343- pages \
3344- widgets
3345-
3346-# indicator-network-settings
3347-insdir = $(pkgdatadir)/indicatorNetworkSettings/frontend
3348-ins_PYTHON = \
3349- __init__.py \
3350- utils.py
3351
3352=== removed file 'src/settings/indicatorNetworkSettings/frontend/__init__.py'
3353--- src/settings/indicatorNetworkSettings/frontend/__init__.py 2010-12-07 15:07:37 +0000
3354+++ src/settings/indicatorNetworkSettings/frontend/__init__.py 1970-01-01 00:00:00 +0000
3355@@ -1,1 +0,0 @@
3356-
3357
3358=== removed directory 'src/settings/indicatorNetworkSettings/frontend/pages'
3359=== removed file 'src/settings/indicatorNetworkSettings/frontend/pages/Makefile.am'
3360--- src/settings/indicatorNetworkSettings/frontend/pages/Makefile.am 2010-12-13 13:55:55 +0000
3361+++ src/settings/indicatorNetworkSettings/frontend/pages/Makefile.am 1970-01-01 00:00:00 +0000
3362@@ -1,5 +0,0 @@
3363-# indicator-network-settings
3364-insdir = $(pkgdatadir)/indicatorNetworkSettings/frontend/pages
3365-ins_PYTHON = \
3366- connections.py \
3367- __init__.py
3368
3369=== removed file 'src/settings/indicatorNetworkSettings/frontend/pages/__init__.py'
3370=== removed file 'src/settings/indicatorNetworkSettings/frontend/pages/connections.py'
3371--- src/settings/indicatorNetworkSettings/frontend/pages/connections.py 2010-12-13 14:18:58 +0000
3372+++ src/settings/indicatorNetworkSettings/frontend/pages/connections.py 1970-01-01 00:00:00 +0000
3373@@ -1,111 +0,0 @@
3374-# Copyright (C) 2010 Canonical
3375-#
3376-# Authors:
3377-# Andrew Higginson
3378-#
3379-# This program is free software; you can redistribute it and/or modify it under
3380-# the terms of the GNU General Public License as published by the Free Software
3381-# Foundation; version 3.
3382-#
3383-# This program is distributed in the hope that it will be useful, but WITHOUT
3384-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3385-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3386-# details.
3387-#
3388-# You should have received a copy of the GNU General Public License along with
3389-# this program; if not, write to the Free Software Foundation, Inc.,
3390-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3391-
3392-import gobject
3393-
3394-from indicatorNetworkSettings.frontend.widgets.device_boxes.wired \
3395- import WiredBox
3396-from indicatorNetworkSettings.frontend.widgets.device_boxes.wireless \
3397- import WirelessBox
3398-from indicatorNetworkSettings.frontend.widgets.device_boxes.bluetooth \
3399- import BluetoothBox
3400-from indicatorNetworkSettings.frontend.widgets.device_boxes.mobile \
3401- import MobileBox
3402-from indicatorNetworkSettings.frontend.widgets.deviceview \
3403- import DeviceView, DeviceStore
3404-
3405-from indicatorNetworkSettings.backend.device import *
3406-from indicatorNetworkSettings.enums import *
3407-
3408-class ConnectionsPage(gobject.GObject):
3409- def __init__(self, app, datadir):
3410- super(ConnectionsPage, self).__init__()
3411-
3412- self.app = app
3413- self.alignment = app.alignment_connections
3414- self.viewed = False
3415-
3416- # Create LHS
3417- ## Create device view
3418- device_store = DeviceStore(app.icons)
3419- self.treeview_devices = DeviceView(device_store)
3420- ## Pack it
3421- app.scrolledwindow_c_devices.add(self.treeview_devices)
3422- ## Connect signals to callbacks
3423- self.treeview_devices.connect("selection-changed",
3424- self._on_treeview_devices_selection_changed)
3425- self.treeview_devices.connect("reordered",
3426- self._on_treeview_devices_reordered)
3427-
3428- wired_devices = app.devicemanager.get_wired_devices()
3429- wireless_devices = app.devicemanager.get_wireless_devices()
3430- mobile_devices = app.devicemanager.get_mobile_devices()
3431- bluetooth_devices = app.devicemanager.get_bluetooth_devices()
3432-
3433- for device in wired_devices:
3434- box = WiredBox(device, datadir)
3435- self.app.notebook_c_right.append_page(box)
3436- self.add_device(device, box)
3437-
3438- for device in wireless_devices:
3439- box = WirelessBox(device, app, datadir)
3440- self.app.notebook_c_right.append_page(box)
3441- self.add_device(device, box)
3442-
3443- for device in mobile_devices:
3444- box = MobileBox(device, datadir)
3445- self.app.notebook_c_right.append_page(box)
3446- self.add_device(device, box)
3447-
3448- for device in bluetooth_devices:
3449- box = BluetoothBox(device, datadir)
3450- self.app.notebook_c_right.append_page(box)
3451- self.add_device(device, box)
3452-
3453- # Order the RHS notebook pages inaccordance with the deviceview
3454- self._on_treeview_devices_reordered(self.treeview_devices)
3455-
3456- # Private Functions
3457-
3458- # Public Functions
3459-
3460- def add_device(self, device, box):
3461- liststore = self.treeview_devices.get_model()
3462- liststore.append(device, box)
3463-
3464- # Callbacks
3465-
3466- def on_first_expose(self):
3467- if not self.viewed:
3468- self.treeview_devices.get_selection().select_path((0,))
3469- self.viewed = True
3470-
3471- def _on_treeview_devices_selection_changed(self, widget, selection):
3472- (model, iter_) = selection.get_selected()
3473-
3474- if iter_:
3475- i = model.get_path(iter_)[0]
3476- self.app.notebook_c_right.set_current_page(i)
3477-
3478- def _on_treeview_devices_reordered(self, widget):
3479- i = 0
3480- model = widget.get_model()
3481- for device in model:
3482- page = device[DeviceStore.COL_SETTINGS_BOX]
3483- self.app.notebook_c_right.reorder_child(page, i)
3484- i += 1
3485
3486=== removed file 'src/settings/indicatorNetworkSettings/frontend/utils.py'
3487--- src/settings/indicatorNetworkSettings/frontend/utils.py 2010-12-07 15:07:37 +0000
3488+++ src/settings/indicatorNetworkSettings/frontend/utils.py 1970-01-01 00:00:00 +0000
3489@@ -1,34 +0,0 @@
3490-# Copyright (C) 2010 Canonical
3491-#
3492-# Authors:
3493-# Andrew Higginson
3494-#
3495-# This program is free software; you can redistribute it and/or modify it under
3496-# the terms of the GNU General Public License as published by the Free Software
3497-# Foundation; version 3.
3498-#
3499-# This program is distributed in the hope that it will be useful, but WITHOUT
3500-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3501-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3502-# details.
3503-#
3504-# You should have received a copy of the GNU General Public License along with
3505-# this program; if not, write to the Free Software Foundation, Inc.,
3506-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3507-
3508-import os
3509-import sys
3510-import gtk
3511-
3512-def setup_ui(self, datadir, name):
3513- builder = gtk.Builder()
3514- builder.set_translation_domain("indicator-network-settings")
3515- path = os.path.join(datadir, "ui", "%s.ui" % name)
3516- builder.add_from_file(path)
3517- builder.connect_signals(self)
3518- for object_ in builder.get_objects():
3519- if issubclass(type(object_), gtk.Buildable):
3520- name = gtk.Buildable.get_name(object_)
3521- setattr(self, name, object_)
3522- else:
3523- print >> sys.stderr, "WARNING: can not get name for '%s'" % object_
3524
3525=== removed directory 'src/settings/indicatorNetworkSettings/frontend/widgets'
3526=== removed file 'src/settings/indicatorNetworkSettings/frontend/widgets/Makefile.am'
3527--- src/settings/indicatorNetworkSettings/frontend/widgets/Makefile.am 2010-12-07 15:07:37 +0000
3528+++ src/settings/indicatorNetworkSettings/frontend/widgets/Makefile.am 1970-01-01 00:00:00 +0000
3529@@ -1,6 +0,0 @@
3530-SUBDIRS = device_boxes
3531-
3532-# indicator-network-settings
3533-insdir = $(pkgdatadir)/indicatorNetworkSettings/frontend/widgets
3534-ins_PYTHON = cellrenderers.py deviceview.py toggleswitch.py connectionview.py __init__.py
3535-
3536
3537=== removed file 'src/settings/indicatorNetworkSettings/frontend/widgets/__init__.py'
3538--- src/settings/indicatorNetworkSettings/frontend/widgets/__init__.py 2010-12-07 15:07:37 +0000
3539+++ src/settings/indicatorNetworkSettings/frontend/widgets/__init__.py 1970-01-01 00:00:00 +0000
3540@@ -1,1 +0,0 @@
3541-
3542
3543=== removed file 'src/settings/indicatorNetworkSettings/frontend/widgets/cellrenderers.py'
3544--- src/settings/indicatorNetworkSettings/frontend/widgets/cellrenderers.py 2010-12-09 12:26:46 +0000
3545+++ src/settings/indicatorNetworkSettings/frontend/widgets/cellrenderers.py 1970-01-01 00:00:00 +0000
3546@@ -1,210 +0,0 @@
3547-#!/usr/bin/env python
3548-# -*- coding: utf-8 -*-
3549-#
3550-# Copyright (C) 2010 Canonical
3551-#
3552-# Authors:
3553-# Andrew Higginson
3554-#
3555-# This program is free software; you can redistribute it and/or modify it under
3556-# the terms of the GNU General Public License as published by the Free Software
3557-# Foundation; version 3.
3558-#
3559-# This program is distributed in the hope that it will be useful, but WITHOUT
3560-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3561-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3562-# details.
3563-#
3564-# You should have received a copy of the GNU General Public License along with
3565-# this program; if not, write to the Free Software Foundation, Inc.,
3566-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3567-
3568-import gtk
3569-import gobject
3570-
3571-from math import pi
3572-
3573-PI = 3.1415926535897931
3574-PI_OVER_180 = 0.017453292519943295
3575-
3576-class PinCellRenderer(gtk.GenericCellRenderer):
3577- __gproperties__ = {
3578- 'color': (gobject.TYPE_STRING,
3579- 'The color of the pin.',
3580- 'The color of the pin.',
3581- '#FFFFFF',
3582- gobject.PARAM_READWRITE
3583- ),
3584- }
3585-
3586- RED_FILL = "#ef2929"
3587- RED_STROKE = "#a40000"
3588- GREEN_FILL = "#8ae234"
3589- GREEN_STROKE = "#4e9a06"
3590- YELLOW_FILL = "#fce94f"
3591- YELLOW_STROKE = "#c4a000"
3592- GREY_FILL = "#d3d7cf"
3593- GREY_STROKE = "#555753"
3594-
3595- PIN_WIDTH = 8
3596- PIN_HEIGHT = 8
3597-
3598- PIN_XPAD = 8
3599- PIN_YPAD = 8
3600-
3601- CELL_WIDTH = PIN_WIDTH + PIN_XPAD
3602- CELL_HEIGHT = PIN_HEIGHT + PIN_YPAD
3603-
3604- def __init__(self):
3605- super(PinCellRenderer, self).__init__()
3606-
3607- def on_get_size(self, widget, cell_area):
3608- return 0, 0, self.CELL_WIDTH, self.CELL_HEIGHT
3609-
3610- def do_set_property(self, pspec, value):
3611- setattr(self, pspec.name, value)
3612-
3613- def do_get_property(self, pspec):
3614- return getattr(self, pspec.name)
3615-
3616- def on_render(self, window, widget, background_area, cell_area,
3617- expose_area, flags):
3618- cr = window.cairo_create()
3619-
3620- x = cell_area.x
3621- y = cell_area.y
3622-
3623- y_offset = (cell_area.height - self.CELL_HEIGHT) / 2
3624-
3625- cr.arc(self.CELL_WIDTH/2+x, self.CELL_HEIGHT/2+y+y_offset,
3626- self.PIN_WIDTH/2, 0, 2 * pi)
3627-
3628- stroke_string = getattr(self, "%s_STROKE" % self.color.upper())
3629- stroke = gtk.gdk.Color(stroke_string)
3630- fill_string = getattr(self, "%s_FILL" % self.color.upper())
3631- fill = gtk.gdk.Color(fill_string)
3632-
3633- cr.set_source_rgb(stroke.red / 65535.,
3634- stroke.green / 65535.,
3635- stroke.blue / 65535.)
3636- cr.stroke_preserve()
3637- cr.set_source_rgb(fill.red / 65535.,
3638- fill.green / 65535.,
3639- fill.blue / 65535.)
3640- cr.fill()
3641-
3642-class SignalStrengthCellRenderer(gtk.GenericCellRenderer):
3643- __gproperties__ = {
3644- 'signal': (gobject.TYPE_STRING,
3645- 'The color of the pin.',
3646- 'The color of the pin.',
3647- '#FFFFFF',
3648- gobject.PARAM_READWRITE
3649- ),
3650- }
3651-
3652- BG_FILL = "#f2f1f0"
3653- BG_STROKE = "#ada9a4"
3654- FG_FILL = "#d6d4d2"
3655- FG_STROKE = "#ada9a4"
3656-
3657- BAR_WIDTH = 50
3658- BAR_HEIGHT = 12
3659-
3660- BAR_XPAD = 4
3661- BAR_YPAD = 5
3662-
3663- CELL_WIDTH = BAR_WIDTH + BAR_XPAD * 2
3664- CELL_HEIGHT = BAR_HEIGHT + BAR_YPAD * 2
3665-
3666- CORNER_RADIUS = 3
3667-
3668- def __init__(self):
3669- super(SignalStrengthCellRenderer, self).__init__()
3670-
3671- def on_get_size(self, widget, cell_area):
3672- return (0, 0, self.CELL_WIDTH, self.CELL_HEIGHT)
3673-
3674- def do_set_property(self, pspec, value):
3675- setattr(self, pspec.name, value)
3676-
3677- def do_get_property(self, pspec):
3678- return getattr(self, pspec.name)
3679-
3680- def on_render(self, window, widget, background_area, cell_area,
3681- expose_area, flags):
3682- cr = window.cairo_create()
3683-
3684- x = cell_area.x
3685- y = cell_area.y
3686-
3687- x_offset = self.BAR_XPAD
3688- y_offset = self.BAR_YPAD
3689-
3690- self._draw_rounded_rectangle(cr, x+x_offset, y+y_offset,
3691- x+x_offset+self.BAR_WIDTH, y+y_offset+self.BAR_HEIGHT,
3692- self.BG_FILL, self.BG_STROKE)
3693-
3694- self._draw_rounded_rectangle(cr, x+x_offset, y+y_offset,
3695- x+x_offset+(int(self.BAR_WIDTH*float(self.signal))), y+y_offset+self.BAR_HEIGHT,
3696- self.FG_FILL, self.FG_STROKE)
3697-
3698- def _draw_rounded_rectangle(self, cr, x, y, w, h, fill, stroke):
3699- self._layout_rounded_rectangle(cr, x, y, w, h)
3700-
3701- stroke = gtk.gdk.Color(stroke)
3702- fill = gtk.gdk.Color(fill)
3703-
3704- cr.set_source_rgb(stroke.red / 65535.,
3705- stroke.green / 65535.,
3706- stroke.blue / 65535.)
3707- cr.stroke_preserve()
3708-
3709- cr.set_source_rgb(fill.red / 65535.,
3710- fill.green / 65535.,
3711- fill.blue / 65535.)
3712- cr.fill()
3713-
3714- def _layout_rounded_rectangle(self, cr, x, y, w, h):
3715- r = self.CORNER_RADIUS
3716- cr.new_sub_path()
3717- cr.arc(r+x, r+y, r, PI, 270*PI_OVER_180)
3718- cr.arc(w-r, r+y, r, 270*PI_OVER_180, 0)
3719- cr.arc(w-r, h-r, r, 0, 90*PI_OVER_180)
3720- cr.arc(r+x, h-r, r, 90*PI_OVER_180, PI)
3721- cr.close_path()
3722-
3723-
3724-
3725-gobject.type_register(PinCellRenderer)
3726-gobject.type_register(SignalStrengthCellRenderer)
3727-
3728-if __name__ == "__main__":
3729- window = gtk.Window()
3730-
3731- treeview = gtk.TreeView()
3732-
3733- # Main Column
3734- column = gtk.TreeViewColumn("Main")
3735- cr = PinCellRenderer()
3736- crs = SignalStrengthCellRenderer()
3737- crt = gtk.CellRendererText()
3738- column.pack_start(cr)
3739- column.pack_start(crs)
3740- column.pack_start(crt)
3741- column.set_attributes(cr, color=0)
3742- column.set_attributes(crs, signal=1)
3743- column.set_attributes(crt, text=2)
3744- treeview.append_column(column)
3745-
3746- store = gtk.ListStore(str, float, str)
3747- store.append(["green", 0.25, "Hey"])
3748- store.append(["red", 0.5, "hi"])
3749- store.append(["yellow", 0.75, "ho"])
3750- store.append(["grey", 1.0, "ha"])
3751- treeview.set_model(store)
3752-
3753- window.add(treeview)
3754- window.show_all()
3755- gtk.main()
3756-
3757
3758=== removed file 'src/settings/indicatorNetworkSettings/frontend/widgets/connectionview.py'
3759--- src/settings/indicatorNetworkSettings/frontend/widgets/connectionview.py 2010-12-07 15:07:37 +0000
3760+++ src/settings/indicatorNetworkSettings/frontend/widgets/connectionview.py 1970-01-01 00:00:00 +0000
3761@@ -1,78 +0,0 @@
3762-# Copyright (C) 2010 Canonical
3763-#
3764-# Authors:
3765-# Andrew Higginson
3766-#
3767-# This program is free software; you can redistribute it and/or modify it under
3768-# the terms of the GNU General Public License as published by the Free Software
3769-# Foundation; version 3.
3770-#
3771-# This program is distributed in the hope that it will be useful, but WITHOUT
3772-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3773-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3774-# details.
3775-#
3776-# You should have received a copy of the GNU General Public License along with
3777-# this program; if not, write to the Free Software Foundation, Inc.,
3778-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3779-
3780-import gtk
3781-import gobject
3782-
3783-from indicatorNetworkSettings.enums import *
3784-from indicatorNetworkSettings.frontend.widgets.cellrenderers \
3785- import SignalStrengthCellRenderer
3786-
3787-from gettext import gettext as _
3788-
3789-class WirelessConnectionView(gtk.TreeView):
3790- def __init__(self, store):
3791- super(WirelessConnectionView, self).__init__()
3792- self.set_model(store)
3793-
3794- # Network Column (contains label)
3795- column = gtk.TreeViewColumn(_("Network"))
3796- cr_label = gtk.CellRendererText()
3797- column.pack_start(cr_label, True)
3798- column.set_attributes(cr_label,
3799- markup=WirelessConnectionStore.COL_NETWORK)
3800- column.set_expand(True)
3801- self.append_column(column)
3802-
3803- # Signal Column (contains signal indicator)
3804- column = gtk.TreeViewColumn(_("Signal"))
3805- cr_signal = SignalStrengthCellRenderer()
3806- column.pack_start(cr_signal, True)
3807- column.set_attributes(cr_signal,
3808- signal=WirelessConnectionStore.COL_SIGNAL)
3809- column.set_clickable(True)
3810- column.set_sort_column_id(WirelessConnectionStore.COL_SIGNAL)
3811- self.append_column(column)
3812-
3813- # Last Used Column (contains label)
3814- column = gtk.TreeViewColumn(_("Last Used"))
3815- cr_label = gtk.CellRendererText()
3816- column.pack_start(cr_label, True)
3817- column.set_attributes(cr_label,
3818- markup=WirelessConnectionStore.COL_LAST_USED)
3819- self.append_column(column)
3820-
3821- def get_selected_connection(self):
3822- (model, iter_) = self.get_selection().get_selected()
3823- if iter_:
3824- return model.get_value(iter_, 0)
3825- return None
3826-
3827-
3828-class WirelessConnectionStore(gtk.ListStore):
3829-
3830- (COL_OBJ, COL_NETWORK, COL_SIGNAL, COL_LAST_USED) = range(4)
3831-
3832- def __init__(self):
3833- super(WirelessConnectionStore, self).__init__(
3834- gobject.TYPE_PYOBJECT, str, str, str)
3835-
3836- def append(self, obj, network, signal, last_used):
3837- row_data = [obj, network, signal, last_used]
3838- return super(WirelessConnectionStore, self).append(row_data)
3839-
3840
3841=== removed directory 'src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes'
3842=== removed file 'src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/Makefile.am'
3843--- src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/Makefile.am 2010-12-07 15:07:37 +0000
3844+++ src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/Makefile.am 1970-01-01 00:00:00 +0000
3845@@ -1,3 +0,0 @@
3846-# indicator-network-settings
3847-insdir = $(pkgdatadir)/indicatorNetworkSettings/frontend/widgets/device_boxes
3848-ins_PYTHON = bluetooth.py __init__.py mobile.py wired.py wireless.py
3849
3850=== removed file 'src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/__init__.py'
3851--- src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/__init__.py 2010-12-07 15:07:37 +0000
3852+++ src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/__init__.py 1970-01-01 00:00:00 +0000
3853@@ -1,30 +0,0 @@
3854-# Copyright (C) 2010 Canonical
3855-#
3856-# Authors:
3857-# Andrew Higginson
3858-#
3859-# This program is free software; you can redistribute it and/or modify it under
3860-# the terms of the GNU General Public License as published by the Free Software
3861-# Foundation; version 3.
3862-#
3863-# This program is distributed in the hope that it will be useful, but WITHOUT
3864-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3865-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3866-# details.
3867-#
3868-# You should have received a copy of the GNU General Public License along with
3869-# this program; if not, write to the Free Software Foundation, Inc.,
3870-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3871-
3872-import gtk
3873-
3874-class DeviceBox(gtk.VBox):
3875- """A gtk.VBox which holds all of the widgets to control a device."""
3876-
3877- def __init__(self, device, datadir):
3878- super(DeviceBox, self).__init__(spacing=12)
3879- self.device = device
3880- self.device.connect("state-changed", self._on_device_state_changed)
3881-
3882- def _on_device_state_changed(self, device, state):
3883- pass
3884
3885=== removed file 'src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/bluetooth.py'
3886--- src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/bluetooth.py 2010-12-07 15:07:37 +0000
3887+++ src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/bluetooth.py 1970-01-01 00:00:00 +0000
3888@@ -1,35 +0,0 @@
3889-# Copyright (C) 2010 Canonical
3890-#
3891-# Authors:
3892-# Andrew Higginson
3893-#
3894-# This program is free software; you can redistribute it and/or modify it under
3895-# the terms of the GNU General Public License as published by the Free Software
3896-# Foundation; version 3.
3897-#
3898-# This program is distributed in the hope that it will be useful, but WITHOUT
3899-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3900-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3901-# details.
3902-#
3903-# You should have received a copy of the GNU General Public License along with
3904-# this program; if not, write to the Free Software Foundation, Inc.,
3905-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3906-
3907-import gtk
3908-import locale
3909-
3910-from indicatorNetworkSettings.enums import *
3911-
3912-from gettext import gettext as _
3913-
3914-class BluetoothBox(gtk.VBox):
3915-
3916- """A gtk.VBox which holds all of thw widgets to control a bluetooth
3917- device."""
3918-
3919- def __init__(self, device, datadir):
3920- super(BluetoothBox, self).__init__(spacing=12)
3921- self.device = device
3922-
3923- # Callbacks
3924
3925=== removed file 'src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/mobile.py'
3926--- src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/mobile.py 2010-12-13 19:53:47 +0000
3927+++ src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/mobile.py 1970-01-01 00:00:00 +0000
3928@@ -1,116 +0,0 @@
3929-# -*- coding: utf-8 -*-
3930-# Copyright (C) 2010 Canonical
3931-#
3932-# Authors:
3933-# Andrew Higginson
3934-#
3935-# This program is free software; you can redistribute it and/or modify it under
3936-# the terms of the GNU General Public License as published by the Free Software
3937-# Foundation; version 3.
3938-#
3939-# This program is distributed in the hope that it will be useful, but WITHOUT
3940-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3941-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3942-# details.
3943-#
3944-# You should have received a copy of the GNU General Public License along with
3945-# this program; if not, write to the Free Software Foundation, Inc.,
3946-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3947-
3948-import gtk
3949-
3950-from indicatorNetworkSettings.frontend.widgets.device_boxes \
3951- import DeviceBox
3952-from indicatorNetworkSettings.frontend.widgets.toggleswitch \
3953- import InfoBox, ToggleSwitch
3954-
3955-from indicatorNetworkSettings.enums import *
3956-import indicatorNetworkSettings.frontend.utils as utils
3957-
3958-from gettext import gettext as _
3959-
3960-class MobileBox(DeviceBox):
3961-
3962- """A gtk.VBox which holds all of the widgets to control a mobile
3963- device. It contains an InfoBox and ToggleSwitch to control and
3964- monitor the state of the mobile device, and a set of widgets
3965- to enter details about the mobile network to connect to."""
3966-
3967- SENSITIVE_WIDGETS = ["label_apn_place", "label_apn",
3968- "label_pin_auth", "checkbutton_show_pin"]
3969-
3970- def __init__(self, device, datadir):
3971- super(MobileBox, self).__init__(device, datadir)
3972-
3973- # Infobox and Togglswitch
3974- ## Creation
3975- self.infobox = InfoBox(spacing=12)
3976- self.toggleswitch = ToggleSwitch((_("ON"), _("OFF")))
3977- self.label_status = gtk.Label()
3978- ## Padding and alignment
3979- self.label_status.set_alignment(0, 0.5)
3980- self.infobox.set_border_width(10)
3981- ## Packing
3982- self.infobox.pack_start(self.label_status, True, True)
3983- self.infobox.pack_start(self.toggleswitch, False, True)
3984- self.pack_start(self.infobox, False, False)
3985- ## Connect signals
3986- self.toggleswitch.connect("toggled", self._on_toggleswitch_toggled)
3987-
3988- # Network Settings
3989- ## Creation
3990- utils.setup_ui(self, datadir, "mobile_box")
3991- ## Packing
3992- self.pack_start(self.table_settings, True, True)
3993-
3994- self._update_widget_states(self.device.get_state())
3995- self._on_checkbutton_show_pin_toggled(self.checkbutton_show_pin)
3996-
3997- # Private Functions
3998- def _update_widget_states(self, state):
3999- if state == DEVICE_STATE_CONNECTED:
4000- device_editable = True
4001- settings_editable = False
4002- toggleswitch_state = True
4003- status_text = _("Connected to “Vodafone UK”.")
4004- elif state == DEVICE_STATE_ON:
4005- device_editable = True
4006- settings_editable = False
4007- toggleswitch_state = True
4008- status_text = _("Not connected.")
4009- elif state == DEVICE_STATE_OFF:
4010- device_editable = False
4011- settings_editable = True
4012- toggleswitch_state = False
4013- status_text = _("The Mobile Broadband device is powered off.")
4014-
4015- self.toggleswitch.set_sensitive(device_editable)
4016- self.toggleswitch.set_active(toggleswitch_state)
4017- self.label_status.set_text(status_text)
4018-
4019- self.table_settings.foreach(self._sensitise_widgets,
4020- (device_editable, settings_editable))
4021-
4022- def _sensitise_widgets(self, widget, data):
4023- (device_editable, settings_editable) = data
4024- name = gtk.Buildable.get_name(widget)
4025- if name in self.SENSITIVE_WIDGETS:
4026- widget.set_sensitive(device_editable)
4027- elif not isinstance(widget, gtk.Box):
4028- widget.set_sensitive(settings_editable)
4029- else:
4030- widget.foreach(self._sensitise_widgets,
4031- (device_editable, settings_editable))
4032-
4033- # Callbacks
4034- def _on_device_state_changed(self, device, state):
4035- self._update_widget_states(state)
4036-
4037- def _on_toggleswitch_toggled(self, widget):
4038- if widget.get_active():
4039- self.device.enable()
4040- else:
4041- self.device.disable()
4042-
4043- def _on_checkbutton_show_pin_toggled(self, widget):
4044- self.entry_pin.set_visibility(widget.get_active())
4045
4046=== removed file 'src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/wired.py'
4047--- src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/wired.py 2010-12-07 15:07:37 +0000
4048+++ src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/wired.py 1970-01-01 00:00:00 +0000
4049@@ -1,35 +0,0 @@
4050-# Copyright (C) 2010 Canonical
4051-#
4052-# Authors:
4053-# Andrew Higginson
4054-#
4055-# This program is free software; you can redistribute it and/or modify it under
4056-# the terms of the GNU General Public License as published by the Free Software
4057-# Foundation; version 3.
4058-#
4059-# This program is distributed in the hope that it will be useful, but WITHOUT
4060-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
4061-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
4062-# details.
4063-#
4064-# You should have received a copy of the GNU General Public License along with
4065-# this program; if not, write to the Free Software Foundation, Inc.,
4066-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
4067-
4068-import gtk
4069-import locale
4070-
4071-from indicatorNetworkSettings.enums import *
4072-
4073-from gettext import gettext as _
4074-
4075-class WiredBox(gtk.VBox):
4076-
4077- """A gtk.VBox which holds all of the widgets to control a wired
4078- device."""
4079-
4080- def __init__(self, device, datadir):
4081- super(WiredBox, self).__init__(spacing=12)
4082- self.device = device
4083-
4084- # Callbacks
4085
4086=== removed file 'src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/wireless.py'
4087--- src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/wireless.py 2010-12-13 20:01:43 +0000
4088+++ src/settings/indicatorNetworkSettings/frontend/widgets/device_boxes/wireless.py 1970-01-01 00:00:00 +0000
4089@@ -1,130 +0,0 @@
4090-# Copyright (C) 2010 Canonical
4091-#
4092-# Authors:
4093-# Andrew Higginson
4094-#
4095-# This program is free software; you can redistribute it and/or modify it under
4096-# the terms of the GNU General Public License as published by the Free Software
4097-# Foundation; version 3.
4098-#
4099-# This program is distributed in the hope that it will be useful, but WITHOUT
4100-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
4101-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
4102-# details.
4103-#
4104-# You should have received a copy of the GNU General Public License along with
4105-# this program; if not, write to the Free Software Foundation, Inc.,
4106-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
4107-
4108-import gtk
4109-import locale
4110-
4111-from indicatorNetworkSettings.frontend.widgets.device_boxes \
4112- import DeviceBox
4113-from indicatorNetworkSettings.frontend.widgets.connectionview \
4114- import WirelessConnectionView, WirelessConnectionStore
4115-from indicatorNetworkSettings.frontend.widgets.toggleswitch \
4116- import InfoBox, ToggleSwitch
4117-
4118-from indicatorNetworkSettings.enums import *
4119-import indicatorNetworkSettings.frontend.utils as utils
4120-
4121-from gettext import gettext as _
4122-
4123-class WirelessBox(DeviceBox):
4124-
4125- """A gtk.VBox which holds all of the widgets to control a wireless
4126- device. It contains an InfoBox and ToggleSwitch to control and
4127- monitor the state of the wireless device, and a
4128- WirelessConnectionView to connect to and remember details for
4129- wireless networks."""
4130-
4131- def __init__(self, device, app, datadir):
4132- super(WirelessBox, self).__init__(device, datadir)
4133-
4134- # Infobox and Togglswitch
4135- ## Creation
4136- self.infobox = InfoBox(spacing=12)
4137- self.toggleswitch = ToggleSwitch((_("ON"), _("OFF")))
4138- self.label_status = gtk.Label()
4139- ## Padding and alignment
4140- self.label_status.set_alignment(0, 0.5)
4141- self.infobox.set_border_width(10)
4142- ## Packing
4143- self.infobox.pack_start(self.label_status, True, True)
4144- self.infobox.pack_start(self.toggleswitch, False, True)
4145- self.pack_start(self.infobox, False, False)
4146- ## Connect signals
4147- self.toggleswitch.connect("toggled", self._on_toggleswitch_toggled)
4148-
4149- # Network Settings
4150- ## Creation
4151- utils.setup_ui(self, datadir, "wireless_box")
4152- ## Packing
4153- self.pack_start(self.vbox_connections, True, True)
4154-
4155- # Connection View
4156- ## Creation
4157- connection_store = WirelessConnectionStore()
4158- self.treeview_connections = WirelessConnectionView(connection_store)
4159- ## Packing
4160- self.scrolledwindow_connections.add(self.treeview_connections)
4161- ## Population
4162- connections = app.devicemanager.get_remembered_wireless_connections()
4163- for connection in connections:
4164- self._add_connection(connection)
4165-
4166- self._update_widget_states(self.device.get_state())
4167-
4168- # Private Functions
4169- def _update_widget_states(self, state):
4170- if state == DEVICE_STATE_ON:
4171- device_editable = True
4172- settings_editable = True
4173- toggleswitch_state = True
4174- status_text = _("Wi-fi is on but not connected to the Internet.")
4175- elif state == DEVICE_STATE_CONNECTED:
4176- device_editable = True
4177- settings_editable = True
4178- toggleswitch_state = True
4179- status_text = _("Wi-fi is on and connected to the Internet.")
4180- elif state == DEVICE_STATE_OFF:
4181- device_editable = False
4182- settings_editable = False
4183- toggleswitch_state = False
4184- status_text = _("The Wi-fi device is powered off.")
4185-
4186- self.vbox_connections.set_sensitive(settings_editable)
4187- self.toggleswitch.set_sensitive(device_editable)
4188- self.toggleswitch.set_active(toggleswitch_state)
4189- self.label_status.set_text(status_text)
4190-
4191- def _add_connection(self, connection):
4192- network = connection.get_name()
4193- signal = float(connection.get_strength()) / 100
4194-
4195- # FIXME: implement
4196- # if connection.last_used:
4197- # date_format = locale.nl_langinfo(locale.D_FMT)
4198- # last_used = connection.last_used.strftime(date_format)
4199- # else:
4200- # last_used = _("Never")
4201-
4202- last_used = _("N/A")
4203-
4204- liststore = self.treeview_connections.get_model()
4205- liststore.append(connection, network, signal, last_used)
4206-
4207- # Callbacks
4208- def _on_device_state_changed(self, device, state):
4209- self._update_widget_states(state)
4210-
4211- def _on_toggleswitch_toggled(self, widget):
4212- if widget.get_active():
4213- self.device.disable()
4214- else:
4215- self.device.enable()
4216-
4217- def _on_button_connect_clicked(self, widget):
4218- connection = self.treeview_connections.get_selected_connection()
4219- connection.connect()
4220
4221=== removed file 'src/settings/indicatorNetworkSettings/frontend/widgets/deviceview.py'
4222--- src/settings/indicatorNetworkSettings/frontend/widgets/deviceview.py 2010-12-13 19:38:26 +0000
4223+++ src/settings/indicatorNetworkSettings/frontend/widgets/deviceview.py 1970-01-01 00:00:00 +0000
4224@@ -1,153 +0,0 @@
4225-# Copyright (C) 2010 Canonical
4226-#
4227-# Authors:
4228-# Andrew Higginson
4229-#
4230-# This program is free software; you can redistribute it and/or modify it under
4231-# the terms of the GNU General Public License as published by the Free Software
4232-# Foundation; version 3.
4233-#
4234-# This program is distributed in the hope that it will be useful, but WITHOUT
4235-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
4236-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
4237-# details.
4238-#
4239-# You should have received a copy of the GNU General Public License along with
4240-# this program; if not, write to the Free Software Foundation, Inc.,
4241-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
4242-
4243-import gtk
4244-import glib
4245-import gobject
4246-import pango
4247-
4248-from indicatorNetworkSettings.enums import *
4249-from indicatorNetworkSettings.frontend.widgets.cellrenderers \
4250- import PinCellRenderer
4251-
4252-from gettext import gettext as _
4253-
4254-class DeviceView(gtk.TreeView):
4255-
4256- __gsignals__ = {
4257- "selection-changed" : (gobject.SIGNAL_RUN_LAST,
4258- gobject.TYPE_NONE,
4259- ([gobject.TYPE_PYOBJECT]),
4260- ),
4261- "reordered" : (gobject.SIGNAL_RUN_LAST,
4262- gobject.TYPE_NONE,
4263- (),
4264- ),
4265- }
4266-
4267- def __init__(self, store):
4268- super(DeviceView, self).__init__()
4269- self.set_model(store)
4270-
4271- # Device (main) Column (contains pin icon, type icon and label)
4272- column = gtk.TreeViewColumn("Device")
4273- cr_pin = PinCellRenderer()
4274- cr_icon = gtk.CellRendererPixbuf()
4275- cr_label = gtk.CellRendererText()
4276- column.pack_start(cr_pin, False)
4277- column.set_attributes(cr_pin, color=DeviceStore.COL_PIN)
4278- column.pack_start(cr_icon, False)
4279- column.set_attributes(cr_icon, pixbuf=DeviceStore.COL_ICON)
4280- column.pack_start(cr_label, True)
4281- column.set_attributes(cr_label, markup=DeviceStore.COL_LABEL)
4282- cr_label.set_property("ellipsize", pango.ELLIPSIZE_END)
4283- self.append_column(column)
4284-
4285- self.set_headers_visible(False)
4286- self.set_reorderable(True)
4287-
4288- self._dragging = False
4289-
4290- self.get_selection().connect("changed", self._on_selection_changed)
4291- self.connect("drag-begin", self._on_drag_begin)
4292- self.connect("drag-end", self._on_drag_end)
4293- self.connect("drag-failed", self._on_drag_failed)
4294-
4295- def _on_selection_changed(self, selection):
4296- self.emit("selection-changed", selection)
4297-
4298- def _on_drag_begin(self, drag_context, *data):
4299- self._dragging = True
4300-
4301- def _on_drag_failed(self, drag_context, *data):
4302- self._dragging = False
4303-
4304- def _on_drag_end(self, drag_context, *data):
4305- if self._dragging:
4306- self.emit("reordered")
4307-
4308- def get_selected_device(self):
4309- (model, iter_) = self.get_selection().get_selected()
4310- if iter_:
4311- return model.get_value(iter_, 0)
4312- return None
4313-
4314-class DeviceStore(gtk.ListStore):
4315-
4316- (COL_DEVICE_OBJ, COL_SETTINGS_BOX, COL_PIN, COL_ICON, COL_LABEL) = range(5)
4317-
4318- def __init__(self, icons):
4319- super(DeviceStore, self).__init__(gobject.TYPE_PYOBJECT,
4320- gobject.TYPE_PYOBJECT, str,
4321- gtk.gdk.Pixbuf, str)
4322- self.icons = icons
4323-
4324- def append(self, device, settings_box):
4325- device.connect("state-changed", self._on_device_state_changed)
4326-
4327- pin_color = self._get_pin_color(device.state)
4328- caption = self._get_device_caption(device.state)
4329- label = DEVICE_TYPE_NAMES[device.type]
4330- icon = DEVICE_TYPE_ICONS[device.type]
4331-
4332- markup = self._get_markup(label, caption)
4333- try:
4334- icon_pixbuf = self.icons.load_icon(icon, 16, 16)
4335- except glib.GError:
4336- icon_pixbuf = self.icons.load_icon(GENERIC_DEVICE_ICON, 16, 16)
4337-
4338- row_data = [device, settings_box, pin_color, icon_pixbuf, markup]
4339-
4340- return super(DeviceStore, self).append(row_data)
4341-
4342- def _on_device_state_changed(self, device, state):
4343- iter_ = self._get_iter_for_device(device)
4344- pin_color = self._get_pin_color(state)
4345- caption = self._get_device_caption(state)
4346- label = DEVICE_TYPE_NAMES[device.type]
4347-
4348- markup = self._get_markup(label, caption)
4349-
4350- self.set_value(iter_, self.COL_PIN, pin_color)
4351- self.set_value(iter_, self.COL_LABEL, markup)
4352-
4353- def _get_iter_for_device(self, device):
4354- for row in self:
4355- if row[0] == device:
4356- return row.iter
4357-
4358- def _get_pin_color(self, state):
4359- if state == DEVICE_STATE_OFF:
4360- return "grey"
4361- elif state == DEVICE_STATE_ON:
4362- return "yellow"
4363- elif state == DEVICE_STATE_CONNECTED:
4364- return "green"
4365-
4366- def _get_device_caption(self, state):
4367- if state == DEVICE_STATE_OFF:
4368- return _("Off")
4369- elif state == DEVICE_STATE_ON:
4370- return _("Not Connected")
4371- elif state == DEVICE_STATE_CONNECTED:
4372- return _("Connected")
4373-
4374- def _get_markup(self, label, caption):
4375- return "%s\n<span font_size=\"small\">%s</span>" % (label, caption)
4376-
4377-
4378
4379=== removed file 'src/settings/indicatorNetworkSettings/frontend/widgets/toggleswitch.py'
4380--- src/settings/indicatorNetworkSettings/frontend/widgets/toggleswitch.py 2010-12-09 12:26:46 +0000
4381+++ src/settings/indicatorNetworkSettings/frontend/widgets/toggleswitch.py 1970-01-01 00:00:00 +0000
4382@@ -1,529 +0,0 @@
4383-#!/usr/bin/env python
4384-# -*- coding: utf-8 -*-
4385-#
4386-# Copyright (C) 2010 Canonical
4387-#
4388-# Authors:
4389-# Andrew Higginson
4390-#
4391-# This program is free software; you can redistribute it and/or modify it under
4392-# the terms of the GNU General Public License as published by the Free Software
4393-# Foundation; version 3.
4394-#
4395-# This program is distributed in the hope that it will be useful, but WITHOUT
4396-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
4397-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
4398-# details.
4399-#
4400-# You should have received a copy of the GNU General Public License along with
4401-# this program; if not, write to the Free Software Foundation, Inc.,
4402-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
4403-
4404-import atk
4405-import gtk
4406-import gobject
4407-import cairo
4408-
4409-from gettext import gettext as _
4410-
4411-PI = 3.1415926535897931
4412-PI_OVER_180 = 0.017453292519943295
4413-
4414-class ToggleSwitch(gtk.EventBox):
4415-
4416- """A switch containing the values ON and OFF (or user-inputed) that
4417- hides the inactive value. It can be clicked or dragged to change
4418- state, or through an enter/return keypress."""
4419-
4420- __gsignals__ = {
4421- "clicked" : (gobject.SIGNAL_RUN_LAST,
4422- gobject.TYPE_NONE,
4423- (),
4424- ),
4425- "toggled" : (gobject.SIGNAL_RUN_LAST,
4426- gobject.TYPE_NONE,
4427- (),
4428- ),
4429- }
4430-
4431- # (In relation to the height of the covering rectangle)
4432- LINE_HEIGHT_RATIO = 9/25.0
4433- LINE_SPACING_RATIO = 5/38.0
4434- CORNER_RADIUS = 3
4435-
4436- ANIMATION_DURATION = 800
4437-
4438- STATE_ACTIVE, STATE_INACTIVE = (True, False)
4439-
4440- # (In relation to the width/height of the text)
4441- TEXT_XPAD = 0.5
4442- TEXT_YPAD = 0.55
4443-
4444- # Used for storing Geometry of Widget
4445- GEO = {}
4446-
4447- def __init__(self, values=(_("ON"), _("OFF")), active=False):
4448- super(ToggleSwitch, self).__init__()
4449-
4450- self.set_visible_window(False)
4451-
4452- # Accessibility info
4453- self.atk = self.get_accessible()
4454- self.atk.set_role(atk.ROLE_CHECK_BOX)
4455-
4456- # Set events for the widget to receive
4457- self.set_flags(gtk.CAN_FOCUS)
4458- self.set_events(gtk.gdk.KEY_PRESS_MASK|
4459- gtk.gdk.ENTER_NOTIFY_MASK|
4460- gtk.gdk.LEAVE_NOTIFY_MASK|
4461- gtk.gdk.BUTTON_PRESS_MASK|
4462- gtk.gdk.BUTTON_RELEASE_MASK)
4463-
4464- # Connect signls and callbacks
4465- self.connect('style-set', self._on_style_set)
4466- self.connect('expose-event', self._on_expose_event)
4467- self.connect('button-press-event', self._on_press)
4468- self.connect('button-release-event', self._on_release)
4469- self.connect('key-release-event', self._on_key_release)
4470- self.connect('enter-notify-event', self._on_enter)
4471- self.connect('leave-notify-event', self._on_leave)
4472- self.connect('motion-notify-event', self._on_motion_notify_event)
4473-
4474- # Set values of the widget
4475- self.set_values(values)
4476- # Set default state of widget
4477- self.state_ = active
4478- # Allocate variables that will be used later
4479- self._layout = None
4480- self._animating = False
4481- self._pressed = False
4482-
4483- # If the covering rectangle needs to start on the right
4484- # set the offset to -1
4485- if self.state_ == self.STATE_ACTIVE:
4486- self.x_movement_offset = -1
4487- else:
4488- self.x_movement_offset = 0
4489-
4490- # Calculate the best size
4491- calc_width, calc_height = self._calculate_size()
4492- self.set_size_request(calc_width, calc_height)
4493-
4494- # Private functions
4495-
4496- def _calculate_size(self):
4497- """Calculate the best size for the toggleswitch based on the
4498- dimensions of the user's default font."""
4499- self._layout = self.create_pango_layout('')
4500-
4501- self._layout.set_text("ON")
4502- text_width, text_height = self._layout.get_pixel_extents()[1][2:]
4503-
4504- width = (text_width+(text_width*self.TEXT_XPAD*2))*2
4505- height = text_height+(text_height*self.TEXT_YPAD*2)
4506-
4507- return (int(width), int(height))
4508-
4509-
4510- def _draw_widget(self, widget):
4511- """Do the drawing of the actual widget."""
4512- cr = widget.window.cairo_create()
4513-
4514- # Store the dimensions of the widget for access throughout
4515- self.GEO["x"] = widget.allocation.x
4516- self.GEO["y"] = widget.allocation.y
4517- self.GEO["x1"] = widget.allocation.x + 1
4518- self.GEO["y1"] = widget.allocation.y + 1
4519- self.GEO["width"] = widget.allocation.width - 3
4520- self.GEO["height"] = widget.allocation.height - 3
4521- self.GEO["x2"] = widget.allocation.x + 1 + widget.allocation.width - 5
4522- self.GEO["y2"] = widget.allocation.y + 1 + widget.allocation.height - 5
4523-
4524- # Draw clipping rectangle
4525- self._layout_rounded_rectangle(cr, self.GEO["x"],
4526- self.GEO["y"],
4527- self.GEO["x"] + widget.allocation.width,
4528- self.GEO["y"] + widget.allocation.height)
4529- cr.clip()
4530-
4531- # Draw the main background
4532- self._draw_main_background(cr)
4533-
4534- # Draw the text
4535- self._draw_on_text()
4536- self._draw_off_text()
4537-
4538- # Draw the covering rectangle
4539- self._draw_covering_rectangle(cr)
4540-
4541- # Update ATK description, based on state
4542- if self.state_ == self.STATE_ACTIVE:
4543- self.atk.set_name(self.values[0])
4544- else:
4545- self.atk.set_name(self.values[1])
4546-
4547- def _draw_main_background(self, cr):
4548- x1 = self.GEO["x1"]
4549- y1 = self.GEO["y1"]
4550- x2 = self.GEO["x2"]
4551- y2 = self.GEO["y2"]
4552-
4553- # Don't change colour of background on hover or press
4554- if self.state == gtk.STATE_PRELIGHT or self.state == gtk.STATE_ACTIVE:
4555- state = gtk.STATE_NORMAL
4556- else:
4557- state = self.state
4558-
4559- # Layout the outline of the whole widget
4560- self._layout_rounded_rectangle(cr, x1, y1, x2, y2)
4561- ## Select colours
4562- fill = self.style.base[state]
4563- stroke = self.style.dark[state]
4564- ## Stroke and then fill it in
4565- self._stroke_rounded_rectangle(cr, stroke)
4566- self._fill_rounded_rectangle(cr, fill)
4567-
4568- # Layout the left (highlighted) part
4569- x1 = self.GEO["x1"]
4570- x2 = self.GEO["x1"] + (self.GEO["width"]/2)
4571- self._layout_rounded_rectangle(cr, x1, y1, x2, y2)
4572- ## Select colours
4573- fill = self.style.light[gtk.STATE_SELECTED]
4574- stroke = self.style.mid[gtk.STATE_SELECTED]
4575- ## Stroke and then fill it in
4576- self._stroke_rounded_rectangle(cr, stroke)
4577- self._fill_rounded_rectangle(cr, fill)
4578-
4579- # Layout the right (normal) part
4580- x1 = self.GEO["x2"] - (self.GEO["width"]/2)
4581- x2 = self.GEO["x2"]
4582- self._layout_rounded_rectangle(cr, x1, y1, x2, y2)
4583- ## Select colours
4584- fill = self.style.base[state]
4585- stroke = self.style.dark[state]
4586- ## Stroke and then fill it in
4587- self._stroke_rounded_rectangle(cr, stroke)
4588- self._fill_rounded_rectangle(cr, fill)
4589-
4590-
4591- def _draw_covering_rectangle(self, cr, x_offset=0):
4592- if self.x_movement_offset == -1:
4593- self.x_movement_offset = self.GEO["width"] / 2 - 1
4594- x1 = self.GEO["x1"] + self.x_movement_offset
4595- x2 = (self.GEO["width"] / 2) + self.GEO["x1"] + self.x_movement_offset
4596-
4597- y1 = self.GEO["y1"]
4598- y2 = self.GEO["y2"]
4599-
4600- stroke = self.style.dark[self.state]
4601- self._layout_rounded_rectangle(cr, x1, y1, x2, y2)
4602- self._stroke_rounded_rectangle(cr, stroke)
4603-
4604- if self.state == gtk.STATE_INSENSITIVE:
4605- fill = self.style.bg[self.state]
4606- self._fill_rounded_rectangle(cr, fill)
4607- else:
4608- fill1 = self.style.light[self.state]
4609- fill2 = self.style.mid[self.state]
4610- linear = self._create_vertical_gradient(fill1, fill2, x1, x2, y1, y2)
4611- self._fill_gradient_rounded_rectangle(cr, linear)
4612-
4613- # Draw the vertical lines
4614- fill_dark = self.style.dark[self.state]
4615- fill_light = self.style.light[self.state]
4616- height = round(self.GEO["height"]*self.LINE_HEIGHT_RATIO)
4617- width = 1
4618-
4619- spacing = int(self.LINE_SPACING_RATIO * (self.GEO["width"] / 2))
4620- c_spacing = 0
4621-
4622- x_offset = ((self.GEO["width"] / 2) - (6+(spacing*2)))/2 + 2
4623- y_offset = (self.GEO["height"] - height)/2
4624-
4625- for i in range(3):
4626- self._draw_vertical_line(cr, x1+x_offset+c_spacing,
4627- y1+y_offset, width, height, fill_dark)
4628- self._draw_vertical_line(cr, x1+x_offset+c_spacing+1,
4629- y1+y_offset, width, height, fill_light)
4630- c_spacing += spacing
4631-
4632-
4633- def _draw_vertical_line(self, cr, x1, y1, width, height, fill):
4634- """Draw a vertical line on the covering rectangle"""
4635- cr.rectangle(x1, y1, width, height)
4636- cr.set_source_rgb(fill.red_float, fill.green_float, fill.blue_float)
4637- cr.fill()
4638-
4639- def _draw_on_text(self):
4640- """Draw the ON (or otherwise) text"""
4641- text = self.values[0]
4642- gravity = "left"
4643- self._draw_text_centered_text(text, gravity)
4644-
4645- def _draw_off_text(self):
4646- """Draw the OFF (or otherwise) text"""
4647- text = self.values[1]
4648- gravity = "right"
4649- self._draw_text_centered_text(text, gravity)
4650-
4651- def _draw_text_centered_text(self, text, gravity):
4652- if not self._layout:
4653- self._layout = self.create_pango_layout('')
4654-
4655- self._layout.set_text(text)
4656- text_width, text_height = self._layout.get_pixel_extents()[1][2:]
4657-
4658- if self.x_movement_offset == -1:
4659- if gravity == "right":
4660- text_x_offset = (((self.GEO["width"]/2) - text_width) / 2) + (self.GEO["width"]/2)
4661- elif gravity == "left":
4662- text_x_offset = (((self.GEO["width"]/2) - text_width) / 2) + self.x_movement_offset
4663- else:
4664- if gravity == "right":
4665- text_x_offset = (((self.GEO["width"]/2) - text_width) / 2) + (self.GEO["width"]/2) + self.x_movement_offset
4666- elif gravity == "left":
4667- text_x_offset = (((self.GEO["width"]/2) - text_width) / 2) + (self.x_movement_offset-(self.GEO["width"]/2))
4668-
4669- text_y_offset = ((self.GEO["height"] - text_height) / 2)
4670-
4671- self.style.paint_layout(self.window, self.state, True,
4672- (self.GEO["x"], self.GEO["y"],
4673- self.GEO["width"], self.GEO["height"]),
4674- self, '',
4675- int(self.GEO["x1"]+text_x_offset),
4676- int(self.GEO["y1"]+text_y_offset),
4677- self._layout)
4678-
4679-
4680- def _layout_rounded_rectangle(self, cr, x, y, w, h):
4681- r = self.CORNER_RADIUS
4682- cr.new_sub_path()
4683- cr.arc(r+x, r+y, r, PI, 270*PI_OVER_180)
4684- cr.arc(w-r, r+y, r, 270*PI_OVER_180, 0)
4685- cr.arc(w-r, h-r, r, 0, 90*PI_OVER_180)
4686- cr.arc(r+x, h-r, r, 90*PI_OVER_180, PI)
4687- cr.close_path()
4688-
4689- def _fill_rounded_rectangle(self, cr, fill):
4690- cr.set_source_rgb(fill.red_float,
4691- fill.green_float,
4692- fill.blue_float)
4693- cr.fill()
4694-
4695- def _fill_gradient_rounded_rectangle(self, cr, fill):
4696- cr.set_source(fill)
4697- cr.fill()
4698-
4699- def _stroke_rounded_rectangle(self, cr, stroke):
4700- cr.set_source_rgb(stroke.red_float,
4701- stroke.green_float,
4702- stroke.blue_float)
4703- cr.stroke_preserve()
4704-
4705- def _create_vertical_gradient(self, color1, color2, x1, x2, y1, y2):
4706- linear = cairo.LinearGradient(x1, y1, x1, y2)
4707- linear.add_color_stop_rgba(0.00, color1.red_float,
4708- color1.green_float,
4709- color1.blue_float, 1)
4710- linear.add_color_stop_rgba(0.8, color2.red_float,
4711- color2.green_float,
4712- color2.blue_float, 1)
4713- return linear
4714-
4715- def _increment_movement(self, state):
4716- if state == self.STATE_ACTIVE:
4717- increment = 1
4718- criterion = self.x_movement_offset == (self.GEO["x2"] - (self.GEO["width"]/2) - self.GEO["x1"])
4719- else:
4720- increment = -1
4721- criterion = self.x_movement_offset == 0
4722-
4723- if criterion:
4724- self._animating = False
4725- self.queue_draw()
4726- return False
4727- else:
4728- self.x_movement_offset += increment
4729- self.queue_draw()
4730- return True
4731-
4732- # Callbacks
4733- def _on_style_set(self, widget, event):
4734- # Re-calculate the best size
4735- calc_width, calc_height = self._calculate_size()
4736- self.set_size_request(calc_width, calc_height)
4737-
4738- def _on_expose_event(self, widget, event):
4739- self._draw_widget(widget)
4740-
4741- def _on_press(self, widget, event):
4742- self.set_state(gtk.STATE_ACTIVE)
4743- if event.x < self.GEO["width"]/2:
4744- self.offset = event.x
4745- elif event.x > self.GEO["width"]/2:
4746- self.offset = event.x - self.GEO["width"]/2
4747-
4748- def _on_release(self, widget, event):
4749- if not self._animating:
4750- if self._pressed:
4751- if self.x_movement_offset <= self.GEO["width"] / 4:
4752- gobject.timeout_add(5, self._increment_movement,
4753- self.STATE_INACTIVE)
4754- self.state_ = self.STATE_INACTIVE
4755- self.emit('toggled')
4756- elif self.x_movement_offset >= self.GEO["width"] / 4:
4757- gobject.timeout_add(5, self._increment_movement,
4758- self.STATE_ACTIVE)
4759- self.state_ = self.STATE_ACTIVE
4760- self.emit('toggled')
4761- self._pressed = False
4762- self.offset = 0
4763- else:
4764- self.set_state(gtk.STATE_PRELIGHT)
4765- self.state_ = not self.state_
4766- self.emit('clicked')
4767- self.emit('toggled')
4768- gobject.timeout_add(5, self._increment_movement,
4769- self.state_)
4770- self._pressed = False
4771- self._animating = True
4772-
4773- def _on_motion_notify_event(self, widget, event):
4774- self._pressed = True
4775- if event.x - self.offset < 0:
4776- self.x_movement_offset = 0
4777- elif event.x - self.offset >= (self.GEO["width"]/2 - 1):
4778- self.x_movement_offset = self.GEO["width"]/2 -1
4779- else:
4780- self.x_movement_offset = event.x - self.offset
4781- self.queue_draw()
4782-
4783- def _on_key_release(self, widget, event):
4784- if widget.has_focus():
4785- if event.keyval == gtk.keysyms.Return or \
4786- event.keyval == gtk.keysyms.KP_Enter:
4787- self.toggled()
4788-
4789- def _on_enter(self, widget, event):
4790- self.set_state(gtk.STATE_PRELIGHT)
4791-
4792- def _on_leave(self, widget, event):
4793- self.set_state(gtk.STATE_NORMAL)
4794-
4795- # Public functions
4796-
4797- def get_active(self):
4798- return self.state_
4799-
4800- def set_active(self, state):
4801- # If the widget is not yet realized, don't bother animating
4802- if self.get_window() == None:
4803- if state:
4804- self.x_movement_offset = -1
4805- else:
4806- self.x_movement_offset = 0
4807- self.queue_draw()
4808- self.state_ = state
4809- # Otherwise if we are not already animating, change the state
4810- elif not self._animating:
4811- self._animating = True
4812- self._on_release(self, None)
4813-
4814- def set_values(self, values):
4815- # If the variable values is a tuple of length 2, and type string
4816- # set the widget's values property to it.
4817- if (len(values) == 2) and (type(values) == tuple):
4818- if (type(values[0]) == str) and (type(values[1]) == str):
4819- self.values = values
4820- return
4821- # Otherwise raise a Type error
4822- raise TypeError("ToggleSwitch.set_values() argument 1 must be " + \
4823- "String Tuple of length 2, not %s." % type(values))
4824-
4825- def toggled(self):
4826- self._on_release(self, None)
4827-
4828- def pressed(self):
4829- self._on_press(self, None)
4830-
4831- def clicked(self):
4832- self._on_release(self, None)
4833-
4834- def enter(self):
4835- self._on_enter(self, None)
4836-
4837- def leave(self):
4838- self._on_leave(self, None)
4839-
4840-class InfoBox(gtk.HBox):
4841- """A gtk.HBox that is filled with the mid-colour and stroked with
4842- the dark colour from a user's gtk theme so that it stands out."""
4843-
4844- YPAD = 1
4845- XPAD = 1
4846-
4847- def __init__(self, homogeneous=False, spacing=0):
4848- super(InfoBox, self).__init__(homogeneous, spacing)
4849- self.connect('expose-event', self._on_expose_event)
4850-
4851- def _on_expose_event(self, widget, event):
4852- cr = widget.window.cairo_create()
4853-
4854- # Get geometry
4855- x = widget.allocation.x + self.XPAD
4856- y = widget.allocation.y + self.YPAD
4857- width = widget.allocation.width - (self.XPAD * 2)
4858- height = widget.allocation.height - (self.YPAD * 2)
4859-
4860- # Fill with the mid color from the current gtk theme
4861- fill = self.style.mid[self.state]
4862- # Fill with the dark color from the current gtk theme
4863- stroke = self.style.dark[self.state]
4864-
4865- # Layout the rectangle
4866- cr.rectangle(x, y, width, height)
4867- # Stroke the outline
4868- cr.set_source_rgb(stroke.red_float, stroke.green_float,
4869- stroke.blue_float)
4870- cr.stroke_preserve()
4871- # Fill it in
4872- cr.set_source_rgb(fill.red_float, fill.green_float,
4873- fill.blue_float)
4874- cr.fill()
4875-
4876-if __name__ == "__main__":
4877- def on_toggle_switch_clicked(widget):
4878- print widget.get_active()
4879-
4880- def do():
4881- s.toggled()
4882- return True
4883-
4884- w = gtk.Window()
4885- v = gtk.VBox()
4886- h = gtk.HBox()
4887- i = InfoBox(spacing=12)
4888- s = ToggleSwitch()
4889- si = ToggleSwitch()
4890- si.set_sensitive(False)
4891- l = gtk.Label("Wi-fi is on and connected to the Internet.")
4892-
4893- gobject.timeout_add(3000, do)
4894-
4895- w.connect("delete-event", gtk.main_quit)
4896- s.connect("clicked", on_toggle_switch_clicked)
4897-
4898- v.set_border_width(10)
4899- w.set_default_size(200, 200)
4900-
4901- i.pack_start(l, False)
4902- i.pack_start(s, False, False)
4903- i.pack_start(si, False, False)
4904- i.set_border_width(12)
4905- h.pack_start(i)
4906- v.pack_start(h, False, False)
4907- w.add(v)
4908-
4909- w.show_all()
4910- gtk.main()
4911-
4912
4913=== removed file 'src/settings/indicatorNetworkSettings/utils.py'
4914--- src/settings/indicatorNetworkSettings/utils.py 2010-12-07 15:07:37 +0000
4915+++ src/settings/indicatorNetworkSettings/utils.py 1970-01-01 00:00:00 +0000
4916@@ -1,18 +0,0 @@
4917-# Copyright (C) 2010 Canonical
4918-#
4919-# Authors:
4920-# Andrew Higginson
4921-#
4922-# This program is free software; you can redistribute it and/or modify it under
4923-# the terms of the GNU General Public License as published by the Free Software
4924-# Foundation; version 3.
4925-#
4926-# This program is distributed in the hope that it will be useful, but WITHOUT
4927-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
4928-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
4929-# details.
4930-#
4931-# You should have received a copy of the GNU General Public License along with
4932-# this program; if not, write to the Free Software Foundation, Inc.,
4933-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
4934-
4935
4936=== removed file 'src/settings/indicatorNetworkSettings/version.py'
4937--- src/settings/indicatorNetworkSettings/version.py 2010-12-07 15:07:37 +0000
4938+++ src/settings/indicatorNetworkSettings/version.py 1970-01-01 00:00:00 +0000
4939@@ -1,5 +0,0 @@
4940-
4941-VERSION = '0.01'
4942-CODENAME = 'UNRELEASED'
4943-DISTRO = 'Ubuntu'
4944-RELEASE = '11.04'
4945
4946=== added file 'src/settings/logger.vala'
4947--- src/settings/logger.vala 1970-01-01 00:00:00 +0000
4948+++ src/settings/logger.vala 2011-01-07 16:06:25 +0000
4949@@ -0,0 +1,44 @@
4950+/*
4951+ * indicator-network - user interface for connman
4952+ * Copyright 2010-2011 Canonical Ltd.
4953+ *
4954+ * Authors:
4955+ * Andrew Higginson
4956+ *
4957+ * This program is free software: you can redistribute it and/or modify it
4958+ * under the terms of the GNU General Public License version 3, as published
4959+ * by the Free Software Foundation.
4960+ *
4961+ * This program is distributed in the hope that it will be useful, but
4962+ * WITHOUT ANY WARRANTY; without even the implied warranties of
4963+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
4964+ * PURPOSE. See the GNU General Public License for more details.
4965+ *
4966+ * You should have received a copy of the GNU General Public License along
4967+ * with this program. If not, see <http://www.gnu.org/licenses/>.
4968+ */
4969+
4970+public enum LogLevel {
4971+ NONE,
4972+ INFO,
4973+ DEBUG
4974+}
4975+
4976+public class Logger : Object {
4977+
4978+ public LogLevel level {get; set;}
4979+
4980+ public void debug(string text) {
4981+ if (this.level >= LogLevel.DEBUG) {
4982+ var msg = @"DEBUG: $text\n";
4983+ stdout.printf(msg);
4984+ }
4985+ }
4986+
4987+ public void info(string text) {
4988+ if (this.level >= LogLevel.INFO) {
4989+ var msg = @"INFO: $text\n";
4990+ stdout.printf(msg);
4991+ }
4992+ }
4993+}
4994
4995=== added file 'src/settings/main.vala'
4996--- src/settings/main.vala 1970-01-01 00:00:00 +0000
4997+++ src/settings/main.vala 2011-01-07 16:06:25 +0000
4998@@ -0,0 +1,68 @@
4999+/*
5000+ * indicator-network - user interface for connman
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches