From 79b3111fb0bde3c938cf1ff2d37f6e3e6abb52db Mon Sep 17 00:00:00 2001 From: coderkun Date: Sun, 6 Apr 2025 16:03:39 +0200 Subject: [PATCH 1/5] Fix reacting to window resizing (close #107) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the handlers for the “default-width” and “default-height” with an override to the virtual “size_allocate” method to reliably react to Window resizing. --- src/window.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/window.py b/src/window.py index 648853d..db10c23 100644 --- a/src/window.py +++ b/src/window.py @@ -75,6 +75,8 @@ class Window(Adw.ApplicationWindow): self._setting_volume = False self._headerbar_connection_button_active = True self._headerbar_playpause_button_active = True + self._width = 0 + self._height = 0 # Help/Shortcuts dialog self.set_help_overlay(ShortcutsDialog()) @@ -144,8 +146,6 @@ class Window(Adw.ApplicationWindow): self._settings.get_boolean(Window.SETTING_SORT_TYPE)) # 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( @@ -258,6 +258,22 @@ class Window(Adw.ApplicationWindow): self.on_menu_search_library) self.add_action(self._search_library_action) + def do_size_allocate(self, width, height, baseline): + Gtk.ApplicationWindow().do_size_allocate(self, width, height, baseline) + + if self._width == width and self._height == height: + return + self._width = width + self._height = height + + if width > 0: + self._cover_panel.set_width(width) + if not self._state.get_property(WindowState.PROP_MAXIMIZED): + self._state.set_property(WindowState.PROP_WIDTH, width) + self._state.set_property(WindowState.PROP_HEIGHT, height) + GObject.idle_add(self._playlist_panel.set_size, width, height) + GObject.idle_add(self._library_panel.set_size, width, height) + # Menu callbacks def on_menu_connect(self, action, value): @@ -287,17 +303,6 @@ class Window(Adw.ApplicationWindow): # Window callbacks - def on_resize(self, widget, event): - width = self.get_size(Gtk.Orientation.HORIZONTAL) - height = self.get_size(Gtk.Orientation.VERTICAL) - if width > 0: - self._cover_panel.set_width(width) - if not self._state.get_property(WindowState.PROP_MAXIMIZED): - self._state.set_property(WindowState.PROP_WIDTH, width) - self._state.set_property(WindowState.PROP_HEIGHT, height) - GObject.idle_add(self._playlist_panel.set_size, width, height) - GObject.idle_add(self._library_panel.set_size, width, height) - def on_maximized(self, widget, maximized): self._state.set_property(WindowState.PROP_MAXIMIZED, maximized is True) From cd4f32e7f21e6dea16ec4b5ce78efb5509a81b5e Mon Sep 17 00:00:00 2001 From: coderkun Date: Sun, 6 Apr 2025 16:48:11 +0200 Subject: [PATCH 2/5] Fix alignment of tracks on Cover panel (close #106) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GTK 4 centers marks of the Scale widget even when the scale has a vertical orientation. Unfortunately, the Scale widget does not provide a way to set the alignment or to access the internal Label widget in any way. To left-align the labels this commit add a method that traverses the all children of the songs scale recursively and adjusts the alignment if it is a Label widget. --- data/ui/cover-panel.ui | 2 +- src/coverpanel.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/data/ui/cover-panel.ui b/data/ui/cover-panel.ui index 75c8530..d869e76 100644 --- a/data/ui/cover-panel.ui +++ b/data/ui/cover-panel.ui @@ -141,6 +141,7 @@ vertical + start fill true False @@ -158,4 +159,3 @@ - diff --git a/src/coverpanel.py b/src/coverpanel.py index ba09e16..d9c5d31 100644 --- a/src/coverpanel.py +++ b/src/coverpanel.py @@ -180,6 +180,21 @@ class CoverPanel(Gtk.Overlay): length, Gtk.PositionType.RIGHT, "{0[0]:02d}:{0[1]:02d} minutes".format(divmod(length, 60))) + # Align marks + self._align_songs_scale_marks() + + def _align_songs_scale_marks(self): + self._align_songs_scale_mark(self.songs_scale) + + def _align_songs_scale_mark(self, widget): + child = widget.get_first_child() + while child: + if type(child) is Gtk.Label: + child.set_halign(Gtk.Align.START) + else: + self._align_songs_scale_mark(child) + child = child.get_next_sibling() + def _enable_tracklist(self): if self._current_album: # enable From dce1c441a03a2b874383a6316b332f1f532ce014 Mon Sep 17 00:00:00 2001 From: coderkun Date: Sun, 6 Apr 2025 16:55:05 +0200 Subject: [PATCH 3/5] =?UTF-8?q?Fix=20READMe=20to=20call=20meson=E2=80=99s?= =?UTF-8?q?=20=E2=80=9Csetup=E2=80=9D=20command=20explicitly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 59cfc3e..f37f2db 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ For testing the application and running it without (system-wide) installation, donwload/clone the code, build it with the `--prefix` option and install it with `ninja`: - $ meson --prefix $(pwd)/install build + $ meson setup --prefix $(pwd)/install build $ ninja -C build $ ninja -C build install From 3d91ab1b3543ca3a37ffd3656f226f7c65e1d213 Mon Sep 17 00:00:00 2001 From: coderkun Date: Sun, 6 Apr 2025 17:33:16 +0200 Subject: [PATCH 4/5] Scroll library to the beginning after loading items (close #108) --- src/librarypanel.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librarypanel.py b/src/librarypanel.py index 488528b..e2ae1fb 100644 --- a/src/librarypanel.py +++ b/src/librarypanel.py @@ -361,6 +361,7 @@ class LibraryPanel(Adw.Bin): self._library_lock.release() GObject.idle_add(self.stack.set_visible_child, self.scroll) self._sort_grid_model() + GObject.idle_add(self.library_grid.scroll_to, 0, Gtk.ListScrollFlags.NONE, None) def _set_widget_grid_size(self, grid_widget, size, vertical): self._library_stop.set() From 099adbab8c0742912176ca9d97a6e090c9b75f20 Mon Sep 17 00:00:00 2001 From: coderkun Date: Sun, 6 Apr 2025 17:36:02 +0200 Subject: [PATCH 5/5] Bump version to 4.0.1 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index cdc1224..a8e88cc 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('mcg', - version: '4.0', + version: '4.0.1', meson_version: '>= 0.59.0', default_options: [ 'warning_level=2',