Author: juha Date: 2006-08-27 19:04:35 +0000 (Sun, 27 Aug 2006) New Revision: 22906
Modified: xfcalendar/trunk/src/appointment.c xfcalendar/trunk/src/appointment.h xfcalendar/trunk/src/event-list.c xfcalendar/trunk/src/ical-code.c xfcalendar/trunk/src/ical-code.h Log: Added complex recurring. Now it is possible to recur based on weekday and interval. Modified: xfcalendar/trunk/src/appointment.c =================================================================== --- xfcalendar/trunk/src/appointment.c 2006-08-27 14:15:30 UTC (rev 22905) +++ xfcalendar/trunk/src/appointment.c 2006-08-27 19:04:35 UTC (rev 22906) @@ -211,7 +211,7 @@ void set_repeat_sensitivity(appt_win *apptw) { - gint freq; + gint freq, i; freq = gtk_combo_box_get_active((GtkComboBox *)apptw->appRecur_freq_cb); if (freq == XFICAL_FREQ_NONE) { @@ -221,6 +221,13 @@ gtk_widget_set_sensitive(apptw->appRecur_count_label, FALSE); gtk_widget_set_sensitive(apptw->appRecur_until_rb, FALSE); gtk_widget_set_sensitive(apptw->appRecur_until_button, FALSE); + for (i=0; i <= 6; i++) { + gtk_widget_set_sensitive(apptw->appRecur_byday_cb[i], FALSE); + gtk_widget_set_sensitive(apptw->appRecur_byday_spin[i], FALSE); + } + gtk_widget_set_sensitive(apptw->appRecur_int_spin, FALSE); + gtk_widget_set_sensitive(apptw->appRecur_int_spin_label1, FALSE); + gtk_widget_set_sensitive(apptw->appRecur_int_spin_label2, FALSE); } else { gtk_widget_set_sensitive(apptw->appRecur_limit_rb, TRUE); @@ -236,12 +243,28 @@ } gtk_widget_set_sensitive(apptw->appRecur_until_rb, TRUE); if (gtk_toggle_button_get_active( - GTK_TOGGLE_BUTTON(apptw->appRecur_until_rb))) { + GTK_TOGGLE_BUTTON(apptw->appRecur_until_rb))) { gtk_widget_set_sensitive(apptw->appRecur_until_button, TRUE); } else { gtk_widget_set_sensitive(apptw->appRecur_until_button, FALSE); } + for (i=0; i <= 6; i++) { + gtk_widget_set_sensitive(apptw->appRecur_byday_cb[i], TRUE); + } + if (freq == XFICAL_FREQ_MONTHLY || freq == XFICAL_FREQ_YEARLY) { + for (i=0; i <= 6; i++) { + gtk_widget_set_sensitive(apptw->appRecur_byday_spin[i], TRUE); + } + } + else { + for (i=0; i <= 6; i++) { + gtk_widget_set_sensitive(apptw->appRecur_byday_spin[i], FALSE); + } + } + gtk_widget_set_sensitive(apptw->appRecur_int_spin, TRUE); + gtk_widget_set_sensitive(apptw->appRecur_int_spin_label1, TRUE); + gtk_widget_set_sensitive(apptw->appRecur_int_spin_label2, TRUE); } } @@ -282,6 +305,32 @@ } void +app_recur_feature_checkbutton_clicked_cb(GtkCheckButton *checkbutton + , gpointer user_data) +{ + appt_win *apptw=(appt_win *)user_data; + + mark_appointment_changed((appt_win *)user_data); + if (gtk_toggle_button_get_active( + GTK_TOGGLE_BUTTON(apptw->appRecur_feature_normal_rb))) { + gtk_widget_hide(apptw->appRecur_int_label); + gtk_widget_hide(apptw->appRecur_int_hbox); + gtk_widget_hide(apptw->appRecur_byday_label); + gtk_widget_hide(apptw->appRecur_byday_hbox); + gtk_widget_hide(apptw->appRecur_byday_spin_label); + gtk_widget_hide(apptw->appRecur_byday_spin_hbox); + } + else { + gtk_widget_show(apptw->appRecur_int_label); + gtk_widget_show(apptw->appRecur_int_hbox); + gtk_widget_show(apptw->appRecur_byday_label); + gtk_widget_show(apptw->appRecur_byday_hbox); + gtk_widget_show(apptw->appRecur_byday_spin_label); + gtk_widget_show(apptw->appRecur_byday_spin_hbox); + } +} + +void app_checkbutton_clicked_cb(GtkCheckButton *checkbutton, gpointer user_data) { mark_appointment_changed((appt_win *)user_data); @@ -447,6 +496,7 @@ const char *time_format="%H:%M"; struct tm current_t; gchar starttime[6], endtime[6]; + gint i; /*Get the title */ appt->title = g_strdup(gtk_entry_get_text( @@ -534,6 +584,10 @@ appt->freq = gtk_combo_box_get_active( (GtkComboBox *)apptw->appRecur_freq_cb); + /* Get the recurrence interval */ + appt->interval = gtk_spin_button_get_value_as_int( + GTK_SPIN_BUTTON(apptw->appRecur_int_spin)); + /* Get the recurrence ending */ if (gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(apptw->appRecur_limit_rb))) { @@ -562,6 +616,15 @@ else g_warning("fill_appt_from_apptw: coding error, illegal recurrence"); + /* Get the recurrence weekdays */ + for (i=0; i <= 6; i++) { + appt->recur_byday[i] = gtk_toggle_button_get_active( + GTK_TOGGLE_BUTTON(apptw->appRecur_byday_cb[i])); + /* Get the recurrence weekday selection for month/yearly case */ + appt->recur_byday_cnt[i] = gtk_spin_button_get_value_as_int( + GTK_SPIN_BUTTON(apptw->appRecur_byday_spin[i])); + } + return(TRUE); } @@ -1095,6 +1158,7 @@ appt_data *appt; struct tm *t; char *untildate_to_display; + int i; g_message("%s appointment: %s", action, par); if ((appt = fill_appt_window_get_appt(action, par)) == NULL) { @@ -1220,6 +1284,33 @@ appt->recur_limit); } + /* weekdays */ + for (i=0; i <= 6; i++) { + gtk_toggle_button_set_active( + GTK_TOGGLE_BUTTON(apptw->appRecur_byday_cb[i]) + , appt->recur_byday[i]); + /* which weekday of month / year */ + gtk_spin_button_set_value( + GTK_SPIN_BUTTON(apptw->appRecur_byday_spin[i]) + , (gdouble)appt->recur_byday_cnt[i]); + } + + /* interval */ + gtk_spin_button_set_value( + GTK_SPIN_BUTTON(apptw->appRecur_int_spin) + , (gdouble)appt->interval); + + if (appt->interval > 1 + || !appt->recur_byday[0] || !appt->recur_byday[1] || !appt->recur_byday[2] + || !appt->recur_byday[3] || !appt->recur_byday[4] || !appt->recur_byday[5] + || !appt->recur_byday[6]) { + gtk_toggle_button_set_active( + GTK_TOGGLE_BUTTON(apptw->appRecur_feature_advanced_rb), TRUE); + } + else { + gtk_toggle_button_set_active( + GTK_TOGGLE_BUTTON(apptw->appRecur_feature_normal_rb), TRUE); + } xfical_appt_free(appt); set_time_sensitivity(apptw); @@ -1522,9 +1613,11 @@ void create_appt_win_tab_recurrence(appt_win *apptw) { - gint row=1; + gint row=1, i; char *recur_freq_array[RECUR_ARRAY_DIM] = { - _("None"), _("Daily"), _("Weekly"), _("Monthly"), _("Yearly")}; + _("None"), _("Daily"), _("Weekly"), _("Monthly"), _("Yearly")}; + char *weekday_array[7] = { + _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun")}; apptw->appTableRecur = xfcalendar_table_new(8, 2); apptw->appRecur_notebook_page = @@ -1534,6 +1627,28 @@ gtk_notebook_append_page(GTK_NOTEBOOK(apptw->appNotebook) , apptw->appRecur_notebook_page, apptw->appRecur_tab_label); + apptw->appRecur_feature_label = gtk_label_new(_("Complexity")); + apptw->appRecur_feature_hbox = gtk_hbox_new(FALSE, 0); + apptw->appRecur_feature_normal_rb = gtk_radio_button_new_with_label(NULL + , _("Basic")); + gtk_box_pack_start(GTK_BOX(apptw->appRecur_feature_hbox) + , apptw->appRecur_feature_normal_rb, FALSE, FALSE, 15); + apptw->appRecur_feature_advanced_rb = + gtk_radio_button_new_with_mnemonic_from_widget( + GTK_RADIO_BUTTON(apptw->appRecur_feature_normal_rb) + , _("Advanced")); + gtk_box_pack_start(GTK_BOX(apptw->appRecur_feature_hbox) + , apptw->appRecur_feature_advanced_rb, FALSE, FALSE, 15); + xfcalendar_table_add_row(apptw->appTableRecur + , apptw->appRecur_feature_label, apptw->appRecur_feature_hbox, row++ + , (GtkAttachOptions) (GTK_EXPAND | GTK_FILL) + , (GtkAttachOptions) (0)); + gtk_tooltips_set_tip(apptw->appTooltips, apptw->appRecur_feature_normal_rb + , _("Use this is you want regular repeating event"), NULL); + gtk_tooltips_set_tip(apptw->appTooltips, apptw->appRecur_feature_advanced_rb + , _("Use this if you need complex times like:\n Every second week or \n Every Saturday and Sunday or \n First Tuesday every month") + , NULL); + apptw->appRecur_freq_label = gtk_label_new(_("Recurrence")); apptw->appRecur_freq_cb = gtk_combo_box_new_text(); xfcalendar_combo_box_append_array(apptw->appRecur_freq_cb @@ -1543,7 +1658,27 @@ , (GtkAttachOptions) (GTK_EXPAND | GTK_FILL) , (GtkAttachOptions) (GTK_FILL)); - apptw->appRecur_limit_label = gtk_label_new(""/* _("Limit") */); + apptw->appRecur_int_label = gtk_label_new(_("Interval")); + apptw->appRecur_int_hbox = gtk_hbox_new(FALSE, 0); + apptw->appRecur_int_spin_label1 = gtk_label_new(_("Each")); + gtk_box_pack_start(GTK_BOX(apptw->appRecur_int_hbox) + , apptw->appRecur_int_spin_label1, FALSE, FALSE, 0); + apptw->appRecur_int_spin = gtk_spin_button_new_with_range(1, 100, 1); + gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(apptw->appRecur_int_spin), TRUE); + gtk_box_pack_start(GTK_BOX(apptw->appRecur_int_hbox) + , apptw->appRecur_int_spin, FALSE, FALSE, 5); + apptw->appRecur_int_spin_label2 = gtk_label_new(_("occurrance")); + gtk_box_pack_start(GTK_BOX(apptw->appRecur_int_hbox) + , apptw->appRecur_int_spin_label2, FALSE, FALSE, 0); + xfcalendar_table_add_row(apptw->appTableRecur + , apptw->appRecur_int_label, apptw->appRecur_int_hbox, row++ + , (GtkAttachOptions) (GTK_EXPAND | GTK_FILL) + , (GtkAttachOptions) (0)); + gtk_tooltips_set_tip(apptw->appTooltips, apptw->appRecur_int_spin + , _("Limit frequency to certain interval. For example:\n Every third day: Frequency = Daily and Interval = 3") + , NULL); + + apptw->appRecur_limit_label = gtk_label_new(_("Limit")); apptw->appRecur_limit_rb = gtk_radio_button_new_with_label(NULL , _("Repeat forever")); xfcalendar_table_add_row(apptw->appTableRecur @@ -1581,11 +1716,43 @@ , NULL, apptw->appRecur_until_hbox, row++ , (GtkAttachOptions) (GTK_EXPAND | GTK_FILL) , (GtkAttachOptions) (0)); + + apptw->appRecur_byday_label = gtk_label_new(_("Weekdays")); + apptw->appRecur_byday_hbox = gtk_hbox_new(FALSE, 0); + for (i=0; i <= 6; i++) { + apptw->appRecur_byday_cb[i] = + gtk_check_button_new_with_mnemonic(weekday_array[i]); + gtk_box_pack_start(GTK_BOX(apptw->appRecur_byday_hbox) + , apptw->appRecur_byday_cb[i], FALSE, FALSE, i ? 5 : 0); + } + xfcalendar_table_add_row(apptw->appTableRecur + , apptw->appRecur_byday_label, apptw->appRecur_byday_hbox, row++ + , (GtkAttachOptions) (GTK_EXPAND | GTK_FILL) + , (GtkAttachOptions) (0)); + + apptw->appRecur_byday_spin_label = gtk_label_new(_("Which day")); + apptw->appRecur_byday_spin_hbox = gtk_hbox_new(FALSE, 0); + for (i=0; i <= 6; i++) { + apptw->appRecur_byday_spin[i] = + gtk_spin_button_new_with_range(-9, 9, 1); + gtk_box_pack_start(GTK_BOX(apptw->appRecur_byday_spin_hbox) + , apptw->appRecur_byday_spin[i], FALSE, FALSE, i ? 2 : 0); + gtk_tooltips_set_tip(apptw->appTooltips, apptw->appRecur_byday_spin[i] + , _("Specify which weekday for monthly and yearly events.\n For example:\n Every second Wednesday each month:\n\tFrequency = Monthly,\n\tWeekdays = cross only Wednesday,\n\tWhich day = select 2 from the number below Wednesday") + , NULL); + } + xfcalendar_table_add_row(apptw->appTableRecur + , apptw->appRecur_byday_spin_label + , apptw->appRecur_byday_spin_hbox, row++ + , (GtkAttachOptions) (GTK_EXPAND | GTK_FILL) + , (GtkAttachOptions) (0)); } appt_win *create_appt_win(char *action, char *par, eventlist_win *event_list) { + int i; + /* main window creation and base elements */ appt_win *apptw = g_new(appt_win, 1); @@ -1726,9 +1893,26 @@ g_signal_connect((gpointer) apptw->appRecur_until_rb, "clicked", G_CALLBACK(app_recur_checkbutton_clicked_cb), apptw); + g_signal_connect((gpointer) apptw->appRecur_feature_normal_rb, "clicked", + G_CALLBACK(app_recur_feature_checkbutton_clicked_cb), apptw); + + g_signal_connect((gpointer) apptw->appRecur_feature_advanced_rb, "clicked", + G_CALLBACK(app_recur_feature_checkbutton_clicked_cb), apptw); + g_signal_connect((gpointer) apptw->appRecur_until_button, "clicked", G_CALLBACK(on_appStartEndDate_clicked_cb), apptw); + + for (i=0; i <= 6; i++) { + g_signal_connect((gpointer) apptw->appRecur_byday_cb[i], "clicked", + G_CALLBACK(app_checkbutton_clicked_cb), apptw); + g_signal_connect((gpointer) apptw->appRecur_byday_spin[i], + "value-changed", + G_CALLBACK(on_app_spin_button_changed_cb), apptw); + } + g_signal_connect((gpointer) apptw->appRecur_int_spin, "value-changed", + G_CALLBACK(on_app_spin_button_changed_cb), apptw); + g_signal_connect((gpointer) apptw->appAvailability_cb, "changed", G_CALLBACK(on_app_combobox_changed_cb), apptw); @@ -1750,6 +1934,15 @@ fill_appt_window(apptw, action, par); gtk_widget_show_all(apptw->appWindow); + if (gtk_toggle_button_get_active( + GTK_TOGGLE_BUTTON(apptw->appRecur_feature_normal_rb))) { + gtk_widget_hide(apptw->appRecur_int_label); + gtk_widget_hide(apptw->appRecur_int_hbox); + gtk_widget_hide(apptw->appRecur_byday_label); + gtk_widget_hide(apptw->appRecur_byday_hbox); + gtk_widget_hide(apptw->appRecur_byday_spin_label); + gtk_widget_hide(apptw->appRecur_byday_spin_hbox); + } return apptw; } Modified: xfcalendar/trunk/src/appointment.h =================================================================== --- xfcalendar/trunk/src/appointment.h 2006-08-27 14:15:30 UTC (rev 22905) +++ xfcalendar/trunk/src/appointment.h 2006-08-27 19:04:35 UTC (rev 22906) @@ -68,6 +68,9 @@ gint recur_limit; /* 0 = no limit 1 = count 2 = until */ gint recur_count; gchar recur_until[17]; + gboolean recur_byday[7]; /* 0=Mo, 1=Tu, 2=We, 3=Th, 4=Fr, 5=Sa, 6=Su */ + gint recur_byday_cnt[7]; /* monthly/early: 1=first -1=last 2=second... */ + gint interval; /* 1=every day/week..., 2=every second day/week,... */ } appt_data; typedef struct @@ -83,7 +86,6 @@ GtkWidget *appFileDuplicate_menuitem; GtkWidget *appFileDelete_menuitem; GtkWidget *appFileClose_menuitem; - /* GtkWidget *appHandleBox; */ GtkWidget *appToolbar; GtkTooltips *appTooltips; GtkWidget *appNotebook; @@ -114,6 +116,10 @@ GtkWidget *appNote_Scrolledwindow; GtkWidget *appNote_textview; GtkTextBuffer *appNote_buffer; + GtkWidget *appRecur_feature_label; + GtkWidget *appRecur_feature_hbox; + GtkWidget *appRecur_feature_normal_rb; + GtkWidget *appRecur_feature_advanced_rb; GtkWidget *appRecur_freq_label; GtkWidget *appRecur_freq_cb; GtkWidget *appRecur_limit_rb; @@ -125,6 +131,17 @@ GtkWidget *appRecur_until_hbox; GtkWidget *appRecur_until_rb; GtkWidget *appRecur_until_button; + GtkWidget *appRecur_byday_label; + GtkWidget *appRecur_byday_hbox; + GtkWidget *appRecur_byday_cb[7]; /* 0=Mo, 1=Tu ... 6=Su */ + GtkWidget *appRecur_byday_spin_label; + GtkWidget *appRecur_byday_spin_hbox; + GtkWidget *appRecur_byday_spin[7]; /* 0=Mo, 1=Tu ... 6=Su */ + GtkWidget *appRecur_int_label; + GtkWidget *appRecur_int_hbox; + GtkWidget *appRecur_int_spin; + GtkWidget *appRecur_int_spin_label1; + GtkWidget *appRecur_int_spin_label2; GtkWidget *appAvailability_cb; GtkWidget *appAllDay_checkbutton; GtkWidget *appStartDate_button; Modified: xfcalendar/trunk/src/event-list.c =================================================================== --- xfcalendar/trunk/src/event-list.c 2006-08-27 14:15:30 UTC (rev 22905) +++ xfcalendar/trunk/src/event-list.c 2006-08-27 19:04:35 UTC (rev 22906) @@ -42,7 +42,6 @@ #include <libxfce4util/libxfce4util.h> #include <libxfcegui4/libxfcegui4.h> -#include <libxfcegui4/netk-trayicon.h> #include <gdk/gdkkeysyms.h> #include <gdk/gdk.h> #include <gtk/gtk.h> Modified: xfcalendar/trunk/src/ical-code.c =================================================================== --- xfcalendar/trunk/src/ical-code.c 2006-08-27 14:15:30 UTC (rev 22905) +++ xfcalendar/trunk/src/ical-code.c 2006-08-27 19:04:35 UTC (rev 22906) @@ -39,6 +39,7 @@ #include <unistd.h> #include <time.h> +#include <math.h> #include <libxfce4util/libxfce4util.h> #include <libxfcegui4/libxfcegui4.h> @@ -55,6 +56,7 @@ #include "mainbox.h" #include "ical-code.h" #include "functions.h" +#include "xfce_trayicon.h" #define MAX_APPT_LENGTH 4096 #define LEN_BUFFER 1024 @@ -63,6 +65,9 @@ #define XFICAL_STR_EXISTS(str) ((str != NULL) && (str[0] != 0)) +extern XfceTrayIcon *trayIcon; + + typedef struct { struct icaltimetype stime; @@ -477,6 +482,7 @@ N_("Pacific/Wallis"), N_("Pacific/Yap"), }; + xfical_timezone_array xfical_get_timezones() { static xfical_timezone_array tz={0, NULL}; @@ -944,11 +950,14 @@ */ appt_data *xfical_appt_alloc() { - appt_data *temp; + appt_data *appt; + int i; - temp = g_new0(appt_data, 1); - temp->availability = 1; - return(temp); + appt = g_new0(appt_data, 1); + appt->availability = 1; + for (i=0; i <= 6; i++) + appt->recur_byday[i] = TRUE; + return(appt); } void alarm_free(gpointer galarm, gpointer dummy) @@ -985,6 +994,7 @@ , struct icaltimetype alarm_time, struct icaltimetype event_time) { alarm_struct *new_alarm; + new_alarm = g_new(alarm_struct, 1); new_alarm->uid = g_string_new(uid); new_alarm->title = g_string_new(title); @@ -1002,6 +1012,7 @@ new_alarm->audio = TRUE; else new_alarm->audio = FALSE; + alarm_list = g_list_append(alarm_list, new_alarm); } @@ -1168,6 +1179,23 @@ return(FALSE); } +gboolean xfical_duration(char *alarm_stime, int *days, int *hours, int *mins) +{ + struct icaltimetype alarm_time, cur_time; + struct icaldurationtype duration; + + duration = icaldurationtype_null_duration(); + cur_time = ical_get_current_local_time(); + alarm_time = icaltime_from_string(alarm_stime); + duration = icaltime_subtract(alarm_time, cur_time); + if (icaldurationtype_is_bad_duration(duration) || duration.is_neg) + return(FALSE); + *days = duration.weeks*7 + duration.days; + *hours = duration.hours; + *mins = duration.minutes; + return(TRUE); + } + void appt_add_alarm_internal(appt_data *appt, icalcomponent *ievent) { icalcomponent *ialarm; @@ -1220,9 +1248,11 @@ struct icaltimetype dtstamp, create_time, wtime; static gchar xf_uid[1001]; gchar xf_host[501]; - gchar recur_str[101], *recur_p; + gchar recur_str[1001], *recur_p, *recur_p2; struct icalrecurrencetype rrule; struct icaldurationtype duration; + int i, cnt; + gchar *byday_a[] = {"MO", "TU", "WE", "TH", "FR", "SA", "SU"}; dtstamp = icaltime_current_time_with_zone(utc_icaltimezone); if (add) { @@ -1341,11 +1371,34 @@ icalrecurrencetype_clear(&rrule); } if (appt->recur_limit == 1) { - g_sprintf(recur_p, ";COUNT=%d", appt->recur_count); + recur_p += g_sprintf(recur_p, ";COUNT=%d", appt->recur_count); } else if (appt->recur_limit == 2) { /* needs to be in UTC */ - g_sprintf(recur_p, ";UNTIL=%sZ", appt->recur_until); + recur_p += g_sprintf(recur_p, ";UNTIL=%sZ", appt->recur_until); } + recur_p2 = recur_p; /* store current pointer */ + for (i = 0, cnt = 0; i <= 6; i++) { + if (appt->recur_byday[i]) { + if (cnt == 0) /* first day found */ + recur_p = g_stpcpy(recur_p, ";BYDAY="); + else /* continue the list */ + recur_p = g_stpcpy(recur_p, ","); + if ((appt->freq == XFICAL_FREQ_MONTHLY + || appt->freq == XFICAL_FREQ_YEARLY) + && (appt->recur_byday_cnt[i])) /* number defined */ + recur_p += g_sprintf(recur_p, "%d" + , appt->recur_byday_cnt[i]); + recur_p = g_stpcpy(recur_p, byday_a[i]); + cnt++; + } + } + if (cnt == 7) { /* all days defined... */ + *recur_p2 = *recur_p; /* ...reset to null... */ + recur_p = recur_p2; /* ...no need for BYDAY then */ + } + if (appt->interval > 1) { /* not default, need to insert it */ + recur_p += g_sprintf(recur_p, ";INTERVAL=%d", appt->interval); + } rrule = icalrecurrencetype_from_string(recur_str); icalcomponent_add_property(ievent, icalproperty_new_rrule(rrule)); } @@ -1440,12 +1493,13 @@ icalproperty_transp xf_transp; struct icalrecurrencetype rrule; struct icaldurationtype duration; + int i, cnt, day; for (c = icalcomponent_get_first_component(ical, ICAL_VEVENT_COMPONENT); c != 0 && !key_found; c = icalcomponent_get_next_component(ical, ICAL_VEVENT_COMPONENT)) { text = icalcomponent_get_uid(c); - if (strcmp(text, ical_uid) == 0) { + if (strcmp(text, ical_uid) == 0) { /* we found our uid (=event) */ /*********** Defaults ***********/ stime = icaltime_null_time(); sltime = icaltime_null_time(); @@ -1473,6 +1527,10 @@ appt.recur_limit = 0; appt.recur_count = 0; appt.recur_until[0] = '\0'; + for (i=0; i <= 6; i++) { + appt.recur_byday[i] = TRUE; + appt.recur_byday_cnt[i] = 0; + } /*********** Properties ***********/ for (p = icalcomponent_get_first_property(c, ICAL_ANY_PROPERTY); p != 0; @@ -1575,6 +1633,52 @@ text = icaltime_as_ical_string(rrule.until); g_strlcpy(appt.recur_until, text, 17); } + if (rrule.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { + for (i=0; i <= 6; i++) + appt.recur_byday[i] = FALSE; + for (i=0; i <= 6 && + rrule.by_day[i] != ICAL_RECURRENCE_ARRAY_MAX; + i++) { + cnt = (int)floor((double)(rrule.by_day[i]/8)); + day = abs(rrule.by_day[i]-8*cnt); + switch (day) { + case ICAL_MONDAY_WEEKDAY: + appt.recur_byday[0] = TRUE; + appt.recur_byday_cnt[0] = cnt; + break; + case ICAL_TUESDAY_WEEKDAY: + appt.recur_byday[1] = TRUE; + appt.recur_byday_cnt[1] = cnt; + break; + case ICAL_WEDNESDAY_WEEKDAY: + appt.recur_byday[2] = TRUE; + appt.recur_byday_cnt[2] = cnt; + break; + case ICAL_THURSDAY_WEEKDAY: + appt.recur_byday[3] = TRUE; + appt.recur_byday_cnt[3] = cnt; + break; + case ICAL_FRIDAY_WEEKDAY: + appt.recur_byday[4] = TRUE; + appt.recur_byday_cnt[4] = cnt; + break; + case ICAL_SATURDAY_WEEKDAY: + appt.recur_byday[5] = TRUE; + appt.recur_byday_cnt[5] = cnt; + break; + case ICAL_SUNDAY_WEEKDAY: + appt.recur_byday[6] = TRUE; + appt.recur_byday_cnt[6] = cnt; + break; + case ICAL_NO_WEEKDAY: + break; + default: + g_warning("Orage xfical_appt_get_internal: unknown weekday %s: %d/%d (%x)", ical_uid, rrule.by_day[i], i, rrule.by_day[i]); + break; + } + } + } + appt.interval = rrule.interval; break; case ICAL_CATEGORIES_PROPERTY: case ICAL_CLASS_PROPERTY: @@ -1582,7 +1686,7 @@ case ICAL_CREATED_PROPERTY: break; default: - g_warning("Orage xfical_appt_get: unknown property %s", (char *)icalproperty_get_property_name(p)); + g_warning("Orage xfical_appt_get_internal: unknown property %s", (char *)icalproperty_get_property_name(p)); break; } } @@ -1828,7 +1932,9 @@ else end_day = 31; for (day_cnt = start_day; day_cnt <= end_day; day_cnt++) + { gtk_calendar_mark_day(gtkcal, day_cnt); + } } if ((p = icalcomponent_get_first_property(c , ICAL_RRULE_PROPERTY)) != 0) { /* check recurring EVENTs */ @@ -1842,8 +1948,8 @@ nsdate = icalrecur_iterator_next(ri), nedate = icaltime_add(nsdate, per.duration)) { if ((nsdate.year*12+nsdate.month) <= (year*12+month) - && (year*12+month) <= (nedate.year*12+nedate.month)) { - /* event is in our year+month = visible in calendar */ + && (year*12+month) <= (nedate.year*12+nedate.month)) { + /* event is in our year+month = visible in calendar */ if (nsdate.year == year && nsdate.month == month) start_day = nsdate.day; else @@ -1853,7 +1959,9 @@ else end_day = 31; for (day_cnt = start_day; day_cnt <= end_day; day_cnt++) + { gtk_calendar_mark_day(gtkcal, day_cnt); + } } } icalrecur_iterator_free(ri); Modified: xfcalendar/trunk/src/ical-code.h =================================================================== --- xfcalendar/trunk/src/ical-code.h 2006-08-27 14:15:30 UTC (rev 22905) +++ xfcalendar/trunk/src/ical-code.h 2006-08-27 19:04:35 UTC (rev 22906) @@ -63,6 +63,8 @@ gboolean xfical_alarm_passed(char *alarm_stime); +gboolean xfical_duration(char *alarm_stime, int *days, int *hours, int *mins); + gboolean xfical_keep_tidy(void); int xfical_compare_times(appt_data *appt); _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits