Compare commits

..

5 commits

Author SHA1 Message Date
099adbab8c Bump version to 4.0.1 2025-04-06 17:36:02 +02:00
3d91ab1b35 Scroll library to the beginning after loading items (close #108) 2025-04-06 17:33:16 +02:00
dce1c441a0 Fix READMe to call meson’s “setup” command explicitly 2025-04-06 16:55:05 +02:00
cd4f32e7f2 Fix alignment of tracks on Cover panel (close #106)
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.
2025-04-06 16:52:10 +02:00
79b3111fb0 Fix reacting to window resizing (close #107)
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.
2025-04-06 16:03:39 +02:00
6 changed files with 37 additions and 16 deletions

View file

@ -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

View file

@ -141,6 +141,7 @@
<child>
<object class="GtkScale" id="songs_scale">
<property name="orientation">vertical</property>
<property name="halign">start</property>
<property name="valign">fill</property>
<property name="vexpand">true</property>
<property name="restrict-to-fill-level">False</property>
@ -158,4 +159,3 @@
</child>
</template>
</interface>

View file

@ -1,5 +1,5 @@
project('mcg',
version: '4.0',
version: '4.0.1',
meson_version: '>= 0.59.0',
default_options: [
'warning_level=2',

View file

@ -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

View file

@ -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()

View file

@ -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)