From f67da0a4a03a9ea89673ef714a3a7cb8e5fa2522 Mon Sep 17 00:00:00 2001 From: coderkun Date: Wed, 10 Apr 2024 13:10:45 +0200 Subject: [PATCH] =?UTF-8?q?fixup!=20Port=20UI=20to=20GTK=E2=80=AF4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/librarypanel.py | 13 +++++-------- src/window.py | 2 ++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/librarypanel.py b/src/librarypanel.py index d426a0f..4f9ebc8 100644 --- a/src/librarypanel.py +++ b/src/librarypanel.py @@ -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()) diff --git a/src/window.py b/src/window.py index d915047..4d83b39 100644 --- a/src/window.py +++ b/src/window.py @@ -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):