cassidyjames / ideogram

Insert emoji anywhere in elementary OS, even in non-native apps
https://cassidyjames.com
GNU General Public License v3.0
92 stars 19 forks source link

Adds Timeouts to avoid the app closing before the paste. #60

Closed leggettc18 closed 3 years ago

leggettc18 commented 3 years ago

Fixes #56

Basically the app closes before the paste keystroke actually occurs, which then clears the clipboard (this particular behavior appears to be what changed between Odin and Hera). I added a 500 millisecond timeout before the actual close happens, both when the entry change signal occurs as well as the focus in or out of the main window. The following line of code is what actually does it.

Timeout.add(500, () => {
    close ();
    return false;
});

This does not feel like an ideal solution, ideally we would set it up so that the close function somehow waits for the keystroke to happen, or we could first store the clipboard data somewhere where the app could be closed without losing the clipboard data. I attempted to make each solution work but was unable to make it work. It would always either paste nothing or whatever was on my clipboard before the app was launched. More experimentation might yield a better solution, but for now I'm submitting this in the interest of getting something working.

leggettc18 commented 3 years ago

Well actually I just saw #57... I didn't see any changes to what wasn't working as far as the auto-paste goes but I guess that appears to be working now based on the conversation. Feel free to close if that is the case.

EDIT: Well I pulled that branch and the issue this fixes still seems to be present...

cassidyjames commented 3 years ago

@leggettc18 thanks for this! I went ahead and used this branch as a basis to clean up the closing behavior a bit more:

leggettc18 commented 3 years ago

Awesome, glad I was able to help contribute in some small way, and learned a lot about Vala in the process. A bit frustrating that I couldn't figure out how to make clipboard storage work instead, would have been a much cleaner solution I would think.

cassidyjames commented 3 years ago

@leggettc18 I think I know how I want to approach #17, which is basically:

And then probably clear the GSetting for privacy reasons to ensure we're not keeping old Clipboard data around in our app's data