Adjust blank lines to match Code Style Guide (see #103)
This commit is contained in:
parent
75b99e5820
commit
d2e1f6f5d8
14 changed files with 14 additions and 413 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version('Gtk', '4.0')
|
||||
gi.require_version('Adw', '1')
|
||||
import logging
|
||||
|
|
@ -9,15 +9,12 @@ import math
|
|||
import threading
|
||||
|
||||
from gi.repository import Gtk, Gdk, Gio, GObject, GdkPixbuf, Adw
|
||||
|
||||
from mcg import client
|
||||
from mcg.albumheaderbar import AlbumHeaderbar
|
||||
from mcg.utils import Utils
|
||||
from mcg.utils import GridItem
|
||||
|
||||
|
||||
|
||||
|
||||
@Gtk.Template(resource_path='/xyz/suruatoel/mcg/ui/playlist-panel.ui')
|
||||
class PlaylistPanel(Adw.Bin):
|
||||
__gtype_name__ = 'McgPlaylistPanel'
|
||||
|
|
@ -31,7 +28,6 @@ class PlaylistPanel(Adw.Bin):
|
|||
'albumart': (GObject.SIGNAL_RUN_FIRST, None, (str,)),
|
||||
}
|
||||
|
||||
|
||||
# Widgets
|
||||
playlist_stack = Gtk.Template.Child()
|
||||
panel_normal = Gtk.Template.Child()
|
||||
|
|
@ -52,7 +48,6 @@ class PlaylistPanel(Adw.Bin):
|
|||
standalone_scroll = Gtk.Template.Child()
|
||||
standalone_image = Gtk.Template.Child()
|
||||
|
||||
|
||||
def __init__(self, client, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self._client = client
|
||||
|
|
@ -78,19 +73,15 @@ class PlaylistPanel(Adw.Bin):
|
|||
# Playlist Grid
|
||||
self.playlist_grid.set_model(self._playlist_grid_selection_single)
|
||||
|
||||
|
||||
def get_headerbar_standalone(self):
|
||||
return self._headerbar_standalone
|
||||
|
||||
|
||||
def get_toolbar(self):
|
||||
return self.toolbar
|
||||
|
||||
|
||||
def set_selected(self, selected):
|
||||
self._is_selected = selected
|
||||
|
||||
|
||||
@Gtk.Template.Callback()
|
||||
def on_select_toggled(self, widget):
|
||||
if self.select_button.get_active():
|
||||
|
|
@ -104,12 +95,10 @@ class PlaylistPanel(Adw.Bin):
|
|||
self.playlist_grid.set_single_click_activate(True)
|
||||
self.playlist_grid.get_style_context().remove_class(Utils.CSS_SELECTION)
|
||||
|
||||
|
||||
@Gtk.Template.Callback()
|
||||
def on_clear_clicked(self, widget):
|
||||
self.emit('clear-playlist')
|
||||
|
||||
|
||||
@Gtk.Template.Callback()
|
||||
def on_playlist_grid_clicked(self, widget, position):
|
||||
# Get selected album
|
||||
|
|
@ -131,54 +120,44 @@ class PlaylistPanel(Adw.Bin):
|
|||
self.standalone_stack.set_visible_child(self.standalone_spinner)
|
||||
self.standalone_spinner.start()
|
||||
|
||||
|
||||
@Gtk.Template.Callback()
|
||||
def on_selection_cancel_clicked(self, widget):
|
||||
self.select_button.set_active(False)
|
||||
|
||||
|
||||
@Gtk.Template.Callback()
|
||||
def on_selection_remove_clicked(self, widget):
|
||||
self.emit('remove-multiple-albums', self._get_selected_albums())
|
||||
self.select_button.set_active(False)
|
||||
|
||||
|
||||
def on_headerbar_close_clicked(self, widget):
|
||||
self._close_standalone()
|
||||
|
||||
|
||||
@Gtk.Template.Callback()
|
||||
def on_standalone_remove_clicked(self, widget):
|
||||
self.emit('remove-album', self._get_selected_albums()[0])
|
||||
self._close_standalone()
|
||||
|
||||
|
||||
@Gtk.Template.Callback()
|
||||
def on_standalone_play_clicked(self, widget):
|
||||
self.emit('play', self._get_selected_albums()[0])
|
||||
self._close_standalone()
|
||||
|
||||
|
||||
def set_size(self, width, height):
|
||||
self._resize_standalone_image()
|
||||
|
||||
|
||||
def set_item_size(self, item_size):
|
||||
if self._item_size != item_size:
|
||||
self._item_size = item_size
|
||||
self._redraw()
|
||||
|
||||
|
||||
def get_item_size(self):
|
||||
return self._item_size
|
||||
|
||||
|
||||
def set_playlist(self, host, playlist):
|
||||
self._host = host
|
||||
self._playlist_stop.set()
|
||||
threading.Thread(target=self._set_playlist, args=(host, playlist, self._item_size,)).start()
|
||||
|
||||
|
||||
def set_albumart(self, album, data):
|
||||
if album in self._selected_albums:
|
||||
if data:
|
||||
|
|
@ -193,11 +172,9 @@ class PlaylistPanel(Adw.Bin):
|
|||
# Show image
|
||||
GObject.idle_add(self._show_image)
|
||||
|
||||
|
||||
def stop_threads(self):
|
||||
self._playlist_stop.set()
|
||||
|
||||
|
||||
def _set_playlist(self, host, playlist, size):
|
||||
self._playlist_lock.acquire()
|
||||
self._playlist_stop.clear()
|
||||
|
|
@ -237,28 +214,23 @@ class PlaylistPanel(Adw.Bin):
|
|||
self.playlist_grid.set_model(self._playlist_grid_selection_single)
|
||||
self._playlist_lock.release()
|
||||
|
||||
|
||||
def _show_image(self):
|
||||
self._resize_standalone_image()
|
||||
self.standalone_stack.set_visible_child(self.standalone_scroll)
|
||||
self.standalone_spinner.stop()
|
||||
|
||||
|
||||
def _redraw(self):
|
||||
if self._playlist is not None:
|
||||
self.set_playlist(self._host, self._playlist)
|
||||
|
||||
|
||||
def _open_standalone(self):
|
||||
self.playlist_stack.set_visible_child(self.panel_standalone)
|
||||
self.emit('open-standalone')
|
||||
|
||||
|
||||
def _close_standalone(self):
|
||||
self.playlist_stack.set_visible_child(self.panel_normal)
|
||||
self.emit('close-standalone')
|
||||
|
||||
|
||||
def _resize_standalone_image(self):
|
||||
"""Diese Methode skaliert das geladene Bild aus dem Pixelpuffer
|
||||
auf die Größe des Fensters unter Beibehalt der Seitenverhältnisse
|
||||
|
|
@ -288,7 +260,6 @@ class PlaylistPanel(Adw.Bin):
|
|||
self.standalone_image.set_from_pixbuf(pixbuf.scale_simple(width, height, GdkPixbuf.InterpType.HYPER))
|
||||
self.standalone_image.show()
|
||||
|
||||
|
||||
def _get_default_image(self):
|
||||
return self._icon_theme.lookup_icon(
|
||||
Utils.STOCK_ICON_DEFAULT,
|
||||
|
|
@ -299,7 +270,6 @@ class PlaylistPanel(Adw.Bin):
|
|||
Gtk.IconLookupFlags.FORCE_SYMBOLIC
|
||||
)
|
||||
|
||||
|
||||
def _get_selected_albums(self):
|
||||
albums = []
|
||||
for i in range(self.playlist_grid.get_model().get_n_items()):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue