New Masked Calender for GnuCash

classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

New Masked Calender for GnuCash

RotenVorest
Hi All

Finally I add new Masked calendar to GnuCash , and it seem to be work ,
I test date entry load and save date and sheet on database and report , all
of this part work with my Mask Logic ,
the last thing that need to be change is Date Picker. and write some test.
I see this part is a GTK library , and I have not any Idea have can I mask
my new Date ( Jalali ) on it .
any one can help me on it I need Idea :D ?

Thanks & Regards
Amin
_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

John Ralls-2

> On Oct 31, 2016, at 3:17 AM, Amin Aghabeiki <[hidden email]> wrote:
>
> Hi All
>
> Finally I add new Masked calendar to GnuCash , and it seem to be work ,
> I test date entry load and save date and sheet on database and report , all
> of this part work with my Mask Logic ,
> the last thing that need to be change is Date Picker. and write some test.
> I see this part is a GTK library , and I have not any Idea have can I mask
> my new Date ( Jalali ) on it .
> any one can help me on it I need Idea :D ?

Umm, "mask" isn't quite right. Perhaps you mean "override"?

For the GtkDatePicker, you'll need to learn how GObject classes work (there's a nice turorial [1] in the documentation), then derive a class GtkJalaliDatePicker from GtkDatePicker and replace the appropriate functions so that it displays a Jalali month and passes back a Gregorian date when the user completes the selection.

Be sure to use Gtk2!

Regards,
John Ralls

[1] https://developer.gnome.org/gobject/stable/pt02.html
_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

RotenVorest
I use Mask instead of Override because I just show Jalalian Date to user
and rest of back-end function ( event current Gregorian Date-Picker ) work
with Gregorian Date ( when user select an date in Gregorian Date-Picker
automatically convert to Jalalian Date in cell ) . may be in technical the
Override is true word for this kind of  implementation.

About date picker , there is not any easier way ?

Regards
Amin

On Mon, Oct 31, 2016 at 9:54 PM, John Ralls <[hidden email]> wrote:

