Merge lp:~lemonboy/noise/noise-privacy-mode into lp:~elementary-apps/noise/trunk

Proposed by The Lemon Man
Status: Merged
Approved by: Corentin Noël
Approved revision: 1846
Merged at revision: 1848
Proposed branch: lp:~lemonboy/noise/noise-privacy-mode
Merge into: lp:~elementary-apps/noise/trunk
Diff against target: 140 lines (+37/-22)
4 files modified
core/Settings.vala (+10/-5)
src/LibraryWindow.vala (+11/-7)
src/PlaybackManager.vala (+5/-2)
src/Views/ListView/Lists/GenericList.vala (+11/-8)
To merge this branch: bzr merge lp:~lemonboy/noise/noise-privacy-mode
Reviewer Review Type Date Requested Status
kay van der Zander (community) Approve
Corentin Noël Approve
Review via email: mp+274444@code.launchpad.net

Commit message

Respect Privacy Mode

To post a comment you must log in.
Revision history for this message
kay van der Zander (kay20) wrote :

Hey nice work,

Please place the function privacy_mode_enabled inside a class. Logical would be the main class in settings.vala.

You get main_settings.privacy_mode_enabled() in the if statement in the on_quit function.

Next time no functions outside a class. In case of static it is allowed :) but not needed in this case.

review: Needs Fixing (code)
Revision history for this message
The Lemon Man (lemonboy) wrote :

Done :)

Revision history for this message
kay van der Zander (kay20) wrote :

Hey
You have made some code style faults. Please fix them :)

I will check the rest later. I have a feeling when you clean up, you made it to hard for yourself.

review: Needs Fixing (code)
1846. By The Lemon Man

Respect the privacy mode when enabled.

Revision history for this message
Corentin Noël (tintou) wrote :

Okay to me

