> On Nov 6, 2016, at 6:23 PM, Amin Aghabeiki <amin.aghabe...@gmail.com> wrote: > > yep , its fantastic guide , thanks a late Geert
And I'm not Geert, which is why you should always copy the list on all replies. ;-) Regards, John Ralls > > Regards > Amin > > On 11/6/16, John Ralls <jra...@ceridwen.us> wrote: >> >>> On Nov 5, 2016, at 6:09 AM, Geert Janssens <geert.gnuc...@kobaltwit.be> >>> wrote: >>> >>> On Friday 04 November 2016 08:08:46 John Ralls wrote: >>>>> On Nov 3, 2016, at 8:39 PM, Amin Aghabeiki >>>>> <amin.aghabe...@gmail.com <mailto:amin.aghabe...@gmail.com>> wrote: >>>>> >>>>> Hi John >>>>> >>>>> I plane to change check box for calendar to combo box but its really >>>>> complicated there is any guide to add combo box in preference? >>> >>> Which check box are you referring to here ? >>>> >>>> Amin, >>>> >>>> No, I've never worked with the preferences dialog. Perhaps Geert can >>>> offer some help. >>>> >>>> Regards, >>>> John Ralls >>> >>> Hmm, it's been a while. Let's see what I remember... >>> >>> I assume you want to add a combobox in which the user can select the >>> calendar widget to use (Gregorian vs Jalali). >>> >>> There are several examples you can follow in the preferences already. The >>> date-format combobox is probably a good start. >>> >>> First you should define your combobox in the glade interface file >>> (src/gnome-utils/gtkbuilder/dialog-preferences.glade). Note the name needs >>> a particular format, which I'll get back to later. >>> >>> Each combobox needs a model, which you can also define in the same glade >>> file. For the date-format combobox this is a gtkliststore with the name >>> "date-formats". You'll need to define one similar for your combobox. >>> >>> Next, all settings you see in the preferences dialog are stored in >>> gsettings. Gsettings uses xml configuration files to define its settings. >>> You'll need to create the schema for your specific preference. The schema >>> are stored in gsettings subdirectories in various places of the code. The >>> other date-time related settings are defined in >>> src/gnome/gsettings/org.gnucash.gschema.xml.in.in >>> Again you can follow the example of the date-format preference. You will >>> need to add a key to the general schema for your preference. It will store >>> an integer value which is the selected line number in the combobox' >>> liststore (though 0-based). This sounds more complicated than it is >>> really. If you offer the user two options in your combobox, like this: >>> Gregorian calendar >>> Jalali calendar >>> and the user selects "Jalali calendar", the value to store in the >>> preference will be 1. Otherwise it will be 0. Note that I believe 0 should >>> be the default to avoid unexpected changes to existing users. >>> >>> And now for a crucial part: the name of your combobox in the glade file >>> should be the gsettings path of your preference prefixed with "pref/". For >>> the date-format preference for example this becomes: >>> pref/general/date-format >>> The combobox called that way will be tied automatically to the date-format >>> gsettings preference in the general section in gsettings. This part is >>> crucial. If the name of the widget is not correctly matched to the >>> gsettings key, your preference will not work. >>> >>> Lastly, due to the way gtkbuilder works, you'll have to explicitly tell >>> gnucash to load the liststore you have defined for your combobox. It will >>> load the combobox automatically, but not the liststore. This needs one >>> more line in src/gnome-utils/dialog-preferences.c around line 1084. >>> >>> After all that is done, your preference should just work. >>> >>> For readability you should add a #define for the key of your preference in >>> your own code, starting with "GNC_PREF_" and use that in combination with >>> GNC_PREFS_GROUP_GENERAL in your calls to gnc_prefs_get_int to query the >>> value of the new preference. >>> >>> Finally, you may want to listen for changes in your new preference in >>> order to update date/time widgets on open registers, report-option dialogs >>> and anywhere else you are offering the jalali calendar as alternative. You >>> can register callbacks to your preference via "gnc_prefs_register_cb" >>> >>> Is that sufficient to get you going ? >> >> That would be an excellent wiki article... >> >> Regards, >> John Ralls >> >> >> _______________________________________________ gnucash-devel mailing list gnucash-devel@gnucash.org https://lists.gnucash.org/mailman/listinfo/gnucash-devel