Merge lp:~hauzer-d/noise/now-playing-label-context-menu into lp:~elementary-apps/noise/trunk

Proposed by Danielle Foré
Status: Work in progress
Proposed branch: lp:~hauzer-d/noise/now-playing-label-context-menu
Merge into: lp:~elementary-apps/noise/trunk
Diff against target: 309 lines (+63/-28)
5 files modified
src/LibraryWindow.vala (+2/-2)
src/Views/ListView/ListView.vala (+1/-2)
src/Views/ListView/Lists/MusicListView.vala (+36/-17)
src/Views/Wrappers/MusicViewWrapper.vala (+5/-5)
src/Widgets/TopDisplay.vala (+19/-2)
To merge this branch: bzr merge lp:~hauzer-d/noise/now-playing-label-context-menu
Reviewer Review Type Date Requested Status
Danielle Foré Needs Fixing
Review via email: mp+216550@code.launchpad.net

Description of the change

Adds context menu to now playing track label

To post a comment you must log in.
Revision history for this message
Danielle Foré (danrabbit) wrote :

The "Other Actions" and "Add to Playlist" submenus don't seem to be populated until after a submenu is activated elsewhere in the app

review: Needs Fixing
Revision history for this message
Robert Roth (evfool) wrote :

@hauzer-d: Could you please address the issue pointed out by Daniel?

Unmerged revisions

1564. By Никола Вукосављевић