review: Approve
Revision history for this message
kay van der Zander (kay20) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'core/Settings.vala'
--- core/Settings.vala 2015-08-24 16:05:21 +0000
+++ core/Settings.vala 2015-10-20 19:30:43 +0000
@@ -29,7 +29,6 @@
29 */29 */
3030
31namespace Noise.Settings {31namespace Noise.Settings {
32
33 public class SavedState : Granite.Services.Settings {32 public class SavedState : Granite.Services.Settings {
3433
35 public int window_width { get; set; }34 public int window_width { get; set; }
@@ -85,6 +84,12 @@
85 return main_settings;84 return main_settings;
86 }85 }
8786
87 public bool privacy_mode_enabled () {
88 var privacy_settings = new GLib.Settings ("org.gnome.desktop.privacy");
89 return privacy_settings.get_boolean ("remember-app-usage") ||
90 privacy_settings.get_boolean ("remember-recent-files");
91 }
92
88 private Main () {93 private Main () {
89 base ("org.pantheon.noise.settings");94 base ("org.pantheon.noise.settings");
90 if (music_folder == "") {95 if (music_folder == "") {
@@ -115,19 +120,19 @@
115120
116 public Gee.Collection<Noise.EqualizerPreset> getPresets () {121 public Gee.Collection<Noise.EqualizerPreset> getPresets () {
117 var presets_data = new Gee.TreeSet<string> ();122 var presets_data = new Gee.TreeSet<string> ();
118 123
119 if (custom_presets != null) {124 if (custom_presets != null) {
120 for (int i = 0; i < custom_presets.length; i++) {125 for (int i = 0; i < custom_presets.length; i++) {
121 presets_data.add (custom_presets[i]);126 presets_data.add (custom_presets[i]);
122 }127 }
123 }128 }
124 129
125 var rv = new Gee.TreeSet<Noise.EqualizerPreset>();130 var rv = new Gee.TreeSet<Noise.EqualizerPreset>();
126 131
127 foreach (var preset_str in presets_data) {132 foreach (var preset_str in presets_data) {
128 rv.add (new Noise.EqualizerPreset.from_string (preset_str));133 rv.add (new Noise.EqualizerPreset.from_string (preset_str));
129 }134 }
130 135
131 return rv.read_only_view;136 return rv.read_only_view;
132 }137 }
133 }138 }
134139
=== modified file 'src/LibraryWindow.vala'
--- src/LibraryWindow.vala 2015-08-27 10:06:14 +0000
+++ src/LibraryWindow.vala 2015-10-20 19:30:43 +0000
@@ -1236,12 +1236,14 @@
1236 }1236 }
12371237
1238 private void on_quit () {1238 private void on_quit () {
1239 // Save media position and info1239 if (!main_settings.privacy_mode_enabled ()) {
1240 main_settings.last_media_position = (int)((double)App.player.player.get_position1240 // Save media position and info
1241 ()/TimeUtils.NANO_INV);1241 main_settings.last_media_position = (int)((double)App.player.player.get_position
1242 if(App.player.current_media != null) {1242 ()/TimeUtils.NANO_INV);
1243 App.player.current_media.resume_pos = (int)((double)App.player.player.get_position()/TimeUtils.NANO_INV);1243 if(App.player.current_media != null) {
1244 library_manager.update_media (App.player.current_media, false, false);1244 App.player.current_media.resume_pos = (int)((double)App.player.player.get_position()/TimeUtils.NANO_INV);
1245 library_manager.update_media (App.player.current_media, false, false);
1246 }
1245 }1247 }
1246 App.player.player.pause();1248 App.player.player.pause();
12471249
@@ -1250,7 +1252,9 @@
1250 saved_state.view_mode = viewSelector.selected;1252 saved_state.view_mode = viewSelector.selected;
12511253
1252 // Search1254 // Search
1253 main_settings.search_string = searchField.text;1255 if (!main_settings.privacy_mode_enabled ()) {
1256 main_settings.search_string = searchField.text;
1257 }
1254 1258
1255 // Save info pane (context pane) width1259 // Save info pane (context pane) width
1256 saved_state.more_width = info_panel.get_allocated_width ();1260 saved_state.more_width = info_panel.get_allocated_width ();
12571261
=== modified file 'src/PlaybackManager.vala'
--- src/PlaybackManager.vala 2015-08-15 09:47:21 +0000
+++ src/PlaybackManager.vala 2015-10-20 19:30:43 +0000
@@ -546,8 +546,9 @@
546 player.pause ();546 player.pause ();
547 547
548 //update settings548 //update settings
549 if (m.rowid >= 0)549 if (m.rowid >= 0 && !Settings.Main.get_default ().privacy_mode_enabled ()) {
550 Settings.Main.get_default ().last_media_playing = m.rowid;550 Settings.Main.get_default ().last_media_playing = m.rowid;
551 }
551 552
552 if (m != null)553 if (m != null)
553 media_played (m);554 media_played (m);
@@ -632,7 +633,9 @@
632 if (current_media != null)633 if (current_media != null)
633 was_playing = current_media.rowid;634 was_playing = current_media.rowid;
634 635
635 Settings.Main.get_default ().last_media_playing = 0;636 if (!Settings.Main.get_default ().privacy_mode_enabled ()) {
637 Settings.Main.get_default ().last_media_playing = 0;
638 }
636 current_media = null;639 current_media = null;
637 640
638 playback_stopped (was_playing);641 playback_stopped (was_playing);
639642
=== modified file 'src/Views/ListView/Lists/GenericList.vala'
--- src/Views/ListView/Lists/GenericList.vala 2015-08-26 14:03:19 +0000
+++ src/Views/ListView/Lists/GenericList.vala 2015-10-20 19:30:43 +0000
@@ -283,15 +283,18 @@
283283
284 is_current_list = true;284 is_current_list = true;
285 var main_settings = Settings.Main.get_default ();285 var main_settings = Settings.Main.get_default ();
286 if (playlist == null || playlist == ((Noise.LocalLibrary)libraries_manager.local_library).p_music || parent_wrapper.library != libraries_manager.local_library) {286
287 main_settings.last_playlist_playing = "";287 if (!main_settings.privacy_mode_enabled ()) {
288 } else if (playlist is SmartPlaylist) {288 if (playlist == null || playlist == ((Noise.LocalLibrary)libraries_manager.local_library).p_music || parent_wrapper.library != libraries_manager.local_library) {
289 main_settings.last_playlist_playing = "s%lld".printf (playlist.rowid);289 main_settings.last_playlist_playing = "";
290 } else {290 } else if (playlist is SmartPlaylist) {
291 if (((StaticPlaylist)playlist).read_only == false) {291 main_settings.last_playlist_playing = "s%lld".printf (playlist.rowid);
292 main_settings.last_playlist_playing = "p%lld".printf (playlist.rowid);
293 } else {292 } else {
294 main_settings.last_playlist_playing = "";293 if (((StaticPlaylist)playlist).read_only == false) {
294 main_settings.last_playlist_playing = "p%lld".printf (playlist.rowid);
295 } else {
296 main_settings.last_playlist_playing = "";
297 }
295 }298 }
296 }299 }
297300

Subscribers

People subscribed via source and target branches