workbenchdev / workbenchdev/Workbench
Can't reference custom widget inside UI file
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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