-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there way to get GType from GObject / Widget #152
Comments
From the Vala docs we learn that get_type() is related to https://developer.gnome.org/gobject/stable/gobject-Type-Information.html#G-TYPE-FROM-INSTANCE:CAPS which should only be used in type implementations. But we have
what may do what you need. Generally we should be a bit careful porting Vala examples, as Vala code may be not of highest quality. May be fine for tiny examples, but for larger ones we may get code which is not 100% correct. The aeldemery examples may be nice, but he told me that he is a german doctor, not a professional programmer. Personally I use mostly C examples from gtk4-demo and from gtk/tests. Have you seen the ugly GIR file bugs from https://gitlab.gnome.org/GNOME/gtk/-/issues/4097 That is really ugly as it may takes years until all people have the fixed version. I may have to fix that manually somehow. |
He translates C examples from gtk4 demo to Vala, so I think they correct. https://gitlab.gnome.org/GNOME/gtk/-/blob/master/demos/gtk-demo/dnd.c |
I need GType to create Gtk. Expression #144 Here Vala example Here my start code of doing this, but I need to get GType of FileInfo to create expression. import gintro/[gio, glib, gtk4, gobject]
let
file = gio.newGFileForPath(".")
dl = gtk4.newDirectoryList("standard::name", file)
sortListModel = newSortListModel(listModel(dl))
listModel = sortListModel.listModel()
expression = newPropertyExpression()
strSorter = newStringSorter(expression)
sortListModel.sorter = strSorter
let x = cast[gio.FileInfo](listModel.getItem(0))
echo x.name |
So far, I can use the typeFromName function |
Im remaking this example, and cant find a method for get type from Widget, like was donw on this line:
https://github.com/aeldemery/simple-drag-n-drop/blob/main/sources/MainWindow.vala#L84
https://valadoc.org/gobject-2.0/GLib.Object.get_type.html
Looks like this bind vala to C G_TYPE_FROM_INSTANCE
The text was updated successfully, but these errors were encountered: