Commit daf8abad authored by Marinus Schraal's avatar Marinus Schraal

disclistboxwidget: Add logging

Keep in line with current logging solution.
parent 46dbcbef
...@@ -38,6 +38,10 @@ class StarStack(Gtk.Stack): ...@@ -38,6 +38,10 @@ class StarStack(Gtk.Stack):
"""Stackwidget for starring songs""" """Stackwidget for starring songs"""
__gtype_name__ = 'StarStack' __gtype_name__ = 'StarStack'
def __repr__(self):
return '<StarStack>'
@log
def __init__(self): def __init__(self):
super().__init__(self) super().__init__(self)
...@@ -55,6 +59,7 @@ class StarStack(Gtk.Stack): ...@@ -55,6 +59,7 @@ class StarStack(Gtk.Stack):
self.show_all() self.show_all()
@log
def set_favorite(self, favorite): def set_favorite(self, favorite):
"""Set favorite """Set favorite
...@@ -69,6 +74,7 @@ class StarStack(Gtk.Stack): ...@@ -69,6 +74,7 @@ class StarStack(Gtk.Stack):
else: else:
self.set_visible_child_name('non-starred') self.set_visible_child_name('non-starred')
@log
def get_favorite(self): def get_favorite(self):
"""Return the current state of the widget """Return the current state of the widget
...@@ -77,6 +83,7 @@ class StarStack(Gtk.Stack): ...@@ -77,6 +83,7 @@ class StarStack(Gtk.Stack):
""" """
return self._favorite return self._favorite
@log
def toggle_favorite(self): def toggle_favorite(self):
"""Toggle the widget state""" """Toggle the widget state"""
self._favorite = not self._favorite self._favorite = not self._favorite
...@@ -92,6 +99,10 @@ class DiscSongsFlowBox(Gtk.FlowBox): ...@@ -92,6 +99,10 @@ class DiscSongsFlowBox(Gtk.FlowBox):
""" """
__gtype_name__ = 'DiscSongsFlowBox' __gtype_name__ = 'DiscSongsFlowBox'
def __repr__(self):
return '<DiscSongsFlowBox>'
@log
def __init__(self, columns=1): def __init__(self, columns=1):
"""Initialize """Initialize
...@@ -103,6 +114,7 @@ class DiscSongsFlowBox(Gtk.FlowBox): ...@@ -103,6 +114,7 @@ class DiscSongsFlowBox(Gtk.FlowBox):
self._columns = columns self._columns = columns
self.get_style_context().add_class('discsongsflowbox') self.get_style_context().add_class('discsongsflowbox')
@log
def set_columns(self, columns): def set_columns(self, columns):
"""Set the number of columns to use """Set the number of columns to use
...@@ -136,6 +148,10 @@ class DiscBox(Gtk.Box): ...@@ -136,6 +148,10 @@ class DiscBox(Gtk.Box):
} }
def __repr__(self):
return '<DiscBox>'
@log
def __init__(self, model=None): def __init__(self, model=None):
"""Initialize """Initialize
...@@ -160,6 +176,7 @@ class DiscBox(Gtk.Box): ...@@ -160,6 +176,7 @@ class DiscBox(Gtk.Box):
self.pack_start(builder.get_object('disc'), True, True, 0) self.pack_start(builder.get_object('disc'), True, True, 0)
@log
def set_columns(self, columns): def set_columns(self, columns):
"""Set the number of columns used by the songs list """Set the number of columns used by the songs list
...@@ -167,6 +184,7 @@ class DiscBox(Gtk.Box): ...@@ -167,6 +184,7 @@ class DiscBox(Gtk.Box):
""" """
self._disc_songs_flowbox.set_columns(columns) self._disc_songs_flowbox.set_columns(columns)
@log
def set_disc_number(self, disc_number): def set_disc_number(self, disc_number):
"""Set the dics number to display """Set the dics number to display
...@@ -176,6 +194,7 @@ class DiscBox(Gtk.Box): ...@@ -176,6 +194,7 @@ class DiscBox(Gtk.Box):
self._label.get_style_context().add_class('dim-label') self._label.get_style_context().add_class('dim-label')
self._label.set_visible(True) self._label.set_visible(True)
@log
def show_disc_label(self, show_header): def show_disc_label(self, show_header):
"""Wheter to show the disc number label """Wheter to show the disc number label
...@@ -184,6 +203,7 @@ class DiscBox(Gtk.Box): ...@@ -184,6 +203,7 @@ class DiscBox(Gtk.Box):
self._label.set_visible(False) self._label.set_visible(False)
self._label.hide() self._label.hide()
@log
def show_duration(self, show_duration): def show_duration(self, show_duration):
"""Wheter to show the song durations """Wheter to show the song durations
...@@ -194,6 +214,7 @@ class DiscBox(Gtk.Box): ...@@ -194,6 +214,7 @@ class DiscBox(Gtk.Box):
self._disc_songs_flowbox.foreach(child_show_duration) self._disc_songs_flowbox.foreach(child_show_duration)
@log
def show_favorites(self, show_favorites): def show_favorites(self, show_favorites):
"""Where to show the favorite switches """Where to show the favorite switches
...@@ -205,6 +226,7 @@ class DiscBox(Gtk.Box): ...@@ -205,6 +226,7 @@ class DiscBox(Gtk.Box):
self._disc_songs_flowbox.foreach(child_show_favorites) self._disc_songs_flowbox.foreach(child_show_favorites)
@log
def show_song_numbers(self, show_song_number): def show_song_numbers(self, show_song_number):
"""Whether to show the song numbers """Whether to show the song numbers
...@@ -215,6 +237,7 @@ class DiscBox(Gtk.Box): ...@@ -215,6 +237,7 @@ class DiscBox(Gtk.Box):
self._disc_songs_flowbox.foreach(child_show_song_number) self._disc_songs_flowbox.foreach(child_show_song_number)
@log
def set_tracks(self, tracks): def set_tracks(self, tracks):
"""Songs to display """Songs to display
...@@ -226,6 +249,7 @@ class DiscBox(Gtk.Box): ...@@ -226,6 +249,7 @@ class DiscBox(Gtk.Box):
self._disc_songs_flowbox.insert(song_widget, -1) self._disc_songs_flowbox.insert(song_widget, -1)
track.song_widget = song_widget track.song_widget = song_widget
@log
def set_selection_mode(self, selection_mode): def set_selection_mode(self, selection_mode):
"""Set selection mode """Set selection mode
...@@ -234,6 +258,7 @@ class DiscBox(Gtk.Box): ...@@ -234,6 +258,7 @@ class DiscBox(Gtk.Box):
self._selection_mode = selection_mode self._selection_mode = selection_mode
self._disc_songs_flowbox.foreach(self._toggle_widget_selection) self._disc_songs_flowbox.foreach(self._toggle_widget_selection)
@log
def get_selected_items(self): def get_selected_items(self):
"""Return all selected items """Return all selected items
...@@ -245,6 +270,7 @@ class DiscBox(Gtk.Box): ...@@ -245,6 +270,7 @@ class DiscBox(Gtk.Box):
return self._selected_items return self._selected_items
@log
def _get_selected(self, child): def _get_selected(self, child):
song_widget = child.get_child() song_widget = child.get_child()
...@@ -254,6 +280,7 @@ class DiscBox(Gtk.Box): ...@@ -254,6 +280,7 @@ class DiscBox(Gtk.Box):
# FIXME: select all/none slow probably b/c of the row changes # FIXME: select all/none slow probably b/c of the row changes
# invocations, maybe workaround? # invocations, maybe workaround?
@log
def select_all(self): def select_all(self):
"""Select all songs""" """Select all songs"""
def child_select_all(child): def child_select_all(child):
...@@ -262,6 +289,7 @@ class DiscBox(Gtk.Box): ...@@ -262,6 +289,7 @@ class DiscBox(Gtk.Box):
self._disc_songs_flowbox.foreach(child_select_all) self._disc_songs_flowbox.foreach(child_select_all)
@log
def select_none(self): def select_none(self):
"""Deselect all songs""" """Deselect all songs"""
def child_select_none(child): def child_select_none(child):
...@@ -270,6 +298,7 @@ class DiscBox(Gtk.Box): ...@@ -270,6 +298,7 @@ class DiscBox(Gtk.Box):
self._disc_songs_flowbox.foreach(child_select_none) self._disc_songs_flowbox.foreach(child_select_none)
@log
def _create_song_widget(self, track): def _create_song_widget(self, track):
"""Helper function to create a song widget for a """Helper function to create a song widget for a
single song single song
...@@ -330,6 +359,7 @@ class DiscBox(Gtk.Box): ...@@ -330,6 +359,7 @@ class DiscBox(Gtk.Box):
return song_widget return song_widget
@log
def _toggle_favorite(self, widget, event, song_widget): def _toggle_favorite(self, widget, event, song_widget):
if event.button == Gdk.BUTTON_PRIMARY: if event.button == Gdk.BUTTON_PRIMARY:
song_widget.star_stack.toggle_favorite() song_widget.star_stack.toggle_favorite()
...@@ -340,11 +370,13 @@ class DiscBox(Gtk.Box): ...@@ -340,11 +370,13 @@ class DiscBox(Gtk.Box):
grilo.set_favorite(self._model[song_widget.itr][5], favorite) grilo.set_favorite(self._model[song_widget.itr][5], favorite)
return True return True
@log
def _check_button_toggled(self, widget, song_widget): def _check_button_toggled(self, widget, song_widget):
self.emit('selection-changed') self.emit('selection-changed')
return True return True
@log
def _toggle_widget_selection(self, child): def _toggle_widget_selection(self, child):
song_widget = child.get_child() song_widget = child.get_child()
song_widget.check_button.set_visible(self._selection_mode) song_widget.check_button.set_visible(self._selection_mode)
...@@ -352,6 +384,7 @@ class DiscBox(Gtk.Box): ...@@ -352,6 +384,7 @@ class DiscBox(Gtk.Box):
if song_widget.check_button.get_active(): if song_widget.check_button.get_active():
song_widget.check_button.set_active(False) song_widget.check_button.set_active(False)
@log
def _track_activated(self, widget, event): def _track_activated(self, widget, event):
# FIXME: don't think keys work correctly, if they did ever # FIXME: don't think keys work correctly, if they did ever
# even. # even.
...@@ -394,6 +427,10 @@ class DiscListBox(Gtk.ListBox): ...@@ -394,6 +427,10 @@ class DiscListBox(Gtk.ListBox):
'selection-changed': (GObject.SignalFlags.RUN_FIRST, None, ()), 'selection-changed': (GObject.SignalFlags.RUN_FIRST, None, ()),
} }
def __repr__(self):
return '<DiscListBox>'
@log
def __init__(self): def __init__(self):
"""Initialize""" """Initialize"""
super().__init__() super().__init__()
...@@ -403,14 +440,17 @@ class DiscListBox(Gtk.ListBox): ...@@ -403,14 +440,17 @@ class DiscListBox(Gtk.ListBox):
self._selection_mode_allowed = False self._selection_mode_allowed = False
self._selected_items = [] self._selected_items = []
@log
def insert(self, widget, position): def insert(self, widget, position):
"""Insert a DiscBox widget""" """Insert a DiscBox widget"""
super().insert(widget, position) super().insert(widget, position)
widget.connect('selection-changed', self._on_selection_changed) widget.connect('selection-changed', self._on_selection_changed)
@log
def _on_selection_changed(self, widget): def _on_selection_changed(self, widget):
self.emit('selection-changed') self.emit('selection-changed')
@log
def get_selected_items(self): def get_selected_items(self):
"""Returns all selected items for all discs """Returns all selected items for all discs
...@@ -426,6 +466,7 @@ class DiscListBox(Gtk.ListBox): ...@@ -426,6 +466,7 @@ class DiscListBox(Gtk.ListBox):
return self._selected_items return self._selected_items
@log
def select_all(self): def select_all(self):
"""Select all songs""" """Select all songs"""
def child_select_all(child): def child_select_all(child):
...@@ -433,6 +474,7 @@ class DiscListBox(Gtk.ListBox): ...@@ -433,6 +474,7 @@ class DiscListBox(Gtk.ListBox):
self.foreach(child_select_all) self.foreach(child_select_all)
@log
def select_none(self): def select_none(self):
"""Deselect all songs""" """Deselect all songs"""
def child_select_none(child): def child_select_none(child):
...@@ -440,6 +482,7 @@ class DiscListBox(Gtk.ListBox): ...@@ -440,6 +482,7 @@ class DiscListBox(Gtk.ListBox):
self.foreach(child_select_none) self.foreach(child_select_none)
@log
def set_selection_mode(self, selection_mode): def set_selection_mode(self, selection_mode):
"""Set selection mode """Set selection mode
...@@ -455,6 +498,7 @@ class DiscListBox(Gtk.ListBox): ...@@ -455,6 +498,7 @@ class DiscListBox(Gtk.ListBox):
self.foreach(set_child_selection_mode) self.foreach(set_child_selection_mode)
@log
def set_selection_mode_allowed(self, allowed): def set_selection_mode_allowed(self, allowed):
"""Set if selection mode is allowed """Set if selection mode is allowed
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment