Merge lp:~elementary-pantheon/switchboard-plug-security-privacy/trackpanel-classes into lp:~elementary-apps/switchboard-plug-security-privacy/trunk
- trackpanel-classes
- Merge into trunk
Proposed by
Danielle Foré
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | David Hewitt | ||||
Approved revision: | 304 | ||||
Merged at revision: | 303 | ||||
Proposed branch: | lp:~elementary-pantheon/switchboard-plug-security-privacy/trackpanel-classes | ||||
Merge into: | lp:~elementary-apps/switchboard-plug-security-privacy/trunk | ||||
Diff against target: |
700 lines (+328/-291) 5 files modified
src/CMakeLists.txt (+2/-0) src/Views/TrackPanel.vala (+41/-290) src/Widgets/ExcludeTreeView.vala (+186/-0) src/Widgets/IncludeTreeView.vala (+98/-0) src/Widgets/ServiceList.vala (+1/-1) |
||||
To merge this branch: | bzr merge lp:~elementary-pantheon/switchboard-plug-security-privacy/trackpanel-classes | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
David Hewitt | code, function | Approve | |
Review via email: mp+318424@code.launchpad.net |
Commit message
* Split TrackPanel.vala into 3 classes
* Rename "Privacy" to History
* Update copy to reflect the rename
* Invert switch active state to match the new label
Description of the change
These changes are a bit unrelated but I split this up so I could understand what was going on in order to implement this change
To post a comment you must log in.
Revision history for this message
David Hewitt (davidmhewitt) wrote : | # |
review:
Approve
(code, function)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/CMakeLists.txt' |
2 | --- src/CMakeLists.txt 2017-02-26 20:21:42 +0000 |
3 | +++ src/CMakeLists.txt 2017-02-27 23:09:39 +0000 |
4 | @@ -25,6 +25,8 @@ |
5 | Widgets/AppChooser.vala |
6 | Widgets/AppRow.vala |
7 | Widgets/ClearUsagePopover.vala |
8 | + Widgets/ExcludeTreeView.vala |
9 | + Widgets/IncludeTreeView.vala |
10 | Widgets/ServiceItem.vala |
11 | Widgets/ServiceList.vala |
12 | |
13 | |
14 | === modified file 'src/Views/TrackPanel.vala' |
15 | --- src/Views/TrackPanel.vala 2017-02-27 18:20:56 +0000 |
16 | +++ src/Views/TrackPanel.vala 2017-02-27 23:09:39 +0000 |
17 | @@ -22,32 +22,8 @@ |
18 | |
19 | public class SecurityPrivacy.TrackPanel : Gtk.Grid { |
20 | private Widgets.ClearUsagePopover remove_popover; |
21 | - private Dialogs.AppChooser app_chooser; |
22 | - private ApplicationBlacklist app_blacklist; |
23 | - private PathBlacklist path_blacklist; |
24 | - private FileTypeBlacklist filetype_blacklist; |
25 | - private Gtk.Grid record_grid; |
26 | - private Gtk.Container description_frame; |
27 | - private Gtk.Grid exclude_grid; |
28 | - |
29 | private Gtk.Switch record_switch; |
30 | |
31 | - private enum Columns { |
32 | - ACTIVE, |
33 | - NAME, |
34 | - ICON, |
35 | - FILE_TYPE, |
36 | - N_COLUMNS |
37 | - } |
38 | - |
39 | - private enum NotColumns { |
40 | - NAME, |
41 | - ICON, |
42 | - PATH, |
43 | - IS_APP, |
44 | - N_COLUMNS |
45 | - } |
46 | - |
47 | public TrackPanel () { |
48 | Object (column_spacing: 12, |
49 | margin: 12, |
50 | @@ -55,34 +31,28 @@ |
51 | } |
52 | |
53 | construct { |
54 | - app_blacklist = new ApplicationBlacklist (blacklist); |
55 | - path_blacklist = new PathBlacklist (blacklist); |
56 | - filetype_blacklist = new FileTypeBlacklist (blacklist); |
57 | - |
58 | - create_description_panel (); |
59 | - |
60 | - var privacy_settings = new GLib.Settings ("org.gnome.desktop.privacy"); |
61 | - |
62 | - var icon = new Gtk.Image.from_icon_name ("document-open-recent", Gtk.IconSize.DIALOG); |
63 | - |
64 | - var record_label = new Gtk.Label (_("Privacy")); |
65 | + var title = _("History Is Disabled").printf (get_operating_system_name ()); |
66 | + var description = ("%s\n\n%s\n\n%s".printf ( |
67 | + _("%s won't retain any further data or statistics about file and application usage.").printf (get_operating_system_name ()), |
68 | + _("The additional functionality that this data provides will be affected."), |
69 | + _("This will not prevent apps from recording their own usage data like browser history."))); |
70 | + |
71 | + var alert = new Granite.Widgets.AlertView (title, description, ""); |
72 | + alert.show_all (); |
73 | + |
74 | + var description_frame = new Gtk.Frame (null); |
75 | + description_frame.no_show_all = true; |
76 | + description_frame.add (alert); |
77 | + |
78 | + var header_image = new Gtk.Image.from_icon_name ("document-open-recent", Gtk.IconSize.DIALOG); |
79 | + |
80 | + var record_label = new Gtk.Label (_("History")); |
81 | record_label.get_style_context ().add_class ("h2"); |
82 | |
83 | record_switch = new Gtk.Switch (); |
84 | + record_switch.active = true; |
85 | record_switch.valign = Gtk.Align.CENTER; |
86 | |
87 | - record_switch.notify["active"].connect (() => { |
88 | - bool privacy_mode = record_switch.active; |
89 | - record_grid.visible = !privacy_mode; |
90 | - exclude_grid.visible = !privacy_mode; |
91 | - description_frame.visible = privacy_mode; |
92 | - if (privacy_mode != blacklist.get_incognito ()) { |
93 | - blacklist.set_incognito (privacy_mode); |
94 | - privacy_settings.set_boolean ("remember-recent-files", !privacy_mode); |
95 | - privacy_settings.set_boolean ("remember-app-usage", !privacy_mode); |
96 | - } |
97 | - }); |
98 | - |
99 | var info_button = new Gtk.Image.from_icon_name ("help-info-symbolic", Gtk.IconSize.MENU); |
100 | info_button.hexpand = true; |
101 | info_button.xalign = 0; |
102 | @@ -91,12 +61,12 @@ |
103 | var header_grid = new Gtk.Grid (); |
104 | header_grid.column_spacing = 12; |
105 | header_grid.margin_bottom = 12; |
106 | - header_grid.add (icon); |
107 | + header_grid.add (header_image); |
108 | header_grid.add (record_label); |
109 | header_grid.add (info_button); |
110 | header_grid.add (record_switch); |
111 | |
112 | - var clear_data = new Gtk.ToggleButton.with_label (_("Clear Usage Data…")); |
113 | + var clear_data = new Gtk.ToggleButton.with_label (_("Clear History…")); |
114 | clear_data.halign = Gtk.Align.END; |
115 | clear_data.notify["active"].connect (() => { |
116 | if (clear_data.active == false) { |
117 | @@ -111,13 +81,31 @@ |
118 | clear_data.active = false; |
119 | }); |
120 | |
121 | - create_include_treeview (); |
122 | - create_exclude_treeview (); |
123 | + var include_treeview = new IncludeTreeView (); |
124 | + var exclude_treeview = new ExcludeTreeView (); |
125 | + |
126 | attach (header_grid, 0, 0, 2, 1); |
127 | - attach (exclude_grid, 1, 1, 1, 1); |
128 | + attach (description_frame, 0, 1, 2, 1); |
129 | + attach (include_treeview, 0, 1, 1, 1); |
130 | + attach (exclude_treeview, 1, 1, 1, 1); |
131 | attach (clear_data, 1, 2, 1, 1); |
132 | |
133 | - record_switch.active = blacklist.get_incognito (); |
134 | + record_switch.notify["active"].connect (() => { |
135 | + bool privacy_mode = !record_switch.active; |
136 | + include_treeview.visible = !privacy_mode; |
137 | + exclude_treeview.visible = !privacy_mode; |
138 | + description_frame.visible = privacy_mode; |
139 | + |
140 | + if (privacy_mode != blacklist.get_incognito ()) { |
141 | + blacklist.set_incognito (privacy_mode); |
142 | + |
143 | + var privacy_settings = new GLib.Settings ("org.gnome.desktop.privacy"); |
144 | + privacy_settings.set_boolean ("remember-recent-files", !privacy_mode); |
145 | + privacy_settings.set_boolean ("remember-app-usage", !privacy_mode); |
146 | + } |
147 | + }); |
148 | + |
149 | + record_switch.active = !blacklist.get_incognito (); |
150 | } |
151 | |
152 | public void focus_privacy_switch () { |
153 | @@ -137,241 +125,4 @@ |
154 | } |
155 | return system; |
156 | } |
157 | - |
158 | - private void create_description_panel () { |
159 | - description_frame = new Gtk.Frame (null); |
160 | - description_frame.expand = true; |
161 | - description_frame.no_show_all = true; |
162 | - |
163 | - string system = get_operating_system_name (); |
164 | - |
165 | - var icon = "view-private"; |
166 | - var title = _("%s is in Privacy Mode").printf (system); |
167 | - var description = ("%s\n\n%s\n\n%s".printf ( |
168 | - _("While in Privacy Mode, this operating system won't retain any further data or statistics about file and application usage."), |
169 | - _("The additional functionality that this data provides will be affected."), |
170 | - _("This will not prevent apps from recording their own usage data like browser history."))); |
171 | - |
172 | - var alert = new Granite.Widgets.AlertView (title, description, icon); |
173 | - alert.show_all (); |
174 | - |
175 | - description_frame.add (alert); |
176 | - |
177 | - attach (description_frame, 0, 1, 2, 1); |
178 | - } |
179 | - |
180 | - private void create_include_treeview () { |
181 | - var list_store = new Gtk.ListStore (Columns.N_COLUMNS, typeof (bool), |
182 | - typeof (string), typeof (string), typeof (string)); |
183 | - |
184 | - var view = new Gtk.TreeView.with_model (list_store); |
185 | - view.vexpand = true; |
186 | - view.headers_visible = false; |
187 | - view.activate_on_single_click = true; |
188 | - |
189 | - var celltoggle = new Gtk.CellRendererToggle (); |
190 | - view.row_activated.connect ((path, column) => { |
191 | - Value active; |
192 | - Gtk.TreeIter iter; |
193 | - list_store.get_iter (out iter, path); |
194 | - list_store.get_value (iter, Columns.ACTIVE, out active); |
195 | - var is_active = !active.get_boolean (); |
196 | - list_store.set (iter, Columns.ACTIVE, is_active); |
197 | - Value name; |
198 | - list_store.get_value (iter, Columns.FILE_TYPE, out name); |
199 | - if (is_active == true) { |
200 | - filetype_blacklist.unblock (name.get_string ()); |
201 | - } else { |
202 | - filetype_blacklist.block (name.get_string ()); |
203 | - } |
204 | - }); |
205 | - |
206 | - var cell = new Gtk.CellRendererText (); |
207 | - var cellpixbuf = new Gtk.CellRendererPixbuf (); |
208 | - cellpixbuf.stock_size = Gtk.IconSize.DND; |
209 | - view.insert_column_with_attributes (-1, "", celltoggle, "active", Columns.ACTIVE); |
210 | - view.insert_column_with_attributes (-1, "", cellpixbuf, "icon-name", Columns.ICON); |
211 | - view.insert_column_with_attributes (-1, "", cell, "markup", Columns.NAME); |
212 | - |
213 | - var scrolled = new Gtk.ScrolledWindow (null, null); |
214 | - scrolled.shadow_type = Gtk.ShadowType.IN; |
215 | - scrolled.expand = true; |
216 | - scrolled.add (view); |
217 | - |
218 | - var record_label = new Gtk.Label (_("Data Sources:")); |
219 | - record_label.xalign = 0; |
220 | - |
221 | - record_grid = new Gtk.Grid (); |
222 | - record_grid.row_spacing = 6; |
223 | - record_grid.attach (record_label, 0, 0, 1, 1); |
224 | - record_grid.attach (scrolled, 0, 1, 1, 1); |
225 | - attach (record_grid, 0, 1, 1, 1); |
226 | - |
227 | - set_inclue_iter_to_liststore (list_store, _("Chat Logs"), "internet-chat", Zeitgeist.NMO.IMMESSAGE); |
228 | - set_inclue_iter_to_liststore (list_store, _("Documents"), "x-office-document", Zeitgeist.NFO.DOCUMENT); |
229 | - set_inclue_iter_to_liststore (list_store, _("Music"), "audio-x-generic", Zeitgeist.NFO.AUDIO); |
230 | - set_inclue_iter_to_liststore (list_store, _("Pictures"), "image-x-generic", Zeitgeist.NFO.IMAGE); |
231 | - set_inclue_iter_to_liststore (list_store, _("Presentations"), "x-office-presentation", Zeitgeist.NFO.PRESENTATION); |
232 | - set_inclue_iter_to_liststore (list_store, _("Spreadsheets"), "x-office-spreadsheet", Zeitgeist.NFO.SPREADSHEET); |
233 | - set_inclue_iter_to_liststore (list_store, _("Videos"), "video-x-generic", Zeitgeist.NFO.VIDEO); |
234 | - } |
235 | - |
236 | - private void set_inclue_iter_to_liststore (Gtk.ListStore list_store, string name, string icon, string file_type) { |
237 | - Gtk.TreeIter iter; |
238 | - list_store.append (out iter); |
239 | - bool active = (filetype_blacklist.all_filetypes.contains (file_type) == false); |
240 | - list_store.set (iter, Columns.ACTIVE, active, Columns.NAME, name, |
241 | - Columns.ICON, icon, Columns.FILE_TYPE, file_type); |
242 | - } |
243 | - |
244 | - private void create_exclude_treeview () { |
245 | - var list_store = new Gtk.ListStore (NotColumns.N_COLUMNS, typeof (string), |
246 | - typeof (Icon), typeof (string), typeof (bool)); |
247 | - |
248 | - var view = new Gtk.TreeView.with_model (list_store); |
249 | - view.vexpand = true; |
250 | - view.headers_visible = false; |
251 | - |
252 | - var cell = new Gtk.CellRendererText (); |
253 | - var cellpixbuf = new Gtk.CellRendererPixbuf (); |
254 | - cellpixbuf.stock_size = Gtk.IconSize.DND; |
255 | - view.insert_column_with_attributes (-1, "", cellpixbuf, "gicon", NotColumns.ICON); |
256 | - view.insert_column_with_attributes (-1, "", cell, "markup", NotColumns.NAME); |
257 | - |
258 | - var scrolled = new Gtk.ScrolledWindow (null, null); |
259 | - scrolled.expand = true; |
260 | - scrolled.add (view); |
261 | - |
262 | - var add_app_button = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("application-add-symbolic", Gtk.IconSize.SMALL_TOOLBAR), null); |
263 | - add_app_button.tooltip_text = _("Add Application…"); |
264 | - add_app_button.clicked.connect (() => { |
265 | - if (app_chooser.visible == false) { |
266 | - app_chooser.show_all (); |
267 | - } |
268 | - }); |
269 | - |
270 | - app_chooser = new Dialogs.AppChooser (add_app_button); |
271 | - app_chooser.modal = true; |
272 | - app_chooser.app_chosen.connect ((info) => { |
273 | - var file = File.new_for_path (info.filename); |
274 | - app_blacklist.block (file.get_basename ()); |
275 | - }); |
276 | - |
277 | - var add_folder_button = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("folder-new-symbolic", Gtk.IconSize.SMALL_TOOLBAR), null); |
278 | - add_folder_button.tooltip_text = _("Add Folder…"); |
279 | - add_folder_button.clicked.connect (() => { |
280 | - var chooser = new Gtk.FileChooserDialog (_("Select a folder to blacklist"), null, Gtk.FileChooserAction.SELECT_FOLDER); |
281 | - chooser.add_buttons (_("Cancel"), Gtk.ResponseType.CANCEL, _("Add"), Gtk.ResponseType.OK); |
282 | - int res = chooser.run (); |
283 | - chooser.hide (); |
284 | - if (res == Gtk.ResponseType.OK) { |
285 | - string folder = chooser.get_filename (); |
286 | - if (this.path_blacklist.is_duplicate (folder) == false) { |
287 | - path_blacklist.block (folder); |
288 | - } |
289 | - } |
290 | - }); |
291 | - |
292 | - var remove_button = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("list-remove-symbolic", Gtk.IconSize.SMALL_TOOLBAR), null); |
293 | - remove_button.tooltip_text = _("Delete"); |
294 | - remove_button.sensitive = false; |
295 | - remove_button.clicked.connect (() => { |
296 | - Gtk.TreePath path; |
297 | - Gtk.TreeViewColumn column; |
298 | - view.get_cursor (out path, out column); |
299 | - Gtk.TreeIter iter; |
300 | - list_store.get_iter (out iter, path); |
301 | - Value is_app; |
302 | - list_store.get_value (iter, NotColumns.IS_APP, out is_app); |
303 | - if (is_app.get_boolean () == true) { |
304 | - string name; |
305 | - list_store.get (iter, NotColumns.PATH, out name); |
306 | - app_blacklist.unblock (name); |
307 | - } else { |
308 | - string name; |
309 | - list_store.get (iter, NotColumns.PATH, out name); |
310 | - path_blacklist.unblock (name); |
311 | - } |
312 | - |
313 | -#if VALA_0_36 |
314 | - list_store.remove (ref iter); |
315 | -#else |
316 | - list_store.remove (iter); |
317 | -#endif |
318 | - }); |
319 | - |
320 | - var list_toolbar = new Gtk.Toolbar (); |
321 | - list_toolbar.get_style_context ().add_class (Gtk.STYLE_CLASS_INLINE_TOOLBAR); |
322 | - list_toolbar.set_icon_size (Gtk.IconSize.SMALL_TOOLBAR); |
323 | - list_toolbar.insert (add_app_button, -1); |
324 | - list_toolbar.insert (add_folder_button, -1); |
325 | - list_toolbar.insert (remove_button, -1); |
326 | - |
327 | - var frame_grid = new Gtk.Grid (); |
328 | - frame_grid.orientation = Gtk.Orientation.VERTICAL; |
329 | - frame_grid.add (scrolled); |
330 | - frame_grid.add (list_toolbar); |
331 | - |
332 | - var frame = new Gtk.Frame (null); |
333 | - frame.add (frame_grid); |
334 | - |
335 | - var record_label = new Gtk.Label (_("Do not collect data from the following:")); |
336 | - record_label.xalign = 0; |
337 | - |
338 | - exclude_grid = new Gtk.Grid (); |
339 | - exclude_grid.row_spacing = 6; |
340 | - exclude_grid.orientation = Gtk.Orientation.VERTICAL; |
341 | - exclude_grid.add (record_label); |
342 | - exclude_grid.add (frame); |
343 | - |
344 | - view.cursor_changed.connect (() => { |
345 | - remove_button.sensitive = true; |
346 | - }); |
347 | - |
348 | - Gtk.TreeIter iter; |
349 | - foreach (var app_info in AppInfo.get_all ()) { |
350 | - if (app_info is DesktopAppInfo) { |
351 | - var file = File.new_for_path (((DesktopAppInfo)app_info).filename); |
352 | - if (app_blacklist.all_apps.contains (file.get_basename ())) { |
353 | - list_store.append (out iter); |
354 | - list_store.set (iter, NotColumns.NAME, Markup.escape_text (app_info.get_display_name ()), |
355 | - NotColumns.ICON, app_info.get_icon (), NotColumns.PATH, file.get_basename (), |
356 | - NotColumns.IS_APP, true); |
357 | - } |
358 | - } |
359 | - } |
360 | - |
361 | - foreach (var folder in path_blacklist.all_folders) { |
362 | - list_store.append (out iter); |
363 | - var file = File.new_for_path (folder); |
364 | - list_store.set (iter, NotColumns.NAME, Markup.escape_text (file.get_basename ()), |
365 | - NotColumns.ICON, new ThemedIcon ("folder"), NotColumns.PATH, folder, |
366 | - NotColumns.IS_APP, false); |
367 | - } |
368 | - |
369 | - app_blacklist.application_added.connect ((name, ev) => { |
370 | - Gtk.TreeIter it; |
371 | - foreach (var app_info in AppInfo.get_all ()) { |
372 | - if (app_info is DesktopAppInfo) { |
373 | - var file = File.new_for_path (((DesktopAppInfo)app_info).filename); |
374 | - if (file.get_basename () == name) { |
375 | - list_store.append (out it); |
376 | - list_store.set (it, NotColumns.NAME, Markup.escape_text (app_info.get_display_name ()), |
377 | - NotColumns.ICON, app_info.get_icon (), NotColumns.PATH, file.get_basename (), |
378 | - NotColumns.IS_APP, true); |
379 | - break; |
380 | - } |
381 | - } |
382 | - } |
383 | - }); |
384 | - |
385 | - path_blacklist.folder_added.connect ((path) => { |
386 | - Gtk.TreeIter it; |
387 | - list_store.append (out it); |
388 | - var file = File.new_for_path (path); |
389 | - list_store.set (it, NotColumns.NAME, Markup.escape_text (file.get_basename ()), |
390 | - NotColumns.ICON, new ThemedIcon ("folder"), NotColumns.PATH, path, |
391 | - NotColumns.IS_APP, false); |
392 | - }); |
393 | - } |
394 | } |
395 | |
396 | === added file 'src/Widgets/ExcludeTreeView.vala' |
397 | --- src/Widgets/ExcludeTreeView.vala 1970-01-01 00:00:00 +0000 |
398 | +++ src/Widgets/ExcludeTreeView.vala 2017-02-27 23:09:39 +0000 |
399 | @@ -0,0 +1,186 @@ |
400 | +/*- |
401 | +* Copyright (c) 2014-2017 elementary LLC. (http://launchpad.net/switchboard-plug-security-privacy) |
402 | +* |
403 | +* This program is free software; you can redistribute it and/or |
404 | +* modify it under the terms of the GNU Lesser General Public |
405 | +* License as published by the Free Software Foundation; either |
406 | +* version 3 of the License, or (at your option) any later version. |
407 | +* |
408 | +* This program is distributed in the hope that it will be useful, |
409 | +* but WITHOUT ANY WARRANTY; without even the implied warranty of |
410 | +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
411 | +* Lesser General Public License for more details. |
412 | +* |
413 | +* You should have received a copy of the GNU Lesser General Public |
414 | +* License along with this program; if not, write to the |
415 | +* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
416 | +* Boston, MA 02110-1301 USA |
417 | +* |
418 | +* Authored by: Corentin Noël <corentin@elementaryos.org> |
419 | +*/ |
420 | + |
421 | +public class ExcludeTreeView : Gtk.Grid { |
422 | + private SecurityPrivacy.Dialogs.AppChooser app_chooser; |
423 | + private SecurityPrivacy.ApplicationBlacklist app_blacklist; |
424 | + private SecurityPrivacy.PathBlacklist path_blacklist; |
425 | + |
426 | + private enum NotColumns { |
427 | + NAME, |
428 | + ICON, |
429 | + PATH, |
430 | + IS_APP, |
431 | + N_COLUMNS |
432 | + } |
433 | + |
434 | + construct { |
435 | + app_blacklist = new SecurityPrivacy.ApplicationBlacklist (SecurityPrivacy.blacklist); |
436 | + path_blacklist = new SecurityPrivacy.PathBlacklist (SecurityPrivacy.blacklist); |
437 | + |
438 | + var list_store = new Gtk.ListStore (NotColumns.N_COLUMNS, typeof (string), typeof (Icon), typeof (string), typeof (bool)); |
439 | + |
440 | + var view = new Gtk.TreeView.with_model (list_store); |
441 | + view.vexpand = true; |
442 | + view.headers_visible = false; |
443 | + |
444 | + var cell = new Gtk.CellRendererText (); |
445 | + var cellpixbuf = new Gtk.CellRendererPixbuf (); |
446 | + cellpixbuf.stock_size = Gtk.IconSize.DND; |
447 | + view.insert_column_with_attributes (-1, "", cellpixbuf, "gicon", NotColumns.ICON); |
448 | + view.insert_column_with_attributes (-1, "", cell, "markup", NotColumns.NAME); |
449 | + |
450 | + var scrolled = new Gtk.ScrolledWindow (null, null); |
451 | + scrolled.expand = true; |
452 | + scrolled.add (view); |
453 | + |
454 | + var add_app_button = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("application-add-symbolic", Gtk.IconSize.SMALL_TOOLBAR), null); |
455 | + add_app_button.tooltip_text = _("Add Application…"); |
456 | + add_app_button.clicked.connect (() => { |
457 | + if (app_chooser.visible == false) { |
458 | + app_chooser.show_all (); |
459 | + } |
460 | + }); |
461 | + |
462 | + app_chooser = new SecurityPrivacy.Dialogs.AppChooser (add_app_button); |
463 | + app_chooser.modal = true; |
464 | + app_chooser.app_chosen.connect ((info) => { |
465 | + var file = File.new_for_path (info.filename); |
466 | + app_blacklist.block (file.get_basename ()); |
467 | + }); |
468 | + |
469 | + var add_folder_button = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("folder-new-symbolic", Gtk.IconSize.SMALL_TOOLBAR), null); |
470 | + add_folder_button.tooltip_text = _("Add Folder…"); |
471 | + add_folder_button.clicked.connect (() => { |
472 | + var chooser = new Gtk.FileChooserDialog (_("Select a folder to blacklist"), null, Gtk.FileChooserAction.SELECT_FOLDER); |
473 | + chooser.add_buttons (_("Cancel"), Gtk.ResponseType.CANCEL, _("Add"), Gtk.ResponseType.OK); |
474 | + int res = chooser.run (); |
475 | + chooser.hide (); |
476 | + if (res == Gtk.ResponseType.OK) { |
477 | + string folder = chooser.get_filename (); |
478 | + if (this.path_blacklist.is_duplicate (folder) == false) { |
479 | + path_blacklist.block (folder); |
480 | + } |
481 | + } |
482 | + }); |
483 | + |
484 | + var remove_button = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("list-remove-symbolic", Gtk.IconSize.SMALL_TOOLBAR), null); |
485 | + remove_button.tooltip_text = _("Delete"); |
486 | + remove_button.sensitive = false; |
487 | + remove_button.clicked.connect (() => { |
488 | + Gtk.TreePath path; |
489 | + Gtk.TreeViewColumn column; |
490 | + view.get_cursor (out path, out column); |
491 | + Gtk.TreeIter iter; |
492 | + list_store.get_iter (out iter, path); |
493 | + Value is_app; |
494 | + list_store.get_value (iter, NotColumns.IS_APP, out is_app); |
495 | + if (is_app.get_boolean () == true) { |
496 | + string name; |
497 | + list_store.get (iter, NotColumns.PATH, out name); |
498 | + app_blacklist.unblock (name); |
499 | + } else { |
500 | + string name; |
501 | + list_store.get (iter, NotColumns.PATH, out name); |
502 | + path_blacklist.unblock (name); |
503 | + } |
504 | + |
505 | +#if VALA_0_36 |
506 | + list_store.remove (ref iter); |
507 | +#else |
508 | + list_store.remove (iter); |
509 | +#endif |
510 | + }); |
511 | + |
512 | + var list_toolbar = new Gtk.Toolbar (); |
513 | + list_toolbar.get_style_context ().add_class (Gtk.STYLE_CLASS_INLINE_TOOLBAR); |
514 | + list_toolbar.set_icon_size (Gtk.IconSize.SMALL_TOOLBAR); |
515 | + list_toolbar.insert (add_app_button, -1); |
516 | + list_toolbar.insert (add_folder_button, -1); |
517 | + list_toolbar.insert (remove_button, -1); |
518 | + |
519 | + var frame_grid = new Gtk.Grid (); |
520 | + frame_grid.orientation = Gtk.Orientation.VERTICAL; |
521 | + frame_grid.add (scrolled); |
522 | + frame_grid.add (list_toolbar); |
523 | + |
524 | + var frame = new Gtk.Frame (null); |
525 | + frame.add (frame_grid); |
526 | + |
527 | + var record_label = new Gtk.Label (_("Do not collect data from the following:")); |
528 | + record_label.xalign = 0; |
529 | + |
530 | + row_spacing = 6; |
531 | + orientation = Gtk.Orientation.VERTICAL; |
532 | + add (record_label); |
533 | + add (frame); |
534 | + |
535 | + view.cursor_changed.connect (() => { |
536 | + remove_button.sensitive = true; |
537 | + }); |
538 | + |
539 | + Gtk.TreeIter iter; |
540 | + foreach (var app_info in AppInfo.get_all ()) { |
541 | + if (app_info is DesktopAppInfo) { |
542 | + var file = File.new_for_path (((DesktopAppInfo)app_info).filename); |
543 | + if (app_blacklist.all_apps.contains (file.get_basename ())) { |
544 | + list_store.append (out iter); |
545 | + list_store.set (iter, NotColumns.NAME, Markup.escape_text (app_info.get_display_name ()), |
546 | + NotColumns.ICON, app_info.get_icon (), NotColumns.PATH, file.get_basename (), |
547 | + NotColumns.IS_APP, true); |
548 | + } |
549 | + } |
550 | + } |
551 | + |
552 | + foreach (var folder in path_blacklist.all_folders) { |
553 | + list_store.append (out iter); |
554 | + var file = File.new_for_path (folder); |
555 | + list_store.set (iter, NotColumns.NAME, Markup.escape_text (file.get_basename ()), |
556 | + NotColumns.ICON, new ThemedIcon ("folder"), NotColumns.PATH, folder, |
557 | + NotColumns.IS_APP, false); |
558 | + } |
559 | + |
560 | + app_blacklist.application_added.connect ((name, ev) => { |
561 | + Gtk.TreeIter it; |
562 | + foreach (var app_info in AppInfo.get_all ()) { |
563 | + if (app_info is DesktopAppInfo) { |
564 | + var file = File.new_for_path (((DesktopAppInfo)app_info).filename); |
565 | + if (file.get_basename () == name) { |
566 | + list_store.append (out it); |
567 | + list_store.set (it, NotColumns.NAME, Markup.escape_text (app_info.get_display_name ()), |
568 | + NotColumns.ICON, app_info.get_icon (), NotColumns.PATH, file.get_basename (), |
569 | + NotColumns.IS_APP, true); |
570 | + break; |
571 | + } |
572 | + } |
573 | + } |
574 | + }); |
575 | + |
576 | + path_blacklist.folder_added.connect ((path) => { |
577 | + Gtk.TreeIter it; |
578 | + list_store.append (out it); |
579 | + var file = File.new_for_path (path); |
580 | + list_store.set (it, NotColumns.NAME, Markup.escape_text (file.get_basename ()), |
581 | + NotColumns.ICON, new ThemedIcon ("folder"), NotColumns.PATH, path, |
582 | + NotColumns.IS_APP, false); |
583 | + }); |
584 | + } |
585 | +} |
586 | |
587 | === added file 'src/Widgets/IncludeTreeView.vala' |
588 | --- src/Widgets/IncludeTreeView.vala 1970-01-01 00:00:00 +0000 |
589 | +++ src/Widgets/IncludeTreeView.vala 2017-02-27 23:09:39 +0000 |
590 | @@ -0,0 +1,98 @@ |
591 | +/*- |
592 | +* Copyright (c) 2014-2017 elementary LLC. (http://launchpad.net/switchboard-plug-security-privacy) |
593 | +* |
594 | +* This program is free software; you can redistribute it and/or |
595 | +* modify it under the terms of the GNU Lesser General Public |
596 | +* License as published by the Free Software Foundation; either |
597 | +* version 3 of the License, or (at your option) any later version. |
598 | +* |
599 | +* This program is distributed in the hope that it will be useful, |
600 | +* but WITHOUT ANY WARRANTY; without even the implied warranty of |
601 | +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
602 | +* Lesser General Public License for more details. |
603 | +* |
604 | +* You should have received a copy of the GNU Lesser General Public |
605 | +* License along with this program; if not, write to the |
606 | +* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
607 | +* Boston, MA 02110-1301 USA |
608 | +* |
609 | +* Authored by: Corentin Noël <corentin@elementaryos.org> |
610 | +*/ |
611 | + |
612 | +public class IncludeTreeView : Gtk.Grid { |
613 | + private SecurityPrivacy.FileTypeBlacklist filetype_blacklist; |
614 | + |
615 | + private enum Columns { |
616 | + ACTIVE, |
617 | + NAME, |
618 | + ICON, |
619 | + FILE_TYPE, |
620 | + N_COLUMNS |
621 | + } |
622 | + |
623 | + public IncludeTreeView () { |
624 | + Object (row_spacing: 6); |
625 | + } |
626 | + |
627 | + construct { |
628 | + filetype_blacklist = new SecurityPrivacy.FileTypeBlacklist (SecurityPrivacy.blacklist); |
629 | + |
630 | + var list_store = new Gtk.ListStore (Columns.N_COLUMNS, typeof (bool), typeof (string), typeof (string), typeof (string)); |
631 | + |
632 | + var view = new Gtk.TreeView.with_model (list_store); |
633 | + view.vexpand = true; |
634 | + view.headers_visible = false; |
635 | + view.activate_on_single_click = true; |
636 | + |
637 | + var celltoggle = new Gtk.CellRendererToggle (); |
638 | + view.row_activated.connect ((path, column) => { |
639 | + Value active; |
640 | + Gtk.TreeIter iter; |
641 | + list_store.get_iter (out iter, path); |
642 | + list_store.get_value (iter, Columns.ACTIVE, out active); |
643 | + var is_active = !active.get_boolean (); |
644 | + list_store.set (iter, Columns.ACTIVE, is_active); |
645 | + Value name; |
646 | + list_store.get_value (iter, Columns.FILE_TYPE, out name); |
647 | + if (is_active == true) { |
648 | + filetype_blacklist.unblock (name.get_string ()); |
649 | + } else { |
650 | + filetype_blacklist.block (name.get_string ()); |
651 | + } |
652 | + }); |
653 | + |
654 | + var cell = new Gtk.CellRendererText (); |
655 | + var cellpixbuf = new Gtk.CellRendererPixbuf (); |
656 | + cellpixbuf.stock_size = Gtk.IconSize.DND; |
657 | + view.insert_column_with_attributes (-1, "", celltoggle, "active", Columns.ACTIVE); |
658 | + view.insert_column_with_attributes (-1, "", cellpixbuf, "icon-name", Columns.ICON); |
659 | + view.insert_column_with_attributes (-1, "", cell, "markup", Columns.NAME); |
660 | + |
661 | + var scrolled = new Gtk.ScrolledWindow (null, null); |
662 | + scrolled.shadow_type = Gtk.ShadowType.IN; |
663 | + scrolled.expand = true; |
664 | + scrolled.add (view); |
665 | + |
666 | + var record_label = new Gtk.Label (_("Data Sources:")); |
667 | + record_label.xalign = 0; |
668 | + |
669 | + attach (record_label, 0, 0, 1, 1); |
670 | + attach (scrolled, 0, 1, 1, 1); |
671 | + |
672 | + set_inclue_iter_to_liststore (list_store, _("Chat Logs"), "internet-chat", Zeitgeist.NMO.IMMESSAGE); |
673 | + set_inclue_iter_to_liststore (list_store, _("Documents"), "x-office-document", Zeitgeist.NFO.DOCUMENT); |
674 | + set_inclue_iter_to_liststore (list_store, _("Music"), "audio-x-generic", Zeitgeist.NFO.AUDIO); |
675 | + set_inclue_iter_to_liststore (list_store, _("Pictures"), "image-x-generic", Zeitgeist.NFO.IMAGE); |
676 | + set_inclue_iter_to_liststore (list_store, _("Presentations"), "x-office-presentation", Zeitgeist.NFO.PRESENTATION); |
677 | + set_inclue_iter_to_liststore (list_store, _("Spreadsheets"), "x-office-spreadsheet", Zeitgeist.NFO.SPREADSHEET); |
678 | + set_inclue_iter_to_liststore (list_store, _("Videos"), "video-x-generic", Zeitgeist.NFO.VIDEO); |
679 | + } |
680 | + |
681 | + private void set_inclue_iter_to_liststore (Gtk.ListStore list_store, string name, string icon, string file_type) { |
682 | + Gtk.TreeIter iter; |
683 | + list_store.append (out iter); |
684 | + bool active = (filetype_blacklist.all_filetypes.contains (file_type) == false); |
685 | + list_store.set (iter, Columns.ACTIVE, active, Columns.NAME, name, |
686 | + Columns.ICON, icon, Columns.FILE_TYPE, file_type); |
687 | + } |
688 | +} |
689 | |
690 | === modified file 'src/Widgets/ServiceList.vala' |
691 | --- src/Widgets/ServiceList.vala 2017-02-27 01:30:20 +0000 |
692 | +++ src/Widgets/ServiceList.vala 2017-02-27 23:09:39 +0000 |
693 | @@ -5,7 +5,7 @@ |
694 | } |
695 | |
696 | construct { |
697 | - var privacy_item = new ServiceItem ("document-open-recent", "tracking", _("Privacy")); |
698 | + var privacy_item = new ServiceItem ("document-open-recent", "tracking", _("History")); |
699 | var lock_item = new ServiceItem ("system-lock-screen", "locking", _("Locking")); |
700 | var firewall_item = new ServiceItem ("network-firewall", "firewall", _("Firewall")); |
701 |
Tested the two treeviews and the on/off switch with d-feet, they're still making the required changes in zeitgeist. Rename to History makes much more sense in the context of the other privacy related panels that will be added.