>
> > On Oct 31, 2016, at 3:17 AM, Amin Aghabeiki <[hidden email]>
> wrote:
> >
> > Hi All
> >
> > Finally I add new Masked calendar to GnuCash , and it seem to be work ,
> > I test date entry load and save date and sheet on database and report ,
> all
> > of this part work with my Mask Logic ,
> > the last thing that need to be change is Date Picker. and write some
> test.
> > I see this part is a GTK library , and I have not any Idea have can I
> mask
> > my new Date ( Jalali ) on it .
> > any one can help me on it I need Idea :D ?
>
> Umm, "mask" isn't quite right. Perhaps you mean "override"?
>
> For the GtkDatePicker, you'll need to learn how GObject classes work
> (there's a nice turorial [1] in the documentation), then derive a class
> GtkJalaliDatePicker from GtkDatePicker and replace the appropriate
> functions so that it displays a Jalali month and passes back a Gregorian
> date when the user completes the selection.
>
> Be sure to use Gtk2!
>
> Regards,
> John Ralls
>
> [1] https://developer.gnome.org/gobject/stable/pt02.html
_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

John Ralls-2

> On Oct 31, 2016, at 8:27 PM, Amin Aghabeiki <[hidden email]> wrote:
>
>
> I use Mask instead of Override because I just show Jalalian Date to user and rest of back-end function ( event current Gregorian Date-Picker ) work with Gregorian Date ( when user select an date in Gregorian Date-Picker automatically convert to Jalalian Date in cell ) . may be in technical the Override is true word for this kind of  implementation.

Right, you're overriding the display methods.  You didn't mention setting up a preference, did you do that or are you assuming everyone in the fa_IR locale will want to use your Jalali calendar?

>
> About date picker , there is not any easier way ?

Not that comes to mind, and besides anything more hackish isn't likely to get merged.

Regards,
John Ralls


_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

RotenVorest
> Right, you're overriding the display methods.  You didn't mention setting
up a preference, did you do that or are you assuming everyone in the fa_IR
locale will want to use your Jalali calendar?

yes I add a setting in preference.

>Not that comes to mind, and besides anything more hackish isn't likely to
get merged.

Noted !

Is it true I flow the implementation of * gnucash-date-picker* and change
to Jalalian Calender ?

Regards
Amin




On Tue, Nov 1, 2016 at 11:54 AM, John Ralls <[hidden email]> wrote:

>
> > On Oct 31, 2016, at 8:27 PM, Amin Aghabeiki <[hidden email]>
> wrote:
> >
> >
> > I use Mask instead of Override because I just show Jalalian Date to user
> and rest of back-end function ( event current Gregorian Date-Picker ) work
> with Gregorian Date ( when user select an date in Gregorian Date-Picker
> automatically convert to Jalalian Date in cell ) . may be in technical the
> Override is true word for this kind of  implementation.
>
> Right, you're overriding the display methods.  You didn't mention setting
> up a preference, did you do that or are you assuming everyone in the fa_IR
> locale will want to use your Jalali calendar?
>
> >
> > About date picker , there is not any easier way ?
>
> Not that comes to mind, and besides anything more hackish isn't likely to
> get merged.
>
> Regards,
> John Ralls
>
>
_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

John Ralls-2

> On Oct 31, 2016, at 9:49 PM, Amin Aghabeiki <[hidden email]> wrote:
>
> > Right, you're overriding the display methods.  You didn't mention setting up a preference, did you do that or are you assuming everyone in the fa_IR locale will want to use your Jalali calendar?
>
> yes I add a setting in preference.
>
> >Not that comes to mind, and besides anything more hackish isn't likely to get merged.
>
> Noted !
>
> Is it true I flow the implementation of  gnucash-date-picker and change to Jalalian Calender ?
>

No, though you'll have to modify it as well as everywhere else that uses GtkCalendar to optionally use your GtkJalaliCalendar. Grep tells me there are 5 modules that use GtkCalendar.

Regards,
John Ralls
_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

Christian Stimming-4
In reply to this post by RotenVorest
Dear Amin,

can you put your current code online somewhere, such as in some github fork? I
would be interested to see which parts of gnucash you actually changed. Maybe
in "our world-view" the change seems too incomplete, but if you say your
change would already be an improvement for users with Jalali calendar, we
might consider this again. But we would have to see your code for that.

Thanks!

Christian


Am Dienstag, 1. November 2016, 12:49:40 schrieb Amin Aghabeiki:

> > Right, you're overriding the display methods.  You didn't mention setting
>
> up a preference, did you do that or are you assuming everyone in the fa_IR
> locale will want to use your Jalali calendar?
>
> yes I add a setting in preference.
>
> >Not that comes to mind, and besides anything more hackish isn't likely to
>
> get merged.
>
> Noted !
>
> Is it true I flow the implementation of * gnucash-date-picker* and change
> to Jalalian Calender ?
>
> Regards
> Amin
>
> On Tue, Nov 1, 2016 at 11:54 AM, John Ralls <[hidden email]> wrote:
> > > On Oct 31, 2016, at 8:27 PM, Amin Aghabeiki <[hidden email]>
> >
> > wrote:
> > > I use Mask instead of Override because I just show Jalalian Date to user
> >
> > and rest of back-end function ( event current Gregorian Date-Picker ) work
> > with Gregorian Date ( when user select an date in Gregorian Date-Picker
> > automatically convert to Jalalian Date in cell ) . may be in technical the
> > Override is true word for this kind of  implementation.
> >
> > Right, you're overriding the display methods.  You didn't mention setting
> > up a preference, did you do that or are you assuming everyone in the fa_IR
> > locale will want to use your Jalali calendar?
> >
> > > About date picker , there is not any easier way ?
> >
> > Not that comes to mind, and besides anything more hackish isn't likely to
> > get merged.
> >
> > Regards,
> > John Ralls
>
> _______________________________________________
> gnucash-devel mailing list
> [hidden email]
> https://lists.gnucash.org/mailman/listinfo/gnucash-devel

_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

RotenVorest
Dear Christian

My change is not complete till now ( tests and DatePicker are not complete
), when it will be ready I'll push in a  fork and Note Here.

Thanks & Regards
Amin

On Thu, Nov 3, 2016 at 5:18 AM, Christian Stimming <[hidden email]>
wrote:

> Dear Amin,
>
> can you put your current code online somewhere, such as in some github
> fork? I
> would be interested to see which parts of gnucash you actually changed.
> Maybe
> in "our world-view" the change seems too incomplete, but if you say your
> change would already be an improvement for users with Jalali calendar, we
> might consider this again. But we would have to see your code for that.
>
> Thanks!
>
> Christian
>
>
> Am Dienstag, 1. November 2016, 12:49:40 schrieb Amin Aghabeiki:
> > > Right, you're overriding the display methods.  You didn't mention
> setting
> >
> > up a preference, did you do that or are you assuming everyone in the
> fa_IR
> > locale will want to use your Jalali calendar?
> >
> > yes I add a setting in preference.
> >
> > >Not that comes to mind, and besides anything more hackish isn't likely
> to
> >
> > get merged.
> >
> > Noted !
> >
> > Is it true I flow the implementation of * gnucash-date-picker* and change
> > to Jalalian Calender ?
> >
> > Regards
> > Amin
> >
> > On Tue, Nov 1, 2016 at 11:54 AM, John Ralls <[hidden email]> wrote:
> > > > On Oct 31, 2016, at 8:27 PM, Amin Aghabeiki <
> [hidden email]>
> > >
> > > wrote:
> > > > I use Mask instead of Override because I just show Jalalian Date to
> user
> > >
> > > and rest of back-end function ( event current Gregorian Date-Picker )
> work
> > > with Gregorian Date ( when user select an date in Gregorian Date-Picker
> > > automatically convert to Jalalian Date in cell ) . may be in technical
> the
> > > Override is true word for this kind of  implementation.
> > >
> > > Right, you're overriding the display methods.  You didn't mention
> setting
> > > up a preference, did you do that or are you assuming everyone in the
> fa_IR
> > > locale will want to use your Jalali calendar?
> > >
> > > > About date picker , there is not any easier way ?
> > >
> > > Not that comes to mind, and besides anything more hackish isn't likely
> to
> > > get merged.
> > >
> > > Regards,
> > > John Ralls
> >
> > _______________________________________________
> > gnucash-devel mailing list
> > [hidden email]
> > https://lists.gnucash.org/mailman/listinfo/gnucash-devel
>
>
_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

RotenVorest
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?

Regards
Amin


On Thu, Nov 3, 2016 at 9:53 AM, Amin Aghabeiki <[hidden email]>
wrote:

> Dear Christian
>
> My change is not complete till now ( tests and DatePicker are not complete
> ), when it will be ready I'll push in a  fork and Note Here.
>
> Thanks & Regards
> Amin
>
> On Thu, Nov 3, 2016 at 5:18 AM, Christian Stimming <[hidden email]
> > wrote:
>
>> Dear Amin,
>>
>> can you put your current code online somewhere, such as in some github
>> fork? I
>> would be interested to see which parts of gnucash you actually changed.
>> Maybe
>> in "our world-view" the change seems too incomplete, but if you say your
>> change would already be an improvement for users with Jalali calendar, we
>> might consider this again. But we would have to see your code for that.
>>
>> Thanks!
>>
>> Christian
>>
>>
>> Am Dienstag, 1. November 2016, 12:49:40 schrieb Amin Aghabeiki:
>> > > Right, you're overriding the display methods.  You didn't mention
>> setting
>> >
>> > up a preference, did you do that or are you assuming everyone in the
>> fa_IR
>> > locale will want to use your Jalali calendar?
>> >
>> > yes I add a setting in preference.
>> >
>> > >Not that comes to mind, and besides anything more hackish isn't likely
>> to
>> >
>> > get merged.
>> >
>> > Noted !
>> >
>> > Is it true I flow the implementation of * gnucash-date-picker* and
>> change
>> > to Jalalian Calender ?
>> >
>> > Regards
>> > Amin
>> >
>> > On Tue, Nov 1, 2016 at 11:54 AM, John Ralls <[hidden email]> wrote:
>> > > > On Oct 31, 2016, at 8:27 PM, Amin Aghabeiki <
>> [hidden email]>
>> > >
>> > > wrote:
>> > > > I use Mask instead of Override because I just show Jalalian Date to
>> user
>> > >
>> > > and rest of back-end function ( event current Gregorian Date-Picker )
>> work
>> > > with Gregorian Date ( when user select an date in Gregorian
>> Date-Picker
>> > > automatically convert to Jalalian Date in cell ) . may be in
>> technical the
>> > > Override is true word for this kind of  implementation.
>> > >
>> > > Right, you're overriding the display methods.  You didn't mention
>> setting
>> > > up a preference, did you do that or are you assuming everyone in the
>> fa_IR
>> > > locale will want to use your Jalali calendar?
>> > >
>> > > > About date picker , there is not any easier way ?
>> > >
>> > > Not that comes to mind, and besides anything more hackish isn't
>> likely to
>> > > get merged.
>> > >
>> > > Regards,
>> > > John Ralls
>> >
>> > _______________________________________________
>> > gnucash-devel mailing list
>> > [hidden email]
>> > https://lists.gnucash.org/mailman/listinfo/gnucash-devel
>>
>>
>
_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

John Ralls-2

> On Nov 3, 2016, at 8:39 PM, Amin Aghabeiki <[hidden email]> 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?
>

Amin,

No, I've never worked with the preferences dialog. Perhaps Geert can offer some help.

Regards,
John Ralls


_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

Geert Janssens-4
On Friday 04 November 2016 08:08:46 John Ralls wrote:
> > On Nov 3, 2016, at 8:39 PM, Amin Aghabeiki
> > <[hidden email]> 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 ?

Regards,

Geert
_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

John Ralls-2

> On Nov 5, 2016, at 6:09 AM, Geert Janssens <[hidden email]> wrote:
>
> On Friday 04 November 2016 08:08:46 John Ralls wrote:
> > > On Nov 3, 2016, at 8:39 PM, Amin Aghabeiki
> > > <[hidden email] <mailto:[hidden email]>> 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
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

John Ralls-2

> On Nov 6, 2016, at 6:23 PM, Amin Aghabeiki <[hidden email]> 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 <[hidden email]> wrote:
>>
>>> On Nov 5, 2016, at 6:09 AM, Geert Janssens <[hidden email]>
>>> wrote:
>>>
>>> On Friday 04 November 2016 08:08:46 John Ralls wrote:
>>>>> On Nov 3, 2016, at 8:39 PM, Amin Aghabeiki
>>>>> <[hidden email] <mailto:[hidden email]>> 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
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

RotenVorest
In reply to this post by Christian Stimming-4
Hi Christian

A copy of my code now available  here
<https://github.com/RaianRaika/gnucash/tree/jalali> , a fork of GnuCash
under my account in Jalali branch.

Date Picker not implimented
you can switch between Gregorian and Jalali in preference  date/time
setting

Regards
Amin




On Thu, Nov 3, 2016 at 5:18 AM, Christian Stimming <[hidden email]>
wrote:

> Dear Amin,
>
> can you put your current code online somewhere, such as in some github
> fork? I
> would be interested to see which parts of gnucash you actually changed.
> Maybe
> in "our world-view" the change seems too incomplete, but if you say your
> change would already be an improvement for users with Jalali calendar, we
> might consider this again. But we would have to see your code for that.
>
> Thanks!
>
> Christian
>
>
> Am Dienstag, 1. November 2016, 12:49:40 schrieb Amin Aghabeiki:
> > > Right, you're overriding the display methods.  You didn't mention
> setting
> >
> > up a preference, did you do that or are you assuming everyone in the
> fa_IR
> > locale will want to use your Jalali calendar?
> >
> > yes I add a setting in preference.
> >
> > >Not that comes to mind, and besides anything more hackish isn't likely
> to
> >
> > get merged.
> >
> > Noted !
> >
> > Is it true I flow the implementation of * gnucash-date-picker* and change
> > to Jalalian Calender ?
> >
> > Regards
> > Amin
> >
> > On Tue, Nov 1, 2016 at 11:54 AM, John Ralls <[hidden email]> wrote:
> > > > On Oct 31, 2016, at 8:27 PM, Amin Aghabeiki <
> [hidden email]>
> > >
> > > wrote:
> > > > I use Mask instead of Override because I just show Jalalian Date to
> user
> > >
> > > and rest of back-end function ( event current Gregorian Date-Picker )
> work
> > > with Gregorian Date ( when user select an date in Gregorian Date-Picker
> > > automatically convert to Jalalian Date in cell ) . may be in technical
> the
> > > Override is true word for this kind of  implementation.
> > >
> > > Right, you're overriding the display methods.  You didn't mention
> setting
> > > up a preference, did you do that or are you assuming everyone in the
> fa_IR
> > > locale will want to use your Jalali calendar?
> > >
> > > > About date picker , there is not any easier way ?
> > >
> > > Not that comes to mind, and besides anything more hackish isn't likely
> to
> > > get merged.
> > >
> > > Regards,
> > > John Ralls
> >
> > _______________________________________________
> > gnucash-devel mailing list
> > [hidden email]
> > https://lists.gnucash.org/mailman/listinfo/gnucash-devel
>
>
_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

Geert Janssens-4
In reply to this post by John Ralls-2
On Saturday 05 November 2016 19:46:10 John Ralls wrote:
>
> That would be an excellent wiki article...
>
Thanks and a good idea. I have added it [1] under the
Development category [2]. Any suggestions for other pages I
should add a reference to this new page to ?

Geert

[1] http://wiki.gnucash.org/wiki/How_to_add_a_new_preference
[2] http://wiki.gnucash.org/wiki/Category:Development
_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

John Ralls-2

> On Nov 8, 2016, at 5:46 AM, Geert Janssens <[hidden email]> wrote:
>
> On Saturday 05 November 2016 19:46:10 John Ralls wrote:
> >
> > That would be an excellent wiki article...
> >
> Thanks and a good idea. I have added it [1] under the Development category [2]. Any suggestions for other pages I should add a reference to this new page to ?

No, I can't think of any right now.

Regards,
John Ralls

_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

RotenVorest
Hi Everyone

Flow of my Change to add support for new Calendar in Gnu-Cash , I need to
know how Date Picker that used in Preferences work , any one can help me to
find a start point ?

Regards
Amin
_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

John Ralls-2

> On Nov 21, 2016, at 1:37 AM, Amin Aghabeiki <[hidden email]> wrote:
>
> Hi Everyone
>
> Flow of my Change to add support for new Calendar in Gnu-Cash , I need to
> know how Date Picker that used in Preferences work , any one can help me to
> find a start point ?

Amin,

It's a GNCDateEdit and the code is in src/gnome-utils/gnc-date-edit.c.

Regards,
John Ralls


_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

RotenVorest
Hi Everyone

I make a lots of  change on  GtkCalendar , the change is in this way :

1- I replace GtkCalendar with a  new GObject ( GTK like Calendar) ( all the
external function is like GtkCalendar )
2- separate all the calendar base function ( some function that do
calculation for week month and etc ) , and create a class like interface
with separated implantation for Gregorian / Jalalian ( and its also
possible to be  implement in different calendar logic )
3- replace the most part that use GtkCalendar and use now gnucash-calendar

note : all the implementation/Change is in C not CPP ( so its just a struct
not a class interface)

ok now  the question :D

1- is it posible to merge my change ( I remove GTK Calendar - and add my
onwn calendar )?
2- if answer of first question is false ,please guide me what should I do ?
3- which place use GtkCalendar ( except of Gnc-date-picker - gnc date-edit
) to replace my own Gnucash-calendar ) ?


