Improve variable names to match Code Style Guide (see #103)

This commit is contained in:
coderkun 2024-05-28 12:02:43 +02:00
commit 54fe825acf
6 changed files with 71 additions and 65 deletions

View file

@ -23,10 +23,10 @@ from .zeroconf import ZeroconfProvider
class WindowState(GObject.Object):
WIDTH = 'width'
HEIGHT = 'height'
IS_MAXIMIZED = 'is_maximized'
IS_FULLSCREENED = 'is_fullscreened'
PROP_WIDTH = 'width'
PROP_HEIGHT = 'height'
PROP_MAXIMIZED = 'is_maximized'
PROP_FULLSCREENED = 'is_fullscreened'
width = GObject.Property(type=int, default=800)
height = GObject.Property(type=int, default=600)
is_maximized = GObject.Property(type=bool, default=False)
@ -206,16 +206,18 @@ class Window(Adw.ApplicationWindow):
self._settings.connect('changed::' + Window.SETTING_SORT_TYPE,
self.on_settings_sort_type_changed)
self._settings.bind(Window.SETTING_WINDOW_WIDTH, self._state,
WindowState.WIDTH, Gio.SettingsBindFlags.DEFAULT)
WindowState.PROP_WIDTH,
Gio.SettingsBindFlags.DEFAULT)
self._settings.bind(Window.SETTING_WINDOW_HEIGHT, self._state,
WindowState.HEIGHT, Gio.SettingsBindFlags.DEFAULT)
WindowState.PROP_HEIGHT,
Gio.SettingsBindFlags.DEFAULT)
self._settings.bind(Window.SETTING_WINDOW_MAXIMIZED, self._state,
WindowState.IS_MAXIMIZED,
WindowState.PROP_MAXIMIZED,
Gio.SettingsBindFlags.DEFAULT)
# Actions
self.set_default_size(self._state.width, self._state.height)
if self._state.get_property(WindowState.IS_MAXIMIZED):
if self._state.get_property(WindowState.PROP_MAXIMIZED):
self.maximize()
self.content_stack.set_visible_child(self._connection_panel)
if self._settings.get_boolean(Window.SETTING_CONNECTED):
@ -274,7 +276,7 @@ class Window(Adw.ApplicationWindow):
def on_menu_toggle_fullscreen(self, action, value):
self.panel_stack.set_visible_child(self._cover_panel)
if not self._state.get_property(WindowState.IS_FULLSCREENED):
if not self._state.get_property(WindowState.PROP_FULLSCREENED):
self.fullscreen()
else:
self.unfullscreen()
@ -290,14 +292,14 @@ class Window(Adw.ApplicationWindow):
height = self.get_size(Gtk.Orientation.VERTICAL)
if width > 0:
self._cover_panel.set_width(width)
if not self._state.get_property(WindowState.IS_MAXIMIZED):
self._state.set_property(WindowState.WIDTH, width)
self._state.set_property(WindowState.HEIGHT, height)
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.IS_MAXIMIZED, maximized is True)
self._state.set_property(WindowState.PROP_MAXIMIZED, maximized is True)
def on_fullscreened(self, widget, fullscreened):
self._fullscreen(self.is_fullscreen())
@ -371,7 +373,7 @@ class Window(Adw.ApplicationWindow):
self._mcg.enable_output_device(device, enabled)
def on_cover_panel_toggle_fullscreen(self, widget):
if not self._state.get_property(WindowState.IS_FULLSCREENED):
if not self._state.get_property(WindowState.PROP_FULLSCREENED):
self.fullscreen()
else:
self.unfullscreen()
@ -433,7 +435,10 @@ class Window(Adw.ApplicationWindow):
bitrate, error):
# Album
GObject.idle_add(self._cover_panel.set_album, album)
if not album and self._state.get_property(WindowState.IS_FULLSCREENED):
if (
not album
and self._state.get_property(WindowState.PROP_FULLSCREENED)
):
self._fullscreen(False)
# State
if state == 'play':
@ -534,10 +539,11 @@ class Window(Adw.ApplicationWindow):
def _fullscreen(self, fullscreened_new):
if fullscreened_new != self._state.get_property(
WindowState.IS_FULLSCREENED):
self._state.set_property(WindowState.IS_FULLSCREENED,
WindowState.PROP_FULLSCREENED
):
self._state.set_property(WindowState.PROP_FULLSCREENED,
fullscreened_new)
if self._state.get_property(WindowState.IS_FULLSCREENED):
if self._state.get_property(WindowState.PROP_FULLSCREENED):
self.headerbar.hide()
self._cover_panel.set_fullscreen(True)
self.set_cursor(Gdk.Cursor.new_from_name("none", None))