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.
This commit is contained in:
parent
f3e3f920a5
commit
79b3111fb0
1 changed files with 18 additions and 13 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue