mirror of
https://github.com/SoongNoonien/mpdevil.git
synced 2023-08-10 21:12:44 +03:00
Compare commits
No commits in common. "7f2cccdbab857014b91dd5da8e56d7fffac206af" and "22f452c4efef0d365c349efaf60ebc10ffb50631" have entirely different histories.
7f2cccdbab
...
22f452c4ef
|
@ -2868,7 +2868,8 @@ class MainCover(Gtk.DrawingArea):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._client=client
|
self._client=client
|
||||||
self._settings=settings
|
self._settings=settings
|
||||||
self._fallback=True
|
self._pixbuf=GdkPixbuf.Pixbuf()
|
||||||
|
self._surface=Gdk.cairo_surface_create_from_pixbuf(self._pixbuf, 0, None)
|
||||||
|
|
||||||
# connect
|
# connect
|
||||||
self._client.emitter.connect("current_song", self._refresh)
|
self._client.emitter.connect("current_song", self._refresh)
|
||||||
|
@ -2876,7 +2877,8 @@ class MainCover(Gtk.DrawingArea):
|
||||||
self._client.emitter.connect("reconnected", self._on_reconnected)
|
self._client.emitter.connect("reconnected", self._on_reconnected)
|
||||||
|
|
||||||
def _clear(self):
|
def _clear(self):
|
||||||
self._fallback=True
|
self._pixbuf=GdkPixbuf.Pixbuf.new_from_file_at_size(FALLBACK_COVER, 1000, 1000)
|
||||||
|
self._surface=Gdk.cairo_surface_create_from_pixbuf(self._pixbuf, 0, None)
|
||||||
self.queue_draw()
|
self.queue_draw()
|
||||||
|
|
||||||
def _refresh(self, *args):
|
def _refresh(self, *args):
|
||||||
|
@ -2885,7 +2887,6 @@ class MainCover(Gtk.DrawingArea):
|
||||||
else:
|
else:
|
||||||
self._pixbuf=self._client.current_cover.get_pixbuf()
|
self._pixbuf=self._client.current_cover.get_pixbuf()
|
||||||
self._surface=Gdk.cairo_surface_create_from_pixbuf(self._pixbuf, 0, None)
|
self._surface=Gdk.cairo_surface_create_from_pixbuf(self._pixbuf, 0, None)
|
||||||
self._fallback=False
|
|
||||||
self.queue_draw()
|
self.queue_draw()
|
||||||
|
|
||||||
def _on_disconnected(self, *args):
|
def _on_disconnected(self, *args):
|
||||||
|
@ -2896,17 +2897,14 @@ class MainCover(Gtk.DrawingArea):
|
||||||
self.set_sensitive(True)
|
self.set_sensitive(True)
|
||||||
|
|
||||||
def do_draw(self, context):
|
def do_draw(self, context):
|
||||||
if self._fallback:
|
height_factor=self.get_allocated_height()/self._pixbuf.get_height()
|
||||||
size=min(self.get_allocated_height(), self.get_allocated_width())
|
width_factor=self.get_allocated_width()/self._pixbuf.get_width()
|
||||||
self._pixbuf=GdkPixbuf.Pixbuf.new_from_file_at_size(FALLBACK_COVER, size, size)
|
if height_factor < width_factor:
|
||||||
self._surface=Gdk.cairo_surface_create_from_pixbuf(self._pixbuf, 0, None)
|
context.scale(height_factor, height_factor)
|
||||||
scale_factor=1
|
context.set_source_surface(self._surface, ((self.get_allocated_width()/height_factor)-self._pixbuf.get_width())/2, 0)
|
||||||
else:
|
else:
|
||||||
scale_factor=min(self.get_allocated_width()/self._pixbuf.get_width(), self.get_allocated_height()/self._pixbuf.get_height())
|
context.scale(width_factor, width_factor)
|
||||||
context.scale(scale_factor, scale_factor)
|
context.set_source_surface(self._surface, 0, ((self.get_allocated_height()/width_factor)-self._pixbuf.get_height())/2)
|
||||||
x=((self.get_allocated_width()/scale_factor)-self._pixbuf.get_width())/2
|
|
||||||
y=((self.get_allocated_height()/scale_factor)-self._pixbuf.get_height())/2
|
|
||||||
context.set_source_surface(self._surface, x, y)
|
|
||||||
context.paint()
|
context.paint()
|
||||||
|
|
||||||
class CoverLyricsWindow(Gtk.Overlay):
|
class CoverLyricsWindow(Gtk.Overlay):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user