rind: Set a default image when there is no artwork
This acts as a placeholder, and keeps the sidebar from bouncing around when tracks are changed. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
0b334ddbee
commit
a7438b2be3
|
@ -479,6 +479,7 @@ audio-volume-medium-symbolic</property>
|
|||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="album_artwork">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">image-missing</property>
|
||||
<property name="icon_size">5</property>
|
||||
|
@ -493,7 +494,8 @@ audio-volume-medium-symbolic</property>
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator" id="artwork_separator">
|
||||
<object class="GtkSeparator">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
# Copyright 2019 (c) Anna Schumaker.
|
||||
from .. import gtk
|
||||
from gi.repository import GdkPixbuf
|
||||
from gi.repository import GdkPixbuf, Gtk
|
||||
|
||||
Default = Gtk.IconTheme.get_default().load_icon("applications-multimedia-symbolic", 512, 0)
|
||||
Image = gtk.Builder.get_object("album_artwork")
|
||||
Paned = gtk.Builder.get_object("sidebar_pane")
|
||||
Pixbuf = None
|
||||
Separator = gtk.Builder.get_object("artwork_separator")
|
||||
Pixbuf = Default
|
||||
|
||||
def reset():
|
||||
Image.hide()
|
||||
Separator.hide()
|
||||
global Pixbuf
|
||||
Pixbuf = Default
|
||||
set_scaled_image()
|
||||
|
||||
def resize(*args):
|
||||
if Pixbuf != None:
|
||||
|
@ -23,10 +24,7 @@ def set_image(data):
|
|||
loader.write(data)
|
||||
Pixbuf = loader.get_pixbuf()
|
||||
loader.close()
|
||||
|
||||
set_scaled_image()
|
||||
Image.show()
|
||||
Separator.show()
|
||||
|
||||
def set_scaled_image():
|
||||
new_w = Paned.get_position()
|
||||
|
@ -34,3 +32,4 @@ def set_scaled_image():
|
|||
if new_h > 0:
|
||||
pix = Pixbuf.scale_simple(new_w, new_h, GdkPixbuf.InterpType.BILINEAR)
|
||||
Image.set_from_pixbuf(pix)
|
||||
set_scaled_image()
|
||||
|
|
|
@ -5,7 +5,7 @@ from . import widgets
|
|||
from .. import gtk
|
||||
import os
|
||||
import unittest
|
||||
from gi.repository import Gtk, Gst
|
||||
from gi.repository import GdkPixbuf, Gtk, Gst
|
||||
|
||||
test_track = os.path.abspath("./trier/Test Album/01 - Test Track.ogg")
|
||||
|
||||
|
@ -15,12 +15,11 @@ class TestAudioArtwork(unittest.TestCase):
|
|||
widgets.reset()
|
||||
|
||||
def test_artwork_init(self):
|
||||
self.assertIsInstance(artwork.Default, GdkPixbuf.Pixbuf)
|
||||
self.assertIsInstance(artwork.Image, Gtk.Image)
|
||||
self.assertIsInstance(artwork.Paned, Gtk.Paned)
|
||||
self.assertIsInstance(artwork.Separator, Gtk.Separator)
|
||||
self.assertIsNone(artwork.Pixbuf)
|
||||
self.assertFalse(artwork.Image.is_visible())
|
||||
self.assertFalse(artwork.Separator.is_visible())
|
||||
self.assertEqual(artwork.Pixbuf, artwork.Default)
|
||||
self.assertTrue(artwork.Image.is_visible())
|
||||
|
||||
def test_artwork_load(self):
|
||||
artwork.Paned.set_position(150)
|
||||
|
@ -28,7 +27,6 @@ class TestAudioArtwork(unittest.TestCase):
|
|||
gtk.main_loop(delay=0.1)
|
||||
|
||||
self.assertTrue(artwork.Image.is_visible())
|
||||
self.assertTrue(artwork.Separator.is_visible())
|
||||
self.assertEqual(artwork.Image.get_storage_type(), Gtk.ImageType.PIXBUF)
|
||||
self.assertEqual(artwork.Pixbuf.get_height(), 512)
|
||||
self.assertEqual(artwork.Pixbuf.get_width(), 512)
|
||||
|
@ -38,8 +36,7 @@ class TestAudioArtwork(unittest.TestCase):
|
|||
self.assertEqual(pbuf.get_width(), 150)
|
||||
|
||||
playbin.set_uri(test_track)
|
||||
self.assertFalse(artwork.Image.is_visible())
|
||||
self.assertFalse(artwork.Separator.is_visible())
|
||||
self.assertEqual(artwork.Pixbuf, artwork.Default)
|
||||
|
||||
def test_artwork_resize(self):
|
||||
artwork.Paned.set_position(150)
|
||||
|
|
Loading…
Reference in New Issue