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



commit 82653ab386f3eb997d62cfb674daf0db361b6119
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       | 46 +++++++++++++++++++++++-----------------------
 2 files changed, 25 insertions(+), 25 deletions(-)
---
diff --git a/gnomemusic/application.py b/gnomemusic/application.py
index 9a496093..dda3ebc7 100644
--- a/gnomemusic/application.py
+++ b/gnomemusic/application.py
@@ -36,7 +36,7 @@ import logging
 from gi.repository import Gtk, Gio, GLib, Gdk
 
 from gnomemusic import log
-from gnomemusic.mpris import MediaPlayer2Service
+from gnomemusic.mpris import MPRIS
 from gnomemusic.widgets.aboutdialog import AboutDialog
 from gnomemusic.window import Window
 
@@ -108,7 +108,7 @@ class Application(Gtk.Application):
             self._window.set_default_icon_name(self._application_id)
             if self._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 4bfa80d5..aefdcc43 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'>
@@ -217,7 +217,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)
@@ -385,7 +385,7 @@ class MediaPlayer2Service(DBusInterface):
                 self.player.props.current_song)
             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
@@ -455,7 +455,7 @@ class MediaPlayer2Service(DBusInterface):
         if self.player.props.repeat_mode == RepeatMode.SONG:
             self.Seeked(0)
 
-        self.PropertiesChanged(MediaPlayer2Service.MEDIA_PLAYER2_PLAYER_IFACE,
+        self.PropertiesChanged(MPRIS.MEDIA_PLAYER2_PLAYER_IFACE,
                                {
                                    'Metadata': GLib.Variant('a{sv}', self._get_metadata()),
                                    'CanPlay': GLib.Variant('b', True),
@@ -465,7 +465,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()),
                                },
@@ -473,7 +473,7 @@ class MediaPlayer2Service(DBusInterface):
 
     @log
     def _on_player_state_changed(self, klass, args):
-        self.PropertiesChanged(MediaPlayer2Service.MEDIA_PLAYER2_PLAYER_IFACE,
+        self.PropertiesChanged(MPRIS.MEDIA_PLAYER2_PLAYER_IFACE,
                                {
                                    'PlaybackStatus': GLib.Variant('s', self._get_playback_status()),
                                },
@@ -482,7 +482,7 @@ class MediaPlayer2Service(DBusInterface):
     @log
     def _on_repeat_mode_changed(self, player, param):
         self._update_songs_list()
-        self.PropertiesChanged(MediaPlayer2Service.MEDIA_PLAYER2_PLAYER_IFACE,
+        self.PropertiesChanged(MPRIS.MEDIA_PLAYER2_PLAYER_IFACE,
                                {
                                    'LoopStatus': GLib.Variant('s', self._get_loop_status()),
                                    'Shuffle': GLib.Variant('b', self.player.props.repeat_mode == 
RepeatMode.SHUFFLE),
@@ -491,7 +491,7 @@ class MediaPlayer2Service(DBusInterface):
 
     @log
     def _on_volume_changed(self, player, data=None):
-        self.PropertiesChanged(MediaPlayer2Service.MEDIA_PLAYER2_PLAYER_IFACE,
+        self.PropertiesChanged(MPRIS.MEDIA_PLAYER2_PLAYER_IFACE,
                                {
                                    'Volume': GLib.Variant('d', self.player.get_volume()),
                                },
@@ -499,7 +499,7 @@ class MediaPlayer2Service(DBusInterface):
 
     @log
     def _on_prev_next_invalidated(self, player, data=None):
-        self.PropertiesChanged(MediaPlayer2Service.MEDIA_PLAYER2_PLAYER_IFACE,
+        self.PropertiesChanged(MPRIS.MEDIA_PLAYER2_PLAYER_IFACE,
                                {
                                    'CanGoNext': GLib.Variant('b', self.player.props.has_next),
                                    'CanGoPrevious': GLib.Variant('b', self.player.props.has_previous),
@@ -518,7 +518,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()
@@ -527,7 +527,7 @@ class MediaPlayer2Service(DBusInterface):
     def _reload_playlists(self):
         def get_playlists_callback(playlists):
             self.playlists = playlists
-            self.PropertiesChanged(MediaPlayer2Service.MEDIA_PLAYER2_PLAYLISTS_IFACE,
+            self.PropertiesChanged(MPRIS.MEDIA_PLAYER2_PLAYLISTS_IFACE,
                                    {
                                        'PlaylistCount': GLib.Variant('u', len(playlists)),
                                    },
@@ -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 = []
@@ -635,7 +635,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)))
@@ -643,7 +643,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)))
@@ -651,13 +651,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)))
@@ -678,7 +678,7 @@ class MediaPlayer2Service(DBusInterface):
     def PlaylistChanged(self, playlist):
         self.con.emit_signal(None,
                              '/org/mpris/MediaPlayer2',
-                             MediaPlayer2Service.MEDIA_PLAYER2_PLAYLISTS_IFACE,
+                             MPRIS.MEDIA_PLAYER2_PLAYLISTS_IFACE,
                              'PlaylistChanged',
                              GLib.Variant.new_tuple(GLib.Variant('(oss)', playlist)))
 
@@ -686,7 +686,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:
             return {
                 'CanQuit': GLib.Variant('b', True),
                 'Fullscreen': GLib.Variant('b', False),
@@ -705,7 +705,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()),
@@ -724,12 +724,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:
             return {
                 'PlaylistCount': GLib.Variant('u', len(self.playlists)),
                 'Orderings': GLib.Variant('as', ['Alphabetical']),
@@ -746,10 +746,10 @@ class MediaPlayer2Service(DBusInterface):
                 % 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 == 'Rate':
                 pass
             elif property_name == 'Volume':


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]