GNOME Bugzilla – Bug 608329
Patch to add Color to Account tabs.
Last modified: 2018-06-29 22:34:14 UTC
Created attachment 152478 [details] [review] Diff file of changes I wanted a way to select an account easily when I have several accounts open in the main window. I decided to add a color option to the account so that the tab can be set to a specific color and so easily identifiable. This could also be used to link like minded accounts together. This is my first attempt at programming so there may be a better way of implementing but it compiles with no errors and warnings on my 64 bit Linux box so please let me know what you think. Will attach a screen shot and a diff file for the changes made.
Created attachment 152479 [details] Screen shot of changes.
I forgot to mention, using an xml file the upgrade appears to be seem less but when tested with sqlite3 database, the old database needs to be saved as with a new name so the additional field can be setup otherwise the new color field would have to be added some how.
Comment on attachment 152478 [details] [review] Diff file of changes Thanks for this interesting new feature. In terms of the GUI side of this, the patch is fine. However, there is a problem with the data store of this: We cannot start to *write* new XML elements in the current version ("account_color"), because this will cause all previous versions to refuse reading these data files. But there is a different solution available: You need to store your account_color string in the "KVP" (key-value frame) of the account, with some key you invent for yourself. In contrast to "real XML elements", the KVP entries can transparently be added and they will also be correctly loaded and saved again even by earlier gnucash versions. See also src/engine/kvp_doc.txt
See e.g. how xaccAccountGetNotes and SetNotes is implemented.
Created attachment 152914 [details] [review] New patch using KVP I thought that it was OK for new program versions to open old files but not necessary the other way round. Any way I have changed the way the 'color' is saved to use KVP as you suggested, much easier than I thought and now an unpatched version can read the files. Also I forgot to mention that the patch fixes the account tooltip not being updated when the name changes.
Comment on attachment 152914 [details] [review] New patch using KVP Looks good to me. Thanks a lot!
With this patch (and my unchanged file) I get the following warnings on the console: CRIT <Pango> pango_color_parse: assertion `spec != NULL' failed Can you look into this?
(In reply to comment #5) > Also I forgot to mention that the patch fixes the account tooltip not being > updated when the name changes. May you please prepare separate patches for separate issues (I suppose they are). After a quick glance on your changes to main_window_update_page_name, you probably leak a few strings (oldname, longname, maybe more). Honestly, I do not fully understand that function now. What is the relation between longname and oldname, and what is index? I have not even looked at the rest of the patch yet, I am too confused ;-(
Created attachment 153086 [details] [review] New patch using KVP to fix PANGO errors.
(In reply to comment #7) > With this patch (and my unchanged file) I get the following warnings on the > console: > > CRIT <Pango> pango_color_parse: assertion `spec != NULL' failed > > Can you look into this? Sorry about this, I ran from a console and did not see any errors but failed to look in the gnucash.trace file, hopefully I have fixed these.
(In reply to comment #8) > (In reply to comment #5) > > Also I forgot to mention that the patch fixes the account tooltip not being > > updated when the name changes. > > May you please prepare separate patches for separate issues (I suppose they > are). > > After a quick glance on your changes to main_window_update_page_name, you > probably leak a few strings (oldname, longname, maybe more). Honestly, I do not > fully understand that function now. What is the relation between longname and > oldname, and what is index? > I have not even looked at the rest of the patch yet, I am too confused ;-( The tooltip fix is in the same area of my tab color changes and it seemed easier to combine them. I am sorry that you were confused, I have changed some of the variable names to hopefully make more sense.
Comment on attachment 153086 [details] [review] New patch using KVP to fix PANGO errors. r18637, thanks a lot!
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=608329. Please update any external references or bookmarks.