PS1 : I add a path of my change that has GnuCash-Calendar at this e-mail .
PS2 : the code is not last
PS3 : it just compile with CMAKE and make not work ( I did not have time
yet to find the reason )

at the end , sorry again for my bad english ;-)

Regards
Amin




On Mon, Nov 21, 2016 at 11:05 PM, John Ralls <[hidden email]> wrote:

>
> > On Nov 21, 2016, at 1:37 AM, Amin Aghabeiki <[hidden email]>
> wrote:
> >
> > Hi Everyone
> >
> > Flow of my Change to add support for new Calendar in Gnu-Cash , I need to
> > know how Date Picker that used in Preferences work , any one can help me
> to
> > find a start point ?
>
> Amin,
>
> It's a GNCDateEdit and the code is in src/gnome-utils/gnc-date-edit.c.
>
> Regards,
> John Ralls
>
>

_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Jalalian_Calendar___add_Jalalian_Calendar_to_GnuCash___use_preference_date_time_setting_to.patch (319K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: New Masked Calender for GnuCash

John Ralls-2

> On Nov 22, 2016, at 4:28 AM, Amin Aghabeiki <[hidden email]> wrote:
>
> Hi Everyone
>
> I make a lots of  change on  GtkCalendar , the change is in this way :
>
> 1- I replace GtkCalendar with a  new GObject ( GTK like Calendar) ( all the
> external function is like GtkCalendar )
> 2- separate all the calendar base function ( some function that do
> calculation for week month and etc ) , and create a class like interface
> with separated implantation for Gregorian / Jalalian ( and its also
> possible to be  implement in different calendar logic )
> 3- replace the most part that use GtkCalendar and use now gnucash-calendar
>
> note : all the implementation/Change is in C not CPP ( so its just a struct
> not a class interface)
>
> ok now  the question :D
>
> 1- is it posible to merge my change ( I remove GTK Calendar - and add my
> onwn calendar )?
> 2- if answer of first question is false ,please guide me what should I do ?
> 3- which place use GtkCalendar ( except of Gnc-date-picker - gnc date-edit
> ) to replace my own Gnucash-calendar ) ?
>
>
> PS1 : I add a path of my change that has GnuCash-Calendar at this e-mail .
> PS2 : the code is not last
> PS3 : it just compile with CMAKE and make not work ( I did not have time
> yet to find the reason )
>
> at the end , sorry again for my bad english ;-)

