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

Save custom commands when clicking ok #2868

Open
Davidy22 opened this issue Aug 18, 2021 · 8 comments
Open

Save custom commands when clicking ok #2868

Davidy22 opened this issue Aug 18, 2021 · 8 comments

Comments

@Davidy22
Copy link
Contributor

Currently, if I go to custom commands, type a nice long command and click ok, I lose my custom command and have to go back and type it in again. I have to hit enter first in the command field, then click ok. Ok should save the contents of the custom command field that has focus and hasn't been saved yet.

@elextr
Copy link
Member

elextr commented Aug 18, 2021

I'm afraid thats a GTK-ism that we don't control, the signal to Geany from the entry field isn't sent until you enter the command, just exiting the dialog doesn't do it.

@Davidy22
Copy link
Contributor Author

I remember when fixing the numbered bookmarks that keypresses in general can be captured, so a little bit of binding of save to any keypress when you have focus on the text box might do the job. I'll try to find a gtk program with auto updating search, see how someone else handles making events happen without the gtk baked lose focus event.

@elextr
Copy link
Member

elextr commented Aug 18, 2021

Actually its slightly more subtle, 1) custom commands is a Gtk tree view, not a simple entry, more complicated 2) the cell renderer doesn't fire the edited signal until enter, so the value isn't copied into the underlying store until then, so when the dialog is closed the value in the store is unchanged and thats what is saved.

But the same thing happens for plain GTK entrys eg in the build commands dialog, without an enter or moving to another entry the edited value isn't saved to be available for the application to read when the dialog is "OK"ed.

@Davidy22
Copy link
Contributor Author

For the ugly solution that doesn't involve waiting on gtk, could we do some manual keypress captures and maintain our own copy of the store, so semi reimplement it to make this work? Or we could petition some changes to tree view upstream, anything that happens if we went that route would probably happen in gtk 4 though and I think geany hasn't jumped over yet

@elextr
Copy link
Member

elextr commented Aug 18, 2021

Well, I don't know what others think, but as far as I'm concerned, no, reimplementing your toolkit isn't sensible. Perhaps there is a better solution somewhere, but somebodys got to find it.

@elextr
Copy link
Member

elextr commented Aug 18, 2021

I might also just throw out the possibility of removing or reducing the number of places that need Ok-ing, its not the way most current UIs seem to work, maybe we are fighting the toolkit by keeping that paradigm.

@elextr
Copy link
Member

elextr commented Aug 18, 2021

Hmmm, the thought above prompted me to see what the HIG says (brand new one for GTK3/4). It says entrys should accept the text on activate and focus loss (my italics) so maybe all that is needed is to listen for that and treat it as activate?

(Sorry for the bitty response, but it wasn't a contiguous thought process :-)

@Davidy22
Copy link
Contributor Author

I believe it is already bound to a lose focus event because I can make it save by doing things other than hitting enter, like clicking random things. Just doesn't seem to think it's losing focus when I hit esc or the ok button. Actually, I think gtk has switch focus calls, could try see if calling one of those still invokes the lose focus. If it does, we could switch focus to some unused, hidden if possible, widget to force the update before closing the dialog, a little hacky

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

No branches or pull requests

2 participants