fixup! Port UI to GTK 4

This commit is contained in:
coderkun 2024-04-10 13:10:45 +02:00
parent 8673d44976
commit f67da0a4a0
2 changed files with 7 additions and 8 deletions

View file

@ -91,7 +91,7 @@ class LibraryPanel(Adw.Bin):
self._icon_theme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default())
self._standalone_pixbuf = None
self._selected_albums = []
self._allocation = (0, 0)
self._grid_width = 0
self._is_selected = False
# Widgets
@ -189,15 +189,12 @@ class LibraryPanel(Adw.Bin):
self.emit('sort-type-changed', button.get_active())
# FIXME on_resize()
#@Gtk.Template.Callback()
def on_resize(self, widget, event):
new_allocation = (widget.get_allocation().width, widget.get_allocation().height)
if new_allocation == self._allocation:
def set_size(self, width, height):
width = self.scroll.get_width()
if width == self._grid_width:
return
self._allocation = new_allocation
self._grid_width = width
self.grid_scale.clear_marks()
width = widget.get_allocation().width
lower = int(self.grid_scale.get_adjustment().get_lower())
upper = int(self.grid_scale.get_adjustment().get_upper())

View file

@ -136,6 +136,7 @@ class Window(Adw.ApplicationWindow):
# Signals
self.connect("notify::default-width", self.on_resize)
self.connect("notify::default-height", self.on_resize)
self.connect("notify::maximized", self.on_maximized)
self.connect("notify::fullscreened", self.on_fullscreened)
self._connection_panel.connect('connection-changed', self.on_connection_panel_connection_changed)
@ -253,6 +254,7 @@ class Window(Adw.ApplicationWindow):
if not self._state.get_property(WindowState.IS_MAXIMIZED):
self._state.set_property(WindowState.WIDTH, width)
self._state.set_property(WindowState.HEIGHT, height)
GObject.idle_add(self._library_panel.set_size, width, height)
def on_maximized(self, widget, maximized):