diff --git a/src/backend/file/gnc-freqspec-xml-v2.c b/src/backend/file/gnc-freqspec-xml-v2.c
index 7d470ec946..ec831d0f8e 100644
--- a/src/backend/file/gnc-freqspec-xml-v2.c
+++ b/src/backend/file/gnc-freqspec-xml-v2.c
@@ -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 },
};
diff --git a/src/backend/file/gnc-recurrence-xml-v2.c b/src/backend/file/gnc-recurrence-xml-v2.c
index c004a7e694..dce602d2a1 100644
--- a/src/backend/file/gnc-recurrence-xml-v2.c
+++ b/src/backend/file/gnc-recurrence-xml-v2.c
@@ -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;
}
diff --git a/src/gnome-utils/gnc-frequency.c b/src/gnome-utils/gnc-frequency.c
index 28278add1a..960dfd4702 100644
--- a/src/gnome-utils/gnc-frequency.c
+++ b/src/gnome-utils/gnc-frequency.c
@@ -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)
diff --git a/src/gnome/glade/sched-xact.glade b/src/gnome/glade/sched-xact.glade
index ee6805248d..3c3701e670 100644
--- a/src/gnome/glade/sched-xact.glade
+++ b/src/gnome/glade/sched-xact.glade
@@ -1892,6 +1892,47 @@ Last Sunday
True
+
+
+
+ True
+ except on weekends:
+ False
+ False
+ GTK_JUSTIFY_RIGHT
+ False
+ False
+ 1
+ 0.5
+ 0
+ 0
+ PANGO_ELLIPSIZE_NONE
+ -1
+ False
+ 0
+
+
+ 2
+ False
+ True
+
+
+
+
+
+ True
+ No change
+Use previous weekday
+Use next weekday
+ False
+ True
+
+
+ 0
+ False
+ False
+
+
3
@@ -1982,6 +2023,47 @@ Last Sunday
False
+
+
+
+ True
+ except on weekends:
+ False
+ False
+ GTK_JUSTIFY_RIGHT
+ False
+ False
+ 1
+ 0.5
+ 0
+ 0
+ PANGO_ELLIPSIZE_NONE
+ -1
+ False
+ 0
+
+
+ 2
+ False
+ True
+
+
+
+
+
+ True
+ No change
+Use previous weekday
+Use next weekday
+ False
+ True
+
+
+ 0
+ False
+ False
+
+
3
@@ -2202,16 +2284,57 @@ Last Sunday
False
+
+
+
+ True
+ except on weekends:
+ False
+ False
+ GTK_JUSTIFY_RIGHT
+ False
+ False
+ 1
+ 0.5
+ 0
+ 0
+ PANGO_ELLIPSIZE_NONE
+ -1
+ False
+ 0
+
+
+ 2
+ False
+ True
+
+
+
+
+
+ True
+ No change
+Use previous weekday
+Use next weekday
+ False
+ True
+
+
+ 0
+ False
+ False
+
+
- 5
+ 3
False
True
- 5
+ 3
True
True