Changes
1 changed files (+42/-14)
-
-
@@ -14,7 +14,6 @@ // limitations under the License.// // SPDX-License-Identifier: Apache-2.0 // Sample code from Elementary tutorial public class PlacApp : Gtk.Application { public PlacApp(){ Object(
-
@@ -23,26 +22,55 @@ flags : ApplicationFlags.DEFAULT_FLAGS); } protected override void activate() { // TODO: Write this to GUI var opts = Plac.ScanOptions(); stderr.printf("count=%u, window=%u\n", opts.count, opts.receive_window_ms); private async Plac.Server[] scan_servers() { SourceFunc callback = scan_servers.callback; Plac.Server[] servers = {}; var scanner = new Plac.ServerScanner(); var result = scanner.scan(opts); while (true) { var server = result.next(); if (server == null) { break; ThreadFunc<void>run = () => { var opts = Plac.ScanOptions(); var scanner = new Plac.ServerScanner(); var result = scanner.scan(opts); while (true) { var next = result.next(); if (next == null) { Idle.add((owned) callback); return; } servers += (owned) next; } }; stderr.printf("%s\n", server.name); } new Thread<void>("server_scanner", (owned) run); yield; return (owned) servers; } protected override void activate() { var container = new Gtk.Box(Gtk.Orientation.VERTICAL, 6); var loading_text = new Gtk.Label("Scanning Roon Servers on network..."); container.append(loading_text); scan_servers.begin((_obj, res) => { var servers = scan_servers.end(res); container.remove(loading_text); var box = new Gtk.ListBox(); container.append(box); foreach (unowned Plac.Server server in servers) { box.append(new Gtk.Label(server.name)); } }); var main_window = new Gtk.ApplicationWindow(this) { default_height = 300, default_width = 300, title = "Hello, World!" title = "Plac", child = container, }; main_window.present(); }
-