workbenchdev / workbenchdev/Workbench

Can't reference custom widget inside UI file

Open
#267 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
844
Forks
91
Avg merge
7h 12m
Merged PRs (30d)
1

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the JavaScript and Blueprint reproducer in the issue, then compare the Blueprint behavior with the reported XML behavior. Re-run the example and inspect the namespace warning and changing MyBin type names; done means the custom widget can be referenced from the UI file without the warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.