aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorDamon Chaplin <damon@ximian.com>2001-09-18 09:35:46 +0800
committerDamon Chaplin <damon@src.gnome.org>2001-09-18 09:35:46 +0800
commit999889586bbb251669c5a384f1b5d03bd72d0a6d (patch)
tree7041172cea75e0ee3556c3629425a8cda60bd58f /calendar/gui
parent5772dcbe43079dd8cf59e5458cb44a7a749df66f (diff)
downloadgsoc2013-evolution-999889586bbb251669c5a384f1b5d03bd72d0a6d.tar
gsoc2013-evolution-999889586bbb251669c5a384f1b5d03bd72d0a6d.tar.gz
gsoc2013-evolution-999889586bbb251669c5a384f1b5d03bd72d0a6d.tar.bz2
gsoc2013-evolution-999889586bbb251669c5a384f1b5d03bd72d0a6d.tar.lz
gsoc2013-evolution-999889586bbb251669c5a384f1b5d03bd72d0a6d.tar.xz
gsoc2013-evolution-999889586bbb251669c5a384f1b5d03bd72d0a6d.tar.zst
gsoc2013-evolution-999889586bbb251669c5a384f1b5d03bd72d0a6d.zip
added a timeout to refresh the list every 10 minutes. Not ideal, as the
2001-09-17 Damon Chaplin <damon@ximian.com> * gui/calendar-model.c: added a timeout to refresh the list every 10 minutes. Not ideal, as the user may be editing a task when it gets refreshed. (adjust_query_sexp): use the 'completed-before?' operator to filter out tasks according to the config settings. * gui/dialogs/task-details-page.c (task_details_page_fill_widgets): added support for the 'Completed' date. This code must have got lost somewhere, as it used to work. (date_changed_cb): set the priv->updating flag while updating the other widgets. * pcs/cal-backend-file.c (cal_backend_file_update_objects): made sure we freed the components. * pcs/query.c (func_completed_before): added 'completed-before?' operator. * gui/calendar-config.c (calendar_config_configure_e_cell_date_edit): don't set the lower & upper hour. Use 0-24 like the EDateEdit does. * gui/dialogs/cal-prefs-dialog.c (cal_prefs_dialog_show_config): set the 12/24-hour time format options sensitive only if we support both. * gui/calendar-config.c (config_read): if the locale doesn't define 'am' and 'pm' strings then we must use 24-hour format. * gui/calendar-commands.c (calendar_set_folder_bar_label): don't translate the '%d' as it doesn't make much sense. Resolves bug #8027. svn path=/trunk/; revision=12925
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/calendar-commands.c2
-rw-r--r--calendar/gui/calendar-config.c29
-rw-r--r--calendar/gui/calendar-config.h3
-rw-r--r--calendar/gui/calendar-model.c114
-rw-r--r--calendar/gui/calendar-model.h2
-rw-r--r--calendar/gui/dialogs/cal-prefs-dialog.c6
-rw-r--r--calendar/gui/dialogs/task-details-page.c45
7 files changed, 183 insertions, 18 deletions
diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c
index efb4b7860c..7c510024c3 100644
--- a/calendar/gui/calendar-commands.c
+++ b/calendar/gui/calendar-commands.c
@@ -448,7 +448,7 @@ calendar_set_folder_bar_label (GnomeCalendar *gcal, BonoboControl *control)
if (start_tm.tm_year == end_tm.tm_year) {
if (start_tm.tm_mon == end_tm.tm_mon) {
strftime (buffer, sizeof (buffer),
- _("%d"), &start_tm);
+ "%d", &start_tm);
strftime (end_buffer, sizeof (end_buffer),
_("%d %B %Y"), &end_tm);
strcat (buffer, " - ");
diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c
index 33be9f2f02..aed61238ec 100644
--- a/calendar/gui/calendar-config.c
+++ b/calendar/gui/calendar-config.c
@@ -90,14 +90,16 @@ calendar_config_init (void)
config_read ();
}
-static gboolean
-locale_uses_24h_time_format (void)
+/* Returns TRUE if the locale has 'am' and 'pm' strings defined, in which
+ case the user can choose between 12 and 24-hour time formats. */
+gboolean
+calendar_config_locale_supports_12_hour_format (void)
{
char s[16];
time_t t = 0;
strftime (s, sizeof s, "%p", gmtime (&t));
- return s[0] == '\0';
+ return s[0] != '\0';
}
static void
@@ -128,8 +130,15 @@ config_read (void)
config->week_start_day = bonobo_config_get_long_with_default (db,
"/Calendar/Display/WeekStartDay", 1, NULL);
- config->use_24_hour_format = bonobo_config_get_boolean_with_default (
- db, "/Calendar/Display/Use24HourFormat", locale_uses_24h_time_format (), NULL);
+ /* If the locale defines 'am' and 'pm' strings then the user has the
+ choice of 12-hour or 24-hour time format, with 12-hour as the
+ default. If the locale doesn't have 'am' and 'pm' strings we have
+ to use 24-hour format, or strftime()/strptime() won't work. */
+ if (calendar_config_locale_supports_12_hour_format ()) {
+ config->use_24_hour_format = bonobo_config_get_boolean_with_default (db, "/Calendar/Display/Use24HourFormat", FALSE, NULL);
+ } else {
+ config->use_24_hour_format = TRUE;
+ }
config->week_start_day = bonobo_config_get_long_with_default (db,
"/Calendar/Display/WeekStartDay", 1, NULL);
@@ -687,15 +696,19 @@ calendar_config_configure_e_cell_date_edit (ECellDateEdit *ecde)
start_hour = calendar_config_get_day_start_hour ();
end_hour = calendar_config_get_day_end_hour ();
+
/* Round up the end hour. */
if (calendar_config_get_day_end_minute () != 0)
- end_hour = end_hour + 1 % 24;
+ end_hour++;
e_cell_date_edit_freeze (ecde);
gtk_object_set (GTK_OBJECT (ecde),
"use_24_hour_format", use_24_hour,
+#if 0
+ /* We use the default 0 - 24 now. */
"lower_hour", start_hour,
"upper_hour", end_hour,
+#endif
NULL);
e_cell_date_edit_thaw (ecde);
}
@@ -725,6 +738,10 @@ calendar_config_configure_e_calendar_table (ECalendarTable *cal_table)
calendar_config_configure_e_cell_date_edit (cal_table->dates_cell);
+ /* Reload the event/tasks, since the 'Hide Completed Tasks' option
+ may have been changed, so the query needs to be updated. */
+ calendar_model_refresh (model);
+
/* This is for changing the colors of the text; they will be re-fetched
* by ECellText when the table is redrawn.
*/
diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h
index 83132267f9..d579cd8190 100644
--- a/calendar/gui/calendar-config.h
+++ b/calendar/gui/calendar-config.h
@@ -159,5 +159,8 @@ void calendar_config_configure_e_cell_date_edit (ECellDateEdit *ecde);
/* Shows the timezone dialog if the user hasn't set a default timezone. */
void calendar_config_check_timezone_set (void);
+/* Returns TRUE if the locale has 'am' and 'pm' strings defined, i.e. it
+ supports 12-hour time format. */
+gboolean calendar_config_locale_supports_12_hour_format(void);
#endif /* _CALENDAR_CONFIG_H_ */
diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c
index 5779266a2f..8a26af5faf 100644
--- a/calendar/gui/calendar-model.c
+++ b/calendar/gui/calendar-model.c
@@ -40,6 +40,12 @@
#include "itip-utils.h"
#include "calendar-model.h"
+/* This specifies how often we refresh the list, so that completed tasks are
+ hidden according to the config setting, and overdue tasks change color etc.
+ It is in milliseconds, so this is 10 minutes.
+ Note that if the user is editing an item in the list, they will probably
+ lose their edit, so this isn't ideal. */
+#define CALENDAR_MODEL_REFRESH_TIMEOUT 1000 * 60 * 10
/* Private part of the ECalendarModel structure */
struct _CalendarModelPrivate {
@@ -75,6 +81,9 @@ struct _CalendarModelPrivate {
/* The current timezone. */
icaltimezone *zone;
+
+ /* The id of our timeout function for refreshing the list. */
+ gint timeout_id;
};
@@ -162,6 +171,25 @@ calendar_model_class_init (CalendarModelClass *class)
etm_class->value_to_string = calendar_model_value_to_string;
}
+
+static gboolean
+calendar_model_timeout_cb (gpointer data)
+{
+ CalendarModel *model;
+
+ g_return_val_if_fail (IS_CALENDAR_MODEL (data), FALSE);
+
+ model = CALENDAR_MODEL (data);
+
+ GDK_THREADS_ENTER ();
+
+ calendar_model_refresh (model);
+
+ GDK_THREADS_LEAVE ();
+ return TRUE;
+}
+
+
/* Object initialization function for the calendar table model */
static void
calendar_model_init (CalendarModel *model)
@@ -179,6 +207,9 @@ calendar_model_init (CalendarModel *model)
priv->new_comp_vtype = CAL_COMPONENT_EVENT;
priv->use_24_hour_format = TRUE;
+ priv->timeout_id = g_timeout_add (CALENDAR_MODEL_REFRESH_TIMEOUT,
+ calendar_model_timeout_cb, model);
+
priv->addresses = itip_addresses_get ();
priv->zone = NULL;
@@ -233,6 +264,11 @@ calendar_model_destroy (GtkObject *object)
model = CALENDAR_MODEL (object);
priv = model->priv;
+ if (priv->timeout_id) {
+ g_source_remove (priv->timeout_id);
+ priv->timeout_id = 0;
+ }
+
/* Free the calendar client interface object */
if (priv->client) {
@@ -1839,7 +1875,8 @@ query_eval_error_cb (CalQuery *query, const char *error_str, gpointer data)
}
/* Builds a complete query sexp for the calendar model by adding the predicates
- * to filter only for the type of objects that the model supports.
+ * to filter only for the type of objects that the model supports, and
+ * whether we want completed tasks.
*/
static char *
adjust_query_sexp (CalendarModel *model, const char *sexp)
@@ -1848,6 +1885,7 @@ adjust_query_sexp (CalendarModel *model, const char *sexp)
CalObjType type;
char *type_sexp;
char *completed_sexp = "";
+ gboolean free_completed_sexp = FALSE;
char *new_sexp;
priv = model->priv;
@@ -1863,15 +1901,60 @@ adjust_query_sexp (CalendarModel *model, const char *sexp)
(type & CALOBJ_TYPE_TODO) ? "(= (get-vtype) \"VTODO\")" : "",
(type & CALOBJ_TYPE_JOURNAL) ? "(= (get-vtype) \"VJOURNAL\")" : "");
- /* FIXME: Use config setting eventually. */
-#if 0
- if (1)
- completed_sexp = "(not is-completed?)";
-#endif
+ /* Create a sub-expression for filtering out completed tasks, based on
+ the config settings. */
+ if (calendar_config_get_hide_completed_tasks ()) {
+ CalUnits units;
+ gint value;
+
+ units = calendar_config_get_hide_completed_tasks_units ();
+ value = calendar_config_get_hide_completed_tasks_value ();
+
+ if (value == 0) {
+ /* If the value is 0, we want to hide completed tasks
+ immediately, so we filter out all completed tasks.*/
+ completed_sexp = "(not is-completed?)";
+ } else {
+ char *location, *isodate;
+ icaltimezone *zone;
+ struct icaltimetype tt;
+ time_t t;
+
+ /* Get the current time, and subtract the appropriate
+ number of days/hours/minutes. */
+ location = calendar_config_get_timezone ();
+ zone = icaltimezone_get_builtin_timezone (location);
+ tt = icaltime_current_time_with_zone (zone);
+
+ switch (units) {
+ case CAL_DAYS:
+ icaltime_adjust (&tt, -value, 0, 0, 0);
+ break;
+ case CAL_HOURS:
+ icaltime_adjust (&tt, 0, -value, 0, 0);
+ break;
+ case CAL_MINUTES:
+ icaltime_adjust (&tt, 0, 0, -value, 0);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ t = icaltime_as_timet_with_zone (tt, zone);
+
+ /* Convert the time to an ISO date string, and build
+ the query sub-expression. */
+ isodate = isodate_from_time_t (t);
+ completed_sexp = g_strdup_printf ("(not (completed-before? (make-time \"%s\")))", isodate);
+ free_completed_sexp = TRUE;
+ }
+ }
new_sexp = g_strdup_printf ("(and %s %s %s)", type_sexp,
completed_sexp, sexp);
g_free (type_sexp);
+ if (free_completed_sexp)
+ g_free (completed_sexp);
g_print ("Calendar mode sexp:\n%s\n", new_sexp);
@@ -2188,7 +2271,7 @@ calendar_model_get_component (CalendarModel *model,
is not -1, then that is used, otherwise if the "Date Completed" property
is not already set it is set to the current time.
It makes sure the percent is set to 100, and that the status is "Completed".
- Note that this doesn't update the component on the client. */
+ Note that this doesn't update the component on the server. */
static void
ensure_task_complete (CalComponent *comp,
time_t completed_date)
@@ -2326,3 +2409,20 @@ calendar_model_set_timezone (CalendarModel *model,
e_table_model_changed (E_TABLE_MODEL (model));
}
}
+
+
+/**
+ * calendar_model_refresh:
+ * @model: A calendar model.
+ *
+ * Refreshes the calendar model, reloading the events/tasks from the server.
+ * Be careful about doing this when the user is editing an event/task.
+ **/
+void
+calendar_model_refresh (CalendarModel *model)
+{
+ g_return_if_fail (model != NULL);
+ g_return_if_fail (IS_CALENDAR_MODEL (model));
+
+ update_query (model);
+}
diff --git a/calendar/gui/calendar-model.h b/calendar/gui/calendar-model.h
index 5e1350100d..6bda61f49d 100644
--- a/calendar/gui/calendar-model.h
+++ b/calendar/gui/calendar-model.h
@@ -66,6 +66,8 @@ void calendar_model_set_cal_client (CalendarModel *model,
void calendar_model_set_query (CalendarModel *model,
const char *sexp);
+void calendar_model_refresh (CalendarModel *model);
+
void calendar_model_set_new_comp_vtype (CalendarModel *model,
CalComponentVType vtype);
CalComponentVType calendar_model_get_new_comp_vtype (CalendarModel *model);
diff --git a/calendar/gui/dialogs/cal-prefs-dialog.c b/calendar/gui/dialogs/cal-prefs-dialog.c
index 0b1d14d55e..0b3d43e98b 100644
--- a/calendar/gui/dialogs/cal-prefs-dialog.c
+++ b/calendar/gui/dialogs/cal-prefs-dialog.c
@@ -483,6 +483,7 @@ cal_prefs_dialog_show_config (CalPrefsDialog *prefs)
gint mask, day, week_start_day, time_divisions;
char *zone_name;
icaltimezone *zone;
+ gboolean sensitive;
priv = prefs->priv;
@@ -521,6 +522,11 @@ cal_prefs_dialog_show_config (CalPrefsDialog *prefs)
else
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->use_12_hour), TRUE);
+ sensitive = calendar_config_locale_supports_12_hour_format ();
+ gtk_widget_set_sensitive (priv->use_12_hour, sensitive);
+ gtk_widget_set_sensitive (priv->use_24_hour, sensitive);
+
+
/* Time Divisions. */
time_divisions = calendar_config_get_time_divisions ();
e_dialog_option_menu_set (priv->time_divisions, time_divisions,
diff --git a/calendar/gui/dialogs/task-details-page.c b/calendar/gui/dialogs/task-details-page.c
index ff7223362a..3196994bd1 100644
--- a/calendar/gui/dialogs/task-details-page.c
+++ b/calendar/gui/dialogs/task-details-page.c
@@ -296,6 +296,7 @@ task_details_page_fill_widgets (CompEditorPage *page, CalComponent *comp)
TaskEditorPriority priority;
icalproperty_status status;
const char *url;
+ struct icaltimetype *completed = NULL;
tdpage = TASK_DETAILS_PAGE (page);
priv = tdpage->priv;
@@ -331,6 +332,30 @@ task_details_page_fill_widgets (CompEditorPage *page, CalComponent *comp)
}
e_dialog_option_menu_set (priv->status, status, status_map);
+ /* Completed Date. */
+ cal_component_get_completed (comp, &completed);
+ if (completed) {
+ icaltimezone *utc_zone, *zone;
+ char *location;
+
+ /* Completed is in UTC, but that would confuse the user, so
+ we convert it to local time. */
+ utc_zone = icaltimezone_get_utc_timezone ();
+ location = calendar_config_get_timezone ();
+ zone = icaltimezone_get_builtin_timezone (location);
+
+ icaltimezone_convert_time (completed, utc_zone, zone);
+
+ e_date_edit_set_date (E_DATE_EDIT (priv->completed_date),
+ completed->year, completed->month,
+ completed->day);
+ e_date_edit_set_time_of_day (E_DATE_EDIT (priv->completed_date),
+ completed->hour,
+ completed->minute);
+
+ cal_component_free_icaltimetype (completed);
+ }
+
/* Priority. */
cal_component_get_priority (comp, &priority_value);
if (priority_value) {
@@ -492,6 +517,8 @@ date_changed_cb (EDateEdit *dedit, gpointer data)
if (priv->updating)
return;
+ priv->updating = TRUE;
+
date_set = e_date_edit_get_date (E_DATE_EDIT (priv->completed_date),
&completed_tt.year,
&completed_tt.month,
@@ -499,20 +526,30 @@ date_changed_cb (EDateEdit *dedit, gpointer data)
e_date_edit_get_time_of_day (E_DATE_EDIT (priv->completed_date),
&completed_tt.hour,
&completed_tt.minute);
+
+ status = e_dialog_option_menu_get (priv->status, status_map);
+
if (!date_set) {
completed_tt = icaltime_null_time ();
-
- status = e_dialog_option_menu_get (priv->status, status_map);
if (status == ICAL_STATUS_COMPLETED) {
- e_dialog_option_menu_set (priv->status, ICAL_STATUS_NEEDSACTION, status_map);
+ e_dialog_option_menu_set (priv->status,
+ ICAL_STATUS_NEEDSACTION,
+ status_map);
e_dialog_spin_set (priv->percent_complete, 0);
}
} else {
- e_dialog_option_menu_set (priv->status, ICAL_STATUS_COMPLETED, status_map);
+ if (status != ICAL_STATUS_COMPLETED) {
+ e_dialog_option_menu_set (priv->status,
+ ICAL_STATUS_COMPLETED,
+ status_map);
+ }
e_dialog_spin_set (priv->percent_complete, 100);
}
+ priv->updating = FALSE;
+
/* Notify upstream */
+ dates.complete = &completed_tt;
comp_editor_page_notify_dates_changed (COMP_EDITOR_PAGE (tdpage), &dates);
}