mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Revert r17730 and re-apply r17725, "Bug #106401: Add SX weekend occurence to be shifted to weekdays"
This time, the XML element handler for the "weekend adjustment" is optional so that old files without that element are read without error. Patch (well, kind of) by Simon Arlott. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17751 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
9301a8cd9c
commit
5c25bb7557
@ -243,6 +243,20 @@ fs_occurrence_handler( xmlNodePtr node, gpointer data )
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static
|
||||
gboolean
|
||||
fs_weekend_adj_handler( xmlNodePtr node, gpointer data )
|
||||
{
|
||||
fsParseData *fspd = data;
|
||||
gboolean ret;
|
||||
gint64 foo;
|
||||
ret = dom_tree_to_integer( node, &foo );
|
||||
if ( !ret )
|
||||
return ret;
|
||||
fspd->weekend_adj = foo;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static
|
||||
gboolean
|
||||
fs_subelement_handler( xmlNodePtr node, gpointer data )
|
||||
@ -273,13 +287,14 @@ fs_subelement_handler( xmlNodePtr node, gpointer data )
|
||||
}
|
||||
|
||||
struct dom_tree_handler fs_union_dom_handlers[] = {
|
||||
{ "fs:date", fs_date_handler, 0, 0 },
|
||||
{ "fs:interval", fs_interval_handler, 0, 0 },
|
||||
{ "fs:offset", fs_offset_handler, 0, 0 },
|
||||
{ "fs:day", fs_day_handler, 0, 0 },
|
||||
{ "fs:weekday", fs_weekday_handler, 0, 0 },
|
||||
{ "fs:occurrence", fs_occurrence_handler, 0, 0 },
|
||||
{ "gnc:freqspec", fs_subelement_handler, 0, 0 },
|
||||
{ "fs:date", fs_date_handler, 0, 0 },
|
||||
{ "fs:interval", fs_interval_handler, 0, 0 },
|
||||
{ "fs:offset", fs_offset_handler, 0, 0 },
|
||||
{ "fs:day", fs_day_handler, 0, 0 },
|
||||
{ "fs:weekday", fs_weekday_handler, 0, 0 },
|
||||
{ "fs:occurrence", fs_occurrence_handler, 0, 0 },
|
||||
{ "fs:weekend_adj", fs_weekend_adj_handler, 0, 0 },
|
||||
{ "gnc:freqspec", fs_subelement_handler, 0, 0 },
|
||||
{ NULL, NULL, 0, 0 },
|
||||
};
|
||||
|
||||
|
@ -47,6 +47,7 @@ const gchar *recurrence_version_string = "1.0.0";
|
||||
#define recurrence_mult "recurrence:mult"
|
||||
#define recurrence_period_type "recurrence:period_type"
|
||||
#define recurrence_start "recurrence:start"
|
||||
#define recurrence_weekend_adj "recurrence:weekend_adj"
|
||||
|
||||
//TODO: I think three of these functions rightly belong in Recurrence.c.
|
||||
|
||||
@ -83,10 +84,25 @@ recurrence_mult_handler(xmlNodePtr node, gpointer r)
|
||||
return dom_tree_to_guint16(node, &((Recurrence *)r)->mult);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
recurrence_weekend_adj_handler(xmlNodePtr node, gpointer d)
|
||||
{
|
||||
WeekendAdjust wadj;
|
||||
char *nodeTxt;
|
||||
|
||||
nodeTxt = dom_tree_to_text(node);
|
||||
g_return_val_if_fail(nodeTxt, FALSE);
|
||||
wadj= recurrenceWeekendAdjustFromString(nodeTxt);
|
||||
((Recurrence *) d)->wadj = wadj;
|
||||
g_free(nodeTxt);
|
||||
return (wadj != -1);
|
||||
}
|
||||
|
||||
static struct dom_tree_handler recurrence_dom_handlers[] = {
|
||||
{ recurrence_mult, recurrence_mult_handler, 1, 0 },
|
||||
{ recurrence_period_type, recurrence_period_type_handler, 1, 0 },
|
||||
{ recurrence_start, recurrence_start_date_handler, 1, 0 },
|
||||
{ recurrence_weekend_adj, recurrence_weekend_adj_handler, 0, 0 },
|
||||
{ NULL, NULL, 0, 0 }
|
||||
};
|
||||
|
||||
@ -113,6 +129,7 @@ recurrence_to_dom_tree(const gchar *tag, const Recurrence *r)
|
||||
xmlNodePtr n;
|
||||
PeriodType pt;
|
||||
GDate d;
|
||||
WeekendAdjust wadj;
|
||||
|
||||
n = xmlNewNode(NULL, tag);
|
||||
xmlSetProp(n, "version", recurrence_version_string );
|
||||
@ -123,5 +140,8 @@ recurrence_to_dom_tree(const gchar *tag, const Recurrence *r)
|
||||
recurrencePeriodTypeToString(pt)));
|
||||
d = recurrenceGetDate(r);
|
||||
xmlAddChild(n, gdate_to_dom_tree(recurrence_start, &d));
|
||||
wadj = recurrenceGetWeekendAdjust(r);
|
||||
xmlAddChild(n, text_to_dom_tree(recurrence_weekend_adj,
|
||||
recurrenceWeekendAdjustToString(wadj)));
|
||||
return n;
|
||||
}
|
||||
|
@ -412,8 +412,12 @@ gnc_frequency_setup(GncFrequency *gf, GList *recurrences, GDate *start_date)
|
||||
|
||||
dom_combobox = glade_xml_get_widget(gf->gxml, "semimonthly_first");
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(dom_combobox), _get_monthly_combobox_index(first));
|
||||
dom_combobox = glade_xml_get_widget(gf->gxml, "semimonthly_first_weekend");
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(dom_combobox), recurrenceGetWeekendAdjust(first));
|
||||
dom_combobox = glade_xml_get_widget(gf->gxml, "semimonthly_second");
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(dom_combobox), _get_monthly_combobox_index(second));
|
||||
dom_combobox = glade_xml_get_widget(gf->gxml, "semimonthly_second_weekend");
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(dom_combobox), recurrenceGetWeekendAdjust(second));
|
||||
|
||||
gtk_notebook_set_current_page(gf->nb, PAGE_SEMI_MONTHLY);
|
||||
gtk_combo_box_set_active(gf->freqComboBox, PAGE_SEMI_MONTHLY);
|
||||
@ -464,7 +468,7 @@ gnc_frequency_setup(GncFrequency *gf, GList *recurrences, GDate *start_date)
|
||||
case PERIOD_YEAR:
|
||||
case PERIOD_LAST_WEEKDAY: {
|
||||
guint multiplier;
|
||||
GtkWidget *multipler_spin, *day_of_month;
|
||||
GtkWidget *multipler_spin, *day_of_month, *weekend_mode;
|
||||
|
||||
multipler_spin = glade_xml_get_widget(gf->gxml, "monthly_spin");
|
||||
multiplier = recurrenceGetMultiplier(r);
|
||||
@ -474,6 +478,8 @@ gnc_frequency_setup(GncFrequency *gf, GList *recurrences, GDate *start_date)
|
||||
|
||||
day_of_month = glade_xml_get_widget(gf->gxml, "monthly_day");
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(day_of_month), _get_monthly_combobox_index(r));
|
||||
weekend_mode = glade_xml_get_widget(gf->gxml, "monthly_weekend");
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(weekend_mode), recurrenceGetWeekendAdjust(r));
|
||||
|
||||
gtk_notebook_set_current_page(gf->nb, PAGE_MONTHLY);
|
||||
gtk_combo_box_set_active(gf->freqComboBox, PAGE_MONTHLY);
|
||||
@ -507,7 +513,8 @@ _get_day_of_month_recurrence(GncFrequency *gf, GDate *start_date, int multiplier
|
||||
Recurrence *r;
|
||||
GtkWidget *day_of_month_combo = glade_xml_get_widget(gf->gxml, combo_name);
|
||||
int day_of_month_index = gtk_combo_box_get_active(GTK_COMBO_BOX(day_of_month_combo));
|
||||
int weekend_adjust = WEEKEND_ADJ_NONE;
|
||||
GtkWidget *weekend_adjust_combo = glade_xml_get_widget(gf->gxml, combo_weekend_name);
|
||||
int weekend_adjust = gtk_combo_box_get_active(GTK_COMBO_BOX(weekend_adjust_combo));
|
||||
|
||||
r = g_new0(Recurrence, 1);
|
||||
if (day_of_month_index > LAST_DAY_OF_MONTH_OPTION_INDEX)
|
||||
|
@ -1892,6 +1892,47 @@ Last Sunday</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label847751">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">except on weekends:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_RIGHT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">2</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="semimonthly_first_weekend">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">No change
|
||||
Use previous weekday
|
||||
Use next weekday</property>
|
||||
<property name="add_tearoffs">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">3</property>
|
||||
@ -1982,6 +2023,47 @@ Last Sunday</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label847752">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">except on weekends:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_RIGHT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">2</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="semimonthly_second_weekend">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">No change
|
||||
Use previous weekday
|
||||
Use next weekday</property>
|
||||
<property name="add_tearoffs">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">3</property>
|
||||
@ -2202,16 +2284,57 @@ Last Sunday</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label847750">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">except on weekends:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_RIGHT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">2</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="monthly_weekend">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">No change
|
||||
Use previous weekday
|
||||
Use next weekday</property>
|
||||
<property name="add_tearoffs">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="padding">3</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">5</property>
|
||||
<property name="padding">3</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
|
Loading…
Reference in New Issue
Block a user