← Back to team overview

nuvola-player-devel team mailing list archive

[Merge] lp:~fenryxo/nuvola-player/rdio-nav-buttons into lp:nuvola-player

 

Jiří Janoušek has proposed merging lp:~fenryxo/nuvola-player/rdio-nav-buttons into lp:nuvola-player.

Requested reviews:
  Michael Mims (mims-michael)
Related bugs:
  Bug #1212167 in Nuvola Player: "feature request: 'back' and 'forward' buttons, integrated with the service"
  https://bugs.launchpad.net/nuvola-player/+bug/1212167

For more details, see:
https://code.launchpad.net/~fenryxo/nuvola-player/rdio-nav-buttons/+merge/219324

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

Rdio: implemented integrated navigation buttons, see bug LP:1212167.
-- 
https://code.launchpad.net/~fenryxo/nuvola-player/rdio-nav-buttons/+merge/219324
Your team Nuvola Player Development is subscribed to branch lp:nuvola-player.
=== modified file 'data/nuvolaplayer/services/googleplay/integration.js'
--- data/nuvolaplayer/services/googleplay/integration.js	2014-05-04 12:17:37 +0000
+++ data/nuvolaplayer/services/googleplay/integration.js	2014-05-13 09:48:56 +0000
@@ -1,6 +1,6 @@
 /*
  * Copyright 2011-2014 Jiří Janoušek <janousek.jiri@xxxxxxxxx>
- * Copyright 2014 Martin Pöhlmann <http://mpdeimos.com>
+ * Copyright 2014 Martin Pöhlmann <martin.deimos@xxxxxx>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met: 

=== modified file 'data/nuvolaplayer/services/rdio/integration.js'
--- data/nuvolaplayer/services/rdio/integration.js	2013-12-22 18:57:54 +0000
+++ data/nuvolaplayer/services/rdio/integration.js	2014-05-13 09:48:56 +0000
@@ -1,6 +1,8 @@
 /*
  * Copyright 2013 Michael Mims <mims.michael@xxxxxxxxx>
- *
+ * Copyright 2014 Martin Pöhlmann <martin.deimos@xxxxxx>
+ * Copyright 2014 Jiří Janoušek <janousek.jiri@xxxxxxxxx>
+ * 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met: 
  * 
@@ -37,12 +39,13 @@
 		Nuvola.onMessageReceived = Nuvola.bind(this, this.messageHandler);
 		
 		/* For debug output */
-		this.name = "Rdio";		
+		this.name = "Rdio";
 		
 		/* Let's run */
 		this.state = Nuvola.STATE_NONE;
 		this.firstPlayToggled = false;
 		this.update();
+		this.integrateNavigationButtons();
 	};
 
 	/**
@@ -85,7 +88,7 @@
 		var can_next;
 
 		try{
-			var playingTrack = R.Services.Player.model.get("playingTrack").attributes;				
+			var playingTrack = R.Services.Player.model.get("playingTrack").attributes;
 			album_art = playingTrack.icon;
 			album = playingTrack.album;
 			artist = playingTrack.artist;
@@ -144,7 +147,12 @@
 	 * Command handler
 	 * @param cmd command to execute
 	 */
-	Integration.prototype.messageHandler = function(cmd){
+	Integration.prototype.messageHandler = function(cmd, param1, param2){
+		// Return if navigation buttons are enabled and can handle this event.
+		if (this.navigationButtons !== undefined 
+		&& this.navigationButtons.onMessageReceived(cmd, param1, param2) === true)
+			return;
+		
 		try{
 			switch(cmd){
 			case Nuvola.ACTION_PLAY:
@@ -173,6 +181,69 @@
 			throw (this.name + ": " + e.message);
 		}
 	}
+	
+	Integration.prototype.getSearchContainer = function()
+	{
+		return document.querySelector("#header .search_container");
+	}
+	
+	Integration.prototype.integrateNavigationButtons = function()
+	{
+		// This feature is disabled on pre 2.4.0
+		if (Nuvola.NavigationButtonIntegration === undefined)
+			return;
+		
+		if (!this.getSearchContainer())
+		{
+			console.log("Could not find the search box.");
+			setTimeout(Nuvola.bind(this, this.integrateNavigationButtons), 500);
+			return;
+		}
+		
+		var marginTop = "20px";
+		var navigateBack = this.navigateBack = Nuvola.makeElement("button", null, "<");
+		navigateBack.className = "button";
+		navigateBack.style.float = "left";
+		navigateBack.style.marginRight = "0px";
+		navigateBack.style.marginTop = marginTop;
+		navigateBack.style.borderTopRightRadius = "0px";
+		navigateBack.style.borderBottomRightRadius = "0px";
+		navigateBack.style.verticalAlign = "middle";
+		
+		var navigateForward = this. navigateForward = Nuvola.makeElement("button", null, ">");
+		navigateForward.className = "button";
+		navigateForward.style.float = "left";
+		navigateForward.style.marginRight = "15px";
+		navigateForward.style.marginTop = marginTop;
+		navigateForward.style.borderLeft = "none";
+		navigateForward.style.borderTopLeftRadius = "0px";
+		navigateForward.style.borderBottomLeftRadius = "0px";
+		
+		this.insertNavigationButtons();
+		this.navigationButtons = new Nuvola.NavigationButtonIntegration(navigateBack, navigateForward);
+		
+		// The #header element is occasionally removed from the DOM tree,
+		// so we need to re-insert our navigation buttons.
+		$("body").bind("DOMNodeRemoved", Nuvola.bind(this, function(e)
+		{
+			if (e.target.id == "header")
+				setTimeout(Nuvola.bind(this, this.insertNavigationButtons), 100);
+		}));
+	}
+	
+	Integration.prototype.insertNavigationButtons = function()
+	{
+		var cursor = this.getSearchContainer();
+		if (!cursor)
+		{
+			setTimeout(Nuvola.bind(this, this.insertNavigationButtons), 500);
+			return;
+		}
+		
+		var container = cursor.parentNode;
+		container.insertBefore(this.navigateBack, cursor);
+		container.insertBefore(this.navigateForward, cursor);
+	}
 
 	/* Store reference */ 
 	Nuvola.integration = new Integration(); // Singleton

=== modified file 'setup_env.sh'
--- setup_env.sh	2014-01-12 18:17:57 +0000
+++ setup_env.sh	2014-05-13 09:48:56 +0000
@@ -5,7 +5,7 @@
 export LD_LIBRARY_PATH=./build
 
 # rebuild whole project
-alias rebuild='./waf distclean configure --no-unity-quick-list build '
+alias rebuild='./waf distclean configure --with-gstreamer=1.0 build '
 # build without tests and run NP
 alias debug='./waf build --skip-tests && ./nuvolaplayer.wrapper -D '
 # launch GUI demos


Follow ups