namespace StudySystemClient { public class MainWindow : Gtk.ApplicationWindow { public MainWindow(Gtk.Application app, Client client) { Object(application: app); default_width = 360; default_height = 580; var header_bar = new Gtk.HeaderBar(); var title = new Gtk.Label("Study System Client"); title.add_css_class("title"); header_bar.title_widget = title; set_titlebar(header_bar); var connection_indicator = new ConnectionIndicator(client); var activities_view = new ActivitiesView(client); var content = new Gtk.Box(Gtk.Orientation.VERTICAL, 0); content.append(connection_indicator); content.append(activities_view); set_child(content); } } private class ConnectionIndicator : Gtk.Box { public ConnectionIndicator(Client client) { var icon = new Gtk.Image.from_icon_name("network-offline-symbolic"); var label = new Gtk.Label("Disconnected"); var content = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 8); content.margin_top = content.margin_bottom = content.margin_start = content.margin_end = 12; content.hexpand = true; content.halign = Gtk.Align.CENTER; content.append(icon); content.append(label); var revealer = new Gtk.Revealer(); revealer.set_child(content); append(revealer); client.connection_status.connect((connected) => { revealer.reveal_child = !connected; }); } } }