Improved update logic
This commit is contained in:
@@ -98,7 +98,7 @@ class LibremsonicApp(Gtk.Application):
|
|||||||
self.save_settings()
|
self.save_settings()
|
||||||
|
|
||||||
# Update the window according to the new server configuration.
|
# Update the window according to the new server configuration.
|
||||||
self.window.update(self.config)
|
self.window.update(self.config.servers[self.config.current_server])
|
||||||
|
|
||||||
def show_configure_servers_dialog(self):
|
def show_configure_servers_dialog(self):
|
||||||
"""Show the Connect to Server dialog."""
|
"""Show the Connect to Server dialog."""
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
gi.require_version('Gtk', '3.0')
|
gi.require_version('Gtk', '3.0')
|
||||||
from gi.repository import Gio, Gtk
|
from gi.repository import Gio, Gtk
|
||||||
|
|
||||||
from .albums import AlbumsPanel
|
from .albums import AlbumsPanel
|
||||||
from .player_controls import PlayerControls
|
from .player_controls import PlayerControls
|
||||||
from libremsonic.config import AppConfiguration
|
from libremsonic.server import Server
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(Gtk.ApplicationWindow):
|
class MainWindow(Gtk.ApplicationWindow):
|
||||||
@@ -35,16 +37,16 @@ class MainWindow(Gtk.ApplicationWindow):
|
|||||||
flowbox.pack_start(self.player_controls, False, True, 0)
|
flowbox.pack_start(self.player_controls, False, True, 0)
|
||||||
self.add(flowbox)
|
self.add(flowbox)
|
||||||
|
|
||||||
def update(self, config: AppConfiguration):
|
def update(self, server: Optional[Server]):
|
||||||
# Update the Connected to label on the popup menu.
|
# Update the Connected to label on the popup menu.
|
||||||
if config.current_server >= 0:
|
if server:
|
||||||
server_name = config.servers[config.current_server].name
|
self.connected_to_label.set_markup(f'Connected to {server.name}')
|
||||||
self.connected_to_label.set_markup(f'Connected to {server_name}')
|
|
||||||
else:
|
else:
|
||||||
self.connected_to_label.set_markup(
|
self.connected_to_label.set_markup(
|
||||||
f'<span style="italic">Not Connected to a Server</span>')
|
f'<span style="italic">Not Connected to a Server</span>')
|
||||||
|
|
||||||
print(self.panels)
|
print(self.panels)
|
||||||
|
print(self.player_controls)
|
||||||
|
|
||||||
def create_stack(self, **kwargs):
|
def create_stack(self, **kwargs):
|
||||||
stack = Gtk.Stack()
|
stack = Gtk.Stack()
|
||||||
|
Reference in New Issue
Block a user