diff options
-rw-r--r-- | calendar/ChangeLog | 48 | ||||
-rw-r--r-- | calendar/cal-util/cal-component.c | 4 | ||||
-rw-r--r-- | calendar/cal-util/cal-component.h | 4 | ||||
-rw-r--r-- | calendar/gui/Makefile.am | 2 | ||||
-rw-r--r-- | calendar/gui/calendar-commands.c | 10 | ||||
-rw-r--r-- | calendar/gui/calendar-config.c | 55 | ||||
-rw-r--r-- | calendar/gui/calendar-config.h | 12 | ||||
-rw-r--r-- | calendar/gui/calendar-model.c | 392 | ||||
-rw-r--r-- | calendar/gui/dialogs/cal-prefs-dialog.c | 2 | ||||
-rw-r--r-- | calendar/gui/e-calendar-table.c | 174 | ||||
-rw-r--r-- | calendar/gui/e-calendar-table.h | 4 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 153 | ||||
-rw-r--r-- | calendar/gui/e-tasks.c | 26 | ||||
-rw-r--r-- | calendar/gui/e-tasks.h | 4 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 139 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 3 | ||||
-rw-r--r-- | calendar/gui/popup-menu.c | 43 | ||||
-rw-r--r-- | calendar/gui/popup-menu.h | 25 | ||||
-rw-r--r-- | calendar/gui/print.c | 1 |
19 files changed, 715 insertions, 386 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 983a58ad73..674488dc22 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,51 @@ +2001-03-05 Damon Chaplin <damon@ximian.com> + + * gui/e-tasks.c: keep list of all Tasks folders so we can update the + preference settings when necessary. + + * gui/gnome-cal.c: configure the TaskPad according to the settings. + + * gui/e-calendar-table.c: use ECellCombo and ECellDateEdit for fields, + so the tasks folders is almost usable now. + + * gui/calendar-model.c: added support for the Status property. + + * gui/calendar-config.[hc]: added convenience functions to setup + ECalendarTable and ECellDateEdit objects. + + * gui/calendar-commands.c: connected to "destroy" signal of calendars + so we can remove them from all_calendars list. + + * gui/dialogs/cal-prefs-dialog.c (cal_prefs_dialog_update_config): + call e_tasks_update_all_config_settings() to update all the settings + in the Tasks folders as well. + + * cal-util/cal-component.h: added CAL_COMPONENT_FIELD_STATUS. + + * cal-util/cal-component.c (cal_component_get_transparency): fixed + calls to strcasecmp so they check for '== 0'. + + Applied patch from Miguel... + +2001-02-27 Miguel de Icaza <miguel@ximian.com> + + * gui/e-day-view.c (e_day_view_on_event_right_click): Reorganize + the menus to have entries always in a consistent fashion, as + reported to the genepool mailing list. + (e_day_view_on_event_right_click): Added a FIXME comment to the + FIXME comment without a FIXME. + + Now we use e_popup_menu. This allows us to hide/show items on + demand, and to sensitize/de-sensitize items depending on their + state. + + This will also let us add icon support (when we get nice icons for + this) + + * gui/e-week-view.c (e_week_view_show_popup_menu): Ditto. + + The files popup-menu.c and popup-menu.h can now be removed. + 2001-03-02 JP Rosevear <jpr@ximian.com> * conduits/todo/e-todo.conduit.in: update for new pilot foo diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c index b0269ba262..43c6841b2c 100644 --- a/calendar/cal-util/cal-component.c +++ b/calendar/cal-util/cal-component.c @@ -3100,9 +3100,9 @@ cal_component_get_transparency (CalComponent *comp, CalComponentTransparency *tr val = icalproperty_get_transp (priv->transparency); - if (strcasecmp (val, "TRANSPARENT")) + if (strcasecmp (val, "TRANSPARENT") == 0) *transp = CAL_COMPONENT_TRANSP_TRANSPARENT; - else if (strcasecmp (val, "OPAQUE")) + else if (strcasecmp (val, "OPAQUE") == 0) *transp = CAL_COMPONENT_TRANSP_OPAQUE; else *transp = CAL_COMPONENT_TRANSP_UNKNOWN; diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h index b912c04e9e..95d2b1eb0b 100644 --- a/calendar/cal-util/cal-component.h +++ b/calendar/cal-util/cal-component.h @@ -54,6 +54,9 @@ typedef enum { /* Field identifiers for a calendar component; these are used by the data model * for ETable. + * + * NOTE: These are also used in the ETable specification, and the column + * numbers are saved in the user settings file. So don't reorder them! */ typedef enum { CAL_COMPONENT_FIELD_CATEGORIES, /* concatenation of the categories list */ @@ -74,6 +77,7 @@ typedef enum { CAL_COMPONENT_FIELD_RECURRING, /* not a real field */ CAL_COMPONENT_FIELD_OVERDUE, /* not a real field */ CAL_COMPONENT_FIELD_COLOR, /* not a real field */ + CAL_COMPONENT_FIELD_STATUS, CAL_COMPONENT_FIELD_NUM_FIELDS } CalComponentField; diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index bf3a7f200e..7c4a862b15 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -93,8 +93,6 @@ evolution_calendar_SOURCES = \ itip-utils.c \ itip-utils.h \ main.c \ - popup-menu.c \ - popup-menu.h \ print.c \ print.h \ tag-calendar.c \ diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c index 29557e2d68..4b6078df99 100644 --- a/calendar/gui/calendar-commands.c +++ b/calendar/gui/calendar-commands.c @@ -434,6 +434,13 @@ calendar_control_deactivate (BonoboControl *control) bonobo_ui_component_unset_container (uic); } +/* Removes a calendar from our list of all calendars when it is destroyed. */ +static void +on_calendar_destroyed (GnomeCalendar *gcal) +{ + all_calendars = g_list_remove (all_calendars, gcal); +} + GnomeCalendar * new_calendar (void) { @@ -446,6 +453,9 @@ new_calendar (void) return NULL; } + gtk_signal_connect (GTK_OBJECT (gcal), "destroy", + GTK_SIGNAL_FUNC (on_calendar_destroyed), NULL); + all_calendars = g_list_prepend (all_calendars, gcal); return GNOME_CALENDAR (gcal); diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index 08579182fe..eb1071b913 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -430,6 +430,8 @@ calendar_config_configure_e_calendar (ECalendar *cal) gboolean dnav_show_week_no; gint week_start_day; + g_return_if_fail (E_IS_CALENDAR (cal)); + dnav_show_week_no = calendar_config_get_dnav_show_week_no (); /* Note that this is 0 (Sun) to 6 (Sat). */ @@ -455,6 +457,8 @@ calendar_config_configure_e_date_edit (EDateEdit *dedit) gboolean dnav_show_week_no, use_24_hour; gint week_start_day, start_hour, end_hour; + g_return_if_fail (E_IS_DATE_EDIT (dedit)); + dnav_show_week_no = calendar_config_get_dnav_show_week_no (); /* Note that this is 0 (Sun) to 6 (Sat). */ @@ -476,3 +480,54 @@ calendar_config_configure_e_date_edit (EDateEdit *dedit) e_date_edit_set_use_24_hour_format (dedit, use_24_hour); e_date_edit_set_time_popup_range (dedit, start_hour, end_hour); } + + +/* This sets all the common config settings for an ECellDateEdit ETable item. + These are the settings for the ECalendar popup and the time list (if we use + 24 hour format, and the hours of the working day). */ +void +calendar_config_configure_e_cell_date_edit (ECellDateEdit *ecde) +{ + gboolean use_24_hour; + gint start_hour, end_hour; + + g_return_if_fail (E_IS_CELL_DATE_EDIT (ecde)); + + calendar_config_configure_e_calendar (E_CALENDAR (ecde->calendar)); + + use_24_hour = calendar_config_get_24_hour_format (); + + 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; + + e_cell_date_edit_freeze (ecde); + gtk_object_set (GTK_OBJECT (ecde), + "use_24_hour_format", use_24_hour, + "lower_hour", start_hour, + "upper_hour", end_hour, + NULL); + e_cell_date_edit_thaw (ecde); +} + + +/* This sets all the common config settings for an ECalendarTable widget. + These are the settings for the ECalendar popup and the time list (if we use + 24 hour format, and the hours of the working day). */ +void +calendar_config_configure_e_calendar_table (ECalendarTable *cal_table) +{ + CalendarModel *model; + gboolean use_24_hour; + + g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table)); + + use_24_hour = calendar_config_get_24_hour_format (); + + model = e_calendar_table_get_model (cal_table); + calendar_model_set_use_24_hour_format (model, use_24_hour); + + calendar_config_configure_e_cell_date_edit (cal_table->dates_cell); +} diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h index 8b11570f12..fb19ba2cc5 100644 --- a/calendar/gui/calendar-config.h +++ b/calendar/gui/calendar-config.h @@ -32,6 +32,8 @@ #include <widgets/misc/e-calendar.h> #include <widgets/misc/e-dateedit.h> +#include <widgets/misc/e-cell-date-edit.h> +#include "e-calendar-table.h" /* These are used to get/set the working days in the week. The bit-flags are @@ -118,9 +120,11 @@ gfloat calendar_config_get_month_vpane_pos (void); void calendar_config_set_month_vpane_pos (gfloat vpane_pos); -/* Convenience functions to configure common properties of ECalendar and - EDateEdit widgets. */ -void calendar_config_configure_e_calendar (ECalendar *cal); -void calendar_config_configure_e_date_edit (EDateEdit *dedit); +/* Convenience functions to configure common properties of ECalendar, + EDateEdit & ECalendarTable widgets, and the ECellDateEdit ETable cell. */ +void calendar_config_configure_e_calendar (ECalendar *cal); +void calendar_config_configure_e_date_edit (EDateEdit *dedit); +void calendar_config_configure_e_calendar_table (ECalendarTable *cal_table); +void calendar_config_configure_e_cell_date_edit (ECellDateEdit *ecde); #endif /* _CALENDAR_CONFIG_H_ */ diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c index 3e8f3359ab..89ad5f3545 100644 --- a/calendar/gui/calendar-model.c +++ b/calendar/gui/calendar-model.c @@ -42,6 +42,7 @@ #include <libgnome/gnome-i18n.h> #include <libgnomeui/gnome-messagebox.h> #include <gal/widgets/e-unicode.h> +#include <e-util/e-time-utils.h> #include <cal-util/timeutil.h> #include "calendar-model.h" #include "calendar-commands.h" @@ -315,33 +316,22 @@ calendar_model_row_count (ETableModel *etm) return priv->objects->len; } -/* Creates a nice string representation of a time value */ +/* Creates a nice string representation of a time value. If show_midnight is + FALSE, and the time is midnight, then we just show the date. */ static char* -get_time_t (CalendarModel *model, time_t *t, gboolean skip_midnight) +get_time_t (CalendarModel *model, time_t *t, gboolean show_midnight) { static char buffer[64]; struct tm *tmp_tm; - char *format; if (*t <= 0) { buffer[0] = '\0'; } else { tmp_tm = localtime (t); - - if (skip_midnight && tmp_tm->tm_hour == 0 - && tmp_tm->tm_min == 0 && tmp_tm->tm_sec == 0) - /* strftime format of a weekday and a date. */ - format = _("%a %m/%d/%Y"); - else if (model->priv->use_24_hour_format) - /* strftime format of a weekday, a date and a time, - in 24-hour format. */ - format = _("%a %m/%d/%Y %H:%M:%S"); - else - /* strftime format of a weekday, a date and a time, - in 12-hour format. */ - format = _("%a %m/%d/%Y %I:%M:%S %p"); - - strftime (buffer, sizeof (buffer), format, tmp_tm); + e_time_format_date_and_time (tmp_tm, + model->priv->use_24_hour_format, + show_midnight, FALSE, + buffer, sizeof (buffer)); } return buffer; @@ -407,7 +397,7 @@ get_completed (CalendarModel *model, cal_component_free_icaltimetype (completed); } - return get_time_t (model, &t, FALSE); + return get_time_t (model, &t, TRUE); } /* Builds a string for and frees a date/time value */ @@ -423,7 +413,7 @@ get_and_free_datetime (CalendarModel *model, CalComponentDateTime dt) cal_component_free_datetime (&dt); - return get_time_t (model, &t, FALSE); + return get_time_t (model, &t, TRUE); } /* Builds a string for the DTEND property of a calendar component */ @@ -503,18 +493,23 @@ static char * get_priority (CalComponent *comp) { int *priority; - static char buf[32]; + char *retval; cal_component_get_priority (comp, &priority); - if (!priority) - buf[0] = '\0'; - else { - g_snprintf (buf, sizeof (buf), "%d", *priority); + if (!priority || *priority == 0) + retval = ""; + else if (*priority <= 4) + retval = _("High"); + else if (*priority == 5) + retval = _("Normal"); + else + retval = _("Low"); + + if (priority) cal_component_free_priority (priority); - } - return buf; + return retval; } /* Builds a string for the SUMMARY property of a calendar component */ @@ -541,6 +536,7 @@ get_transparency (CalComponent *comp) switch (transp) { case CAL_COMPONENT_TRANSP_NONE: + case CAL_COMPONENT_TRANSP_UNKNOWN: return ""; case CAL_COMPONENT_TRANSP_TRANSPARENT: @@ -549,9 +545,6 @@ get_transparency (CalComponent *comp) case CAL_COMPONENT_TRANSP_OPAQUE: return _("Opaque"); - case CAL_COMPONENT_TRANSP_UNKNOWN: - return _("Unknown"); - default: g_assert_not_reached (); return NULL; @@ -633,6 +626,35 @@ get_is_overdue (CalComponent *comp) return retval; } +static void * +get_status (CalComponent *comp) +{ + icalproperty_status status; + + cal_component_get_status (comp, &status); + + switch (status) { + case ICAL_STATUS_NONE: + return ""; + + case ICAL_STATUS_NEEDSACTION: + return _("Not Started"); + + case ICAL_STATUS_INPROCESS: + return _("In Progress"); + + case ICAL_STATUS_COMPLETED: + return _("Completed"); + + case ICAL_STATUS_CANCELLED: + return _("Cancelled"); + + default: + g_assert_not_reached (); + return NULL; + } +} + /* value_at handler for the calendar table model */ static void * calendar_model_value_at (ETableModel *etm, int col, int row) @@ -650,6 +672,10 @@ calendar_model_value_at (ETableModel *etm, int col, int row) comp = g_array_index (priv->objects, CalComponent *, row); g_assert (comp != NULL); +#if 0 + g_print ("In calendar_model_value_at: %i\n", col); +#endif + switch (col) { case CAL_COMPONENT_FIELD_CATEGORIES: return get_categories (comp); @@ -723,6 +749,9 @@ calendar_model_value_at (ETableModel *etm, int col, int row) else return NULL; + case CAL_COMPONENT_FIELD_STATUS: + return get_status (comp); + default: g_message ("calendar_model_value_at(): Requested invalid column %d", col); return NULL; @@ -844,146 +873,63 @@ set_categories (CalComponent *comp, const char *value) g_slist_free (list); } -/* Parses a time value entered by the user; returns -1 if it could not be - * parsed. Returns 0 for an empty time. + +/* FIXME: We won't need this eventually, since the user won't be allowed to + * edit the field. */ -static time_t -parse_time (const char *value) +static void +show_classification_warning (void) { - struct tm discard_tm, date_tm, time_tm; - struct tm *today_tm; - time_t t; - const char *pos, *parse_end; - char *format[4]; - gboolean parsed_date = FALSE, parsed_time = FALSE; - gint i; - - if (string_is_empty (value)) - return 0; - - pos = value; - - /* Skip any whitespace. */ - while (isspace (*pos)) - pos++; - - /* Skip any weekday name, full or abbreviated. */ - parse_end = strptime (pos, "%a ", &discard_tm); - if (parse_end) - pos = parse_end; - - memset (&date_tm, 0, sizeof (date_tm)); - /* strptime format for a date. */ - parse_end = strptime (pos, _("%m/%d/%Y"), &date_tm); - if (parse_end) { - pos = parse_end; - parsed_date = TRUE; - } - - /* Skip any whitespace. */ - while (isspace (*pos)) - pos++; - - /* Skip any weekday name, full or abbreviated, again. */ - parse_end = strptime (pos, "%a ", &discard_tm); - if (parse_end) - pos = parse_end; - - - /* strptime format for a time of day, in 12-hour format. - If it is is not appropriate in the locale set to an empty string. */ - format[0] = _("%I:%M:%S %p%n"); - - /* strptime format for a time of day, in 24-hour format. */ - format[1] = _("%H:%M:%S%n"); - - /* strptime format for time of day, without seconds, 12-hour format. - If it is is not appropriate in the locale set to an empty string. */ - format[2] = _("%I:%M %p%n"); - - /* strptime format for time of day, without seconds 24-hour format. */ - format[3] = _("%H:%M%n"); - - for (i = 0; i < sizeof (format) / sizeof (format[0]); i++) { - memset (&time_tm, 0, sizeof (time_tm)); - parse_end = strptime (pos, format[i], &time_tm); - if (parse_end) { - pos = parse_end; - parsed_time = TRUE; - break; - } - } - - /* Skip any whitespace. */ - while (isspace (*pos)) - pos++; - - /* If we haven't already parsed a date, try again. */ - if (!parsed_date) { - memset (&date_tm, 0, sizeof (date_tm)); - /* strptime format for a date. */ - parse_end = strptime (pos, _("%m/%d/%Y"), &date_tm); - if (parse_end) { - pos = parse_end; - parsed_date = TRUE; - } - } - - /* If we don't have a date or a time it must be invalid. */ - if (!parsed_date && !parsed_time) - return -1; - + GtkWidget *dialog; - if (parsed_date) { - /* If a 2-digit year was used we use the current century. */ - if (date_tm.tm_year < 0) { - t = time (NULL); - today_tm = localtime (&t); + dialog = gnome_message_box_new (_("The classification must be 'Public', 'Private', 'Confidential' or 'None'"), + GNOME_MESSAGE_BOX_ERROR, + GNOME_STOCK_BUTTON_OK, NULL); + gtk_widget_show (dialog); +} - /* This should convert it into a value from 0 to 99. */ - date_tm.tm_year += 1900; - /* Now add on the century. */ - date_tm.tm_year += today_tm->tm_year - - (today_tm->tm_year % 100); - } - } else { - /* If we didn't get a date we use the current day. */ - t = time (NULL); - today_tm = localtime (&t); - date_tm.tm_mday = today_tm->tm_mday; - date_tm.tm_mon = today_tm->tm_mon; - date_tm.tm_year = today_tm->tm_year; - } +static void +set_classification (CalComponent *comp, + const char *value) +{ + CalComponentClassification classif; - if (parsed_time) { - date_tm.tm_hour = time_tm.tm_hour; - date_tm.tm_min = time_tm.tm_min; - date_tm.tm_sec = time_tm.tm_sec; - } else { - date_tm.tm_hour = 0; - date_tm.tm_min = 0; - date_tm.tm_sec = 0; + /* An empty string is the same as 'None'. */ + if (!value[0] || !g_strcasecmp (value, _("None"))) + classif = CAL_COMPONENT_CLASS_NONE; + else if (!g_strcasecmp (value, _("Public"))) + classif = CAL_COMPONENT_CLASS_PUBLIC; + else if (!g_strcasecmp (value, _("Private"))) + classif = CAL_COMPONENT_CLASS_PRIVATE; + else if (!g_strcasecmp (value, _("Confidential"))) + classif = CAL_COMPONENT_CLASS_CONFIDENTIAL; + else { + show_classification_warning (); + return; } - - date_tm.tm_isdst = -1; - return mktime (&date_tm); + cal_component_set_classification (comp, classif); } + /* Called to set the "Date Completed" field. We also need to update the Status and Percent fields to make sure they match. */ static void set_completed (CalendarModel *model, CalComponent *comp, const char *value) { + ETimeParseStatus status; + struct tm tmp_tm; time_t t; - t = parse_time (value); - if (t == -1) { + status = e_time_parse_date_and_time (value, &tmp_tm); + + if (status == E_TIME_PARSE_INVALID) { show_date_warning (model); - } else if (t == 0) { + } else if (status == E_TIME_PARSE_NONE) { ensure_task_not_complete (comp); } else { + t = mktime (&tmp_tm); ensure_task_complete (comp, t); } } @@ -993,19 +939,21 @@ static void set_datetime (CalendarModel *model, CalComponent *comp, const char *value, void (* set_func) (CalComponent *comp, CalComponentDateTime *dt)) { + ETimeParseStatus status; + struct tm tmp_tm; time_t t; - t = parse_time (value); - if (t == -1) { + status = e_time_parse_date_and_time (value, &tmp_tm); + + if (status == E_TIME_PARSE_INVALID) { show_date_warning (model); - return; - } else if (t == 0) { + } else if (status == E_TIME_PARSE_NONE) { (* set_func) (comp, NULL); - return; } else { CalComponentDateTime dt; struct icaltimetype itt; + t = mktime (&tmp_tm); itt = icaltime_from_timet (t, FALSE); dt.value = &itt; dt.tzid = NULL; @@ -1095,14 +1043,15 @@ set_percent (CalComponent *comp, const char *value) ensure_task_not_complete (comp); } -/* FIXME: We need to set the "transient_for" property for the dialog, but the - * model doesn't know anything about the windows. */ +/* FIXME: We won't need this eventually, since the user won't be allowed to + * edit the field. + */ static void show_priority_warning (void) { GtkWidget *dialog; - dialog = gnome_message_box_new (_("The priority must be between 1 and 9, inclusive"), + dialog = gnome_message_box_new (_("The priority must be 'High', 'Normal', 'Low' or 'Undefined'."), GNOME_MESSAGE_BOX_ERROR, GNOME_STOCK_BUTTON_OK, NULL); gtk_widget_show (dialog); @@ -1112,16 +1061,18 @@ show_priority_warning (void) static void set_priority (CalComponent *comp, const char *value) { - int matched, priority; - - if (string_is_empty (value)) { - cal_component_set_priority (comp, NULL); - return; - } - - matched = sscanf (value, "%i", &priority); - - if (matched != 1 || priority < 1 || priority > 9) { + int priority; + + /* An empty string is the same as 'None'. */ + if (!value[0] || !g_strcasecmp (value, _("Undefined"))) + priority = 0; + else if (!g_strcasecmp (value, _("High"))) + priority = 3; + else if (!g_strcasecmp (value, _("Normal"))) + priority = 5; + else if (!g_strcasecmp (value, _("Low"))) + priority = 7; + else { show_priority_warning (); return; } @@ -1146,10 +1097,51 @@ set_summary (CalComponent *comp, const char *value) cal_component_set_summary (comp, &text); } +/* FIXME: We won't need this eventually, since the user won't be allowed to + * edit the field. + */ +static void +show_transparency_warning (void) +{ + GtkWidget *dialog; + + dialog = gnome_message_box_new (_("The transparency must be 'Transparent', 'Opaque', or 'None'."), + GNOME_MESSAGE_BOX_ERROR, + GNOME_STOCK_BUTTON_OK, NULL); + gtk_widget_show (dialog); +} + +/* Sets the URI of a calendar component */ +static void +set_transparency (CalComponent *comp, const char *value) +{ + CalComponentTransparency transp; + + g_print ("In calendar model set_transparency: %s\n", value); + + /* An empty string is the same as 'None'. */ + if (!value[0] || !g_strcasecmp (value, _("None"))) + transp = CAL_COMPONENT_TRANSP_NONE; + else if (!g_strcasecmp (value, _("Transparent"))) + transp = CAL_COMPONENT_TRANSP_TRANSPARENT; + else if (!g_strcasecmp (value, _("Opaque"))) { + transp = CAL_COMPONENT_TRANSP_OPAQUE; + } else { + show_transparency_warning (); + return; + } + + g_print (" transp: %i\n", transp); + + cal_component_set_transparency (comp, transp); +} + /* Sets the URI of a calendar component */ static void set_url (CalComponent *comp, const char *value) { + g_print ("In calendar model set_url\n"); + if (string_is_empty (value)) { cal_component_set_url (comp, NULL); return; @@ -1172,6 +1164,42 @@ set_complete (CalComponent *comp, const void *value) } } +/* Sets the status of a calendar component. */ +static void +set_status (CalComponent *comp, const char *value) +{ + icalproperty_status status; + int percent; + + g_print ("In calendar model set_status: %s\n", value); + + /* An empty string is the same as 'None'. */ + if (!value[0] || !g_strcasecmp (value, _("None"))) + status = ICAL_STATUS_NONE; + else if (!g_strcasecmp (value, _("Not Started"))) + status = ICAL_STATUS_NEEDSACTION; + else if (!g_strcasecmp (value, _("In Progress"))) + status = ICAL_STATUS_INPROCESS; + else if (!g_strcasecmp (value, _("Completed"))) + status = ICAL_STATUS_COMPLETED; + else if (!g_strcasecmp (value, _("Cancelled"))) + status = ICAL_STATUS_CANCELLED; + else { + g_warning ("Invalid status: %s\n", value); + return; + } + + cal_component_set_status (comp, status); + + if (status == ICAL_STATUS_NEEDSACTION) { + percent = 0; + cal_component_set_percent (comp, &percent); + cal_component_set_completed (comp, NULL); + } else if (status == ICAL_STATUS_COMPLETED) { + ensure_task_complete (comp, -1); + } +} + /* set_value_at handler for the calendar table model */ static void calendar_model_set_value_at (ETableModel *etm, int col, int row, const void *value) @@ -1189,6 +1217,10 @@ calendar_model_set_value_at (ETableModel *etm, int col, int row, const void *val comp = g_array_index (priv->objects, CalComponent *, row); g_assert (comp != NULL); +#if 1 + g_print ("In calendar_model_set_value_at: %i\n", col); +#endif + switch (col) { case CAL_COMPONENT_FIELD_CATEGORIES: set_categories (comp, value); @@ -1198,7 +1230,9 @@ calendar_model_set_value_at (ETableModel *etm, int col, int row, const void *val } break; - /* FIXME: CLASSIFICATION requires an option menu cell renderer */ + case CAL_COMPONENT_FIELD_CLASSIFICATION: + set_classification (comp, value); + break; case CAL_COMPONENT_FIELD_COMPLETED: set_completed (model, comp, value); @@ -1234,7 +1268,9 @@ calendar_model_set_value_at (ETableModel *etm, int col, int row, const void *val set_summary (comp, value); break; - /* FIXME: TRANSPARENCY requires an option menu cell renderer */ + case CAL_COMPONENT_FIELD_TRANSPARENCY: + set_transparency (comp, value); + break; case CAL_COMPONENT_FIELD_URL: set_url (comp, value); @@ -1244,6 +1280,10 @@ calendar_model_set_value_at (ETableModel *etm, int col, int row, const void *val set_complete (comp, value); break; + case CAL_COMPONENT_FIELD_STATUS: + set_status (comp, value); + break; + default: g_message ("calendar_model_set_value_at(): Requested invalid column %d", col); break; @@ -1276,6 +1316,7 @@ calendar_model_is_cell_editable (ETableModel *etm, int col, int row) switch (col) { case CAL_COMPONENT_FIELD_CATEGORIES: + case CAL_COMPONENT_FIELD_CLASSIFICATION: case CAL_COMPONENT_FIELD_COMPLETED: case CAL_COMPONENT_FIELD_DTEND: case CAL_COMPONENT_FIELD_DTSTART: @@ -1284,8 +1325,10 @@ calendar_model_is_cell_editable (ETableModel *etm, int col, int row) case CAL_COMPONENT_FIELD_PERCENT: case CAL_COMPONENT_FIELD_PRIORITY: case CAL_COMPONENT_FIELD_SUMMARY: + case CAL_COMPONENT_FIELD_TRANSPARENCY: case CAL_COMPONENT_FIELD_URL: case CAL_COMPONENT_FIELD_COMPLETE: + case CAL_COMPONENT_FIELD_STATUS: return TRUE; default: @@ -1378,6 +1421,7 @@ calendar_model_duplicate_value (ETableModel *etm, int col, const void *value) case CAL_COMPONENT_FIELD_SUMMARY: case CAL_COMPONENT_FIELD_TRANSPARENCY: case CAL_COMPONENT_FIELD_URL: + case CAL_COMPONENT_FIELD_STATUS: return dup_string (value); case CAL_COMPONENT_FIELD_HAS_ALARMS: @@ -1415,6 +1459,7 @@ calendar_model_free_value (ETableModel *etm, int col, void *value) case CAL_COMPONENT_FIELD_PERCENT: case CAL_COMPONENT_FIELD_PRIORITY: case CAL_COMPONENT_FIELD_SUMMARY: + case CAL_COMPONENT_FIELD_STATUS: g_free (value); case CAL_COMPONENT_FIELD_TRANSPARENCY: @@ -1469,6 +1514,7 @@ calendar_model_initialize_value (ETableModel *etm, int col) case CAL_COMPONENT_FIELD_SUMMARY: case CAL_COMPONENT_FIELD_TRANSPARENCY: case CAL_COMPONENT_FIELD_URL: + case CAL_COMPONENT_FIELD_STATUS: return init_string (); case CAL_COMPONENT_FIELD_HAS_ALARMS: @@ -1507,6 +1553,7 @@ calendar_model_value_is_empty (ETableModel *etm, int col, const void *value) case CAL_COMPONENT_FIELD_SUMMARY: case CAL_COMPONENT_FIELD_TRANSPARENCY: case CAL_COMPONENT_FIELD_URL: + case CAL_COMPONENT_FIELD_STATUS: return string_is_empty (value); case CAL_COMPONENT_FIELD_HAS_ALARMS: @@ -1541,6 +1588,7 @@ calendar_model_value_to_string (ETableModel *etm, int col, const void *value) case CAL_COMPONENT_FIELD_SUMMARY: case CAL_COMPONENT_FIELD_TRANSPARENCY: case CAL_COMPONENT_FIELD_URL: + case CAL_COMPONENT_FIELD_STATUS: return e_utf8_from_locale_string (value); case CAL_COMPONENT_FIELD_ICON: @@ -1680,6 +1728,8 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data) int *new_idx; CalClientGetStatus status; + g_print ("In calendar model obj_updated_cb\n"); + model = CALENDAR_MODEL (data); priv = model->priv; @@ -1774,6 +1824,8 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data) default: g_assert_not_reached (); } + + g_print ("Out calendar model obj_updated_cb\n"); } /* Callback used when an object is removed in the server */ diff --git a/calendar/gui/dialogs/cal-prefs-dialog.c b/calendar/gui/dialogs/cal-prefs-dialog.c index 11577ffc05..9839318e8e 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.c +++ b/calendar/gui/dialogs/cal-prefs-dialog.c @@ -36,6 +36,7 @@ #include "cal-prefs-dialog.h" #include "../calendar-config.h" #include "../calendar-commands.h" +#include "../e-tasks.h" typedef struct { @@ -451,4 +452,5 @@ cal_prefs_dialog_update_config (CalPrefsDialog *prefs) calendar_config_write (); update_all_config_settings (); + e_tasks_update_all_config_settings (); } diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index ba3d1dedb3..f173ac3783 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -36,6 +36,8 @@ #include <gal/e-table/e-cell-checkbox.h> #include <gal/e-table/e-cell-toggle.h> #include <gal/e-table/e-cell-text.h> +#include <gal/e-table/e-cell-combo.h> +#include <widgets/misc/e-cell-date-edit.h> #include "e-calendar-table.h" #include "calendar-model.h" #include "dialogs/delete-comp.h" @@ -158,7 +160,7 @@ static char *list [] = { N_("Start Date"), N_("Due Date"), N_("Geographical Position"), - N_("Precent complete"), + N_("Percent complete"), N_("Priority"), N_("Summary"), N_("Transparency"), @@ -177,34 +179,34 @@ static char *list [] = { " cell=\"calstring\" compare=\"string\"/>" \ " <ETableColumn model_col= \"1\" _title=\"Classification\" " \ " expansion=\"1.0\" minimum_width=\"10\" resizable=\"true\" " \ - " cell=\"calstring\" compare=\"string\"/>" \ + " cell=\"classification\" compare=\"string\"/>" \ " <ETableColumn model_col= \"2\" _title=\"Completion Date\" " \ " expansion=\"2.0\" minimum_width=\"10\" resizable=\"true\" " \ - " cell=\"calstring\" compare=\"string\"/>" \ + " cell=\"dateedit\" compare=\"string\"/>" \ " <ETableColumn model_col= \"3\" _title=\"End Date\" " \ " expansion=\"2.0\" minimum_width=\"10\" resizable=\"true\" " \ - " cell=\"calstring\" compare=\"string\"/>" \ + " cell=\"dateedit\" compare=\"string\"/>" \ " <ETableColumn model_col= \"4\" _title=\"Start Date\" " \ " expansion=\"2.0\" minimum_width=\"10\" resizable=\"true\" " \ - " cell=\"calstring\" compare=\"string\"/>" \ + " cell=\"dateedit\" compare=\"string\"/>" \ " <ETableColumn model_col= \"5\" _title=\"Due Date\" " \ " expansion=\"2.0\" minimum_width=\"10\" resizable=\"true\" " \ - " cell=\"calstring\" compare=\"string\"/>" \ + " cell=\"dateedit\" compare=\"string\"/>" \ " <ETableColumn model_col= \"6\" _title=\"Geographical Position\" " \ " expansion=\"1.0\" minimum_width=\"10\" resizable=\"true\" " \ " cell=\"calstring\" compare=\"string\"/>" \ " <ETableColumn model_col= \"7\" _title=\"% Complete\" " \ " expansion=\"1.0\" minimum_width=\"10\" resizable=\"true\" " \ - " cell=\"calstring\" compare=\"string\"/>" \ + " cell=\"percent\" compare=\"string\"/>" \ " <ETableColumn model_col= \"8\" _title=\"Priority\" " \ " expansion=\"1.0\" minimum_width=\"10\" resizable=\"true\" " \ - " cell=\"calstring\" compare=\"string\"/>" \ + " cell=\"priority\" compare=\"string\"/>" \ " <ETableColumn model_col= \"9\" _title=\"Summary\" " \ " expansion=\"3.0\" minimum_width=\"10\" resizable=\"true\" " \ " cell=\"calstring\" compare=\"string\"/>" \ " <ETableColumn model_col=\"10\" _title=\"Transparency\" " \ " expansion=\"1.0\" minimum_width=\"10\" resizable=\"true\" " \ - " cell=\"calstring\" compare=\"string\"/>" \ + " cell=\"transparency\" compare=\"string\"/>" \ " <ETableColumn model_col=\"11\" _title=\"URL\" " \ " expansion=\"2.0\" minimum_width=\"10\" resizable=\"true\" " \ " cell=\"calstring\" compare=\"string\"/>" \ @@ -214,9 +216,12 @@ static char *list [] = { " <ETableColumn model_col=\"13\" pixbuf=\"icon\" _title=\"Type\" "\ " expansion=\"1.0\" minimum_width=\"16\" resizable=\"false\" "\ " cell=\"icon\" compare=\"integer\"/>" \ - " <ETableColumn model_col=\"14\" pixbuf=\"complete\" _title=\"Compelete\" " \ + " <ETableColumn model_col=\"14\" pixbuf=\"complete\" _title=\"Complete\" " \ " expansion=\"1.0\" minimum_width=\"16\" resizable=\"false\" "\ " cell=\"checkbox\" compare=\"integer\"/>" \ + " <ETableColumn model_col=\"18\" _title=\"Status\" " \ + " expansion=\"1.0\" minimum_width=\"10\" resizable=\"true\" " \ + " cell=\"calstatus\" compare=\"string\"/>" \ " <ETableState>" \ " <column source=\"13\"/>" \ " <column source=\"14\"/>" \ @@ -230,13 +235,14 @@ e_calendar_table_init (ECalendarTable *cal_table) { GtkWidget *table; ETable *e_table; - ECell *cell; + ECell *cell, *popup_cell; ETableExtras *extras; gint i; GdkPixbuf *pixbuf; GdkColormap *colormap; gboolean success[E_CALENDAR_TABLE_COLOR_LAST]; gint nfailed; + GList *strings; /* Allocate the colors we need. */ @@ -271,14 +277,160 @@ e_calendar_table_init (ECalendarTable *cal_table) extras = e_table_extras_new(); + /* + * Normal string fields. + */ cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); gtk_object_set (GTK_OBJECT (cell), "strikeout_column", CAL_COMPONENT_FIELD_COMPLETE, "bold_column", CAL_COMPONENT_FIELD_OVERDUE, "color_column", CAL_COMPONENT_FIELD_COLOR, NULL); + e_table_extras_add_cell (extras, "calstring", cell); + + /* + * Date fields. + */ + cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); + gtk_object_set (GTK_OBJECT (cell), + "strikeout_column", CAL_COMPONENT_FIELD_COMPLETE, + "bold_column", CAL_COMPONENT_FIELD_OVERDUE, + "color_column", CAL_COMPONENT_FIELD_COLOR, + NULL); + + popup_cell = e_cell_date_edit_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + gtk_object_unref (GTK_OBJECT (cell)); + e_table_extras_add_cell (extras, "dateedit", popup_cell); + cal_table->dates_cell = E_CELL_DATE_EDIT (popup_cell); + + + /* + * Combo fields. + */ + + /* Classification field. */ + cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); + gtk_object_set (GTK_OBJECT (cell), + "strikeout_column", CAL_COMPONENT_FIELD_COMPLETE, + "bold_column", CAL_COMPONENT_FIELD_OVERDUE, + "color_column", CAL_COMPONENT_FIELD_COLOR, + "editable", FALSE, + NULL); + + popup_cell = e_cell_combo_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + gtk_object_unref (GTK_OBJECT (cell)); + + strings = NULL; + strings = g_list_append (strings, _("None")); + strings = g_list_append (strings, _("Public")); + strings = g_list_append (strings, _("Private")); + strings = g_list_append (strings, _("Confidential")); + e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), + strings); + + e_table_extras_add_cell (extras, "classification", popup_cell); + + /* Priority field. */ + cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); + gtk_object_set (GTK_OBJECT (cell), + "strikeout_column", CAL_COMPONENT_FIELD_COMPLETE, + "bold_column", CAL_COMPONENT_FIELD_OVERDUE, + "color_column", CAL_COMPONENT_FIELD_COLOR, + "editable", FALSE, + NULL); + + popup_cell = e_cell_combo_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + gtk_object_unref (GTK_OBJECT (cell)); + + strings = NULL; + strings = g_list_append (strings, _("High")); + strings = g_list_append (strings, _("Normal")); + strings = g_list_append (strings, _("Low")); + strings = g_list_append (strings, _("Undefined")); + e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), + strings); + + e_table_extras_add_cell (extras, "priority", popup_cell); + + /* Percent field. */ + cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); + gtk_object_set (GTK_OBJECT (cell), + "strikeout_column", CAL_COMPONENT_FIELD_COMPLETE, + "bold_column", CAL_COMPONENT_FIELD_OVERDUE, + "color_column", CAL_COMPONENT_FIELD_COLOR, + NULL); + + popup_cell = e_cell_combo_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + gtk_object_unref (GTK_OBJECT (cell)); + + strings = NULL; + strings = g_list_append (strings, _("0%")); + strings = g_list_append (strings, _("10%")); + strings = g_list_append (strings, _("20%")); + strings = g_list_append (strings, _("30%")); + strings = g_list_append (strings, _("40%")); + strings = g_list_append (strings, _("50%")); + strings = g_list_append (strings, _("60%")); + strings = g_list_append (strings, _("70%")); + strings = g_list_append (strings, _("80%")); + strings = g_list_append (strings, _("90%")); + strings = g_list_append (strings, _("100%")); + e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), + strings); + + e_table_extras_add_cell (extras, "percent", popup_cell); + + /* Transparency field. */ + cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); + gtk_object_set (GTK_OBJECT (cell), + "strikeout_column", CAL_COMPONENT_FIELD_COMPLETE, + "bold_column", CAL_COMPONENT_FIELD_OVERDUE, + "color_column", CAL_COMPONENT_FIELD_COLOR, + "editable", FALSE, + NULL); + + popup_cell = e_cell_combo_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + gtk_object_unref (GTK_OBJECT (cell)); + + strings = NULL; + strings = g_list_append (strings, _("None")); + strings = g_list_append (strings, _("Opaque")); + strings = g_list_append (strings, _("Transparent")); + e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), + strings); + + e_table_extras_add_cell (extras, "transparency", popup_cell); + + /* Status field. */ + cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); + gtk_object_set (GTK_OBJECT (cell), + "strikeout_column", CAL_COMPONENT_FIELD_COMPLETE, + "bold_column", CAL_COMPONENT_FIELD_OVERDUE, + "color_column", CAL_COMPONENT_FIELD_COLOR, + "editable", FALSE, + NULL); + + popup_cell = e_cell_combo_new (); + e_cell_popup_set_child (E_CELL_POPUP (popup_cell), cell); + gtk_object_unref (GTK_OBJECT (cell)); + + strings = NULL; + strings = g_list_append (strings, _("Not Started")); + strings = g_list_append (strings, _("In Progress")); + strings = g_list_append (strings, _("Completed")); + strings = g_list_append (strings, _("Cancelled")); + e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), + strings); + + e_table_extras_add_cell (extras, "calstatus", popup_cell); + /* Create pixmaps */ if (!icon_pixbufs[0]) diff --git a/calendar/gui/e-calendar-table.h b/calendar/gui/e-calendar-table.h index 89a57552b3..e19ecf82e8 100644 --- a/calendar/gui/e-calendar-table.h +++ b/calendar/gui/e-calendar-table.h @@ -26,6 +26,7 @@ #define _E_CALENDAR_TABLE_H_ #include <gtk/gtktable.h> +#include <widgets/misc/e-cell-date-edit.h> #include "calendar-model.h" #ifdef __cplusplus @@ -78,6 +79,9 @@ struct _ECalendarTable ECalendarTableFilterFunc filter_func; gpointer filter_data; GDestroyNotify filter_data_destroy; + + /* The ECell used to view & edit dates. */ + ECellDateEdit *dates_cell; }; struct _ECalendarTableClass diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index bbf0732122..537ef44ebc 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -38,10 +38,11 @@ #include "e-day-view-top-item.h" #include "e-day-view-main-item.h" #include "calendar-commands.h" -#include "popup-menu.h" #include <gal/widgets/e-canvas.h> #include <gal/e-text/e-text.h> #include <gal/widgets/e-canvas-utils.h> +#include <gal/widgets/e-gui-utils.h> +#include <gal/widgets/e-popup-menu.h> #include "e-meeting-edit.h" /* Images */ @@ -2989,63 +2990,96 @@ e_day_view_on_event_double_click (EDayView *day_view, gint day, gint event_num) { -#if 0 - g_print ("In e_day_view_on_event_double_click\n"); -#endif - } +enum { + /* + * This is used to "flag" events that can not be editted + */ + MASK_EDITABLE = 1, -static void -e_day_view_on_event_right_click (EDayView *day_view, - GdkEventButton *bevent, - gint day, - gint event_num) -{ - EDayViewEvent *event; - int have_selection, not_being_edited, items, i; - struct menu_item *context_menu; - - static struct menu_item main_items[] = { - { N_("New appointment..."), (GtkSignalFunc) e_day_view_on_new_appointment, NULL, TRUE } - }; - - static struct menu_item child_items[] = { - { N_("Schedule meeting"), (GtkSignalFunc) e_day_view_on_schedule_meet, NULL, TRUE }, + /* + * To disable recurring actions to be displayed + */ + MASK_RECURRING = 2, - { NULL, NULL, NULL, TRUE}, + /* + * To disable actions for non-recurring items to be displayed + */ + MASK_SINGLE = 4, - { N_("Edit this appointment..."), (GtkSignalFunc) e_day_view_on_edit_appointment, NULL, TRUE }, - { N_("Delete this appointment"), (GtkSignalFunc) e_day_view_on_delete_appointment, NULL, TRUE }, + /* + * This is used to when an event is currently being edited + * in another window and we want to disable the event + * from being edited twice + */ + MASK_EDITING = 8 +}; - { NULL, NULL, NULL, TRUE}, - - { N_("New appointment..."), (GtkSignalFunc) e_day_view_on_new_appointment, NULL, TRUE } - }; +static EPopupMenu main_items [] = { + { N_("New Appointment..."), NULL, + e_day_view_on_new_appointment, NULL, 0 }, + { NULL, NULL, NULL, NULL, 0 } +}; - static struct menu_item recur_child_items[] = { - { N_("Make this appointment movable"), (GtkSignalFunc) e_day_view_on_unrecur_appointment, NULL, TRUE }, - { N_("Schedule meeting"), (GtkSignalFunc) e_day_view_on_schedule_meet, NULL, TRUE }, +static EPopupMenu child_items [] = { + { N_("Open"), NULL, + e_day_view_on_edit_appointment, NULL, MASK_EDITABLE | MASK_EDITING }, + { N_("Delete this Appointment"), NULL, + e_day_view_on_delete_appointment, NULL, MASK_EDITABLE | MASK_SINGLE | MASK_EDITING }, + { N_("Schedule Meeting"), NULL, + e_day_view_on_schedule_meet, NULL, MASK_EDITING }, + { "", NULL, NULL, NULL, 0}, - { NULL, NULL, NULL, TRUE}, + { N_("New Appointment..."), NULL, + e_day_view_on_new_appointment, NULL, 0 }, - { N_("Edit this appointment..."), (GtkSignalFunc) e_day_view_on_edit_appointment, NULL, TRUE }, - { N_("Delete this occurrence"), (GtkSignalFunc) e_day_view_on_delete_occurrence, NULL, TRUE }, - { N_("Delete all occurrences"), (GtkSignalFunc) e_day_view_on_delete_appointment, NULL, TRUE }, + { "", NULL, NULL, NULL, MASK_SINGLE}, - { NULL, NULL, NULL, TRUE}, + /* + * The following are only shown if this is a recurring event + */ + { "", NULL, NULL, NULL, MASK_SINGLE}, + { N_("Make this Occurrence Movable"), NULL, + e_day_view_on_unrecur_appointment, NULL, MASK_RECURRING | MASK_EDITING }, + { N_("Delete this Occurrence"), NULL, + e_day_view_on_delete_occurrence, NULL, MASK_RECURRING | MASK_EDITING }, + { N_("Delete all Occurrences"), NULL, + e_day_view_on_delete_appointment, NULL, MASK_RECURRING | MASK_EDITING }, + + { NULL, NULL, NULL, NULL, 0 } +}; - { N_("New appointment..."), (GtkSignalFunc) e_day_view_on_new_appointment, NULL, TRUE }, - }; +static void +e_day_view_on_event_right_click (EDayView *day_view, + GdkEventButton *bevent, + gint day, + gint event_num) +{ + EDayViewEvent *event; + int have_selection; + gboolean being_edited; + EPopupMenu *context_menu; + int hide_mask = 0; + int disable_mask = 0; + /* + * FIXME: + * This used to be set only if the event wasn't being edited + * in the event editor, but we can't check that at present. + * We could possibly set up another method of checking it. + */ + + being_edited = FALSE; + have_selection = GTK_WIDGET_HAS_FOCUS (day_view) && day_view->selection_start_day != -1; - if (event_num == -1) { - items = 1; - context_menu = &main_items[0]; - context_menu[0].sensitive = have_selection; - } else { + if (event_num == -1) + context_menu = main_items; + else { + context_menu = child_items; + if (day == E_DAY_VIEW_LONG_EVENT) event = &g_array_index (day_view->long_events, EDayViewEvent, event_num); @@ -3053,36 +3087,19 @@ e_day_view_on_event_right_click (EDayView *day_view, event = &g_array_index (day_view->events[day], EDayViewEvent, event_num); - /* This used to be set only if the event wasn't being edited - in the event editor, but we can't check that at present. - We could possibly set up another method of checking it. */ - not_being_edited = TRUE; - - if (cal_component_has_recurrences (event->comp)) { - items = 8; - context_menu = &recur_child_items[0]; - context_menu[0].sensitive = not_being_edited; - context_menu[1].sensitive = not_being_edited; - context_menu[3].sensitive = not_being_edited; - context_menu[4].sensitive = not_being_edited; - context_menu[5].sensitive = not_being_edited; - context_menu[7].sensitive = have_selection; - } else { - items = 6; - context_menu = &child_items[0]; - context_menu[0].sensitive = not_being_edited; - context_menu[2].sensitive = not_being_edited; - context_menu[3].sensitive = not_being_edited; - context_menu[5].sensitive = have_selection; - } + if (cal_component_has_recurrences (event->comp)) + hide_mask |= MASK_SINGLE; + else + hide_mask |= MASK_RECURRING; } - for (i = 0; i < items; i++) - context_menu[i].data = day_view; + if (being_edited) + disable_mask |= MASK_EDITING; day_view->popup_event_day = day; day_view->popup_event_num = event_num; - popup_menu (context_menu, items, bevent); + + e_popup_menu_run (context_menu, (GdkEvent *) bevent, disable_mask, hide_mask, day_view); } diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c index 92917d6d55..237f90959e 100644 --- a/calendar/gui/e-tasks.c +++ b/calendar/gui/e-tasks.c @@ -37,6 +37,10 @@ #include "e-tasks.h" +/* A list of all of the ETasks widgets in use. We use this to update the + user preference settings. This will change when we switch to GConf. */ +static GList *all_tasks = NULL; + /* Private part of the GnomeCalendar structure */ struct _ETasksPrivate { @@ -160,6 +164,7 @@ setup_widgets (ETasks *tasks) gtk_table_attach (GTK_TABLE (tasks), priv->tasks_view, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (priv->tasks_view); + calendar_config_configure_e_calendar_table (E_CALENDAR_TABLE (priv->tasks_view)); gtk_signal_connect (GTK_OBJECT (E_CALENDAR_TABLE (priv->tasks_view)->model), "categories-changed", @@ -212,6 +217,8 @@ e_tasks_new (void) return NULL; } + all_tasks = g_list_prepend (all_tasks, tasks); + return GTK_WIDGET (tasks); } @@ -246,6 +253,8 @@ e_tasks_destroy (GtkObject *object) g_free (priv); tasks->priv = NULL; + all_tasks = g_list_remove (all_tasks, tasks); + if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } @@ -565,3 +574,20 @@ e_tasks_setup_menus (ETasks *tasks, gtk_object_sink (GTK_OBJECT (collection)); } + + +/* This updates all the preference settings for all the ETasks widgets in use. + */ +void +e_tasks_update_all_config_settings () +{ + ETasks *tasks; + ETasksPrivate *priv; + GList *elem; + + for (elem = all_tasks; elem; elem = elem->next) { + tasks = E_TASKS (elem->data); + priv = tasks->priv; + calendar_config_configure_e_calendar (E_CALENDAR_TABLE (priv->tasks_view)); + } +} diff --git a/calendar/gui/e-tasks.h b/calendar/gui/e-tasks.h index 94dc8607f6..03b4abf142 100644 --- a/calendar/gui/e-tasks.h +++ b/calendar/gui/e-tasks.h @@ -68,4 +68,8 @@ void e_tasks_setup_menus (ETasks *tasks, BonoboUIComponent *uic); +/* This updates all the preference settings for all the ETasks widgets in use. + */ +void e_tasks_update_all_config_settings (void); + #endif /* _E_TASKS_H_ */ diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 74c0df4f9c..91a5219c87 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -39,9 +39,10 @@ #include "e-week-view-main-item.h" #include "e-week-view-titles-item.h" #include <cal-util/timeutil.h> -#include "popup-menu.h" #include <gal/widgets/e-canvas.h> #include <gal/e-text/e-text.h> +#include <gal/widgets/e-popup-menu.h> +#include <gal/widgets/e-gui-utils.h> #include <gal/widgets/e-canvas-utils.h> #include "e-meeting-edit.h" @@ -3199,86 +3200,102 @@ e_week_view_key_press (GtkWidget *widget, GdkEventKey *event) return TRUE; } +enum { + /* + * This is used to "flag" events that can not be editted + */ + MASK_EDITABLE = 1, -void -e_week_view_show_popup_menu (EWeekView *week_view, - GdkEventButton *bevent, - gint event_num) -{ - EWeekViewEvent *event; - int have_selection, not_being_edited, num_items, i; - struct menu_item *context_menu; - - static struct menu_item items[] = { - { N_("New appointment..."), (GtkSignalFunc) e_week_view_on_new_appointment, NULL, TRUE } - }; - - static struct menu_item child_items[] = { - { N_("Schedule meeting"), (GtkSignalFunc) e_week_view_on_schedule_meet, NULL, TRUE }, - - { NULL, NULL, NULL, TRUE}, + /* + * To disable recurring actions to be displayed + */ + MASK_RECURRING = 2, - { N_("Edit this appointment..."), (GtkSignalFunc) e_week_view_on_edit_appointment, NULL, TRUE }, - { N_("Delete this appointment"), (GtkSignalFunc) e_week_view_on_delete_appointment, NULL, TRUE }, + /* + * To disable actions for non-recurring items to be displayed + */ + MASK_SINGLE = 4, - { NULL, NULL, NULL, TRUE }, + /* + * This is used to when an event is currently being edited + * in another window and we want to disable the event + * from being edited twice + */ + MASK_EDITING = 8 +}; - { N_("New appointment..."), (GtkSignalFunc) e_week_view_on_new_appointment, NULL, TRUE } - }; +static EPopupMenu main_items [] = { + { N_("New Appointment..."), NULL, + e_week_view_on_new_appointment, NULL, 0 }, + { NULL, NULL, NULL, NULL, 0 } +}; - static struct menu_item recur_child_items[] = { - { N_("Make this appointment movable"), (GtkSignalFunc) e_week_view_on_unrecur_appointment, NULL, TRUE }, - { N_("Schedule meeting"), (GtkSignalFunc) e_week_view_on_schedule_meet, NULL, TRUE }, +static EPopupMenu child_items [] = { + { N_("Open"), NULL, + e_week_view_on_edit_appointment, NULL, MASK_EDITABLE | MASK_EDITING }, + { N_("Delete this Appointment"), NULL, + e_week_view_on_delete_appointment, NULL, MASK_EDITABLE | MASK_SINGLE | MASK_EDITING }, + { N_("Schedule Meeting"), NULL, + e_week_view_on_schedule_meet, NULL, MASK_EDITING }, + { "", NULL, NULL, NULL, 0}, - { NULL, NULL, NULL, TRUE }, + { N_("New Appointment..."), NULL, + e_week_view_on_new_appointment, NULL, 0 }, - { N_("Edit this appointment..."), (GtkSignalFunc) e_week_view_on_edit_appointment, NULL, TRUE }, - { N_("Delete this occurrence"), (GtkSignalFunc) e_week_view_on_delete_occurrence, NULL, TRUE }, - { N_("Delete all occurrences"), (GtkSignalFunc) e_week_view_on_delete_appointment, NULL, TRUE }, + { "", NULL, NULL, NULL, MASK_SINGLE }, - { NULL, NULL, NULL, TRUE }, + /* + * The following are only shown if this is a recurring event + */ + { "", NULL, NULL, NULL, MASK_SINGLE}, + { N_("Make this Occurrence Movable"), NULL, + e_week_view_on_unrecur_appointment, NULL, MASK_RECURRING | MASK_EDITING }, + { N_("Delete this Occurrence"), NULL, + e_week_view_on_delete_occurrence, NULL, MASK_RECURRING | MASK_EDITING }, + { N_("Delete All Occurrences"), NULL, + e_week_view_on_delete_appointment, NULL, MASK_RECURRING | MASK_EDITING }, + + { NULL, NULL, NULL, NULL, 0 } +}; - { N_("New appointment..."), (GtkSignalFunc) e_week_view_on_new_appointment, NULL, TRUE } - }; +void +e_week_view_show_popup_menu (EWeekView *week_view, + GdkEventButton *bevent, + gint event_num) +{ + EWeekViewEvent *event; + int have_selection; + gboolean being_edited; + guint32 disable_mask = 0, hide_mask = 0; + EPopupMenu *context_menu; have_selection = GTK_WIDGET_HAS_FOCUS (week_view) && week_view->selection_start_day != -1; + /* + * This used to be set only if the event wasn't being edited + * in the event editor, but we can't check that at present. + * We could possibly set up another method of checking it. + */ + being_edited = FALSE; + if (event_num == -1) { - num_items = 1; - context_menu = &items[0]; - context_menu[0].sensitive = have_selection; + context_menu = main_items; } else { + context_menu = child_items; event = &g_array_index (week_view->events, EWeekViewEvent, event_num); - - /* This used to be set only if the event wasn't being edited - in the event editor, but we can't check that at present. - We could possibly set up another method of checking it. */ - not_being_edited = TRUE; - - if (cal_component_has_recurrences (event->comp)) { - num_items = 7; - context_menu = &recur_child_items[0]; - context_menu[0].sensitive = not_being_edited; - context_menu[2].sensitive = not_being_edited; - context_menu[3].sensitive = not_being_edited; - context_menu[4].sensitive = not_being_edited; - context_menu[6].sensitive = have_selection; - } else { - num_items = 4; - context_menu = &child_items[0]; - context_menu[0].sensitive = not_being_edited; - context_menu[1].sensitive = not_being_edited; - context_menu[3].sensitive = have_selection; - } + if (cal_component_has_recurrences (event->comp)) + hide_mask |= MASK_SINGLE; + else + hide_mask |= MASK_RECURRING; } - for (i = 0; i < num_items; i++) - context_menu[i].data = week_view; - + if (being_edited) + disable_mask |= MASK_EDITING; week_view->popup_event_num = event_num; - popup_menu (context_menu, num_items, bevent); + + e_popup_menu_run (context_menu, (GdkEvent *) bevent, disable_mask, hide_mask, week_view); } diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 3937d31781..588a7a6687 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -252,6 +252,7 @@ setup_widgets (GnomeCalendar *gcal) /* The ToDo list. */ priv->todo = e_calendar_table_new (); + calendar_config_configure_e_calendar_table (E_CALENDAR_TABLE (priv->todo)); model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)); calendar_model_set_new_comp_vtype (model, CAL_COMPONENT_TODO); e_paned_pack2 (E_PANED (priv->vpane), priv->todo, TRUE, TRUE); @@ -1011,6 +1012,8 @@ gnome_calendar_update_config_settings (GnomeCalendar *gcal, calendar_config_configure_e_calendar (E_CALENDAR (priv->date_navigator)); + calendar_config_configure_e_calendar_table (E_CALENDAR_TABLE (priv->todo)); + if (initializing) { priv->hpane_pos = calendar_config_get_hpane_pos (); priv->vpane_pos = calendar_config_get_vpane_pos (); diff --git a/calendar/gui/popup-menu.c b/calendar/gui/popup-menu.c deleted file mode 100644 index 550fede0f3..0000000000 --- a/calendar/gui/popup-menu.c +++ /dev/null @@ -1,43 +0,0 @@ -/* Popup menu utilities for gncal - * - * Copyright (C) 1998 The Free Software Foundation - * - * Author: Federico Mena <quartic@gimp.org> - */ - -#include <config.h> -#include <gtk/gtkmenuitem.h> -#include <libgnome/gnome-defs.h> -#include <libgnome/gnome-i18n.h> -#include <gal/widgets/e-gui-utils.h> -#include "popup-menu.h" - - -void -popup_menu (struct menu_item *items, int nitems, GdkEventButton *event) -{ - GtkWidget *menu; - GtkWidget *item; - int i; - - menu = gtk_menu_new (); - - /* Make sure the menu is destroyed when it disappears. */ - e_auto_kill_popup_menu_on_hide (GTK_MENU (menu)); - - for (i = 0; i < nitems; i++) { - if (items[i].text) { - item = gtk_menu_item_new_with_label (_(items[i].text)); - gtk_signal_connect (GTK_OBJECT (item), "activate", - items[i].callback, - items[i].data); - gtk_widget_set_sensitive (item, items[i].sensitive); - } else - item = gtk_menu_item_new (); - - gtk_widget_show (item); - gtk_menu_append (GTK_MENU (menu), item); - } - - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, event->button, event->time); -} diff --git a/calendar/gui/popup-menu.h b/calendar/gui/popup-menu.h deleted file mode 100644 index a4590dbb98..0000000000 --- a/calendar/gui/popup-menu.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Popup menu utilities for gncal - * - * Copyright (C) 1998 The Free Software Foundation - * - * Author: Federico Mena <quartic@gimp.org> - */ - -#ifndef POPUP_MENU_H -#define POPUP_MENU_H - -#include <gdk/gdktypes.h> -#include <gtk/gtksignal.h> - - -struct menu_item { - char *text; - GtkSignalFunc callback; - gpointer data; - int sensitive; -}; - -void popup_menu (struct menu_item *items, int nitems, GdkEventButton *event); - - -#endif diff --git a/calendar/gui/print.c b/calendar/gui/print.c index 9d5b5f891d..1f87a82aaf 100644 --- a/calendar/gui/print.c +++ b/calendar/gui/print.c @@ -24,6 +24,7 @@ #include <sys/stat.h> #include <sys/time.h> #include <math.h> +#include <time.h> #include <libgnome/gnome-paper.h> #include <libgnomeui/gnome-dialog.h> #include <libgnomeprint/gnome-print.h> |