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
1=== modified file 'core/Settings.vala'
2--- core/Settings.vala 2015-08-24 16:05:21 +0000
3+++ core/Settings.vala 2015-10-20 19:30:43 +0000
4@@ -29,7 +29,6 @@
5 */
6
7 namespace Noise.Settings {
8-
9 public class SavedState : Granite.Services.Settings {
10
11 public int window_width { get; set; }
12@@ -85,6 +84,12 @@
13 return main_settings;
14 }
15
16+ public bool privacy_mode_enabled () {
17+ var privacy_settings = new GLib.Settings ("org.gnome.desktop.privacy");
18+ return privacy_settings.get_boolean ("remember-app-usage") ||
19+ privacy_settings.get_boolean ("remember-recent-files");
20+ }
21+
22 private Main () {
23 base ("org.pantheon.noise.settings");
24 if (music_folder == "") {
25@@ -115,19 +120,19 @@
26
27 public Gee.Collection<Noise.EqualizerPreset> getPresets () {
28 var presets_data = new Gee.TreeSet<string> ();
29-
30+
31 if (custom_presets != null) {
32 for (int i = 0; i < custom_presets.length; i++) {
33 presets_data.add (custom_presets[i]);
34 }
35 }
36-
37+
38 var rv = new Gee.TreeSet<Noise.EqualizerPreset>();
39-
40+
41 foreach (var preset_str in presets_data) {
42 rv.add (new Noise.EqualizerPreset.from_string (preset_str));
43 }
44-
45+
46 return rv.read_only_view;
47 }
48 }
49
50=== modified file 'src/LibraryWindow.vala'
51--- src/LibraryWindow.vala 2015-08-27 10:06:14 +0000
52+++ src/LibraryWindow.vala 2015-10-20 19:30:43 +0000
53@@ -1236,12 +1236,14 @@
54 }
55
56 private void on_quit () {
57- // Save media position and info
58- main_settings.last_media_position = (int)((double)App.player.player.get_position
59- ()/TimeUtils.NANO_INV);
60- if(App.player.current_media != null) {
61- App.player.current_media.resume_pos = (int)((double)App.player.player.get_position()/TimeUtils.NANO_INV);
62- library_manager.update_media (App.player.current_media, false, false);
63+ if (!main_settings.privacy_mode_enabled ()) {
64+ // Save media position and info
65+ main_settings.last_media_position = (int)((double)App.player.player.get_position
66+ ()/TimeUtils.NANO_INV);
67+ if(App.player.current_media != null) {
68+ App.player.current_media.resume_pos = (int)((double)App.player.player.get_position()/TimeUtils.NANO_INV);
69+ library_manager.update_media (App.player.current_media, false, false);
70+ }
71 }
72 App.player.player.pause();
73
74@@ -1250,7 +1252,9 @@
75 saved_state.view_mode = viewSelector.selected;
76
77 // Search
78- main_settings.search_string = searchField.text;
79+ if (!main_settings.privacy_mode_enabled ()) {
80+ main_settings.search_string = searchField.text;
81+ }
82
83 // Save info pane (context pane) width
84 saved_state.more_width = info_panel.get_allocated_width ();
85
86=== modified file 'src/PlaybackManager.vala'
87--- src/PlaybackManager.vala 2015-08-15 09:47:21 +0000
88+++ src/PlaybackManager.vala 2015-10-20 19:30:43 +0000
89@@ -546,8 +546,9 @@
90 player.pause ();
91
92 //update settings
93- if (m.rowid >= 0)
94+ if (m.rowid >= 0 && !Settings.Main.get_default ().privacy_mode_enabled ()) {
95 Settings.Main.get_default ().last_media_playing = m.rowid;
96+ }
97
98 if (m != null)
99 media_played (m);
100@@ -632,7 +633,9 @@
101 if (current_media != null)
102 was_playing = current_media.rowid;
103
104- Settings.Main.get_default ().last_media_playing = 0;
105+ if (!Settings.Main.get_default ().privacy_mode_enabled ()) {
106+ Settings.Main.get_default ().last_media_playing = 0;
107+ }
108 current_media = null;
109
110 playback_stopped (was_playing);
111
112=== modified file 'src/Views/ListView/Lists/GenericList.vala'
113--- src/Views/ListView/Lists/GenericList.vala 2015-08-26 14:03:19 +0000
114+++ src/Views/ListView/Lists/GenericList.vala 2015-10-20 19:30:43 +0000
115@@ -283,15 +283,18 @@
116
117 is_current_list = true;
118 var main_settings = Settings.Main.get_default ();
119- if (playlist == null || playlist == ((Noise.LocalLibrary)libraries_manager.local_library).p_music || parent_wrapper.library != libraries_manager.local_library) {
120- main_settings.last_playlist_playing = "";
121- } else if (playlist is SmartPlaylist) {
122- main_settings.last_playlist_playing = "s%lld".printf (playlist.rowid);
123- } else {
124- if (((StaticPlaylist)playlist).read_only == false) {
125- main_settings.last_playlist_playing = "p%lld".printf (playlist.rowid);
126+
127+ if (!main_settings.privacy_mode_enabled ()) {
128+ if (playlist == null || playlist == ((Noise.LocalLibrary)libraries_manager.local_library).p_music || parent_wrapper.library != libraries_manager.local_library) {
129+ main_settings.last_playlist_playing = "";
130+ } else if (playlist is SmartPlaylist) {
131+ main_settings.last_playlist_playing = "s%lld".printf (playlist.rowid);
132 } else {
133- main_settings.last_playlist_playing = "";
134+ if (((StaticPlaylist)playlist).read_only == false) {
135+ main_settings.last_playlist_playing = "p%lld".printf (playlist.rowid);
136+ } else {
137+ main_settings.last_playlist_playing = "";
138+ }
139 }
140 }
141

Subscribers

People subscribed via source and target branches