[banshee] Mpris: Add CanSetFullscreen and Fullscreen properties (bgo#681890)
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] Mpris: Add CanSetFullscreen and Fullscreen properties (bgo#681890)
- Date: Wed, 15 Aug 2012 16:36:34 +0000 (UTC)
commit a0d66af8cc9d6dbdc1f2112ac16a9c96729336df
Author: Kevin Anthony <kevin s anthony gmail com>
Date: Tue Aug 14 21:11:21 2012 -0400
Mpris: Add CanSetFullscreen and Fullscreen properties (bgo#681890)
This brings our MPRIS support up to version 2.2 of the standard.
Signed-off-by: Bertrand Lorentz <bertrand lorentz gmail com>
.../Banshee.Mpris/Banshee.Mpris/IMediaPlayer.cs | 2 +
.../Banshee.Mpris/Banshee.Mpris/MediaPlayer.cs | 93 +++++++++++++++-----
.../Banshee.Mpris/Banshee.Mpris/MprisService.cs | 19 ++++
3 files changed, 92 insertions(+), 22 deletions(-)
---
diff --git a/src/Extensions/Banshee.Mpris/Banshee.Mpris/IMediaPlayer.cs b/src/Extensions/Banshee.Mpris/Banshee.Mpris/IMediaPlayer.cs
index d2dfc52..f6467c7 100644
--- a/src/Extensions/Banshee.Mpris/Banshee.Mpris/IMediaPlayer.cs
+++ b/src/Extensions/Banshee.Mpris/Banshee.Mpris/IMediaPlayer.cs
@@ -49,6 +49,8 @@ namespace Banshee.Mpris
public interface IMediaPlayer
{
bool CanQuit { get; }
+ bool Fullscreen { get;set; }
+ bool CanSetFullscreen { get; }
bool CanRaise { get; }
bool HasTrackList { get; }
string Identity { get; }
diff --git a/src/Extensions/Banshee.Mpris/Banshee.Mpris/MediaPlayer.cs b/src/Extensions/Banshee.Mpris/Banshee.Mpris/MediaPlayer.cs
index 4badcfe..d7ab5c1 100644
--- a/src/Extensions/Banshee.Mpris/Banshee.Mpris/MediaPlayer.cs
+++ b/src/Extensions/Banshee.Mpris/Banshee.Mpris/MediaPlayer.cs
@@ -52,6 +52,7 @@ namespace Banshee.Mpris
private static string playlists_interface_name = "org.mpris.MediaPlayer2.Playlists";
private PlaybackControllerService playback_service;
private PlayerEngineService engine_service;
+ private Gtk.ToggleAction fullscreen_action;
private Dictionary<string, AbstractPlaylistSource> playlist_sources;
private Dictionary<string, object> changed_properties;
private List<string> invalidated_properties;
@@ -86,6 +87,9 @@ namespace Banshee.Mpris
playlist_sources = new Dictionary<string, AbstractPlaylistSource> ();
changed_properties = new Dictionary<string, object> ();
invalidated_properties = new List<string> ();
+
+ var interface_service = ServiceManager.Get<InterfaceActionService> ();
+ fullscreen_action = interface_service.ViewActions["FullScreenAction"] as Gtk.ToggleAction;
}
#region IMediaPlayer
@@ -98,6 +102,24 @@ namespace Banshee.Mpris
get { return true; }
}
+ public bool Fullscreen {
+ get {
+ if (fullscreen_action != null) {
+ return fullscreen_action.Active;
+ }
+ return false;
+ }
+ set {
+ if (fullscreen_action != null) {
+ fullscreen_action.Active = value;
+ }
+ }
+ }
+
+ public bool CanSetFullscreen {
+ get { return true; }
+ }
+
public bool HasTrackList {
get { return false; }
}
@@ -494,6 +516,17 @@ namespace Banshee.Mpris
}
}
+ public void AddPropertyChange (params MediaPlayerProperties [] properties)
+ {
+ lock (changed_properties) {
+ foreach (MediaPlayerProperties prop in properties) {
+ string prop_name = prop.ToString ();
+ changed_properties[prop_name] = Get (mediaplayer_interface_name, prop_name);
+ }
+ HandlePropertiesChange (mediaplayer_interface_name);
+ }
+ }
+
public void AddPropertyChange (params PlaylistProperties [] properties)
{
lock (changed_properties) {
@@ -509,8 +542,8 @@ namespace Banshee.Mpris
#region Dbus.Properties
- private static string [] mediaplayer_properties = { "CanQuit", "CanRaise", "HasTrackList", "Identity",
- "DesktopEntry", "SupportedMimeTypes", "SupportedUriSchemes" };
+ private static string [] mediaplayer_properties = { "CanQuit", "CanRaise", "CanSetFullscreen", "Fullscreen",
+ "HasTrackList", "Identity", "DesktopEntry", "SupportedMimeTypes", "SupportedUriSchemes" };
private static string [] player_properties = { "CanControl", "CanGoNext", "CanGoPrevious", "CanPause",
"CanPlay", "CanSeek", "LoopStatus", "MaximumRate", "Metadata", "MinimumRate", "PlaybackStatus",
@@ -526,6 +559,10 @@ namespace Banshee.Mpris
return CanQuit;
case "CanRaise":
return CanRaise;
+ case "Fullscreen":
+ return Fullscreen;
+ case "CanSetFullscreen":
+ return CanSetFullscreen;
case "HasTrackList":
return HasTrackList;
case "Identity":
@@ -592,28 +629,33 @@ namespace Banshee.Mpris
public void Set (string interface_name, string propname, object value)
{
- // All writable properties are on the Player interface
- if (interface_name != player_interface_name) {
- return;
- }
-
- switch (propname) {
- case "LoopStatus":
- string s = value as string;
- if (!String.IsNullOrEmpty (s)) {
- LoopStatus = s;
- }
- break;
- case "Shuffle":
- if (value is bool) {
- Shuffle = (bool)value;
+ if (interface_name == player_interface_name) {
+ switch (propname) {
+ case "LoopStatus":
+ string s = value as string;
+ if (!String.IsNullOrEmpty (s)) {
+ LoopStatus = s;
+ }
+ break;
+ case "Shuffle":
+ if (value is bool) {
+ Shuffle = (bool)value;
+ }
+ break;
+ case "Volume":
+ if (value is double) {
+ Volume = (double)value;
+ }
+ break;
}
- break;
- case "Volume":
- if (value is double) {
- Volume = (double)value;
+ } else if (interface_name == mediaplayer_interface_name) {
+ switch (propname) {
+ case "Fullscreen":
+ if (value is bool) {
+ Fullscreen = (bool)value;
+ }
+ break;
}
- break;
}
}
@@ -661,6 +703,13 @@ namespace Banshee.Mpris
Volume
}
+ // Those are all the properties from the MediaPlayer interface that can trigger the PropertiesChanged signal
+ // The names must match exactly the names of the properties
+ public enum MediaPlayerProperties
+ {
+ Fullscreen
+ }
+
// Those are all the properties from the Playlist interface that can trigger the PropertiesChanged signal
// The names must match exactly the names of the properties
public enum PlaylistProperties
diff --git a/src/Extensions/Banshee.Mpris/Banshee.Mpris/MprisService.cs b/src/Extensions/Banshee.Mpris/Banshee.Mpris/MprisService.cs
index 6ab9961..c9ee258 100644
--- a/src/Extensions/Banshee.Mpris/Banshee.Mpris/MprisService.cs
+++ b/src/Extensions/Banshee.Mpris/Banshee.Mpris/MprisService.cs
@@ -32,6 +32,8 @@ using System;
using org.freedesktop.DBus;
using DBus;
using Hyena;
+
+using Banshee.Gui;
using Banshee.MediaEngine;
using Banshee.PlaybackController;
using Banshee.Playlist;
@@ -70,6 +72,12 @@ namespace Banshee.Mpris
ServiceManager.SourceManager.SourceUpdated += OnSourceUpdated;
ServiceManager.PlaybackController.SourceChanged += OnPlayingSourceChanged;
+ var interface_service = ServiceManager.Get<InterfaceActionService> ();
+ var fullscreen_action = interface_service.ViewActions["FullScreenAction"];
+ if (fullscreen_action != null) {
+ fullscreen_action.Activated += OnFullScreenToggled;
+ }
+
player = new MediaPlayer();
Bus.Session.Register (MediaPlayer.Path, player);
@@ -92,6 +100,12 @@ namespace Banshee.Mpris
ServiceManager.SourceManager.SourceUpdated -= OnSourceUpdated;
ServiceManager.PlaybackController.SourceChanged -= OnPlayingSourceChanged;
+ var interface_service = ServiceManager.Get<InterfaceActionService> ();
+ var fullscreen_action = interface_service.ViewActions["FullScreenAction"];
+ if (fullscreen_action != null) {
+ fullscreen_action.Activated -= OnFullScreenToggled;
+ }
+
Bus.Session.ReleaseName (bus_name);
}
@@ -144,6 +158,11 @@ namespace Banshee.Mpris
player.AddPropertyChange (PlaylistProperties.ActivePlaylist);
}
+ private void OnFullScreenToggled (object o, EventArgs args)
+ {
+ player.AddPropertyChange (MediaPlayerProperties.Fullscreen);
+ }
+
string IService.ServiceName {
get { return "MprisService"; }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]