oracc / nammu

Oracc GUI
GNU General Public License v3.0
12 stars 10 forks source link

Add "(*) " to the title bar when there are unsaved changes #390

Closed giordano closed 5 years ago

giordano commented 5 years ago

Fix #387. I'm not sure this is a superefficient solution as it uses NammuController.unsavedChanges(), which may be a bit too expensive.

giordano commented 5 years ago

I'm trying to think about possible strategies to avoid constantly calling NammuController.unsavedChanges().

One very naive solution would be to make atfAreaDocumentListener.changedUpdate() always set the title as if there are unsaved changes (which may not be true), and have NammuController.openFile(), NammuController.saveFile(), and NammuController.saveAsFile() setting the title as there are no unsaved changes (which is hopefully true). The only case in which the title bar would wrongly report saved/unsaved changes is if undoing/redoing brings back to a situation where there are no unsaved changes (which is still better than reporting no unsaved changes when it's false).

ageorgou commented 5 years ago

That sounds fine to me, for what it's worth; some editors show the status as "changed" even if you undo back to the original state. While it can be confusing, it's not that strange.

giordano commented 5 years ago

Ok, new attempt at addressing the issue. Now I'm using insertUpdate and removeUpdate listeners to update the title bar. These functions are called way fewer times than changedUpdate. E.g., setText triggers insertUpdate only once, as pasting a block of text does. I defined a function NammuView.set_title to set the title in a consistent way.