[gnome-music/wip/mschraal/glib-logging: 1/3] Switch to new logging and cleanups
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/glib-logging: 1/3] Switch to new logging and cleanups
- Date: Sun, 2 Feb 2020 15:34:57 +0000 (UTC)
commit 52a92d8a2a2676a4fe797eb84ae358b64ae3540c
Author: Marinus Schraal <mschraal gnome org>
Date: Tue Jan 14 22:28:33 2020 +0100
Switch to new logging and cleanups
* Remove @log decorator use.
* Remove __repr__.
* Switch to new MusicLogger based logging.
gnomemusic/albumartcache.py | 103 ++++++++----------------
gnomemusic/artistart.py | 6 --
gnomemusic/corealbum.py | 3 -
gnomemusic/coreartist.py | 3 -
gnomemusic/coregrilo.py | 20 +++--
gnomemusic/grilowrappers/grlsearchwrapper.py | 6 +-
gnomemusic/grilowrappers/grltrackerplaylists.py | 44 +++++-----
gnomemusic/grilowrappers/grltrackerwrapper.py | 32 ++++----
gnomemusic/gstplayer.py | 40 ++-------
gnomemusic/inhibitsuspend.py | 16 +---
gnomemusic/mediakeys.py | 19 ++---
gnomemusic/mpris.py | 38 +++------
gnomemusic/pauseonsuspend.py | 22 ++---
gnomemusic/player.py | 41 ++--------
gnomemusic/scrobbler.py | 34 +++-----
gnomemusic/search.py | 6 --
gnomemusic/trackerwrapper.py | 19 +++--
gnomemusic/views/albumsview.py | 3 -
gnomemusic/views/artistsview.py | 15 ----
gnomemusic/views/baseview.py | 8 --
gnomemusic/views/emptyview.py | 12 ---
gnomemusic/views/playlistsview.py | 11 ---
gnomemusic/views/searchview.py | 7 --
gnomemusic/views/songsview.py | 14 ----
gnomemusic/widgets/aboutdialog.py | 7 --
gnomemusic/widgets/albumcover.py | 7 --
gnomemusic/widgets/appmenu.py | 3 -
gnomemusic/widgets/artistalbumswidget.py | 11 ---
gnomemusic/widgets/artistalbumwidget.py | 6 --
gnomemusic/widgets/artistartstack.py | 8 --
gnomemusic/widgets/artistsearchtile.py | 3 -
gnomemusic/widgets/artisttile.py | 5 --
gnomemusic/widgets/coverstack.py | 8 --
gnomemusic/widgets/headerbar.py | 12 ---
gnomemusic/widgets/notificationspopup.py | 25 ------
gnomemusic/widgets/playertoolbar.py | 15 ----
gnomemusic/widgets/playlistcontrols.py | 6 --
gnomemusic/widgets/playlistdialog.py | 13 ---
gnomemusic/widgets/playlistdialogrow.py | 3 -
gnomemusic/widgets/playlisttile.py | 5 --
gnomemusic/widgets/searchheaderbar.py | 8 --
gnomemusic/widgets/selectiontoolbar.py | 8 --
gnomemusic/widgets/smoothscale.py | 19 -----
gnomemusic/widgets/songwidget.py | 9 ---
gnomemusic/widgets/starhandlerwidget.py | 11 ---
gnomemusic/widgets/starimage.py | 6 --
gnomemusic/widgets/twolinetip.py | 6 --
gnomemusic/window.py | 23 ------
gnomemusic/windowplacement.py | 10 ---
49 files changed, 133 insertions(+), 626 deletions(-)
---
diff --git a/gnomemusic/albumartcache.py b/gnomemusic/albumartcache.py
index 75e90f52..fbfd1f0f 100644
--- a/gnomemusic/albumartcache.py
+++ b/gnomemusic/albumartcache.py
@@ -23,7 +23,6 @@
# delete this exception statement from your version.
from enum import Enum
-import logging
from math import pi
import os
@@ -34,13 +33,9 @@ gi.require_version('MediaArt', '2.0')
from gi.repository import (Gdk, GdkPixbuf, Gio, GLib, GObject, Gtk, MediaArt,
Gst, GstTag, GstPbutils)
-from gnomemusic import log
+from gnomemusic.musiclogger import MusicLogger
-logger = logging.getLogger(__name__)
-
-
-@log
def lookup_art_file_from_cache(coresong):
"""Lookup MediaArt cache art of an album or song.
@@ -62,7 +57,6 @@ def lookup_art_file_from_cache(coresong):
return thumb_file
-@log
def _make_icon_frame(icon_surface, art_size=None, scale=1, default_icon=False):
border = 3
degrees = pi / 180
@@ -130,14 +124,9 @@ class DefaultIcon(GObject.GObject):
_cache = {}
_default_theme = Gtk.IconTheme.get_default()
- def __repr__(self):
- return '<DefaultIcon>'
-
- @log
def __init__(self):
super().__init__()
- @log
def _make_default_icon(self, icon_type, art_size, scale):
icon_info = self._default_theme.lookup_icon_for_scale(
icon_type.value, art_size.width / 3, scale, 0)
@@ -147,7 +136,6 @@ class DefaultIcon(GObject.GObject):
return icon_surface
- @log
def get(self, icon_type, art_size, scale=1):
"""Returns the requested symbolic icon
@@ -196,10 +184,6 @@ class Art(GObject.GObject):
self.width = width
self.height = height
- def __repr__(self):
- return '<Art>'
-
- @log
def __init__(self, size, coresong, scale=1):
super().__init__()
@@ -213,7 +197,6 @@ class Art(GObject.GObject):
self._surface = None
self._scale = scale
- @log
def lookup(self):
"""Starts the art lookup sequence"""
if self._in_blacklist():
@@ -225,14 +208,12 @@ class Art(GObject.GObject):
cache.connect('hit', self._cache_hit)
cache.query(self._coresong)
- @log
def _cache_miss(self, klass):
embedded_art = EmbeddedArt()
embedded_art.connect('found', self._embedded_art_found)
embedded_art.connect('unavailable', self._embedded_art_unavailable)
embedded_art.query(self._coresong)
- @log
def _cache_hit(self, klass, pixbuf):
surface = Gdk.cairo_surface_create_from_pixbuf(
pixbuf, self._scale, None)
@@ -241,7 +222,6 @@ class Art(GObject.GObject):
self.emit('finished')
- @log
def _embedded_art_found(self, klass):
cache = Cache()
# In case of an error in local art retrieval, there are two
@@ -254,7 +234,6 @@ class Art(GObject.GObject):
cache.connect('hit', self._cache_hit)
cache.query(self._coresong)
- @log
def _embedded_art_unavailable(self, klass):
remote_art = RemoteArt()
remote_art.connect('retrieved', self._remote_art_retrieved)
@@ -262,30 +241,25 @@ class Art(GObject.GObject):
remote_art.connect('no-remote-sources', self._remote_art_no_sources)
remote_art.query(self._coresong)
- @log
def _remote_art_retrieved(self, klass):
cache = Cache()
cache.connect('miss', self._remote_art_unavailable)
cache.connect('hit', self._cache_hit)
cache.query(self._coresong)
- @log
def _remote_art_unavailable(self, klass):
self._add_to_blacklist()
self._no_art_available()
- @log
def _remote_art_no_sources(self, klass):
self._no_art_available()
- @log
def _no_art_available(self):
self._surface = DefaultIcon().get(
DefaultIcon.Type.MUSIC, self._size, self._scale)
self.emit('finished')
- @log
def _add_to_blacklist(self):
# FIXME: coresong can be a CoreAlbum
try:
@@ -300,7 +274,6 @@ class Art(GObject.GObject):
album_stripped = MediaArt.strip_invalid_entities(album)
self._blacklist[artist].append(album_stripped)
- @log
def _in_blacklist(self):
# FIXME: coresong can be a CoreAlbum
try:
@@ -336,24 +309,21 @@ class Cache(GObject.GObject):
'hit': (GObject.SignalFlags.RUN_FIRST, None, (GObject.GObject, ))
}
- def __repr__(self):
- return '<Cache>'
-
- @log
def __init__(self):
super().__init__()
+ self._log = MusicLogger()
+
# FIXME: async
self.cache_dir = os.path.join(GLib.get_user_cache_dir(), 'media-art')
if not os.path.exists(self.cache_dir):
try:
Gio.file_new_for_path(self.cache_dir).make_directory(None)
except GLib.Error as error:
- logger.warning(
+ self._log.warning(
"Error: {}, {}".format(error.domain, error.message))
return
- @log
def query(self, coresong):
"""Start the cache query
@@ -367,36 +337,36 @@ class Cache(GObject.GObject):
self.emit('miss')
- @log
def _open_stream(self, thumb_file, result, arguments):
try:
stream = thumb_file.read_finish(result)
except GLib.Error as error:
- logger.warning("Error: {}, {}".format(error.domain, error.message))
+ self._log.warning(
+ "Error: {}, {}".format(error.domain, error.message))
self.emit('miss')
return
GdkPixbuf.Pixbuf.new_from_stream_async(
stream, None, self._pixbuf_loaded, None)
- @log
def _pixbuf_loaded(self, stream, result, data):
try:
pixbuf = GdkPixbuf.Pixbuf.new_from_stream_finish(result)
except GLib.Error as error:
- logger.warning("Error: {}, {}".format(error.domain, error.message))
+ self._log.warning(
+ "Error: {}, {}".format(error.domain, error.message))
self.emit('miss')
return
stream.close_async(GLib.PRIORITY_LOW, None, self._close_stream, None)
self.emit('hit', pixbuf)
- @log
def _close_stream(self, stream, result, data):
try:
stream.close_finish(result)
except GLib.Error as error:
- logger.warning("Error: {}, {}".format(error.domain, error.message))
+ self._log.warning(
+ "Error: {}, {}".format(error.domain, error.message))
class EmbeddedArt(GObject.GObject):
@@ -414,15 +384,17 @@ class EmbeddedArt(GObject.GObject):
def __repr__(self):
return '<EmbeddedArt>'
- @log
def __init__(self):
super().__init__()
+ self._log = MusicLogger()
+
try:
Gst.init(None)
GstPbutils.pb_utils_init()
except GLib.Error as error:
- logger.warning("Error: {}, {}".format(error.domain, error.message))
+ self._log.warning(
+ "Error: {}, {}".format(error.domain, error.message))
return
self._media_art = MediaArt.Process.new()
@@ -432,7 +404,6 @@ class EmbeddedArt(GObject.GObject):
self._coresong = None
self._path = None
- @log
def query(self, coresong):
"""Start the local query
@@ -457,7 +428,8 @@ class EmbeddedArt(GObject.GObject):
try:
discoverer = GstPbutils.Discoverer.new(Gst.SECOND)
except GLib.Error as error:
- logger.warning("Error: {}, {}".format(error.domain, error.message))
+ self._log.warning(
+ "Error: {}, {}".format(error.domain, error.message))
self._lookup_cover_in_directory()
return
@@ -476,12 +448,11 @@ class EmbeddedArt(GObject.GObject):
success = discoverer.discover_uri_async(self._coresong.props.url)
if not success:
- logger.warning("Could not add url to discoverer.")
+ self._log.warning("Could not add url to discoverer.")
self.emit('unavailable')
discoverer.stop()
return
- @log
def _discovered(self, discoverer, info, error):
tags = info.get_tags()
index = 0
@@ -489,7 +460,7 @@ class EmbeddedArt(GObject.GObject):
if (error is not None
or tags is None):
if error:
- logger.warning("Discoverer error: {}, {}".format(
+ self._log.warning("Discoverer error: {}, {}".format(
Gst.CoreError(error.code), error.message))
discoverer.stop()
self.emit('unavailable')
@@ -520,14 +491,13 @@ class EmbeddedArt(GObject.GObject):
discoverer.stop()
return
except GLib.Error as error:
- logger.warning("Error: {}, {}".format(
+ self._log.warning("Error: {}, {}".format(
MediaArt.Error(error.code), error.message))
discoverer.stop()
self._lookup_cover_in_directory()
- @log
def _lookup_cover_in_directory(self):
# Find local art in cover.jpeg files.
self._media_art.uri_async(
@@ -535,7 +505,6 @@ class EmbeddedArt(GObject.GObject):
self._coresong.props.url, self._artist, self._album,
GLib.PRIORITY_LOW, None, self._uri_async_cb, None)
- @log
def _uri_async_cb(self, src, result, data):
try:
success = self._media_art.uri_finish(result)
@@ -549,7 +518,7 @@ class EmbeddedArt(GObject.GObject):
self.emit('found')
return
else:
- logger.warning("Error: {}, {}".format(
+ self._log.warning("Error: {}, {}".format(
MediaArt.Error(error.code), error.message))
self.emit('unavailable')
@@ -567,19 +536,16 @@ class RemoteArt(GObject.GObject):
'no-remote-sources': (GObject.SignalFlags.RUN_FIRST, None, ())
}
- def __repr__(self):
- return '<RemoteArt>'
-
- @log
def __init__(self):
super().__init__()
+ self._log = MusicLogger()
+
self._artist = None
self._album = None
self._coresong = None
self._grilo = None
- @log
def query(self, coresong):
"""Start the remote query
@@ -618,14 +584,13 @@ class RemoteArt(GObject.GObject):
self._grilo.get_album_art_for_item(
self._coresong, self._remote_album_art)
- @log
def _delete_callback(self, src, result, data):
try:
src.delete_finish(result)
except GLib.Error as error:
- logger.warning("Error: {}, {}".format(error.domain, error.message))
+ self._log.warning(
+ "Error: {}, {}".format(error.domain, error.message))
- @log
def _splice_callback(self, src, result, data):
tmp_file, iostream = data
@@ -635,7 +600,8 @@ class RemoteArt(GObject.GObject):
try:
src.splice_finish(result)
except GLib.Error as error:
- logger.warning("Error: {}, {}".format(error.domain, error.message))
+ self._log.warning(
+ "Error: {}, {}".format(error.domain, error.message))
self.emit('unavailable')
return
@@ -650,7 +616,8 @@ class RemoteArt(GObject.GObject):
# FIXME: I/O blocking
MediaArt.file_to_jpeg(tmp_file.get_path(), cache_path)
except GLib.Error as error:
- logger.warning("Error: {}, {}".format(error.domain, error.message))
+ self._log.warning(
+ "Error: {}, {}".format(error.domain, error.message))
self.emit('unavailable')
return
@@ -659,26 +626,27 @@ class RemoteArt(GObject.GObject):
tmp_file.delete_async(
GLib.PRIORITY_LOW, None, self._delete_callback, None)
- @log
def _close_iostream_callback(self, src, result, data):
try:
src.close_finish(result)
except GLib.Error as error:
- logger.warning("Error: {}, {}".format(error.domain, error.message))
+ self._log.warning(
+ "Error: {}, {}".format(error.domain, error.message))
- @log
def _read_callback(self, src, result, data):
try:
istream = src.read_finish(result)
except GLib.Error as error:
- logger.warning("Error: {}, {}".format(error.domain, error.message))
+ self._log.warning(
+ "Error: {}, {}".format(error.domain, error.message))
self.emit('unavailable')
return
try:
[tmp_file, iostream] = Gio.File.new_tmp()
except GLib.Error as error:
- logger.warning("Error: {}, {}".format(error.domain, error.message))
+ self._log.warning(
+ "Error: {}, {}".format(error.domain, error.message))
self.emit('unavailable')
return
@@ -690,10 +658,9 @@ class RemoteArt(GObject.GObject):
| Gio.OutputStreamSpliceFlags.CLOSE_TARGET, GLib.PRIORITY_LOW,
None, self._splice_callback, [tmp_file, iostream])
- @log
def _remote_album_art(self, source, param, item, count, error):
if error:
- logger.warning("Grilo error {}".format(error))
+ self._log.warning("Grilo error {}".format(error))
self.emit('unavailable')
return
diff --git a/gnomemusic/artistart.py b/gnomemusic/artistart.py
index 08b11baa..c810198b 100644
--- a/gnomemusic/artistart.py
+++ b/gnomemusic/artistart.py
@@ -89,9 +89,6 @@ class DefaultIcon(GObject.GObject):
_cache = {}
_default_theme = Gtk.IconTheme.get_default()
- def __repr__(self):
- return "<DefaultIcon>"
-
def __init__(self):
super().__init__()
@@ -259,9 +256,6 @@ class ArtistCache(GObject.GObject):
_log = MusicLogger()
- def __repr__(self):
- return "<ArtistCache>"
-
def __init__(self, size, scale):
super().__init__()
diff --git a/gnomemusic/corealbum.py b/gnomemusic/corealbum.py
index 9d081d63..9084cd82 100644
--- a/gnomemusic/corealbum.py
+++ b/gnomemusic/corealbum.py
@@ -41,9 +41,6 @@ class CoreAlbum(GObject.GObject):
url = GObject.Property(type=str)
year = GObject.Property(type=str, default="----")
- def __repr__(self):
- return "<CoreAlbum>"
-
def __init__(self, media, coremodel):
"""Initiate the CoreAlbum object
diff --git a/gnomemusic/coreartist.py b/gnomemusic/coreartist.py
index 74d22655..96b8a15f 100644
--- a/gnomemusic/coreartist.py
+++ b/gnomemusic/coreartist.py
@@ -26,7 +26,6 @@ import gi
gi.require_version('Grl', '0.3')
from gi.repository import Gio, Grl, GObject
-from gnomemusic import log
from gnomemusic.artistart import ArtistArt
import gnomemusic.utils as utils
@@ -38,7 +37,6 @@ class CoreArtist(GObject.GObject):
artist = GObject.Property(type=str)
media = GObject.Property(type=Grl.Media)
- @log
def __init__(self, media, coremodel):
super().__init__()
@@ -50,7 +48,6 @@ class CoreArtist(GObject.GObject):
self.update(media)
- @log
def update(self, media):
self.props.media = media
self.props.artist = utils.get_artist_name(media)
diff --git a/gnomemusic/coregrilo.py b/gnomemusic/coregrilo.py
index 9741d05d..2941acb2 100644
--- a/gnomemusic/coregrilo.py
+++ b/gnomemusic/coregrilo.py
@@ -52,9 +52,6 @@ class CoreGrilo(GObject.GObject):
cover_sources = GObject.Property(type=bool, default=False)
tracker_available = GObject.Property(type=int)
- def __repr__(self):
- return "<CoreGrilo>"
-
def __init__(self, coremodel, application):
"""Initiate the CoreGrilo object
@@ -66,6 +63,7 @@ class CoreGrilo(GObject.GObject):
self._application = application
self._coremodel = coremodel
self._coreselection = application.props.coreselection
+ self._log = application.props.log
self._search_wrappers = {}
self._thumbnail_sources = []
self._thumbnail_sources_timeout = None
@@ -115,8 +113,8 @@ class CoreGrilo(GObject.GObject):
try:
registry.unregister_source(source)
except GLib.GError:
- print("Failed to unregister {}".format(
- source.props.source_id))
+ self._log.warning(
+ "Failed to unregister {}".format(source.props.source_id))
return
if Grl.METADATA_KEY_THUMBNAIL in source.supported_keys():
@@ -132,7 +130,7 @@ class CoreGrilo(GObject.GObject):
new_state = self._tracker_wrapper.props.tracker_available
if (source.props.source_id == "grl-tracker-source"
and source.props.source_id not in self._wrappers.keys()
- and TrackerWrapper.location_filter() is not None
+ and self._tracker_wrapper.location_filter() is not None
and new_state == TrackerState.AVAILABLE):
new_wrapper = GrlTrackerWrapper(
source, self._coremodel, self._application, self,
@@ -142,7 +140,7 @@ class CoreGrilo(GObject.GObject):
# new_wrapper = GrlDLeynaWrapper(
# source, self._coremodel, self._coreselection, self)
# self._wrappers.append(new_wrapper)
- print("wrapper", new_wrapper)
+ self._log.debug("Adding wrapper {}".format(new_wrapper))
elif (source.props.source_id not in self._search_wrappers.keys()
and source.props.source_id not in self._wrappers.keys()
and source.props.source_id != "grl-tracker-source"
@@ -150,11 +148,11 @@ class CoreGrilo(GObject.GObject):
and source.supported_operations() & Grl.SupportedOps.SEARCH):
self._search_wrappers[source.props.source_id] = GrlSearchWrapper(
source, self._coremodel, self._application, self)
- print("search source", source)
+ self._log.debug("Adding search source {}".format(source))
def _on_source_removed(self, registry, source):
# FIXME: Handle removing sources.
- print("removed,", source.props.source_id)
+ self._log.debug("Removed source {}".format(source.props.source_id))
# FIXME: Only removes search sources atm.
self._search_wrappers.pop(source.props.source_id, None)
@@ -184,8 +182,8 @@ class CoreGrilo(GObject.GObject):
source.store_metadata_sync(
media, [key], Grl.WriteFlags.NORMAL)
except GLib.Error as error:
- # FIXME: Do not print.
- print("Error {}: {}".format(error.domain, error.message))
+ self._log.warning(
+ "Error {}: {}".format(error.domain, error.message))
return GLib.SOURCE_REMOVE
diff --git a/gnomemusic/grilowrappers/grlsearchwrapper.py b/gnomemusic/grilowrappers/grlsearchwrapper.py
index 8e9a70dc..ab263e6c 100644
--- a/gnomemusic/grilowrappers/grlsearchwrapper.py
+++ b/gnomemusic/grilowrappers/grlsearchwrapper.py
@@ -70,6 +70,7 @@ class GrlSearchWrapper(GObject.GObject):
self._coremodel = coremodel
self._coreselection = application.props.coreselection
self._grilo = grilo
+ self._log = application.props.log
self._source = source
self._song_search_proxy = self._coremodel.props.songs_search_proxy
@@ -97,9 +98,10 @@ class GrlSearchWrapper(GObject.GObject):
def _search_result_cb(source, op_id, media, remaining, error):
if error:
- print("error")
+ self._log.warning("Error: {}".format(error))
return
- if media is None:
+
+ if not media:
return
coresong = CoreSong(media, self._coreselection, self._grilo)
diff --git a/gnomemusic/grilowrappers/grltrackerplaylists.py b/gnomemusic/grilowrappers/grltrackerplaylists.py
index 5b147aa8..63db2ade 100644
--- a/gnomemusic/grilowrappers/grltrackerplaylists.py
+++ b/gnomemusic/grilowrappers/grltrackerplaylists.py
@@ -22,7 +22,6 @@
# code, but you are not obligated to do so. If you do not wish to do so,
# delete this exception statement from your version.
-import logging
import time
from gettext import gettext as _
@@ -35,8 +34,6 @@ from gnomemusic.coresong import CoreSong
from gnomemusic.trackerwrapper import TrackerWrapper
import gnomemusic.utils as utils
-logger = logging.getLogger(__name__)
-
class GrlTrackerPlaylists(GObject.GObject):
@@ -58,9 +55,6 @@ class GrlTrackerPlaylists(GObject.GObject):
Grl.METADATA_KEY_URL
]
- def __repr__(self):
- return "<GrlTrackerPlaylists>"
-
def __init__(
self, source, coremodel, application, grilo, tracker_wrapper):
"""Initialize GrlTrackerPlaylists.
@@ -79,12 +73,14 @@ class GrlTrackerPlaylists(GObject.GObject):
self._coremodel = coremodel
self._coreselection = application.props.coreselection
self._grilo = grilo
+ self._log = application.props.log
self._source = source
self._model = self._coremodel.props.playlists
self._model_filter = self._coremodel.props.playlists_filter
self._user_model_filter = self._coremodel.props.user_playlists_filter
self._pls_todelete = []
self._tracker = tracker_wrapper.props.tracker
+ self._tracker_wrapper = tracker_wrapper
self._window = application.props.window
self._user_model_filter.set_filter_func(self._user_playlists_filter)
@@ -100,7 +96,7 @@ class GrlTrackerPlaylists(GObject.GObject):
"source": self._source,
"application": self._application,
"grilo": self._grilo,
- "tracker": self._tracker
+ "tracker_wrapper": self._tracker_wrapper
}
smart_playlists = {
@@ -144,7 +140,7 @@ class GrlTrackerPlaylists(GObject.GObject):
def _add_user_playlist(
self, source, op_id, media, remaining, data=None, error=None):
if error:
- print("ERROR", error)
+ self._log.warning("Error: {}".format(error))
self._window.notifications_popup.pop_loading()
return
if not media:
@@ -154,7 +150,7 @@ class GrlTrackerPlaylists(GObject.GObject):
playlist = Playlist(
media=media, source=self._source, coremodel=self._coremodel,
application=self._application, grilo=self._grilo,
- tracker=self._tracker)
+ tracker_wrapper=self._tracker_wrapper)
self._model.append(playlist)
callback = data
@@ -295,12 +291,10 @@ class Playlist(GObject.GObject):
query = GObject.Property(type=str, default=None)
tag_text = GObject.Property(type=str, default=None)
- def __repr__(self):
- return "<Playlist>"
-
def __init__(
self, media=None, query=None, tag_text=None, source=None,
- coremodel=None, application=None, grilo=None, tracker=None):
+ coremodel=None, application=None, grilo=None,
+ tracker_wrapper=None):
super().__init__()
"""Initialize a playlist
@@ -313,7 +307,8 @@ class Playlist(GObject.GObject):
:param CoreModel coremodel: The CoreModel instance
:param Application application: The Application instance
:param CoreGrilo grilo: The CoreGrilo instance
- :param TrackerWrapper tracker: The TrackerWrapper instance
+ :param TrackerWrapper tracker_wrapper: The TrackerWrapper
+ instance
"""
if media:
self.props.pl_id = media.get_id()
@@ -330,7 +325,9 @@ class Playlist(GObject.GObject):
self._coremodel = coremodel
self._coreselection = application.props.coreselection
self._grilo = grilo
- self._tracker = tracker
+ self._log = application.props.log
+ self._tracker = tracker_wrapper.props.tracker
+ self._tracker_wrapper = tracker_wrapper
self._window = application.props.window
self._fast_options = Grl.OperationOptions()
@@ -434,7 +431,7 @@ class Playlist(GObject.GObject):
try:
conn.update_finish(res)
except GLib.Error as e:
- logger.warning(
+ self._log.warning(
"Unable to rename playlist from {} to {}: {}".format(
self._title, new_name, e.message))
else:
@@ -699,9 +696,6 @@ class Playlist(GObject.GObject):
class SmartPlaylist(Playlist):
"""Base class for smart playlists"""
- def __repr__(self):
- return "<SmartPlaylist>"
-
def __init__(self, **args):
super().__init__(**args)
@@ -716,7 +710,7 @@ class SmartPlaylist(Playlist):
def _add_to_model(source, op_id, media, remaining, error):
if error:
- print("ERROR", error)
+ self._log.warning("Error: {}".format(error))
self._window.notifications_popup.pop_loading()
self.emit("playlist-loaded")
return
@@ -771,7 +765,7 @@ class MostPlayed(SmartPlaylist):
}
ORDER BY DESC(?count) LIMIT 50
""".replace('\n', ' ').strip() % {
- "location_filter": TrackerWrapper.location_filter()
+ "location_filter": self._tracker_wrapper.location_filter()
}
@@ -807,7 +801,7 @@ class NeverPlayed(SmartPlaylist):
%(location_filter)s
} ORDER BY nfo:fileLastAccessed(?song) LIMIT 50
""".replace('\n', ' ').strip() % {
- "location_filter": TrackerWrapper.location_filter()
+ "location_filter": self._tracker_wrapper.location_filter()
}
@@ -853,7 +847,7 @@ class RecentlyPlayed(SmartPlaylist):
} ORDER BY DESC(?last_played) LIMIT 50
""".replace('\n', ' ').strip() % {
'compare_date': compare_date,
- "location_filter": TrackerWrapper.location_filter()
+ "location_filter": self._tracker_wrapper.location_filter()
}
@@ -898,7 +892,7 @@ class RecentlyAdded(SmartPlaylist):
} ORDER BY DESC(tracker:added(?song)) LIMIT 50
""".replace('\n', ' ').strip() % {
'compare_date': compare_date,
- "location_filter": TrackerWrapper.location_filter()
+ "location_filter": self._tracker_wrapper.location_filter()
}
@@ -936,5 +930,5 @@ class Favorites(SmartPlaylist):
%(location_filter)s
} ORDER BY DESC(tracker:added(?song))
""".replace('\n', ' ').strip() % {
- "location_filter": TrackerWrapper.location_filter()
+ "location_filter": self._tracker_wrapper.location_filter()
}
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index 86596609..cf991d90 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -62,9 +62,6 @@ class GrlTrackerWrapper(GObject.GObject):
Grl.METADATA_KEY_THUMBNAIL,
]
- def __repr__(self):
- return "<GrlTrackerWrapper>"
-
def __init__(
self, source, coremodel, application, grilo, tracker_wrapper):
"""Initialize the Tracker wrapper
@@ -94,6 +91,7 @@ class GrlTrackerWrapper(GObject.GObject):
self._artist_search_model = self._coremodel.props.artists_search
self._batch_changed_media_ids = {}
self._content_changed_timeout = None
+ self._tracker_wrapper = tracker_wrapper
self._window = application.props.window
self._song_search_tracker = Gfm.FilterListModel.new(self._model)
@@ -179,7 +177,7 @@ class GrlTrackerWrapper(GObject.GObject):
%(location_filter)s
} GROUP BY ?album
""".replace('\n', ' ').strip() % {
- 'location_filter': TrackerWrapper.location_filter()
+ 'location_filter': self._tracker_wrapper.location_filter()
}
def check_album_cb(source, op_id, media, user_data, error):
@@ -240,7 +238,7 @@ class GrlTrackerWrapper(GObject.GObject):
}
GROUP BY ?artist_bind
""".replace('\n', ' ').strip() % {
- 'location_filter': TrackerWrapper.location_filter()
+ 'location_filter': self._tracker_wrapper.location_filter()
}
def check_artist_cb(source, op_id, media, user_data, error):
@@ -323,7 +321,7 @@ class GrlTrackerWrapper(GObject.GObject):
%(location_filter)s
}
""".replace('\n', ' ').strip() % {
- 'location_filter': TrackerWrapper.location_filter(),
+ 'location_filter': self._tracker_wrapper.location_filter(),
'media_ids': media_ids
}
@@ -403,7 +401,7 @@ class GrlTrackerWrapper(GObject.GObject):
}
ORDER BY ?title
""".replace('\n', ' ').strip() % {
- 'location_filter': TrackerWrapper.location_filter()
+ 'location_filter': self._tracker_wrapper.location_filter()
}
options = self._fast_options.copy()
@@ -456,7 +454,7 @@ class GrlTrackerWrapper(GObject.GObject):
GROUP BY ?album
ORDER BY ?title ?album_artist ?artist ?creation_date
""".replace('\n', ' ').strip() % {
- 'location_filter': TrackerWrapper.location_filter()
+ 'location_filter': self._tracker_wrapper.location_filter()
}
options = self._fast_options.copy()
@@ -508,7 +506,7 @@ class GrlTrackerWrapper(GObject.GObject):
GROUP BY ?artist_bind
ORDER BY ?artist_bind
""".replace('\n', ' ').strip() % {
- 'location_filter': TrackerWrapper.location_filter()
+ 'location_filter': self._tracker_wrapper.location_filter()
}
options = self._fast_options.copy()
@@ -545,7 +543,7 @@ class GrlTrackerWrapper(GObject.GObject):
ORDER BY ?date ?album
""".replace('\n', ' ').strip() % {
'artist_id': int(artist_id),
- 'location_filter': TrackerWrapper.location_filter()
+ 'location_filter': self._tracker_wrapper.location_filter()
}
albums = []
@@ -597,7 +595,7 @@ class GrlTrackerWrapper(GObject.GObject):
ORDER BY ?album_disc_number
""".replace('\n', ' ').strip() % {
'album_id': int(album_id),
- 'location_filter': TrackerWrapper.location_filter()
+ 'location_filter': self._tracker_wrapper.location_filter()
}
def _disc_nr_cb(source, op_id, media, user_data, error):
@@ -658,7 +656,7 @@ class GrlTrackerWrapper(GObject.GObject):
""".replace('\n', ' ').strip() % {
'album_id': album_id,
'disc_nr': disc_nr,
- 'location_filter': TrackerWrapper.location_filter()
+ 'location_filter': self._tracker_wrapper.location_filter()
}
options = self._fast_options.copy()
@@ -705,7 +703,7 @@ class GrlTrackerWrapper(GObject.GObject):
}
LIMIT 50
""".replace('\n', ' ').strip() % {
- 'location_filter': TrackerWrapper.location_filter(),
+ 'location_filter': self._tracker_wrapper.location_filter(),
'name': term
}
@@ -760,7 +758,7 @@ class GrlTrackerWrapper(GObject.GObject):
}
LIMIT 50
""".replace('\n', ' ').strip() % {
- 'location_filter': TrackerWrapper.location_filter(),
+ 'location_filter': self._tracker_wrapper.location_filter(),
'name': term
}
@@ -821,7 +819,7 @@ class GrlTrackerWrapper(GObject.GObject):
}
LIMIT 50
""".replace('\n', ' ').strip() % {
- 'location_filter': TrackerWrapper.location_filter(),
+ 'location_filter': self._tracker_wrapper.location_filter(),
'name': term
}
@@ -903,7 +901,7 @@ class GrlTrackerWrapper(GObject.GObject):
}
""".replace("\n", " ").strip() % {
'album_id': album_id,
- 'location_filter': TrackerWrapper.location_filter()
+ 'location_filter': self._tracker_wrapper.location_filter()
}
return query
@@ -945,7 +943,7 @@ class GrlTrackerWrapper(GObject.GObject):
%(location_filter)s
}
""".replace("\n", " ").strip() % {
- 'location_filter': TrackerWrapper.location_filter(),
+ 'location_filter': self._tracker_wrapper.location_filter(),
'song_id': song_id
}
diff --git a/gnomemusic/gstplayer.py b/gnomemusic/gstplayer.py
index 0c4591f6..5cff75ab 100644
--- a/gnomemusic/gstplayer.py
+++ b/gnomemusic/gstplayer.py
@@ -23,7 +23,6 @@
# delete this exception statement from your version.
from enum import IntEnum
-import logging
from gettext import gettext as _, ngettext
import gi
@@ -32,11 +31,6 @@ gi.require_version('GstPbutils', '1.0')
from gi.repository import GLib, Gtk, Gio, GObject, Gst, GstPbutils
-from gnomemusic import log
-
-logger = logging.getLogger(__name__)
-
-
class Playback(IntEnum):
"""Playback status enumerator"""
STOPPED = 0
@@ -59,10 +53,6 @@ class GstPlayer(GObject.GObject):
"stream-start": (GObject.SignalFlags.RUN_FIRST, None, ())
}
- def __repr__(self):
- return '<GstPlayer>'
-
- @log
def __init__(self, application):
"""Initialize the GStreamer player
@@ -74,6 +64,7 @@ class GstPlayer(GObject.GObject):
self._application = application
self._duration = -1.
+ self._log = application.props.log
self._seek = False
self._tick = 0
@@ -101,7 +92,6 @@ class GstPlayer(GObject.GObject):
self.props.state = Playback.STOPPED
- @log
def _setup_replaygain(self):
"""Set up replaygain"""
self._rg_volume = Gst.ElementFactory.make("rgvolume", "rg volume")
@@ -123,21 +113,18 @@ class GstPlayer(GObject.GObject):
if (not self._filter_bin
or not self._rg_volume
or not self._rg_limiter):
- logger.debug("Replay Gain is not available")
+ self._log.message("Replay Gain is not available")
return
- @log
def _on_replaygain_setting_changed(self, settings, value):
if value:
self._player.set_property("audio-filter", self._filter_bin)
else:
self._player.set_property("audio-filter", None)
- @log
def _on_about_to_finish(self, klass):
self.emit("about-to-finish")
- @log
def _on_async_done(self, bus, message):
success, duration = self._player.query_duration(
Gst.Format.TIME)
@@ -153,23 +140,19 @@ class GstPlayer(GObject.GObject):
self.notify("state")
- @log
def _on_new_clock(self, bus, message):
clock = message.parse_new_clock()
id_ = clock.new_periodic_id(0, 1 * Gst.SECOND)
clock.id_wait_async(id_, self._on_clock_tick, None)
- @log
def _on_clock_tick(self, clock, time, id, data):
self.emit("clock-tick", self._tick)
self._tick += 1
- @log
def _on_bus_element(self, bus, message):
if GstPbutils.is_missing_plugin_message(message):
self._missing_plugin_messages.append(message)
- @log
def _on_bus_stream_start(self, bus, message):
def delayed_query():
self._on_async_done(None, None)
@@ -180,7 +163,6 @@ class GstPlayer(GObject.GObject):
# have been set yet.
GLib.timeout_add(1, delayed_query)
- @log
def _on_bus_error(self, bus, message):
if self._is_missing_plugin_message(message):
self.props.state = Playback.PAUSED
@@ -191,20 +173,18 @@ class GstPlayer(GObject.GObject):
debug = debug.split('\n')
debug = [(' ') + line.lstrip() for line in debug]
debug = '\n'.join(debug)
- logger.warning("URI: {}".format(self.props.url))
- logger.warning(
+ self._log.warning("URI: {}".format(self.props.url))
+ self._log.warning(
"Error from element {}: {}".format(
message.src.get_name(), error.message))
- logger.warning("Debugging info:\n{}".format(debug))
+ self._log.warning("Debugging info:\n{}".format(debug))
self.emit("error")
return True
- @log
def _on_bus_eos(self, bus, message):
self.emit('eos')
- @log
def _get_playback_status(self):
ok, state, pending = self._player.get_state(0)
@@ -298,7 +278,6 @@ class GstPlayer(GObject.GObject):
"""
self._duration = duration
- @log
def seek(self, seconds):
"""Seek to position
@@ -308,7 +287,6 @@ class GstPlayer(GObject.GObject):
Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT,
seconds * Gst.SECOND)
- @log
def _start_plugin_installation(
self, missing_plugin_messages, confirm_search):
install_ctx = GstPbutils.InstallPluginsContext.new()
@@ -333,7 +311,6 @@ class GstPlayer(GObject.GObject):
GstPbutils.install_plugins_async(
installer_details, install_ctx, on_install_done)
- @log
def _show_codec_confirmation_dialog(
self, install_helper_name, missing_plugin_messages):
active_window = self._application.props.active_window
@@ -355,7 +332,6 @@ class GstPlayer(GObject.GObject):
dialog.connect('response', on_dialog_response)
dialog.present()
- @log
def _handle_missing_plugins(self):
if not self._missing_plugin_messages:
return
@@ -380,7 +356,6 @@ class GstPlayer(GObject.GObject):
# codec installation.
self._start_plugin_installation(missing_plugin_messages, True)
- @log
def _is_missing_plugin_message(self, message):
error, debug = message.parse_error()
@@ -392,10 +367,6 @@ class GstPlayer(GObject.GObject):
class MissingCodecsDialog(Gtk.MessageDialog):
- def __repr__(self):
- return '<MissingCodecsDialog>'
-
- @log
def __init__(self, parent_window, install_helper_name):
super().__init__(
transient_for=parent_window, modal=True, destroy_with_parent=True,
@@ -412,7 +383,6 @@ class MissingCodecsDialog(Gtk.MessageDialog):
Gtk.StyleContext.add_class(
self.find_button.get_style_context(), 'suggested-action')
- @log
def set_codec_names(self, codec_names):
n_codecs = len(codec_names)
if n_codecs == 2:
diff --git a/gnomemusic/inhibitsuspend.py b/gnomemusic/inhibitsuspend.py
index 16e2a640..29058344 100644
--- a/gnomemusic/inhibitsuspend.py
+++ b/gnomemusic/inhibitsuspend.py
@@ -21,16 +21,11 @@
# code, but you are not obligated to do so. If you do not wish to do so,
# delete this exception statement from your version.
-import logging
-
from gettext import gettext as _
from gi.repository import Gtk, GObject
-from gnomemusic import log
from gnomemusic.gstplayer import Playback
-logger = logging.getLogger(__name__)
-
class InhibitSuspend(GObject.GObject):
"""InhibitSuspend object
@@ -39,10 +34,6 @@ class InhibitSuspend(GObject.GObject):
until the application has played all the songs in the playlist.
"""
- def __repr__(self):
- return '<InhibitSuspend>'
-
- @log
def __init__(self, application):
"""Initialize supend inhibitor
@@ -51,6 +42,7 @@ class InhibitSuspend(GObject.GObject):
super().__init__()
self._application = application
+ self._log = application.props.log
self._player = application.props.player
self._inhibit_cookie = 0
@@ -61,7 +53,6 @@ class InhibitSuspend(GObject.GObject):
self._settings.connect(
'changed::inhibit-suspend', self._on_inhibit_suspend_changed)
- @log
def _inhibit_suspend(self):
if (self._inhibit_cookie == 0
and self._should_inhibit):
@@ -72,20 +63,17 @@ class InhibitSuspend(GObject.GObject):
_("Playing music"))
if self._inhibit_cookie == 0:
- logger.warning("Unable to inhibit automatic system suspend")
+ self._log.warning("Unable to inhibit automatic system suspend")
- @log
def _uninhibit_suspend(self):
if self._inhibit_cookie != 0:
self._application.uninhibit(self._inhibit_cookie)
self._inhibit_cookie = 0
- @log
def _on_inhibit_suspend_changed(self, settings, value):
self._should_inhibit = value
self._on_player_state_changed(None, None)
- @log
def _on_player_state_changed(self, klass, arguments):
if (self._player.props.state == Playback.PLAYING
or self._player.props.state == Playback.LOADING):
diff --git a/gnomemusic/mediakeys.py b/gnomemusic/mediakeys.py
index cf89438e..f0ba1623 100644
--- a/gnomemusic/mediakeys.py
+++ b/gnomemusic/mediakeys.py
@@ -24,10 +24,7 @@
from gi.repository import GObject, Gio, GLib, Gtk
-from gnomemusic import log
-
-import logging
-logger = logging.getLogger(__name__)
+from gnomemusic.musiclogger import MusicLogger
class MediaKeys(GObject.GObject):
@@ -36,10 +33,6 @@ class MediaKeys(GObject.GObject):
__gtype_name__ = 'MediaKeys'
- def __repr__(self):
- return '<MediaKeys>'
-
- @log
def __init__(self, player, window):
"""Initialize media keys handling
@@ -48,6 +41,8 @@ class MediaKeys(GObject.GObject):
"""
super().__init__()
+ self._log = MusicLogger()
+
self._player = player
self._window = window
@@ -55,7 +50,6 @@ class MediaKeys(GObject.GObject):
self._init_media_keys_proxy()
- @log
def _init_media_keys_proxy(self):
def name_appeared(connection, name, name_owner, data=None):
Gio.DBusProxy.new_for_bus(
@@ -70,12 +64,11 @@ class MediaKeys(GObject.GObject):
Gio.BusType.SESSION, "org.gnome.SettingsDaemon.MediaKeys",
Gio.BusNameWatcherFlags.NONE, name_appeared, None)
- @log
def _media_keys_proxy_ready(self, proxy, result, data=None):
try:
self._media_keys_proxy = proxy.new_finish(result)
except GLib.Error as e:
- logger.warning(
+ self._log.warning(
"Error: Failed to contact settings daemon:", e.message)
return
@@ -85,13 +78,12 @@ class MediaKeys(GObject.GObject):
self._ctrlr.props.propagation_phase = Gtk.PropagationPhase.CAPTURE
self._ctrlr.connect("focus-in", self._grab_media_player_keys)
- @log
def _grab_media_player_keys(self, controllerkey=None):
def proxy_call_finished(proxy, result, data=None):
try:
proxy.call_finish(result)
except GLib.Error as e:
- logger.warning(
+ self._log.warning(
"Error: Failed to grab mediaplayer keys: {}".format(
e.message))
@@ -99,7 +91,6 @@ class MediaKeys(GObject.GObject):
"GrabMediaPlayerKeys", GLib.Variant("(su)", ("Music", 0)),
Gio.DBusCallFlags.NONE, -1, None, proxy_call_finished)
- @log
def _handle_media_keys(self, proxy, sender, signal, parameters):
app, response = parameters.unpack()
if app != "Music":
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index 937d86b3..2bb2b30e 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -23,28 +23,26 @@
# delete this exception statement from your version.
from itertools import chain
-import logging
import re
from gi.repository import Gio, GLib
-from gnomemusic import log
from gnomemusic.albumartcache import lookup_art_file_from_cache
-from gnomemusic.widgets.songwidget import SongWidget
from gnomemusic.gstplayer import Playback
from gnomemusic.player import PlayerPlaylist, RepeatMode
-
-logger = logging.getLogger(__name__)
+from gnomemusic.widgets.songwidget import SongWidget
class DBusInterface:
- def __init__(self, name, path):
+ def __init__(self, name, path, application):
"""Etablish a D-Bus session connection
:param str name: interface name
:param str path: object path
+ :param GtkApplication application: The Application object
"""
+ self._log = application.props.log
self._path = path
self._signals = None
Gio.bus_get(Gio.BusType.SESSION, None, self._bus_get_sync, name)
@@ -53,7 +51,7 @@ class DBusInterface:
try:
self._con = Gio.bus_get_finish(res)
except GLib.Error as e:
- logger.warning(
+ self._log.warning(
"Unable to connect to to session bus: {}".format(e.message))
return
@@ -278,15 +276,13 @@ class MPRIS(DBusInterface):
_playlist_nb_songs = 10
- def __repr__(self):
- return "<MPRIS>"
-
def __init__(self, app):
name = 'org.mpris.MediaPlayer2.GnomeMusic'
path = '/org/mpris/MediaPlayer2'
- super().__init__(name, path)
+ super().__init__(name, path, app)
self._app = app
+ self._log = app.props.log
self._player = app.props.player
self._player.connect(
'song-changed', self._on_current_song_changed)
@@ -320,7 +316,6 @@ class MPRIS(DBusInterface):
self._previous_mpris_playlist = self._get_active_playlist()
self._previous_playback_status = "Stopped"
- @log
def _get_playback_status(self):
state = self._player.props.state
if state == Playback.STOPPED:
@@ -330,7 +325,6 @@ class MPRIS(DBusInterface):
else:
return 'Playing'
- @log
def _get_loop_status(self):
if self._player.props.repeat_mode == RepeatMode.ALL:
return "Playlist"
@@ -339,7 +333,6 @@ class MPRIS(DBusInterface):
else:
return "None"
- @log
def _get_metadata(self, coresong=None, index=None):
song_dbus_path = self._get_song_dbus_path(coresong, index)
if not self._player.props.current_song:
@@ -398,7 +391,6 @@ class MPRIS(DBusInterface):
return metadata
- @log
def _get_song_dbus_path(self, coresong=None, index=None):
"""Convert a Grilo media to a D-Bus path
@@ -425,7 +417,6 @@ class MPRIS(DBusInterface):
id_hex, index)
return path
- @log
def _update_tracklist(self):
previous_path_list = self._path_list
self._path_list = []
@@ -472,7 +463,6 @@ class MPRIS(DBusInterface):
current_song_path = self._get_song_dbus_path()
self._track_list_replaced(self._path_list, current_song_path)
- @log
def _get_playlist_dbus_path(self, playlist):
"""Convert a playlist to a D-Bus path
@@ -487,13 +477,11 @@ class MPRIS(DBusInterface):
pl_id = playlist.props.pl_id or playlist.props.tag_text
return "/org/gnome/GnomeMusic/Playlist/{}".format(pl_id)
- @log
def _get_mpris_playlist_from_playlist(self, playlist):
playlist_name = playlist.props.title
path = self._get_playlist_dbus_path(playlist)
return (path, playlist_name, "")
- @log
def _get_active_playlist(self):
"""Get Active Maybe_Playlist
@@ -514,7 +502,6 @@ class MPRIS(DBusInterface):
current_playlist)
return (True, mpris_playlist)
- @log
def _on_current_song_changed(self, player):
# In repeat song mode, no metadata has changed if the
# player was already started
@@ -558,7 +545,6 @@ class MPRIS(DBusInterface):
self._properties_changed(
MPRIS.MEDIA_PLAYER2_PLAYER_IFACE, properties, [])
- @log
def _on_player_state_changed(self, klass, args):
playback_status = self._get_playback_status()
if playback_status == self._previous_playback_status:
@@ -569,7 +555,6 @@ class MPRIS(DBusInterface):
MPRIS.MEDIA_PLAYER2_PLAYER_IFACE,
{'PlaybackStatus': GLib.Variant('s', playback_status), }, [])
- @log
def _on_repeat_mode_changed(self, player, param):
self._update_tracklist()
@@ -590,12 +575,10 @@ class MPRIS(DBusInterface):
self._properties_changed(
MPRIS.MEDIA_PLAYER2_PLAYER_IFACE, properties, [])
- @log
def _on_seek_finished(self, player):
position_second = self._player.get_position()
self._seeked(int(position_second * 1e6))
- @log
def _on_player_playlist_changed(self, coremodel, playlist_type):
self._player_playlist_type = playlist_type
@@ -622,7 +605,6 @@ class MPRIS(DBusInterface):
self._properties_changed(
MPRIS.MEDIA_PLAYER2_PLAYLISTS_IFACE, properties, [])
- @log
def _on_playlist_renamed(self, playlist, param):
mpris_playlist = self._get_mpris_playlist_from_playlist(playlist)
self._dbus_emit_signal('PlaylistChanged', {'Playlist': mpris_playlist})
@@ -829,7 +811,7 @@ class MPRIS(DBusInterface):
except KeyError:
msg = "MPRIS does not handle {} property from {} interface".format(
property_name, interface_name)
- logger.warning(msg)
+ self._log.warning(msg)
raise ValueError(msg)
def _get_all(self, interface_name):
@@ -893,7 +875,7 @@ class MPRIS(DBusInterface):
elif interface_name == 'org.freedesktop.DBus.Introspectable':
return {}
else:
- logger.warning(
+ self._log.warning(
"MPRIS does not implement {} interface".format(interface_name))
def _set(self, interface_name, property_name, new_value):
@@ -916,7 +898,7 @@ class MPRIS(DBusInterface):
else:
self._player.props.repeat_mode = RepeatMode.NONE
else:
- logger.warning(
+ self._log.warning(
"MPRIS does not implement {} interface".format(interface_name))
def _properties_changed(self, interface_name, changed_properties,
diff --git a/gnomemusic/pauseonsuspend.py b/gnomemusic/pauseonsuspend.py
index eafe3df0..b75ca949 100644
--- a/gnomemusic/pauseonsuspend.py
+++ b/gnomemusic/pauseonsuspend.py
@@ -24,12 +24,9 @@
import os
from gi.repository import GLib, Gio, GObject
-import logging
-from gnomemusic import log
from gnomemusic.gstplayer import Playback
-
-logger = logging.getLogger(__name__)
+from gnomemusic.musiclogger import MusicLogger
class PauseOnSuspend(GObject.GObject):
@@ -39,10 +36,6 @@ class PauseOnSuspend(GObject.GObject):
and inhibit suspend before pause.
"""
- def __repr__(self):
- return '<PauseOnSuspend>'
-
- @log
def __init__(self, player):
"""Initialize pause on supend handling
@@ -50,6 +43,8 @@ class PauseOnSuspend(GObject.GObject):
"""
super().__init__()
+ self._log = MusicLogger()
+
self._player = player
self._init_pause_on_suspend()
@@ -59,7 +54,6 @@ class PauseOnSuspend(GObject.GObject):
self._previous_state = self._player.props.state
self._player.connect("notify::state", self._on_player_state_changed)
- @log
def _on_player_state_changed(self, klass, arguments):
new_state = self._player.props.state
if self._previous_state == new_state:
@@ -75,7 +69,6 @@ class PauseOnSuspend(GObject.GObject):
self._previous_state = new_state
- @log
def _take_lock(self):
variant = GLib.Variant(
"(ssss)",
@@ -91,7 +84,6 @@ class PauseOnSuspend(GObject.GObject):
"Inhibit", variant, Gio.DBusCallFlags.NONE,
-1, None, self._on_inhibit)
- @log
def _on_inhibit(self, proxy, task, data=None):
if not self._suspend_proxy:
return
@@ -102,17 +94,15 @@ class PauseOnSuspend(GObject.GObject):
self._connection = self._suspend_proxy.connect(
"g-signal", self._pause_playing)
except GLib.Error as e:
- logger.warning(
+ self._log.warning(
"Error: Failed to finish proxy call:", e.message)
- @log
def _release_lock(self):
if self._file_descriptor >= 0:
os.close(self._file_descriptor)
self._file_descriptor = -1
self._suspend_proxy.disconnect(self._connection)
- @log
def _init_pause_on_suspend(self):
Gio.DBusProxy.new_for_bus(
Gio.BusType.SYSTEM,
@@ -122,16 +112,14 @@ class PauseOnSuspend(GObject.GObject):
"org.freedesktop.login1.Manager", None,
self._suspend_proxy_ready)
- @log
def _suspend_proxy_ready(self, proxy, result, data=None):
try:
self._suspend_proxy = proxy.new_finish(result)
except GLib.Error as e:
- logger.warning(
+ self._log.warning(
"Error: Failed to contact logind daemon:", e.message)
return
- @log
def _pause_playing(self, proxy, sender, signal, parameters):
if signal != "PrepareForSleep":
return
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 64d38680..013295fa 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -24,7 +24,6 @@
from enum import IntEnum
from random import randint, randrange
-import logging
import time
import gi
@@ -32,15 +31,11 @@ gi.require_version('GstPbutils', '1.0')
from gi.repository import GObject, GstPbutils
from gi._gi import pygobject_new_full
-from gnomemusic import log
from gnomemusic.coresong import CoreSong
from gnomemusic.gstplayer import GstPlayer, Playback
from gnomemusic.widgets.songwidget import SongWidget
-logger = logging.getLogger(__name__)
-
-
class RepeatMode(IntEnum):
"""Enum for player repeat mode"""
NONE = 0
@@ -66,16 +61,13 @@ class PlayerPlaylist(GObject.GObject):
repeat_mode = GObject.Property(type=int, default=RepeatMode.NONE)
- def __repr__(self):
- return '<PlayerPlayList>'
-
- @log
def __init__(self, application):
super().__init__()
GstPbutils.pb_utils_init()
self._app = application
+ self._log = application.props.log
self._position = 0
self._validation_songs = {}
@@ -87,7 +79,6 @@ class PlayerPlaylist(GObject.GObject):
self.connect("notify::repeat-mode", self._on_repeat_mode_changed)
- @log
def has_next(self):
"""Test if there is a song after the current one.
@@ -101,7 +92,6 @@ class PlayerPlaylist(GObject.GObject):
return False
- @log
def has_previous(self):
"""Test if there is a song before the current one.
@@ -135,7 +125,6 @@ class PlayerPlaylist(GObject.GObject):
return self._model[next_position]
- @log
def next(self):
"""Go to the next song in the playlist.
@@ -164,7 +153,6 @@ class PlayerPlaylist(GObject.GObject):
self._validate_next_song()
return True
- @log
def previous(self):
"""Go to the previous song in the playlist.
@@ -258,7 +246,6 @@ class PlayerPlaylist(GObject.GObject):
return None
- @log
def _on_repeat_mode_changed(self, klass, param):
def _wrap_list_store_sort_func(func):
@@ -287,11 +274,11 @@ class PlayerPlaylist(GObject.GObject):
url = coresong.props.url
if not url:
- logger.warning(
+ self._log.warning(
"The item {} doesn't have a URL set.".format(coresong))
return
if not url.startswith("file://"):
- logger.debug(
+ self._log.debug(
"Skipping validation of {} as not a local file".format(url))
return
@@ -330,7 +317,7 @@ class PlayerPlaylist(GObject.GObject):
coresong = self._validation_songs[url]
if error:
- logger.warning("Info {}: error: {}".format(info, error))
+ self._log.warning("Info {}: error: {}".format(info, error))
coresong.props.validation = CoreSong.Validation.FAILED
else:
coresong.props.validation = CoreSong.Validation.SUCCEEDED
@@ -350,10 +337,6 @@ class Player(GObject.GObject):
state = GObject.Property(type=int, default=Playback.STOPPED)
duration = GObject.Property(type=float, default=-1.)
- def __repr__(self):
- return '<Player>'
-
- @log
def __init__(self, application):
"""Initialize the player
@@ -369,7 +352,7 @@ class Player(GObject.GObject):
# TODO: Improve playlist handling so this hack is no longer
# needed.
self._gapless_set = False
-
+ self._log = application.props.log
self._playlist = PlayerPlaylist(self._app)
self._playlist_model = self._app.props.coremodel.props.playlist_sort
@@ -436,7 +419,6 @@ class Player(GObject.GObject):
and model.get_n_items() == 0):
self.stop()
- @log
def _on_about_to_finish(self, klass):
if self.props.has_next:
next_coresong = self._playlist.get_next()
@@ -444,7 +426,6 @@ class Player(GObject.GObject):
self._gst_player.props.url = new_url
self._gapless_set = True
- @log
def _on_eos(self, klass):
self._playlist.next()
@@ -508,17 +489,14 @@ class Player(GObject.GObject):
if self.props.current_song is not None:
self._gst_player.props.state = Playback.PLAYING
- @log
def pause(self):
"""Pause"""
self._gst_player.props.state = Playback.PAUSED
- @log
def stop(self):
"""Stop"""
self._gst_player.props.state = Playback.STOPPED
- @log
def next(self):
""""Play next song
@@ -527,7 +505,6 @@ class Player(GObject.GObject):
if self._playlist.next():
self.play(self._playlist.props.current_song)
- @log
def previous(self):
"""Play previous song
@@ -541,7 +518,6 @@ class Player(GObject.GObject):
if self._playlist.previous():
self.play(self._playlist.props.current_song)
- @log
def play_pause(self):
"""Toggle play/pause state"""
if self.props.state == Playback.PLAYING:
@@ -549,9 +525,8 @@ class Player(GObject.GObject):
else:
self.play()
- @log
def _on_clock_tick(self, klass, tick):
- logger.debug("Clock tick {}, player at {} seconds".format(
+ self._log.debug("Clock tick {}, player at {} seconds".format(
tick, self._gst_player.props.position))
current_song = self._playlist.props.current_song
@@ -582,7 +557,6 @@ class Player(GObject.GObject):
current_song.bump_play_count()
current_song.set_last_played()
- @log
def _on_repeat_setting_changed(self, settings, value):
self.props.repeat_mode = settings.get_enum('repeat')
@@ -617,7 +591,6 @@ class Player(GObject.GObject):
"""
return self._playlist.props.current_song
- @log
def get_position(self):
"""Get player position.
@@ -628,7 +601,6 @@ class Player(GObject.GObject):
return self._gst_player.props.position
# TODO: used by MPRIS
- @log
def set_position(self, position_second):
"""Change GstPlayer position.
@@ -643,7 +615,6 @@ class Player(GObject.GObject):
if position_second <= duration_second:
self._gst_player.seek(position_second)
- @log
def _on_seek_finished(self, klass):
# FIXME: Just a proxy
self.emit('seek-finished')
diff --git a/gnomemusic/scrobbler.py b/gnomemusic/scrobbler.py
index fbaf377b..331b1ba0 100644
--- a/gnomemusic/scrobbler.py
+++ b/gnomemusic/scrobbler.py
@@ -24,20 +24,16 @@
from enum import IntEnum
from hashlib import md5
-import logging
import gi
gi.require_version('Goa', '1.0')
gi.require_version('Soup', '2.4')
from gi.repository import GLib, Goa, GObject, Soup
-from gnomemusic import log
+from gnomemusic.musiclogger import MusicLogger
import gnomemusic.utils as utils
-logger = logging.getLogger(__name__)
-
-
class GoaLastFM(GObject.GObject):
"""Last.fm account handling through GOA
"""
@@ -49,13 +45,11 @@ class GoaLastFM(GObject.GObject):
DISABLED = 1
ENABLED = 2
- def __repr__(self):
- return '<GoaLastFM>'
-
- @log
def __init__(self):
super().__init__()
+ self._log = MusicLogger()
+
self._client = None
self._reset_attributes()
Goa.Client.new(None, self._new_client_callback)
@@ -67,12 +61,11 @@ class GoaLastFM(GObject.GObject):
self._music_disabled_id = None
self.notify("state")
- @log
def _new_client_callback(self, source, result):
try:
self._client = source.new_finish(result)
except GLib.Error as error:
- logger.warning("Error: {}, {}".format(
+ self._log.warning("Error: {}, {}".format(
Goa.Error(error.code), error.message))
return
@@ -89,7 +82,6 @@ class GoaLastFM(GObject.GObject):
self._account.disconnect(self._music_disabled_id)
self._reset_attributes()
- @log
def _find_lastfm_account(self):
accounts = self._client.get_accounts()
@@ -103,7 +95,6 @@ class GoaLastFM(GObject.GObject):
self._goa_music_disabled(self._account)
break
- @log
def _goa_music_disabled(self, klass, args=None):
if self._account.props.music_disabled is True:
self._state = GoaLastFM.State.DISABLED
@@ -141,7 +132,7 @@ class GoaLastFM(GObject.GObject):
try:
return self._authentication.call_get_access_token_sync(None)[0]
except GLib.Error as e:
- logger.warning(
+ self._log.warning(
"Error: Unable to retrieve last.fm session key", e.message)
return None
@@ -149,10 +140,6 @@ class GoaLastFM(GObject.GObject):
class LastFmScrobbler(GObject.GObject):
"""Scrobble songs to Last.fm"""
- def __repr__(self):
- return '<LastFmScrobbler>'
-
- @log
def __init__(self, application):
"""Intialize LastFm Scrobbler
@@ -160,6 +147,7 @@ class LastFmScrobbler(GObject.GObject):
"""
super().__init__()
+ self._log = application.props.log
self._settings = application.props.settings
self._report = self._settings.get_boolean("lastfm-report")
@@ -236,13 +224,12 @@ class LastFmScrobbler(GObject.GObject):
def scrobbled(self, scrobbled):
self._scrobbled = scrobbled
- @log
def _lastfm_api_call(self, media, time_stamp, request_type_key):
"""Internal method called by self.scrobble"""
api_key = self._goa_lastfm.client_id
sk = self._goa_lastfm.session_key
if sk is None:
- logger.warning(
+ self._log.warning(
"Error: Unable to perform last.fm api call", request_type_key)
return
secret = self._goa_lastfm.secret
@@ -317,19 +304,17 @@ class LastFmScrobbler(GObject.GObject):
self._soup_session.queue_message(
msg, self._lastfm_api_callback, request_type_key)
- @log
def _lastfm_api_callback(self, session, msg, request_type_key):
"""Internall callback method called by queue_message"""
status_code = msg.props.status_code
if status_code != 200:
- logger.warning("Failed to {} track {} : {}".format(
+ self._log.debug("Failed to {} track {} : {}".format(
request_type_key, status_code, msg.props.reason_phrase))
- logger.warning(msg.props.response_body.data)
+ self._log.debug(msg.props.response_body.data)
elif (status_code == 200
and request_type_key == "scrobble"):
self._scrobble_cache.clear()
- @log
def scrobble(self, coresong, time_stamp):
"""Scrobble a song to Last.fm.
@@ -346,7 +331,6 @@ class LastFmScrobbler(GObject.GObject):
media = coresong.props.media
self._lastfm_api_call(media, time_stamp, "scrobble")
- @log
def now_playing(self, coresong):
"""Set now playing song to Last.fm
diff --git a/gnomemusic/search.py b/gnomemusic/search.py
index 2428f0e3..3e2a85cc 100644
--- a/gnomemusic/search.py
+++ b/gnomemusic/search.py
@@ -26,8 +26,6 @@ from enum import IntEnum
from gi.repository import GObject
-from gnomemusic import log
-
class Search(GObject.GObject):
@@ -45,9 +43,5 @@ class Search(GObject.GObject):
search_mode_active = GObject.Property(type=bool, default=False)
state = GObject.Property(type=int, default=0)
- def __repr__(self):
- return "<Search>"
-
- @log
def __init__(self):
super().__init__()
diff --git a/gnomemusic/trackerwrapper.py b/gnomemusic/trackerwrapper.py
index 06e406e9..0990eedb 100644
--- a/gnomemusic/trackerwrapper.py
+++ b/gnomemusic/trackerwrapper.py
@@ -22,11 +22,10 @@
# delete this exception statement from your version.
from enum import IntEnum
-import logging
from gi.repository import GLib, GObject, Tracker
-logger = logging.getLogger(__name__)
+from gnomemusic.musiclogger import MusicLogger
class TrackerState(IntEnum):
@@ -40,12 +39,11 @@ class TrackerState(IntEnum):
class TrackerWrapper(GObject.GObject):
"""Create a connection to an instance of Tracker"""
- def __repr__(self):
- return "<TrackerWrapper>"
-
def __init__(self):
super().__init__()
+ self._log = MusicLogger()
+
self._tracker = None
self._tracker_available = TrackerState.UNAVAILABLE
@@ -55,7 +53,8 @@ class TrackerWrapper(GObject.GObject):
try:
self._tracker = Tracker.SparqlConnection.get_finish(result)
except GLib.Error as error:
- logger.warning("Error: {}, {}".format(error.domain, error.message))
+ self._log.warning(
+ "Error: {}, {}".format(error.domain, error.message))
self.notify("tracker-available")
return
@@ -69,7 +68,8 @@ class TrackerWrapper(GObject.GObject):
klass.query_finish(result)
self._tracker_available = TrackerState.AVAILABLE
except GLib.Error as error:
- logger.warning("Error: {}, {}".format(error.domain, error.message))
+ self._log.warning(
+ "Error: {}, {}".format(error.domain, error.message))
self._tracker_available = TrackerState.OUTDATED
self.notify("tracker-available")
@@ -92,14 +92,13 @@ class TrackerWrapper(GObject.GObject):
"""
return self._tracker_available
- @staticmethod
- def location_filter():
+ def location_filter(self):
try:
music_dir = GLib.get_user_special_dir(
GLib.UserDirectory.DIRECTORY_MUSIC)
assert music_dir is not None
except (TypeError, AssertionError):
- logger.warning("XDG Music dir is not set")
+ self._log.message("XDG Music dir is not set")
return None
music_dir = Tracker.sparql_escape_string(
diff --git a/gnomemusic/views/albumsview.py b/gnomemusic/views/albumsview.py
index 35d20b0f..22a12d82 100644
--- a/gnomemusic/views/albumsview.py
+++ b/gnomemusic/views/albumsview.py
@@ -47,9 +47,6 @@ class AlbumsView(Gtk.Stack):
_scrolled_window = Gtk.Template.Child()
_flowbox = Gtk.Template.Child()
- def __repr__(self):
- return '<AlbumsView>'
-
def __init__(self, application, player=None):
"""Initialize AlbumsView
diff --git a/gnomemusic/views/artistsview.py b/gnomemusic/views/artistsview.py
index 2ed4ad35..9876bf7d 100644
--- a/gnomemusic/views/artistsview.py
+++ b/gnomemusic/views/artistsview.py
@@ -22,17 +22,13 @@
# code, but you are not obligated to do so. If you do not wish to do so,
# delete this exception statement from your version.
-import logging
from gettext import gettext as _
from gi.repository import Gdk, Gtk
-from gnomemusic import log
from gnomemusic.views.baseview import BaseView
from gnomemusic.widgets.artistalbumswidget import ArtistAlbumsWidget
from gnomemusic.widgets.artisttile import ArtistTile
-logger = logging.getLogger(__name__)
-
class ArtistsView(BaseView):
"""Main view of all available artists
@@ -41,10 +37,6 @@ class ArtistsView(BaseView):
all albums by this artist on the right side.
"""
- def __repr__(self):
- return '<ArtistsView>'
-
- @log
def __init__(self, application, player):
"""Initialize
@@ -130,7 +122,6 @@ class ArtistsView(BaseView):
self._sidebar.select_row(first_row)
self._on_artist_activated(self._sidebar, first_row)
- @log
def _setup_view(self):
self._view_container = Gtk.ScrolledWindow(hexpand=True, vexpand=True)
self._box.pack_start(self._view_container, True, True, 0)
@@ -140,7 +131,6 @@ class ArtistsView(BaseView):
vhomogeneous=False)
self._view_container.add(self._view)
- @log
def _on_artist_activated(self, sidebar, row, data=None):
"""Initializes new artist album widgets"""
# On application start the first row of ArtistView is activated
@@ -179,7 +169,6 @@ class ArtistsView(BaseView):
self._loaded_artists.append(coreartist.props.artist)
- @log
def _on_sidebar_clicked(self, gesture, n_press, x, y):
success, state = Gtk.get_current_event_state()
modifiers = Gtk.accelerator_get_default_mod_mask()
@@ -187,7 +176,6 @@ class ArtistsView(BaseView):
and not self.props.selection_mode):
self.props.selection_mode = True
- @log
def _on_selection_mode_changed(self, widget, data=None):
if self.get_parent().get_visible_child() != self:
return
@@ -212,7 +200,6 @@ class ArtistsView(BaseView):
self._sidebar.select_row(selected_row)
self._selected_artist = None
- @log
def _toggle_all_selection(self, selected):
def toggle_selection(child):
@@ -220,10 +207,8 @@ class ArtistsView(BaseView):
self._sidebar.foreach(toggle_selection)
- @log
def select_all(self):
self._toggle_all_selection(True)
- @log
def deselect_all(self):
self._toggle_all_selection(False)
diff --git a/gnomemusic/views/baseview.py b/gnomemusic/views/baseview.py
index 80235b52..0323c42e 100644
--- a/gnomemusic/views/baseview.py
+++ b/gnomemusic/views/baseview.py
@@ -24,18 +24,12 @@
from gi.repository import GObject, Gtk
-from gnomemusic import log
-
class BaseView(Gtk.Stack):
"""Base Class for all view classes"""
selection_mode = GObject.Property(type=bool, default=False)
- def __repr__(self):
- return '<BaseView>'
-
- @log
def __init__(self, name, title, application, sidebar=None):
"""Initialize
:param name: The view name
@@ -72,12 +66,10 @@ class BaseView(Gtk.Stack):
self._selection_mode_id = self.connect(
"notify::selection-mode", self._on_selection_mode_changed)
- @log
def _setup_view(self):
"""Instantiate and set up the view object"""
pass
- @log
def _on_selection_mode_changed(self, widget, data=None):
if self.get_parent().get_visible_child() != self:
return
diff --git a/gnomemusic/views/emptyview.py b/gnomemusic/views/emptyview.py
index 0c01287a..2736f085 100644
--- a/gnomemusic/views/emptyview.py
+++ b/gnomemusic/views/emptyview.py
@@ -27,7 +27,6 @@ from enum import IntEnum
from gettext import gettext as _
from gi.repository import GLib, GObject, Gtk, Tracker
-from gnomemusic import log
from gnomemusic.albumartcache import Art
@@ -56,10 +55,6 @@ class EmptyView(Gtk.Stack):
_main_label = Gtk.Template.Child()
_icon = Gtk.Template.Child()
- def __repr__(self):
- return "<EmptyView>"
-
- @log
def __init__(self):
super().__init__()
@@ -113,7 +108,6 @@ class EmptyView(Gtk.Stack):
self._set_tracker_outdated_state()
self.show_all()
- @log
def _set_initial_state(self):
self._information_label.props.label = self._content_text
self._main_label.props.label = _("Hey DJ")
@@ -124,19 +118,16 @@ class EmptyView(Gtk.Stack):
self._icon.props.height_request = Art.Size.LARGE.height
self._icon.props.width_request = Art.Size.LARGE.width
- @log
def _set_empty_state(self):
self._main_label.props.label = _("No music found")
self._information_label.props.label = self._content_text
- @log
def _set_search_state(self):
self._main_label.props.margin_bottom = 12
self._main_label.props.label = _("No music found")
self._icon.props.margin_bottom = 18
self._information_label.props.label = _("Try a different search")
- @log
def _set_no_tracker_state(self):
self._main_label.props.margin_bottom = 12
self._main_label.props.label = _(
@@ -147,7 +138,6 @@ class EmptyView(Gtk.Stack):
self._icon.props.icon_name = "dialog-error-symbolic"
- @log
def _set_tracker_outdated_state(self):
self._main_label.props.margin_bottom = 12
self._main_label.props.label = _(
@@ -158,12 +148,10 @@ class EmptyView(Gtk.Stack):
self._icon.props.icon_name = "dialog-error-symbolic"
- @log
def select_all(self):
"""Cannot select songs from EmptyView."""
pass
- @log
def deselect_all(self):
"""Cannot select songs from EmptyView."""
pass
diff --git a/gnomemusic/views/playlistsview.py b/gnomemusic/views/playlistsview.py
index b04e7b17..0c695a48 100644
--- a/gnomemusic/views/playlistsview.py
+++ b/gnomemusic/views/playlistsview.py
@@ -26,7 +26,6 @@ from gettext import gettext as _
from gi.repository import Gdk, GObject, Gtk
-from gnomemusic import log
from gnomemusic.player import PlayerPlaylist
from gnomemusic.views.baseview import BaseView
from gnomemusic.widgets.playlistcontextmenu import PlaylistContextMenu
@@ -40,10 +39,6 @@ from gnomemusic.widgets.songwidget import SongWidget
class PlaylistsView(BaseView):
"""Main view for playlists"""
- def __repr__(self):
- return '<PlaylistsView>'
-
- @log
def __init__(self, application, player):
"""Initialize
@@ -106,7 +101,6 @@ class PlaylistsView(BaseView):
self.show_all()
- @log
def _setup_view(self):
view_container = Gtk.ScrolledWindow(hexpand=True, vexpand=True)
self._box.pack_start(view_container, True, True, 0)
@@ -125,7 +119,6 @@ class PlaylistsView(BaseView):
view_container.add(self._view)
- @log
def _add_playlist_to_sidebar(self, playlist):
"""Add a playlist to sidebar
@@ -154,7 +147,6 @@ class PlaylistsView(BaseView):
self._sidebar.select_row(row_next)
self._on_playlist_activated(self._sidebar, row_next, True)
- @log
def _on_view_right_clicked(self, gesture, n_press, x, y):
requested_row = self._view.get_row_at_y(y)
self._view.select_row(requested_row)
@@ -169,7 +161,6 @@ class PlaylistsView(BaseView):
self._song_popover.props.pointing_to = rect
self._song_popover.popup()
- @log
def _play_song(self, menuitem, data=None):
selected_row = self._view.get_selected_row()
song_widget = selected_row.get_child()
@@ -189,7 +180,6 @@ class PlaylistsView(BaseView):
self._view.unselect_all()
playlist_dialog.destroy()
- @log
def _stage_song_for_deletion(self, menuitem, data=None):
selected_row = self._view.get_selected_row()
position = selected_row.get_index()
@@ -204,7 +194,6 @@ class PlaylistsView(BaseView):
PlaylistNotification.Type.SONG, selected_playlist, position,
coresong)
- @log
def _on_playlist_activated(self, sidebar, row, untouched=False):
"""Update view with content from selected playlist"""
if untouched is False:
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index 9bc223c2..7b4f1a6d 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -25,7 +25,6 @@
from gettext import gettext as _
from gi.repository import Gdk, GObject, Gtk
-from gnomemusic import log
from gnomemusic.player import PlayerPlaylist
from gnomemusic.search import Search
from gnomemusic.widgets.albumcover import AlbumCover
@@ -61,10 +60,6 @@ class SearchView(Gtk.Stack):
_view_all_albums = Gtk.Template.Child()
_view_all_artists = Gtk.Template.Child()
- def __repr__(self):
- return '<SearchView>'
-
- @log
def __init__(self, application, player=None):
"""Initialize SearchView
@@ -407,7 +402,6 @@ class SearchView(Gtk.Stack):
def deselect_all(self):
self._select_all(False)
- @log
def _back_button_clicked(self, widget, data=None):
if self.get_visible_child() == self._search_results:
return
@@ -420,7 +414,6 @@ class SearchView(Gtk.Stack):
self.props.search_mode_active = True
self._headerbar.props.state = HeaderBar.State.MAIN
- @log
def _on_selection_mode_changed(self, widget, data=None):
if (not self.props.selection_mode
and self.get_parent().get_visible_child() == self):
diff --git a/gnomemusic/views/songsview.py b/gnomemusic/views/songsview.py
index 7e70eed4..e3ce8778 100644
--- a/gnomemusic/views/songsview.py
+++ b/gnomemusic/views/songsview.py
@@ -22,19 +22,15 @@
# code, but you are not obligated to do so. If you do not wish to do so,
# delete this exception statement from your version.
-import logging
from gettext import gettext as _
from gi.repository import Gdk, Gtk, Pango
-from gnomemusic import log
from gnomemusic.coresong import CoreSong
from gnomemusic.player import PlayerPlaylist
from gnomemusic.utils import SongStateIcon
from gnomemusic.views.baseview import BaseView
from gnomemusic.widgets.starhandlerwidget import StarHandlerWidget
-logger = logging.getLogger(__name__)
-
class SongsView(BaseView):
"""Main view of all songs sorted artistwise
@@ -43,10 +39,6 @@ class SongsView(BaseView):
and the album name.
"""
- def __repr__(self):
- return '<SongsView>'
-
- @log
def __init__(self, application, player):
"""Initialize
@@ -70,7 +62,6 @@ class SongsView(BaseView):
self._model = self._view.props.model
self._view.show()
- @log
def _setup_view(self):
view_container = Gtk.ScrolledWindow(hexpand=True, vexpand=True)
self._box.pack_start(view_container, True, True, 0)
@@ -90,7 +81,6 @@ class SongsView(BaseView):
view_container.add(self._view)
- @log
def _add_list_renderers(self):
now_playing_symbol_renderer = Gtk.CellRendererPixbuf(
xpad=0, xalign=0.5, yalign=0.5)
@@ -155,7 +145,6 @@ class SongsView(BaseView):
else:
cell.props.visible = False
- @log
def _on_selection_mode_changed(self, widget, data=None):
if self.get_parent().get_visible_child() != self:
return
@@ -165,7 +154,6 @@ class SongsView(BaseView):
cols = self._view.get_columns()
cols[1].props.visible = self.props.selection_mode
- @log
def _on_item_activated(self, treeview, path, column):
"""Action performed when clicking on a song
@@ -190,7 +178,6 @@ class SongsView(BaseView):
self._player.play(coresong)
- @log
def _on_view_clicked(self, gesture, n_press, x, y):
"""Ctrl+click on self._view triggers selection mode."""
_, state = Gtk.get_current_event_state()
@@ -211,7 +198,6 @@ class SongsView(BaseView):
self._model[iter_][1] = new_fav_status
self._model[iter_][7].props.selected = new_fav_status
- @log
def _update_model(self, player):
"""Updates model when the song changes
diff --git a/gnomemusic/widgets/aboutdialog.py b/gnomemusic/widgets/aboutdialog.py
index 84630b81..ac8b20e2 100644
--- a/gnomemusic/widgets/aboutdialog.py
+++ b/gnomemusic/widgets/aboutdialog.py
@@ -24,8 +24,6 @@
from gi.repository import Gtk
-from gnomemusic import log
-
@Gtk.Template(resource_path='/org/gnome/Music/ui/AboutDialog.ui')
class AboutDialog(Gtk.AboutDialog):
@@ -33,15 +31,10 @@ class AboutDialog(Gtk.AboutDialog):
__gtype_name__ = 'AboutDialog'
- def __repr__(self):
- return '<AboutDialog>'
-
- @log
def __init__(self):
super().__init__()
self.connect("response", self._about_response)
- @log
def _about_response(self, klass, data=None):
klass.destroy()
diff --git a/gnomemusic/widgets/albumcover.py b/gnomemusic/widgets/albumcover.py
index 7b9cfaa7..89e97798 100644
--- a/gnomemusic/widgets/albumcover.py
+++ b/gnomemusic/widgets/albumcover.py
@@ -26,7 +26,6 @@ import gi
gi.require_version('Grl', '0.3')
from gi.repository import Gdk, GObject, Gtk
-from gnomemusic import log
from gnomemusic.albumartcache import Art
from gnomemusic.corealbum import CoreAlbum
from gnomemusic.widgets.twolinetip import TwoLineTip
@@ -54,10 +53,6 @@ class AlbumCover(Gtk.FlowBoxChild):
selection_mode = GObject.Property(
type=bool, default=False, flags=GObject.ParamFlags.READWRITE)
- def __repr__(self):
- return '<AlbumCover>'
-
- @log
def __init__(self, corealbum):
"""Initialize the AlbumCover
@@ -122,7 +117,6 @@ class AlbumCover(Gtk.FlowBoxChild):
return self._corealbum
@Gtk.Template.Callback()
- @log
def _on_album_event(self, evbox, event, data=None):
modifiers = Gtk.accelerator_get_default_mod_mask()
if ((event.get_state() & modifiers) == Gdk.ModifierType.CONTROL_MASK
@@ -133,7 +127,6 @@ class AlbumCover(Gtk.FlowBoxChild):
self.props.selected = not self.props.selected
@Gtk.Template.Callback()
- @log
def _on_tooltip_query(self, widget, x, y, kb, tooltip, data=None):
tooltip.set_custom(self._tooltip)
diff --git a/gnomemusic/widgets/appmenu.py b/gnomemusic/widgets/appmenu.py
index 101c447a..80590751 100644
--- a/gnomemusic/widgets/appmenu.py
+++ b/gnomemusic/widgets/appmenu.py
@@ -36,9 +36,6 @@ class AppMenu(Gtk.PopoverMenu):
_lastfm_box = Gtk.Template.Child()
_lastfm_switch = Gtk.Template.Child()
- def __repr__(self):
- return "<AppMenu>"
-
def __init__(self, application):
"""Initialize the application menu
diff --git a/gnomemusic/widgets/artistalbumswidget.py b/gnomemusic/widgets/artistalbumswidget.py
index e867e61c..e87922da 100644
--- a/gnomemusic/widgets/artistalbumswidget.py
+++ b/gnomemusic/widgets/artistalbumswidget.py
@@ -22,16 +22,11 @@
# code, but you are not obligated to do so. If you do not wish to do so,
# delete this exception statement from your version.
-import logging
-
from gi.repository import GObject, Gtk
-from gnomemusic import log
from gnomemusic.player import PlayerPlaylist
from gnomemusic.widgets.artistalbumwidget import ArtistAlbumWidget
-logger = logging.getLogger(__name__)
-
class ArtistAlbumsWidget(Gtk.ListBox):
"""Widget containing all albums by an artist
@@ -45,10 +40,6 @@ class ArtistAlbumsWidget(Gtk.ListBox):
selection_mode = GObject.Property(type=bool, default=False)
- def __repr__(self):
- return '<ArtistAlbumsWidget>'
-
- @log
def __init__(
self, coreartist, application, selection_mode_allowed=False):
super().__init__()
@@ -105,13 +96,11 @@ class ArtistAlbumsWidget(Gtk.ListBox):
return row
- @log
def select_all(self):
"""Select all items"""
for widget in self._widgets:
widget.select_all()
- @log
def deselect_all(self):
"""Deselect all items"""
for widget in self._widgets:
diff --git a/gnomemusic/widgets/artistalbumwidget.py b/gnomemusic/widgets/artistalbumwidget.py
index b9c35ba1..2c7e5d73 100644
--- a/gnomemusic/widgets/artistalbumwidget.py
+++ b/gnomemusic/widgets/artistalbumwidget.py
@@ -24,7 +24,6 @@
from gi.repository import GObject, Gtk
-from gnomemusic import log
from gnomemusic.albumartcache import Art
from gnomemusic.widgets.disclistboxwidget import DiscBox
from gnomemusic.widgets.songwidget import SongWidget
@@ -48,9 +47,6 @@ class ArtistAlbumWidget(Gtk.Box):
),
}
- def __repr__(self):
- return '<ArtistAlbumWidget>'
-
def __init__(
self, corealbum, selection_mode_allowed, size_group=None,
cover_size_group=None):
@@ -128,12 +124,10 @@ class ArtistAlbumWidget(Gtk.Box):
self.emit("song-activated", song_widget)
- @log
def select_all(self):
"""Select all items"""
self._disc_list_box.select_all()
- @log
def deselect_all(self):
"""Deselect all items"""
self._disc_list_box.deselect_all()
diff --git a/gnomemusic/widgets/artistartstack.py b/gnomemusic/widgets/artistartstack.py
index a88a6abe..103a3596 100644
--- a/gnomemusic/widgets/artistartstack.py
+++ b/gnomemusic/widgets/artistartstack.py
@@ -24,7 +24,6 @@
from gi.repository import GLib, GObject, Gtk
-from gnomemusic import log
from gnomemusic.albumartcache import Art
from gnomemusic.artistart import ArtistCache, DefaultIcon
from gnomemusic.coreartist import CoreArtist
@@ -42,10 +41,6 @@ class ArtistArtStack(Gtk.Stack):
_default_icon = DefaultIcon()
- def __repr__(self):
- return "ArtistArtStack"
-
- @log
def __init__(self, size=Art.Size.MEDIUM):
"""Initialize the CoverStack
@@ -123,7 +118,6 @@ class ArtistArtStack(Gtk.Stack):
self._cover_b.props.surface = surface
self.props.visible_child_name = "B"
- @log
def update(self, coresong):
"""Update the stack with the given CoreSong
@@ -145,7 +139,6 @@ class ArtistArtStack(Gtk.Stack):
self._handler_id = self._art.connect("finished", self._art_retrieved)
self._art.lookup()
- @log
def _set_loading_child(self):
self.props.visible_child_name = "loading"
self._active_child = self.props.visible_child_name
@@ -153,7 +146,6 @@ class ArtistArtStack(Gtk.Stack):
return GLib.SOURCE_REMOVE
- @log
def _art_retrieved(self, klass):
if self._timeout:
GLib.source_remove(self._timeout)
diff --git a/gnomemusic/widgets/artistsearchtile.py b/gnomemusic/widgets/artistsearchtile.py
index b6751d5f..cd2e74ac 100644
--- a/gnomemusic/widgets/artistsearchtile.py
+++ b/gnomemusic/widgets/artistsearchtile.py
@@ -51,9 +51,6 @@ class ArtistSearchTile(Gtk.FlowBoxChild):
selection_mode = GObject.Property(
type=bool, default=False, flags=GObject.ParamFlags.READWRITE)
- def __repr__(self):
- return "<ArtistSearchTile>"
-
def __init__(self, coreartist):
"""Initialize the ArtistSearchTile
diff --git a/gnomemusic/widgets/artisttile.py b/gnomemusic/widgets/artisttile.py
index 577349f1..0c092060 100644
--- a/gnomemusic/widgets/artisttile.py
+++ b/gnomemusic/widgets/artisttile.py
@@ -24,7 +24,6 @@
from gi.repository import GObject, Gtk
-from gnomemusic import log
from gnomemusic.coreartist import CoreArtist
@@ -46,10 +45,6 @@ class ArtistTile(Gtk.ListBoxRow):
selection_mode = GObject.Property(type=bool, default=False)
text = GObject.Property(type=str, default='')
- def __repr__(self):
- return '<ArtistTile>'
-
- @log
def __init__(self, coreartist=None):
super().__init__()
diff --git a/gnomemusic/widgets/coverstack.py b/gnomemusic/widgets/coverstack.py
index ae9eff81..72d0a3af 100644
--- a/gnomemusic/widgets/coverstack.py
+++ b/gnomemusic/widgets/coverstack.py
@@ -24,7 +24,6 @@
from gi.repository import GLib, GObject, Gtk
-from gnomemusic import log
from gnomemusic.albumartcache import Art, DefaultIcon
@@ -44,10 +43,6 @@ class CoverStack(Gtk.Stack):
_default_icon = DefaultIcon()
- def __repr__(self):
- return '<CoverStack>'
-
- @log
def __init__(self, size=Art.Size.MEDIUM):
"""Initialize the CoverStack
@@ -95,7 +90,6 @@ class CoverStack(Gtk.Stack):
DefaultIcon.Type.LOADING, self.props.size, self.props.scale_factor)
self._loading_cover.props.surface = icon
- @log
def update(self, coresong):
"""Update the stack with the given CoreSong
@@ -117,7 +111,6 @@ class CoverStack(Gtk.Stack):
self._handler_id = self._art.connect('finished', self._art_retrieved)
self._art.lookup()
- @log
def _set_loading_child(self):
self.props.visible_child_name = "loading"
self._active_child = self.props.visible_child_name
@@ -125,7 +118,6 @@ class CoverStack(Gtk.Stack):
return GLib.SOURCE_REMOVE
- @log
def _art_retrieved(self, klass):
if self._timeout:
GLib.source_remove(self._timeout)
diff --git a/gnomemusic/widgets/headerbar.py b/gnomemusic/widgets/headerbar.py
index 07a669c0..909974a2 100644
--- a/gnomemusic/widgets/headerbar.py
+++ b/gnomemusic/widgets/headerbar.py
@@ -27,7 +27,6 @@ from enum import IntEnum
from gettext import gettext as _, ngettext
from gi.repository import GObject, Gtk
-from gnomemusic import log
from gnomemusic.widgets.appmenu import AppMenu
@@ -42,9 +41,6 @@ class SelectionBarMenuButton(Gtk.MenuButton):
_menu_label = Gtk.Template.Child()
- def __repr__(self):
- return "<SelectionBarMenuButton>"
-
def __init__(self):
super().__init__()
@@ -103,10 +99,6 @@ class HeaderBar(Gtk.HeaderBar):
selection_mode_allowed = GObject.Property(type=bool, default=True)
stack = GObject.Property(type=Gtk.Stack)
- def __repr__(self):
- return "<HeaderBar>"
-
- @log
def __init__(self, application):
"""Initialize Headerbar
@@ -210,16 +202,13 @@ class HeaderBar(Gtk.HeaderBar):
self._stack_switcher.show()
@Gtk.Template.Callback()
- @log
def _on_back_button_clicked(self, widget=None):
self.emit('back-button-clicked')
@Gtk.Template.Callback()
- @log
def _on_cancel_button_clicked(self, button):
self.props.selection_mode = False
- @log
def _update(self):
if self.props.selection_mode:
self.props.custom_title = self._selection_menu
@@ -239,7 +228,6 @@ class HeaderBar(Gtk.HeaderBar):
and self.props.state == HeaderBar.State.MAIN
)
- @log
def _on_selection_mode_allowed_changed(self, widget, data):
if self.props.selection_mode_allowed:
self._select_button.props.sensitive = True
diff --git a/gnomemusic/widgets/notificationspopup.py b/gnomemusic/widgets/notificationspopup.py
index dccfdf3a..25025149 100644
--- a/gnomemusic/widgets/notificationspopup.py
+++ b/gnomemusic/widgets/notificationspopup.py
@@ -26,8 +26,6 @@ from enum import IntEnum
from gettext import gettext as _
from gi.repository import GLib, GObject, Gtk
-from gnomemusic import log
-
class NotificationsPopup(Gtk.Revealer):
"""Display notification messages as popups
@@ -40,16 +38,11 @@ class NotificationsPopup(Gtk.Revealer):
__gtype_name__ = "NotificationsPopup"
- def __repr__(self):
- return '<NotificationsPopup>'
-
- @log
def __init__(self):
super().__init__()
self._setup_view()
- @log
def _setup_view(self):
frame = Gtk.Frame()
frame.get_style_context().add_class('app-notification')
@@ -67,14 +60,12 @@ class NotificationsPopup(Gtk.Revealer):
self.show_all()
self._loading_notification.hide()
- @log
def _hide_notifications(self, notification, remove):
if remove:
self._grid.remove(notification)
self._loading_notification.hide()
self.hide()
- @log
def _set_visibility(self, notification, remove=False):
"""Display or hide Notifications Popup.
@@ -99,7 +90,6 @@ class NotificationsPopup(Gtk.Revealer):
duration + 100, self._hide_notifications, notification, remove)
self.set_reveal_child(not invisible)
- @log
def pop_loading(self):
"""Decrease loading notification counter.
@@ -107,7 +97,6 @@ class NotificationsPopup(Gtk.Revealer):
"""
self._loading_notification.pop()
- @log
def push_loading(self):
"""Increase loading notification counter.
@@ -115,7 +104,6 @@ class NotificationsPopup(Gtk.Revealer):
"""
self._loading_notification.push()
- @log
def add_notification(self, notification):
"""Display a new notification
@@ -125,7 +113,6 @@ class NotificationsPopup(Gtk.Revealer):
self.show()
self.set_reveal_child(True)
- @log
def remove_notification(self, notification):
"""Removes notification.
@@ -133,7 +120,6 @@ class NotificationsPopup(Gtk.Revealer):
"""
self._set_visibility(notification, True)
- @log
def terminate_pending(self):
"""Terminate all pending playlists notifications"""
children = self._grid.get_children()
@@ -154,10 +140,6 @@ class LoadingNotification(Gtk.Grid):
'invisible': (GObject.SignalFlags.RUN_FIRST, None, ())
}
- def __repr__(self):
- return '<LoadingNotification>'
-
- @log
def __init__(self):
super().__init__(column_spacing=18)
self._counter = 0
@@ -172,7 +154,6 @@ class LoadingNotification(Gtk.Grid):
self.add(label)
self.show_all()
- @log
def pop(self):
"""Decrease the counter. Hide notification if it reaches 0."""
self._counter = self._counter - 1
@@ -185,7 +166,6 @@ class LoadingNotification(Gtk.Grid):
self._timeout_id = 0
self.emit('invisible')
- @log
def push(self):
"""Increase the counter. Start notification if necessary."""
def callback():
@@ -212,10 +192,6 @@ class PlaylistNotification(Gtk.Grid):
PLAYLIST = 0
SONG = 1
- def __repr__(self):
- return '<PlaylistNotification>'
-
- @log
def __init__(
self, notifications_popup, coremodel, type_, playlist,
position=None, coresong=None):
@@ -265,7 +241,6 @@ class PlaylistNotification(Gtk.Grid):
return msg
- @log
def _undo_deletion(self, widget_):
"""Undo deletion and remove notification"""
if self._timeout_id > 0:
diff --git a/gnomemusic/widgets/playertoolbar.py b/gnomemusic/widgets/playertoolbar.py
index 57083517..e060f02d 100644
--- a/gnomemusic/widgets/playertoolbar.py
+++ b/gnomemusic/widgets/playertoolbar.py
@@ -25,7 +25,6 @@
from gettext import gettext as _
from gi.repository import GObject, Gtk
-from gnomemusic import log
from gnomemusic.albumartcache import Art
from gnomemusic.gstplayer import Playback
from gnomemusic.player import Player, RepeatMode
@@ -65,10 +64,6 @@ class PlayerToolbar(Gtk.ActionBar):
RepeatMode.SONG: "media-playlist-repeat-song-symbolic"
}
- def __repr__(self):
- return '<PlayerToolbar>'
-
- @log
def __init__(self):
super().__init__()
@@ -111,37 +106,30 @@ class PlayerToolbar(Gtk.ActionBar):
self._sync_repeat_image()
@Gtk.Template.Callback()
- @log
def _on_progress_value_changed(self, progress_scale):
seconds = int(progress_scale.get_value() / 60)
self._progress_time_label.set_label(utils.seconds_to_string(seconds))
@Gtk.Template.Callback()
- @log
def _on_prev_button_clicked(self, button):
self._player.previous()
@Gtk.Template.Callback()
- @log
def _on_play_button_clicked(self, button):
self._player.play_pause()
@Gtk.Template.Callback()
- @log
def _on_next_button_clicked(self, button):
self._player.next()
- @log
def _on_repeat_mode_changed(self, klass, param):
self._sync_repeat_image()
self._sync_prev_next()
- @log
def _sync_repeat_image(self):
icon = self._repeat_dict[self._player.props.repeat_mode]
self._repeat_image.set_from_icon_name(icon, Gtk.IconSize.MENU)
- @log
def _sync_playing(self, player, state):
if (self._player.props.state == Playback.STOPPED
and not self._player.props.has_next
@@ -163,12 +151,10 @@ class PlayerToolbar(Gtk.ActionBar):
self._play_button.set_tooltip_text(tooltip)
- @log
def _sync_prev_next(self):
self._next_button.props.sensitive = self._player.props.has_next
self._prev_button.props.sensitive = self._player.props.has_previous
- @log
def _update_view(self, player):
"""Update all visual elements on song change
@@ -194,7 +180,6 @@ class PlayerToolbar(Gtk.ActionBar):
self._cover_stack.update(coresong)
@Gtk.Template.Callback()
- @log
def _on_tooltip_query(self, widget, x, y, kb, tooltip, data=None):
tooltip.set_custom(self._tooltip)
diff --git a/gnomemusic/widgets/playlistcontrols.py b/gnomemusic/widgets/playlistcontrols.py
index 888de539..8ff91d3a 100644
--- a/gnomemusic/widgets/playlistcontrols.py
+++ b/gnomemusic/widgets/playlistcontrols.py
@@ -26,7 +26,6 @@ import gettext
from gi.repository import Gdk, GObject, Gio, Gtk
-from gnomemusic import log
from gnomemusic.grilowrappers.grltrackerplaylists import Playlist
from gnomemusic.widgets.notificationspopup import PlaylistNotification
@@ -83,20 +82,17 @@ class PlaylistControls(Gtk.Grid):
# self._window.set_player_visible(False)
@Gtk.Template.Callback()
- @log
def _on_rename_entry_changed(self, selection):
selection_length = selection.props.text_length
self._rename_done_button.props.sensitive = selection_length > 0
@Gtk.Template.Callback()
- @log
def _on_rename_entry_key_pressed(self, widget, event):
(_, keyval) = event.get_keyval()
if keyval == Gdk.KEY_Escape:
self._disable_rename_playlist()
@Gtk.Template.Callback()
- @log
def _on_playlist_renamed(self, widget):
new_name = self._rename_entry.props.text
@@ -106,7 +102,6 @@ class PlaylistControls(Gtk.Grid):
self.props.playlist.props.title = new_name
self._disable_rename_playlist()
- @log
def _on_songs_count_changed(self, klass, data=None):
self._songs_count_label.props.label = gettext.ngettext(
"{} Song", "{} Songs", self.props.playlist.count).format(
@@ -136,7 +131,6 @@ class PlaylistControls(Gtk.Grid):
return self._name_stack.props.visible_child_name == "renaming_dialog"
- @log
def _set_rename_entry_text_and_focus(self, text):
self._rename_entry.props.text = text
self._rename_entry.grab_focus()
diff --git a/gnomemusic/widgets/playlistdialog.py b/gnomemusic/widgets/playlistdialog.py
index 055a9d6c..c94f3448 100644
--- a/gnomemusic/widgets/playlistdialog.py
+++ b/gnomemusic/widgets/playlistdialog.py
@@ -24,7 +24,6 @@
from gi.repository import GObject, Gtk
-from gnomemusic import log
from gnomemusic.grilowrappers.grltrackerplaylists import Playlist
from gnomemusic.widgets.playlistdialogrow import PlaylistDialogRow
@@ -49,10 +48,6 @@ class PlaylistDialog(Gtk.Dialog):
_first_playlist_button = Gtk.Template.Child()
_first_playlist_entry = Gtk.Template.Child()
- def __repr__(self):
- return '<PlaylistDialog>'
-
- @log
def __init__(self, parent):
super().__init__()
@@ -70,7 +65,6 @@ class PlaylistDialog(Gtk.Dialog):
self._set_view()
- @log
def _set_view(self):
if self._user_playlists_available:
self._normal_box.show()
@@ -83,7 +77,6 @@ class PlaylistDialog(Gtk.Dialog):
self._add_playlist_button = self._first_playlist_button
self._add_playlist_entry = self._first_playlist_entry
- @log
def _create_playlist_row(self, playlist):
"""Adds (non-smart only) playlists to the model"""
self._user_playlists_available = True
@@ -94,17 +87,14 @@ class PlaylistDialog(Gtk.Dialog):
return row
@Gtk.Template.Callback()
- @log
def _on_selection(self, select_button):
self.response(Gtk.ResponseType.ACCEPT)
@Gtk.Template.Callback()
- @log
def _on_cancel_button_clicked(self, cancel_button):
self.response(Gtk.ResponseType.REJECT)
@Gtk.Template.Callback()
- @log
def _on_selected_rows_changed(self, klass):
self._add_playlist_entry.props.text = ""
self._add_playlist_button.props.sensitive = False
@@ -117,7 +107,6 @@ class PlaylistDialog(Gtk.Dialog):
row.props.selected = (row == selected_row)
@Gtk.Template.Callback()
- @log
def _on_editing_done(self, sender, data=None):
def select_and_close_dialog(playlist):
for row in self._listbox:
@@ -131,7 +120,6 @@ class PlaylistDialog(Gtk.Dialog):
self._coremodel.create_playlist(text, select_and_close_dialog)
@Gtk.Template.Callback()
- @log
def _on_add_playlist_entry_changed(self, editable, data=None):
if editable.props.text:
self._add_playlist_button.props.sensitive = True
@@ -139,6 +127,5 @@ class PlaylistDialog(Gtk.Dialog):
self._add_playlist_button.props.sensitive = False
@Gtk.Template.Callback()
- @log
def _on_add_playlist_entry_focused(self, editable, data=None):
self._listbox.unselect_all()
diff --git a/gnomemusic/widgets/playlistdialogrow.py b/gnomemusic/widgets/playlistdialogrow.py
index 030c17ff..a52abcc6 100644
--- a/gnomemusic/widgets/playlistdialogrow.py
+++ b/gnomemusic/widgets/playlistdialogrow.py
@@ -38,9 +38,6 @@ class PlaylistDialogRow(Gtk.ListBoxRow):
_label = Gtk.Template.Child()
_selection_icon = Gtk.Template.Child()
- def __repr__(self):
- return "PlaylistDialogRow"
-
def __init__(self, playlist):
"""Create a row of the PlaylistDialog
diff --git a/gnomemusic/widgets/playlisttile.py b/gnomemusic/widgets/playlisttile.py
index 7667bacd..9d9a6441 100644
--- a/gnomemusic/widgets/playlisttile.py
+++ b/gnomemusic/widgets/playlisttile.py
@@ -24,7 +24,6 @@
from gi.repository import GObject, Gtk
-from gnomemusic import log
from gnomemusic.grilowrappers.grltrackerplaylists import Playlist
@@ -42,10 +41,6 @@ class PlaylistTile(Gtk.ListBoxRow):
playlist = GObject.Property(type=Playlist, default=None)
text = GObject.Property(type=str, default='')
- def __repr__(self):
- return "<PlaylistTile>"
-
- @log
def __init__(self, playlist):
super().__init__()
diff --git a/gnomemusic/widgets/searchheaderbar.py b/gnomemusic/widgets/searchheaderbar.py
index 0e56443a..2b6de962 100644
--- a/gnomemusic/widgets/searchheaderbar.py
+++ b/gnomemusic/widgets/searchheaderbar.py
@@ -28,7 +28,6 @@ import gi
gi.require_version("Gd", "1.0")
from gi.repository import GLib, GObject, Gd, Gtk
-from gnomemusic import log
from gnomemusic.search import Search
from gnomemusic.widgets.headerbar import HeaderBar, SelectionBarMenuButton
@@ -56,10 +55,6 @@ class SearchHeaderBar(Gtk.HeaderBar):
selection_mode_allowed = GObject.Property(type=bool, default=True)
stack = GObject.Property(type=Gtk.Stack)
- def __repr__(self):
- return "<SearchHeaderBar>"
-
- @log
def __init__(self, application):
super().__init__()
@@ -162,18 +157,15 @@ class SearchHeaderBar(Gtk.HeaderBar):
self._entry.props.visible = False
@Gtk.Template.Callback()
- @log
def _on_cancel_button_clicked(self, button):
self.props.selection_mode = False
- @log
def _update(self):
if self.props.selection_mode:
self.props.custom_title = self._selection_menu
else:
self.props.custom_title = self._entry
- @log
def _on_selection_mode_allowed_changed(self, widget, data):
if self.props.selection_mode_allowed:
self._select_button.props.sensitive = True
diff --git a/gnomemusic/widgets/selectiontoolbar.py b/gnomemusic/widgets/selectiontoolbar.py
index 16c9472b..b97c2d39 100644
--- a/gnomemusic/widgets/selectiontoolbar.py
+++ b/gnomemusic/widgets/selectiontoolbar.py
@@ -24,8 +24,6 @@
from gi.repository import GObject, Gtk
-from gnomemusic import log
-
@Gtk.Template(resource_path='/org/gnome/Music/ui/SelectionToolbar.ui')
class SelectionToolbar(Gtk.ActionBar):
@@ -40,10 +38,6 @@ class SelectionToolbar(Gtk.ActionBar):
selected_items_count = GObject.Property(type=int, default=0, minimum=0)
- def __repr__(self):
- return '<SelectionToolbar>'
-
- @log
def __init__(self):
super().__init__()
@@ -53,11 +47,9 @@ class SelectionToolbar(Gtk.ActionBar):
self.notify("selected-items-count")
@Gtk.Template.Callback()
- @log
def _on_add_to_playlist_button_clicked(self, widget):
self.emit('add-to-playlist')
- @log
def _on_item_selection_changed(self, widget, data):
if self.props.selected_items_count > 0:
self._add_to_playlist_button.props.sensitive = True
diff --git a/gnomemusic/widgets/smoothscale.py b/gnomemusic/widgets/smoothscale.py
index c17b315d..31bd85cd 100644
--- a/gnomemusic/widgets/smoothscale.py
+++ b/gnomemusic/widgets/smoothscale.py
@@ -22,15 +22,10 @@
# code, but you are not obligated to do so. If you do not wish to do so,
# delete this exception statement from your version.
-import logging
-
from gi.repository import GLib, GObject, Gtk
-from gnomemusic import log
from gnomemusic.gstplayer import Playback
-logger = logging.getLogger(__name__)
-
class SmoothScale(Gtk.Scale):
"""Progressbar UI element
@@ -40,10 +35,6 @@ class SmoothScale(Gtk.Scale):
"""
__gtype_name__ = 'SmoothScale'
- def __repr__(self):
- return '<SmoothScale>'
-
- @log
def __init__(self):
super().__init__()
@@ -89,7 +80,6 @@ class SmoothScale(Gtk.Scale):
self._player.connect('notify::state', self._on_state_change)
self._player.connect('notify::duration', self._on_duration_changed)
- @log
def _on_state_change(self, klass, arguments):
state = self._player.props.state
@@ -109,7 +99,6 @@ class SmoothScale(Gtk.Scale):
return True
- @log
def _on_duration_changed(self, klass, arguments):
duration = self._player.props.duration
@@ -117,7 +106,6 @@ class SmoothScale(Gtk.Scale):
self.set_range(0.0, duration * 60)
self.set_increments(300, 600)
- @log
def _on_smooth_scale_seek_finish(self, value):
"""Prevent stutters when seeking with infinitesimal amounts"""
self._seek_timeout = None
@@ -128,7 +116,6 @@ class SmoothScale(Gtk.Scale):
return False
- @log
def _on_smooth_scale_seek(self, scale, scroll_type, value):
"""Smooths out the seeking process
@@ -149,7 +136,6 @@ class SmoothScale(Gtk.Scale):
return True
- @log
def _on_button_released(self, gesture, n_press, x, y):
if self._seek_timeout:
GLib.source_remove(self._seek_timeout)
@@ -160,14 +146,12 @@ class SmoothScale(Gtk.Scale):
return False
- @log
def _on_button_pressed(self, gesture, n_press, x, y):
self._remove_timeout()
self._old_smooth_scale_value = self.get_value()
return False
- @log
def _update_timeout(self):
"""Update the duration for self._timeout
@@ -191,20 +175,17 @@ class SmoothScale(Gtk.Scale):
self._timeout = GLib.timeout_add(
timeout_period, self._update_position_callback)
- @log
def _remove_timeout(self):
if self._timeout:
GLib.source_remove(self._timeout)
self._timeout = None
- @log
def _on_smooth_scale_change_value(self, scroll):
seconds = scroll.get_value() / 60
self._player.set_position(seconds)
return True
- @log
def _update_position_callback(self):
position = self._player.get_position()
if position > 0:
diff --git a/gnomemusic/widgets/songwidget.py b/gnomemusic/widgets/songwidget.py
index 3a796ed5..cd0fbe97 100644
--- a/gnomemusic/widgets/songwidget.py
+++ b/gnomemusic/widgets/songwidget.py
@@ -29,7 +29,6 @@ gi.require_version('Dazzle', '1.0')
from gi.repository import Gdk, GObject, Gtk
from gi.repository.Dazzle import BoldingLabel # noqa: F401
-from gnomemusic import log
from gnomemusic import utils
from gnomemusic.coresong import CoreSong
from gnomemusic.utils import SongStateIcon
@@ -85,10 +84,6 @@ class SongWidget(Gtk.EventBox):
PLAYING = 1
UNPLAYED = 2
- def __repr__(self):
- return '<SongWidget>'
-
- @log
def __init__(self, coresong, can_dnd=False, show_artist_and_album=False):
"""Instanciates a SongWidget
@@ -174,7 +169,6 @@ class SongWidget(Gtk.EventBox):
Gtk.DestDefaults.ALL, entries, Gdk.DragAction.MOVE)
@Gtk.Template.Callback()
- @log
def _on_selection_changed(self, klass, value):
self.emit('selection-changed')
@@ -221,7 +215,6 @@ class SongWidget(Gtk.EventBox):
self.props.select_click = not self.props.select_click
@Gtk.Template.Callback()
- @log
def _on_star_toggle(self, widget, event):
(_, button) = event.get_button()
if button != Gdk.BUTTON_PRIMARY:
@@ -233,12 +226,10 @@ class SongWidget(Gtk.EventBox):
return True
@Gtk.Template.Callback()
- @log
def _on_star_hover(self, widget, event):
self._star_image.props.hover = True
@Gtk.Template.Callback()
- @log
def _on_star_unhover(self, widget, event):
self._star_image.props.hover = False
diff --git a/gnomemusic/widgets/starhandlerwidget.py b/gnomemusic/widgets/starhandlerwidget.py
index 5e276de4..2657237f 100644
--- a/gnomemusic/widgets/starhandlerwidget.py
+++ b/gnomemusic/widgets/starhandlerwidget.py
@@ -24,8 +24,6 @@
from gi.repository import GObject, Gtk
-from gnomemusic import log
-
class CellRendererStar(Gtk.CellRendererPixbuf):
"""Starwidget cellrenderer implementation"""
@@ -34,9 +32,6 @@ class CellRendererStar(Gtk.CellRendererPixbuf):
'clicked': (GObject.SignalFlags.RUN_LAST, None, (str,))
}
- def __repr__(self):
- return '<CellRendererStar>'
-
def __init__(self):
super().__init__()
@@ -104,10 +99,6 @@ class CellRendererStar(Gtk.CellRendererPixbuf):
class StarHandlerWidget(object):
"""Handles the treeview column for favorites (stars)."""
- def __repr__(self):
- return '<StarHandlerWidget>'
-
- @log
def __init__(self, parent, star_index):
"""Initialize.
@@ -118,7 +109,6 @@ class StarHandlerWidget(object):
self._star_index = star_index
self._parent = parent
- @log
def add_star_renderers(self, col):
"""Adds the star renderer column
@@ -130,7 +120,6 @@ class StarHandlerWidget(object):
col.pack_start(star_renderer, False)
col.add_attribute(star_renderer, 'show_star', self._star_index)
- @log
def _on_star_toggled(self, widget, path):
"""Called if a star is clicked"""
model = self._parent._view.props.model
diff --git a/gnomemusic/widgets/starimage.py b/gnomemusic/widgets/starimage.py
index 4ccb21d6..0bfd7f5f 100644
--- a/gnomemusic/widgets/starimage.py
+++ b/gnomemusic/widgets/starimage.py
@@ -24,17 +24,11 @@
from gi.repository import GObject, Gtk
-from gnomemusic import log
-
class StarImage(Gtk.Image):
"""GtkImage for starring songs"""
__gtype_name__ = 'StarImage'
- def __repr__(self):
- return '<StarImage>'
-
- @log
def __init__(self):
super().__init__()
diff --git a/gnomemusic/widgets/twolinetip.py b/gnomemusic/widgets/twolinetip.py
index a02dc45d..d40cdd77 100644
--- a/gnomemusic/widgets/twolinetip.py
+++ b/gnomemusic/widgets/twolinetip.py
@@ -24,8 +24,6 @@
from gi.repository import GObject, Gtk
-from gnomemusic import log
-
@Gtk.Template(resource_path='/org/gnome/Music/ui/TwoLineTip.ui')
class TwoLineTip(Gtk.Box):
@@ -43,10 +41,6 @@ class TwoLineTip(Gtk.Box):
subtitle = GObject.Property(type=str)
subtitle_visible = GObject.Property(type=bool, default=True)
- def __repr__(self):
- return '<TwoLineTip>'
-
- @log
def __init__(self):
super().__init__()
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 7e194e8a..cd5a2855 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -25,7 +25,6 @@
from gi.repository import Gtk, Gdk, Gio, GLib, GObject
from gettext import gettext as _
-from gnomemusic import log
from gnomemusic.gstplayer import Playback
from gnomemusic.mediakeys import MediaKeys
from gnomemusic.player import RepeatMode
@@ -46,9 +45,6 @@ from gnomemusic.widgets.searchheaderbar import SearchHeaderBar
from gnomemusic.widgets.selectiontoolbar import SelectionToolbar # noqa: F401
from gnomemusic.windowplacement import WindowPlacement
-import logging
-logger = logging.getLogger(__name__)
-
@Gtk.Template(resource_path="/org/gnome/Music/ui/Window.ui")
class Window(Gtk.ApplicationWindow):
@@ -65,10 +61,6 @@ class Window(Gtk.ApplicationWindow):
_selection_toolbar = Gtk.Template.Child()
_stack = Gtk.Template.Child()
- def __repr__(self):
- return '<Window>'
-
- @log
def __init__(self, app):
"""Initialize the main window.
@@ -103,7 +95,6 @@ class Window(Gtk.ApplicationWindow):
MediaKeys(self._player, self)
- @log
def _setup_view(self):
self._search = Search()
self._headerbar_stack = Gtk.Stack()
@@ -196,7 +187,6 @@ class Window(Gtk.ApplicationWindow):
else:
self._switch_to_empty_view()
- @log
def _switch_to_empty_view(self):
did_initial_state = self._settings.get_boolean('did-initial-state')
@@ -238,7 +228,6 @@ class Window(Gtk.ApplicationWindow):
self._on_songs_available(None, None)
- @log
def _switch_to_player_view(self):
self._settings.set_boolean('did-initial-state', True)
self._on_notify_model_id = self._stack.connect(
@@ -295,7 +284,6 @@ class Window(Gtk.ApplicationWindow):
"search-mode-active", self.views[View.ALBUM],
"search-mode-active", GObject.BindingFlags.SYNC_CREATE)
- @log
def _select_all(self, action=None, param=None):
if not self.props.selection_mode:
return
@@ -306,7 +294,6 @@ class Window(Gtk.ApplicationWindow):
view.select_all()
- @log
def _deselect_all(self, action=None, param=None):
if not self.props.selection_mode:
return
@@ -317,7 +304,6 @@ class Window(Gtk.ApplicationWindow):
view = self.props.active_view.get_visible_child()
view.deselect_all()
- @log
def _on_key_press(self, widget, event):
modifiers = event.get_state() & Gtk.accelerator_get_default_mod_mask()
(_, keyval) = event.get_keyval()
@@ -419,17 +405,14 @@ class Window(Gtk.ApplicationWindow):
and self._headerbar.props.state != HeaderBar.State.SEARCH):
self._search.props.search_mode_active = True
- @log
def _on_back_button_pressed(self, gesture, n_press, x, y):
self._headerbar.emit('back-button-clicked')
- @log
def _notify_mode_disconnect(self, data=None):
self._player.stop()
self.notifications_popup.terminate_pending()
self._stack.disconnect(self._on_notify_model_id)
- @log
def _on_notify_mode(self, stack, param):
previous_view = self._current_view
self._current_view = self.props.active_view
@@ -452,7 +435,6 @@ class Window(Gtk.ApplicationWindow):
allowed = self._current_view not in no_selection_mode
self._headerbar.props.selection_mode_allowed = allowed
- @log
def _toggle_view(self, view_enum):
# TODO: The SEARCH state actually refers to the child state of
# the search mode. This fixes the behaviour as needed, but is
@@ -463,7 +445,6 @@ class Window(Gtk.ApplicationWindow):
and not self._headerbar.props.state == HeaderBar.State.SEARCH):
self._stack.set_visible_child(self.views[view_enum])
- @log
def _on_search_state_changed(self, klass, param):
if (self._search.props.state != Search.State.NONE
or not self._view_before_search):
@@ -472,7 +453,6 @@ class Window(Gtk.ApplicationWindow):
# Get back to the view before the search
self._stack.set_visible_child(self._view_before_search)
- @log
def _switch_back_from_childview(self, klass=None):
if self.props.selection_mode:
return
@@ -484,13 +464,11 @@ class Window(Gtk.ApplicationWindow):
if self._current_view in views_with_child:
self._current_view._back_button_clicked(self._current_view)
- @log
def _on_selection_mode_changed(self, widget, data=None):
if (not self.props.selection_mode
and self._player.state == Playback.STOPPED):
self._player_toolbar.hide()
- @log
def _on_add_to_playlist(self, widget):
if self.props.active_view == self.views[View.PLAYLIST]:
return
@@ -508,7 +486,6 @@ class Window(Gtk.ApplicationWindow):
self.props.selection_mode = False
playlist_dialog.destroy()
- @log
def set_player_visible(self, visible):
"""Set PlayWidget action visibility
diff --git a/gnomemusic/windowplacement.py b/gnomemusic/windowplacement.py
index 60c87034..2eb5bff7 100644
--- a/gnomemusic/windowplacement.py
+++ b/gnomemusic/windowplacement.py
@@ -24,8 +24,6 @@
from gi.repository import GLib, GObject
-from gnomemusic import log
-
class WindowPlacement(GObject.GObject):
"""Main window placement
@@ -36,10 +34,6 @@ class WindowPlacement(GObject.GObject):
__gtype_name__ = 'WindowPlacement'
- def __repr__(self):
- return '<WindowPlacement>'
-
- @log
def __init__(self, window):
"""Initialize WindowPlacement
@@ -57,7 +51,6 @@ class WindowPlacement(GObject.GObject):
self._window.connect('notify::is-maximized', self._on_maximized)
self._window.connect('configure-event', self._on_configure_event)
- @log
def _restore_window_state(self):
size_setting = self._settings.get_value('window-size')
if (len(size_setting) == 2
@@ -74,13 +67,11 @@ class WindowPlacement(GObject.GObject):
if self._settings.get_value('window-maximized'):
self._window.maximize()
- @log
def _on_configure_event(self, widget, event):
if self._window_placement_update_timeout is None:
self._window_placement_update_timeout = GLib.timeout_add(
500, self._store_size_and_position, widget)
- @log
def _store_size_and_position(self, widget):
size = widget.get_size()
self._settings.set_value(
@@ -95,7 +86,6 @@ class WindowPlacement(GObject.GObject):
return False
- @log
def _on_maximized(self, klass, value, data=None):
self._settings.set_boolean(
'window-maximized', self._window.is_maximized())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]