[Xfce4-commits] r26600 - in xfcalendar/trunk: . src
Juha Kautto
juha at xfce.org
Thu Feb 7 21:51:01 CET 2008
Author: juha
Date: 2008-02-07 20:51:01 +0000 (Thu, 07 Feb 2008)
New Revision: 26600
Modified:
xfcalendar/trunk/configure.in.in
xfcalendar/trunk/src/appointment.c
xfcalendar/trunk/src/appointment.h
xfcalendar/trunk/src/day-view.c
xfcalendar/trunk/src/day-view.h
xfcalendar/trunk/src/event-list.c
xfcalendar/trunk/src/event-list.h
xfcalendar/trunk/src/mainbox.c
xfcalendar/trunk/src/reminder.c
xfcalendar/trunk/src/tray_icon.c
Log:
1) Fixing BUG 3835 - No visual confirmation of setting
now it works similarly than Orage 4.4 but correctly
2) Fixed error in day view when showing reserved time for
appointments crossing day change.
Modified: xfcalendar/trunk/configure.in.in
===================================================================
--- xfcalendar/trunk/configure.in.in 2008-02-07 08:04:21 UTC (rev 26599)
+++ xfcalendar/trunk/configure.in.in 2008-02-07 20:51:01 UTC (rev 26600)
@@ -9,7 +9,7 @@
dnl
dnl Version information
-m4_define([orage_version], [4.5.12.3-svn])
+m4_define([orage_version], [4.5.12.4-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 2008-02-07 08:04:21 UTC (rev 26599)
+++ xfcalendar/trunk/src/appointment.c 2008-02-07 20:51:01 UTC (rev 26600)
@@ -670,6 +670,10 @@
static void app_free_memory(appt_win *apptw)
{
+ /* remove myself from event list appointment monitoring list */
+ if (apptw->el)
+ ((el_win *)apptw->el)->apptw_list =
+ g_list_remove(((el_win *)apptw->el)->apptw_list, apptw);
gtk_widget_destroy(apptw->Window);
gtk_object_destroy(GTK_OBJECT(apptw->Tooltips));
g_free(apptw->xf_uid);
@@ -1044,11 +1048,8 @@
if (ok) {
apptw->appointment_new = FALSE;
mark_appointment_unchanged(apptw);
- /* FIXME: Removed since it fails if event_list window has been removed.
- * We should check that it really still exists, before calling this.
if (apptw->el != NULL)
refresh_el_win((el_win *)apptw->el);
- */
orage_mark_appointments();
}
}
@@ -1108,11 +1109,8 @@
xfical_file_close(TRUE);
}
- /* FIXME: This fails if event_list window has been removed.
- * We should check that it really still exists, before calling this.
if (apptw->el != NULL)
refresh_el_win((el_win *)apptw->el);
- */
orage_mark_appointments();
app_free_memory(apptw);
@@ -1135,7 +1133,8 @@
gint x, y;
appt_win *apptw2;
- apptw2 = create_appt_win("COPY", apptw->xf_uid, apptw->el);
+ /* do not keep track of appointments created here */
+ apptw2 = create_appt_win("COPY", apptw->xf_uid);
gtk_window_get_position(GTK_WINDOW(apptw->Window), &x, &y);
gtk_window_move(GTK_WINDOW(apptw2->Window), x+20, y+20);
}
@@ -2343,7 +2342,7 @@
}
}
-appt_win *create_appt_win(char *action, char *par, el_win *event_list)
+appt_win *create_appt_win(char *action, char *par)
{
appt_win *apptw;
GdkWindow *window;
@@ -2353,7 +2352,7 @@
apptw->xf_uid = NULL;
apptw->par = NULL;
apptw->appt = NULL;
- apptw->el = event_list; /* Keep track of the parent, if any */
+ apptw->el = NULL;
apptw->appointment_changed = FALSE;
apptw->Tooltips = gtk_tooltips_new();
apptw->accel_group = gtk_accel_group_new();
@@ -2395,6 +2394,7 @@
}
else { /* failed to get data */
app_free_memory(apptw);
+ apptw = NULL;
}
return(apptw);
Modified: xfcalendar/trunk/src/appointment.h
===================================================================
--- xfcalendar/trunk/src/appointment.h 2008-02-07 08:04:21 UTC (rev 26599)
+++ xfcalendar/trunk/src/appointment.h 2008-02-07 20:51:01 UTC (rev 26600)
@@ -25,7 +25,6 @@
#define __APPOINTMENT_H__
#include "ical-code.h"
-#include "event-list.h"
typedef struct _appt_win
{
@@ -173,7 +172,7 @@
xfical_appt *appt;
gchar *xf_uid;
gchar *par;
- el_win *el;
+ void *el; /* used to refresh calling event list */
gboolean appointment_add; /* are we adding app */
gboolean appointment_changed; /* has this app been modified now */
gboolean appointment_new; /* is this new = no uid yet */
@@ -181,6 +180,6 @@
* add == TRUE && new == FALSE */
} appt_win;
-appt_win *create_appt_win(char *action, char *par, el_win *el);
+appt_win *create_appt_win(char *action, char *par);
#endif /* !__APPOINTMENT_H__ */
Modified: xfcalendar/trunk/src/day-view.c
===================================================================
--- xfcalendar/trunk/src/day-view.c 2008-02-07 08:04:21 UTC (rev 26599)
+++ xfcalendar/trunk/src/day-view.c 2008-02-07 20:51:01 UTC (rev 26600)
@@ -144,7 +144,7 @@
s_date = (char *)gtk_button_get_label(GTK_BUTTON(dw->StartDate_button));
strcpy(a_day, orage_i18_date_to_icaltime(s_date));
- create_appt_win("NEW", a_day, NULL);
+ create_appt_win("NEW", a_day);
}
static void on_File_newApp_activate_cb(GtkMenuItem *mi, gpointer user_data)
@@ -378,7 +378,7 @@
if (event->type==GDK_2BUTTON_PRESS) {
uid = g_object_get_data(G_OBJECT(widget), "UID");
- create_appt_win("UPDATE", uid, NULL);
+ create_appt_win("UPDATE", uid);
}
}
@@ -395,14 +395,17 @@
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);
+ start_col = orage_days_between(&tm_first, &tm_start)+1;
+ end_col = orage_days_between(&tm_first, &tm_end)+1;
- col = orage_days_between(&tm_first, &tm_start)+1;
- if (col < 1) {
+ if (start_col < 1) {
col = 1;
row = 0;
}
- else
+ else {
+ col = start_col;
row = tm_start.tm_hour;
+ }
/* then add the appointment */
text = g_strdup(appt->title ? appt->title : _("Unknown"));
@@ -474,12 +477,10 @@
/*
* same_date = !strncmp(start_ical_time, end_ical_time, 8);
* */
- start_col = orage_days_between(&tm_first, &tm_start)+1;
if (start_col < 1)
first_col = 1;
else
first_col = start_col;
- end_col = orage_days_between(&tm_first, &tm_end)+1;
if (end_col > days)
last_col = days;
else
@@ -562,6 +563,7 @@
height = dw->StartDate_button_req.height;
width = dw->StartDate_button_req.width;
+ /* first clear the structure */
for (col = 1; col < days+1; col++) {
dw->header[col] = NULL;
for (row = 0; row < 24; row++) {
@@ -570,11 +572,14 @@
dw->line[row][col] = build_line(dw, 0, 0, 3, height, NULL);
}
}
+
app_data(dw);
+
for (col = 1; col < days+1; col++) {
hb = gtk_hbox_new(FALSE, 0);
marker = build_line(dw, 0, 0, 2, height, NULL);
gtk_box_pack_start(GTK_BOX(hb), marker, FALSE, FALSE, 0);
+ /* check if we have full day events and put them to header */
if (dw->header[col]) {
gtk_box_pack_start(GTK_BOX(hb), dw->header[col], TRUE, TRUE, 0);
gtk_widget_set_size_request(hb, width, -1);
@@ -586,6 +591,8 @@
}
gtk_table_attach(GTK_TABLE(dw->dtable_h), hb, col, col+1, 1, 2
, (GTK_FILL), (0), 0, 0);
+
+ /* check rows */
for (row = 0; row < 24; row++) {
hb = gtk_hbox_new(FALSE, 0);
if (row == 0)
@@ -691,45 +698,59 @@
dw->line_color.blue = 230 * (65535/255);
}
gdk_colormap_alloc_color(pic1_cmap, &dw->line_color, FALSE, TRUE);
+
+ if (!gdk_color_parse("red", &dw->fg_sunday)) {
+ g_warning("color parse failed: red\n");
+ dw->fg_sunday.red = 255 * (65535/255);
+ dw->fg_sunday.green = 10 * (65535/255);
+ dw->fg_sunday.blue = 10 * (65535/255);
+ }
+ gdk_colormap_alloc_color(pic1_cmap, &dw->fg_sunday, FALSE, TRUE);
+
+ if (!gdk_color_parse("gold", &dw->bg_today)) {
+ g_warning("color parse failed: gold\n");
+ dw->bg_today.red = 255 * (65535/255);
+ dw->bg_today.green = 215 * (65535/255);
+ dw->bg_today.blue = 115 * (65535/255);
+ }
+ gdk_colormap_alloc_color(pic1_cmap, &dw->bg_today, FALSE, TRUE);
}
+static void fill_hour(day_win *dw, gint col, gint row, char *text)
+{
+ GtkWidget *name, *ev;
+
+ ev = gtk_event_box_new();
+ name = gtk_label_new(text);
+ gtk_container_add(GTK_CONTAINER(ev), name);
+ if ((row % 2) == 1)
+ gtk_widget_modify_bg(ev, GTK_STATE_NORMAL, &dw->bg1);
+ gtk_widget_set_size_request(ev, dw->hour_req.width
+ , dw->StartDate_button_req.height);
+ if (text)
+ gtk_table_attach(GTK_TABLE(dw->dtable), ev, col, col+1, row, row+1
+ , (GTK_FILL), (0), 0, 0);
+ else /* special, needed for header table full day events */
+ gtk_table_attach(GTK_TABLE(dw->dtable_h), ev, col, col+1, row, row+1
+ , (GTK_FILL), (0), 0, 0);
+}
+
static void build_day_view_table(day_win *dw)
{
gint days; /* number of days to show */
int year, month, day;
gint i, sunday;
- GtkWidget *name, *label, *ev;
+ GtkWidget *label, *button;
char text[5+1], *date, *today;
struct tm tm_date;
guint monthdays[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
GtkWidget *vp;
- GdkColor fg, bg;
- GdkColormap *pic1_cmap;
-
- pic1_cmap = gdk_colormap_get_system();
- if (!gdk_color_parse("red", &fg)) {
- g_warning("color parse failed: red\n");
- fg.red = 255 * (65535/255);
- fg.green = 10 * (65535/255);
- fg.blue = 10 * (65535/255);
- }
- gdk_colormap_alloc_color(pic1_cmap, &fg, FALSE, TRUE);
- if (!gdk_color_parse("gold", &bg)) {
- g_warning("color parse failed: gold\n");
- bg.red = 255 * (65535/255);
- bg.green = 215 * (65535/255);
- bg.blue = 115 * (65535/255);
- }
- gdk_colormap_alloc_color(pic1_cmap, &bg, FALSE, TRUE);
-
+
days = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(dw->day_spin));
tm_date = orage_i18_date_to_tm_date(
gtk_button_get_label(GTK_BUTTON(dw->StartDate_button)));
- sunday = tm_date.tm_wday; /* 0 = Sunday */
- if (sunday)
- sunday = 7-sunday;
-
- /* header of day table = days columns */
+
+ /****** header of day table = days columns ******/
dw->scroll_win_h = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(dw->scroll_win_h)
, GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER);
@@ -741,35 +762,38 @@
/*
gtk_container_add(GTK_CONTAINER(dw->scroll_win_h), dw->day_view_vbox);
*/
+ /* row 1= day header buttons
+ * row 2= full day events after the buttons */
dw->dtable_h = gtk_table_new(2, days+2, FALSE);
gtk_box_pack_start(GTK_BOX(dw->day_view_vbox), dw->dtable_h
, FALSE, FALSE, 0);
+
+ sunday = tm_date.tm_wday; /* 0 = Sunday */
+ if (sunday) /* index to next sunday */
+ sunday = 7-sunday;
year = tm_date.tm_year + 1900;
month = tm_date.tm_mon;
day = tm_date.tm_mday;
if (((tm_date.tm_year%4) == 0) && (((tm_date.tm_year%100) != 0)
|| ((tm_date.tm_year%400) == 0)))
++monthdays[1];
- name = gtk_label_new(" ");
- gtk_widget_set_size_request(name, dw->hour_req.width, -1);
- gtk_table_attach(GTK_TABLE(dw->dtable_h), name, 0, 1, 0, 1
- , (GTK_FILL), (0), 0, 0);
+ fill_hour(dw, 0, 0, NULL);
today = g_strdup(orage_localdate_i18());
for (i = 1; i < days+1; i++) {
date = orage_tm_date_to_i18_date(&tm_date);
- name = gtk_button_new();
- gtk_button_set_label(GTK_BUTTON(name), date);
+ button = gtk_button_new();
+ gtk_button_set_label(GTK_BUTTON(button), date);
if (strcmp(today, date) == 0) {
- gtk_widget_modify_bg(name, GTK_STATE_NORMAL, &bg);
+ gtk_widget_modify_bg(button, GTK_STATE_NORMAL, &dw->bg_today);
}
if ((i-1)%7 == sunday) {
- label = gtk_bin_get_child(GTK_BIN(name));
- gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &fg);
+ label = gtk_bin_get_child(GTK_BIN(button));
+ gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &dw->fg_sunday);
}
- gtk_widget_set_size_request(name, dw->StartDate_button_req.width, -1);
- g_signal_connect((gpointer)name, "clicked"
+ gtk_widget_set_size_request(button, dw->StartDate_button_req.width, -1);
+ g_signal_connect((gpointer)button, "clicked"
, G_CALLBACK(header_button_clicked_cb), dw);
- gtk_table_attach(GTK_TABLE(dw->dtable_h), name, i, i+1, 0, 1
+ gtk_table_attach(GTK_TABLE(dw->dtable_h), button, i, i+1, 0, 1
, (GTK_FILL), (0), 0, 0);
if (++tm_date.tm_mday == (monthdays[tm_date.tm_mon]+1)) {
@@ -781,12 +805,9 @@
}
}
g_free(today);
- name = gtk_label_new(" ");
- gtk_widget_set_size_request(name, dw->hour_req.width, -1);
- gtk_table_attach(GTK_TABLE(dw->dtable_h), name, days+1, days+2, 0, 1
- , (GTK_FILL), (0), 0, 0);
+ fill_hour(dw, days+1, 0, NULL);
- /* body of day table */
+ /****** body of day table ******/
dw->scroll_win = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(dw->scroll_win)
, GTK_SHADOW_NONE);
@@ -804,25 +825,10 @@
/* hours column = hour rows */
for (i = 0; i < 24; i++) {
- ev = gtk_event_box_new();
g_sprintf(text, "%02d", i);
- name = gtk_label_new(text);
- gtk_container_add(GTK_CONTAINER(ev), name);
- if ((i % 2) == 1)
- gtk_widget_modify_bg(ev, GTK_STATE_NORMAL, &dw->bg1);
- gtk_widget_set_size_request(ev, dw->hour_req.width
- , dw->StartDate_button_req.height);
- gtk_table_attach(GTK_TABLE(dw->dtable), ev, 0, 1, i, i+1
- , (GTK_FILL), (0), 0, 0);
- ev = gtk_event_box_new();
- name = gtk_label_new(text);
- gtk_container_add(GTK_CONTAINER(ev), name);
- if ((i % 2) == 1)
- gtk_widget_modify_bg(ev, GTK_STATE_NORMAL, &dw->bg1);
- gtk_widget_set_size_request(ev, dw->hour_req.width
- , dw->StartDate_button_req.height);
- gtk_table_attach(GTK_TABLE(dw->dtable), ev, days+1, days+2, i, i+1
- , (GTK_FILL), (0), 0, 0);
+ /* ev is needed for background colour */
+ fill_hour(dw, 0, i, text);
+ fill_hour(dw, days+1, i, text);
}
fill_days(dw, days);
}
Modified: xfcalendar/trunk/src/day-view.h
===================================================================
--- xfcalendar/trunk/src/day-view.h 2008-02-07 08:04:21 UTC (rev 26599)
+++ xfcalendar/trunk/src/day-view.h 2008-02-07 20:51:01 UTC (rev 26600)
@@ -71,7 +71,7 @@
guint upd_timer;
gdouble scroll_pos; /* remember the scroll position */
- GdkColor bg1, bg2, line_color;
+ GdkColor bg1, bg2, line_color, bg_today, fg_sunday;
} day_win;
day_win *create_day_win(char *start_date);
Modified: xfcalendar/trunk/src/event-list.c
===================================================================
--- xfcalendar/trunk/src/event-list.c 2008-02-07 08:04:21 UTC (rev 26599)
+++ xfcalendar/trunk/src/event-list.c 2008-02-07 20:51:01 UTC (rev 26600)
@@ -82,6 +82,19 @@
{ "STRING", 0, DRAG_TARGET_STRING }
};
+static void do_appt_win(char *mode, char *uid, el_win *el)
+{
+ appt_win *apptw;
+
+ apptw = create_appt_win(mode, uid);
+ if (apptw) {
+ /* we started this, so keep track of it */
+ el->apptw_list = g_list_prepend(el->apptw_list, apptw);
+ /* inform the appointment that we are interested in it */
+ apptw->el = el;
+ }
+};
+
static void start_appt_win(char *mode, el_win *el
, GtkTreeModel *model, GtkTreeIter *iter, GtkTreePath *path)
{
@@ -99,7 +112,7 @@
}
g_free(flags);
#endif
- create_appt_win(mode, uid, el);
+ do_appt_win(mode, uid, el);
g_free(uid);
}
}
@@ -551,7 +564,7 @@
app_data(el, a_day, NULL);
}
-void journal_data(el_win *el)
+static void journal_data(el_win *el)
{
char a_day[9]; /* yyyymmdd */
@@ -692,10 +705,27 @@
static void close_window(el_win *el)
{
+ appt_win *apptw;
+ GList *apptw_list;
+
gtk_window_get_size(GTK_WINDOW(el->Window)
, &g_par.el_size_x, &g_par.el_size_y);
write_parameters();
+ /* need to clean the apointment list and inform all appointments that
+ * we are not interested anymore (= should not get updated) */
+ apptw_list = el->apptw_list;
+ for (apptw_list = g_list_first(apptw_list);
+ apptw_list != NULL;
+ apptw_list = g_list_next(apptw_list)) {
+ apptw = (appt_win *)apptw_list->data;
+ if (apptw) /* appointment window is still alive */
+ apptw->el = NULL; /* not interested anymore */
+ else
+ orage_message(10, "close_window: not null appt window");
+ }
+ g_list_free(el->apptw_list);
+
gtk_widget_destroy(el->Window); /* destroy the eventlist window */
gtk_object_destroy(GTK_OBJECT(el->Tooltips));
g_free(el);
@@ -793,8 +823,7 @@
title = (char *)gtk_window_get_title(GTK_WINDOW(el->Window));
strcpy(a_day, orage_i18_date_to_icaltime(title));
-
- create_appt_win("NEW", a_day, el);
+ do_appt_win("NEW", a_day, el);
}
static void on_File_newApp_activate_cb(GtkMenuItem *mi, gpointer user_data)
@@ -1238,6 +1267,7 @@
el->today = FALSE;
el->days = 0;
el->time_now[0] = 0;
+ el->apptw_list = NULL;
el->Tooltips = gtk_tooltips_new();
el->accel_group = gtk_accel_group_new();
Modified: xfcalendar/trunk/src/event-list.h
===================================================================
--- xfcalendar/trunk/src/event-list.h 2008-02-07 08:04:21 UTC (rev 26599)
+++ xfcalendar/trunk/src/event-list.h 2008-02-07 20:51:01 UTC (rev 26600)
@@ -92,6 +92,7 @@
el_page page; /* appointment page to show */
char time_now[6]; /* hh:mm */
char date_now[XFICAL_APPT_TIME_FORMAT_LEN]; /* yyyymmddThhmmss */
+ GList *apptw_list; /* keep track of appointments being updated */
} el_win; /* event list window */
el_win* create_el_win(char *start_date);
Modified: xfcalendar/trunk/src/mainbox.c
===================================================================
--- xfcalendar/trunk/src/mainbox.c 2008-02-07 08:04:21 UTC (rev 26599)
+++ xfcalendar/trunk/src/mainbox.c 2008-02-07 20:51:01 UTC (rev 26600)
@@ -83,7 +83,7 @@
t = orage_localtime();
g_snprintf(cur_date, 9, "%04d%02d%02d", t->tm_year+1900
, t->tm_mon+1, t->tm_mday);
- create_appt_win("NEW", cur_date, NULL);
+ create_appt_win("NEW", cur_date);
}
static void mFile_interface_activate_cb(GtkMenuItem *menuitem
@@ -345,7 +345,7 @@
#endif
if (event->type==GDK_2BUTTON_PRESS) {
uid = g_object_get_data(G_OBJECT(widget), "UID");
- create_appt_win("UPDATE", uid, NULL);
+ create_appt_win("UPDATE", uid);
}
}
Modified: xfcalendar/trunk/src/reminder.c
===================================================================
--- xfcalendar/trunk/src/reminder.c 2008-02-07 08:04:21 UTC (rev 26599)
+++ xfcalendar/trunk/src/reminder.c 2008-02-07 20:51:01 UTC (rev 26600)
@@ -361,7 +361,7 @@
alarm->notify_refresh = TRUE;
create_notify_reminder(alarm);
*/
- create_appt_win("UPDATE", alarm->uid, NULL);
+ create_appt_win("UPDATE", alarm->uid);
}
#endif
@@ -531,7 +531,7 @@
{
alarm_struct *alarm = (alarm_struct *)user_data;
- create_appt_win("UPDATE", alarm->uid, NULL);
+ create_appt_win("UPDATE", alarm->uid);
}
static void create_orage_reminder(alarm_struct *alarm)
Modified: xfcalendar/trunk/src/tray_icon.c
===================================================================
--- xfcalendar/trunk/src/tray_icon.c 2008-02-07 08:04:21 UTC (rev 26599)
+++ xfcalendar/trunk/src/tray_icon.c 2008-02-07 20:51:01 UTC (rev 26600)
@@ -75,7 +75,7 @@
t = orage_localtime();
g_snprintf(cur_date, 9, "%04d%02d%02d", t->tm_year+1900
, t->tm_mon+1, t->tm_mday);
- create_appt_win("NEW", cur_date, NULL);
+ create_appt_win("NEW", cur_date);
}
void on_about_activate(GtkMenuItem *menuitem, gpointer user_data)
More information about the Xfce4-commits
mailing list