Comments (9)
I'm not sure how viable generating a type getter for every single class is. The
generated documentation for packages are already really big, but this will make
it a lot bigger.
Does this code work?
var pixbufType = glib.TypeFromName("GdkPixbuf")
The code used to get the GdkPixbuf
string is below:
package main
import (
"log"
"github.com/diamondburned/gotk4/pkg/core/glib"
"github.com/diamondburned/gotk4/pkg/gdkpixbuf/v2"
)
func main() {
pixbuf := gdkpixbuf.NewPixbuf(
gdkpixbuf.ColorspaceRGB,
false, 8, 1, 1,
)
log.Println(pixbuf.TypeFromInstance())
log.Println(pixbuf.TypeFromInstance().Name())
log.Println(glib.TypeFromName("GdkPixbuf"))
// Output:
// GdkPixbuf
// GdkPixbuf
// GdkPixbuf
}
from gotk4.
AFAIK there was no other specific need like this, but the IconView is not usable without it.
Your answer seem perfect: efficient and readable.
It would be nice to add an information in the ListStore doc, as it's one of its hidden options.
For the gallery I wanted to get pixbuf from icon name, which seem pretty hard now that everything is wrapped in Paintable or other, so for now it will be from download.
Side question now that my gallery is almost ready, is there a way to make a screenshot of the window (or part of) :
mainW := app.Win.Child()
snap := gtk.NewSnapshot()
mainW.SnapshotChild(mainW.FirstChild(), snap)
renderNode := snap.ToNode()
renderNode.WriteToFile("screenshot.png")
Panics in the ToNode() method.
panic: interface conversion: *glib.Object is not gsk.RenderNoder: missing method Bounds
pkg/gtk/v4/gtksnapshot.go:895
Example found on the gnome forums
from gotk4.
Is there a log print that says "missing marshaler for type"?
This will only work on commit 5622f54 and later.
from gotk4.
I should probably change the code generator to generate an assertion that vomits
out a more helpful message when the type mismatches.
Edit: commit 2625db3 implements this.
from gotk4.
your new error message:
gotk4: marshaler error for : invalid type
Need to make more changes in pkg/core/glib/glib.go
to print the real type:
- log.Printf("gotk4: missing marshaler for type %s (i.e. %s)", v.Type(), fundamental)
+ log.Printf("gotk4: missing marshaler for type %s (%T): %s", v.Type(), v, fundamental)
- log.Printf("gotk4: marshaler error for %s: %v", v.Type(), err)
+ log.Printf("gotk4: marshaler error for type %s (%T): %v", v.Type(), v, err)
Which now crash my screenshot attempt like this:
Gtk-WARNING: Trying to snapshot GtkViewport 0x2dfc7e0 without a current allocation
GLib-GObject-WARNING: invalid (NULL) pointer instance
GLib-GObject-CRITICAL: g_value_init_from_instance: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
With my new error message and its magical %T
gotk4: missing marshaler for type (*glib.Value): invalid type
from gotk4.
That's unusual. Can you make a working piece of code that reproduces the
problem?
from gotk4.
Wait... I'm wondering if this is because the returned renderNode
is nil...
from gotk4.
I think the most appropriate fix in this case would be to fix the bug that's
causing ToNode
to return nil.
For now, commit 1988d98 now panics with a message indicating that an object that
wasn't supposed to be nil is now nil, which should crash the application with a
more helpful and less confusing error.
from gotk4.
I'm not sure how viable generating a type getter for every single class is. The
generated documentation for packages are already really big, but this will make
it a lot bigger.
Latest commit now generates a gdkpixbuf.GTypePixbuf
value. TypeFromName
is no longer needed.
from gotk4.
Related Issues (20)
- Why go4.org/unsafe/assume-no-moving-gc ? HOT 4
- gir-generate failed to decode gir XML HOT 4
- Gstreamer bindings HOT 17
- Generator Workflow HOT 2
- Unusable GtkBuilderCScope API
- Memory is not freed when destroying Window HOT 1
- `DropTarget` panics when calling the `"drop"` signal handler HOT 10
- Bring back Unref methods
- Switch intern to KarpelesLab/weak
- Missing bindings: Cannot read selected item of gtk.DropDown as string HOT 4
- Copy text into clipboard works on Linux but crashes on Windows HOT 2
- support building without gobject-introspection & atk HOT 3
- GtkApplication? crash HOT 3
- Refactor SetFinalizer and toggle notifier HOT 2
- ConstraintLayout.AddConstraintsFromDescription results in SIGSEGV HOT 1
- GTK Assertion Fails calling NewConstraint HOT 3
- gotk4 ApplicationWindow does not show after Hide()
- ASSUME_NO_MOVING_GC_UNSAFE_RISK_IT_WITH HOT 2
- Video Streaming HOT 26
- Custom glib.LogSetWriter HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gotk4.