Merge lp:~hauzer-d/noise/now-playing-label-context-menu into lp:~elementary-apps/noise/trunk
- now-playing-label-context-menu
- Merge into 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 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Danielle Foré | Needs Fixing | ||
Review via email: mp+216550@code.launchpad.net |
Commit message
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
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 | 657 | match_tvs.set (library_manager.p_music, music_tvs); | 657 | match_tvs.set (library_manager.p_music, music_tvs); |
6 | 658 | } | 658 | } |
7 | 659 | // Add Music Library View | 659 | // Add Music Library View |
9 | 660 | var music_view_wrapper = new MusicViewWrapper (music_tvs, library_manager); | 660 | var music_view_wrapper = new MusicViewWrapper (music_tvs, library_manager, topDisplay); |
10 | 661 | int view_number = view_container.add_view (music_view_wrapper); | 661 | int view_number = view_container.add_view (music_view_wrapper); |
11 | 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); |
12 | 663 | match_playlist_entry.set (library_manager.p_music, entry); | 663 | match_playlist_entry.set (library_manager.p_music, entry); |
13 | @@ -1361,4 +1361,4 @@ | |||
14 | 1361 | 1361 | ||
15 | 1362 | return base.configure_event (event); | 1362 | return base.configure_event (event); |
16 | 1363 | } | 1363 | } |
17 | 1364 | } | ||
18 | 1365 | \ No newline at end of file | 1364 | \ No newline at end of file |
19 | 1365 | } | ||
20 | 1366 | 1366 | ||
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 | 20 | * Contains the column browser and list view. | 20 | * Contains the column browser and list view. |
26 | 21 | */ | 21 | */ |
27 | 22 | public class Noise.ListView : ContentView, Gtk.Box { | 22 | public class Noise.ListView : ContentView, Gtk.Box { |
28 | 23 | |||
29 | 24 | public signal void reordered (); | 23 | public signal void reordered (); |
30 | 25 | 24 | ||
31 | 26 | // Wrapper for the list view and miller columns | 25 | // Wrapper for the list view and miller columns |
32 | @@ -425,4 +424,4 @@ | |||
33 | 425 | list_text_overlay.message_visible = true; | 424 | list_text_overlay.message_visible = true; |
34 | 426 | } | 425 | } |
35 | 427 | } | 426 | } |
36 | 428 | } | ||
37 | 429 | \ No newline at end of file | 427 | \ No newline at end of file |
38 | 428 | } | ||
39 | 430 | 429 | ||
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 | 66 | Gtk.MenuItem importToLibrary; | 66 | Gtk.MenuItem importToLibrary; |
45 | 67 | Gtk.MenuItem mediaScrollToCurrent; | 67 | Gtk.MenuItem mediaScrollToCurrent; |
46 | 68 | Gtk.MenuItem mediaScrollToCurrentSeparator; | 68 | Gtk.MenuItem mediaScrollToCurrentSeparator; |
47 | 69 | GLib.List<Media> mediaMenuData; | ||
48 | 69 | bool is_queue = false; | 70 | bool is_queue = false; |
49 | 70 | bool read_only = false; | 71 | bool read_only = false; |
50 | 71 | 72 | ||
51 | @@ -230,7 +231,7 @@ | |||
52 | 230 | 231 | ||
53 | 231 | playlist_item.activate.connect (() => { | 232 | playlist_item.activate.connect (() => { |
54 | 232 | var to_add = new Gee.LinkedList<Media> (); | 233 | var to_add = new Gee.LinkedList<Media> (); |
56 | 233 | foreach (var m in get_selected_medias ()) | 234 | foreach (var m in mediaMenuData) |
57 | 234 | to_add.add (m); | 235 | to_add.add (m); |
58 | 235 | playlist.add_medias (to_add); | 236 | playlist.add_medias (to_add); |
59 | 236 | }); | 237 | }); |
60 | @@ -243,7 +244,7 @@ | |||
61 | 243 | // if half and half, change text to 'Download %external of %total' | 244 | // if half and half, change text to 'Download %external of %total' |
62 | 244 | int temporary_count = 0; | 245 | int temporary_count = 0; |
63 | 245 | int total_count = 0; | 246 | int total_count = 0; |
65 | 246 | foreach (var m in get_selected_medias ()) { | 247 | foreach (var m in mediaMenuData) { |
66 | 247 | if (m.isTemporary) | 248 | if (m.isTemporary) |
67 | 248 | temporary_count++; | 249 | temporary_count++; |
68 | 249 | total_count++; | 250 | total_count++; |
69 | @@ -261,7 +262,7 @@ | |||
70 | 261 | } | 262 | } |
71 | 262 | 263 | ||
72 | 263 | int set_rating = -1; | 264 | int set_rating = -1; |
74 | 264 | foreach (Media m in get_selected_medias ()) { | 265 | foreach (Media m in mediaMenuData) { |
75 | 265 | if (set_rating == -1) { | 266 | if (set_rating == -1) { |
76 | 266 | set_rating = (int) m.rating; | 267 | set_rating = (int) m.rating; |
77 | 267 | } else if (set_rating != m.rating) { | 268 | } else if (set_rating != m.rating) { |
78 | @@ -280,10 +281,9 @@ | |||
79 | 280 | 281 | ||
80 | 281 | try { | 282 | try { |
81 | 282 | var files = new Gee.HashSet<File> (); //for automatic deduplication | 283 | var files = new Gee.HashSet<File> (); //for automatic deduplication |
84 | 283 | var selected_medias = get_selected_medias (); //to avoid querying it every time | 284 | debug ("Number of selected medias obtained by MusicListView class: %u\n", mediaMenuData.length ()); |
83 | 284 | debug ("Number of selected medias obtained by MusicListView class: %u\n", selected_medias.length ()); | ||
85 | 285 | 285 | ||
87 | 286 | foreach (var media in selected_medias) { | 286 | foreach (var media in mediaMenuData) { |
88 | 287 | if (media.file.query_exists ()) { | 287 | if (media.file.query_exists ()) { |
89 | 288 | files.add (media.file); | 288 | files.add (media.file); |
90 | 289 | //if the file was marked nonexistent, update its status | 289 | //if the file was marked nonexistent, update its status |
91 | @@ -301,7 +301,7 @@ | |||
92 | 301 | 301 | ||
93 | 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 ()); |
94 | 303 | foreach (var contract in contracts) { | 303 | foreach (var contract in contracts) { |
96 | 304 | var menu_item = new ContractMenuItem (contract, selected_medias); | 304 | var menu_item = new ContractMenuItem (contract, mediaMenuData); |
97 | 305 | contractorSubMenu.append (menu_item); | 305 | contractorSubMenu.append (menu_item); |
98 | 306 | } | 306 | } |
99 | 307 | this.queue_draw (); | 307 | this.queue_draw (); |
100 | @@ -310,8 +310,8 @@ | |||
101 | 310 | warning ("Failed to obtain Contractor actions: %s", err.message); | 310 | warning ("Failed to obtain Contractor actions: %s", err.message); |
102 | 311 | mediaMenuContractorEntry.sensitive = false; | 311 | mediaMenuContractorEntry.sensitive = false; |
103 | 312 | } | 312 | } |
106 | 313 | 313 | ||
107 | 314 | mediaActionMenu.popup (null, null, null, 3, Gtk.get_current_event_time()); | 314 | popupMediaMenu(); |
108 | 315 | 315 | ||
109 | 316 | return true; | 316 | return true; |
110 | 317 | } | 317 | } |
111 | @@ -391,12 +391,31 @@ | |||
112 | 391 | tvs.sort_direction = sort_dir; | 391 | tvs.sort_direction = sort_dir; |
113 | 392 | } | 392 | } |
114 | 393 | 393 | ||
115 | 394 | public void popupMediaMenu (bool data_is_cur_playing = false) { | ||
116 | 395 | mediaMenuData.foreach((x) => { | ||
117 | 396 | mediaMenuData.remove(x); | ||
118 | 397 | }); | ||
119 | 398 | |||
120 | 399 | if (data_is_cur_playing) { | ||
121 | 400 | mediaMenuData.append (App.player.media_info.media); | ||
122 | 401 | mediaScrollToCurrent.hide(); | ||
123 | 402 | mediaScrollToCurrentSeparator.hide(); | ||
124 | 403 | } | ||
125 | 404 | else { | ||
126 | 405 | mediaMenuData = get_selected_medias (); | ||
127 | 406 | mediaScrollToCurrent.show(); | ||
128 | 407 | mediaScrollToCurrentSeparator.show(); | ||
129 | 408 | } | ||
130 | 409 | |||
131 | 410 | mediaActionMenu.popup (null, null, null, 3, Gtk.get_current_event_time()); | ||
132 | 411 | } | ||
133 | 412 | |||
134 | 394 | /** media menu popup clicks **/ | 413 | /** media menu popup clicks **/ |
135 | 395 | void mediaMenuEditClicked () { | 414 | void mediaMenuEditClicked () { |
136 | 396 | var to_edit = new Gee.LinkedList<int> (); | 415 | var to_edit = new Gee.LinkedList<int> (); |
137 | 397 | var to_edit_med = new Gee.LinkedList<Media> (); | 416 | var to_edit_med = new Gee.LinkedList<Media> (); |
138 | 398 | 417 | ||
140 | 399 | foreach (Media m in get_selected_medias ()) { | 418 | foreach (Media m in mediaMenuData) { |
141 | 400 | to_edit.add (m.rowid); | 419 | to_edit.add (m.rowid); |
142 | 401 | if (to_edit.size == 1) | 420 | if (to_edit.size == 1) |
143 | 402 | to_edit_med.add (m); | 421 | to_edit_med.add (m); |
144 | @@ -435,7 +454,7 @@ | |||
145 | 435 | } | 454 | } |
146 | 436 | 455 | ||
147 | 437 | protected void mediaFileBrowseClicked () { | 456 | protected void mediaFileBrowseClicked () { |
149 | 438 | foreach (Media m in get_selected_medias ()) { | 457 | foreach (Media m in mediaMenuData) { |
150 | 439 | try { | 458 | try { |
151 | 440 | var file = File.new_for_uri (m.uri); | 459 | var file = File.new_for_uri (m.uri); |
152 | 441 | Gtk.show_uri (null, file.get_parent ().get_uri (), 0); | 460 | Gtk.show_uri (null, file.get_parent ().get_uri (), 0); |
153 | @@ -450,7 +469,7 @@ | |||
154 | 450 | protected virtual void mediaMenuQueueClicked () { | 469 | protected virtual void mediaMenuQueueClicked () { |
155 | 451 | var to_queue = new Gee.LinkedList<Media> (); | 470 | var to_queue = new Gee.LinkedList<Media> (); |
156 | 452 | 471 | ||
158 | 453 | foreach (Media m in get_selected_medias ()) { | 472 | foreach (Media m in mediaMenuData) { |
159 | 454 | to_queue.add (m); | 473 | to_queue.add (m); |
160 | 455 | } | 474 | } |
161 | 456 | 475 | ||
162 | @@ -461,7 +480,7 @@ | |||
163 | 461 | var p = new StaticPlaylist (); | 480 | var p = new StaticPlaylist (); |
164 | 462 | 481 | ||
165 | 463 | var to_add = new Gee.LinkedList<Media> (); | 482 | var to_add = new Gee.LinkedList<Media> (); |
167 | 464 | foreach (Media m in get_selected_medias ()) { | 483 | foreach (Media m in mediaMenuData) { |
168 | 465 | to_add.add (m); | 484 | to_add.add (m); |
169 | 466 | } | 485 | } |
170 | 467 | p.add_medias (to_add); | 486 | p.add_medias (to_add); |
171 | @@ -473,7 +492,7 @@ | |||
172 | 473 | var los = new Gee.LinkedList<Media> (); | 492 | var los = new Gee.LinkedList<Media> (); |
173 | 474 | int new_rating = mediaRateMedia.rating_value; | 493 | int new_rating = mediaRateMedia.rating_value; |
174 | 475 | 494 | ||
176 | 476 | foreach (Media m in get_selected_medias ()) { | 495 | foreach (Media m in mediaMenuData) { |
177 | 477 | m.rating = new_rating; | 496 | m.rating = new_rating; |
178 | 478 | los.add (m); | 497 | los.add (m); |
179 | 479 | } | 498 | } |
180 | @@ -483,7 +502,7 @@ | |||
181 | 483 | protected override void mediaRemoveClicked () { | 502 | protected override void mediaRemoveClicked () { |
182 | 484 | var to_remove = new Gee.LinkedList<Media> (); | 503 | var to_remove = new Gee.LinkedList<Media> (); |
183 | 485 | 504 | ||
185 | 486 | foreach (Media m in get_selected_medias ()) { | 505 | foreach (Media m in mediaMenuData) { |
186 | 487 | to_remove.add (m); | 506 | to_remove.add (m); |
187 | 488 | } | 507 | } |
188 | 489 | 508 | ||
189 | @@ -505,7 +524,7 @@ | |||
190 | 505 | void importToLibraryClicked () { | 524 | void importToLibraryClicked () { |
191 | 506 | var to_import = new Gee.LinkedList<Media> (); | 525 | var to_import = new Gee.LinkedList<Media> (); |
192 | 507 | 526 | ||
194 | 508 | foreach (Media m in get_selected_medias ()) { | 527 | foreach (Media m in mediaMenuData) { |
195 | 509 | to_import.add (m); | 528 | to_import.add (m); |
196 | 510 | } | 529 | } |
197 | 511 | 530 | ||
198 | @@ -515,7 +534,7 @@ | |||
199 | 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_) { |
200 | 516 | string[] uris = null; | 535 | string[] uris = null; |
201 | 517 | 536 | ||
203 | 518 | foreach (Media m in get_selected_medias ()) { | 537 | foreach (Media m in mediaMenuData) { |
204 | 519 | debug ("adding %s\n", m.uri); | 538 | debug ("adding %s\n", m.uri); |
205 | 520 | uris += (m.uri); | 539 | uris += (m.uri); |
206 | 521 | } | 540 | } |
207 | 522 | 541 | ||
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 | 22 | */ | 22 | */ |
213 | 23 | 23 | ||
214 | 24 | public class Noise.MusicViewWrapper : ViewWrapper { | 24 | public class Noise.MusicViewWrapper : ViewWrapper { |
217 | 25 | 25 | public MusicViewWrapper (TreeViewSetup? tvs = null, Library library, TopDisplay topDisplay) { | |
216 | 26 | public MusicViewWrapper (TreeViewSetup? tvs = null, Library library) { | ||
218 | 27 | base (Hint.MUSIC, library); | 26 | base (Hint.MUSIC, library); |
220 | 28 | build_async.begin (tvs); | 27 | build_async.begin (tvs, topDisplay); |
221 | 29 | } | 28 | } |
222 | 30 | 29 | ||
223 | 31 | private Gee.HashMap<unowned Device, int> _devices; | 30 | private Gee.HashMap<unowned Device, int> _devices; |
224 | 32 | 31 | ||
226 | 33 | private async void build_async (TreeViewSetup? tvs = null) { | 32 | private async void build_async (TreeViewSetup? tvs = null, TopDisplay topDisplay) { |
227 | 34 | Idle.add_full (VIEW_CONSTRUCT_PRIORITY, build_async.callback); | 33 | Idle.add_full (VIEW_CONSTRUCT_PRIORITY, build_async.callback); |
228 | 35 | yield; | 34 | yield; |
229 | 36 | // Add grid view | 35 | // Add grid view |
230 | @@ -45,6 +44,7 @@ | |||
231 | 45 | else | 44 | else |
232 | 46 | music_setup = tvs; | 45 | music_setup = tvs; |
233 | 47 | list_view = new ListView (this, music_setup, true); | 46 | list_view = new ListView (this, music_setup, true); |
234 | 47 | topDisplay.set_list_view(list_view.list_view); | ||
235 | 48 | 48 | ||
236 | 49 | // Welcome screen | 49 | // Welcome screen |
237 | 50 | welcome_screen = new Granite.Widgets.Welcome (_("Get Some Tunes"), | 50 | welcome_screen = new Granite.Widgets.Welcome (_("Get Some Tunes"), |
238 | @@ -165,4 +165,4 @@ | |||
239 | 165 | } | 165 | } |
240 | 166 | } | 166 | } |
241 | 167 | } | 167 | } |
242 | 168 | } | ||
243 | 169 | \ No newline at end of file | 168 | \ No newline at end of file |
244 | 169 | } | ||
245 | 170 | 170 | ||
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 | 28 | Gtk.Scale scale; | 28 | Gtk.Scale scale; |
251 | 29 | Gtk.ProgressBar progressbar; | 29 | Gtk.ProgressBar progressbar; |
252 | 30 | Gtk.Button cancelButton; | 30 | Gtk.Button cancelButton; |
253 | 31 | MusicListView list_view; | ||
254 | 31 | 32 | ||
255 | 32 | private bool is_seeking = false; | 33 | private bool is_seeking = false; |
256 | 33 | private uint timeout_id = 0; | 34 | private uint timeout_id = 0; |
257 | @@ -62,6 +63,9 @@ | |||
258 | 62 | label.set_justify (Gtk.Justification.CENTER); | 63 | label.set_justify (Gtk.Justification.CENTER); |
259 | 63 | label.set_single_line_mode (false); | 64 | label.set_single_line_mode (false); |
260 | 64 | label.ellipsize = Pango.EllipsizeMode.END; | 65 | label.ellipsize = Pango.EllipsizeMode.END; |
261 | 66 | var label_eventbox = new Gtk.EventBox(); | ||
262 | 67 | label_eventbox.add(label); | ||
263 | 68 | label_eventbox.button_press_event.connect(label_clicked); | ||
264 | 65 | 69 | ||
265 | 66 | cancelButton.set_image (Icons.PROCESS_STOP.render_image (Gtk.IconSize.MENU)); | 70 | cancelButton.set_image (Icons.PROCESS_STOP.render_image (Gtk.IconSize.MENU)); |
266 | 67 | cancelButton.set_relief (Gtk.ReliefStyle.NONE); | 71 | cancelButton.set_relief (Gtk.ReliefStyle.NONE); |
267 | @@ -71,7 +75,7 @@ | |||
268 | 71 | 75 | ||
269 | 72 | // all but cancel | 76 | // all but cancel |
270 | 73 | var info = new Gtk.Grid (); | 77 | var info = new Gtk.Grid (); |
272 | 74 | info.attach (label, 0, 0, 1, 1); | 78 | info.attach (label_eventbox, 0, 0, 1, 1); |
273 | 75 | info.attach (progressbar, 0, 1, 1, 1); | 79 | info.attach (progressbar, 0, 1, 1, 1); |
274 | 76 | info.attach (scale_grid, 0, 1, 1, 1); | 80 | info.attach (scale_grid, 0, 1, 1, 1); |
275 | 77 | 81 | ||
276 | @@ -110,6 +114,10 @@ | |||
277 | 110 | libraries_manager.local_library.media_updated.connect(media_updated); | 114 | libraries_manager.local_library.media_updated.connect(media_updated); |
278 | 111 | } | 115 | } |
279 | 112 | 116 | ||
280 | 117 | public void set_list_view(MusicListView list_view) { | ||
281 | 118 | this.list_view = list_view; | ||
282 | 119 | } | ||
283 | 120 | |||
284 | 113 | /** label functions **/ | 121 | /** label functions **/ |
285 | 114 | public void set_label_text(string text) { | 122 | public void set_label_text(string text) { |
286 | 115 | label.set_text(text); | 123 | label.set_text(text); |
287 | @@ -127,6 +135,15 @@ | |||
288 | 127 | label.set_visible (val); | 135 | label.set_visible (val); |
289 | 128 | } | 136 | } |
290 | 129 | 137 | ||
291 | 138 | public virtual bool label_clicked (Gdk.EventButton event) { | ||
292 | 139 | if (event.button == 3) { | ||
293 | 140 | list_view.popupMediaMenu (true); | ||
294 | 141 | return true; | ||
295 | 142 | } | ||
296 | 143 | |||
297 | 144 | return false; | ||
298 | 145 | } | ||
299 | 146 | |||
300 | 130 | /** progressbar functions **/ | 147 | /** progressbar functions **/ |
301 | 131 | public void set_scale_sensitivity (bool val) { | 148 | public void set_scale_sensitivity (bool val) { |
302 | 132 | scale.set_sensitive(val); | 149 | scale.set_sensitive(val); |
303 | @@ -304,4 +321,4 @@ | |||
304 | 304 | set_media (current_media); | 321 | set_media (current_media); |
305 | 305 | } | 322 | } |
306 | 306 | } | 323 | } |
307 | 307 | } | ||
308 | 308 | \ No newline at end of file | 324 | \ No newline at end of file |
309 | 325 | } |
The "Other Actions" and "Add to Playlist" submenus don't seem to be populated until after a submenu is activated elsewhere in the app