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