Skip to content

SignatureDialog: Use ListStore - #1081

Merged
danirabbit merged 4 commits into
masterfrom
danirabbit/signaturedialog-liststore
Aug 10, 2026
Merged

SignatureDialog: Use ListStore#1081
danirabbit merged 4 commits into
masterfrom
danirabbit/signaturedialog-liststore

Conversation

@danirabbit

Copy link
Copy Markdown
Member

can't use get_children in GTK4. We can technically iterate over the listbox still, but it's better to iterate over data

@danirabbit
danirabbit requested a review from a team August 6, 2026 20:03
@danirabbit danirabbit moved this to Needs Review in GTK4 Porting Aug 6, 2026

@jeremypw jeremypw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the filter function will have to be reimplemented a different way, otherwise looking good.

signature_list.set_filter_func ((Gtk.ListBoxFilterFunc)filter_func);
signature_list.set_placeholder (placeholder);
signature_list_box.bind_model (signature_list, (obj) => (Signature) obj);
signature_list_box.set_filter_func ((Gtk.ListBoxFilterFunc)filter_func);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't this ignored when bound to a model? I get the terminal message GtkListBox with a model will ignore sort and filter functions

@danirabbit

Copy link
Copy Markdown
Member Author

@jeremypw in GTK4 we can use a filter list model. Does this not work for you?

@jeremypw

jeremypw commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

@jeremypw in GTK4 we can use a filter list model. Does this not work for you?

In Gtk4 you still cannot use the set_filter_func function of the ListBox but yes, you could wrap the model in a Gtk.FilterListModel. I haven't looked deeply into it but the code looks weird anyway - the filter is dependent on the presence/absence of a timout. I would have thought there is a better way of doing it. Can't we just remove the item from the model when it starts to get deleted?

@danirabbit

Copy link
Copy Markdown
Member Author

@jeremypw I think the idea is we don't want to actually delete it right away because we want to be able to undo. So we're just hiding it from the UI with the filter until we do the actual delete.

I believe you can still use filters and listmodels together in GTK3 even though it warns about it, but I don't think there's any way to really fix the warning in GTK3 🤷‍♀️

@jeremypw

jeremypw commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

@danirabbit You can certainly leave the code in place if you wish - but I don't think the filter will work will it? That may not matter. If it will stay for a significant time and does not work maybe a comment is appropriate?

I now realise the warning is given regardless of whether any sort or filter func is applied.

@danirabbit

Copy link
Copy Markdown
Member Author

@jeremypw it still works in my testing? Does it not work for you?

@danirabbit

Copy link
Copy Markdown
Member Author

Also beware of #1086 when testing

@jeremypw

Copy link
Copy Markdown
Contributor

@danirabbit Hmm, the documentation only says it is "incompatible" not that it doesn't work I guess. Just like you can still add ListBoxRows directly to a ListBox even if it is bound to a model. But then the model does not match the box. I'll check this more thoroughly to see whether there are any drawbacks to applying a filter_func in this case.

@jeremypw

Copy link
Copy Markdown
Contributor

Well, as far as I can see, signatures are never deleted from the model - they are just filtered out by the listbox which seems weird. Can you see a reason for this? Why not just delete them from the model? Maybe its because of the "Undo" facility? But that seems unnecessary as signatures are easy to create?

@jeremypw

Copy link
Copy Markdown
Contributor

But as you say the deleted filter does seem to work, at least in Gtk3. May not in Gtk4 though.

@danirabbit

Copy link
Copy Markdown
Member Author

@jeremypw it should be removed from the model when the window is closed

@jeremypw

Copy link
Copy Markdown
Contributor

Ah, yes there is a 5 second delay before the signature is actually deleted. The undo function just stops the timeout. I guess it is safe enough to leave it as it is for now.

@danirabbit
danirabbit merged commit 9fbcab1 into master Aug 10, 2026
6 checks passed
@danirabbit
danirabbit deleted the danirabbit/signaturedialog-liststore branch August 10, 2026 18:10
@github-project-automation github-project-automation Bot moved this from Needs Review to Done in GTK4 Porting Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants