[Patch] simplify window geometry management

Albrecht Dreß <[email protected]>
Newsgroups gmane.comp.gnome.apps.balsa
Message-ID <[email protected]>
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

_______________________________________________
balsa-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/balsa-list
geometry-management.diff.bz2 (application/x-bzip, 7.7 KB) - not displayed
signature.asc (application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE-----

iQEzBAABCgAdFiEEcCEPemLFTtyGf4zATKlvDmfn2fgFAlwuATIACgkQTKlvDmfn
2fjc4Qf/a4R7Oqw3BKr5WZysbCYuApwLlVKiWL9kzrJYTvj5vae7EOyGhGiCMEJ7
hsysb5C4ZluhHke3iJu3FEEQ3693yKRQP8TE+GoyujtsNX9rNY/T8L3EFfLDe3gQ
O8+y5qRrSd0CVmoc7h0Ht6Jv+YX5lrRM3VKyiS0A3cjsWvWJHh+tk5L7XF+qdsBJ
9lPRtoDVHrq9LOsUnUyln2X4GRlpk73PneUjpymOhWQLNx2FK9BNi73gR94yP1af
aS9J7GcQFfH/yPXxuaR/wOcPos7q6HyznlvBYtisqDT2pkMJChZ6lcTx3zYO3TMX
1Lf7xiR4C+UEmJ5DeZHrvId60aLxmw==
=bt0Y
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.