Skip to content

Commit

Permalink
Library changes & Quit fix (#2906)
Browse files Browse the repository at this point in the history
* Fix label_no_cover not being used

* Center grid items in library

* Properly center view

* move comment

* Fix items_per_line not updating

* Adapt view on entry removal

* Fix window not remembering size on Ctrl+Q

* Gtk.Picture.set_pixbuf deprecation

* Remove unused import

* Set full application name for "No cover" placeholder

* Wrap full name in "no cover"

* Load cover asynchronimously

* Use Gdk.Texture

* GTK is not thread-safe

* __quit is no longer staticmethod

* Remove whitespace

---------

Co-authored-by: Hari Rana <[email protected]>
Co-authored-by: Mirko Brombin <[email protected]>
Co-authored-by: Dallas Strouse <[email protected]>
  • Loading branch information
4 people authored Sep 14, 2023
1 parent d33dcd9 commit b6eb91a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions bottles/frontend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,13 @@ def do_activate(self):
self.win = win
win.present()

@staticmethod
def __quit(action=None, param=None):
def __quit(self, *args):
"""
This function close the application.
It is used by the [Ctrl+Q] shortcut.
"""
logging.info(_("[Quit] request received."), )
self.win.on_close_request()
quit()

@staticmethod
Expand Down
3 changes: 3 additions & 0 deletions bottles/frontend/ui/library-entry.blp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ template LibraryEntry : Box {
vexpand: true;
label: _("No Thumbnail");

wrap: true;
wrap-mode: word_char;

styles [
"dim-label",
]
Expand Down
10 changes: 6 additions & 4 deletions bottles/frontend/widgets/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from gettext import gettext as _

from gi.repository import Gtk, GdkPixbuf
from gi.repository import Gtk, Gdk

from bottles.backend.logger import Logger
from bottles.backend.managers.library import LibraryManager
Expand Down Expand Up @@ -75,6 +75,7 @@ def __init__(self, library, uuid, entry, *args, **kwargs):

self.label_name.set_text(name)
self.label_bottle.set_text(entry['bottle']['name'])
self.label_no_cover.set_label(self.name)

if entry.get('thumbnail'):
path = ThumbnailManager.get_path(self.config, entry['thumbnail'])
Expand All @@ -88,9 +89,10 @@ def __init__(self, library, uuid, entry, *args, **kwargs):
entry = library_manager.get_library().get(uuid)
path = ThumbnailManager.get_path(self.config, entry['thumbnail'])

if path is not None:
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(path, 240, 360)
self.img_cover.set_pixbuf(pixbuf)
if path is not None:
# Gtk.Picture.set_pixbuf deprecated in GTK 4.12
texture = Gdk.Texture.new_from_filename(path)
self.img_cover.set_paintable(texture)
self.img_cover.set_visible(True)
self.label_no_cover.set_visible(False)

Expand Down

0 comments on commit b6eb91a

Please sign in to comment.