Merge lp:~elementary-pantheon/switchboard-plug-security-privacy/trackpanel-classes into lp:~elementary-apps/switchboard-plug-security-privacy/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
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 :

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.

review: Approve (code, function)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2017-02-26 20:21:42 +0000
+++ src/CMakeLists.txt 2017-02-27 23:09:39 +0000
@@ -25,6 +25,8 @@
25 Widgets/AppChooser.vala25 Widgets/AppChooser.vala
26 Widgets/AppRow.vala26 Widgets/AppRow.vala
27 Widgets/ClearUsagePopover.vala27 Widgets/ClearUsagePopover.vala
28 Widgets/ExcludeTreeView.vala
29 Widgets/IncludeTreeView.vala
28 Widgets/ServiceItem.vala30 Widgets/ServiceItem.vala
29 Widgets/ServiceList.vala31 Widgets/ServiceList.vala
3032
3133
=== modified file 'src/Views/TrackPanel.vala'
--- src/Views/TrackPanel.vala 2017-02-27 18:20:56 +0000
+++ src/Views/TrackPanel.vala 2017-02-27 23:09:39 +0000
@@ -22,32 +22,8 @@
2222
23public class SecurityPrivacy.TrackPanel : Gtk.Grid {23public class SecurityPrivacy.TrackPanel : Gtk.Grid {
24 private Widgets.ClearUsagePopover remove_popover;24 private Widgets.ClearUsagePopover remove_popover;
25 private Dialogs.AppChooser app_chooser;
26 private ApplicationBlacklist app_blacklist;
27 private PathBlacklist path_blacklist;
28 private FileTypeBlacklist filetype_blacklist;
29 private Gtk.Grid record_grid;
30 private Gtk.Container description_frame;
31 private Gtk.Grid exclude_grid;
32
33 private Gtk.Switch record_switch;25 private Gtk.Switch record_switch;
3426
35 private enum Columns {
36 ACTIVE,
37 NAME,
38 ICON,
39 FILE_TYPE,
40 N_COLUMNS
41 }
42
43 private enum NotColumns {
44 NAME,
45 ICON,
46 PATH,
47 IS_APP,
48 N_COLUMNS
49 }
50
51 public TrackPanel () {27 public TrackPanel () {
52 Object (column_spacing: 12,28 Object (column_spacing: 12,
53 margin: 12,29 margin: 12,
@@ -55,34 +31,28 @@
55 }31 }
5632
57 construct {33 construct {
58 app_blacklist = new ApplicationBlacklist (blacklist);34 var title = _("History Is Disabled").printf (get_operating_system_name ());
59 path_blacklist = new PathBlacklist (blacklist);35 var description = ("%s\n\n%s\n\n%s".printf (
60 filetype_blacklist = new FileTypeBlacklist (blacklist);36 _("%s won't retain any further data or statistics about file and application usage.").printf (get_operating_system_name ()),
6137 _("The additional functionality that this data provides will be affected."),
62 create_description_panel ();38 _("This will not prevent apps from recording their own usage data like browser history.")));
6339
64 var privacy_settings = new GLib.Settings ("org.gnome.desktop.privacy");40 var alert = new Granite.Widgets.AlertView (title, description, "");
6541 alert.show_all ();
66 var icon = new Gtk.Image.from_icon_name ("document-open-recent", Gtk.IconSize.DIALOG);42
6743 var description_frame = new Gtk.Frame (null);
68 var record_label = new Gtk.Label (_("Privacy"));44 description_frame.no_show_all = true;
45 description_frame.add (alert);
46
47 var header_image = new Gtk.Image.from_icon_name ("document-open-recent", Gtk.IconSize.DIALOG);
48
49 var record_label = new Gtk.Label (_("History"));
69 record_label.get_style_context ().add_class ("h2");50 record_label.get_style_context ().add_class ("h2");
7051
71 record_switch = new Gtk.Switch ();52 record_switch = new Gtk.Switch ();
53 record_switch.active = true;
72 record_switch.valign = Gtk.Align.CENTER;54 record_switch.valign = Gtk.Align.CENTER;
7355
74 record_switch.notify["active"].connect (() => {
75 bool privacy_mode = record_switch.active;
76 record_grid.visible = !privacy_mode;
77 exclude_grid.visible = !privacy_mode;
78 description_frame.visible = privacy_mode;
79 if (privacy_mode != blacklist.get_incognito ()) {
80 blacklist.set_incognito (privacy_mode);
81 privacy_settings.set_boolean ("remember-recent-files", !privacy_mode);
82 privacy_settings.set_boolean ("remember-app-usage", !privacy_mode);
83 }
84 });
85
86 var info_button = new Gtk.Image.from_icon_name ("help-info-symbolic", Gtk.IconSize.MENU);56 var info_button = new Gtk.Image.from_icon_name ("help-info-symbolic", Gtk.IconSize.MENU);
87 info_button.hexpand = true;57 info_button.hexpand = true;
88 info_button.xalign = 0;58 info_button.xalign = 0;
@@ -91,12 +61,12 @@
91 var header_grid = new Gtk.Grid ();61 var header_grid = new Gtk.Grid ();
92 header_grid.column_spacing = 12;62 header_grid.column_spacing = 12;
93 header_grid.margin_bottom = 12;63 header_grid.margin_bottom = 12;
94 header_grid.add (icon);64 header_grid.add (header_image);
95 header_grid.add (record_label);65 header_grid.add (record_label);
96 header_grid.add (info_button);66 header_grid.add (info_button);
97 header_grid.add (record_switch);67 header_grid.add (record_switch);
9868
99 var clear_data = new Gtk.ToggleButton.with_label (_("Clear Usage Data…"));69 var clear_data = new Gtk.ToggleButton.with_label (_("Clear History…"));
100 clear_data.halign = Gtk.Align.END;70 clear_data.halign = Gtk.Align.END;
101 clear_data.notify["active"].connect (() => {71 clear_data.notify["active"].connect (() => {
102 if (clear_data.active == false) {72 if (clear_data.active == false) {
@@ -111,13 +81,31 @@
111 clear_data.active = false;81 clear_data.active = false;
112 });82 });
11383
114 create_include_treeview ();84 var include_treeview = new IncludeTreeView ();
115 create_exclude_treeview ();85 var exclude_treeview = new ExcludeTreeView ();
86
116 attach (header_grid, 0, 0, 2, 1);87 attach (header_grid, 0, 0, 2, 1);
117 attach (exclude_grid, 1, 1, 1, 1);88 attach (description_frame, 0, 1, 2, 1);
89 attach (include_treeview, 0, 1, 1, 1);
90 attach (exclude_treeview, 1, 1, 1, 1);
118 attach (clear_data, 1, 2, 1, 1);91 attach (clear_data, 1, 2, 1, 1);
11992
120 record_switch.active = blacklist.get_incognito ();93 record_switch.notify["active"].connect (() => {
94 bool privacy_mode = !record_switch.active;
95 include_treeview.visible = !privacy_mode;
96 exclude_treeview.visible = !privacy_mode;
97 description_frame.visible = privacy_mode;
98
99 if (privacy_mode != blacklist.get_incognito ()) {
100 blacklist.set_incognito (privacy_mode);
101
102 var privacy_settings = new GLib.Settings ("org.gnome.desktop.privacy");
103 privacy_settings.set_boolean ("remember-recent-files", !privacy_mode);
104 privacy_settings.set_boolean ("remember-app-usage", !privacy_mode);
105 }
106 });
107
108 record_switch.active = !blacklist.get_incognito ();
121 }109 }
122 110
123 public void focus_privacy_switch () {111 public void focus_privacy_switch () {
@@ -137,241 +125,4 @@
137 }125 }
138 return system;126 return system;
139 }127 }
140
141 private void create_description_panel () {
142 description_frame = new Gtk.Frame (null);
143 description_frame.expand = true;
144 description_frame.no_show_all = true;
145
146 string system = get_operating_system_name ();
147
148 var icon = "view-private";
149 var title = _("%s is in Privacy Mode").printf (system);
150 var description = ("%s\n\n%s\n\n%s".printf (
151 _("While in Privacy Mode, this operating system won't retain any further data or statistics about file and application usage."),
152 _("The additional functionality that this data provides will be affected."),
153 _("This will not prevent apps from recording their own usage data like browser history.")));
154
155 var alert = new Granite.Widgets.AlertView (title, description, icon);
156 alert.show_all ();
157
158 description_frame.add (alert);
159
160 attach (description_frame, 0, 1, 2, 1);
161 }
162
163 private void create_include_treeview () {
164 var list_store = new Gtk.ListStore (Columns.N_COLUMNS, typeof (bool),
165 typeof (string), typeof (string), typeof (string));
166
167 var view = new Gtk.TreeView.with_model (list_store);
168 view.vexpand = true;
169 view.headers_visible = false;
170 view.activate_on_single_click = true;
171
172 var celltoggle = new Gtk.CellRendererToggle ();
173 view.row_activated.connect ((path, column) => {
174 Value active;
175 Gtk.TreeIter iter;
176 list_store.get_iter (out iter, path);
177 list_store.get_value (iter, Columns.ACTIVE, out active);
178 var is_active = !active.get_boolean ();
179 list_store.set (iter, Columns.ACTIVE, is_active);
180 Value name;
181 list_store.get_value (iter, Columns.FILE_TYPE, out name);
182 if (is_active == true) {
183 filetype_blacklist.unblock (name.get_string ());
184 } else {
185 filetype_blacklist.block (name.get_string ());
186 }
187 });
188
189 var cell = new Gtk.CellRendererText ();
190 var cellpixbuf = new Gtk.CellRendererPixbuf ();
191 cellpixbuf.stock_size = Gtk.IconSize.DND;
192 view.insert_column_with_attributes (-1, "", celltoggle, "active", Columns.ACTIVE);
193 view.insert_column_with_attributes (-1, "", cellpixbuf, "icon-name", Columns.ICON);
194 view.insert_column_with_attributes (-1, "", cell, "markup", Columns.NAME);
195
196 var scrolled = new Gtk.ScrolledWindow (null, null);
197 scrolled.shadow_type = Gtk.ShadowType.IN;
198 scrolled.expand = true;
199 scrolled.add (view);
200
201 var record_label = new Gtk.Label (_("Data Sources:"));
202 record_label.xalign = 0;
203
204 record_grid = new Gtk.Grid ();
205 record_grid.row_spacing = 6;
206 record_grid.attach (record_label, 0, 0, 1, 1);
207 record_grid.attach (scrolled, 0, 1, 1, 1);
208 attach (record_grid, 0, 1, 1, 1);
209
210 set_inclue_iter_to_liststore (list_store, _("Chat Logs"), "internet-chat", Zeitgeist.NMO.IMMESSAGE);
211 set_inclue_iter_to_liststore (list_store, _("Documents"), "x-office-document", Zeitgeist.NFO.DOCUMENT);
212 set_inclue_iter_to_liststore (list_store, _("Music"), "audio-x-generic", Zeitgeist.NFO.AUDIO);
213 set_inclue_iter_to_liststore (list_store, _("Pictures"), "image-x-generic", Zeitgeist.NFO.IMAGE);
214 set_inclue_iter_to_liststore (list_store, _("Presentations"), "x-office-presentation", Zeitgeist.NFO.PRESENTATION);
215 set_inclue_iter_to_liststore (list_store, _("Spreadsheets"), "x-office-spreadsheet", Zeitgeist.NFO.SPREADSHEET);
216 set_inclue_iter_to_liststore (list_store, _("Videos"), "video-x-generic", Zeitgeist.NFO.VIDEO);
217 }
218
219 private void set_inclue_iter_to_liststore (Gtk.ListStore list_store, string name, string icon, string file_type) {
220 Gtk.TreeIter iter;
221 list_store.append (out iter);
222 bool active = (filetype_blacklist.all_filetypes.contains (file_type) == false);
223 list_store.set (iter, Columns.ACTIVE, active, Columns.NAME, name,
224 Columns.ICON, icon, Columns.FILE_TYPE, file_type);
225 }
226
227 private void create_exclude_treeview () {
228 var list_store = new Gtk.ListStore (NotColumns.N_COLUMNS, typeof (string),
229 typeof (Icon), typeof (string), typeof (bool));
230
231 var view = new Gtk.TreeView.with_model (list_store);
232 view.vexpand = true;
233 view.headers_visible = false;
234
235 var cell = new Gtk.CellRendererText ();
236 var cellpixbuf = new Gtk.CellRendererPixbuf ();
237 cellpixbuf.stock_size = Gtk.IconSize.DND;
238 view.insert_column_with_attributes (-1, "", cellpixbuf, "gicon", NotColumns.ICON);
239 view.insert_column_with_attributes (-1, "", cell, "markup", NotColumns.NAME);
240
241 var scrolled = new Gtk.ScrolledWindow (null, null);
242 scrolled.expand = true;
243 scrolled.add (view);
244
245 var add_app_button = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("application-add-symbolic", Gtk.IconSize.SMALL_TOOLBAR), null);
246 add_app_button.tooltip_text = _("Add Application…");
247 add_app_button.clicked.connect (() => {
248 if (app_chooser.visible == false) {
249 app_chooser.show_all ();
250 }
251 });
252
253 app_chooser = new Dialogs.AppChooser (add_app_button);
254 app_chooser.modal = true;
255 app_chooser.app_chosen.connect ((info) => {
256 var file = File.new_for_path (info.filename);
257 app_blacklist.block (file.get_basename ());
258 });
259
260 var add_folder_button = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("folder-new-symbolic", Gtk.IconSize.SMALL_TOOLBAR), null);
261 add_folder_button.tooltip_text = _("Add Folder…");
262 add_folder_button.clicked.connect (() => {
263 var chooser = new Gtk.FileChooserDialog (_("Select a folder to blacklist"), null, Gtk.FileChooserAction.SELECT_FOLDER);
264 chooser.add_buttons (_("Cancel"), Gtk.ResponseType.CANCEL, _("Add"), Gtk.ResponseType.OK);
265 int res = chooser.run ();
266 chooser.hide ();
267 if (res == Gtk.ResponseType.OK) {
268 string folder = chooser.get_filename ();
269 if (this.path_blacklist.is_duplicate (folder) == false) {
270 path_blacklist.block (folder);
271 }
272 }
273 });
274
275 var remove_button = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("list-remove-symbolic", Gtk.IconSize.SMALL_TOOLBAR), null);
276 remove_button.tooltip_text = _("Delete");
277 remove_button.sensitive = false;
278 remove_button.clicked.connect (() => {
279 Gtk.TreePath path;
280 Gtk.TreeViewColumn column;
281 view.get_cursor (out path, out column);
282 Gtk.TreeIter iter;
283 list_store.get_iter (out iter, path);
284 Value is_app;
285 list_store.get_value (iter, NotColumns.IS_APP, out is_app);
286 if (is_app.get_boolean () == true) {
287 string name;
288 list_store.get (iter, NotColumns.PATH, out name);
289 app_blacklist.unblock (name);
290 } else {
291 string name;
292 list_store.get (iter, NotColumns.PATH, out name);
293 path_blacklist.unblock (name);
294 }
295
296#if VALA_0_36
297 list_store.remove (ref iter);
298#else
299 list_store.remove (iter);
300#endif
301 });
302
303 var list_toolbar = new Gtk.Toolbar ();
304 list_toolbar.get_style_context ().add_class (Gtk.STYLE_CLASS_INLINE_TOOLBAR);
305 list_toolbar.set_icon_size (Gtk.IconSize.SMALL_TOOLBAR);
306 list_toolbar.insert (add_app_button, -1);
307 list_toolbar.insert (add_folder_button, -1);
308 list_toolbar.insert (remove_button, -1);
309
310 var frame_grid = new Gtk.Grid ();
311 frame_grid.orientation = Gtk.Orientation.VERTICAL;
312 frame_grid.add (scrolled);
313 frame_grid.add (list_toolbar);
314
315 var frame = new Gtk.Frame (null);
316 frame.add (frame_grid);
317
318 var record_label = new Gtk.Label (_("Do not collect data from the following:"));
319 record_label.xalign = 0;
320
321 exclude_grid = new Gtk.Grid ();
322 exclude_grid.row_spacing = 6;
323 exclude_grid.orientation = Gtk.Orientation.VERTICAL;
324 exclude_grid.add (record_label);
325 exclude_grid.add (frame);
326
327 view.cursor_changed.connect (() => {
328 remove_button.sensitive = true;
329 });
330
331 Gtk.TreeIter iter;
332 foreach (var app_info in AppInfo.get_all ()) {
333 if (app_info is DesktopAppInfo) {
334 var file = File.new_for_path (((DesktopAppInfo)app_info).filename);
335 if (app_blacklist.all_apps.contains (file.get_basename ())) {
336 list_store.append (out iter);
337 list_store.set (iter, NotColumns.NAME, Markup.escape_text (app_info.get_display_name ()),
338 NotColumns.ICON, app_info.get_icon (), NotColumns.PATH, file.get_basename (),
339 NotColumns.IS_APP, true);
340 }
341 }
342 }
343
344 foreach (var folder in path_blacklist.all_folders) {
345 list_store.append (out iter);
346 var file = File.new_for_path (folder);
347 list_store.set (iter, NotColumns.NAME, Markup.escape_text (file.get_basename ()),
348 NotColumns.ICON, new ThemedIcon ("folder"), NotColumns.PATH, folder,
349 NotColumns.IS_APP, false);
350 }
351
352 app_blacklist.application_added.connect ((name, ev) => {
353 Gtk.TreeIter it;
354 foreach (var app_info in AppInfo.get_all ()) {
355 if (app_info is DesktopAppInfo) {
356 var file = File.new_for_path (((DesktopAppInfo)app_info).filename);
357 if (file.get_basename () == name) {
358 list_store.append (out it);
359 list_store.set (it, NotColumns.NAME, Markup.escape_text (app_info.get_display_name ()),
360 NotColumns.ICON, app_info.get_icon (), NotColumns.PATH, file.get_basename (),
361 NotColumns.IS_APP, true);
362 break;
363 }
364 }
365 }
366 });
367
368 path_blacklist.folder_added.connect ((path) => {
369 Gtk.TreeIter it;
370 list_store.append (out it);
371 var file = File.new_for_path (path);
372 list_store.set (it, NotColumns.NAME, Markup.escape_text (file.get_basename ()),
373 NotColumns.ICON, new ThemedIcon ("folder"), NotColumns.PATH, path,
374 NotColumns.IS_APP, false);
375 });
376 }
377}128}
378129
=== added file 'src/Widgets/ExcludeTreeView.vala'
--- src/Widgets/ExcludeTreeView.vala 1970-01-01 00:00:00 +0000
+++ src/Widgets/ExcludeTreeView.vala 2017-02-27 23:09:39 +0000
@@ -0,0 +1,186 @@
1/*-
2* Copyright (c) 2014-2017 elementary LLC. (http://launchpad.net/switchboard-plug-security-privacy)
3*
4* This program is free software; you can redistribute it and/or
5* modify it under the terms of the GNU Lesser General Public
6* License as published by the Free Software Foundation; either
7* version 3 of the License, or (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12* Lesser General Public License for more details.
13*
14* You should have received a copy of the GNU Lesser General Public
15* License along with this program; if not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17* Boston, MA 02110-1301 USA
18*
19* Authored by: Corentin Noël <corentin@elementaryos.org>
20*/
21
22public class ExcludeTreeView : Gtk.Grid {
23 private SecurityPrivacy.Dialogs.AppChooser app_chooser;
24 private SecurityPrivacy.ApplicationBlacklist app_blacklist;
25 private SecurityPrivacy.PathBlacklist path_blacklist;
26
27 private enum NotColumns {
28 NAME,
29 ICON,
30 PATH,
31 IS_APP,
32 N_COLUMNS
33 }
34
35 construct {
36 app_blacklist = new SecurityPrivacy.ApplicationBlacklist (SecurityPrivacy.blacklist);
37 path_blacklist = new SecurityPrivacy.PathBlacklist (SecurityPrivacy.blacklist);
38
39 var list_store = new Gtk.ListStore (NotColumns.N_COLUMNS, typeof (string), typeof (Icon), typeof (string), typeof (bool));
40
41 var view = new Gtk.TreeView.with_model (list_store);
42 view.vexpand = true;
43 view.headers_visible = false;
44
45 var cell = new Gtk.CellRendererText ();
46 var cellpixbuf = new Gtk.CellRendererPixbuf ();
47 cellpixbuf.stock_size = Gtk.IconSize.DND;
48 view.insert_column_with_attributes (-1, "", cellpixbuf, "gicon", NotColumns.ICON);
49 view.insert_column_with_attributes (-1, "", cell, "markup", NotColumns.NAME);
50
51 var scrolled = new Gtk.ScrolledWindow (null, null);
52 scrolled.expand = true;
53 scrolled.add (view);
54
55 var add_app_button = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("application-add-symbolic", Gtk.IconSize.SMALL_TOOLBAR), null);
56 add_app_button.tooltip_text = _("Add Application…");
57 add_app_button.clicked.connect (() => {
58 if (app_chooser.visible == false) {
59 app_chooser.show_all ();
60 }
61 });
62
63 app_chooser = new SecurityPrivacy.Dialogs.AppChooser (add_app_button);
64 app_chooser.modal = true;
65 app_chooser.app_chosen.connect ((info) => {
66 var file = File.new_for_path (info.filename);
67 app_blacklist.block (file.get_basename ());
68 });
69
70 var add_folder_button = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("folder-new-symbolic", Gtk.IconSize.SMALL_TOOLBAR), null);
71 add_folder_button.tooltip_text = _("Add Folder…");
72 add_folder_button.clicked.connect (() => {
73 var chooser = new Gtk.FileChooserDialog (_("Select a folder to blacklist"), null, Gtk.FileChooserAction.SELECT_FOLDER);
74 chooser.add_buttons (_("Cancel"), Gtk.ResponseType.CANCEL, _("Add"), Gtk.ResponseType.OK);
75 int res = chooser.run ();
76 chooser.hide ();
77 if (res == Gtk.ResponseType.OK) {
78 string folder = chooser.get_filename ();
79 if (this.path_blacklist.is_duplicate (folder) == false) {
80 path_blacklist.block (folder);
81 }
82 }
83 });
84
85 var remove_button = new Gtk.ToolButton (new Gtk.Image.from_icon_name ("list-remove-symbolic", Gtk.IconSize.SMALL_TOOLBAR), null);
86 remove_button.tooltip_text = _("Delete");
87 remove_button.sensitive = false;
88 remove_button.clicked.connect (() => {
89 Gtk.TreePath path;
90 Gtk.TreeViewColumn column;
91 view.get_cursor (out path, out column);
92 Gtk.TreeIter iter;
93 list_store.get_iter (out iter, path);
94 Value is_app;
95 list_store.get_value (iter, NotColumns.IS_APP, out is_app);
96 if (is_app.get_boolean () == true) {
97 string name;
98 list_store.get (iter, NotColumns.PATH, out name);
99 app_blacklist.unblock (name);
100 } else {
101 string name;
102 list_store.get (iter, NotColumns.PATH, out name);
103 path_blacklist.unblock (name);
104 }
105
106#if VALA_0_36
107 list_store.remove (ref iter);
108#else
109 list_store.remove (iter);
110#endif
111 });
112
113 var list_toolbar = new Gtk.Toolbar ();
114 list_toolbar.get_style_context ().add_class (Gtk.STYLE_CLASS_INLINE_TOOLBAR);
115 list_toolbar.set_icon_size (Gtk.IconSize.SMALL_TOOLBAR);
116 list_toolbar.insert (add_app_button, -1);
117 list_toolbar.insert (add_folder_button, -1);
118 list_toolbar.insert (remove_button, -1);
119
120 var frame_grid = new Gtk.Grid ();
121 frame_grid.orientation = Gtk.Orientation.VERTICAL;
122 frame_grid.add (scrolled);
123 frame_grid.add (list_toolbar);
124
125 var frame = new Gtk.Frame (null);
126 frame.add (frame_grid);
127
128 var record_label = new Gtk.Label (_("Do not collect data from the following:"));
129 record_label.xalign = 0;
130
131 row_spacing = 6;
132 orientation = Gtk.Orientation.VERTICAL;
133 add (record_label);
134 add (frame);
135
136 view.cursor_changed.connect (() => {
137 remove_button.sensitive = true;
138 });
139
140 Gtk.TreeIter iter;
141 foreach (var app_info in AppInfo.get_all ()) {
142 if (app_info is DesktopAppInfo) {
143 var file = File.new_for_path (((DesktopAppInfo)app_info).filename);
144 if (app_blacklist.all_apps.contains (file.get_basename ())) {
145 list_store.append (out iter);
146 list_store.set (iter, NotColumns.NAME, Markup.escape_text (app_info.get_display_name ()),
147 NotColumns.ICON, app_info.get_icon (), NotColumns.PATH, file.get_basename (),
148 NotColumns.IS_APP, true);
149 }
150 }
151 }
152
153 foreach (var folder in path_blacklist.all_folders) {
154 list_store.append (out iter);
155 var file = File.new_for_path (folder);
156 list_store.set (iter, NotColumns.NAME, Markup.escape_text (file.get_basename ()),
157 NotColumns.ICON, new ThemedIcon ("folder"), NotColumns.PATH, folder,
158 NotColumns.IS_APP, false);
159 }
160
161 app_blacklist.application_added.connect ((name, ev) => {
162 Gtk.TreeIter it;
163 foreach (var app_info in AppInfo.get_all ()) {
164 if (app_info is DesktopAppInfo) {
165 var file = File.new_for_path (((DesktopAppInfo)app_info).filename);
166 if (file.get_basename () == name) {
167 list_store.append (out it);
168 list_store.set (it, NotColumns.NAME, Markup.escape_text (app_info.get_display_name ()),
169 NotColumns.ICON, app_info.get_icon (), NotColumns.PATH, file.get_basename (),
170 NotColumns.IS_APP, true);
171 break;
172 }
173 }
174 }
175 });
176
177 path_blacklist.folder_added.connect ((path) => {
178 Gtk.TreeIter it;
179 list_store.append (out it);
180 var file = File.new_for_path (path);
181 list_store.set (it, NotColumns.NAME, Markup.escape_text (file.get_basename ()),
182 NotColumns.ICON, new ThemedIcon ("folder"), NotColumns.PATH, path,
183 NotColumns.IS_APP, false);
184 });
185 }
186}
0187
=== added file 'src/Widgets/IncludeTreeView.vala'
--- src/Widgets/IncludeTreeView.vala 1970-01-01 00:00:00 +0000
+++ src/Widgets/IncludeTreeView.vala 2017-02-27 23:09:39 +0000
@@ -0,0 +1,98 @@
1/*-
2* Copyright (c) 2014-2017 elementary LLC. (http://launchpad.net/switchboard-plug-security-privacy)
3*
4* This program is free software; you can redistribute it and/or
5* modify it under the terms of the GNU Lesser General Public
6* License as published by the Free Software Foundation; either
7* version 3 of the License, or (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12* Lesser General Public License for more details.
13*
14* You should have received a copy of the GNU Lesser General Public
15* License along with this program; if not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17* Boston, MA 02110-1301 USA
18*
19* Authored by: Corentin Noël <corentin@elementaryos.org>
20*/
21
22public class IncludeTreeView : Gtk.Grid {
23 private SecurityPrivacy.FileTypeBlacklist filetype_blacklist;
24
25 private enum Columns {
26 ACTIVE,
27 NAME,
28 ICON,
29 FILE_TYPE,
30 N_COLUMNS
31 }
32
33 public IncludeTreeView () {
34 Object (row_spacing: 6);
35 }
36
37 construct {
38 filetype_blacklist = new SecurityPrivacy.FileTypeBlacklist (SecurityPrivacy.blacklist);
39
40 var list_store = new Gtk.ListStore (Columns.N_COLUMNS, typeof (bool), typeof (string), typeof (string), typeof (string));
41
42 var view = new Gtk.TreeView.with_model (list_store);
43 view.vexpand = true;
44 view.headers_visible = false;
45 view.activate_on_single_click = true;
46
47 var celltoggle = new Gtk.CellRendererToggle ();
48 view.row_activated.connect ((path, column) => {
49 Value active;
50 Gtk.TreeIter iter;
51 list_store.get_iter (out iter, path);
52 list_store.get_value (iter, Columns.ACTIVE, out active);
53 var is_active = !active.get_boolean ();
54 list_store.set (iter, Columns.ACTIVE, is_active);
55 Value name;
56 list_store.get_value (iter, Columns.FILE_TYPE, out name);
57 if (is_active == true) {
58 filetype_blacklist.unblock (name.get_string ());
59 } else {
60 filetype_blacklist.block (name.get_string ());
61 }
62 });
63
64 var cell = new Gtk.CellRendererText ();
65 var cellpixbuf = new Gtk.CellRendererPixbuf ();
66 cellpixbuf.stock_size = Gtk.IconSize.DND;
67 view.insert_column_with_attributes (-1, "", celltoggle, "active", Columns.ACTIVE);
68 view.insert_column_with_attributes (-1, "", cellpixbuf, "icon-name", Columns.ICON);
69 view.insert_column_with_attributes (-1, "", cell, "markup", Columns.NAME);
70
71 var scrolled = new Gtk.ScrolledWindow (null, null);
72 scrolled.shadow_type = Gtk.ShadowType.IN;
73 scrolled.expand = true;
74 scrolled.add (view);
75
76 var record_label = new Gtk.Label (_("Data Sources:"));
77 record_label.xalign = 0;
78
79 attach (record_label, 0, 0, 1, 1);
80 attach (scrolled, 0, 1, 1, 1);
81
82 set_inclue_iter_to_liststore (list_store, _("Chat Logs"), "internet-chat", Zeitgeist.NMO.IMMESSAGE);
83 set_inclue_iter_to_liststore (list_store, _("Documents"), "x-office-document", Zeitgeist.NFO.DOCUMENT);
84 set_inclue_iter_to_liststore (list_store, _("Music"), "audio-x-generic", Zeitgeist.NFO.AUDIO);
85 set_inclue_iter_to_liststore (list_store, _("Pictures"), "image-x-generic", Zeitgeist.NFO.IMAGE);
86 set_inclue_iter_to_liststore (list_store, _("Presentations"), "x-office-presentation", Zeitgeist.NFO.PRESENTATION);
87 set_inclue_iter_to_liststore (list_store, _("Spreadsheets"), "x-office-spreadsheet", Zeitgeist.NFO.SPREADSHEET);
88 set_inclue_iter_to_liststore (list_store, _("Videos"), "video-x-generic", Zeitgeist.NFO.VIDEO);
89 }
90
91 private void set_inclue_iter_to_liststore (Gtk.ListStore list_store, string name, string icon, string file_type) {
92 Gtk.TreeIter iter;
93 list_store.append (out iter);
94 bool active = (filetype_blacklist.all_filetypes.contains (file_type) == false);
95 list_store.set (iter, Columns.ACTIVE, active, Columns.NAME, name,
96 Columns.ICON, icon, Columns.FILE_TYPE, file_type);
97 }
98}
099
=== modified file 'src/Widgets/ServiceList.vala'
--- src/Widgets/ServiceList.vala 2017-02-27 01:30:20 +0000
+++ src/Widgets/ServiceList.vala 2017-02-27 23:09:39 +0000
@@ -5,7 +5,7 @@
5 }5 }
66
7 construct {7 construct {
8 var privacy_item = new ServiceItem ("document-open-recent", "tracking", _("Privacy"));8 var privacy_item = new ServiceItem ("document-open-recent", "tracking", _("History"));
9 var lock_item = new ServiceItem ("system-lock-screen", "locking", _("Locking"));9 var lock_item = new ServiceItem ("system-lock-screen", "locking", _("Locking"));
10 var firewall_item = new ServiceItem ("network-firewall", "firewall", _("Firewall"));10 var firewall_item = new ServiceItem ("network-firewall", "firewall", _("Firewall"));
1111

Subscribers

People subscribed via source and target branches