[gnome-music/wip/jfelder/mpris-cleanup: 3/17] mpris: Rename MediaPlayer2Service class to MPRIS
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/mpris-cleanup: 3/17] mpris: Rename MediaPlayer2Service class to MPRIS
- Date: Thu, 6 Jun 2019 07:24:43 +0000 (UTC)
commit 9cf34f4e0d6d6899bf1e3d3a3334f40b3ccfdb1a
Author: Jean Felder <jfelder src gnome org>
Date: Tue Oct 23 15:32:33 2018 +0200
mpris: Rename MediaPlayer2Service class to MPRIS
MediaPlayer2Service name is too long and it's not really accurate.
gnomemusic/application.py | 4 ++--
gnomemusic/mpris.py | 39 +++++++++++++++++++--------------------
2 files changed, 21 insertions(+), 22 deletions(-)
---
diff --git a/gnomemusic/application.py b/gnomemusic/application.py
index 3cb88ed1..6f505399 100644
--- a/gnomemusic/application.py
+++ b/gnomemusic/application.py
@@ -37,7 +37,7 @@ from gi.repository import Gtk, Gio, GLib, Gdk, GObject
from gnomemusic import log
from gnomemusic.inhibitsuspend import InhibitSuspend
-from gnomemusic.mpris import MediaPlayer2Service
+from gnomemusic.mpris import MPRIS
from gnomemusic.pauseonsuspend import PauseOnSuspend
from gnomemusic.player import Player
from gnomemusic.widgets.aboutdialog import AboutDialog
@@ -137,7 +137,7 @@ class Application(Gtk.Application):
self._window.set_default_icon_name(self.props.application_id)
if self.props.application_id == 'org.gnome.MusicDevel':
self._window.get_style_context().add_class('devel')
- MediaPlayer2Service(self)
+ MPRIS(self)
# gtk_window_present does not work on Wayland.
# Use gtk_present_with_time as a workaround instead.
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index 4ae1b478..0736faa4 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -94,7 +94,7 @@ class DBusInterface:
invocation.return_value(None)
-class MediaPlayer2Service(DBusInterface):
+class MPRIS(DBusInterface):
'''
<!DOCTYPE node PUBLIC '-//freedesktop//DTD D-BUS Object Introspection 1.0//EN'
'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd'>
@@ -234,7 +234,7 @@ class MediaPlayer2Service(DBusInterface):
MEDIA_PLAYER2_PLAYLISTS_IFACE = 'org.mpris.MediaPlayer2.Playlists'
def __repr__(self):
- return '<MediaPlayer2Service>'
+ return "<MPRIS>"
def __init__(self, app):
self.con = Gio.bus_get_sync(Gio.BusType.SESSION, None)
@@ -489,7 +489,7 @@ class MediaPlayer2Service(DBusInterface):
self._previous_can_play = True
self.PropertiesChanged(
- MediaPlayer2Service.MEDIA_PLAYER2_PLAYER_IFACE, properties, [])
+ MPRIS.MEDIA_PLAYER2_PLAYER_IFACE, properties, [])
@log
def _on_player_state_changed(self, klass, args):
@@ -498,7 +498,7 @@ class MediaPlayer2Service(DBusInterface):
return
self._previous_playback_status = playback_status
- self.PropertiesChanged(MediaPlayer2Service.MEDIA_PLAYER2_PLAYER_IFACE,
+ self.PropertiesChanged(MPRIS.MEDIA_PLAYER2_PLAYER_IFACE,
{
'PlaybackStatus': GLib.Variant('s', playback_status),
},
@@ -523,7 +523,7 @@ class MediaPlayer2Service(DBusInterface):
if not properties:
return
self.PropertiesChanged(
- MediaPlayer2Service.MEDIA_PLAYER2_PLAYER_IFACE, properties, [])
+ MPRIS.MEDIA_PLAYER2_PLAYER_IFACE, properties, [])
@log
def _on_seek_finished(self, player, position_second):
@@ -541,14 +541,14 @@ class MediaPlayer2Service(DBusInterface):
properties = {
"ActivePlaylist": GLib.Variant("(b(oss))", mpris_playlist)}
self.PropertiesChanged(
- MediaPlayer2Service.MEDIA_PLAYER2_PLAYLISTS_IFACE, properties, [])
+ MPRIS.MEDIA_PLAYER2_PLAYLISTS_IFACE, properties, [])
@log
def _reload_playlists(self):
def query_playlists_callback(playlists):
self._stored_playlists = playlists
self.PropertiesChanged(
- MediaPlayer2Service.MEDIA_PLAYER2_PLAYLISTS_IFACE,
+ MPRIS.MEDIA_PLAYER2_PLAYLISTS_IFACE,
{'PlaylistCount': GLib.Variant('u', len(playlists)), }, [])
self._query_playlists(query_playlists_callback)
@@ -563,8 +563,7 @@ class MediaPlayer2Service(DBusInterface):
renamed_playlist)
self.con.emit_signal(
None, '/org/mpris/MediaPlayer2',
- MediaPlayer2Service.MEDIA_PLAYER2_PLAYLISTS_IFACE,
- 'PlaylistChanged',
+ MPRIS.MEDIA_PLAYER2_PLAYLISTS_IFACE, 'PlaylistChanged',
GLib.Variant.new_tuple(GLib.Variant('(oss)', mpris_playlist)))
@log
@@ -637,7 +636,7 @@ class MediaPlayer2Service(DBusInterface):
variant = GLib.Variant.new_tuple(GLib.Variant('x', position_msecond))
self.con.emit_signal(
None, '/org/mpris/MediaPlayer2',
- MediaPlayer2Service.MEDIA_PLAYER2_PLAYER_IFACE, 'Seeked', variant)
+ MPRIS.MEDIA_PLAYER2_PLAYER_IFACE, 'Seeked', variant)
def GetTracksMetadata(self, track_paths):
metadata = []
@@ -662,7 +661,7 @@ class MediaPlayer2Service(DBusInterface):
def TrackListReplaced(self, tracks, current_song):
self.con.emit_signal(None,
'/org/mpris/MediaPlayer2',
- MediaPlayer2Service.MEDIA_PLAYER2_TRACKLIST_IFACE,
+ MPRIS.MEDIA_PLAYER2_TRACKLIST_IFACE,
'TrackListReplaced',
GLib.Variant.new_tuple(GLib.Variant('ao', tracks),
GLib.Variant('o', current_song)))
@@ -670,7 +669,7 @@ class MediaPlayer2Service(DBusInterface):
def TrackAdded(self, metadata, after_track):
self.con.emit_signal(None,
'/org/mpris/MediaPlayer2',
- MediaPlayer2Service.MEDIA_PLAYER2_TRACKLIST_IFACE,
+ MPRIS.MEDIA_PLAYER2_TRACKLIST_IFACE,
'TrackAdded',
GLib.Variant.new_tuple(GLib.Variant('a{sv}', metadata),
GLib.Variant('o', after_track)))
@@ -678,13 +677,13 @@ class MediaPlayer2Service(DBusInterface):
def TrackRemoved(self, path):
self.con.emit_signal(
None, '/org/mpris/MediaPlayer2',
- MediaPlayer2Service.MEDIA_PLAYER2_TRACKLIST_IFACE, 'TrackRemoved',
+ MPRIS.MEDIA_PLAYER2_TRACKLIST_IFACE, 'TrackRemoved',
GLib.Variant.new_tuple(GLib.Variant('o', path)))
def TrackMetadataChanged(self, path, metadata):
self.con.emit_signal(
None, '/org/mpris/MediaPlayer2',
- MediaPlayer2Service.MEDIA_PLAYER2_TRACKLIST_IFACE,
+ MPRIS.MEDIA_PLAYER2_TRACKLIST_IFACE,
'TrackMetadataChanged',
GLib.Variant.new_tuple(
GLib.Variant('o', path), GLib.Variant('a{sv}', metadata)))
@@ -721,7 +720,7 @@ class MediaPlayer2Service(DBusInterface):
return self.GetAll(interface_name)[property_name]
def GetAll(self, interface_name):
- if interface_name == MediaPlayer2Service.MEDIA_PLAYER2_IFACE:
+ if interface_name == MPRIS.MEDIA_PLAYER2_IFACE:
application_id = self.app.props.application_id
return {
'CanQuit': GLib.Variant('b', True),
@@ -741,7 +740,7 @@ class MediaPlayer2Service(DBusInterface):
'audio/mpeg'
]),
}
- elif interface_name == MediaPlayer2Service.MEDIA_PLAYER2_PLAYER_IFACE:
+ elif interface_name == MPRIS.MEDIA_PLAYER2_PLAYER_IFACE:
position_msecond = int(self.player.get_position() * 1e6)
return {
'PlaybackStatus': GLib.Variant('s', self._get_playback_status()),
@@ -759,12 +758,12 @@ class MediaPlayer2Service(DBusInterface):
'CanSeek': GLib.Variant('b', True),
'CanControl': GLib.Variant('b', True),
}
- elif interface_name == MediaPlayer2Service.MEDIA_PLAYER2_TRACKLIST_IFACE:
+ elif interface_name == MPRIS.MEDIA_PLAYER2_TRACKLIST_IFACE:
return {
'Tracks': GLib.Variant('ao', self._path_list),
'CanEditTracks': GLib.Variant('b', False)
}
- elif interface_name == MediaPlayer2Service.MEDIA_PLAYER2_PLAYLISTS_IFACE:
+ elif interface_name == MPRIS.MEDIA_PLAYER2_PLAYLISTS_IFACE:
playlist_count = len(self._stored_playlists)
return {
'PlaylistCount': GLib.Variant('u', playlist_count),
@@ -780,10 +779,10 @@ class MediaPlayer2Service(DBusInterface):
"MPRIS does not implement {} interface".format(interface_name))
def Set(self, interface_name, property_name, new_value):
- if interface_name == MediaPlayer2Service.MEDIA_PLAYER2_IFACE:
+ if interface_name == MPRIS.MEDIA_PLAYER2_IFACE:
if property_name == 'Fullscreen':
pass
- elif interface_name == MediaPlayer2Service.MEDIA_PLAYER2_PLAYER_IFACE:
+ elif interface_name == MPRIS.MEDIA_PLAYER2_PLAYER_IFACE:
if property_name in ['Rate', 'Volume']:
pass
elif property_name == 'LoopStatus':
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]