lakoliu / Furtherance

Track your time without being tracked
GNU General Public License v3.0
243 stars 24 forks source link

Implement task name autocompletion #118

Closed jlledom closed 9 months ago

jlledom commented 9 months ago

Hi, I wrote some changes to implement task autocompletion through a GTK input drop down. If accepted, this PR would close https://github.com/lakoliu/Furtherance/issues/103

There's a glitch in the drop down I don't know how to fix: when the query returns only one result, a empty whitespace is shown in the dropdown:

imatge

I noticed some other strange behaviors, like:

I think these are probably bugs in GTK itself, as gtk::EntryCompletion is marked as deprecated. But I couldn't find any other component in GTK 4 which implements such functionality.

I took this task as an exercise to learn rust and GTK, so it could have made some beginner mistakes. Please review it with care, fortunately, it's not much code.

lakoliu commented 9 months ago

This sounds awesome, thank you for doing this! I'm moving this weekend so I won't be able to look at it for the next few days, but I'll take a look as soon as possible.

lakoliu commented 9 months ago

Thank you for your patience and thank you very much for implementing this! It looks really good! It's too bad that EntryCompletion is deprecated so we will need to alter this code when GTK 5 comes out, but oh well.

jlledom commented 9 months ago

Thanks for merging. Are you OK with those glitches I mentioned?

lakoliu commented 8 months ago

I'm actually not seeing either of those problems (Fedora 38). I will probably make this an option in the Preferences anyway, so if users do see these bugs and are annoyed by them they can turn off autocomplete.

jlledom commented 8 months ago

I'm actually not seeing either of those problems (Fedora 38).

I'm using Debian stable. Glad to know it works fine in more modern systems.

I will probably make this an option in the Preferences anyway, so if users do see these bugs and are annoyed by them they can turn off autocomplete.

Nice.

lakoliu commented 8 months ago

I did find another bug though - if the auto-complete drop down appears and you don't do anything with it and just click the start button, the drop down stays there until you stop the timer. I will try to find a way around that.

jlledom commented 8 months ago

I did find another bug though - if the auto-complete drop down appears and you don't do anything with it and just click the start button, the drop down stays there until you stop the timer. I will try to find a way around that.

I could reproduce this locally. I think this is a bug in GTK: the widget should be responsible of hiding the popup when losing the focus, and not expect the user to do it manually.

I've spent some time trying to add a listener for the focus-out/blur event on the input, to manually hide the popup on that event, but I found that:

  1. The focus-out event doesn't seem to exist in GTK4.
  2. GTK doesn't provide a method to hide the popup anyway 🙃.

I hope you find a workaround for this. I could check it myself but I'll need some weeks before I can focus on Furtherance again.

lakoliu commented 8 months ago

I was able to fix that bug by just disabling autocompletion when a task is started and enabling it again when it is stopped. I also added a preference to turn it on and off, and fixed a bug where it was showing an empty "#" if there weren't any tags on a task name. Thanks again for this, it's working great!