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
=== modified file 'src/LibraryWindow.vala'
--- src/LibraryWindow.vala 2014-03-16 23:04:30 +0000
+++ src/LibraryWindow.vala 2014-04-20 16:56:17 +0000
@@ -657,7 +657,7 @@
657 match_tvs.set (library_manager.p_music, music_tvs);657 match_tvs.set (library_manager.p_music, music_tvs);
658 }658 }
659 // Add Music Library View659 // Add Music Library View
660 var music_view_wrapper = new MusicViewWrapper (music_tvs, library_manager);660 var music_view_wrapper = new MusicViewWrapper (music_tvs, library_manager, topDisplay);
661 int view_number = view_container.add_view (music_view_wrapper);661 int view_number = view_container.add_view (music_view_wrapper);
662 var entry = source_list_view.add_item (view_number, _("Music"), ViewWrapper.Hint.MUSIC, Icons.MUSIC.gicon);662 var entry = source_list_view.add_item (view_number, _("Music"), ViewWrapper.Hint.MUSIC, Icons.MUSIC.gicon);
663 match_playlist_entry.set (library_manager.p_music, entry);663 match_playlist_entry.set (library_manager.p_music, entry);
@@ -1361,4 +1361,4 @@
13611361
1362 return base.configure_event (event);1362 return base.configure_event (event);
1363 }1363 }
1364}
1365\ No newline at end of file1364\ No newline at end of file
1365}
13661366
=== modified file 'src/Views/ListView/ListView.vala'
--- src/Views/ListView/ListView.vala 2014-02-02 11:47:19 +0000
+++ src/Views/ListView/ListView.vala 2014-04-20 16:56:17 +0000
@@ -20,7 +20,6 @@
20 * Contains the column browser and list view.20 * Contains the column browser and list view.
21 */21 */
22public class Noise.ListView : ContentView, Gtk.Box {22public class Noise.ListView : ContentView, Gtk.Box {
23
24 public signal void reordered ();23 public signal void reordered ();
2524
26 // Wrapper for the list view and miller columns25 // Wrapper for the list view and miller columns
@@ -425,4 +424,4 @@
425 list_text_overlay.message_visible = true;424 list_text_overlay.message_visible = true;
426 }425 }
427 }426 }
428}
429\ No newline at end of file427\ No newline at end of file
428}
430429
=== modified file 'src/Views/ListView/Lists/MusicListView.vala'
--- src/Views/ListView/Lists/MusicListView.vala 2014-02-02 11:47:19 +0000
+++ src/Views/ListView/Lists/MusicListView.vala 2014-04-20 16:56:17 +0000
@@ -66,6 +66,7 @@
66 Gtk.MenuItem importToLibrary;66 Gtk.MenuItem importToLibrary;
67 Gtk.MenuItem mediaScrollToCurrent;67 Gtk.MenuItem mediaScrollToCurrent;
68 Gtk.MenuItem mediaScrollToCurrentSeparator;68 Gtk.MenuItem mediaScrollToCurrentSeparator;
69 GLib.List<Media> mediaMenuData;
69 bool is_queue = false;70 bool is_queue = false;
70 bool read_only = false;71 bool read_only = false;
7172
@@ -230,7 +231,7 @@
230231
231 playlist_item.activate.connect (() => {232 playlist_item.activate.connect (() => {
232 var to_add = new Gee.LinkedList<Media> ();233 var to_add = new Gee.LinkedList<Media> ();
233 foreach (var m in get_selected_medias ())234 foreach (var m in mediaMenuData)
234 to_add.add (m);235 to_add.add (m);
235 playlist.add_medias (to_add);236 playlist.add_medias (to_add);
236 });237 });
@@ -243,7 +244,7 @@
243 // if half and half, change text to 'Download %external of %total'244 // if half and half, change text to 'Download %external of %total'
244 int temporary_count = 0;245 int temporary_count = 0;
245 int total_count = 0;246 int total_count = 0;
246 foreach (var m in get_selected_medias ()) {247 foreach (var m in mediaMenuData) {
247 if (m.isTemporary)248 if (m.isTemporary)
248 temporary_count++;249 temporary_count++;
249 total_count++;250 total_count++;
@@ -261,7 +262,7 @@
261 }262 }
262263
263 int set_rating = -1;264 int set_rating = -1;
264 foreach (Media m in get_selected_medias ()) {265 foreach (Media m in mediaMenuData) {
265 if (set_rating == -1) {266 if (set_rating == -1) {
266 set_rating = (int) m.rating;267 set_rating = (int) m.rating;
267 } else if (set_rating != m.rating) {268 } else if (set_rating != m.rating) {
@@ -280,10 +281,9 @@
280281
281 try {282 try {
282 var files = new Gee.HashSet<File> (); //for automatic deduplication283 var files = new Gee.HashSet<File> (); //for automatic deduplication
283 var selected_medias = get_selected_medias (); //to avoid querying it every time284 debug ("Number of selected medias obtained by MusicListView class: %u\n", mediaMenuData.length ());
284 debug ("Number of selected medias obtained by MusicListView class: %u\n", selected_medias.length ());
285285
286 foreach (var media in selected_medias) {286 foreach (var media in mediaMenuData) {
287 if (media.file.query_exists ()) {287 if (media.file.query_exists ()) {
288 files.add (media.file);288 files.add (media.file);
289 //if the file was marked nonexistent, update its status289 //if the file was marked nonexistent, update its status
@@ -301,7 +301,7 @@
301301
302 var contracts = Granite.Services.ContractorProxy.get_contracts_for_files (files.to_array ());302 var contracts = Granite.Services.ContractorProxy.get_contracts_for_files (files.to_array ());
303 foreach (var contract in contracts) {303 foreach (var contract in contracts) {
304 var menu_item = new ContractMenuItem (contract, selected_medias);304 var menu_item = new ContractMenuItem (contract, mediaMenuData);
305 contractorSubMenu.append (menu_item);305 contractorSubMenu.append (menu_item);
306 }306 }
307 this.queue_draw ();307 this.queue_draw ();
@@ -310,8 +310,8 @@
310 warning ("Failed to obtain Contractor actions: %s", err.message);310 warning ("Failed to obtain Contractor actions: %s", err.message);
311 mediaMenuContractorEntry.sensitive = false;311 mediaMenuContractorEntry.sensitive = false;
312 }312 }
313313
314 mediaActionMenu.popup (null, null, null, 3, Gtk.get_current_event_time());314 popupMediaMenu();
315315
316 return true;316 return true;
317 }317 }
@@ -391,12 +391,31 @@
391 tvs.sort_direction = sort_dir;391 tvs.sort_direction = sort_dir;
392 }392 }
393393
394 public void popupMediaMenu (bool data_is_cur_playing = false) {
395 mediaMenuData.foreach((x) => {
396 mediaMenuData.remove(x);
397 });
398
399 if (data_is_cur_playing) {
400 mediaMenuData.append (App.player.media_info.media);
401 mediaScrollToCurrent.hide();
402 mediaScrollToCurrentSeparator.hide();
403 }
404 else {
405 mediaMenuData = get_selected_medias ();
406 mediaScrollToCurrent.show();
407 mediaScrollToCurrentSeparator.show();
408 }
409
410 mediaActionMenu.popup (null, null, null, 3, Gtk.get_current_event_time());
411 }
412
394 /** media menu popup clicks **/413 /** media menu popup clicks **/
395 void mediaMenuEditClicked () {414 void mediaMenuEditClicked () {
396 var to_edit = new Gee.LinkedList<int> ();415 var to_edit = new Gee.LinkedList<int> ();
397 var to_edit_med = new Gee.LinkedList<Media> ();416 var to_edit_med = new Gee.LinkedList<Media> ();
398417
399 foreach (Media m in get_selected_medias ()) {418 foreach (Media m in mediaMenuData) {
400 to_edit.add (m.rowid);419 to_edit.add (m.rowid);
401 if (to_edit.size == 1)420 if (to_edit.size == 1)
402 to_edit_med.add (m);421 to_edit_med.add (m);
@@ -435,7 +454,7 @@
435 }454 }
436455
437 protected void mediaFileBrowseClicked () {456 protected void mediaFileBrowseClicked () {
438 foreach (Media m in get_selected_medias ()) {457 foreach (Media m in mediaMenuData) {
439 try {458 try {
440 var file = File.new_for_uri (m.uri);459 var file = File.new_for_uri (m.uri);
441 Gtk.show_uri (null, file.get_parent ().get_uri (), 0);460 Gtk.show_uri (null, file.get_parent ().get_uri (), 0);
@@ -450,7 +469,7 @@
450 protected virtual void mediaMenuQueueClicked () {469 protected virtual void mediaMenuQueueClicked () {
451 var to_queue = new Gee.LinkedList<Media> ();470 var to_queue = new Gee.LinkedList<Media> ();
452471
453 foreach (Media m in get_selected_medias ()) {472 foreach (Media m in mediaMenuData) {
454 to_queue.add (m);473 to_queue.add (m);
455 }474 }
456475
@@ -461,7 +480,7 @@
461 var p = new StaticPlaylist ();480 var p = new StaticPlaylist ();
462481
463 var to_add = new Gee.LinkedList<Media> ();482 var to_add = new Gee.LinkedList<Media> ();
464 foreach (Media m in get_selected_medias ()) {483 foreach (Media m in mediaMenuData) {
465 to_add.add (m);484 to_add.add (m);
466 }485 }
467 p.add_medias (to_add);486 p.add_medias (to_add);
@@ -473,7 +492,7 @@
473 var los = new Gee.LinkedList<Media> ();492 var los = new Gee.LinkedList<Media> ();
474 int new_rating = mediaRateMedia.rating_value;493 int new_rating = mediaRateMedia.rating_value;
475494
476 foreach (Media m in get_selected_medias ()) {495 foreach (Media m in mediaMenuData) {
477 m.rating = new_rating;496 m.rating = new_rating;
478 los.add (m);497 los.add (m);
479 }498 }
@@ -483,7 +502,7 @@
483 protected override void mediaRemoveClicked () {502 protected override void mediaRemoveClicked () {
484 var to_remove = new Gee.LinkedList<Media> ();503 var to_remove = new Gee.LinkedList<Media> ();
485504
486 foreach (Media m in get_selected_medias ()) {505 foreach (Media m in mediaMenuData) {
487 to_remove.add (m);506 to_remove.add (m);
488 }507 }
489508
@@ -505,7 +524,7 @@
505 void importToLibraryClicked () {524 void importToLibraryClicked () {
506 var to_import = new Gee.LinkedList<Media> ();525 var to_import = new Gee.LinkedList<Media> ();
507526
508 foreach (Media m in get_selected_medias ()) {527 foreach (Media m in mediaMenuData) {
509 to_import.add (m);528 to_import.add (m);
510 }529 }
511530
@@ -515,7 +534,7 @@
515 protected virtual void onDragDataGet (Gdk.DragContext context, Gtk.SelectionData selection_data, uint info, uint time_) {534 protected virtual void onDragDataGet (Gdk.DragContext context, Gtk.SelectionData selection_data, uint info, uint time_) {
516 string[] uris = null;535 string[] uris = null;
517536
518 foreach (Media m in get_selected_medias ()) {537 foreach (Media m in mediaMenuData) {
519 debug ("adding %s\n", m.uri);538 debug ("adding %s\n", m.uri);
520 uris += (m.uri);539 uris += (m.uri);
521 }540 }
522541
=== modified file 'src/Views/Wrappers/MusicViewWrapper.vala'
--- src/Views/Wrappers/MusicViewWrapper.vala 2014-04-13 08:28:46 +0000
+++ src/Views/Wrappers/MusicViewWrapper.vala 2014-04-20 16:56:17 +0000
@@ -22,15 +22,14 @@
22 */22 */
2323
24public class Noise.MusicViewWrapper : ViewWrapper {24public class Noise.MusicViewWrapper : ViewWrapper {
25 25 public MusicViewWrapper (TreeViewSetup? tvs = null, Library library, TopDisplay topDisplay) {
26 public MusicViewWrapper (TreeViewSetup? tvs = null, Library library) {
27 base (Hint.MUSIC, library);26 base (Hint.MUSIC, library);
28 build_async.begin (tvs);27 build_async.begin (tvs, topDisplay);
29 }28 }
3029
31 private Gee.HashMap<unowned Device, int> _devices;30 private Gee.HashMap<unowned Device, int> _devices;
3231
33 private async void build_async (TreeViewSetup? tvs = null) {32 private async void build_async (TreeViewSetup? tvs = null, TopDisplay topDisplay) {
34 Idle.add_full (VIEW_CONSTRUCT_PRIORITY, build_async.callback);33 Idle.add_full (VIEW_CONSTRUCT_PRIORITY, build_async.callback);
35 yield;34 yield;
36 // Add grid view35 // Add grid view
@@ -45,6 +44,7 @@
45 else44 else
46 music_setup = tvs;45 music_setup = tvs;
47 list_view = new ListView (this, music_setup, true);46 list_view = new ListView (this, music_setup, true);
47 topDisplay.set_list_view(list_view.list_view);
4848
49 // Welcome screen49 // Welcome screen
50 welcome_screen = new Granite.Widgets.Welcome (_("Get Some Tunes"),50 welcome_screen = new Granite.Widgets.Welcome (_("Get Some Tunes"),
@@ -165,4 +165,4 @@
165 }165 }
166 }166 }
167 }167 }
168}
169\ No newline at end of file168\ No newline at end of file
169}
170170
=== modified file 'src/Widgets/TopDisplay.vala'
--- src/Widgets/TopDisplay.vala 2014-02-02 11:47:19 +0000
+++ src/Widgets/TopDisplay.vala 2014-04-20 16:56:17 +0000
@@ -28,6 +28,7 @@
28 Gtk.Scale scale;28 Gtk.Scale scale;
29 Gtk.ProgressBar progressbar;29 Gtk.ProgressBar progressbar;
30 Gtk.Button cancelButton;30 Gtk.Button cancelButton;
31 MusicListView list_view;
3132
32 private bool is_seeking = false;33 private bool is_seeking = false;
33 private uint timeout_id = 0;34 private uint timeout_id = 0;
@@ -62,6 +63,9 @@
62 label.set_justify (Gtk.Justification.CENTER);63 label.set_justify (Gtk.Justification.CENTER);
63 label.set_single_line_mode (false);64 label.set_single_line_mode (false);
64 label.ellipsize = Pango.EllipsizeMode.END;65 label.ellipsize = Pango.EllipsizeMode.END;
66 var label_eventbox = new Gtk.EventBox();
67 label_eventbox.add(label);
68 label_eventbox.button_press_event.connect(label_clicked);
65 69
66 cancelButton.set_image (Icons.PROCESS_STOP.render_image (Gtk.IconSize.MENU));70 cancelButton.set_image (Icons.PROCESS_STOP.render_image (Gtk.IconSize.MENU));
67 cancelButton.set_relief (Gtk.ReliefStyle.NONE);71 cancelButton.set_relief (Gtk.ReliefStyle.NONE);
@@ -71,7 +75,7 @@
7175
72 // all but cancel76 // all but cancel
73 var info = new Gtk.Grid ();77 var info = new Gtk.Grid ();
74 info.attach (label, 0, 0, 1, 1);78 info.attach (label_eventbox, 0, 0, 1, 1);
75 info.attach (progressbar, 0, 1, 1, 1);79 info.attach (progressbar, 0, 1, 1, 1);
76 info.attach (scale_grid, 0, 1, 1, 1);80 info.attach (scale_grid, 0, 1, 1, 1);
77 81
@@ -110,6 +114,10 @@
110 libraries_manager.local_library.media_updated.connect(media_updated);114 libraries_manager.local_library.media_updated.connect(media_updated);
111 }115 }
112 116
117 public void set_list_view(MusicListView list_view) {
118 this.list_view = list_view;
119 }
120
113 /** label functions **/121 /** label functions **/
114 public void set_label_text(string text) {122 public void set_label_text(string text) {
115 label.set_text(text);123 label.set_text(text);
@@ -127,6 +135,15 @@
127 label.set_visible (val);135 label.set_visible (val);
128 }136 }
129 137
138 public virtual bool label_clicked (Gdk.EventButton event) {
139 if (event.button == 3) {
140 list_view.popupMediaMenu (true);
141 return true;
142 }
143
144 return false;
145 }
146
130 /** progressbar functions **/147 /** progressbar functions **/
131 public void set_scale_sensitivity (bool val) {148 public void set_scale_sensitivity (bool val) {
132 scale.set_sensitive(val);149 scale.set_sensitive(val);
@@ -304,4 +321,4 @@
304 set_media (current_media);321 set_media (current_media);
305 }322 }
306 }323 }
307}
308\ No newline at end of file324\ No newline at end of file
325}

Subscribers

People subscribed via source and target branches