Merge lp:~fenryxo/nuvola-player/rdio-nav-buttons into lp:nuvola-player/2.5.x

Proposed by Jiří Janoušek
Status: Merged
Merged at revision: 827
Proposed branch: lp:~fenryxo/nuvola-player/rdio-nav-buttons
Merge into: lp:nuvola-player/2.5.x
Diff against target: 146 lines (+77/-6)
3 files modified
data/nuvolaplayer/services/googleplay/integration.js (+1/-1)
data/nuvolaplayer/services/rdio/integration.js (+75/-4)
setup_env.sh (+1/-1)
To merge this branch: bzr merge lp:~fenryxo/nuvola-player/rdio-nav-buttons
Reviewer Review Type Date Requested Status
Michael Mims Pending
Review via email: mp+219324@code.launchpad.net

Description of the change

Michael, could you review following change I've made to your Rdio integration?

Rdio: implemented integrated navigation buttons, see bug LP:1212167.

To post a comment you must log in.
Revision history for this message
Michael Mims (mims-michael) wrote :

Sorry, I haven't had a chance to get to this yet. I reformatted my system recently, so I need to set up a dev environment again. I'll try to look at it this weekend.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/nuvolaplayer/services/googleplay/integration.js'
2--- data/nuvolaplayer/services/googleplay/integration.js 2014-05-04 12:17:37 +0000
3+++ data/nuvolaplayer/services/googleplay/integration.js 2014-05-13 09:48:56 +0000
4@@ -1,6 +1,6 @@
5 /*
6 * Copyright 2011-2014 Jiří Janoušek <janousek.jiri@gmail.com>
7- * Copyright 2014 Martin Pöhlmann <http://mpdeimos.com>
8+ * Copyright 2014 Martin Pöhlmann <martin.deimos@gmx.de>
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12
13=== modified file 'data/nuvolaplayer/services/rdio/integration.js'
14--- data/nuvolaplayer/services/rdio/integration.js 2013-12-22 18:57:54 +0000
15+++ data/nuvolaplayer/services/rdio/integration.js 2014-05-13 09:48:56 +0000
16@@ -1,6 +1,8 @@
17 /*
18 * Copyright 2013 Michael Mims <mims.michael@gmail.com>
19- *
20+ * Copyright 2014 Martin Pöhlmann <martin.deimos@gmx.de>
21+ * Copyright 2014 Jiří Janoušek <janousek.jiri@gmail.com>
22+ *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions are met:
25 *
26@@ -37,12 +39,13 @@
27 Nuvola.onMessageReceived = Nuvola.bind(this, this.messageHandler);
28
29 /* For debug output */
30- this.name = "Rdio";
31+ this.name = "Rdio";
32
33 /* Let's run */
34 this.state = Nuvola.STATE_NONE;
35 this.firstPlayToggled = false;
36 this.update();
37+ this.integrateNavigationButtons();
38 };
39
40 /**
41@@ -85,7 +88,7 @@
42 var can_next;
43
44 try{
45- var playingTrack = R.Services.Player.model.get("playingTrack").attributes;
46+ var playingTrack = R.Services.Player.model.get("playingTrack").attributes;
47 album_art = playingTrack.icon;
48 album = playingTrack.album;
49 artist = playingTrack.artist;
50@@ -144,7 +147,12 @@
51 * Command handler
52 * @param cmd command to execute
53 */
54- Integration.prototype.messageHandler = function(cmd){
55+ Integration.prototype.messageHandler = function(cmd, param1, param2){
56+ // Return if navigation buttons are enabled and can handle this event.
57+ if (this.navigationButtons !== undefined
58+ && this.navigationButtons.onMessageReceived(cmd, param1, param2) === true)
59+ return;
60+
61 try{
62 switch(cmd){
63 case Nuvola.ACTION_PLAY:
64@@ -173,6 +181,69 @@
65 throw (this.name + ": " + e.message);
66 }
67 }
68+
69+ Integration.prototype.getSearchContainer = function()
70+ {
71+ return document.querySelector("#header .search_container");
72+ }
73+
74+ Integration.prototype.integrateNavigationButtons = function()
75+ {
76+ // This feature is disabled on pre 2.4.0
77+ if (Nuvola.NavigationButtonIntegration === undefined)
78+ return;
79+
80+ if (!this.getSearchContainer())
81+ {
82+ console.log("Could not find the search box.");
83+ setTimeout(Nuvola.bind(this, this.integrateNavigationButtons), 500);
84+ return;
85+ }
86+
87+ var marginTop = "20px";
88+ var navigateBack = this.navigateBack = Nuvola.makeElement("button", null, "<");
89+ navigateBack.className = "button";
90+ navigateBack.style.float = "left";
91+ navigateBack.style.marginRight = "0px";
92+ navigateBack.style.marginTop = marginTop;
93+ navigateBack.style.borderTopRightRadius = "0px";
94+ navigateBack.style.borderBottomRightRadius = "0px";
95+ navigateBack.style.verticalAlign = "middle";
96+
97+ var navigateForward = this. navigateForward = Nuvola.makeElement("button", null, ">");
98+ navigateForward.className = "button";
99+ navigateForward.style.float = "left";
100+ navigateForward.style.marginRight = "15px";
101+ navigateForward.style.marginTop = marginTop;
102+ navigateForward.style.borderLeft = "none";
103+ navigateForward.style.borderTopLeftRadius = "0px";
104+ navigateForward.style.borderBottomLeftRadius = "0px";
105+
106+ this.insertNavigationButtons();
107+ this.navigationButtons = new Nuvola.NavigationButtonIntegration(navigateBack, navigateForward);
108+
109+ // The #header element is occasionally removed from the DOM tree,
110+ // so we need to re-insert our navigation buttons.
111+ $("body").bind("DOMNodeRemoved", Nuvola.bind(this, function(e)
112+ {
113+ if (e.target.id == "header")
114+ setTimeout(Nuvola.bind(this, this.insertNavigationButtons), 100);
115+ }));
116+ }
117+
118+ Integration.prototype.insertNavigationButtons = function()
119+ {
120+ var cursor = this.getSearchContainer();
121+ if (!cursor)
122+ {
123+ setTimeout(Nuvola.bind(this, this.insertNavigationButtons), 500);
124+ return;
125+ }
126+
127+ var container = cursor.parentNode;
128+ container.insertBefore(this.navigateBack, cursor);
129+ container.insertBefore(this.navigateForward, cursor);
130+ }
131
132 /* Store reference */
133 Nuvola.integration = new Integration(); // Singleton
134
135=== modified file 'setup_env.sh'
136--- setup_env.sh 2014-01-12 18:17:57 +0000
137+++ setup_env.sh 2014-05-13 09:48:56 +0000
138@@ -5,7 +5,7 @@
139 export LD_LIBRARY_PATH=./build
140
141 # rebuild whole project
142-alias rebuild='./waf distclean configure --no-unity-quick-list build '
143+alias rebuild='./waf distclean configure --with-gstreamer=1.0 build '
144 # build without tests and run NP
145 alias debug='./waf build --skip-tests && ./nuvolaplayer.wrapper -D '
146 # launch GUI demos

Subscribers

People subscribed via source and target branches