After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 681191 - add g_key_file_{get,set}_modified()
add g_key_file_{get,set}_modified()
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gkeyfile
unspecified
Other All
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-08-04 12:05 UTC by Marc-Andre Lureau
Modified: 2018-05-24 14:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
keyfile: add g_key_file_{get,set}_modified() (5.29 KB, patch)
2012-08-04 12:05 UTC, Marc-Andre Lureau
none Details | Review
tests/keyfile: add modified flag test (22.04 KB, patch)
2012-08-04 12:05 UTC, Marc-Andre Lureau
none Details | Review

Description Marc-Andre Lureau 2012-08-04 12:05:47 UTC
It can be useful to track if the keyfile has been modified,
to check if it needs to be saved again.

The API is similar to GtkTextBuffer. The user can manually set the
modified flag.

It could eventually be useful to have hook to be informed when the
flag is modified.
Comment 1 Marc-Andre Lureau 2012-08-04 12:05:49 UTC
Created attachment 220310 [details] [review]
keyfile: add g_key_file_{get,set}_modified()
Comment 2 Marc-Andre Lureau 2012-08-04 12:05:53 UTC
Created attachment 220311 [details] [review]
tests/keyfile: add modified flag test
Comment 3 Emmanuele Bassi (:ebassi) 2012-08-04 14:02:00 UTC
to be perfectly honest, I don't like this manual approach to mutability very much.

I'd rather have a GKeyFile flag that loads the keyfile as 'immutable' - i.e. every set() operation will (more or less silently) fail - and if the flag is not set, the KeyFile will enter in a 'modified' state which will stay until the KeyFile is freed. saving to data won't change the 'modified' state, only loading again will. in other words: GKeyFile.modified can only be FALSE if the GKeyFile is immutable or it has just been created/loaded.
Comment 4 Marc-Andre Lureau 2012-08-04 14:13:04 UTC
(In reply to comment #3)
> to be perfectly honest, I don't like this manual approach to mutability very
> much.

I don't think it serves the same purpose here. keyfile is mutable, I am not trying to change that. That would be a seperate feature

> I'd rather have a GKeyFile flag that loads the keyfile as 'immutable' - i.e.
> every set() operation will (more or less silently) fail - and if the flag is
> not set, the KeyFile will enter in a 'modified' state which will stay until the
> KeyFile is freed. saving to data won't change the 'modified' state, only
> loading again will. in other words: GKeyFile.modified can only be FALSE if the
> GKeyFile is immutable or it has just been created/loaded.

However I agree that after load, we can debate if modified should stay FALSE. Since the current API allows the same keyfile to be reloaded several time, I chose to set it as modified when this happens.

If the flag you propose is not set, you said keyfile should stay in 'modified' state. Does that mean that there would be no way to know if it has actually been modified? That wouldn't be very helpful for the case I propose.

I think adding an immutable flag and raising errors when modification are attempted could be a seperate feature that would combine well with this bug. No?
Comment 5 Allison Karlitskaya (desrt) 2012-08-05 19:45:59 UTC
How much does this new API really buy you over just tracking the state manually outside of GKeyFile?
Comment 6 Marc-Andre Lureau 2012-08-05 19:50:05 UTC
(In reply to comment #5)
> How much does this new API really buy you over just tracking the state manually
> outside of GKeyFile?

Well, I don't have to wrap all the keyfile methods. But sure, I can do it outside. I thought it would make sense for others to have a modified flag as part of keyfile, and the change is fairly non-intrusive imho.
Comment 7 Marc-Andre Lureau 2012-09-06 09:06:22 UTC
(je t'aime, un peu, beaucoup, passionnement, a la folie... pas du tout?)
Comment 8 GNOME Infrastructure Team 2018-05-24 14:25:15 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/582.