[Patch] simplify window geometry management



Hi all,

Balsa saves and restores the geometry (width, height, maximised state) of several dialogues, and keeps the 
current values in the big struct BalsaApplication (global variable balsa_app).  This approach has IMHO some 
disadvantages:
* duplicated code: the same callbacks for catching size-allocate and notify::is-maximized have to be 
implemented repeatedly
* libbalsa dialogues: accessing the global variable balsa_app, in particular from callbacks, is difficult
* the balsa_app structure is bloated by many (almost) similar items
* tracking the geometry of more dialogues requires many changes

Attached is a proposal (against the autocrypt branch, so in master there may be some offsets) how the 
geometry management could be simplified.  The basic idea is to add a libbalsa module for managing these 
values:
* when loading the "Geometry" config, instead of reading the values separately, initialise geometry management for a dialogue identifier.  E.g. for 
"MainWindow", this reads the values "MainWindowWidth", "MainWindowHeight" and "MainWindowMaximized", and stores them in a hash 
with key "MainWindow";
* whenever a "managed" window shall be displayed, attach it to the manager, using the key above.  Internally, 
this makes the window resizable, assigns the geometry values from the hash, and connects the appropriate callbacks;
* when the configuration shall be saved, in the "Geometry" section call just /one/ function to dump all 
values.

Now, remembering the geometry for any window, e.g. for the gpgme key list in a libbalsa callback, basically 
boils down to two calls:
* in config_global_load(), add one call for initialising the hash for a new key and
* before showing the window, attach it to the geometry manager using the same key.

The attached patch implements this approach for the MainWindow*, SendMsgWindow*, MessageWindow* and the 
source viewer, and additionally for the gpgme-related key list and key display dialogues.  Quirks:
* source viewer width and height are moved from the "SourcePreview" to the "Geometry" section and
* "SendmsgWindowMaximized" is renamed to "SendMsgWindowMaximized"
i.e. these items are not restored properly the first time after applying the patch (but of course afterwards).

I didn't look in detail yet, but I guess there are a lot more candidates which could be added, e.g the filter 
dialogues, configuration, Autocrypt database viewer, …

As always, any comment will be welcome!

Cheers,
Albrecht.

---
Patch details:
- libbalsa/Makefile.am: add geometry manager module
- libbalsa/geometry-manager.[hc]: geometry manager module implementation
- libbalsa/libbalsa-gpgme-cb.c: use geometry manager for the key list dialogue
- libbalsa/libbalsa-gpgme-widgets.c: use geometry manager for the key dialogue
- libbalsa/libbalsa.h: simplify libbalsa_show_message_source() api, remove unimplemented function prototype
- libbalsa/source-viewer.c: use geometry manager, simplify libbalsa_show_message_source() api
- src/balsa-app.c: remove initialisation of obsolete balsa_app items
- src/balsa-app.h: remove obsolete balsa_app items
- src/balsa-index.c: use new libbalsa_show_message_source() api
- src/folder-conf.c, src/main-window.c, src/main.c, src/message-window.c, src/sendmsg-window.c: use geometry 
manager and new libbalsa_show_message_source() api
- src/save-restore.c: use geometry manager to load and save values

Attachment: geometry-management.diff.bz2
Description: application/bzip

Attachment: pgpENHc0d9dI0.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]