Merge lp:~elementary-pantheon/switchboard-plug-security-privacy/clear-usage-popover into lp:~elementary-apps/switchboard-plug-security-privacy/trunk
- clear-usage-popover
- Merge into trunk
Proposed by
Danielle Foré
Status: | Merged |
---|---|
Approved by: | Danielle Foré |
Approved revision: | 294 |
Merged at revision: | 294 |
Proposed branch: | lp:~elementary-pantheon/switchboard-plug-security-privacy/clear-usage-popover |
Merge into: | lp:~elementary-apps/switchboard-plug-security-privacy/trunk |
Diff against target: |
426 lines (+195/-165) 3 files modified
src/CMakeLists.txt (+1/-0) src/Views/TrackPanel.vala (+2/-165) src/Widgets/ClearUsagePopover.vala (+192/-0) |
To merge this branch: | bzr merge lp:~elementary-pantheon/switchboard-plug-security-privacy/clear-usage-popover |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
David Hewitt | code, function | Approve | |
Review via email:
|
Commit message
Move the ClearUsagePopover to its own class
Description of the change
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
David Hewitt (davidmhewitt) wrote : | # |
review:
Approve
(code, function)
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
RabbitBot (rabbitbot-a) wrote : | # |
Attempt to merge into lp:switchboard-plug-security-privacy failed due to conflicts:
text conflict in src/CMakeLists.txt
- 294. By Danielle Foré
-
resolve merge conflicts
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-22 17:18:21 +0000 | |||
3 | +++ src/CMakeLists.txt 2017-02-26 17:34:41 +0000 | |||
4 | @@ -24,6 +24,7 @@ | |||
5 | 24 | 24 | ||
6 | 25 | Widgets/AppChooser.vala | 25 | Widgets/AppChooser.vala |
7 | 26 | Widgets/AppRow.vala | 26 | Widgets/AppRow.vala |
8 | 27 | Widgets/ClearUsagePopover.vala | ||
9 | 27 | 28 | ||
10 | 28 | ${CMAKE_CURRENT_BINARY_DIR}/config.vala | 29 | ${CMAKE_CURRENT_BINARY_DIR}/config.vala |
11 | 29 | PACKAGES | 30 | PACKAGES |
12 | 30 | 31 | ||
13 | === modified file 'src/Views/TrackPanel.vala' | |||
14 | --- src/Views/TrackPanel.vala 2017-02-19 21:27:25 +0000 | |||
15 | +++ src/Views/TrackPanel.vala 2017-02-26 17:34:41 +0000 | |||
16 | @@ -21,11 +21,7 @@ | |||
17 | 21 | */ | 21 | */ |
18 | 22 | 22 | ||
19 | 23 | public class SecurityPrivacy.TrackPanel : Gtk.Grid { | 23 | public class SecurityPrivacy.TrackPanel : Gtk.Grid { |
25 | 24 | 24 | private Widgets.ClearUsagePopover remove_popover; | |
21 | 25 | private Gtk.RecentManager recent; | ||
22 | 26 | private List<Gtk.RecentInfo> items; | ||
23 | 27 | |||
24 | 28 | private Gtk.Popover remove_popover; | ||
26 | 29 | private Dialogs.AppChooser app_chooser; | 25 | private Dialogs.AppChooser app_chooser; |
27 | 30 | private ApplicationBlacklist app_blacklist; | 26 | private ApplicationBlacklist app_blacklist; |
28 | 31 | private PathBlacklist path_blacklist; | 27 | private PathBlacklist path_blacklist; |
29 | @@ -34,13 +30,6 @@ | |||
30 | 34 | private Gtk.Container description_frame; | 30 | private Gtk.Container description_frame; |
31 | 35 | private Gtk.Grid exclude_grid; | 31 | private Gtk.Grid exclude_grid; |
32 | 36 | 32 | ||
33 | 37 | private Granite.Widgets.DatePicker to_datepicker; | ||
34 | 38 | private Granite.Widgets.DatePicker from_datepicker; | ||
35 | 39 | private Gtk.RadioButton all_time_radio; | ||
36 | 40 | private Gtk.RadioButton from_radio; | ||
37 | 41 | private Gtk.RadioButton past_hour_radio; | ||
38 | 42 | private Gtk.RadioButton past_day_radio; | ||
39 | 43 | private Gtk.RadioButton past_week_radio; | ||
40 | 44 | private Gtk.Switch record_switch; | 33 | private Gtk.Switch record_switch; |
41 | 45 | 34 | ||
42 | 46 | private enum Columns { | 35 | private enum Columns { |
43 | @@ -63,7 +52,6 @@ | |||
44 | 63 | app_blacklist = new ApplicationBlacklist (blacklist); | 52 | app_blacklist = new ApplicationBlacklist (blacklist); |
45 | 64 | path_blacklist = new PathBlacklist (blacklist); | 53 | path_blacklist = new PathBlacklist (blacklist); |
46 | 65 | filetype_blacklist = new FileTypeBlacklist (blacklist); | 54 | filetype_blacklist = new FileTypeBlacklist (blacklist); |
47 | 66 | recent = new Gtk.RecentManager (); | ||
48 | 67 | 55 | ||
49 | 68 | var privacy_settings = new GLib.Settings ("org.gnome.desktop.privacy"); | 56 | var privacy_settings = new GLib.Settings ("org.gnome.desktop.privacy"); |
50 | 69 | 57 | ||
51 | @@ -96,8 +84,6 @@ | |||
52 | 96 | record_grid.add (record_switch); | 84 | record_grid.add (record_switch); |
53 | 97 | record_grid.add (info_button); | 85 | record_grid.add (info_button); |
54 | 98 | 86 | ||
55 | 99 | /* Remove Popover */ | ||
56 | 100 | |||
57 | 101 | var clear_data = new Gtk.ToggleButton.with_label (_("Clear Usage Data…")); | 87 | var clear_data = new Gtk.ToggleButton.with_label (_("Clear Usage Data…")); |
58 | 102 | clear_data.halign = Gtk.Align.END; | 88 | clear_data.halign = Gtk.Align.END; |
59 | 103 | clear_data.notify["active"].connect (() => { | 89 | clear_data.notify["active"].connect (() => { |
60 | @@ -108,44 +94,7 @@ | |||
61 | 108 | } | 94 | } |
62 | 109 | }); | 95 | }); |
63 | 110 | 96 | ||
102 | 111 | var clear_label = new Gtk.Label (_("Remove system-collected file and application usage data from:")); | 97 | remove_popover = new Widgets.ClearUsagePopover (clear_data); |
65 | 112 | clear_label.halign = Gtk.Align.START; | ||
66 | 113 | |||
67 | 114 | past_hour_radio = new Gtk.RadioButton.with_label (null, _("The past hour")); | ||
68 | 115 | past_day_radio = new Gtk.RadioButton.with_label_from_widget (past_hour_radio, _("The past day")); | ||
69 | 116 | past_week_radio = new Gtk.RadioButton.with_label_from_widget (past_hour_radio, _("The past week")); | ||
70 | 117 | from_radio = new Gtk.RadioButton.with_label_from_widget (past_hour_radio, _("From:")); | ||
71 | 118 | all_time_radio = new Gtk.RadioButton.with_label_from_widget (past_hour_radio, _("All time")); | ||
72 | 119 | |||
73 | 120 | from_datepicker = new Granite.Widgets.DatePicker (); | ||
74 | 121 | var to_label = new Gtk.Label (_("To:")); | ||
75 | 122 | to_datepicker = new Granite.Widgets.DatePicker (); | ||
76 | 123 | |||
77 | 124 | var clear_button = new Gtk.Button.with_label (_("Clear Data")); | ||
78 | 125 | clear_button.halign = Gtk.Align.END; | ||
79 | 126 | clear_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION); | ||
80 | 127 | clear_button.clicked.connect (() => { | ||
81 | 128 | on_clear_data (); | ||
82 | 129 | }); | ||
83 | 130 | |||
84 | 131 | var remove_popover_grid = new Gtk.Grid (); | ||
85 | 132 | remove_popover_grid.margin = 12; | ||
86 | 133 | remove_popover_grid.column_spacing = 12; | ||
87 | 134 | remove_popover_grid.row_spacing = 6; | ||
88 | 135 | |||
89 | 136 | remove_popover_grid.attach (clear_label, 0, 0, 4, 1); | ||
90 | 137 | remove_popover_grid.attach (past_hour_radio, 0, 1, 4, 1); | ||
91 | 138 | remove_popover_grid.attach (past_day_radio, 0, 2, 4, 1); | ||
92 | 139 | remove_popover_grid.attach (past_week_radio, 0, 3, 4, 1); | ||
93 | 140 | remove_popover_grid.attach (from_radio, 0, 4, 1, 1); | ||
94 | 141 | remove_popover_grid.attach (from_datepicker, 1, 4, 1, 1); | ||
95 | 142 | remove_popover_grid.attach (to_label, 2, 4, 1, 1); | ||
96 | 143 | remove_popover_grid.attach (to_datepicker, 3, 4, 1, 1); | ||
97 | 144 | remove_popover_grid.attach (all_time_radio, 0, 5, 4, 1); | ||
98 | 145 | remove_popover_grid.attach (clear_button, 0, 6, 4, 1); | ||
99 | 146 | |||
100 | 147 | remove_popover = new Gtk.Popover (clear_data); | ||
101 | 148 | remove_popover.add (remove_popover_grid); | ||
103 | 149 | remove_popover.closed.connect (() => { | 98 | remove_popover.closed.connect (() => { |
104 | 150 | clear_data.active = false; | 99 | clear_data.active = false; |
105 | 151 | }); | 100 | }); |
106 | @@ -167,20 +116,6 @@ | |||
107 | 167 | record_switch.grab_focus (); | 116 | record_switch.grab_focus (); |
108 | 168 | } | 117 | } |
109 | 169 | 118 | ||
110 | 170 | private async void delete_history (Zeitgeist.TimeRange tr) { | ||
111 | 171 | var events = new GenericArray<Zeitgeist.Event> (); | ||
112 | 172 | events.add (new Zeitgeist.Event ()); | ||
113 | 173 | var zg_log = new Zeitgeist.Log (); | ||
114 | 174 | try { | ||
115 | 175 | uint32[] ids = yield zg_log.find_event_ids (tr, events, Zeitgeist.StorageState.ANY, 0, 0, null); | ||
116 | 176 | Array<uint32> del_ids = new Array<uint32> (); | ||
117 | 177 | del_ids.append_vals (ids, ids.length); | ||
118 | 178 | yield zg_log.delete_events (del_ids, null); | ||
119 | 179 | } catch (Error e) { | ||
120 | 180 | critical (e.message); | ||
121 | 181 | } | ||
122 | 182 | } | ||
123 | 183 | |||
124 | 184 | private string get_operating_system_name () { | 119 | private string get_operating_system_name () { |
125 | 185 | string system = _("Your system"); | 120 | string system = _("Your system"); |
126 | 186 | try { | 121 | try { |
127 | @@ -426,102 +361,4 @@ | |||
128 | 426 | NotColumns.IS_APP, false); | 361 | NotColumns.IS_APP, false); |
129 | 427 | }); | 362 | }); |
130 | 428 | } | 363 | } |
131 | 429 | |||
132 | 430 | private void on_clear_data () { | ||
133 | 431 | Zeitgeist.TimeRange tr; | ||
134 | 432 | |||
135 | 433 | if (past_hour_radio.active == true) { | ||
136 | 434 | int range = 360000;//60*60*1000; | ||
137 | 435 | int64 end = Zeitgeist.Timestamp.from_now (); | ||
138 | 436 | int64 start = end - range; | ||
139 | 437 | tr = new Zeitgeist.TimeRange (start, end); | ||
140 | 438 | delete_history.begin (tr); | ||
141 | 439 | |||
142 | 440 | // Deletes files added in the last hour | ||
143 | 441 | if (recent.size > 0) { | ||
144 | 442 | items = recent.get_items (); | ||
145 | 443 | |||
146 | 444 | try { | ||
147 | 445 | foreach (var item in items) { | ||
148 | 446 | if (item.get_added () >= start/1000) | ||
149 | 447 | recent.remove_item (item.get_uri ()); | ||
150 | 448 | } | ||
151 | 449 | } catch (Error err) { | ||
152 | 450 | critical (err.message); | ||
153 | 451 | } | ||
154 | 452 | } | ||
155 | 453 | } else if (past_day_radio.active == true) { | ||
156 | 454 | int range = 8640000;//24*60*60*1000; | ||
157 | 455 | int64 end = Zeitgeist.Timestamp.from_now (); | ||
158 | 456 | int64 start = end - range; | ||
159 | 457 | tr = new Zeitgeist.TimeRange (start, end); | ||
160 | 458 | delete_history.begin (tr); | ||
161 | 459 | |||
162 | 460 | // Deletes files added in the last day | ||
163 | 461 | if (recent.size > 0) { | ||
164 | 462 | items = recent.get_items (); | ||
165 | 463 | |||
166 | 464 | try { | ||
167 | 465 | foreach (var item in items) { | ||
168 | 466 | if (item.get_age () <= 1) | ||
169 | 467 | recent.remove_item (item.get_uri ()); | ||
170 | 468 | } | ||
171 | 469 | } catch (Error err) { | ||
172 | 470 | critical (err.message); | ||
173 | 471 | } | ||
174 | 472 | } | ||
175 | 473 | } else if (past_week_radio.active == true) { | ||
176 | 474 | int range = 60480000;//7*24*60*60*1000; | ||
177 | 475 | int64 end = Zeitgeist.Timestamp.from_now (); | ||
178 | 476 | int64 start = end - range; | ||
179 | 477 | tr = new Zeitgeist.TimeRange (start, end); | ||
180 | 478 | delete_history.begin (tr); | ||
181 | 479 | |||
182 | 480 | // Deletes files added in the last week | ||
183 | 481 | if (recent.size > 0) { | ||
184 | 482 | items = recent.get_items (); | ||
185 | 483 | |||
186 | 484 | try { | ||
187 | 485 | foreach (var item in items) { | ||
188 | 486 | if (item.get_age () <= 7) | ||
189 | 487 | recent.remove_item (item.get_uri ()); | ||
190 | 488 | } | ||
191 | 489 | } catch (Error err) { | ||
192 | 490 | critical (err.message); | ||
193 | 491 | } | ||
194 | 492 | } | ||
195 | 493 | } else if (from_radio.active == true) { | ||
196 | 494 | int64 start = from_datepicker.date.to_unix ()*1000; | ||
197 | 495 | int64 end = to_datepicker.date.to_unix ()*1000; | ||
198 | 496 | tr = new Zeitgeist.TimeRange (start, end); | ||
199 | 497 | delete_history.begin (tr); | ||
200 | 498 | |||
201 | 499 | // Deletes files added during the given period | ||
202 | 500 | if (recent.size > 0) { | ||
203 | 501 | items = recent.get_items (); | ||
204 | 502 | |||
205 | 503 | try { | ||
206 | 504 | foreach (var item in items) { | ||
207 | 505 | if (item.get_added () >= start/1000 && item.get_added () <= end/1000) | ||
208 | 506 | recent.remove_item (item.get_uri ()); | ||
209 | 507 | } | ||
210 | 508 | } catch (Error err) { | ||
211 | 509 | critical (err.message); | ||
212 | 510 | } | ||
213 | 511 | } | ||
214 | 512 | } else if (all_time_radio.active == true) { | ||
215 | 513 | tr = new Zeitgeist.TimeRange.anytime (); | ||
216 | 514 | delete_history.begin (tr); | ||
217 | 515 | |||
218 | 516 | // Deletes all recent files | ||
219 | 517 | if (recent.size > 0) { | ||
220 | 518 | try { | ||
221 | 519 | recent.purge_items (); | ||
222 | 520 | } catch (Error err) { | ||
223 | 521 | critical (err.message); | ||
224 | 522 | } | ||
225 | 523 | } | ||
226 | 524 | } | ||
227 | 525 | remove_popover.hide (); | ||
228 | 526 | } | ||
229 | 527 | } | 364 | } |
230 | 528 | 365 | ||
231 | === added file 'src/Widgets/ClearUsagePopover.vala' | |||
232 | --- src/Widgets/ClearUsagePopover.vala 1970-01-01 00:00:00 +0000 | |||
233 | +++ src/Widgets/ClearUsagePopover.vala 2017-02-26 17:34:41 +0000 | |||
234 | @@ -0,0 +1,192 @@ | |||
235 | 1 | /*- | ||
236 | 2 | * Copyright (c) 2014-2017 elementary LLC. (http://launchpad.net/switchboard-plug-security-privacy) | ||
237 | 3 | * | ||
238 | 4 | * This library is free software; you can redistribute it and/or | ||
239 | 5 | * modify it under the terms of the GNU Library General Public | ||
240 | 6 | * License as published by the Free Software Foundation; either | ||
241 | 7 | * version 3 of the License, or (at your option) any later version. | ||
242 | 8 | * | ||
243 | 9 | * This library is distributed in the hope that it will be useful, | ||
244 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
245 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
246 | 12 | * Library General Public License for more details. | ||
247 | 13 | * | ||
248 | 14 | * You should have received a copy of the GNU Library General Public | ||
249 | 15 | * License along with this library; if not, write to the | ||
250 | 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
251 | 17 | * Boston, MA 02111-1307, USA. | ||
252 | 18 | * | ||
253 | 19 | * Authored by: Corentin Noël <corentin@elementaryos.org> | ||
254 | 20 | */ | ||
255 | 21 | |||
256 | 22 | public class SecurityPrivacy.Widgets.ClearUsagePopover : Gtk.Popover { | ||
257 | 23 | private Granite.Widgets.DatePicker to_datepicker; | ||
258 | 24 | private Granite.Widgets.DatePicker from_datepicker; | ||
259 | 25 | private Gtk.RadioButton all_time_radio; | ||
260 | 26 | private Gtk.RadioButton from_radio; | ||
261 | 27 | private Gtk.RadioButton past_hour_radio; | ||
262 | 28 | private Gtk.RadioButton past_day_radio; | ||
263 | 29 | private Gtk.RadioButton past_week_radio; | ||
264 | 30 | private Gtk.RecentManager recent; | ||
265 | 31 | |||
266 | 32 | private List<Gtk.RecentInfo> items; | ||
267 | 33 | |||
268 | 34 | public ClearUsagePopover (Gtk.Widget? relative_to) { | ||
269 | 35 | Object (relative_to: relative_to); | ||
270 | 36 | } | ||
271 | 37 | |||
272 | 38 | construct { | ||
273 | 39 | recent = new Gtk.RecentManager (); | ||
274 | 40 | |||
275 | 41 | var clear_label = new Gtk.Label (_("Remove system-collected file and application usage data from:")); | ||
276 | 42 | clear_label.halign = Gtk.Align.START; | ||
277 | 43 | |||
278 | 44 | past_hour_radio = new Gtk.RadioButton.with_label (null, _("The past hour")); | ||
279 | 45 | past_day_radio = new Gtk.RadioButton.with_label_from_widget (past_hour_radio, _("The past day")); | ||
280 | 46 | past_week_radio = new Gtk.RadioButton.with_label_from_widget (past_hour_radio, _("The past week")); | ||
281 | 47 | from_radio = new Gtk.RadioButton.with_label_from_widget (past_hour_radio, _("From:")); | ||
282 | 48 | all_time_radio = new Gtk.RadioButton.with_label_from_widget (past_hour_radio, _("All time")); | ||
283 | 49 | |||
284 | 50 | from_datepicker = new Granite.Widgets.DatePicker (); | ||
285 | 51 | var to_label = new Gtk.Label (_("To:")); | ||
286 | 52 | to_datepicker = new Granite.Widgets.DatePicker (); | ||
287 | 53 | |||
288 | 54 | var clear_button = new Gtk.Button.with_label (_("Clear Data")); | ||
289 | 55 | clear_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION); | ||
290 | 56 | clear_button.halign = Gtk.Align.END; | ||
291 | 57 | |||
292 | 58 | var grid = new Gtk.Grid (); | ||
293 | 59 | grid.margin = 12; | ||
294 | 60 | grid.column_spacing = 12; | ||
295 | 61 | grid.row_spacing = 6; | ||
296 | 62 | grid.attach (clear_label, 0, 0, 4, 1); | ||
297 | 63 | grid.attach (past_hour_radio, 0, 1, 4, 1); | ||
298 | 64 | grid.attach (past_day_radio, 0, 2, 4, 1); | ||
299 | 65 | grid.attach (past_week_radio, 0, 3, 4, 1); | ||
300 | 66 | grid.attach (from_radio, 0, 4, 1, 1); | ||
301 | 67 | grid.attach (from_datepicker, 1, 4, 1, 1); | ||
302 | 68 | grid.attach (to_label, 2, 4, 1, 1); | ||
303 | 69 | grid.attach (to_datepicker, 3, 4, 1, 1); | ||
304 | 70 | grid.attach (all_time_radio, 0, 5, 4, 1); | ||
305 | 71 | grid.attach (clear_button, 0, 6, 4, 1); | ||
306 | 72 | |||
307 | 73 | add (grid); | ||
308 | 74 | |||
309 | 75 | clear_button.clicked.connect (() => { | ||
310 | 76 | on_clear_data (); | ||
311 | 77 | }); | ||
312 | 78 | } | ||
313 | 79 | |||
314 | 80 | private async void delete_history (Zeitgeist.TimeRange tr) { | ||
315 | 81 | var events = new GenericArray<Zeitgeist.Event> (); | ||
316 | 82 | events.add (new Zeitgeist.Event ()); | ||
317 | 83 | var zg_log = new Zeitgeist.Log (); | ||
318 | 84 | try { | ||
319 | 85 | uint32[] ids = yield zg_log.find_event_ids (tr, events, Zeitgeist.StorageState.ANY, 0, 0, null); | ||
320 | 86 | Array<uint32> del_ids = new Array<uint32> (); | ||
321 | 87 | del_ids.append_vals (ids, ids.length); | ||
322 | 88 | yield zg_log.delete_events (del_ids, null); | ||
323 | 89 | } catch (Error e) { | ||
324 | 90 | critical (e.message); | ||
325 | 91 | } | ||
326 | 92 | } | ||
327 | 93 | |||
328 | 94 | private void on_clear_data () { | ||
329 | 95 | Zeitgeist.TimeRange tr; | ||
330 | 96 | |||
331 | 97 | if (past_hour_radio.active == true) { | ||
332 | 98 | int range = 360000;//60*60*1000; | ||
333 | 99 | int64 end = Zeitgeist.Timestamp.from_now (); | ||
334 | 100 | int64 start = end - range; | ||
335 | 101 | tr = new Zeitgeist.TimeRange (start, end); | ||
336 | 102 | delete_history.begin (tr); | ||
337 | 103 | |||
338 | 104 | // Deletes files added in the last hour | ||
339 | 105 | if (recent.size > 0) { | ||
340 | 106 | items = recent.get_items (); | ||
341 | 107 | |||
342 | 108 | try { | ||
343 | 109 | foreach (var item in items) { | ||
344 | 110 | if (item.get_added () >= start/1000) | ||
345 | 111 | recent.remove_item (item.get_uri ()); | ||
346 | 112 | } | ||
347 | 113 | } catch (Error err) { | ||
348 | 114 | critical (err.message); | ||
349 | 115 | } | ||
350 | 116 | } | ||
351 | 117 | } else if (past_day_radio.active == true) { | ||
352 | 118 | int range = 8640000;//24*60*60*1000; | ||
353 | 119 | int64 end = Zeitgeist.Timestamp.from_now (); | ||
354 | 120 | int64 start = end - range; | ||
355 | 121 | tr = new Zeitgeist.TimeRange (start, end); | ||
356 | 122 | delete_history.begin (tr); | ||
357 | 123 | |||
358 | 124 | // Deletes files added in the last day | ||
359 | 125 | if (recent.size > 0) { | ||
360 | 126 | items = recent.get_items (); | ||
361 | 127 | |||
362 | 128 | try { | ||
363 | 129 | foreach (var item in items) { | ||
364 | 130 | if (item.get_age () <= 1) | ||
365 | 131 | recent.remove_item (item.get_uri ()); | ||
366 | 132 | } | ||
367 | 133 | } catch (Error err) { | ||
368 | 134 | critical (err.message); | ||
369 | 135 | } | ||
370 | 136 | } | ||
371 | 137 | } else if (past_week_radio.active == true) { | ||
372 | 138 | int range = 60480000;//7*24*60*60*1000; | ||
373 | 139 | int64 end = Zeitgeist.Timestamp.from_now (); | ||
374 | 140 | int64 start = end - range; | ||
375 | 141 | tr = new Zeitgeist.TimeRange (start, end); | ||
376 | 142 | delete_history.begin (tr); | ||
377 | 143 | |||
378 | 144 | // Deletes files added in the last week | ||
379 | 145 | if (recent.size > 0) { | ||
380 | 146 | items = recent.get_items (); | ||
381 | 147 | |||
382 | 148 | try { | ||
383 | 149 | foreach (var item in items) { | ||
384 | 150 | if (item.get_age () <= 7) | ||
385 | 151 | recent.remove_item (item.get_uri ()); | ||
386 | 152 | } | ||
387 | 153 | } catch (Error err) { | ||
388 | 154 | critical (err.message); | ||
389 | 155 | } | ||
390 | 156 | } | ||
391 | 157 | } else if (from_radio.active == true) { | ||
392 | 158 | int64 start = from_datepicker.date.to_unix ()*1000; | ||
393 | 159 | int64 end = to_datepicker.date.to_unix ()*1000; | ||
394 | 160 | tr = new Zeitgeist.TimeRange (start, end); | ||
395 | 161 | delete_history.begin (tr); | ||
396 | 162 | |||
397 | 163 | // Deletes files added during the given period | ||
398 | 164 | if (recent.size > 0) { | ||
399 | 165 | items = recent.get_items (); | ||
400 | 166 | |||
401 | 167 | try { | ||
402 | 168 | foreach (var item in items) { | ||
403 | 169 | if (item.get_added () >= start/1000 && item.get_added () <= end/1000) | ||
404 | 170 | recent.remove_item (item.get_uri ()); | ||
405 | 171 | } | ||
406 | 172 | } catch (Error err) { | ||
407 | 173 | critical (err.message); | ||
408 | 174 | } | ||
409 | 175 | } | ||
410 | 176 | } else if (all_time_radio.active == true) { | ||
411 | 177 | tr = new Zeitgeist.TimeRange.anytime (); | ||
412 | 178 | delete_history.begin (tr); | ||
413 | 179 | |||
414 | 180 | // Deletes all recent files | ||
415 | 181 | if (recent.size > 0) { | ||
416 | 182 | try { | ||
417 | 183 | recent.purge_items (); | ||
418 | 184 | } catch (Error err) { | ||
419 | 185 | critical (err.message); | ||
420 | 186 | } | ||
421 | 187 | } | ||
422 | 188 | } | ||
423 | 189 | |||
424 | 190 | hide (); | ||
425 | 191 | } | ||
426 | 192 | } |
Cleans up TrackPanel.vala nicely and still works as intended.