Author: juha
Date: 2007-10-13 03:37:33 +0000 (Sat, 13 Oct 2007)
New Revision: 26130
Modified:
xfcalendar/trunk/configure.in.in
xfcalendar/trunk/src/appointment.c
xfcalendar/trunk/src/day-view.c
xfcalendar/trunk/src/day-view.h
xfcalendar/trunk/src/ical-code.c
xfcalendar/trunk/src/ical-code.h
Log:
1) Do not check end date with VJOURNAL since it has no end date.
2) Delay ical file close to save time.
3) Cleaning day view code.
Modified: xfcalendar/trunk/configure.in.in
===================================================================
--- xfcalendar/trunk/configure.in.in 2007-10-12 12:27:27 UTC (rev 26129)
+++ xfcalendar/trunk/configure.in.in 2007-10-13 03:37:33 UTC (rev 26130)
@@ -9,7 +9,7 @@
dnl
dnl Version information
-m4_define([orage_version], [4.5.10.1-svn])
+m4_define([orage_version], [4.5.10.2-svn])
m4_define([gtk_minimum_version], [2.6.0])
m4_define([xfce_minimum_version], [4.4.0])
Modified: xfcalendar/trunk/src/appointment.c
===================================================================
--- xfcalendar/trunk/src/appointment.c 2007-10-12 12:27:27 UTC (rev 26129)
+++ xfcalendar/trunk/src/appointment.c 2007-10-13 03:37:33 UTC (rev 26130)
@@ -564,10 +564,6 @@
if (gtk_text_iter_forward_search(&start, "<D>"
, GTK_TEXT_SEARCH_TEXT_ONLY
, &match_start, &match_end, &end)) { /* found it */
- /*
- tm = orage_localtime();
- cdate = orage_tm_date_to_i18_date(tm);
- */
cdate = orage_localdate_i18();
gtk_text_buffer_delete(tb, &match_start, &match_end);
gtk_text_buffer_insert(tb, &match_start, cdate, -1);
@@ -846,7 +842,10 @@
+ gtk_spin_button_get_value_as_int(
GTK_SPIN_BUTTON(apptw->Dur_spin_mm)) * 60;
- if(!orage_validate_datetime(apptw, appt))
+ /* Check that end time is after start time.
+ * Journal does not have end time so no need to check */
+ if (appt->type != XFICAL_TYPE_JOURNAL
+ && !orage_validate_datetime(apptw, appt))
return(FALSE);
/* completed date and time.
Modified: xfcalendar/trunk/src/day-view.c
===================================================================
--- xfcalendar/trunk/src/day-view.c 2007-10-12 12:27:27 UTC (rev 26129)
+++ xfcalendar/trunk/src/day-view.c 2007-10-13 03:37:33 UTC (rev 26130)
@@ -154,6 +154,7 @@
refresh_day_view_table(dw);
day_cnt = day_cnt_n;
}
+ dw->upd_timer = 0;
return(FALSE); /* we do this only once */
}
@@ -165,7 +166,10 @@
* is not a good idea. We can't keep up with repeated quick presses
* if we do the whole thing here. So let's throw it to background
* and do it later. */
- g_timeout_add(500, (GtkFunction)upd_day_view, dw);
+ if (dw->upd_timer) {
+ g_source_remove(dw->upd_timer);
+ }
+ dw->upd_timer = g_timeout_add(500, (GtkFunction)upd_day_view, dw);
}
static void on_Date_button_clicked_cb(GtkWidget *button, gpointer *user_data)
@@ -215,6 +219,7 @@
struct tm tm_start, tm_end, tm_first;
GDate *g_start, *g_end, *g_first;
+ /* First clarify timings */
tm_start = orage_icaltime_to_tm_time(appt->starttimecur, FALSE);
tm_end = orage_icaltime_to_tm_time(appt->endtimecur, FALSE);
tm_first = orage_icaltime_to_tm_time(a_day, FALSE);
@@ -233,12 +238,13 @@
else
row = tm_start.tm_hour;
+ /* then add the appointment */
text = g_strdup(appt->title ? appt->title : _("Unknown"));
ev = gtk_event_box_new();
lab = gtk_label_new(text);
gtk_container_add(GTK_CONTAINER(ev), lab);
- if (appt->starttimecur[8] != 'T') {
+ if (appt->starttimecur[8] != 'T') { /* whole day event */
gtk_widget_modify_bg(ev, GTK_STATE_NORMAL, &dw->bg2);
if (dw->header[col] == NULL)
hb = gtk_hbox_new(TRUE, 0);
@@ -249,91 +255,86 @@
, appt->starttimecur
, appt->endtimecur
, appt->note);
- gtk_tooltips_set_tip(dw->Tooltips, ev, tip, NULL);
- gtk_box_pack_start(GTK_BOX(hb), ev, TRUE, TRUE, 0);
- g_object_set_data_full(G_OBJECT(ev), "UID", g_strdup(appt->uid)
- , g_free);
- g_signal_connect((gpointer)ev, "button-press-event"
- , G_CALLBACK(on_button_press_event_cb), dw);
dw->header[col] = hb;
- g_free(tip);
- g_free(text);
- g_date_free(g_start);
- g_date_free(g_end);
- g_date_free(g_first);
- return;
}
-
- if (dw->element[row][col] == NULL)
- hb = gtk_hbox_new(TRUE, 0);
- else
- hb = dw->element[row][col];
- if ((row % 2) == 1)
- gtk_widget_modify_bg(ev, GTK_STATE_NORMAL, &dw->bg1);
- if (g_date_days_between(g_start, g_end) == 0)
- tip = g_strdup_printf("%s\n%02d:%02d-%02d:%02d\n%s"
- , appt->title
- , tm_start.tm_hour, tm_start.tm_min
- , tm_end.tm_hour, tm_end.tm_min
- , appt->note);
else {
- /* we took the date in unnormalized format, so we need to do that now
*/
- tm_start.tm_year -= 1900;
- tm_start.tm_mon -= 1;
- tm_end.tm_year -= 1900;
- tm_end.tm_mon -= 1;
- start_date = g_strdup(orage_tm_date_to_i18_date(&tm_start));
- end_date = g_strdup(orage_tm_date_to_i18_date(&tm_end));
- tip = g_strdup_printf("%s\n%s %02d:%02d - %s %02d:%02d\n%s"
- , appt->title
- , start_date, tm_start.tm_hour, tm_start.tm_min
- , end_date, tm_end.tm_hour, tm_end.tm_min
- , appt->note);
- g_free(start_date);
- g_free(end_date);
+ if ((row % 2) == 1)
+ gtk_widget_modify_bg(ev, GTK_STATE_NORMAL, &dw->bg1);
+ if (dw->element[row][col] == NULL)
+ hb = gtk_hbox_new(TRUE, 0);
+ else
+ hb = dw->element[row][col];
+ if (g_date_days_between(g_start, g_end) == 0)
+ tip = g_strdup_printf("%s\n%02d:%02d-%02d:%02d\n%s"
+ , appt->title
+ , tm_start.tm_hour, tm_start.tm_min
+ , tm_end.tm_hour, tm_end.tm_min
+ , appt->note);
+ else {
+ /* we took the date in unnormalized format, so we need to do that now */
+ tm_start.tm_year -= 1900;
+ tm_start.tm_mon -= 1;
+ tm_end.tm_year -= 1900;
+ tm_end.tm_mon -= 1;
+ start_date = g_strdup(orage_tm_date_to_i18_date(&tm_start));
+ end_date = g_strdup(orage_tm_date_to_i18_date(&tm_end));
+ tip = g_strdup_printf("%s\n%s %02d:%02d - %s %02d:%02d\n%s"
+ , appt->title
+ , start_date, tm_start.tm_hour, tm_start.tm_min
+ , end_date, tm_end.tm_hour, tm_end.tm_min
+ , appt->note);
+ g_free(start_date);
+ g_free(end_date);
+ }
+ dw->element[row][col] = hb;
}
gtk_tooltips_set_tip(dw->Tooltips, ev, tip, NULL);
gtk_box_pack_start(GTK_BOX(hb), ev, TRUE, TRUE, 0);
g_object_set_data_full(G_OBJECT(ev), "UID", g_strdup(appt->uid), g_free);
g_signal_connect((gpointer)ev, "button-press-event"
, G_CALLBACK(on_button_press_event_cb), dw);
- dw->element[row][col] = hb;
g_free(tip);
g_free(text);
- height = dw->StartDate_button_req.height;
- /*
- * same_date = !strncmp(start_ical_time, end_ical_time, 8);
- * */
- start_col = g_date_days_between(g_first, g_start)+1;
- if (start_col < 1)
- first_col = 1;
- else
- first_col = start_col;
- end_col = g_date_days_between(g_first, g_end)+1;
- if (end_col > days)
- last_col = days;
- else
- last_col = end_col;
- for (col = first_col; col <= last_col; col++) {
- if (col == start_col)
- start_row = tm_start.tm_hour;
+
+ /* and finally draw the line to show how long the appointment is,
+ * but only if it is Busy type event (=availability != 0)
+ * and it is not whole day event */
+ if (appt->availability && appt->starttimecur[8] == 'T') {
+ height = dw->StartDate_button_req.height;
+ /*
+ * same_date = !strncmp(start_ical_time, end_ical_time, 8);
+ * */
+ start_col = g_date_days_between(g_first, g_start)+1;
+ if (start_col < 1)
+ first_col = 1;
else
- start_row = 0;
- if (col == end_col)
- end_row = tm_end.tm_hour;
+ first_col = start_col;
+ end_col = g_date_days_between(g_first, g_end)+1;
+ if (end_col > days)
+ last_col = days;
else
- end_row = 23;
- for (row = start_row; row <= end_row; row++) {
- if (row == tm_start.tm_hour && col == start_col)
- start_height = tm_start.tm_min*height/60;
+ last_col = end_col;
+ for (col = first_col; col <= last_col; col++) {
+ if (col == start_col)
+ start_row = tm_start.tm_hour;
else
- start_height = 0;
- if (row == tm_end.tm_hour && col == end_col)
- end_height = tm_end.tm_min*height/60;
+ start_row = 0;
+ if (col == end_col)
+ end_row = tm_end.tm_hour;
else
- end_height = height;
- dw->line[row][col] = build_line(1, start_height
- , 2, end_height-start_height, dw->line[row][col]);
+ end_row = 23;
+ for (row = start_row; row <= end_row; row++) {
+ if (row == tm_start.tm_hour && col == start_col)
+ start_height = tm_start.tm_min*height/60;
+ else
+ start_height = 0;
+ if (row == tm_end.tm_hour && col == end_col)
+ end_height = tm_end.tm_min*height/60;
+ else
+ end_height = height;
+ dw->line[row][col] = build_line(1, start_height
+ , 2, end_height-start_height, dw->line[row][col]);
+ }
}
}
g_date_free(g_start);
@@ -669,7 +670,7 @@
program_log("create_day_win started");
/* initialisation + main window + base vbox */
- dw = g_new(day_win, 1);
+ dw = g_new0(day_win, 1);
dw->Tooltips = gtk_tooltips_new();
dw->accel_group = gtk_accel_group_new();
Modified: xfcalendar/trunk/src/day-view.h
===================================================================
--- xfcalendar/trunk/src/day-view.h 2007-10-12 12:27:27 UTC (rev 26129)
+++ xfcalendar/trunk/src/day-view.h 2007-10-13 03:37:33 UTC (rev 26130)
@@ -56,6 +56,8 @@
GtkWidget *element[24][MAX_DAYS];
GtkWidget *line[24][MAX_DAYS];
+ guint upd_timer;
+
GdkColor bg1, bg2;
} day_win;
Modified: xfcalendar/trunk/src/ical-code.c
===================================================================
--- xfcalendar/trunk/src/ical-code.c 2007-10-12 12:27:27 UTC (rev 26129)
+++ xfcalendar/trunk/src/ical-code.c 2007-10-13 03:37:33 UTC (rev 26130)
@@ -88,6 +88,9 @@
static icalcomponent *ical = NULL,
*aical = NULL;
+static gboolean file_modified = FALSE; /* has any ical file been changed */
+static guint file_close_timer = 0; /* delayed file close timer */
+
typedef struct _foreign_ical_files
{;
icalset *fical;
@@ -607,8 +610,21 @@
#ifdef ORAGE_DEBUG
g_print(P_N "\n");
#endif
- if (*p_fical != NULL)
+ if (file_close_timer) {
+ /* We are opening main ical file and delayed close is in progress.
+ * Closing must be cancelled since we are now opening the file. */
+ g_source_remove(file_close_timer);
+ file_close_timer = 0;
+ /*
+ orage_message(P_N "canceling delayed close");
+ */
+ }
+ if (*p_fical != NULL) {
+ /*
g_warning(P_N "file already open");
+ */
+ return(TRUE);
+ }
if (!ORAGE_STR_EXISTS(file_icalpath)) {
if (test)
g_warning(P_N "file empty");
@@ -672,6 +688,7 @@
}
}
}
+ file_modified = FALSE;
return(TRUE);
}
@@ -727,6 +744,31 @@
return(xfical_internal_file_open(&x_ical, &x_fical, file_name, TRUE));
}
+/*
+ * guint = g_timeout_add(30*1000, (GtkFunction)orage_foreign_files_check,
NULL);
+ * if (tune->timeout_id) {
+ * g_source_remove(tune->timeout_id);
+ * tune->timeout_id = 0;
+ * }
+ * */
+gboolean delayed_file_close(gpointer user_data)
+{
+#undef P_N
+#define P_N "delayed_file_close: "
+
+#ifdef ORAGE_DEBUG
+ g_print(P_N "\n");
+#endif
+ icalset_free(fical);
+ fical = NULL;
+ /*
+ orage_message(P_N "closing ical file");
+ */
+ /* we only close file once, so end here */
+ file_close_timer = 0;
+ return(FALSE);
+}
+
void xfical_file_close(gboolean foreign)
{
#undef P_N
@@ -738,9 +780,31 @@
#endif
if (fical == NULL)
g_warning(P_N "fical is NULL");
- else
- icalset_free(fical);
- fical = NULL;
+ else {
+ if (file_close_timer) {
+ /* We are closing main ical file and delayed close is in progress.
+ * Closing must be cancelled since we are now closing the file. */
+ g_source_remove(file_close_timer);
+ file_close_timer = 0;
+ /*
+ orage_message(P_N "canceling delayed close");
+ */
+ }
+ if (file_modified) { /* close it now */
+ /*
+ orage_message(P_N "closing file now");
+ */
+ icalset_free(fical);
+ fical = NULL;
+ }
+ else { /* close it later = after 10 minutes (to save time) */
+ /*
+ orage_message(P_N "closing file after 10 minutes");
+ */
+ file_close_timer = g_timeout_add(10*60*1000
+ , (GtkFunction)delayed_file_close, NULL);
+ }
+ }
if (foreign)
for (i = 0; i < g_par.foreign_count; i++) {
@@ -1696,6 +1760,7 @@
return(NULL);
}
xfical_alarm_build_list_internal(FALSE);
+ file_modified = TRUE;
return(ext_uid);
}
@@ -2542,6 +2607,7 @@
icalcomponent_remove_component(base, c);
icalset_mark(fbase);
xfical_alarm_build_list_internal(FALSE);
+ file_modified = TRUE;
return(TRUE);
}
}
@@ -3511,6 +3577,7 @@
}
}
+ file_modified = TRUE;
icalset_mark(afical);
icalset_commit(afical);
xfical_archive_close();
@@ -3558,9 +3625,12 @@
* After that delete the whole arch file */
orage_message(_("\tPHASE 2: return archived appointments"));
if (!xfical_archive_open()) {
- g_warning(P_N "archive file open error");
+ /* we have risk to delete the data permanently, let's stop here */
+ g_error(P_N "archive file open error");
+ /*
icalset_mark(fical);
icalset_commit(fical);
+ */
xfical_file_close(FALSE);
return(FALSE);
}
@@ -3575,6 +3645,7 @@
if (g_remove(g_par.archive_file) == -1) {
g_warning(P_N "Failed to remove archive file %s", g_par.archive_file);
}
+ file_modified = TRUE;
icalset_mark(fical);
icalset_commit(fical);
xfical_file_close(FALSE);
@@ -3610,14 +3681,15 @@
/* Remove from the archive file */
icalcomponent_remove_component(aical, c);
key_found = TRUE;
+ file_modified = TRUE;
}
}
+ icalset_mark(afical);
+ icalset_commit(afical);
+ xfical_archive_close();
icalset_mark(fical);
icalset_commit(fical);
xfical_file_close(FALSE);
- icalset_mark(afical);
- icalset_commit(afical);
- xfical_archive_close();
return(TRUE);
}
@@ -3670,6 +3742,7 @@
}
*/
+ file_modified = TRUE;
icalset_mark(fical);
icalset_commit(fical);
xfical_file_close(FALSE);
Modified: xfcalendar/trunk/src/ical-code.h
===================================================================
--- xfcalendar/trunk/src/ical-code.h 2007-10-12 12:27:27 UTC (rev 26129)
+++ xfcalendar/trunk/src/ical-code.h 2007-10-13 03:37:33 UTC (rev 26130)
@@ -130,10 +130,6 @@
gboolean xfical_appt_del(char *ical_id);
xfical_appt *xfical_appt_get_next_on_day(char *a_day, gboolean first, gint days
, xfical_type type, gchar *file_type);
-/*
-xfical_appt *xfical_appt_get_next_with_string(char *a_day, gboolean first
- , gboolean arch);
- */
xfical_appt *xfical_appt_get_next_with_string(char *str, gboolean first
, gchar *file_type);
@@ -155,4 +151,5 @@
, gchar **tz);
gboolean xfical_file_check(gchar *file_name);
+
#endif /* !__ICAL_CODE_H__ */
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits