Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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 摘要。