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
Add gtk::ColumnView "data grid" example #1111
Conversation
Haven’t checked the code yet, but I see that the screenshot shows that you don’t use the GTK default theme. That is something we require for our screenshots IIRC. |
not sure if this is the true GTK default theme but I used gnome tweaks to make "Adwaita (default)" for the screenshot now |
thanks all, this is great feedback. I'll try to incorporate |
might be ready for re-review |
just as a random add on, I am sure more features could be added onto this example if there is interest in showing off more features of columnview but the basic example could be helpful to get people started. if there are ideas about the extending the scope this example should have, let me know |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise lgtm, thanks!
<interface> | ||
<template class="GridCell" parent="GtkWidget"> | ||
<child> | ||
<object class="GtkLabel" id="name"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should still be replaced with a GtkInscription btw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was getting an error trying to use "gtk::Inscription" in the imp file (mentioned here #1111 (comment)), not sure if that is what it is called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to modify https://github.com/gtk-rs/gtk4-rs/blob/master/examples/Cargo.toml#L15-L17 and add features = ["v4_8"]
to opt-in for the new gtk 4.8 features. If it doesn't build locally, then it means you have an older gtk version installed which is fine as the example would work fine in the CI. You can add some comment saying, you can use a plain gtk::Label for gtk < 4.8 and point to the docs for Inscription type that explains why it is a good alternative to gtk::Label sometimes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome, thanks. I went ahead and pushed this
sorry for being very picky but one last change and we can land it. If you can squash all the commits into one, that would be awesome. |
Add screenshot Update examples/column_view_datagrid/grid_cell/mod.rs Co-authored-by: Hofer-Julian <30049909+Hofer-Julian@users.noreply.github.com> Update examples/column_view_datagrid/grid_cell/grid_cell.ui Co-authored-by: Marco Melorio <marco.melorio@protonmail.com> Just use a Gtk::Label in the gridcell Subclass plain Gtk::Widget instead of Gtk::Box xref '#1111 (comment)' Add dispose function Append a bunch of items Add note Update examples/column_view_datagrid/grid_cell/imp.rs Co-authored-by: Marco Melorio <marco.melorio@protonmail.com> Update examples/column_view_datagrid/grid_cell/mod.rs Co-authored-by: Marco Melorio <marco.melorio@protonmail.com> Update examples/column_view_datagrid/grid_cell/imp.rs Co-authored-by: Marco Melorio <marco.melorio@protonmail.com> Rename to set_entry Rename some variables and remove outer Gtk.Box Fix lint Update examples/column_view_datagrid/grid_cell/imp.rs Co-authored-by: Bilal Elmoussaoui <belmouss@redhat.com> Update to use gtk::Inscription instead of gtk::Label
no worries, I appreciate the good code review! I made that change now possibly as a follow up PR, we could add more features to this example. I am experimenting with how a user interacts with the columnview currently e.g. with the connect_activate method, MultiSelection with the Bitset+BitsetIterator, maybe adding right click context menu, etc. |
Hi there,
I wanted to create a data grid style app as a learning experience. struggled with it for awhile as I'm very new to both gtk and rust, so not sure if I got all the idiomatic usage correct, but I thought it could be useful for others to have an example for the gtk::ColumnView. It adapts from the listview applications launcher a bit, so some code similarities there
I used a tip from gtk-rs/gtk-rs-core#757 as a starter
Let me know if I can add any more details