Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Can't reference custom widget inside UI file

Aperta
#267 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
desktop

Direzione di ricerca

Inizia con il riproduttore JavaScript e Blueprint nell’issue, quindi confronta il comportamento di Blueprint con il comportamento XML segnalato. Esegui nuovamente l’esempio e analizza l’avviso relativo al namespace e i nomi dei tipi MyBin che cambiano; il lavoro è completo quando è possibile fare riferimento al widget personalizzato dal file UI senza l’avviso.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
JavaScript
Stelle
846
Fork
91
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di workbenchdev/Workbench

Tutte le issue di workbenchdev/Workbench

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.