Added a context menu to the label which displays the currently playing song.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/LibraryWindow.vala'
2--- src/LibraryWindow.vala 2014-03-16 23:04:30 +0000
3+++ src/LibraryWindow.vala 2014-04-20 16:56:17 +0000
4@@ -657,7 +657,7 @@
5 match_tvs.set (library_manager.p_music, music_tvs);
6 }
7 // Add Music Library View
8- var music_view_wrapper = new MusicViewWrapper (music_tvs, library_manager);
9+ var music_view_wrapper = new MusicViewWrapper (music_tvs, library_manager, topDisplay);
10 int view_number = view_container.add_view (music_view_wrapper);
11 var entry = source_list_view.add_item (view_number, _("Music"), ViewWrapper.Hint.MUSIC, Icons.MUSIC.gicon);
12 match_playlist_entry.set (library_manager.p_music, entry);
13@@ -1361,4 +1361,4 @@
14
15 return base.configure_event (event);
16 }
17-}
18\ No newline at end of file
19+}
20
21=== modified file 'src/Views/ListView/ListView.vala'
22--- src/Views/ListView/ListView.vala 2014-02-02 11:47:19 +0000
23+++ src/Views/ListView/ListView.vala 2014-04-20 16:56:17 +0000
24@@ -20,7 +20,6 @@
25 * Contains the column browser and list view.
26 */
27 public class Noise.ListView : ContentView, Gtk.Box {
28-
29 public signal void reordered ();
30
31 // Wrapper for the list view and miller columns
32@@ -425,4 +424,4 @@
33 list_text_overlay.message_visible = true;
34 }
35 }
36-}
37\ No newline at end of file
38+}
39
40=== modified file 'src/Views/ListView/Lists/MusicListView.vala'
41--- src/Views/ListView/Lists/MusicListView.vala 2014-02-02 11:47:19 +0000
42+++ src/Views/ListView/Lists/MusicListView.vala 2014-04-20 16:56:17 +0000
43@@ -66,6 +66,7 @@
44 Gtk.MenuItem importToLibrary;
45 Gtk.MenuItem mediaScrollToCurrent;
46 Gtk.MenuItem mediaScrollToCurrentSeparator;
47+ GLib.List<Media> mediaMenuData;
48 bool is_queue = false;
49 bool read_only = false;
50
51@@ -230,7 +231,7 @@
52
53 playlist_item.activate.connect (() => {
54 var to_add = new Gee.LinkedList<Media> ();
55- foreach (var m in get_selected_medias ())
56+ foreach (var m in mediaMenuData)
57 to_add.add (m);
58 playlist.add_medias (to_add);
59 });
60@@ -243,7 +244,7 @@
61 // if half and half, change text to 'Download %external of %total'
62 int temporary_count = 0;
63 int total_count = 0;
64- foreach (var m in get_selected_medias ()) {
65+ foreach (var m in mediaMenuData) {
66 if (m.isTemporary)
67 temporary_count++;
68 total_count++;
69@@ -261,7 +262,7 @@
70 }
71
72 int set_rating = -1;
73- foreach (Media m in get_selected_medias ()) {
74+ foreach (Media m in mediaMenuData) {
75 if (set_rating == -1) {
76 set_rating = (int) m.rating;
77 } else if (set_rating != m.rating) {
78@@ -280,10 +281,9 @@
79
80 try {
81 var files = new Gee.HashSet<File> (); //for automatic deduplication
82- var selected_medias = get_selected_medias (); //to avoid querying it every time
83- debug ("Number of selected medias obtained by MusicListView class: %u\n", selected_medias.length ());
84+ debug ("Number of selected medias obtained by MusicListView class: %u\n", mediaMenuData.length ());
85
86- foreach (var media in selected_medias) {
87+ foreach (var media in mediaMenuData) {
88 if (media.file.query_exists ()) {
89 files.add (media.file);
90 //if the file was marked nonexistent, update its status
91@@ -301,7 +301,7 @@
92
93 var contracts = Granite.Services.ContractorProxy.get_contracts_for_files (files.to_array ());
94 foreach (var contract in contracts) {
95- var menu_item = new ContractMenuItem (contract, selected_medias);
96+ var menu_item = new ContractMenuItem (contract, mediaMenuData);
97 contractorSubMenu.append (menu_item);
98 }
99 this.queue_draw ();
100@@ -310,8 +310,8 @@
101 warning ("Failed to obtain Contractor actions: %s", err.message);
102 mediaMenuContractorEntry.sensitive = false;
103 }
104-
105- mediaActionMenu.popup (null, null, null, 3, Gtk.get_current_event_time());
106+
107+ popupMediaMenu();
108
109 return true;
110 }
111@@ -391,12 +391,31 @@
112 tvs.sort_direction = sort_dir;
113 }
114
115+ public void popupMediaMenu (bool data_is_cur_playing = false) {
116+ mediaMenuData.foreach((x) => {
117+ mediaMenuData.remove(x);
118+ });
119+
120+ if (data_is_cur_playing) {
121+ mediaMenuData.append (App.player.media_info.media);
122+ mediaScrollToCurrent.hide();
123+ mediaScrollToCurrentSeparator.hide();
124+ }
125+ else {
126+ mediaMenuData = get_selected_medias ();
127+ mediaScrollToCurrent.show();
128+ mediaScrollToCurrentSeparator.show();
129+ }
130+
131+ mediaActionMenu.popup (null, null, null, 3, Gtk.get_current_event_time());
132+ }
133+
134 /** media menu popup clicks **/
135 void mediaMenuEditClicked () {
136 var to_edit = new Gee.LinkedList<int> ();
137 var to_edit_med = new Gee.LinkedList<Media> ();
138
139- foreach (Media m in get_selected_medias ()) {
140+ foreach (Media m in mediaMenuData) {
141 to_edit.add (m.rowid);
142 if (to_edit.size == 1)
143 to_edit_med.add (m);
144@@ -435,7 +454,7 @@
145 }
146
147 protected void mediaFileBrowseClicked () {
148- foreach (Media m in get_selected_medias ()) {
149+ foreach (Media m in mediaMenuData) {
150 try {
151 var file = File.new_for_uri (m.uri);
152 Gtk.show_uri (null, file.get_parent ().get_uri (), 0);
153@@ -450,7 +469,7 @@
154 protected virtual void mediaMenuQueueClicked () {
155 var to_queue = new Gee.LinkedList<Media> ();
156
157- foreach (Media m in get_selected_medias ()) {
158+ foreach (Media m in mediaMenuData) {
159 to_queue.add (m);
160 }
161
162@@ -461,7 +480,7 @@
163 var p = new StaticPlaylist ();
164
165 var to_add = new Gee.LinkedList<Media> ();
166- foreach (Media m in get_selected_medias ()) {
167+ foreach (Media m in mediaMenuData) {
168 to_add.add (m);
169 }
170 p.add_medias (to_add);
171@@ -473,7 +492,7 @@
172 var los = new Gee.LinkedList<Media> ();
173 int new_rating = mediaRateMedia.rating_value;
174
175- foreach (Media m in get_selected_medias ()) {
176+ foreach (Media m in mediaMenuData) {
177 m.rating = new_rating;
178 los.add (m);
179 }
180@@ -483,7 +502,7 @@
181 protected override void mediaRemoveClicked () {
182 var to_remove = new Gee.LinkedList<Media> ();
183
184- foreach (Media m in get_selected_medias ()) {
185+ foreach (Media m in mediaMenuData) {
186 to_remove.add (m);
187 }
188
189@@ -505,7 +524,7 @@
190 void importToLibraryClicked () {
191 var to_import = new Gee.LinkedList<Media> ();
192
193- foreach (Media m in get_selected_medias ()) {
194+ foreach (Media m in mediaMenuData) {
195 to_import.add (m);
196 }
197
198@@ -515,7 +534,7 @@
199 protected virtual void onDragDataGet (Gdk.DragContext context, Gtk.SelectionData selection_data, uint info, uint time_) {
200 string[] uris = null;
201
202- foreach (Media m in get_selected_medias ()) {
203+ foreach (Media m in mediaMenuData) {
204 debug ("adding %s\n", m.uri);
205 uris += (m.uri);
206 }
207
208=== modified file 'src/Views/Wrappers/MusicViewWrapper.vala'
209--- src/Views/Wrappers/MusicViewWrapper.vala 2014-04-13 08:28:46 +0000
210+++ src/Views/Wrappers/MusicViewWrapper.vala 2014-04-20 16:56:17 +0000
211@@ -22,15 +22,14 @@
212 */
213
214 public class Noise.MusicViewWrapper : ViewWrapper {
215-
216- public MusicViewWrapper (TreeViewSetup? tvs = null, Library library) {
217+ public MusicViewWrapper (TreeViewSetup? tvs = null, Library library, TopDisplay topDisplay) {
218 base (Hint.MUSIC, library);
219- build_async.begin (tvs);
220+ build_async.begin (tvs, topDisplay);
221 }
222
223 private Gee.HashMap<unowned Device, int> _devices;
224
225- private async void build_async (TreeViewSetup? tvs = null) {
226+ private async void build_async (TreeViewSetup? tvs = null, TopDisplay topDisplay) {
227 Idle.add_full (VIEW_CONSTRUCT_PRIORITY, build_async.callback);
228 yield;
229 // Add grid view
230@@ -45,6 +44,7 @@
231 else
232 music_setup = tvs;
233 list_view = new ListView (this, music_setup, true);
234+ topDisplay.set_list_view(list_view.list_view);
235
236 // Welcome screen
237 welcome_screen = new Granite.Widgets.Welcome (_("Get Some Tunes"),
238@@ -165,4 +165,4 @@
239 }
240 }
241 }
242-}
243\ No newline at end of file
244+}
245
246=== modified file 'src/Widgets/TopDisplay.vala'
247--- src/Widgets/TopDisplay.vala 2014-02-02 11:47:19 +0000
248+++ src/Widgets/TopDisplay.vala 2014-04-20 16:56:17 +0000
249@@ -28,6 +28,7 @@
250 Gtk.Scale scale;
251 Gtk.ProgressBar progressbar;
252 Gtk.Button cancelButton;
253+ MusicListView list_view;
254
255 private bool is_seeking = false;
256 private uint timeout_id = 0;
257@@ -62,6 +63,9 @@
258 label.set_justify (Gtk.Justification.CENTER);
259 label.set_single_line_mode (false);
260 label.ellipsize = Pango.EllipsizeMode.END;
261+ var label_eventbox = new Gtk.EventBox();
262+ label_eventbox.add(label);
263+ label_eventbox.button_press_event.connect(label_clicked);
264
265 cancelButton.set_image (Icons.PROCESS_STOP.render_image (Gtk.IconSize.MENU));
266 cancelButton.set_relief (Gtk.ReliefStyle.NONE);
267@@ -71,7 +75,7 @@
268
269 // all but cancel
270 var info = new Gtk.Grid ();
271- info.attach (label, 0, 0, 1, 1);
272+ info.attach (label_eventbox, 0, 0, 1, 1);
273 info.attach (progressbar, 0, 1, 1, 1);
274 info.attach (scale_grid, 0, 1, 1, 1);
275
276@@ -110,6 +114,10 @@
277 libraries_manager.local_library.media_updated.connect(media_updated);
278 }
279
280+ public void set_list_view(MusicListView list_view) {
281+ this.list_view = list_view;
282+ }
283+
284 /** label functions **/
285 public void set_label_text(string text) {
286 label.set_text(text);
287@@ -127,6 +135,15 @@
288 label.set_visible (val);
289 }
290
291+ public virtual bool label_clicked (Gdk.EventButton event) {
292+ if (event.button == 3) {
293+ list_view.popupMediaMenu (true);
294+ return true;
295+ }
296+
297+ return false;
298+ }
299+
300 /** progressbar functions **/
301 public void set_scale_sensitivity (bool val) {
302 scale.set_sensitive(val);
303@@ -304,4 +321,4 @@
304 set_media (current_media);
305 }
306 }
307-}
308\ No newline at end of file
309+}

Subscribers

People subscribed via source and target branches