Can't reference custom widget inside UI file

未關閉
#267 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
35/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
javascript
領域
desktop

研究方向

先從 issue 中的 JavaScript 和 Blueprint 重現程式開始,然後將 Blueprint 的行為與回報的 XML 行為進行比較。重新執行範例,並檢查 namespace 警告以及不斷變化的 MyBin 類型名稱;當可以在沒有警告的情況下從 UI 檔案參照自訂 widget 時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

bug

Problem: I've defined a widget MyBin but using it inside a UI file brings up an error.
JS code

import GObject from "gi://GObject";
import Gtk from "gi://Gtk?version=4.0";
import Adw from "gi://Adw";

Gtk.init();

const MyBin = GObject.registerClass(
  {
    GTypeName: "MyBin",
  },
  class MyBin extends Adw.Bin {},
);

const MyBox = GObject.registerClass(
  {
    GTypeName: "MyBox",
    Template: workbench.template,
  },
  class MyBox extends Gtk.Box {},
);

const b = new MyBox();
workbench.preview(b);

blueprint (but the problem seems to be present even with normal XML. You can translate between the two...).

using Gtk 4.0;

template MyBox : Gtk.Box {
  .MyBin {}
}

Error:
(re.sonny.Workbench:4): re.sonny.Workbench-WARNING **: 22:51:26.278: Requiring My, version none: Typelib file for namespace 'My' (any version) not found

Notes:
console.log(MyBin.$gtype.name) outputs MyBin1, MyBin2, ..., MyBin${i}, incrementing every time I click run. The name of the type seems to be changing. Even knowing that, setting in the UI file the type MyBin3 and trying to hit run until MyBin.$gtype.name == 'MyBin3' doesn't fix anything.

主要語言
JavaScript
星號
846
分支
91
PR 合併指標
30 天內沒有已合併 PR

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

workbenchdev/Workbench 的其他 Issue

查看 workbenchdev/Workbench 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。