Changes
4 changed files (+137/-33)
-
-
@@ -39,6 +39,10 @@break :core dep.artifact("plac_core"); }; const gresources = [_][]const u8{ "data/ui/server-list.ui", }; // Vala source codes to compile. As Vala does not have module system, // we have to list every source code files to include. const vala_sources = [_][]const u8{
-
@@ -61,6 +65,10 @@ const valac = b.addSystemCommand(&.{"valac"});// Tell Vala compiler to emit C rather than compile using system C compiler. valac.addArg("--ccode"); // Vala compiler uses GResource XML to statically check attributes. valac.addArg("--gresources"); valac.addFileArg(b.path("data/gresource.xml")); valac.addArg("--vapidir"); valac.addDirectoryArg(core.getEmittedIncludeTree());
-
@@ -88,6 +96,27 @@break :vala dir; }; const gresouce_c = gresource: { const compiler = b.addSystemCommand(&.{"glib-compile-resources"}); // glib-compile-resouces resolves every paths from CWD. compiler.cwd = b.path("data"); compiler.addFileArg(b.path("data/gresource.xml")); // Invalidate build cache whenever a file inside "data/" has changed. for (gresources) |r| { compiler.addFileInput(b.path(r)); } compiler.addArg("--target"); const built_c = compiler.addOutputFileArg("gresource.c"); compiler.addArg("--generate-source"); break :gresource built_c; }; // An executable. const exe = exe: { const exe = b.addExecutable(.{
-
@@ -106,6 +135,8 @@ exe.linkSystemLibrary(lib);} exe.linkLibrary(core); exe.addCSourceFile(.{ .file = gresouce_c }); // At this point, build does not run yet—we can't enumerate C source // directory. Since we already have a list of Vala source code, we can
-
-
-
@@ -0,0 +1,23 @@<?xml version="1.0" encoding="utf-8"?> <!-- Copyright 2025 Shota FUJI Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache-2.0 --> <gresources> <gresource prefix="/jp/pocka/plac/gtk-adwaita"> <file preprocess="xml-stripblanks">ui/server-list.ui</file> </gresource> </gresources>
-
-
-
@@ -0,0 +1,48 @@<?xml version="1.0" encoding="utf-8"?> <!-- Copyright 2025 Shota FUJI Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache-2.0 --> <interface> <template class="PlacServerSelectorWindow" parent="AdwApplicationWindow"> <property name="default-width">300</property> <property name="default-height">300</property> <property name="title">Server Selector</property> <property name="content"> <object class="GtkBox"> <property name="orientation">vertical</property> <property name="spacing">8</property> <child> <object class="GtkLabel"> <property name="label">Select Roon Server to connect.</property> <attributes> <attribute name="weight" value="PANGO_WEIGHT_BOLD" /> </attributes> </object> </child> <child> <object class="GtkListBox" id="servers_list"> <child type="placeholder"> <object class="GtkLabel"> <property name="label">Scanning Roon Servers on network...</property> </object> </child> </object> </child> </object> </property> </template> </interface>
-
-
-
@@ -14,14 +14,46 @@ // limitations under the License.// // SPDX-License-Identifier: Apache-2.0 public class PlacApp : Gtk.Application { public PlacApp(){ namespace Plac { public class App : Adw.Application { public App(){ Object( application_id: "jp.pocka.plac", flags : ApplicationFlags.DEFAULT_FLAGS ); } protected override void activate() { var main_window = new ServerSelectorWindow(this); main_window.present(); } public static int main(string[] args) { return new App().run(args); } } [GtkTemplate(ui = "/jp/pocka/plac/gtk-adwaita/ui/server-list.ui")] class ServerSelectorWindow : Adw.ApplicationWindow { [GtkChild] private unowned Gtk.ListBox servers_list; public ServerSelectorWindow(Gtk.Application app) { Object(application: app); scan_servers.begin((_obj, res) => { var servers = scan_servers.end(res); foreach (unowned Plac.Server server in servers) { var row = new Adw.ActionRow(); row.title = server.name; row.subtitle = server.version; servers_list.append(row); } }); } private async Plac.Server[] scan_servers() { SourceFunc callback = scan_servers.callback; Plac.Server[] servers = {};
-
@@ -47,35 +79,5 @@ 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 = "Plac", child = container, }; main_window.present(); } public static int main(string[] args) { return new PlacApp().run(args); } } }
-