diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 6f34070c..8b0c00f5 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -4,44 +4,33 @@ */ public class Monitor.MainWindow : Hdy.ApplicationWindow { - private Resources resources; - - // Widgets public Search search { get; private set; } + public ProcessView process_view { get; private set; } - public ProcessView process_view; - public SystemView system_view; - private Gtk.Stack stack; - - private Statusbar statusbar; - - public DBusServer dbusserver; - - - // Constructs a main window public MainWindow (MonitorApp app) { - this.set_application (app); + Object (application: app); + } + construct { setup_window_state (); title = _("Monitor"); - get_style_context ().add_class ("rounded"); - - resources = new Resources (); + var resources = new Resources (); process_view = new ProcessView (); - system_view = new SystemView (resources); + var system_view = new SystemView (resources); - stack = new Gtk.Stack (); - stack.set_transition_type (Gtk.StackTransitionType.SLIDE_LEFT_RIGHT); + var stack = new Gtk.Stack () { + transition_type = SLIDE_LEFT_RIGHT + }; stack.add_titled (process_view, "process_view", _("Processes")); stack.add_titled (system_view, "system_view", _("System")); - - Gtk.StackSwitcher stack_switcher = new Gtk.StackSwitcher (); - stack_switcher.valign = Gtk.Align.CENTER; - stack_switcher.set_stack (stack); + var stack_switcher = new Gtk.StackSwitcher () { + stack = stack, + valign = CENTER + }; var sv = new PreferencesView (); sv.show_all (); @@ -74,25 +63,22 @@ public class Monitor.MainWindow : Hdy.ApplicationWindow { headerbar.set_custom_title (stack_switcher); headerbar.pack_end (preferences_button); - statusbar = new Statusbar (); - - var grid = new Gtk.Grid () { - orientation = Gtk.Orientation.VERTICAL - }; + var statusbar = new Statusbar (); - grid.add (headerbar); - grid.add (stack); - grid.add (statusbar); + var box = new Gtk.Box (VERTICAL, 0); + box.add (headerbar); + box.add (stack); + box.add (statusbar); - add (grid); + child = box; show_all (); - dbusserver = DBusServer.get_default (); + var dbusserver = DBusServer.get_default (); - search_revealer.set_reveal_child (stack.visible_child_name == "process_view"); - stack.notify["visible-child-name"].connect (() => { - search_revealer.set_reveal_child (stack.visible_child_name == "process_view"); + search_revealer.reveal_child = stack.visible_child == process_view; + stack.notify["visible-child"].connect (() => { + search_revealer.reveal_child = stack.visible_child == process_view; }); new Thread ("upd", () => { @@ -112,7 +98,7 @@ public class Monitor.MainWindow : Hdy.ApplicationWindow { }); - dbusserver.quit.connect (() => app.quit ()); + dbusserver.quit.connect (() => application.quit ()); dbusserver.show.connect (() => { this.deiconify (); this.present (); @@ -135,7 +121,7 @@ public class Monitor.MainWindow : Hdy.ApplicationWindow { this.hide_on_delete (); } else { dbusserver.indicator_state (false); - app.quit (); + application.quit (); } return true;