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