Amin,

It looks like your patch is backwards; your changes seem to be the --- set and the original code the +++ set. It's a pretty big change, so for an easier review process please do it as a Github pull request. As you work on creating it there are some required big-picture changes:
* gnc-jalali.[ch] need to move to libqof/qof. libqof compiles first so it mustn't have dependencies in other directories.
* Don't use 'qof' as a prefix for any new functions, variables, or constants, use 'gnc'. 'QOF' refers to a co-developed project, the Query Object Framework, that we're gradually replacing as we migrate to a true database application.
* Don't comment out code that you don't want to use, remove it. Git makes it easy to bring back anything that been removed and it's much easier to see removed blocks than commented out ones when reviewing a change.
* Provide Doxygen comments on all new functions. Doxygen comments should include at least a brief description of the function's purpose as well as the parameters and return type.
* Provide unit tests on all new or changed functions, using Google Test, also known as gtest, as the testing framework.
* Use multiple commits to implement changes, explaining in each commit message what that commit does to move the project forward.  Use at least two commits  for GtkCalendar, the first to copy in the existing code and a second with your changes.
* GtkCalendar should go in gnome-utils, not register.
* New files *must* have the FSF license blurb at the top including a proper copyright statement: "Copyright 2016 Amin Aghabiki <[hidden email] <mailto:[hidden email]>>"
* The way you decomposed the selection of gregorian/jalali in gnc-date.cpp is ugly. For example, instead of having a separate public function GncDate::format_masked for non-gregorian calendars and splattering if/else clauses all over the code, do the branch once in GncDate::format, or better yet subclass GncDate with GncDateJalali and construct the appropriate one based on the preference. Even better, convert GncDate to a template on GncCalendarType and save the vtable indirection. There should be no need to change the C API at all.
* Following up on that, you've created a lot of functions that are copy-pastes of existing functions with a line or two changed. That's poor practice. Extract the common code to a new static function that you call from each of the specializations if you must, but first think about whether the difference would be better handled at a lower abstraction level.

Regards,
John Ralls


_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel