Skip to content
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

Adds gtk.TreeView example #1

Merged
merged 4 commits into from
Aug 31, 2021

Conversation

rubiojr
Copy link
Contributor

@rubiojr rubiojr commented Aug 30, 2021

No description provided.

// FIXME: doesn't seem to work
//listStore.Set(&iter,
// []int{COLUMN_NAME, COLUMN_COMMENT},
// []glib.Value{*glib.NewValue(name), *glib.NewValue(comment)})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diamondburned any idea what's going on here? the value of a column is missing if I use this.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the dereference here may cause glib.Value to be freed earlier
than it should be, because that throws away the Finalizer. This would be a bug
in pkg/core/glib, I think.

@rubiojr
Copy link
Contributor Author

rubiojr commented Aug 30, 2021

@diamondburned started playing with the bindings today. Quite pleasant to use. Nice job!.

Some early feedback:

  • Not having to handle/ignore errors when creating widgets or using function that return a native error that you can't really handle is 💯 🍬 (compared to gotk3, that is).
  • Function names follow the Go naming conventions better (NewTreeView vs TreeViewNew).
  • win.SetChild(&treeView.Widget) surprised me a bit, found Widgets not usable as Widgetter: FontButton and MenuButton gotk4#31 which helped. TreeView in particular has a Cursor function which made things a bit confusing:
./treeview.go:80:14: cannot use treeView (type *gtk.TreeView) as type gtk.Widgetter in argument to win.Window.SetChild:
        *gtk.TreeView does not implement gtk.Widgetter (wrong type for Cursor method)
                have Cursor() (*gtk.TreePath, *gtk.TreeViewColumn)
                want Cursor() *gdk.Cursor

Copy link
Owner

@diamondburned diamondburned left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR blocks on a separate GLib issue.

Edit: tracking in diamondburned/gotk4#34.

// FIXME: doesn't seem to work
//listStore.Set(&iter,
// []int{COLUMN_NAME, COLUMN_COMMENT},
// []glib.Value{*glib.NewValue(name), *glib.NewValue(comment)})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the dereference here may cause glib.Value to be freed earlier
than it should be, because that throws away the Finalizer. This would be a bug
in pkg/core/glib, I think.

@diamondburned
Copy link
Owner

diamondburned commented Aug 30, 2021

Commit e977c64 in gotk4/pkg should fix the glib.Value issue.

@diamondburned
Copy link
Owner

It seems like using i.SetValue(&iter, COLUMN_NAME, glib.NewValue(name)) for
each row actually works as expected. Something is likely wrong with i.Set's
internals.

@diamondburned
Copy link
Owner

gotk4 commit 318362c fixed this. It was an issue to do with how C's int type
is only 4 bytes on 64-bit, but Go's is 8.

@rubiojr
Copy link
Contributor Author

rubiojr commented Aug 31, 2021

Nice spelunking, that fixed it. Bumped gotk4 also.

@diamondburned diamondburned merged commit cccc582 into diamondburned:master Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants