fixup! Port UI to GTK 4

This commit is contained in:
coderkun 2023-01-15 14:45:17 +01:00
commit 15f8f67de9

View file

@ -15,7 +15,7 @@ import logging
from gi.repository import Gtk, Adw, Gdk, GObject, GLib, Gio
from . import client
from .shortcutsdialog import ShortcutsDialog
#from .shortcutsdialog import ShortcutsDialog
from .connectionpanel import ConnectionPanel
from .serverpanel import ServerPanel
from .coverpanel import CoverPanel
@ -64,9 +64,9 @@ class Window(Adw.ApplicationWindow):
toolbar_stack = Gtk.Template.Child()
# Headerbar
headerbar = Gtk.Template.Child()
headerbar_title_stack = Gtk.Template.Child()
#headerbar_title_stack = Gtk.Template.Child()
headerbar_panel_switcher = Gtk.Template.Child()
headerbar_connection_label = Gtk.Template.Child()
#headerbar_connection_label = Gtk.Template.Child()
headerbar_button_connect = Gtk.Template.Child()
headerbar_button_playpause = Gtk.Template.Child()
headerbar_button_volume = Gtk.Template.Child()
@ -86,12 +86,11 @@ class Window(Adw.ApplicationWindow):
self._headerbar_connection_button_active = True
self._headerbar_playpause_button_active = True
# Help/Shortcuts dialog
self.set_help_overlay(ShortcutsDialog())
# FIXME Help/Shortcuts dialog
#self.set_help_overlay(ShortcutsDialog())
# Login screen
self._connection_panel = ConnectionPanel()
self._panels.append(self._connection_panel)
# Server panel
self._server_panel = ServerPanel()
self._panels.append(self._server_panel)
@ -100,13 +99,13 @@ class Window(Adw.ApplicationWindow):
self._panels.append(self._cover_panel)
# Playlist panel
self._playlist_panel = PlaylistPanel(self._mcg)
self._playlist_panel.connect('open-standalone', self.on_panel_open_standalone)
self._playlist_panel.connect('close-standalone', self.on_panel_close_standalone)
#self._playlist_panel.connect('open-standalone', self.on_panel_open_standalone)
#self._playlist_panel.connect('close-standalone', self.on_panel_close_standalone)
self._panels.append(self._playlist_panel)
# Library panel
self._library_panel = LibraryPanel(self._mcg)
self._library_panel.connect('open-standalone', self.on_panel_open_standalone)
self._library_panel.connect('close-standalone', self.on_panel_close_standalone)
#self._library_panel.connect('open-standalone', self.on_panel_open_standalone)
#self._library_panel.connect('close-standalone', self.on_panel_close_standalone)
self._panels.append(self._library_panel)
# Stack
self.content_stack.add_child(self._connection_panel)
@ -115,8 +114,8 @@ class Window(Adw.ApplicationWindow):
self.panel_stack.add_titled(self._playlist_panel, 'playlist-panel', locale.gettext("Playlist"))
self.panel_stack.add_titled(self._library_panel, 'library-panel', locale.gettext("Library"))
# Header
self._playlist_panel.get_headerbar_standalone().connect('close', self.on_panel_close_standalone)
self._library_panel.get_headerbar_standalone().connect('close', self.on_panel_close_standalone)
#self._playlist_panel.get_headerbar_standalone().connect('close', self.on_panel_close_standalone)
#self._library_panel.get_headerbar_standalone().connect('close', self.on_panel_close_standalone)
# Toolbar stack
self.toolbar_stack.add_child(self._server_panel.get_toolbar())
self.toolbar_stack.add_child(self._cover_panel.get_toolbar())
@ -291,13 +290,13 @@ class Window(Adw.ApplicationWindow):
self._save_visible_panel()
self._set_menu_visible_panel()
for panel in self._panels:
GObject.idle_add(
self.panel_stack.child_set_property,
self.panel_stack.get_visible_child(),
'needs-attention',
False
)
panel.set_selected(panel == self.panel_stack.get_visible_child())
#GObject.idle_add(
# self.panel_stack.child_set_property,
# self.panel_stack.get_visible_child(),
# 'needs-attention',
# False
#)
def on_panel_open_standalone(self, panel):
self.set_titlebar(panel.get_headerbar_standalone())
@ -466,6 +465,8 @@ class Window(Adw.ApplicationWindow):
def on_mcg_custom(self, name):
pass
"""
if name == Window._CUSTOM_STARTUP_COMPLETE:
for panel in self._panels:
GObject.idle_add(
@ -474,6 +475,7 @@ class Window(Adw.ApplicationWindow):
'needs-attention',
False
)
"""
def on_mcg_error(self, error):