Changes
7 changed files (+103/-0)
-
-
@@ -97,4 +97,14 @@ void plac_server_scanner_free(plac_server_scanner*);plac_scan_result *plac_server_scanner_scan(plac_server_scanner*, plac_server_scan_options*); plac_find_result *plac_server_scanner_find(plac_server_scanner*, char * const, unsigned int); /* Application */ typedef struct { struct sockaddr __addr; void *__conn; } plac_application; plac_application *plac_application_make_from_server(plac_server*); char *plac_application_connect(plac_application*, char*); void plac_application_free(plac_application*); #endif
-
-
-
@@ -90,4 +90,14 @@[CCode (cname = "plac_server_scanner_find")] public FindResult? find (string id, uint len); } [CCode (cname = "plac_application", free_function = "plac_application_free")] [Compact] public class CoreApp { [CCode (cname = "plac_application_make_from_server")] public CoreApp (Server server); [CCode (cname = "plac_application_connect")] public string? connect (string? token); } }
-
-
-
@@ -39,4 +39,8 @@ @export(&server.ServerScanner.make, .{ .name = "plac_server_scanner_make" });@export(&server.ServerScanner.free, .{ .name = "plac_server_scanner_free" }); @export(&server.ServerScanner.scan, .{ .name = "plac_server_scanner_scan" }); @export(&server.ServerScanner.find, .{ .name = "plac_server_scanner_find" }); @export(&Application.makeFromServer, .{ .name = "plac_application_make_from_server" }); @export(&Application.free, .{ .name = "plac_application_free" }); @export(&Application.connect, .{ .name = "plac_application_connect" }); }
-
-
-
@@ -40,6 +40,7 @@ break :core dep.artifact("plac_core");}; const gresources = [_][]const u8{ "data/ui/main-window.ui", "data/ui/server-list.ui", "data/ui/generic-error-dialog.ui", "data/ui/server-list-unexpected-error-dialog.ui",
-
-
-
@@ -18,6 +18,7 @@ SPDX-License-Identifier: Apache-2.0--> <gresources> <gresource prefix="/jp/pocka/plac/gtk-adwaita"> <file preprocess="xml-stripblanks">ui/main-window.ui</file> <file preprocess="xml-stripblanks">ui/server-list.ui</file> <file preprocess="xml-stripblanks">ui/generic-error-dialog.ui</file> <file preprocess="xml-stripblanks">ui/server-list-unexpected-error-dialog.ui</file>
-
-
-
@@ -0,0 +1,40 @@<?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="PlacMainWindow" parent="AdwApplicationWindow"> <property name="default-width">800</property> <property name="default-height">640</property> <property name="title">Plac</property> <style> <class name="devel" /> </style> <property name="content"> <object class="AdwToolbarView"> <child type="top"> <object class="AdwHeaderBar" /> </child> <property name="content"> <object class="GtkLabel" id="test_label"> <property name="label">Empty</property> </object> </property> </object> </property> </template> </interface>
-
-
-
@@ -121,6 +121,15 @@ var row = new Adw.ActionRow();row.title = server.name; row.subtitle = server.version; var main_window = new MainWindow(this.application, server); row.activatable_widget = main_window; row.activated.connect(() => { main_window.start(); main_window.present(); this.close(); }); servers_list.append(row); } } catch (ScanError e) {
-
@@ -213,6 +222,34 @@ [GtkTemplate(ui = "/jp/pocka/plac/gtk-adwaita/ui/server-list-network-error-dialog.ui")]class ServerListNetworkErrorDialog : GenericErrorDialog { public ServerListNetworkErrorDialog(string details) { Object(details: details); } } [GtkTemplate(ui = "/jp/pocka/plac/gtk-adwaita/ui/main-window.ui")] class MainWindow : Adw.ApplicationWindow { [GtkChild] private unowned Gtk.Label test_label; private Plac.Server server; private Plac.CoreApp app; public MainWindow(Gtk.Application app, Plac.Server server) { Object(application: app); this.server = server.dup(); } // NOTE: `server` is `null` in `construct` block. Stupid constructor design forces // manual memory management or ditching constructor. Here, I chose the latter // because window is hidden by default and startup procedures should start // once after the window became visible. public void start() { test_label.label = this.server.name; this.app = new Plac.CoreApp(this.server); if (this.app != null) { var token = this.app.connect(null); stderr.printf("Got token: %s\n", token); } } } }
-