[gnome-music/wip/jfelder/mpris-cleanup: 18/38] mpris: Rename MediaPlayer2Service class to MPRIS



commit f3998eddc05568f751c6bf255fee32290b479e2d
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       | 40 ++++++++++++++++++++--------------------
 2 files changed, 22 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 32c0c032..ac5db9f9 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -93,7 +93,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'>
@@ -233,7 +233,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)
@@ -375,7 +375,7 @@ class MediaPlayer2Service(DBusInterface):
             current_song_path = self._get_song_dbus_path()
             self.TrackListReplaced(self._path_list, current_song_path)
             self.PropertiesChanged(
-                MediaPlayer2Service.MEDIA_PLAYER2_TRACKLIST_IFACE,
+                MPRIS.MEDIA_PLAYER2_TRACKLIST_IFACE,
                 {'Tracks': GLib.Variant('ao', self._path_list), }, [])
 
     @log
@@ -453,7 +453,7 @@ class MediaPlayer2Service(DBusInterface):
 
         has_next = self.player.props.has_next
         has_previous = self.player.props.has_previous
-        self.PropertiesChanged(MediaPlayer2Service.MEDIA_PLAYER2_PLAYER_IFACE,
+        self.PropertiesChanged(MPRIS.MEDIA_PLAYER2_PLAYER_IFACE,
                                {
                                    'Metadata': GLib.Variant('a{sv}', self._get_metadata()),
                                    'CanGoNext': GLib.Variant('b', has_next),
@@ -466,7 +466,7 @@ class MediaPlayer2Service(DBusInterface):
 
     @log
     def _on_thumbnail_updated(self, player, data=None):
-        self.PropertiesChanged(MediaPlayer2Service.MEDIA_PLAYER2_PLAYER_IFACE,
+        self.PropertiesChanged(MPRIS.MEDIA_PLAYER2_PLAYER_IFACE,
                                {
                                    'Metadata': GLib.Variant('a{sv}', self._get_metadata()),
                                },
@@ -479,7 +479,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),
                                },
@@ -490,7 +490,7 @@ class MediaPlayer2Service(DBusInterface):
         self._update_songs_list()
         has_next = self.player.props.has_next
         has_previous = self.player.props.has_previous
-        self.PropertiesChanged(MediaPlayer2Service.MEDIA_PLAYER2_PLAYER_IFACE,
+        self.PropertiesChanged(MPRIS.MEDIA_PLAYER2_PLAYER_IFACE,
                                {
                                    'CanGoNext': GLib.Variant('b', has_next),
                                    'CanGoPrevious': GLib.Variant('b', has_previous),
@@ -511,7 +511,7 @@ class MediaPlayer2Service(DBusInterface):
                 or self._player_previous_type == PlayerPlaylist.Type.PLAYLIST):
             variant = GLib.Variant('(b(oss))', self._get_active_playlist())
             self.PropertiesChanged(
-                MediaPlayer2Service.MEDIA_PLAYER2_PLAYLISTS_IFACE,
+                MPRIS.MEDIA_PLAYER2_PLAYLISTS_IFACE,
                 {'ActivePlaylist': variant, }, [])
 
         self._player_previous_type = klass.get_playlist_type()
@@ -521,7 +521,7 @@ class MediaPlayer2Service(DBusInterface):
         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)
@@ -609,7 +609,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 = []
@@ -634,7 +634,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)))
@@ -642,7 +642,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)))
@@ -650,13 +650,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)))
@@ -693,7 +693,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),
@@ -713,7 +713,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()),
@@ -731,12 +731,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),
@@ -752,10 +752,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]