aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendar/ChangeLog20
-rw-r--r--calendar/eventedit.c2
-rw-r--r--calendar/eventedit.h2
-rw-r--r--calendar/gncal-day-panel.c12
-rw-r--r--calendar/gncal-day-panel.h3
-rw-r--r--calendar/gncal-todo.c245
-rw-r--r--calendar/gncal-todo.h3
-rw-r--r--calendar/gnome-cal.c16
-rw-r--r--calendar/gnome-cal.h9
-rw-r--r--calendar/goto.c10
-rw-r--r--calendar/gui/eventedit.c2
-rw-r--r--calendar/gui/eventedit.h2
-rw-r--r--calendar/gui/gncal-day-panel.c12
-rw-r--r--calendar/gui/gncal-day-panel.h3
-rw-r--r--calendar/gui/gncal-todo.c245
-rw-r--r--calendar/gui/gncal-todo.h3
-rw-r--r--calendar/gui/gnome-cal.c16
-rw-r--r--calendar/gui/gnome-cal.h9
-rw-r--r--calendar/gui/goto.c10
-rw-r--r--calendar/gui/main.c25
-rw-r--r--calendar/gui/main.h16
-rw-r--r--calendar/gui/prop.c127
-rw-r--r--calendar/main.c25
-rw-r--r--calendar/main.h16
-rw-r--r--calendar/prop.c127
25 files changed, 888 insertions, 72 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 5e3246578d..4453610820 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,23 @@
+1999-03-10 Clifford R. Conover <rconover@montana.edu>
+
+ * gncal-todo.c (simple_todo_editor): Add support for Due Date when
+ adding a TODO item here.
+ (column_resized): New function
+ (init_column_sorting): New function.
+ (todo_click_column): New function.
+ (convert_time_t_to_char, make_overdue_todo_style): New functions.
+
+ * gnome-cal.c (gnome_calendar_todo_properties_changed): New
+ function used to update the TODO when the properties have been
+ chagned for it.
+
+ * prop.c (prop_apply_todo): Apply TODO properties.
+
+ * gncal-day-panel.c (todo_list_properties_changed): Update the
+ TODO display here.
+
+ * eventedit.c (date_edit_new): Made public
+
1999-03-10 Craig A Soules (soules+@andrew.cmu.edu)
* timeutil.c, calendar.c, calobj.c, gncal-day-panel.c: Add support
diff --git a/calendar/eventedit.c b/calendar/eventedit.c
index 15a33d92ea..72d48617d0 100644
--- a/calendar/eventedit.c
+++ b/calendar/eventedit.c
@@ -210,7 +210,7 @@ set_all_day (GtkToggleButton *toggle, EventEditor *ee)
}
/* Convenience function to create a properly-configured date editor widget */
-static GtkWidget *
+GtkWidget *
date_edit_new (time_t the_time, int show_time)
{
return gnome_date_edit_new_flags (the_time,
diff --git a/calendar/eventedit.h b/calendar/eventedit.h
index 15ef540333..4d605892dd 100644
--- a/calendar/eventedit.h
+++ b/calendar/eventedit.h
@@ -76,7 +76,7 @@ GtkWidget *event_editor_new (GnomeCalendar *owner, iCalObject *);
*/
void event_editor_new_whole_day (GnomeCalendar *owner, time_t day);
-
+GtkWidget *date_edit_new (time_t the_time, int show_time);
END_GNOME_DECLS
diff --git a/calendar/gncal-day-panel.c b/calendar/gncal-day-panel.c
index 518babfa1a..1eb8941019 100644
--- a/calendar/gncal-day-panel.c
+++ b/calendar/gncal-day-panel.c
@@ -266,3 +266,15 @@ gncal_day_panel_time_format_changed (GncalDayPanel *dpanel)
: (dpanel->gtk_calendar->display_flags
& ~GTK_CALENDAR_WEEK_START_MONDAY)));
}
+
+void
+todo_list_properties_changed (GncalDayPanel *dpanel)
+{
+ g_return_if_fail (dpanel != NULL);
+ g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
+
+ gncal_todo_update (dpanel->todo, NULL, 0);
+}
+
+
+
diff --git a/calendar/gncal-day-panel.h b/calendar/gncal-day-panel.h
index 48ba6f38b1..6bf8768d9c 100644
--- a/calendar/gncal-day-panel.h
+++ b/calendar/gncal-day-panel.h
@@ -56,6 +56,9 @@ void gncal_day_panel_update (GncalDayPanel *dpanel, iCalObject *ico, int flags);
void gncal_day_panel_set (GncalDayPanel *dpanel, time_t start_of_day);
void gncal_day_panel_time_format_changed (GncalDayPanel *dpanel);
+void todo_list_properties_changed (GncalDayPanel *dpanel);
+
+
END_GNOME_DECLS
diff --git a/calendar/gncal-todo.c b/calendar/gncal-todo.c
index a78bd9432b..4c48fe1807 100644
--- a/calendar/gncal-todo.c
+++ b/calendar/gncal-todo.c
@@ -11,8 +11,17 @@
#include "gncal-todo.h"
#include "main.h"
#include "popup-menu.h"
+#include "eventedit.h"
+int todo_show_due_date = 0;
+int todo_due_date_overdue_highlight = 0;
+char *todo_overdue_font_text;
+gint todo_current_sort_column = 0;
+gint todo_current_sort_type = GTK_SORT_ASCENDING;
+gboolean todo_style_changed =0;
+gboolean todo_list_autoresize = 1;
+gboolean todo_list_redraw_in_progess = 0;
static void gncal_todo_init (GncalTodo *todo);
@@ -44,15 +53,15 @@ ok_button (GtkWidget *widget, GnomeDialog *dialog)
iCalObject *ico;
GncalTodo *todo;
GtkEntry *entry;
-
+ GnomeDateEdit *due_date;
ico = gtk_object_get_user_data (GTK_OBJECT (dialog));
todo = GNCAL_TODO (gtk_object_get_data (GTK_OBJECT (dialog), "gncal_todo"));
entry = GTK_ENTRY (gtk_object_get_data (GTK_OBJECT (dialog), "summary_entry"));
-
+ due_date = GNOME_DATE_EDIT (gtk_object_get_data(GTK_OBJECT(dialog), "due_date"));
if (ico->summary)
g_free (ico->summary);
-
+ ico->dtend = gnome_date_edit_get_date (due_date);
ico->summary = g_strdup (gtk_entry_get_text (entry));
ico->user_data = NULL;
@@ -79,6 +88,8 @@ cancel_button (GtkWidget *widget, GnomeDialog *dialog)
ical_object_destroy (ico);
gtk_widget_destroy (GTK_WIDGET (dialog));
+
+
}
static gint
@@ -93,7 +104,11 @@ simple_todo_editor (GncalTodo *todo, iCalObject *ico)
{
GtkWidget *dialog;
GtkWidget *hbox;
+ GtkWidget *due_box;
+ GtkWidget *due_label;
+ GtkWidget *due_entry;
GtkWidget *w;
+
GtkWidget *entry;
dialog = gnome_dialog_new (ico->new ? _("Create to-do item") : _("Edit to-do item"),
@@ -106,6 +121,12 @@ simple_todo_editor (GncalTodo *todo, iCalObject *ico)
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
+
+ due_box = gtk_hbox_new (FALSE, 4);
+ gtk_container_border_width (GTK_CONTAINER (due_box), 4);
+ gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), due_box, FALSE, FALSE, 0);
+ gtk_widget_show (due_box);
+
w = gtk_label_new (_("Summary:"));
gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
gtk_widget_show (w);
@@ -115,15 +136,28 @@ simple_todo_editor (GncalTodo *todo, iCalObject *ico)
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
gtk_widget_show (entry);
+
+ due_label = gtk_label_new (_("Due Date:"));
+ gtk_box_pack_start (GTK_BOX (due_box), due_label, FALSE, FALSE, 0);
+ gtk_widget_show (due_label);
+
+ due_entry = gtk_entry_new ();
+ due_entry = date_edit_new (ico->dtend, FALSE);
+ gtk_box_pack_start (GTK_BOX (due_box), due_entry, TRUE, TRUE, 0);
+ gtk_widget_show (due_entry);
+
+
ico->user_data = dialog;
gtk_object_set_user_data (GTK_OBJECT (dialog), ico);
gtk_object_set_data (GTK_OBJECT (dialog), "gncal_todo", todo);
gtk_object_set_data (GTK_OBJECT (dialog), "summary_entry", entry);
+ gtk_object_set_data (GTK_OBJECT (dialog), "due_date", due_entry);
gnome_dialog_button_connect (GNOME_DIALOG (dialog), 0, (GtkSignalFunc) ok_button, dialog);
gnome_dialog_button_connect (GNOME_DIALOG (dialog), 1, (GtkSignalFunc) cancel_button, dialog);
+
gtk_signal_connect (GTK_OBJECT (dialog), "delete_event",
(GtkSignalFunc) delete_event,
dialog);
@@ -172,6 +206,7 @@ delete_todo (GncalTodo *todo)
{
gnome_calendar_remove_object (todo->calendar, get_clist_selected_ico (todo->clist));
save_default_calendar (todo->calendar);
+
}
static void
@@ -192,6 +227,7 @@ delete_activated (GtkWidget *widget, GncalTodo *todo)
delete_todo (todo);
}
+
static void
clist_row_selected (GtkCList *clist, gint row, gint column, GdkEventButton *event, GncalTodo *todo)
{
@@ -227,13 +263,75 @@ clist_row_selected (GtkCList *clist, gint row, gint column, GdkEventButton *even
}
}
+/*
+ * once we get a call back stating that a column
+ * has been resized never ever automatically resize again
+ */
+void
+column_resized (GtkWidget *widget, GncalTodo *todo)
+{
+ /* disabling autoresize of columns */
+ if (todo_list_autoresize && !todo_list_redraw_in_progess){
+ todo_list_autoresize = 0;
+ }
+}
+
+/*
+ * restore the previously set settings for sorting the
+ * todo list
+ */
+static void
+init_column_sorting (GtkCList *clist)
+{
+
+ /* due date isn't shown so we can't sort by it */
+ if (todo_current_sort_column == 1 && ! todo_show_due_date)
+ todo_current_sort_column = 0;
+
+ clist->sort_type = todo_current_sort_type;
+ clist->sort_column = todo_current_sort_column;
+
+ gtk_clist_set_sort_column (clist, todo_current_sort_column);
+ gtk_clist_sort (clist);
+}
+
+static void
+todo_click_column (GtkCList *clist, gint column, gpointer data)
+{
+ if (column == clist->sort_column)
+ {
+ if (clist->sort_type == GTK_SORT_ASCENDING) {
+ clist->sort_type = GTK_SORT_DESCENDING;
+ todo_current_sort_type = GTK_SORT_DESCENDING;
+ } else {
+ clist->sort_type = GTK_SORT_ASCENDING;
+ todo_current_sort_type = GTK_SORT_ASCENDING;
+ }
+ }
+ else {
+ gtk_clist_set_sort_column (clist, column);
+ todo_current_sort_column = column;
+ }
+
+ gtk_clist_sort (clist);
+
+ /*
+ * save the sorting preferences cause I hate to have the user
+ * click twice
+ */
+
+ gnome_config_set_int("/calendar/Todo/sort_column", todo_current_sort_column);
+ gnome_config_set_int("/calendar/Todo/sort_type", todo_current_sort_type);
+ gnome_config_sync();
+}
+
static void
gncal_todo_init (GncalTodo *todo)
{
GtkWidget *w;
GtkWidget *sw;
GtkWidget *hbox;
-
+ gchar *titles[2] = {"Summary","Due Date"};
gtk_box_set_spacing (GTK_BOX (todo), 4);
/* Label */
@@ -250,13 +348,20 @@ gncal_todo_init (GncalTodo *todo)
gtk_box_pack_start (GTK_BOX (todo), sw, TRUE, TRUE, 0);
gtk_widget_show (sw);
- w = gtk_clist_new (1);
+
+ w = gtk_clist_new_with_titles(2, titles);
+
todo->clist = GTK_CLIST (w);
gtk_clist_set_selection_mode (todo->clist, GTK_SELECTION_BROWSE);
gtk_signal_connect (GTK_OBJECT (todo->clist), "select_row",
(GtkSignalFunc) clist_row_selected,
todo);
+ gtk_signal_connect (GTK_OBJECT (todo->clist), "resize_column",
+ (GtkSignalFunc) column_resized,
+ todo);
+ gtk_signal_connect (GTK_OBJECT (todo->clist), "click_column",
+ (GtkSignalFunc) todo_click_column, NULL);
gtk_container_add (GTK_CONTAINER (sw), w);
gtk_widget_show (w);
@@ -315,51 +420,143 @@ gncal_todo_new (GnomeCalendar *calendar)
return GTK_WIDGET (todo);
}
+
+
+char *
+convert_time_t_to_char (time_t t)
+{
+ char *buffer;
+ struct tm *tm;
+
+ buffer = g_malloc(15);
+ tm = localtime (&t);
+ strftime(buffer, 15, "%m/%d/%y", tm);
+
+ return buffer;
+}
+
+GtkStyle *
+make_overdue_todo_style(GncalTodo *todo)
+{
+ GtkStyle *overdue_style = NULL;
+ GdkColor overdue_color;
+
+ /*make the overdue color configurable */
+ overdue_color.red = color_props[COLOR_PROP_OVERDUE_TODO].r;
+ overdue_color.green = color_props[COLOR_PROP_OVERDUE_TODO].g;
+ overdue_color.blue = color_props[COLOR_PROP_OVERDUE_TODO].b;
+
+ overdue_style = gtk_style_copy (GTK_WIDGET (todo->clist)->style);
+ overdue_style->base[GTK_STATE_NORMAL] = overdue_color;
+
+ return overdue_style;
+}
+
static void
insert_in_clist (GncalTodo *todo, iCalObject *ico)
{
int i;
- char *text[1] = { ico->summary };
- iCalObject *row_ico;
+ char *text[2];
+ static GtkStyle *overdue_style = NULL;
+
+
+ /* setup the over due style if we haven't already, or it changed.*/
+ if (todo_style_changed || !overdue_style) {
+ /* free the old style cause its not needed anymore */
+ if(!overdue_style) g_free(overdue_style);
+ overdue_style = make_overdue_todo_style(todo);
+ todo_style_changed = 0;
+ }
- if (ico->priority == 0)
- i = gtk_clist_append (todo->clist, text); /* items with undefined priority go to the end of the list */
- else {
- /* Find proper place in clist to insert object. Objects are sorted by priority. */
+ text[0] = ico->summary;
- for (i = 0; i < todo->clist->rows; i++) {
- row_ico = gtk_clist_get_row_data (todo->clist, i);
+ /*
+ * right now column 0 will be the summary
+ * and column 1 will be the due date.
+ * WISH: this should be able to be changed on the fly
+ */
- if (ico->priority >= row_ico->priority)
- break;
- }
-
- gtk_clist_insert (todo->clist, i, text);
+ if(ico->dtend && todo_show_due_date) {
+ text[1] = convert_time_t_to_char(ico->dtend);
+ /* Append the data's pointer so later it can be properly freed */
+ todo->data_ptrs = g_slist_append (todo->data_ptrs, text[1]);
}
-
- /* Set the appropriate "done" icon and hook the object to the row */
-
+ else
+ text[1] = NULL;
+
+
+ i = gtk_clist_append (todo->clist, text);
+
gtk_clist_set_row_data (todo->clist, i, ico);
+
+ /*
+ * determine if the task is overdue..
+ * if so mark with the apropriate style
+ */
+ if(todo_due_date_overdue_highlight) {
+ if(ico->dtend < time(NULL))
+ gtk_clist_set_row_style(todo->clist, i, overdue_style);
+ }
+
+ /* keep the list in order */
+ gtk_clist_sort (todo->clist);
}
void
gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags)
{
- GList *list;
+ GList *list;
+ GSList *current_list;
g_return_if_fail (todo != NULL);
g_return_if_fail (GNCAL_IS_TODO (todo));
-
+
+ /*
+ * shut down the resize handler cause we are playing with the list.
+ * In otherwords turn off the event handler
+ */
+ todo_list_redraw_in_progess =1;
+
+ /* freeze the list */
gtk_clist_freeze (todo->clist);
+ init_column_sorting (todo->clist);
+
+ /*
+ * before here we have to free some of the memory that
+ * stores the due date, or else we have a memory leak.
+ * luckily all of the pointers are stored in todo->data_ptrs;
+ */
+
+ /* check on the columns that we should display */
+ /* check for due date */
+
+ if(todo_show_due_date)
+ gtk_clist_set_column_visibility (todo->clist, 1, 1);
+ else
+ gtk_clist_set_column_visibility (todo->clist, 1, 0);
+
+ /* free the memory locations that were used in the previous display */
+ for (current_list = todo->data_ptrs; current_list != NULL; current_list = g_slist_next(current_list)){
+ g_free(current_list->data);
+ }
+
+ /* free the list and clear out the pointer */
+ g_slist_free(todo->data_ptrs);
+ todo->data_ptrs = NULL;
gtk_clist_clear (todo->clist);
for (list = todo->calendar->cal->todo; list; list = list->next)
insert_in_clist (todo, list->data);
- gtk_clist_thaw (todo->clist);
+ /* if we are autoresizing then do it now */
+ if(todo_list_autoresize && todo->clist->rows != 0)
+ gtk_clist_columns_autosize (todo->clist);
+ gtk_clist_thaw (todo->clist);
+
gtk_widget_set_sensitive (todo->edit_button, (todo->clist->selection != NULL));
gtk_widget_set_sensitive (todo->delete_button, (todo->clist->selection != NULL));
+ todo_list_redraw_in_progess = 0;
}
diff --git a/calendar/gncal-todo.h b/calendar/gncal-todo.h
index cb32c25421..51cfadea3f 100644
--- a/calendar/gncal-todo.h
+++ b/calendar/gncal-todo.h
@@ -34,6 +34,9 @@ struct _GncalTodo {
GtkWidget *edit_button;
GtkWidget *delete_button;
+ GSList *data_ptrs;
+
+
};
struct _GncalTodoClass {
diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c
index 5b59cb379c..f589d0fe28 100644
--- a/calendar/gnome-cal.c
+++ b/calendar/gnome-cal.c
@@ -483,4 +483,20 @@ gnome_calendar_colors_changed (GnomeCalendar *gcal)
month_view_colors_changed (MONTH_VIEW (gcal->month_view));
year_view_colors_changed (YEAR_VIEW (gcal->year_view));
+ todo_style_changed = 1;
+ todo_list_properties_changed (GNCAL_DAY_PANEL (gcal->day_view));
}
+
+void
+gnome_calendar_todo_properties_changed (GnomeCalendar *gcal)
+{
+ g_return_if_fail (gcal != NULL);
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
+
+ /* FIXME: add day and week view when they are done */
+
+ todo_style_changed = 1;
+ todo_list_properties_changed (GNCAL_DAY_PANEL (gcal->day_view));
+}
+
+
diff --git a/calendar/gnome-cal.h b/calendar/gnome-cal.h
index ab4f5ff304..3939becc52 100644
--- a/calendar/gnome-cal.h
+++ b/calendar/gnome-cal.h
@@ -65,8 +65,13 @@ void gnome_calendar_object_changed (GnomeCalendar *gcal,
/* Notifies the calendar that the time format has changed and it must update all its views */
void gnome_calendar_time_format_changed (GnomeCalendar *gcal);
-/* Notifies the calendar that the colors have changed and it must update all its views */
-void gnome_calendar_colors_changed (GnomeCalendar *gcal);
+/* Notifies the calendar that the todo list properties have changed and its time to update the views */
+void
+gnome_calendar_colors_changed (GnomeCalendar *gcal);
+
+/* Notifies the calendar that the todo list properties have changed and its time to update the views */
+void
+gnome_calendar_todo_properties_changed (GnomeCalendar *gcal);
END_GNOME_DECLS
diff --git a/calendar/goto.c b/calendar/goto.c
index c371b74db4..20479889aa 100644
--- a/calendar/goto.c
+++ b/calendar/goto.c
@@ -254,12 +254,12 @@ goto_dialog (GnomeCalendar *gcal)
GtkWidget *hbox;
GtkWidget *w;
GtkWidget *days;
- struct tm tm;
+ struct tm *tm;
gnome_calendar = gcal;
current_index = -1;
- tm = *localtime (&gnome_calendar->current_display);
+ tm = localtime (&gnome_calendar->current_display);
goto_win = gnome_dialog_new (_("Go to date"),
GNOME_STOCK_BUTTON_CANCEL,
@@ -282,17 +282,17 @@ goto_dialog (GnomeCalendar *gcal)
* month_item to be created.
*/
- days = create_days (tm.tm_mday, tm.tm_mon, tm.tm_year + 1900);
+ days = create_days (tm->tm_mday, tm->tm_mon, tm->tm_year + 1900);
/* Year */
- w = create_year (tm.tm_year + 1900);
+ w = create_year (tm->tm_year + 1900);
gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
gtk_widget_show (w);
/* Month */
- w = create_months (tm.tm_mon);
+ w = create_months (tm->tm_mon);
gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
gtk_widget_show (w);
diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c
index 15a33d92ea..72d48617d0 100644
--- a/calendar/gui/eventedit.c
+++ b/calendar/gui/eventedit.c
@@ -210,7 +210,7 @@ set_all_day (GtkToggleButton *toggle, EventEditor *ee)
}
/* Convenience function to create a properly-configured date editor widget */
-static GtkWidget *
+GtkWidget *
date_edit_new (time_t the_time, int show_time)
{
return gnome_date_edit_new_flags (the_time,
diff --git a/calendar/gui/eventedit.h b/calendar/gui/eventedit.h
index 15ef540333..4d605892dd 100644
--- a/calendar/gui/eventedit.h
+++ b/calendar/gui/eventedit.h
@@ -76,7 +76,7 @@ GtkWidget *event_editor_new (GnomeCalendar *owner, iCalObject *);
*/
void event_editor_new_whole_day (GnomeCalendar *owner, time_t day);
-
+GtkWidget *date_edit_new (time_t the_time, int show_time);
END_GNOME_DECLS
diff --git a/calendar/gui/gncal-day-panel.c b/calendar/gui/gncal-day-panel.c
index 518babfa1a..1eb8941019 100644
--- a/calendar/gui/gncal-day-panel.c
+++ b/calendar/gui/gncal-day-panel.c
@@ -266,3 +266,15 @@ gncal_day_panel_time_format_changed (GncalDayPanel *dpanel)
: (dpanel->gtk_calendar->display_flags
& ~GTK_CALENDAR_WEEK_START_MONDAY)));
}
+
+void
+todo_list_properties_changed (GncalDayPanel *dpanel)
+{
+ g_return_if_fail (dpanel != NULL);
+ g_return_if_fail (GNCAL_IS_DAY_PANEL (dpanel));
+
+ gncal_todo_update (dpanel->todo, NULL, 0);
+}
+
+
+
diff --git a/calendar/gui/gncal-day-panel.h b/calendar/gui/gncal-day-panel.h
index 48ba6f38b1..6bf8768d9c 100644
--- a/calendar/gui/gncal-day-panel.h
+++ b/calendar/gui/gncal-day-panel.h
@@ -56,6 +56,9 @@ void gncal_day_panel_update (GncalDayPanel *dpanel, iCalObject *ico, int flags);
void gncal_day_panel_set (GncalDayPanel *dpanel, time_t start_of_day);
void gncal_day_panel_time_format_changed (GncalDayPanel *dpanel);
+void todo_list_properties_changed (GncalDayPanel *dpanel);
+
+
END_GNOME_DECLS
diff --git a/calendar/gui/gncal-todo.c b/calendar/gui/gncal-todo.c
index a78bd9432b..4c48fe1807 100644
--- a/calendar/gui/gncal-todo.c
+++ b/calendar/gui/gncal-todo.c
@@ -11,8 +11,17 @@
#include "gncal-todo.h"
#include "main.h"
#include "popup-menu.h"
+#include "eventedit.h"
+int todo_show_due_date = 0;
+int todo_due_date_overdue_highlight = 0;
+char *todo_overdue_font_text;
+gint todo_current_sort_column = 0;
+gint todo_current_sort_type = GTK_SORT_ASCENDING;
+gboolean todo_style_changed =0;
+gboolean todo_list_autoresize = 1;
+gboolean todo_list_redraw_in_progess = 0;
static void gncal_todo_init (GncalTodo *todo);
@@ -44,15 +53,15 @@ ok_button (GtkWidget *widget, GnomeDialog *dialog)
iCalObject *ico;
GncalTodo *todo;
GtkEntry *entry;
-
+ GnomeDateEdit *due_date;
ico = gtk_object_get_user_data (GTK_OBJECT (dialog));
todo = GNCAL_TODO (gtk_object_get_data (GTK_OBJECT (dialog), "gncal_todo"));
entry = GTK_ENTRY (gtk_object_get_data (GTK_OBJECT (dialog), "summary_entry"));
-
+ due_date = GNOME_DATE_EDIT (gtk_object_get_data(GTK_OBJECT(dialog), "due_date"));
if (ico->summary)
g_free (ico->summary);
-
+ ico->dtend = gnome_date_edit_get_date (due_date);
ico->summary = g_strdup (gtk_entry_get_text (entry));
ico->user_data = NULL;
@@ -79,6 +88,8 @@ cancel_button (GtkWidget *widget, GnomeDialog *dialog)
ical_object_destroy (ico);
gtk_widget_destroy (GTK_WIDGET (dialog));
+
+
}
static gint
@@ -93,7 +104,11 @@ simple_todo_editor (GncalTodo *todo, iCalObject *ico)
{
GtkWidget *dialog;
GtkWidget *hbox;
+ GtkWidget *due_box;
+ GtkWidget *due_label;
+ GtkWidget *due_entry;
GtkWidget *w;
+
GtkWidget *entry;
dialog = gnome_dialog_new (ico->new ? _("Create to-do item") : _("Edit to-do item"),
@@ -106,6 +121,12 @@ simple_todo_editor (GncalTodo *todo, iCalObject *ico)
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
+
+ due_box = gtk_hbox_new (FALSE, 4);
+ gtk_container_border_width (GTK_CONTAINER (due_box), 4);
+ gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), due_box, FALSE, FALSE, 0);
+ gtk_widget_show (due_box);
+
w = gtk_label_new (_("Summary:"));
gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0);
gtk_widget_show (w);
@@ -115,15 +136,28 @@ simple_todo_editor (GncalTodo *todo, iCalObject *ico)
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
gtk_widget_show (entry);
+
+ due_label = gtk_label_new (_("Due Date:"));
+ gtk_box_pack_start (GTK_BOX (due_box), due_label, FALSE, FALSE, 0);
+ gtk_widget_show (due_label);
+
+ due_entry = gtk_entry_new ();
+ due_entry = date_edit_new (ico->dtend, FALSE);
+ gtk_box_pack_start (GTK_BOX (due_box), due_entry, TRUE, TRUE, 0);
+ gtk_widget_show (due_entry);
+
+
ico->user_data = dialog;
gtk_object_set_user_data (GTK_OBJECT (dialog), ico);
gtk_object_set_data (GTK_OBJECT (dialog), "gncal_todo", todo);
gtk_object_set_data (GTK_OBJECT (dialog), "summary_entry", entry);
+ gtk_object_set_data (GTK_OBJECT (dialog), "due_date", due_entry);
gnome_dialog_button_connect (GNOME_DIALOG (dialog), 0, (GtkSignalFunc) ok_button, dialog);
gnome_dialog_button_connect (GNOME_DIALOG (dialog), 1, (GtkSignalFunc) cancel_button, dialog);
+
gtk_signal_connect (GTK_OBJECT (dialog), "delete_event",
(GtkSignalFunc) delete_event,
dialog);
@@ -172,6 +206,7 @@ delete_todo (GncalTodo *todo)
{
gnome_calendar_remove_object (todo->calendar, get_clist_selected_ico (todo->clist));
save_default_calendar (todo->calendar);
+
}
static void
@@ -192,6 +227,7 @@ delete_activated (GtkWidget *widget, GncalTodo *todo)
delete_todo (todo);
}
+
static void
clist_row_selected (GtkCList *clist, gint row, gint column, GdkEventButton *event, GncalTodo *todo)
{
@@ -227,13 +263,75 @@ clist_row_selected (GtkCList *clist, gint row, gint column, GdkEventButton *even
}
}
+/*
+ * once we get a call back stating that a column
+ * has been resized never ever automatically resize again
+ */
+void
+column_resized (GtkWidget *widget, GncalTodo *todo)
+{
+ /* disabling autoresize of columns */
+ if (todo_list_autoresize && !todo_list_redraw_in_progess){
+ todo_list_autoresize = 0;
+ }
+}
+
+/*
+ * restore the previously set settings for sorting the
+ * todo list
+ */
+static void
+init_column_sorting (GtkCList *clist)
+{
+
+ /* due date isn't shown so we can't sort by it */
+ if (todo_current_sort_column == 1 && ! todo_show_due_date)
+ todo_current_sort_column = 0;
+
+ clist->sort_type = todo_current_sort_type;
+ clist->sort_column = todo_current_sort_column;
+
+ gtk_clist_set_sort_column (clist, todo_current_sort_column);
+ gtk_clist_sort (clist);
+}
+
+static void
+todo_click_column (GtkCList *clist, gint column, gpointer data)
+{
+ if (column == clist->sort_column)
+ {
+ if (clist->sort_type == GTK_SORT_ASCENDING) {
+ clist->sort_type = GTK_SORT_DESCENDING;
+ todo_current_sort_type = GTK_SORT_DESCENDING;
+ } else {
+ clist->sort_type = GTK_SORT_ASCENDING;
+ todo_current_sort_type = GTK_SORT_ASCENDING;
+ }
+ }
+ else {
+ gtk_clist_set_sort_column (clist, column);
+ todo_current_sort_column = column;
+ }
+
+ gtk_clist_sort (clist);
+
+ /*
+ * save the sorting preferences cause I hate to have the user
+ * click twice
+ */
+
+ gnome_config_set_int("/calendar/Todo/sort_column", todo_current_sort_column);
+ gnome_config_set_int("/calendar/Todo/sort_type", todo_current_sort_type);
+ gnome_config_sync();
+}
+
static void
gncal_todo_init (GncalTodo *todo)
{
GtkWidget *w;
GtkWidget *sw;
GtkWidget *hbox;
-
+ gchar *titles[2] = {"Summary","Due Date"};
gtk_box_set_spacing (GTK_BOX (todo), 4);
/* Label */
@@ -250,13 +348,20 @@ gncal_todo_init (GncalTodo *todo)
gtk_box_pack_start (GTK_BOX (todo), sw, TRUE, TRUE, 0);
gtk_widget_show (sw);
- w = gtk_clist_new (1);
+
+ w = gtk_clist_new_with_titles(2, titles);
+
todo->clist = GTK_CLIST (w);
gtk_clist_set_selection_mode (todo->clist, GTK_SELECTION_BROWSE);
gtk_signal_connect (GTK_OBJECT (todo->clist), "select_row",
(GtkSignalFunc) clist_row_selected,
todo);
+ gtk_signal_connect (GTK_OBJECT (todo->clist), "resize_column",
+ (GtkSignalFunc) column_resized,
+ todo);
+ gtk_signal_connect (GTK_OBJECT (todo->clist), "click_column",
+ (GtkSignalFunc) todo_click_column, NULL);
gtk_container_add (GTK_CONTAINER (sw), w);
gtk_widget_show (w);
@@ -315,51 +420,143 @@ gncal_todo_new (GnomeCalendar *calendar)
return GTK_WIDGET (todo);
}
+
+
+char *
+convert_time_t_to_char (time_t t)
+{
+ char *buffer;
+ struct tm *tm;
+
+ buffer = g_malloc(15);
+ tm = localtime (&t);
+ strftime(buffer, 15, "%m/%d/%y", tm);
+
+ return buffer;
+}
+
+GtkStyle *
+make_overdue_todo_style(GncalTodo *todo)
+{
+ GtkStyle *overdue_style = NULL;
+ GdkColor overdue_color;
+
+ /*make the overdue color configurable */
+ overdue_color.red = color_props[COLOR_PROP_OVERDUE_TODO].r;
+ overdue_color.green = color_props[COLOR_PROP_OVERDUE_TODO].g;
+ overdue_color.blue = color_props[COLOR_PROP_OVERDUE_TODO].b;
+
+ overdue_style = gtk_style_copy (GTK_WIDGET (todo->clist)->style);
+ overdue_style->base[GTK_STATE_NORMAL] = overdue_color;
+
+ return overdue_style;
+}
+
static void
insert_in_clist (GncalTodo *todo, iCalObject *ico)
{
int i;
- char *text[1] = { ico->summary };
- iCalObject *row_ico;
+ char *text[2];
+ static GtkStyle *overdue_style = NULL;
+
+
+ /* setup the over due style if we haven't already, or it changed.*/
+ if (todo_style_changed || !overdue_style) {
+ /* free the old style cause its not needed anymore */
+ if(!overdue_style) g_free(overdue_style);
+ overdue_style = make_overdue_todo_style(todo);
+ todo_style_changed = 0;
+ }
- if (ico->priority == 0)
- i = gtk_clist_append (todo->clist, text); /* items with undefined priority go to the end of the list */
- else {
- /* Find proper place in clist to insert object. Objects are sorted by priority. */
+ text[0] = ico->summary;
- for (i = 0; i < todo->clist->rows; i++) {
- row_ico = gtk_clist_get_row_data (todo->clist, i);
+ /*
+ * right now column 0 will be the summary
+ * and column 1 will be the due date.
+ * WISH: this should be able to be changed on the fly
+ */
- if (ico->priority >= row_ico->priority)
- break;
- }
-
- gtk_clist_insert (todo->clist, i, text);
+ if(ico->dtend && todo_show_due_date) {
+ text[1] = convert_time_t_to_char(ico->dtend);
+ /* Append the data's pointer so later it can be properly freed */
+ todo->data_ptrs = g_slist_append (todo->data_ptrs, text[1]);
}
-
- /* Set the appropriate "done" icon and hook the object to the row */
-
+ else
+ text[1] = NULL;
+
+
+ i = gtk_clist_append (todo->clist, text);
+
gtk_clist_set_row_data (todo->clist, i, ico);
+
+ /*
+ * determine if the task is overdue..
+ * if so mark with the apropriate style
+ */
+ if(todo_due_date_overdue_highlight) {
+ if(ico->dtend < time(NULL))
+ gtk_clist_set_row_style(todo->clist, i, overdue_style);
+ }
+
+ /* keep the list in order */
+ gtk_clist_sort (todo->clist);
}
void
gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags)
{
- GList *list;
+ GList *list;
+ GSList *current_list;
g_return_if_fail (todo != NULL);
g_return_if_fail (GNCAL_IS_TODO (todo));
-
+
+ /*
+ * shut down the resize handler cause we are playing with the list.
+ * In otherwords turn off the event handler
+ */
+ todo_list_redraw_in_progess =1;
+
+ /* freeze the list */
gtk_clist_freeze (todo->clist);
+ init_column_sorting (todo->clist);
+
+ /*
+ * before here we have to free some of the memory that
+ * stores the due date, or else we have a memory leak.
+ * luckily all of the pointers are stored in todo->data_ptrs;
+ */
+
+ /* check on the columns that we should display */
+ /* check for due date */
+
+ if(todo_show_due_date)
+ gtk_clist_set_column_visibility (todo->clist, 1, 1);
+ else
+ gtk_clist_set_column_visibility (todo->clist, 1, 0);
+
+ /* free the memory locations that were used in the previous display */
+ for (current_list = todo->data_ptrs; current_list != NULL; current_list = g_slist_next(current_list)){
+ g_free(current_list->data);
+ }
+
+ /* free the list and clear out the pointer */
+ g_slist_free(todo->data_ptrs);
+ todo->data_ptrs = NULL;
gtk_clist_clear (todo->clist);
for (list = todo->calendar->cal->todo; list; list = list->next)
insert_in_clist (todo, list->data);
- gtk_clist_thaw (todo->clist);
+ /* if we are autoresizing then do it now */
+ if(todo_list_autoresize && todo->clist->rows != 0)
+ gtk_clist_columns_autosize (todo->clist);
+ gtk_clist_thaw (todo->clist);
+
gtk_widget_set_sensitive (todo->edit_button, (todo->clist->selection != NULL));
gtk_widget_set_sensitive (todo->delete_button, (todo->clist->selection != NULL));
+ todo_list_redraw_in_progess = 0;
}
diff --git a/calendar/gui/gncal-todo.h b/calendar/gui/gncal-todo.h
index cb32c25421..51cfadea3f 100644
--- a/calendar/gui/gncal-todo.h
+++ b/calendar/gui/gncal-todo.h
@@ -34,6 +34,9 @@ struct _GncalTodo {
GtkWidget *edit_button;
GtkWidget *delete_button;
+ GSList *data_ptrs;
+
+
};
struct _GncalTodoClass {
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 5b59cb379c..f589d0fe28 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -483,4 +483,20 @@ gnome_calendar_colors_changed (GnomeCalendar *gcal)
month_view_colors_changed (MONTH_VIEW (gcal->month_view));
year_view_colors_changed (YEAR_VIEW (gcal->year_view));
+ todo_style_changed = 1;
+ todo_list_properties_changed (GNCAL_DAY_PANEL (gcal->day_view));
}
+
+void
+gnome_calendar_todo_properties_changed (GnomeCalendar *gcal)
+{
+ g_return_if_fail (gcal != NULL);
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
+
+ /* FIXME: add day and week view when they are done */
+
+ todo_style_changed = 1;
+ todo_list_properties_changed (GNCAL_DAY_PANEL (gcal->day_view));
+}
+
+
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index ab4f5ff304..3939becc52 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -65,8 +65,13 @@ void gnome_calendar_object_changed (GnomeCalendar *gcal,
/* Notifies the calendar that the time format has changed and it must update all its views */
void gnome_calendar_time_format_changed (GnomeCalendar *gcal);
-/* Notifies the calendar that the colors have changed and it must update all its views */
-void gnome_calendar_colors_changed (GnomeCalendar *gcal);
+/* Notifies the calendar that the todo list properties have changed and its time to update the views */
+void
+gnome_calendar_colors_changed (GnomeCalendar *gcal);
+
+/* Notifies the calendar that the todo list properties have changed and its time to update the views */
+void
+gnome_calendar_todo_properties_changed (GnomeCalendar *gcal);
END_GNOME_DECLS
diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c
index c371b74db4..20479889aa 100644
--- a/calendar/gui/goto.c
+++ b/calendar/gui/goto.c
@@ -254,12 +254,12 @@ goto_dialog (GnomeCalendar *gcal)
GtkWidget *hbox;
GtkWidget *w;
GtkWidget *days;
- struct tm tm;
+ struct tm *tm;
gnome_calendar = gcal;
current_index = -1;
- tm = *localtime (&gnome_calendar->current_display);
+ tm = localtime (&gnome_calendar->current_display);
goto_win = gnome_dialog_new (_("Go to date"),
GNOME_STOCK_BUTTON_CANCEL,
@@ -282,17 +282,17 @@ goto_dialog (GnomeCalendar *gcal)
* month_item to be created.
*/
- days = create_days (tm.tm_mday, tm.tm_mon, tm.tm_year + 1900);
+ days = create_days (tm->tm_mday, tm->tm_mon, tm->tm_year + 1900);
/* Year */
- w = create_year (tm.tm_year + 1900);
+ w = create_year (tm->tm_year + 1900);
gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
gtk_widget_show (w);
/* Month */
- w = create_months (tm.tm_mon);
+ w = create_months (tm->tm_mon);
gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
gtk_widget_show (w);
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
index 0d572277ba..6818eb8d23 100644
--- a/calendar/gui/main.c
+++ b/calendar/gui/main.c
@@ -56,7 +56,8 @@ struct color_prop color_props[] = {
{ 0xfc1e, 0xf87f, 0x5f80, N_("Appointments:"), "/calendar/Colors/mark_bg" },
{ 0xd364, 0xc6b7, 0x7969, N_("Highlighted day:"), "/calendar/Colors/prelight_bg" },
{ 0x01f0, 0x01f0, 0x01f0, N_("Day numbers:"), "/calendar/Colors/day_fg" },
- { 0x0000, 0x0000, 0xffff, N_("Current day's number:"), "/calendar/Colors/current_fg" }
+ { 0x0000, 0x0000, 0xffff, N_("Current day's number:"), "/calendar/Colors/current_fg" },
+ { 0x0000, 0xaaaa, 0xaaaa, N_("Overdue TODO item"), "/calendar/Coloirs/todo_overdue" }
};
/* Number of active calendars */
@@ -134,6 +135,17 @@ init_calendar (void)
g_free (color);
}
+ /* read todolist settings */
+
+ todo_show_due_date = gnome_config_get_bool("/calendar/Todo/show_due_date");
+
+ todo_due_date_overdue_highlight = gnome_config_get_bool("/calendar/Todo/highlight_overdue_tasks");
+
+ todo_current_sort_column = gnome_config_get_int("/calendar/Todo/sort_column");
+
+ todo_current_sort_type = gnome_config_get_int("/calendar/Todo/sort_type");
+
+
/* Done */
gnome_config_pop_prefix ();
@@ -223,6 +235,17 @@ colors_changed (void)
gnome_calendar_colors_changed (GNOME_CALENDAR (l->data));
}
+void
+todo_properties_changed(void)
+{
+ GList *l;
+
+ for (l = all_calendars; l; l = l->next)
+ gnome_calendar_todo_properties_changed (GNOME_CALENDAR (l->data));
+}
+
+
+
static void
quit_cmd (void)
{
diff --git a/calendar/gui/main.h b/calendar/gui/main.h
index 476349f3aa..845fae6f35 100644
--- a/calendar/gui/main.h
+++ b/calendar/gui/main.h
@@ -8,6 +8,7 @@ extern char *user_name;
extern int am_pm_flag;
extern int week_starts_on_monday;
+
/* This enum and the following array define the color preferences */
typedef enum {
@@ -18,6 +19,7 @@ typedef enum {
COLOR_PROP_PRELIGHT_DAY_BG, /* Background color for prelighted day */
COLOR_PROP_DAY_FG, /* Color for day numbers */
COLOR_PROP_CURRENT_DAY_FG, /* Color for current day's number */
+ COLOR_PROP_OVERDUE_TODO,
COLOR_PROP_LAST /* Number of color properties */
} ColorProp;
@@ -31,6 +33,17 @@ struct color_prop {
extern struct color_prop color_props[];
+
+/* todo preferences */
+extern int todo_show_due_date;
+extern int todo_due_date_overdue_highlight;
+extern char *todo_overdue_font_text;
+extern struct color_prop todo_overdue_highlight_color;
+extern gboolean todo_style_changed;
+extern gint todo_current_sort_column;
+extern gint todo_current_sort_type;
+
+
/* Creates and runs the preferences dialog box */
void properties (GtkWidget *toplevel);
@@ -42,6 +55,9 @@ void time_format_changed (void);
/* Asks for all the month items' colors to be reset */
void colors_changed (void);
+/* Asks for all todo lists to reflect the accurate properties */
+void todo_properties_changed(void);
+
/* Creates and runs the Go-to date dialog */
void goto_dialog (GnomeCalendar *gcal);
diff --git a/calendar/gui/prop.c b/calendar/gui/prop.c
index 2f24f4551e..dd5130fa1a 100644
--- a/calendar/gui/prop.c
+++ b/calendar/gui/prop.c
@@ -20,7 +20,8 @@
/* These specify the page numbers in the preferences notebook */
enum {
PROP_TIME_DISPLAY,
- PROP_COLORS
+ PROP_COLORS,
+ PROP_TODO
};
static GtkWidget *prop_win; /* The preferences dialog */
@@ -41,7 +42,9 @@ static GtkWidget *end_items[24]; /* Menu items for end of day menu */
static GtkWidget *color_pickers[COLOR_PROP_LAST];
static GnomeCanvasItem *month_item;
-
+/* Widgets for the todo page */
+static GtkWidget *due_date_show_button;
+static GtkWidget *due_date_overdue_highlight;
/* Callback used when the property box is closed -- just sets the prop_win variable to null. */
static int
prop_cancel (void)
@@ -106,6 +109,24 @@ prop_apply_colors (void)
gnome_config_sync ();
colors_changed ();
}
+/* Applies the settings in the todo page (FIX THIS IF ITS NOT WRITTEN) */
+static void
+prop_apply_todo(void)
+{
+ todo_show_due_date = GTK_TOGGLE_BUTTON (due_date_show_button)->active;
+ todo_due_date_overdue_highlight = GTK_TOGGLE_BUTTON (due_date_overdue_highlight)->active;
+
+ /* storing the values */
+ gnome_config_set_bool("/calendar/Todo/show_due_date", todo_show_due_date);
+ gnome_config_set_bool("/calendar/Todo/highlight_overdue_tasks", todo_due_date_overdue_highlight);
+
+ /* need to sync our config changes. */
+ gnome_config_sync ();
+
+ /* apply the current changes */
+ todo_properties_changed();
+}
+
/* Callback used when the Apply button is clicked. */
static void
@@ -120,6 +141,10 @@ prop_apply (GtkWidget *w, int page)
prop_apply_colors ();
break;
+ case PROP_TODO:
+ prop_apply_todo();
+ break;
+
case -1:
break;
@@ -498,6 +523,103 @@ create_colors_page (void)
}
+
+static void
+set_todo_page_options(void)
+{
+ if(!GTK_TOGGLE_BUTTON (due_date_show_button)->active) {
+ /* disable everything */
+ gtk_widget_set_sensitive(due_date_overdue_highlight,0);
+ }
+ else
+ {
+ gtk_widget_set_sensitive(due_date_overdue_highlight,1);
+ }
+
+ while (gtk_events_pending ())
+ gtk_main_iteration ();
+}
+
+static void
+todo_option_set (void)
+{
+ prop_changed ();
+ set_todo_page_options ();
+}
+
+/* Creates the colors page in the preferences dialog */
+static GtkWidget *
+build_list_options_frame(void)
+{
+ GtkWidget *frame;
+ GtkWidget *vbox;
+ frame = gtk_frame_new (_("Show on TODO List:"));
+
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (frame), vbox);
+
+ due_date_show_button = gtk_check_button_new_with_label (_("Summary"));
+ due_date_show_button = gtk_check_button_new_with_label (_("Due Date"));
+
+ gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(due_date_show_button), todo_show_due_date);
+ gtk_signal_connect (GTK_OBJECT(due_date_show_button),
+ "clicked",
+ (GtkSignalFunc) todo_option_set,
+ NULL);
+ gtk_box_pack_start (GTK_BOX (vbox), due_date_show_button, FALSE, FALSE, 0);
+ return frame;
+}
+static GtkWidget *
+build_style_list_options_frame(void)
+{
+ GtkWidget *frame;
+ GtkWidget *vbox;
+
+ frame = gtk_frame_new (_("TODO List style options:"));
+
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (frame), vbox);
+
+ due_date_overdue_highlight = gtk_check_button_new_with_label (_("Highlight overdue items"));
+
+ gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(due_date_overdue_highlight), todo_due_date_overdue_highlight);
+ gtk_signal_connect (GTK_OBJECT(due_date_overdue_highlight),
+ "clicked",
+ (GtkSignalFunc) todo_option_set,
+ NULL);
+ gtk_box_pack_start (GTK_BOX (vbox), due_date_overdue_highlight, FALSE, FALSE, 0);
+ return frame;
+}
+static void
+create_todo_page (void)
+{
+ GtkWidget *frame;
+ GtkWidget *main_box;
+ GtkWidget *hbox;
+
+
+ frame = gtk_frame_new (_("Todo List Properties"));
+ gtk_container_set_border_width (GTK_CONTAINER (frame), GNOME_PAD_SMALL);
+ gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), frame,
+ gtk_label_new (_("Todo List")));
+
+ /* first vbox*/
+ main_box = gtk_vbox_new(FALSE, GNOME_PAD);
+ gtk_container_set_border_width (GTK_CONTAINER (main_box), GNOME_PAD_SMALL);
+ gtk_container_add (GTK_CONTAINER (frame), main_box);
+
+
+ /* first hbox*/
+ hbox = gtk_hbox_new (FALSE, GNOME_PAD);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL);
+ gtk_container_add (GTK_CONTAINER (main_box), hbox);
+
+ gtk_box_pack_start (GTK_BOX(hbox), build_list_options_frame(), FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(hbox), build_style_list_options_frame(), FALSE, FALSE, 0);
+
+ set_todo_page_options();
+}
+
/* Creates and displays the preferences dialog for the whole application */
void
properties (GtkWidget *toplevel)
@@ -515,6 +637,7 @@ properties (GtkWidget *toplevel)
create_time_display_page ();
create_colors_page ();
+ create_todo_page();
gtk_signal_connect (GTK_OBJECT (prop_win), "destroy",
(GtkSignalFunc) prop_cancel, NULL);
diff --git a/calendar/main.c b/calendar/main.c
index 0d572277ba..6818eb8d23 100644
--- a/calendar/main.c
+++ b/calendar/main.c
@@ -56,7 +56,8 @@ struct color_prop color_props[] = {
{ 0xfc1e, 0xf87f, 0x5f80, N_("Appointments:"), "/calendar/Colors/mark_bg" },
{ 0xd364, 0xc6b7, 0x7969, N_("Highlighted day:"), "/calendar/Colors/prelight_bg" },
{ 0x01f0, 0x01f0, 0x01f0, N_("Day numbers:"), "/calendar/Colors/day_fg" },
- { 0x0000, 0x0000, 0xffff, N_("Current day's number:"), "/calendar/Colors/current_fg" }
+ { 0x0000, 0x0000, 0xffff, N_("Current day's number:"), "/calendar/Colors/current_fg" },
+ { 0x0000, 0xaaaa, 0xaaaa, N_("Overdue TODO item"), "/calendar/Coloirs/todo_overdue" }
};
/* Number of active calendars */
@@ -134,6 +135,17 @@ init_calendar (void)
g_free (color);
}
+ /* read todolist settings */
+
+ todo_show_due_date = gnome_config_get_bool("/calendar/Todo/show_due_date");
+
+ todo_due_date_overdue_highlight = gnome_config_get_bool("/calendar/Todo/highlight_overdue_tasks");
+
+ todo_current_sort_column = gnome_config_get_int("/calendar/Todo/sort_column");
+
+ todo_current_sort_type = gnome_config_get_int("/calendar/Todo/sort_type");
+
+
/* Done */
gnome_config_pop_prefix ();
@@ -223,6 +235,17 @@ colors_changed (void)
gnome_calendar_colors_changed (GNOME_CALENDAR (l->data));
}
+void
+todo_properties_changed(void)
+{
+ GList *l;
+
+ for (l = all_calendars; l; l = l->next)
+ gnome_calendar_todo_properties_changed (GNOME_CALENDAR (l->data));
+}
+
+
+
static void
quit_cmd (void)
{
diff --git a/calendar/main.h b/calendar/main.h
index 476349f3aa..845fae6f35 100644
--- a/calendar/main.h
+++ b/calendar/main.h
@@ -8,6 +8,7 @@ extern char *user_name;
extern int am_pm_flag;
extern int week_starts_on_monday;
+
/* This enum and the following array define the color preferences */
typedef enum {
@@ -18,6 +19,7 @@ typedef enum {
COLOR_PROP_PRELIGHT_DAY_BG, /* Background color for prelighted day */
COLOR_PROP_DAY_FG, /* Color for day numbers */
COLOR_PROP_CURRENT_DAY_FG, /* Color for current day's number */
+ COLOR_PROP_OVERDUE_TODO,
COLOR_PROP_LAST /* Number of color properties */
} ColorProp;
@@ -31,6 +33,17 @@ struct color_prop {
extern struct color_prop color_props[];
+
+/* todo preferences */
+extern int todo_show_due_date;
+extern int todo_due_date_overdue_highlight;
+extern char *todo_overdue_font_text;
+extern struct color_prop todo_overdue_highlight_color;
+extern gboolean todo_style_changed;
+extern gint todo_current_sort_column;
+extern gint todo_current_sort_type;
+
+
/* Creates and runs the preferences dialog box */
void properties (GtkWidget *toplevel);
@@ -42,6 +55,9 @@ void time_format_changed (void);
/* Asks for all the month items' colors to be reset */
void colors_changed (void);
+/* Asks for all todo lists to reflect the accurate properties */
+void todo_properties_changed(void);
+
/* Creates and runs the Go-to date dialog */
void goto_dialog (GnomeCalendar *gcal);
diff --git a/calendar/prop.c b/calendar/prop.c
index 2f24f4551e..dd5130fa1a 100644
--- a/calendar/prop.c
+++ b/calendar/prop.c
@@ -20,7 +20,8 @@
/* These specify the page numbers in the preferences notebook */
enum {
PROP_TIME_DISPLAY,
- PROP_COLORS
+ PROP_COLORS,
+ PROP_TODO
};
static GtkWidget *prop_win; /* The preferences dialog */
@@ -41,7 +42,9 @@ static GtkWidget *end_items[24]; /* Menu items for end of day menu */
static GtkWidget *color_pickers[COLOR_PROP_LAST];
static GnomeCanvasItem *month_item;
-
+/* Widgets for the todo page */
+static GtkWidget *due_date_show_button;
+static GtkWidget *due_date_overdue_highlight;
/* Callback used when the property box is closed -- just sets the prop_win variable to null. */
static int
prop_cancel (void)
@@ -106,6 +109,24 @@ prop_apply_colors (void)
gnome_config_sync ();
colors_changed ();
}
+/* Applies the settings in the todo page (FIX THIS IF ITS NOT WRITTEN) */
+static void
+prop_apply_todo(void)
+{
+ todo_show_due_date = GTK_TOGGLE_BUTTON (due_date_show_button)->active;
+ todo_due_date_overdue_highlight = GTK_TOGGLE_BUTTON (due_date_overdue_highlight)->active;
+
+ /* storing the values */
+ gnome_config_set_bool("/calendar/Todo/show_due_date", todo_show_due_date);
+ gnome_config_set_bool("/calendar/Todo/highlight_overdue_tasks", todo_due_date_overdue_highlight);
+
+ /* need to sync our config changes. */
+ gnome_config_sync ();
+
+ /* apply the current changes */
+ todo_properties_changed();
+}
+
/* Callback used when the Apply button is clicked. */
static void
@@ -120,6 +141,10 @@ prop_apply (GtkWidget *w, int page)
prop_apply_colors ();
break;
+ case PROP_TODO:
+ prop_apply_todo();
+ break;
+
case -1:
break;
@@ -498,6 +523,103 @@ create_colors_page (void)
}
+
+static void
+set_todo_page_options(void)
+{
+ if(!GTK_TOGGLE_BUTTON (due_date_show_button)->active) {
+ /* disable everything */
+ gtk_widget_set_sensitive(due_date_overdue_highlight,0);
+ }
+ else
+ {
+ gtk_widget_set_sensitive(due_date_overdue_highlight,1);
+ }
+
+ while (gtk_events_pending ())
+ gtk_main_iteration ();
+}
+
+static void
+todo_option_set (void)
+{
+ prop_changed ();
+ set_todo_page_options ();
+}
+
+/* Creates the colors page in the preferences dialog */
+static GtkWidget *
+build_list_options_frame(void)
+{
+ GtkWidget *frame;
+ GtkWidget *vbox;
+ frame = gtk_frame_new (_("Show on TODO List:"));
+
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (frame), vbox);
+
+ due_date_show_button = gtk_check_button_new_with_label (_("Summary"));
+ due_date_show_button = gtk_check_button_new_with_label (_("Due Date"));
+
+ gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(due_date_show_button), todo_show_due_date);
+ gtk_signal_connect (GTK_OBJECT(due_date_show_button),
+ "clicked",
+ (GtkSignalFunc) todo_option_set,
+ NULL);
+ gtk_box_pack_start (GTK_BOX (vbox), due_date_show_button, FALSE, FALSE, 0);
+ return frame;
+}
+static GtkWidget *
+build_style_list_options_frame(void)
+{
+ GtkWidget *frame;
+ GtkWidget *vbox;
+
+ frame = gtk_frame_new (_("TODO List style options:"));
+
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (frame), vbox);
+
+ due_date_overdue_highlight = gtk_check_button_new_with_label (_("Highlight overdue items"));
+
+ gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON(due_date_overdue_highlight), todo_due_date_overdue_highlight);
+ gtk_signal_connect (GTK_OBJECT(due_date_overdue_highlight),
+ "clicked",
+ (GtkSignalFunc) todo_option_set,
+ NULL);
+ gtk_box_pack_start (GTK_BOX (vbox), due_date_overdue_highlight, FALSE, FALSE, 0);
+ return frame;
+}
+static void
+create_todo_page (void)
+{
+ GtkWidget *frame;
+ GtkWidget *main_box;
+ GtkWidget *hbox;
+
+
+ frame = gtk_frame_new (_("Todo List Properties"));
+ gtk_container_set_border_width (GTK_CONTAINER (frame), GNOME_PAD_SMALL);
+ gnome_property_box_append_page (GNOME_PROPERTY_BOX (prop_win), frame,
+ gtk_label_new (_("Todo List")));
+
+ /* first vbox*/
+ main_box = gtk_vbox_new(FALSE, GNOME_PAD);
+ gtk_container_set_border_width (GTK_CONTAINER (main_box), GNOME_PAD_SMALL);
+ gtk_container_add (GTK_CONTAINER (frame), main_box);
+
+
+ /* first hbox*/
+ hbox = gtk_hbox_new (FALSE, GNOME_PAD);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL);
+ gtk_container_add (GTK_CONTAINER (main_box), hbox);
+
+ gtk_box_pack_start (GTK_BOX(hbox), build_list_options_frame(), FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(hbox), build_style_list_options_frame(), FALSE, FALSE, 0);
+
+ set_todo_page_options();
+}
+
/* Creates and displays the preferences dialog for the whole application */
void
properties (GtkWidget *toplevel)
@@ -515,6 +637,7 @@ properties (GtkWidget *toplevel)
create_time_display_page ();
create_colors_page ();
+ create_todo_page();
gtk_signal_connect (GTK_OBJECT (prop_win), "destroy",
(GtkSignalFunc) prop_cancel, NULL);