From 82925c6be94e9e48e4ef521a88a9feec24cf9eef Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 31 Oct 2010 16:02:30 -0400 Subject: Pass an EAlertSink to e_alert_sink_submit_alert(). Passing a random GtkWidget and then searching its ancestors for an EAlertSink turned out to be not as useful as I thought. Most of the time we know about and have access to the widget that implements EAlertSink, so just pass it directly as an EAlertSink. --- calendar/gui/dialogs/comp-editor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'calendar') diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index eb908d1e33..af5b23d384 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -834,7 +834,7 @@ action_save_cb (GtkAction *action, if (!e_cal_is_read_only (priv->client, &read_only, NULL) || read_only) { e_alert_submit ( - GTK_WIDGET (editor), + E_ALERT_SINK (editor), "calendar:prompt-read-only-cal-editor", e_source_peek_name ( e_cal_get_source (priv->client)), @@ -1881,7 +1881,7 @@ prompt_and_save_changes (CompEditor *editor, gboolean send) case GTK_RESPONSE_YES: /* Save */ if (!e_cal_is_read_only (priv->client, &read_only, NULL) || read_only) { e_alert_submit ( - GTK_WIDGET (editor), + E_ALERT_SINK (editor), "calendar:prompt-read-only-cal-editor", e_source_peek_name ( e_cal_get_source (priv->client)), -- cgit From 3bffd96b038194ceef081735197278b0c8cd080d Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 1 Nov 2010 11:40:59 +0100 Subject: stock_appontment-reminder icons renamed (reverts previous commit) --- calendar/gui/alarm-notify/alarm-queue.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'calendar') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index 752ce3749e..e8b3f86201 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -1390,9 +1390,9 @@ tray_icon_blink_cb (gpointer data) tray_blink_state = !tray_blink_state; if (tray_blink_state || tray_blink_countdown <= 0) - icon_name = "stock_appointment-reminder-excl"; + icon_name = "appointment-missed"; else - icon_name = "stock_appointment-reminder"; + icon_name = "appointment-soon"; if (tray_icon) gtk_status_icon_set_from_icon_name (tray_icon, icon_name); @@ -1479,7 +1479,7 @@ display_notification (time_t trigger, CompQueuedAlarms *cqa, if (tray_icon == NULL) { tray_icon = gtk_status_icon_new (); gtk_status_icon_set_from_icon_name ( - tray_icon, "stock_appointment-reminder"); + tray_icon, "appointment-soon"); g_signal_connect (G_OBJECT (tray_icon), "activate", G_CALLBACK (icon_activated), NULL); g_signal_connect (G_OBJECT (tray_icon), "popup-menu", @@ -1607,9 +1607,9 @@ popup_notification (time_t trigger, CompQueuedAlarms *cqa, } #ifdef HAVE_LIBNOTIFY_07 - n = notify_notification_new (summary, body, "stock_appointment-reminder"); + n = notify_notification_new (summary, body, "appointment-soon"); #else - n = notify_notification_new (summary, body, "stock_appointment-reminder", NULL); + n = notify_notification_new (summary, body, "appointment-soon", NULL); #endif /* HAVE_LIBNOTIFY_07 */ if (!notify_notification_show (n, NULL)) g_warning ("Could not send notification to daemon\n"); -- cgit From 966c22cc9440851d166a530c7e187e0f80633c57 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 1 Nov 2010 17:39:52 +0100 Subject: Bug #484554 - Day names can overlap in calendar printouts --- calendar/gui/print.c | 176 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 114 insertions(+), 62 deletions(-) (limited to 'calendar') diff --git a/calendar/gui/print.c b/calendar/gui/print.c index ebbaead1a0..abd844b34a 100644 --- a/calendar/gui/print.c +++ b/calendar/gui/print.c @@ -49,6 +49,7 @@ #include "e-day-view-layout.h" #include "e-week-view.h" #include "e-week-view-layout.h" +#include "e-task-table.h" #include "gnome-cal.h" #include "print.h" @@ -87,6 +88,26 @@ evo_calendar_print_renderer_get_width (GtkPrintContext *context, return pango_units_to_double (layout_width); } +static gdouble +evo_calendar_print_renderer_get_height (GtkPrintContext *context, + PangoFontDescription *font, + const gchar *text) +{ + PangoLayout *layout; + gint layout_width, layout_height; + + layout = gtk_print_context_create_pango_layout (context); + + pango_layout_set_font_description (layout, font); + pango_layout_set_text (layout, text, -1); + pango_layout_set_indent (layout, 0); + pango_layout_get_size (layout, &layout_width, &layout_height); + + g_object_unref (layout); + + return pango_units_to_double (layout_height); +} + static double get_font_size (PangoFontDescription *font) { @@ -123,7 +144,7 @@ get_font_size (PangoFontDescription *font) /* The width of the small calendar months, the space from the right edge of the header rectangle, and the space between the months. */ -#define SMALL_MONTH_WIDTH 100 +#define MIN_SMALL_MONTH_WIDTH 100 #define SMALL_MONTH_PAD 5 #define SMALL_MONTH_SPACING 20 @@ -479,7 +500,6 @@ print_text_size_bold (GtkPrintContext *context, const gchar *text, return w; } -#if 0 /* KILL-BONOBO */ static void titled_box (GtkPrintContext *context, const gchar *text, PangoFontDescription *font, PangoAlignment alignment, @@ -488,16 +508,15 @@ titled_box (GtkPrintContext *context, const gchar *text, { gdouble size; - size = get_font_size (font); - print_border (context, *x1, *x2, *y1, *y1 + size * 1.4, linewidth, 0.9); - print_border (context, *x1, *x2, *y1 + size * 1.4, *y2, linewidth, -1.0); + size = evo_calendar_print_renderer_get_height (context, font, text); + print_border (context, *x1, *x2, *y1, *y1 + size + 2, linewidth, 0.9); + print_border (context, *x1, *x2, *y1 + size + 2, *y2, linewidth, -1.0); *x1 += 2; *x2 -= 2; *y2 += 2; - print_text (context, font, text, alignment, *x1, *x2, *y1 + 1.0, *y1 + size * 1.4); - *y1 += size * 1.4; + print_text (context, font, text, alignment, *x1, *x2, *y1 + 1.0, *y1 + size); + *y1 += size + 2; } -#endif /* KILL-BONOBO */ static gboolean get_show_week_numbers (void) @@ -575,6 +594,36 @@ instance_cb (ECalComponent *comp, return FALSE; } +/* Translators: These are workday abbreviations, e.g. Su=Sunday and Th=thursday */ +const gchar *daynames[] = + { N_("Su"), N_("Mo"), N_("Tu"), N_("We"), + N_("Th"), N_("Fr"), N_("Sa") }; + +static gdouble +calc_small_month_width (GtkPrintContext *context, gdouble for_height) +{ + + PangoFontDescription *font_bold; + gdouble res = 0.0; + gint ii; + + font_bold = get_font_for_size (for_height / 7.4, PANGO_WEIGHT_BOLD); + res = MAX (evo_calendar_print_renderer_get_width (context, font_bold, "23"), res); + for (ii = 0; ii < 7; ii++) { + res = MAX (evo_calendar_print_renderer_get_width (context, font_bold, _(daynames[ii])), res); + } + + pango_font_description_free (font_bold); + + /* res is max cell width, thus multiply it with column count plus some space between columns */ + res = (res + 1.0) * (7 + (get_show_week_numbers () ? 1 : 0)) - 1.0; + + if (res < MIN_SMALL_MONTH_WIDTH) + res = MIN_SMALL_MONTH_WIDTH; + + return res; +} + /* print out the month small, embolden any days with events. */ @@ -596,11 +645,6 @@ print_month_small (GtkPrintContext *context, GnomeCalendar *gcal, time_t month, gdouble header_size, col_width, row_height, text_xpad, w; gdouble cell_top, cell_bottom, cell_left, cell_right, text_right; gboolean week_numbers; - - /* Translators: These are workday abbreviations, e.g. Su=Sunday and Th=thursday */ - const gchar *daynames[] = - { N_("Su"), N_("Mo"), N_("Tu"), N_("We"), - N_("Th"), N_("Fr"), N_("Sa") }; cairo_t *cr; week_numbers = get_show_week_numbers (); @@ -807,9 +851,11 @@ print_day_background (GtkPrintContext *context, GnomeCalendar *gcal, const gchar *minute; gboolean use_24_hour; gint i, hour, row; - gdouble hour_minute_x; + gdouble hour_minute_x, hour_minute_width; cairo_t *cr; + use_24_hour = calendar_config_get_24_hour_format (); + /* Fill the time column in light-gray. */ print_border (context, left, left + width, top, bottom, -1.0, 0.9); @@ -834,19 +880,20 @@ print_day_background (GtkPrintContext *context, GnomeCalendar *gcal, /* Get the 2 fonts we need. */ font_size = yinc * 0.6; - max_font_size = width * 0.5; + max_font_size = width * 0.45; hour_font_size = MIN (font_size, max_font_size); font_hour = get_font_for_size (hour_font_size, PANGO_WEIGHT_BOLD); font_size = yinc * 0.33; - max_font_size = width * 0.25; + max_font_size = width * 0.2; minute_font_size = MIN (font_size, max_font_size); font_minute = get_font_for_size (minute_font_size, PANGO_WEIGHT_BOLD); - - use_24_hour = calendar_config_get_24_hour_format (); + hour_minute_width = evo_calendar_print_renderer_get_width (context, font_minute, use_24_hour ? "00" : _("am")); + if (!use_24_hour) + hour_minute_width = MAX (hour_minute_width, evo_calendar_print_renderer_get_width (context, font_minute, _("pm"))); row = 0; - hour_minute_x = left + width * 0.58; + hour_minute_x = left + width - hour_minute_width - 3; for (i = pdi->start_hour; i < pdi->end_hour; i++) { y = top + yinc * (row + 1); cr = gtk_print_context_get_cairo_context (context); @@ -2086,11 +2133,10 @@ print_todo_details (GtkPrintContext *context, GnomeCalendar *gcal, time_t start, time_t end, double left, double right, double top, double bottom) { -#if 0 /* KILL-BONOBO */ PangoFontDescription *font_summary; gdouble y, yend, x, xend; struct icaltimetype *tt; - ECalendarTable *task_pad; + GtkWidget *task_table; ETable *table; ECalModel *model; gint rows, row; @@ -2098,9 +2144,10 @@ print_todo_details (GtkPrintContext *context, GnomeCalendar *gcal, /* We get the tasks directly from the TaskPad ETable. This means we get them filtered & sorted for free. */ - task_pad = gnome_calendar_get_task_pad (gcal); - table = e_calendar_table_get_table (task_pad); - model = e_calendar_table_get_model (task_pad); + task_table = gnome_calendar_get_task_table (gcal); + table = E_TABLE (task_table); + g_return_if_fail (table != NULL); + model = e_task_table_get_model (E_TASK_TABLE (task_table)); font_summary = get_font_for_size (12, PANGO_WEIGHT_NORMAL); @@ -2176,7 +2223,6 @@ print_todo_details (GtkPrintContext *context, GnomeCalendar *gcal, } pango_font_description_free (font_summary); -#endif } static void @@ -2185,7 +2231,7 @@ print_day_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) GtkPageSetup *setup; icaltimezone *zone = calendar_config_get_icaltimezone (); gint i, days = 1; - gdouble todo, l, week_numbers_inc; + gdouble todo, l, week_numbers_inc, small_month_width; gchar buf[100]; gdouble width, height; @@ -2193,36 +2239,37 @@ print_day_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) width = gtk_page_setup_get_page_width (setup, GTK_UNIT_POINTS); height = gtk_page_setup_get_page_height (setup, GTK_UNIT_POINTS); - week_numbers_inc = get_show_week_numbers () ? SMALL_MONTH_WIDTH / 7.0 : 0; + small_month_width = calc_small_month_width (context, HEADER_HEIGHT); + week_numbers_inc = get_show_week_numbers () ? small_month_width / 7.0 : 0; for (i = 0; i < days; i++) { todo = width * 0.75; /* Print the main view with all the events in. */ print_day_details (context, gcal, date, - 0.0, todo - 2.0, HEADER_HEIGHT, + 0.0, todo - 2.0, HEADER_HEIGHT + 4, height); /* Print the TaskPad down the right. */ print_todo_details (context, gcal, 0, INT_MAX, - todo, width, HEADER_HEIGHT, + todo, width, HEADER_HEIGHT + 4, height); /* Print the filled border around the header. */ print_border (context, 0.0, width, - 0.0, HEADER_HEIGHT + 3.5, 1.0, 0.9); + 0.0, HEADER_HEIGHT + 4, 1.0, 0.9); /* Print the 2 mini calendar-months. */ - l = width - SMALL_MONTH_PAD - (SMALL_MONTH_WIDTH + week_numbers_inc) * 2 - SMALL_MONTH_SPACING; + l = width - SMALL_MONTH_PAD - (small_month_width + week_numbers_inc) * 2 - SMALL_MONTH_SPACING; - print_month_small (context, gcal, date, - l, 4, l + SMALL_MONTH_WIDTH + week_numbers_inc, HEADER_HEIGHT + 4, + print_month_small (context, gcal, date, + l, 2, l + small_month_width + week_numbers_inc, HEADER_HEIGHT + 2, DATE_MONTH | DATE_YEAR, date, date, FALSE); - l += SMALL_MONTH_SPACING + SMALL_MONTH_WIDTH + week_numbers_inc; + l += SMALL_MONTH_SPACING + small_month_width + week_numbers_inc; print_month_small (context, gcal, time_add_month_with_zone (date, 1, zone), - l, 4, l + SMALL_MONTH_WIDTH + week_numbers_inc, HEADER_HEIGHT + 4, + l, 2, l + small_month_width + week_numbers_inc, HEADER_HEIGHT + 2, DATE_MONTH | DATE_YEAR, 0, 0, FALSE); /* Print the date, e.g. '8th May, 2001'. */ @@ -2238,8 +2285,8 @@ print_day_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) print_text_size_bold (context, buf, PANGO_ALIGN_LEFT, 4, todo, - HEADER_HEIGHT + 6, - HEADER_HEIGHT + 6 + 18); + HEADER_HEIGHT + 9, + HEADER_HEIGHT + 9 + 18); date = time_add_day_with_zone (date, 1, zone); } @@ -2263,6 +2310,8 @@ print_work_week_background (GtkPrintContext *context, GnomeCalendar *gcal, gdouble hour_minute_xl, hour_minute_xr; cairo_t *cr; + use_24_hour = calendar_config_get_24_hour_format (); + /* Fill the left time column in light-gray. */ print_border (context, left, left + width, top, bottom, -1.0, 0.9); /* Fill the right time column in light-gray */ @@ -2294,20 +2343,21 @@ print_work_week_background (GtkPrintContext *context, GnomeCalendar *gcal, /* Get the 2 fonts we need. */ font_size = yinc * 0.6; - max_font_size = width * 0.5; + max_font_size = width * 0.45; hour_font_size = MIN (font_size, max_font_size); font_hour = get_font_for_size (hour_font_size, PANGO_WEIGHT_BOLD); font_size = yinc * 0.33; - max_font_size = width * 0.25; + max_font_size = width * 0.2; minute_font_size = MIN (font_size, max_font_size); font_minute = get_font_for_size (minute_font_size, PANGO_WEIGHT_BOLD); - - use_24_hour = calendar_config_get_24_hour_format (); + hour_minute_xr = evo_calendar_print_renderer_get_width (context, font_minute, use_24_hour ? "00" : _("am")); + if (!use_24_hour) + hour_minute_xr = MAX (hour_minute_xr, evo_calendar_print_renderer_get_width (context, font_minute, _("pm"))); row = 0; - hour_minute_xl = left + width * 0.58; - hour_minute_xr = right - width * 0.45; + hour_minute_xl = left + width - hour_minute_xr - 3; + hour_minute_xr = right - hour_minute_xr - 3; for (i = pdi->start_hour; i < pdi->end_hour; i++) { y = top + yinc * (row + 1); cr = gtk_print_context_get_cairo_context (context); @@ -2338,10 +2388,10 @@ print_work_week_background (GtkPrintContext *context, GnomeCalendar *gcal, /* To the right */ print_text (context, font_hour, buf, PANGO_ALIGN_RIGHT, - left, hour_minute_xr, + right - width, hour_minute_xr, y - yinc, y - yinc + hour_font_size); print_text (context, font_minute, minute, PANGO_ALIGN_LEFT, - hour_minute_xr, right - 1, + hour_minute_xr, right - 3, y - yinc, y - yinc + minute_font_size); @@ -2584,14 +2634,14 @@ print_work_week_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date GtkPageSetup *setup; icaltimezone *zone = calendar_config_get_icaltimezone (); time_t when, start, end; - gdouble width, height, l; + gdouble width, height, l, small_month_width = calc_small_month_width (context, HEADER_HEIGHT); gint i, days = 5; char buf[100]; const int LONG_EVENT_OFFSET = 6; struct pdinfo pdi; gdouble day_width, day_x; ECalModel *model = gnome_calendar_get_model (gcal); - gdouble weeknum_inc = get_show_week_numbers () ? SMALL_MONTH_WIDTH / 7.0 : 0; + gdouble weeknum_inc = get_show_week_numbers () ? small_month_width / 7.0 : 0; setup = gtk_print_context_get_page_setup (context); @@ -2616,16 +2666,16 @@ print_work_week_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date print_border (context, 0.0, width, 0.0, HEADER_HEIGHT, 1.0, 0.9); /* Print the 2 mini calendar-months. */ - l = width - SMALL_MONTH_PAD - (SMALL_MONTH_WIDTH + weeknum_inc) * 2 - SMALL_MONTH_SPACING; + l = width - SMALL_MONTH_PAD - (small_month_width + weeknum_inc) * 2 - SMALL_MONTH_SPACING; print_month_small (context, gcal, start, - l, 4, l + SMALL_MONTH_WIDTH + weeknum_inc, HEADER_HEIGHT + 4, + l, 4, l + small_month_width + weeknum_inc, HEADER_HEIGHT + 4, DATE_MONTH | DATE_YEAR, start, end, FALSE); - l += SMALL_MONTH_SPACING + SMALL_MONTH_WIDTH + weeknum_inc; + l += SMALL_MONTH_SPACING + small_month_width + weeknum_inc; print_month_small (context, gcal, time_add_month_with_zone (start, 1, zone), - l, 4, l + SMALL_MONTH_WIDTH + weeknum_inc, HEADER_HEIGHT + 4, + l, 4, l + small_month_width + weeknum_inc, HEADER_HEIGHT + 4, DATE_MONTH | DATE_YEAR, 0, 0, FALSE); /* Print the start day of the week, e.g. '7th May 2001'. */ @@ -2667,7 +2717,7 @@ print_week_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) { GtkPageSetup *setup; icaltimezone *zone = calendar_config_get_icaltimezone (); - gdouble l, week_numbers_inc; + gdouble l, week_numbers_inc, small_month_width; gchar buf[100]; time_t when; gint week_start_day; @@ -2678,7 +2728,8 @@ print_week_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) width = gtk_page_setup_get_page_width (setup, GTK_UNIT_POINTS); height = gtk_page_setup_get_page_height (setup, GTK_UNIT_POINTS); - week_numbers_inc = get_show_week_numbers () ? SMALL_MONTH_WIDTH / 7.0 : 0; + small_month_width = calc_small_month_width (context, HEADER_HEIGHT); + week_numbers_inc = get_show_week_numbers () ? small_month_width / 7.0 : 0; tm = *convert_timet_to_struct_tm (date, zone); week_start_day = calendar_config_get_week_start_day (); @@ -2708,17 +2759,17 @@ print_week_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) 0.0, HEADER_HEIGHT + 2.0 + 20, 1.0, 0.9); /* Print the 2 mini calendar-months. */ - l = width - SMALL_MONTH_PAD - (SMALL_MONTH_WIDTH + week_numbers_inc) * 2 + l = width - SMALL_MONTH_PAD - (small_month_width + week_numbers_inc) * 2 - SMALL_MONTH_SPACING; print_month_small (context, gcal, when, - l, 4, l + SMALL_MONTH_WIDTH + week_numbers_inc, HEADER_HEIGHT + 10, + l, 4, l + small_month_width + week_numbers_inc, HEADER_HEIGHT + 10, DATE_MONTH | DATE_YEAR, when, time_add_week_with_zone (when, 1, zone), FALSE); - l += SMALL_MONTH_SPACING + SMALL_MONTH_WIDTH + week_numbers_inc; + l += SMALL_MONTH_SPACING + small_month_width + week_numbers_inc; print_month_small (context, gcal, time_add_month_with_zone (when, 1, zone), - l, 4, l + SMALL_MONTH_WIDTH + week_numbers_inc, HEADER_HEIGHT + 10, + l, 4, l + small_month_width + week_numbers_inc, HEADER_HEIGHT + 10, DATE_MONTH | DATE_YEAR, when, time_add_week_with_zone (when, 1, zone), FALSE); @@ -2743,13 +2794,14 @@ print_month_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) icaltimezone *zone = calendar_config_get_icaltimezone (); gchar buf[100]; gdouble width, height; - gdouble l, week_numbers_inc; + gdouble l, week_numbers_inc, small_month_width; setup = gtk_print_context_get_page_setup (context); width = gtk_page_setup_get_page_width (setup, GTK_UNIT_POINTS); height = gtk_page_setup_get_page_height (setup, GTK_UNIT_POINTS); - week_numbers_inc = get_show_week_numbers () ? SMALL_MONTH_WIDTH / 7.0 : 0; + small_month_width = calc_small_month_width (context, HEADER_HEIGHT); + week_numbers_inc = get_show_week_numbers () ? small_month_width / 7.0 : 0; /* Print the main month view. */ print_month_summary (context, gcal, date, 0.0, width, HEADER_HEIGHT, height); @@ -2757,17 +2809,17 @@ print_month_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) /* Print the border around the header. */ print_border (context, 0.0, width, 0.0, HEADER_HEIGHT + 10, 1.0, 0.9); - l = width - SMALL_MONTH_PAD - SMALL_MONTH_WIDTH - week_numbers_inc; + l = width - SMALL_MONTH_PAD - small_month_width - week_numbers_inc; /* Print the 2 mini calendar-months. */ print_month_small (context, gcal, time_add_month_with_zone (date, 1, zone), - l, 4, l + SMALL_MONTH_WIDTH + week_numbers_inc, HEADER_HEIGHT + 4, + l, 4, l + small_month_width + week_numbers_inc, HEADER_HEIGHT + 4, DATE_MONTH | DATE_YEAR, 0, 0, FALSE); print_month_small (context, gcal, time_add_month_with_zone (date, -1, zone), - 8, 4, 8 + SMALL_MONTH_WIDTH + week_numbers_inc, HEADER_HEIGHT + 4, + 8, 4, 8 + small_month_width + week_numbers_inc, HEADER_HEIGHT + 4, DATE_MONTH | DATE_YEAR, 0, 0, FALSE); /* Print the month, e.g. 'May 2001'. */ -- cgit From 7d20b8fd5fd28a90852c737f35cef7ba03a2c116 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 1 Nov 2010 14:44:23 -0400 Subject: Utilize the new ESourceSelector:primary-selection property. --- calendar/gui/apps_evolution_calendar.schemas.in | 15 ++++++++++++--- calendar/importers/icalendar-importer.c | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'calendar') diff --git a/calendar/gui/apps_evolution_calendar.schemas.in b/calendar/gui/apps_evolution_calendar.schemas.in index 70590ee0ca..c37bbbd1fb 100644 --- a/calendar/gui/apps_evolution_calendar.schemas.in +++ b/calendar/gui/apps_evolution_calendar.schemas.in @@ -10,7 +10,10 @@ string Primary calendar - URI of the highlighted ("primary") calendar + + The UID of the selected (or "primary") calendar in the + sidebar of the "Calendar" view. + @@ -512,7 +515,10 @@ string Primary memo list - URI of the highlighted ("primary") memo list + + The UID of the selected (or "primary") memo list in the + sidebar of the "Memos" view. + @@ -525,7 +531,10 @@ string Primary task list - URI of the highlighted ("primary") task list + + The UID of the selected (or "primary") task list in the + sidebar of the "Tasks" view. + diff --git a/calendar/importers/icalendar-importer.c b/calendar/importers/icalendar-importer.c index 45de793778..8e20e19bcf 100644 --- a/calendar/importers/icalendar-importer.c +++ b/calendar/importers/icalendar-importer.c @@ -206,7 +206,7 @@ static void button_toggled_cb (GtkWidget *widget, struct _selector_data *sd) { g_datalist_set_data_full(&sd->target->data, "primary-source", - g_object_ref (e_source_selector_peek_primary_selection ((ESourceSelector *)sd->selector)), + g_object_ref (e_source_selector_get_primary_selection ((ESourceSelector *)sd->selector)), g_object_unref); g_datalist_set_data(&sd->target->data, "primary-type", GINT_TO_POINTER(import_type_map[sd->page])); gtk_notebook_set_current_page ((GtkNotebook *)sd->notebook, sd->page); @@ -216,7 +216,7 @@ static void primary_selection_changed_cb (ESourceSelector *selector, EImportTarget *target) { g_datalist_set_data_full(&target->data, "primary-source", - g_object_ref (e_source_selector_peek_primary_selection (selector)), + g_object_ref (e_source_selector_get_primary_selection (selector)), g_object_unref); } -- cgit From 870ab18eb9a040b7b6a188ec48466b41a2ca383b Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 2 Nov 2010 09:42:36 +0100 Subject: Bug #632941 - Calendar ignores preference "show/hide end times" --- calendar/gui/e-week-view.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'calendar') diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index c151ccbfa0..c964d1ebab 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -2080,7 +2080,7 @@ e_week_view_set_show_event_end_times (EWeekView *week_view, { g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - if (week_view->show_event_end_times != show_event_end_times) + if (week_view->show_event_end_times == show_event_end_times) return; week_view->show_event_end_times = show_event_end_times; @@ -2088,6 +2088,9 @@ e_week_view_set_show_event_end_times (EWeekView *week_view, week_view->events_need_reshape = TRUE; e_week_view_check_layout (week_view); + gtk_widget_queue_draw (week_view->titles_canvas); + gtk_widget_queue_draw (week_view->main_canvas); + g_object_notify (G_OBJECT (week_view), "show-event-end-times"); } -- cgit From c2b2e863cb97b6203b1be955a52096166462da8e Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 2 Nov 2010 11:16:48 +0100 Subject: Add forgotten cairo_destroy() calls --- calendar/gui/e-day-view-main-item.c | 8 ++++++-- calendar/gui/e-day-view-top-item.c | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'calendar') diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c index 366062f36f..08793c9c53 100644 --- a/calendar/gui/e-day-view-main-item.c +++ b/calendar/gui/e-day-view-main-item.c @@ -251,14 +251,18 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item, font_options = get_font_options (); - if (!is_array_index_in_bounds (day_view->events[day], event_num)) + if (!is_array_index_in_bounds (day_view->events[day], event_num)) { + cairo_destroy (cr); return; + } event = &g_array_index (day_view->events[day], EDayViewEvent, event_num); - if (!is_comp_data_valid (event)) + if (!is_comp_data_valid (event)) { + cairo_destroy (cr); return; + } /* Fill in the event background. Note that for events in the first column of the day, we might not want to paint over the vertical bar, diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c index fffb6141eb..1703467840 100644 --- a/calendar/gui/e-day-view-top-item.c +++ b/calendar/gui/e-day-view-top-item.c @@ -76,8 +76,6 @@ day_view_top_item_draw_triangle (EDayViewTopItem *top_item, gint c1, c2; cairo_t *cr; - cr = gdk_cairo_create (drawable); - day_view = e_day_view_top_item_get_day_view (top_item); points[0].x = x; @@ -102,6 +100,8 @@ day_view_top_item_draw_triangle (EDayViewTopItem *top_item, if (!is_comp_data_valid (event)) return; + cr = gdk_cairo_create (drawable); + cairo_save (cr); /* Fill it in. */ if (gdk_color_parse ( @@ -181,8 +181,6 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item, day_view = e_day_view_top_item_get_day_view (top_item); model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); - cr = gdk_cairo_create (drawable); - gradient = calendar_config_get_display_events_gradient (); alpha = calendar_config_get_display_events_alpha (); @@ -207,6 +205,8 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item, if (!is_comp_data_valid (event)) return; + cr = gdk_cairo_create (drawable); + style = gtk_widget_get_style (GTK_WIDGET (day_view)); comp = e_cal_component_new (); e_cal_component_set_icalcomponent ( -- cgit From bad8aff04f274c58c584bd5f7e8a396918aa9fb4 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 3 Nov 2010 16:35:02 +0100 Subject: Bug #612181 - Show recurring events in italic in date navigator --- calendar/gui/apps_evolution_calendar.schemas.in | 13 +++++++++++++ calendar/gui/dialogs/cal-prefs-dialog.c | 7 +++++++ calendar/gui/dialogs/cal-prefs-dialog.ui | 17 ++++++++++++++++- calendar/gui/dialogs/recurrence-page.c | 2 +- calendar/gui/gnome-cal.c | 2 +- calendar/gui/tag-calendar.c | 22 +++++++++++++++++++++- calendar/gui/tag-calendar.h | 3 ++- 7 files changed, 61 insertions(+), 5 deletions(-) (limited to 'calendar') diff --git a/calendar/gui/apps_evolution_calendar.schemas.in b/calendar/gui/apps_evolution_calendar.schemas.in index c37bbbd1fb..229020a4db 100644 --- a/calendar/gui/apps_evolution_calendar.schemas.in +++ b/calendar/gui/apps_evolution_calendar.schemas.in @@ -506,6 +506,19 @@ + + + /schemas/apps/evolution/calendar/display/recur_events_italic + /apps/evolution/calendar/display/recur_events_italic + evolution-calendar + bool + false + + Recurrent Events in Italic + Show days with recurrent events in italic font in bottom left calendar. + + + diff --git a/calendar/gui/dialogs/cal-prefs-dialog.c b/calendar/gui/dialogs/cal-prefs-dialog.c index 266d699143..6316211c8a 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.c +++ b/calendar/gui/dialogs/cal-prefs-dialog.c @@ -789,6 +789,13 @@ calendar_prefs_dialog_construct (CalendarPrefsDialog *prefs, G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); + widget = e_builder_get_widget (prefs->builder, "recur_events_italic"); + g_object_bind_property ( + shell_settings, "cal-recur-events-italic", + widget, "active", + G_BINDING_BIDIRECTIONAL | + G_BINDING_SYNC_CREATE); + prefs->month_scroll_by_week = e_builder_get_widget (prefs->builder, "month_scroll_by_week"); widget = e_builder_get_widget (prefs->builder, "tasks_due_today_color"); diff --git a/calendar/gui/dialogs/cal-prefs-dialog.ui b/calendar/gui/dialogs/cal-prefs-dialog.ui index 6b6218df70..7e581cf4ad 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.ui +++ b/calendar/gui/dialogs/cal-prefs-dialog.ui @@ -977,6 +977,21 @@ 3 + + + Show r_ecurring events in italic in bottom left calendar + True + True + False + True + True + + + False + False + 4 + + Sc_roll Month View by a week @@ -989,7 +1004,7 @@ False False - 4 + 5 diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c index 4014cfbc92..f5ef574efd 100644 --- a/calendar/gui/dialogs/recurrence-page.c +++ b/calendar/gui/dialogs/recurrence-page.c @@ -271,7 +271,7 @@ preview_recur (RecurrencePage *rpage) fill_component (rpage, comp); tag_calendar_by_comp (E_CALENDAR (priv->preview_calendar), comp, - client, zone, TRUE, FALSE); + client, zone, TRUE, FALSE, FALSE); g_object_unref (comp); } diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 9b9400dd09..3945003a68 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -775,7 +775,7 @@ dn_e_cal_view_objects_added_cb (ECalView *query, GList *objects, gpointer data) tag_calendar_by_comp ( priv->date_navigator, comp, e_cal_view_get_client (query), - NULL, FALSE, TRUE); + NULL, FALSE, TRUE, TRUE); g_object_unref (comp); } } diff --git a/calendar/gui/tag-calendar.c b/calendar/gui/tag-calendar.c index f700da5a3b..0af271e1de 100644 --- a/calendar/gui/tag-calendar.c +++ b/calendar/gui/tag-calendar.c @@ -29,6 +29,8 @@ #endif #include +#include "shell/e-shell.h" +#include "shell/e-shell-settings.h" #include "calendar-config.h" #include "tag-calendar.h" @@ -39,6 +41,7 @@ struct calendar_tag_closure { time_t end_time; gboolean skip_transparent_events; + gboolean recur_events_italic; }; /* Clears all the tags in a calendar and fills a closure structure with the @@ -107,6 +110,8 @@ tag_calendar_cb (ECalComponent *comp, if (c->skip_transparent_events) return TRUE; + style = E_CALENDAR_ITEM_MARK_ITALIC; + } else if (c->recur_events_italic && e_cal_component_is_instance (comp)) { style = E_CALENDAR_ITEM_MARK_ITALIC; } else { style = E_CALENDAR_ITEM_MARK_BOLD; @@ -124,6 +129,18 @@ tag_calendar_cb (ECalComponent *comp, return TRUE; } +static gboolean +get_recur_events_italic (void) +{ + EShell *shell; + EShellSettings *shell_settings; + + shell = e_shell_get_default (); + shell_settings = e_shell_get_shell_settings (shell); + + return e_shell_settings_get_boolean (shell_settings, "cal-recur-events-italic"); +} + /** * tag_calendar_by_client: * @ecal: Calendar widget to tag. @@ -152,6 +169,7 @@ tag_calendar_by_client (ECalendar *ecal, return; c.skip_transparent_events = TRUE; + c.recur_events_italic = get_recur_events_italic (); e_cal_generate_instances ( client, c.start_time, c.end_time, tag_calendar_cb, &c); @@ -202,7 +220,8 @@ tag_calendar_by_comp (ECalendar *ecal, ECal *client, icaltimezone *display_zone, gboolean clear_first, - gboolean comp_is_on_server) + gboolean comp_is_on_server, + gboolean can_recur_events_italic) { struct calendar_tag_closure c; @@ -217,6 +236,7 @@ tag_calendar_by_comp (ECalendar *ecal, return; c.skip_transparent_events = FALSE; + c.recur_events_italic = can_recur_events_italic && get_recur_events_italic (); if (comp_is_on_server) e_cal_generate_instances_for_object ( diff --git a/calendar/gui/tag-calendar.h b/calendar/gui/tag-calendar.h index e1d9fcf0b1..ebf996173e 100644 --- a/calendar/gui/tag-calendar.h +++ b/calendar/gui/tag-calendar.h @@ -33,6 +33,7 @@ void tag_calendar_by_client (ECalendar *ecal, ECal *client); void tag_calendar_by_comp (ECalendar *ecal, ECalComponent *comp, ECal *client, icaltimezone *display_zone, - gboolean clear_first, gboolean comp_is_on_server); + gboolean clear_first, gboolean comp_is_on_server, + gboolean can_recur_events_italic); #endif -- cgit From 62eb433998d8562d958ca2761ebdf21972294948 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 1 Nov 2010 16:01:46 -0400 Subject: Remove unused calendar-config API. --- calendar/gui/calendar-config-keys.h | 19 ------------------- calendar/gui/calendar-config.c | 17 ----------------- calendar/gui/calendar-config.h | 9 --------- 3 files changed, 45 deletions(-) (limited to 'calendar') diff --git a/calendar/gui/calendar-config-keys.h b/calendar/gui/calendar-config-keys.h index 568e211acf..1dc43a68db 100644 --- a/calendar/gui/calendar-config-keys.h +++ b/calendar/gui/calendar-config-keys.h @@ -31,7 +31,6 @@ G_BEGIN_DECLS #define CALENDAR_CONFIG_TIMEZONE CALENDAR_CONFIG_PREFIX "/display/timezone" #define CALENDAR_CONFIG_SELECTED_CALENDARS CALENDAR_CONFIG_PREFIX "/display/selected_calendars" #define CALENDAR_CONFIG_24HOUR CALENDAR_CONFIG_PREFIX "/display/use_24hour_format" -#define CALENDAR_CONFIG_SHOW_ATTENDEE CALENDAR_CONFIG_PREFIX "/display/show_attendee" #define CALENDAR_CONFIG_WEEK_START CALENDAR_CONFIG_PREFIX "/display/week_start_day" #define CALENDAR_CONFIG_DAY_START_HOUR CALENDAR_CONFIG_PREFIX "/display/day_start_hour" #define CALENDAR_CONFIG_DAY_START_MINUTE CALENDAR_CONFIG_PREFIX "/display/day_start_minute" @@ -39,41 +38,23 @@ G_BEGIN_DECLS #define CALENDAR_CONFIG_DAY_END_MINUTE CALENDAR_CONFIG_PREFIX "/display/day_end_minute" #define CALENDAR_CONFIG_TIME_DIVISIONS CALENDAR_CONFIG_PREFIX "/display/time_divisions" #define CALENDAR_CONFIG_MONTH_SCROLL_BY_WEEK CALENDAR_CONFIG_PREFIX "/display/month_scroll_by_week" -#define CALENDAR_CONFIG_MARCUS_BAINS_LINE CALENDAR_CONFIG_PREFIX "/display/marcus_bains_line" -#define CALENDAR_CONFIG_MARCUS_BAINS_COLOR_DAYVIEW CALENDAR_CONFIG_PREFIX "/display/marcus_bains_color_dayview" -#define CALENDAR_CONFIG_MARCUS_BAINS_COLOR_TIMEBAR CALENDAR_CONFIG_PREFIX "/display/marcus_bains_color_timebar" -#define CALENDAR_CONFIG_DEFAULT_VIEW CALENDAR_CONFIG_PREFIX "/display/default_view" -#define CALENDAR_CONFIG_HPANE_POS CALENDAR_CONFIG_PREFIX "/display/hpane_position" -#define CALENDAR_CONFIG_VPANE_POS CALENDAR_CONFIG_PREFIX "/display/vpane_position" -#define CALENDAR_CONFIG_MONTH_HPANE_POS CALENDAR_CONFIG_PREFIX "/display/month_hpane_position" -#define CALENDAR_CONFIG_MONTH_VPANE_POS CALENDAR_CONFIG_PREFIX "/display/month_vpane_position" -#define CALENDAR_CONFIG_TAG_VPANE_POS CALENDAR_CONFIG_PREFIX "/display/tag_vpane_position" -#define CALENDAR_CONFIG_TASK_PREVIEW CALENDAR_CONFIG_PREFIX "/display/show_task_preview" -#define CALENDAR_CONFIG_TASK_VPANE_POS CALENDAR_CONFIG_PREFIX "/display/task_vpane_position" #define CALENDAR_CONFIG_COMPRESS_WEEKEND CALENDAR_CONFIG_PREFIX "/display/compress_weekend" -#define CALENDAR_CONFIG_SHOW_EVENT_END CALENDAR_CONFIG_PREFIX "/display/show_event_end" #define CALENDAR_CONFIG_WORKING_DAYS CALENDAR_CONFIG_PREFIX "/display/working_days" -#define CALENDAR_CONFIG_SHOW_WEEK_NUMBERS CALENDAR_CONFIG_PREFIX "/display/show_week_numbers" #define CALENDAR_CONFIG_DAY_SECOND_ZONE CALENDAR_CONFIG_PREFIX "/display/day_second_zone" #define CALENDAR_CONFIG_DAY_SECOND_ZONES_LIST CALENDAR_CONFIG_PREFIX "/display/day_second_zones" #define CALENDAR_CONFIG_DAY_SECOND_ZONES_MAX CALENDAR_CONFIG_PREFIX "/display/day_second_zones_max" /* Task display settings */ #define CALENDAR_CONFIG_TASKS_SELECTED_TASKS CALENDAR_CONFIG_PREFIX "/tasks/selected_tasks" -#define CALENDAR_CONFIG_PRIMARY_TASKS CALENDAR_CONFIG_PREFIX "/tasks/primary_tasks" #define CALENDAR_CONFIG_TASKS_HIDE_COMPLETED CALENDAR_CONFIG_PREFIX "/tasks/hide_completed" #define CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_UNITS CALENDAR_CONFIG_PREFIX "/tasks/hide_completed_units" #define CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_VALUE CALENDAR_CONFIG_PREFIX "/tasks/hide_completed_value" -#define CALENDAR_CONFIG_TASKS_DUE_TODAY_COLOR CALENDAR_CONFIG_PREFIX "/tasks/colors/due_today" -#define CALENDAR_CONFIG_TASKS_OVERDUE_COLOR CALENDAR_CONFIG_PREFIX "/tasks/colors/overdue" /* Memo display settings */ #define CALENDAR_CONFIG_MEMOS_SELECTED_MEMOS CALENDAR_CONFIG_PREFIX "/memos/selected_memos" -#define CALENDAR_CONFIG_PRIMARY_MEMOS CALENDAR_CONFIG_PREFIX "/memos/primary_memos" /* Prompt settings */ #define CALENDAR_CONFIG_PROMPT_DELETE CALENDAR_CONFIG_PREFIX "/prompts/confirm_delete" -#define CALENDAR_CONFIG_PROMPT_PURGE CALENDAR_CONFIG_PREFIX "/prompts/confirm_purge" /* Default reminder */ #define CALENDAR_CONFIG_DEFAULT_REMINDER CALENDAR_CONFIG_PREFIX "/other/use_default_reminder" diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index a98e55d999..882459f13f 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -324,23 +324,6 @@ calendar_config_add_notification_month_scroll_by_week (GConfClientNotifyFunc fun return id; } -/* The positions of the panes in the normal and month views. */ -void -calendar_config_set_hpane_pos (gint hpane_pos) -{ - calendar_config_init (); - - gconf_client_set_int (config, CALENDAR_CONFIG_HPANE_POS, hpane_pos, NULL); -} - -void -calendar_config_set_month_hpane_pos (gint hpane_pos) -{ - calendar_config_init (); - - gconf_client_set_int (config, CALENDAR_CONFIG_MONTH_HPANE_POS, hpane_pos, NULL); -} - /* The current list of task lists selected */ GSList * calendar_config_get_tasks_selected (void) diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h index 6ca9457af9..af183d3d2e 100644 --- a/calendar/gui/calendar-config.h +++ b/calendar/gui/calendar-config.h @@ -97,11 +97,6 @@ void calendar_config_set_time_divisions (gint divisions); /* Whether we compress the weekend in the week/month views. */ gboolean calendar_config_get_compress_weekend (void); -/* The positions of the panes in the normal and month views. */ -void calendar_config_set_hpane_pos (gint hpane_pos); - -void calendar_config_set_month_hpane_pos (gint hpane_pos); - /* The current list of task lists selected */ GSList *calendar_config_get_tasks_selected (void); void calendar_config_set_tasks_selected (GSList *selected); @@ -135,10 +130,6 @@ void calendar_config_set_default_reminder_interval (gint interval); CalUnits calendar_config_get_default_reminder_units (void); void calendar_config_set_default_reminder_units (CalUnits units); -/* Free/Busy Settings */ -GSList * calendar_config_get_free_busy (void); -void calendar_config_set_free_busy (GSList * url_list); - /* 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); -- cgit From a2e309c2a1735bd68b315aa971388e20db3a8621 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 1 Nov 2010 16:32:21 -0400 Subject: Rename CalUnits to EDurationType. And move the definition to e-util-enums.h so we get a GType for it. --- calendar/gui/calendar-config.c | 56 ++++++++++++++++----------------- calendar/gui/calendar-config.h | 23 ++++++-------- calendar/gui/comp-util.c | 8 ++--- calendar/gui/dialogs/cal-prefs-dialog.c | 10 +++--- calendar/gui/dialogs/event-page.c | 32 +++++++++---------- calendar/gui/e-itip-control.c | 8 ++--- 6 files changed, 66 insertions(+), 71 deletions(-) (limited to 'calendar') diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index 882459f13f..a572ac004e 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -90,16 +90,16 @@ calendar_config_locale_supports_12_hour_format (void) /* Returns the string representation of a units value */ static const gchar * -units_to_string (CalUnits units) +units_to_string (EDurationType units) { switch (units) { - case CAL_DAYS: + case E_DURATION_DAYS: return "days"; - case CAL_HOURS: + case E_DURATION_HOURS: return "hours"; - case CAL_MINUTES: + case E_DURATION_MINUTES: return "minutes"; default: @@ -108,17 +108,17 @@ units_to_string (CalUnits units) } /* opposite function to 'units_to_string' */ -static CalUnits +static EDurationType string_to_units (const gchar *units) { - CalUnits res; + EDurationType res; if (units && !strcmp (units, "days")) - res = CAL_DAYS; + res = E_DURATION_DAYS; else if (units && !strcmp (units, "hours")) - res = CAL_HOURS; + res = E_DURATION_HOURS; else - res = CAL_MINUTES; + res = E_DURATION_MINUTES; return res; } @@ -397,22 +397,22 @@ calendar_config_set_hide_completed_tasks (gboolean hide) gconf_client_set_bool (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED, hide, NULL); } -CalUnits +EDurationType calendar_config_get_hide_completed_tasks_units (void) { gchar *units; - CalUnits cu; + EDurationType cu; calendar_config_init (); units = gconf_client_get_string (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_UNITS, NULL); if (units && !strcmp (units, "minutes")) - cu = CAL_MINUTES; + cu = E_DURATION_MINUTES; else if (units && !strcmp (units, "hours")) - cu = CAL_HOURS; + cu = E_DURATION_HOURS; else - cu = CAL_DAYS; + cu = E_DURATION_DAYS; g_free (units); @@ -420,17 +420,17 @@ calendar_config_get_hide_completed_tasks_units (void) } void -calendar_config_set_hide_completed_tasks_units (CalUnits cu) +calendar_config_set_hide_completed_tasks_units (EDurationType cu) { gchar *units; calendar_config_init (); switch (cu) { - case CAL_MINUTES : + case E_DURATION_MINUTES : units = g_strdup ("minutes"); break; - case CAL_HOURS : + case E_DURATION_HOURS : units = g_strdup ("hours"); break; default : @@ -542,15 +542,15 @@ calendar_config_set_default_reminder_interval (gint interval) * calendar_config_get_default_reminder_units: * * Queries the units of time in which default reminders should be created for - * new appointments, e.g. CAL_MINUTES for "5 minutes". + * new appointments, e.g. E_DURATION_MINUTES for "5 minutes". * * Return value: Time units for default reminders. **/ -CalUnits +EDurationType calendar_config_get_default_reminder_units (void) { gchar *units; - CalUnits cu; + EDurationType cu; calendar_config_init (); @@ -563,12 +563,12 @@ calendar_config_get_default_reminder_units (void) /** * calendar_config_set_default_reminder_units: - * @units: Time units, e.g. CAL_MINUTES for "5 minutes". + * @units: Time units, e.g. E_DURATION_MINUTES for "5 minutes". * * Sets the units to be used for default reminders in new appointments. **/ void -calendar_config_set_default_reminder_units (CalUnits units) +calendar_config_set_default_reminder_units (EDurationType units) { calendar_config_init (); @@ -586,7 +586,7 @@ calendar_config_set_default_reminder_units (CalUnits units) * are retrieved even when returns FALSE. **/ gboolean -calendar_config_get_ba_reminder (gint *interval, CalUnits *units) +calendar_config_get_ba_reminder (gint *interval, EDurationType *units) { calendar_config_init (); @@ -614,7 +614,7 @@ calendar_config_get_ba_reminder (gint *interval, CalUnits *units) * @units: The units of the reminder; can be NULL. **/ void -calendar_config_set_ba_reminder (gboolean *enabled, gint *interval, CalUnits *units) +calendar_config_set_ba_reminder (gboolean *enabled, gint *interval, EDurationType *units) { calendar_config_init (); @@ -642,7 +642,7 @@ calendar_config_get_hide_completed_tasks_sexp (gboolean get_completed) gchar *sexp = NULL; if (calendar_config_get_hide_completed_tasks ()) { - CalUnits units; + EDurationType units; gint value; units = calendar_config_get_hide_completed_tasks_units (); @@ -667,13 +667,13 @@ calendar_config_get_hide_completed_tasks_sexp (gboolean get_completed) tt = icaltime_current_time_with_zone (zone); switch (units) { - case CAL_DAYS: + case E_DURATION_DAYS: icaltime_adjust (&tt, -value, 0, 0, 0); break; - case CAL_HOURS: + case E_DURATION_HOURS: icaltime_adjust (&tt, 0, -value, 0, 0); break; - case CAL_MINUTES: + case E_DURATION_MINUTES: icaltime_adjust (&tt, 0, 0, -value, 0); break; default: diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h index af183d3d2e..8f41276b89 100644 --- a/calendar/gui/calendar-config.h +++ b/calendar/gui/calendar-config.h @@ -32,6 +32,7 @@ #include #include #include +#include /* These are used to get/set the working days in the week. The bit-flags are combined together. The bits must be from 0 (Sun) to 6 (Sat) to match the @@ -47,14 +48,6 @@ typedef enum CAL_SATURDAY = 1 << 6 } CalWeekdays; -/* Units for settings. */ -typedef enum -{ - CAL_DAYS, - CAL_HOURS, - CAL_MINUTES -} CalUnits; - void calendar_config_remove_notification (guint id); /* @@ -109,8 +102,9 @@ void calendar_config_set_memos_selected (GSList *selected); gboolean calendar_config_get_hide_completed_tasks (void); void calendar_config_set_hide_completed_tasks (gboolean hide); -CalUnits calendar_config_get_hide_completed_tasks_units (void); -void calendar_config_set_hide_completed_tasks_units (CalUnits units); +EDurationType + calendar_config_get_hide_completed_tasks_units (void); +void calendar_config_set_hide_completed_tasks_units (EDurationType units); gint calendar_config_get_hide_completed_tasks_value (void); void calendar_config_set_hide_completed_tasks_value (gint value); @@ -127,8 +121,9 @@ void calendar_config_set_use_default_reminder (gboolean value); gint calendar_config_get_default_reminder_interval (void); void calendar_config_set_default_reminder_interval (gint interval); -CalUnits calendar_config_get_default_reminder_units (void); -void calendar_config_set_default_reminder_units (CalUnits units); +EDurationType + calendar_config_get_default_reminder_units (void); +void calendar_config_set_default_reminder_units (EDurationType units); /* Returns TRUE if the locale has 'am' and 'pm' strings defined, i.e. it supports 12-hour time format. */ @@ -145,8 +140,8 @@ void calendar_config_select_day_second_zone (void); guint calendar_config_add_notification_day_second_zone (GConfClientNotifyFunc func, gpointer data); /* Birthdays & Anniversaries reminder settings */ -gboolean calendar_config_get_ba_reminder (gint *interval, CalUnits *units); -void calendar_config_set_ba_reminder (gboolean *enabled, gint *interval, CalUnits *units); +gboolean calendar_config_get_ba_reminder (gint *interval, EDurationType *units); +void calendar_config_set_ba_reminder (gboolean *enabled, gint *interval, EDurationType *units); /* Scroll in a month view by a week, not by a month */ gboolean calendar_config_get_month_scroll_by_week (void); diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index 2254d49cf6..d0182a0f8d 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -290,7 +290,7 @@ cal_comp_event_new_with_defaults (ECal *client, gboolean all_day) icalcomponent *icalcomp; ECalComponent *comp; gint interval; - CalUnits units; + EDurationType units; ECalComponentAlarm *alarm; icalproperty *icalprop; ECalComponentAlarmTrigger trigger; @@ -331,15 +331,15 @@ cal_comp_event_new_with_defaults (ECal *client, gboolean all_day) trigger.u.rel_duration.is_neg = TRUE; switch (units) { - case CAL_MINUTES: + case E_DURATION_MINUTES: trigger.u.rel_duration.minutes = interval; break; - case CAL_HOURS: + case E_DURATION_HOURS: trigger.u.rel_duration.hours = interval; break; - case CAL_DAYS: + case E_DURATION_DAYS: trigger.u.rel_duration.days = interval; break; diff --git a/calendar/gui/dialogs/cal-prefs-dialog.c b/calendar/gui/dialogs/cal-prefs-dialog.c index 6316211c8a..f404d08927 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.c +++ b/calendar/gui/dialogs/cal-prefs-dialog.c @@ -45,12 +45,12 @@ static const gint time_division_map[] = { /* The following two are kept separate in case we need to re-order each menu individually */ static const gint hide_completed_units_map[] = { - CAL_MINUTES, CAL_HOURS, CAL_DAYS, -1 + E_DURATION_MINUTES, E_DURATION_HOURS, E_DURATION_DAYS, -1 }; /* same is used for Birthdays & Anniversaries calendar */ static const gint default_reminder_units_map[] = { - CAL_MINUTES, CAL_HOURS, CAL_DAYS, -1 + E_DURATION_MINUTES, E_DURATION_HOURS, E_DURATION_DAYS, -1 }; static GtkVBoxClass *parent_class = NULL; @@ -331,7 +331,7 @@ ba_reminder_interval_changed (GtkWidget *widget, CalendarPrefsDialog *prefs) static void ba_reminder_units_changed (GtkWidget *widget, CalendarPrefsDialog *prefs) { - CalUnits units = e_dialog_combo_box_get (prefs->ba_reminder_units, default_reminder_units_map); + EDurationType units = e_dialog_combo_box_get (prefs->ba_reminder_units, default_reminder_units_map); calendar_config_set_ba_reminder (NULL, NULL, &units); } @@ -451,7 +451,7 @@ setup_changes (CalendarPrefsDialog *prefs) static void show_task_list_config (CalendarPrefsDialog *prefs) { - CalUnits units; + EDurationType units; gboolean hide_completed_tasks; /* Hide Completed Tasks. */ @@ -517,7 +517,7 @@ show_config (CalendarPrefsDialog *prefs) { gint time_divisions; gboolean set = FALSE; - CalUnits units; + EDurationType units; gint interval; /* Day's second zone */ diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index 94b25a0510..0418c7f5df 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -180,7 +180,7 @@ struct _EventPagePrivate { ESendOptionsDialog *sod; gchar *old_summary; - CalUnits alarm_units; + EDurationType alarm_units; gint alarm_interval; /* This is TRUE if both the start & end timezone are the same. If the @@ -517,7 +517,7 @@ clear_widgets (EventPage *epage) } static gboolean -is_custom_alarm (ECalComponentAlarm *ca, gchar *old_summary, CalUnits user_units, gint user_interval, gint *alarm_type) +is_custom_alarm (ECalComponentAlarm *ca, gchar *old_summary, EDurationType user_units, gint user_interval, gint *alarm_type) { ECalComponentAlarmTrigger trigger; ECalComponentAlarmRepeat repeat; @@ -600,7 +600,7 @@ is_custom_alarm (ECalComponentAlarm *ca, gchar *old_summary, CalUnits user_units if (user_interval != -1) { switch (user_units) { - case CAL_DAYS: + case E_DURATION_DAYS: if (trigger.u.rel_duration.days == user_interval && trigger.u.rel_duration.hours == 0 && trigger.u.rel_duration.minutes == 0) { @@ -610,7 +610,7 @@ is_custom_alarm (ECalComponentAlarm *ca, gchar *old_summary, CalUnits user_units } break; - case CAL_HOURS: + case E_DURATION_HOURS: if (trigger.u.rel_duration.days == 0 && trigger.u.rel_duration.hours == user_interval && trigger.u.rel_duration.minutes == 0) { @@ -620,7 +620,7 @@ is_custom_alarm (ECalComponentAlarm *ca, gchar *old_summary, CalUnits user_units } break; - case CAL_MINUTES: + case E_DURATION_MINUTES: if (trigger.u.rel_duration.days == 0 && trigger.u.rel_duration.hours == 0 && trigger.u.rel_duration.minutes == user_interval) { @@ -636,7 +636,7 @@ is_custom_alarm (ECalComponentAlarm *ca, gchar *old_summary, CalUnits user_units } static gboolean -is_custom_alarm_uid_list (ECalComponent *comp, GList *alarms, gchar *old_summary, CalUnits user_units, gint user_interval, gint *alarm_type) +is_custom_alarm_uid_list (ECalComponent *comp, GList *alarms, gchar *old_summary, EDurationType user_units, gint user_interval, gint *alarm_type) { ECalComponentAlarm *ca; gboolean result; @@ -652,7 +652,7 @@ is_custom_alarm_uid_list (ECalComponent *comp, GList *alarms, gchar *old_summary } static gboolean -is_custom_alarm_store (EAlarmList *alarm_list_store, gchar *old_summary, CalUnits user_units, gint user_interval, gint *alarm_type) +is_custom_alarm_store (EAlarmList *alarm_list_store, gchar *old_summary, EDurationType user_units, gint user_interval, gint *alarm_type) { const ECalComponentAlarm *alarm; GtkTreeModel *model; @@ -1492,15 +1492,15 @@ event_page_fill_component (CompEditorPage *page, ECalComponent *comp) case ALARM_USER_TIME: switch (calendar_config_get_default_reminder_units ()) { - case CAL_DAYS: + case E_DURATION_DAYS: trigger.u.rel_duration.days = priv->alarm_interval; break; - case CAL_HOURS: + case E_DURATION_HOURS: trigger.u.rel_duration.hours = priv->alarm_interval; break; - case CAL_MINUTES: + case E_DURATION_MINUTES: trigger.u.rel_duration.minutes = priv->alarm_interval; break; } @@ -2744,15 +2744,15 @@ alarm_changed_cb (GtkWidget *widget, case ALARM_USER_TIME: e_alarm_list_clear (priv->alarm_list_store); switch (calendar_config_get_default_reminder_units ()) { - case CAL_DAYS: + case E_DURATION_DAYS: trigger.u.rel_duration.days = priv->alarm_interval; break; - case CAL_HOURS: + case E_DURATION_HOURS: trigger.u.rel_duration.hours = priv->alarm_interval; break; - case CAL_MINUTES: + case E_DURATION_MINUTES: trigger.u.rel_duration.minutes = priv->alarm_interval; break; } @@ -2992,19 +2992,19 @@ init_widgets (EventPage *epage) combo_label = NULL; switch (priv->alarm_units) { - case CAL_DAYS: + case E_DURATION_DAYS: if (priv->alarm_interval != 1) { combo_label = g_strdup_printf (ngettext("%d day before appointment", "%d days before appointment", priv->alarm_interval), priv->alarm_interval); } break; - case CAL_HOURS: + case E_DURATION_HOURS: if (priv->alarm_interval != 1) { combo_label = g_strdup_printf (ngettext("%d hour before appointment", "%d hours before appointment", priv->alarm_interval), priv->alarm_interval); } break; - case CAL_MINUTES: + case E_DURATION_MINUTES: if (priv->alarm_interval != 15) { combo_label = g_strdup_printf (ngettext("%d minute before appointment", "%d minutes before appointment", priv->alarm_interval), priv->alarm_interval); } diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c index 2c1c452299..6c96b1a4e6 100644 --- a/calendar/gui/e-itip-control.c +++ b/calendar/gui/e-itip-control.c @@ -1620,7 +1620,7 @@ show_current (EItipControl *itip) if (calendar_config_get_use_default_reminder ()) { ECalComponentAlarm *acomp; gint interval; - CalUnits units; + EDurationType units; ECalComponentAlarmTrigger trigger; interval = calendar_config_get_default_reminder_interval (); @@ -1636,13 +1636,13 @@ show_current (EItipControl *itip) trigger.u.rel_duration.is_neg = TRUE; switch (units) { - case CAL_MINUTES: + case E_DURATION_MINUTES: trigger.u.rel_duration.minutes = interval; break; - case CAL_HOURS: + case E_DURATION_HOURS: trigger.u.rel_duration.hours = interval; break; - case CAL_DAYS: + case E_DURATION_DAYS: trigger.u.rel_duration.days = interval; break; default: -- cgit From 1f17dab6b0d9c5413dea38dcc95e7a7bb5b4bd9b Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 2 Nov 2010 11:49:38 -0400 Subject: Move calendar preferences to the calendar module. Continue replacing the use of calendar-config functions with GObject property bindings to EShellSettings properties. --- calendar/gui/Makefile.am | 45 - calendar/gui/apps_evolution_calendar.schemas.in | 828 ------- calendar/gui/calendar-config-keys.h | 3 - calendar/gui/calendar-config.c | 453 +--- calendar/gui/calendar-config.h | 69 - calendar/gui/comp-util.c | 39 +- calendar/gui/comp-util.h | 16 +- calendar/gui/dialogs/Makefile.am | 164 +- calendar/gui/dialogs/cal-prefs-dialog.c | 915 -------- calendar/gui/dialogs/cal-prefs-dialog.h | 113 - calendar/gui/dialogs/cal-prefs-dialog.ui | 1440 ------------- calendar/gui/dialogs/comp-editor-util.c | 6 +- calendar/gui/dialogs/comp-editor-util.h | 5 +- calendar/gui/dialogs/comp-editor.c | 308 ++- calendar/gui/dialogs/comp-editor.h | 28 + calendar/gui/dialogs/delete-comp.c | 12 +- calendar/gui/dialogs/e-send-options-utils.c | 6 +- calendar/gui/dialogs/e-send-options-utils.h | 11 +- calendar/gui/dialogs/event-editor.c | 2 +- calendar/gui/dialogs/event-page.c | 105 +- calendar/gui/dialogs/event-page.h | 4 +- calendar/gui/dialogs/recurrence-page.c | 54 +- calendar/gui/dialogs/recurrence-page.h | 7 +- calendar/gui/dialogs/schedule-page.c | 12 +- calendar/gui/dialogs/task-details-page.c | 23 +- calendar/gui/dialogs/task-page.c | 29 +- calendar/gui/e-cal-component-preview.c | 49 +- calendar/gui/e-cal-component-preview.h | 12 +- calendar/gui/e-cal-config.c | 7 +- calendar/gui/e-cal-config.h | 2 +- calendar/gui/e-cal-model.c | 436 +++- calendar/gui/e-cal-model.h | 47 +- calendar/gui/e-calendar-view.c | 90 +- calendar/gui/e-calendar-view.h | 5 + calendar/gui/e-date-time-list.c | 525 ++--- calendar/gui/e-date-time-list.h | 80 +- calendar/gui/e-day-view-main-item.c | 107 +- calendar/gui/e-day-view-time-item.c | 38 +- calendar/gui/e-day-view-top-item.c | 28 +- calendar/gui/e-day-view.c | 567 ++--- calendar/gui/e-day-view.h | 30 - calendar/gui/e-itip-control.c | 2604 ----------------------- calendar/gui/e-itip-control.h | 77 - calendar/gui/e-itip-control.ui | 464 ---- calendar/gui/e-meeting-store.c | 142 +- calendar/gui/e-meeting-store.h | 16 + calendar/gui/e-meeting-time-sel-item.c | 108 +- calendar/gui/e-memo-table.c | 13 +- calendar/gui/e-task-table.c | 10 +- calendar/gui/e-week-view-event-item.c | 37 +- calendar/gui/ea-day-view-main-item.c | 7 +- calendar/gui/goto.c | 4 +- calendar/gui/itip-utils.c | 82 +- calendar/gui/print.c | 381 ++-- calendar/gui/print.h | 22 +- 55 files changed, 2334 insertions(+), 8353 deletions(-) delete mode 100644 calendar/gui/apps_evolution_calendar.schemas.in delete mode 100644 calendar/gui/dialogs/cal-prefs-dialog.c delete mode 100644 calendar/gui/dialogs/cal-prefs-dialog.h delete mode 100644 calendar/gui/dialogs/cal-prefs-dialog.ui delete mode 100644 calendar/gui/e-itip-control.c delete mode 100644 calendar/gui/e-itip-control.h delete mode 100644 calendar/gui/e-itip-control.ui (limited to 'calendar') diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index a168582db0..a74d4a1a70 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -75,7 +75,6 @@ libevolution_calendar_la_CPPFLAGS = \ $(CAMEL_CFLAGS) ui_DATA = \ - e-itip-control.ui \ goto-dialog.ui etspec_DATA = \ @@ -132,8 +131,6 @@ libevolution_calendar_la_SOURCES = \ e-day-view-top-item.h \ e-day-view.c \ e-day-view.h \ - e-itip-control.c \ - e-itip-control.h \ e-meeting-attendee.c \ e-meeting-attendee.h \ e-meeting-list-view.c \ @@ -233,51 +230,9 @@ libevolution_calendar_la_LIBADD = \ libevolution_calendar_la_LDFLAGS = $(NO_UNDEFINED) -@INTLTOOL_SERVER_RULE@ - -# GConf schemas - -schemadir = $(GCONF_SCHEMA_FILE_DIR) -schema_in_files = apps_evolution_calendar.schemas.in -schema_DATA = $(schema_in_files:.schemas.in=.schemas) - -@INTLTOOL_SCHEMAS_RULE@ - EXTRA_DIST = \ $(ui_DATA) \ - $(schema_in_files) \ $(etspec_DATA) \ $(search_files) -CLEANFILES = $(BUILT_SOURCES) - -DISTCLEANFILES = $(schema_DATA) - -if GCONF_SCHEMAS_INSTALL - -if OS_WIN32 -install-data-local: - if test -z "$(DESTDIR)" ; then \ - for p in $(schema_DATA) ; do \ - (echo set GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE); \ - echo $(GCONFTOOL) --makefile-install-rule $$p) >_temp.bat; \ - cmd /c _temp.bat; \ - rm _temp.bat; \ - done \ - fi -else -install-data-local: - if test -z "$(DESTDIR)" ; then \ - for p in $(schema_DATA) ; do \ - GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \ - $(GCONFTOOL) --makefile-install-rule $$p; \ - done \ - fi -endif - -endif - -dist-hook: - cd $(distdir); rm -f $(BUILT_SOURCES) - -include $(top_srcdir)/git.mk diff --git a/calendar/gui/apps_evolution_calendar.schemas.in b/calendar/gui/apps_evolution_calendar.schemas.in deleted file mode 100644 index 229020a4db..0000000000 --- a/calendar/gui/apps_evolution_calendar.schemas.in +++ /dev/null @@ -1,828 +0,0 @@ - - - - - - - /schemas/apps/evolution/calendar/display/primary_calendar - /apps/evolution/calendar/display/primary_calendar - evolution-calendar - string - - Primary calendar - - The UID of the selected (or "primary") calendar in the - sidebar of the "Calendar" view. - - - - - - /schemas/apps/evolution/calendar/display/timezone - /apps/evolution/calendar/display/timezone - evolution-calendar - string - UTC - - Timezone - The default timezone to use for dates and times in the calendar, as an untranslated Olsen timezone database location like "America/New York". - - - - - /schemas/apps/evolution/calendar/display/use_system_timezone - /apps/evolution/calendar/display/use_system_timezone - evolution-calendar - bool - true - - Use system timezone - Use the system timezone instead of the timezone selected - in Evolution. - - - - - /schemas/apps/evolution/calendar/display/day_second_zone - /apps/evolution/calendar/display/day_second_zone - evolution-calendar - string - - - The second timezone for a Day View - Shows the second time zone in a Day View, if set. Value is similar to one used in a 'timezone' key. - - - - - /schemas/apps/evolution/calendar/display/day_second_zones - /apps/evolution/calendar/display/day_second_zones - evolution-calendar - list - string - [] - - Recently used second time zones in a Day View - List of recently used second time zones in a Day View. - - - - - /schemas/apps/evolution/calendar/display/day_second_zones_max - /apps/evolution/calendar/display/day_second_zones_max - evolution-calendar - int - 5 - - Maximum number of recently used timezones to remember. - Maximum number of recently used timezones to remember in a 'day_second_zones' list. - - - - - /schemas/apps/evolution/calendar/display/use_24hour_format - /apps/evolution/calendar/display/use_24hour_format - evolution-calendar - bool - false - - Twenty four hour time format - Whether to show times in twenty four hour format instead of using am/pm. - - - - - /schemas/apps/evolution/calendar/display/show_role - /apps/evolution/calendar/display/show_role - evolution-calendar - bool - true - - Show Role field in the event/task/meeting editor - Whether to show role field in the event/task/meeting editor - - - - - /schemas/apps/evolution/calendar/display/show_status - /apps/evolution/calendar/display/show_status - evolution-calendar - bool - false - - Show status field in the event/task/meeting editor - Whether to show status field in the event/task/meeting editor - - - - - /schemas/apps/evolution/calendar/display/show_type - /apps/evolution/calendar/display/show_type - evolution-calendar - bool - false - - Show type field in the event/task/meeting editor - Whether to show type field in the event/task/meeting editor - - - - - /schemas/apps/evolution/calendar/display/show_rsvp - /apps/evolution/calendar/display/show_rsvp - evolution-calendar - bool - false - - Show RSVP field in the event/task/meeting editor - Whether to show RSVP field in the event/task/meeting editor - - - - - /schemas/apps/evolution/calendar/display/show_timezone - /apps/evolution/calendar/display/show_timezone - evolution-calendar - bool - false - - Show timezone field in the event/meeting editor - Whether to show timezone field in the event/meeting editor - - - - - /schemas/apps/evolution/calendar/display/show_categories - /apps/evolution/calendar/display/show_categories - evolution-calendar - bool - false - - Show categories field in the event/meeting/task editor - Whether to show categories field in the event/meeting editor - - - - - /schemas/apps/evolution/calendar/display/week_start_day - /apps/evolution/calendar/display/week_start_day - evolution-calendar - int - 1 - - Week start - Weekday the week starts on, from Sunday (0) to Saturday (6). - - - - - /schemas/apps/evolution/calendar/display/day_start_hour - /apps/evolution/calendar/display/day_start_hour - evolution-calendar - int - 9 - - Workday start hour - Hour the workday starts on, in twenty four hour format, 0 to 23. - - - - - /schemas/apps/evolution/calendar/display/day_start_minute - /apps/evolution/calendar/display/day_start_minute - evolution-calendar - int - 0 - - Workday start minute - Minute the workday starts on, 0 to 59. - - - - - /schemas/apps/evolution/calendar/display/day_end_hour - /apps/evolution/calendar/display/day_end_hour - evolution-calendar - int - 17 - - Workday end hour - Hour the workday ends on, in twenty four hour format, 0 to 23. - - - - - /schemas/apps/evolution/calendar/display/day_end_minute - /apps/evolution/calendar/display/day_end_minute - evolution-calendar - int - 0 - - Workday end minute - Minute the workday ends on, 0 to 59. - - - - - /schemas/apps/evolution/calendar/display/time_divisions - /apps/evolution/calendar/display/time_divisions - evolution-calendar - int - 30 - - Time divisions - Intervals shown in Day and Work Week views, in minutes. - - - - - /schemas/apps/evolution/calendar/display/hpane_position - /apps/evolution/calendar/display/hpane_position - evolution-calendar - int - 400 - - Horizontal pane position - Position of the horizontal pane, between the date navigator calendar and the task list when not in the month view, in pixels. - - - - - /schemas/apps/evolution/calendar/display/vpane_position - /apps/evolution/calendar/display/vpane_position - evolution-calendar - int - 150 - - Vertical pane position - Position of the vertical pane, between the view and the date navigator calendar and task list when not in the month view, in pixels. - - - - - /schemas/apps/evolution/calendar/display/month_hpane_position - /apps/evolution/calendar/display/month_hpane_position - evolution-calendar - int - 32000 - - Month view horizontal pane position - Position of the horizontal pane, between the view and the date navigator calendar and task list in the month view, in pixels. - - - - - /schemas/apps/evolution/calendar/display/month_vpane_position - /apps/evolution/calendar/display/month_vpane_position - evolution-calendar - int - 150 - - Month view vertical pane position - Position of the vertical pane, between the view and the date navigator calendar and task list in the month view, in pixels. - - - - /schemas/apps/evolution/calendar/display/date_navigator_pane_position - /apps/evolution/calendar/display/date_navigator_pane_position - evolution-calendar - int - 150 - - Month view vertical pane position - Position of the vertical pane, between the calendar lists and the date navigator calendar. - - - - - /schemas/apps/evolution/calendar/display/memo_layout - /apps/evolution/calendar/display/memo_layout - int - 0 - - Memo layout style - - The layout style determines where to place the preview pane - in relation to the memo list. "0" (Classic View) places the - preview pane below the memo list. "1" (Vertical View) places - the preview pane next to the memo list. - - - - - - /schemas/apps/evolution/calendar/display/show_memo_preview - /apps/evolution/calendar/display/show_memo_preview - evolution-calendar - bool - true - - Show the memo preview pane - - If "true", show the memo preview pane in the main window. - - - - - - /schemas/apps/evolution/calendar/display/memo_hpane_position - /apps/evolution/calendar/display/memo_hpane_position - evolution-calendar - int - 200 - - Memo preview pane position (horizontal) - - Position of the task preview pane when oriented horizontally. - - - - - - /schemas/apps/evolution/calendar/display/memo_vpane_position - /apps/evolution/calendar/display/memo_vpane_position - evolution-calendar - int - 400 - - Memo preview pane position (vertical) - - Position of the memo preview pane when oriented vertically. - - - - - - /schemas/apps/evolution/calendar/display/task_layout - /apps/evolution/calendar/display/task_layout - int - 0 - - Task layout style - - The layout style determines where to place the preview pane - in relation to the task list. "0" (Classic View) places the - preview pane below the task list. "1" (Vertical View) places - the preview pane next to the task list. - - - - - - /schemas/apps/evolution/calendar/display/show_task_preview - /apps/evolution/calendar/display/show_task_preview - evolution-calendar - bool - true - - Show the task preview pane - - If "true", show the task preview pane in the main window. - - - - - - /schemas/apps/evolution/calendar/display/task_hpane_position - /apps/evolution/calendar/display/task_hpane_position - evolution-calendar - int - 200 - - Task preview pane position (horizontal) - - Position of the task preview pane when oriented horizontally. - - - - - - /schemas/apps/evolution/calendar/display/task_vpane_position - /apps/evolution/calendar/display/task_vpane_position - evolution-calendar - int - 400 - - Task preview pane position (vertical) - - Position of the task preview pane when oriented vertically. - - - - - - /schemas/apps/evolution/calendar/display/compress_weekend - /apps/evolution/calendar/display/compress_weekend - evolution-calendar - bool - true - - Compress weekends in month view - Whether to compress weekends in the month view, which puts Saturday and Sunday in the space of one weekday. - - - - - /schemas/apps/evolution/calendar/display/show_event_end - /apps/evolution/calendar/display/show_event_end - evolution-calendar - bool - true - - Show appointment end times in week and month views - Whether to display the end time of events in the week and month views. - - - - - /schemas/apps/evolution/calendar/display/working_days - /apps/evolution/calendar/display/working_days - evolution-calendar - int - 62 - - Work days - Days on which the start and end of work hours should be indicated. - - - - - /schemas/apps/evolution/calendar/display/marcus_bains_line - /apps/evolution/calendar/display/marcus_bains_line - evolution-calendar - bool - true - - Marcus Bains Line - Whether to draw the Marcus Bains Line (line at current time) in the calendar. - - - - - /schemas/apps/evolution/calendar/display/marcus_bains_color_dayview - /apps/evolution/calendar/display/marcus_bains_color_dayview - evolution-calendar - string - #ff0000 - - Marcus Bains Line Color - Day View - Color to draw the Marcus Bains line in the Day View. - - - - - /schemas/apps/evolution/calendar/display/marcus_bains_color_timebar - /apps/evolution/calendar/display/marcus_bains_color_timebar - evolution-calendar - string - #ff0000 - - Marcus Bains Line Color - Time bar - Color to draw the Marcus Bains Line in the Time bar (empty for default). - - - - - /schemas/apps/evolution/calendar/display/events_transparency - /apps/evolution/calendar/display/events_transparency - evolution-calendar - float - 1.0 - - Event Transparency - Transparency of the events in calendar views, a value between 0 (transparent) and 1 (opaque). - - - - - /schemas/apps/evolution/calendar/display/events_gradient - /apps/evolution/calendar/display/events_gradient - evolution-calendar - bool - true - - Event Gradient - Gradient of the events in calendar views. - - - - - - /schemas/apps/evolution/calendar/display/recur_events_italic - /apps/evolution/calendar/display/recur_events_italic - evolution-calendar - bool - false - - Recurrent Events in Italic - Show days with recurrent events in italic font in bottom left calendar. - - - - - - - /schemas/apps/evolution/calendar/memos/primary_memos - /apps/evolution/calendar/memos/primary_memos - evolution-calendar - string - - Primary memo list - - The UID of the selected (or "primary") memo list in the - sidebar of the "Memos" view. - - - - - - - - /schemas/apps/evolution/calendar/tasks/primary_tasks - /apps/evolution/calendar/tasks/primary_tasks - evolution-calendar - string - - Primary task list - - The UID of the selected (or "primary") task list in the - sidebar of the "Tasks" view. - - - - - - /schemas/apps/evolution/calendar/tasks/hide_completed - /apps/evolution/calendar/tasks/hide_completed - evolution-calendar - bool - false - - Hide completed tasks - Whether to hide completed tasks in the tasks view. - - - - - /schemas/apps/evolution/calendar/tasks/hide_completed_units - /apps/evolution/calendar/tasks/hide_completed_units - evolution-calendar - string - days - - Hide task units - Units for determining when to hide tasks, "minutes", "hours" or "days". - - - - - /schemas/apps/evolution/calendar/tasks/hide_completed_value - /apps/evolution/calendar/tasks/hide_completed_value - evolution-calendar - int - 1 - - Hide task value - Number of units for determining when to hide tasks. - - - - - - - /schemas/apps/evolution/calendar/tasks/colors/due_today - /apps/evolution/calendar/tasks/colors/due_today - evolution-calendar - string - #1e90ff - - Tasks due today color - Background color of tasks that are due today, in "#rrggbb" format. - - - - - /schemas/apps/evolution/calendar/tasks/colors/overdue - /apps/evolution/calendar/tasks/colors/overdue - evolution-calendar - string - #ff0000 - - Overdue tasks color - Background color of tasks that are overdue, in "#rrggbb" format. - - - - - - - /schemas/apps/evolution/calendar/prompts/confirm_delete - /apps/evolution/calendar/prompts/confirm_delete - evolution-calendar - bool - true - - Ask for confirmation when deleting items - Whether to ask for confirmation when deleting an appointment or task. - - - - - /schemas/apps/evolution/calendar/prompts/confirm_purge - /apps/evolution/calendar/prompts/confirm_purge - evolution-calendar - bool - true - - Confirm expunge - Whether to ask for confirmation when expunging appointments and tasks. - - - - - /schemas/apps/evolution/calendar/other/use_default_reminder - /apps/evolution/calendar/other/use_default_reminder - evolution-calendar - bool - false - - Default appointment reminder - Whether to set a default reminder for appointments. - - - - - /schemas/apps/evolution/calendar/other/default_reminder_interval - /apps/evolution/calendar/other/default_reminder_interval - evolution-calendar - int - 15 - - Default reminder value - Number of units for determining a default reminder. - - - - - /schemas/apps/evolution/calendar/other/default_reminder_units - /apps/evolution/calendar/other/default_reminder_units - evolution-calendar - string - - - Default reminder units - Units for a default reminder, "minutes", "hours" or "days". - - - - - /schemas/apps/evolution/calendar/other/def_recur_count - /apps/evolution/calendar/other/def_recur_count - evolution-calendar - int - 2 - - Default recurrence count - Count of default recurrence for a new event. -1 means forever. - - - - - /schemas/apps/evolution/calendar/display/show_week_numbers - /apps/evolution/calendar/display/show_week_numbers - evolution-calendar - bool - false - - Show week numbers in Day View, Work Week View, and Date Navigator - Whether to show week numbers in various places in the Calendar. - - - - - /schemas/apps/evolution/calendar/display/month_scroll_by_week - /apps/evolution/calendar/display/month_scroll_by_week - evolution-calendar - bool - true - - Scroll Month View by a week - Whether to scroll a Month View by a week, not by a month. - - - - - - - /schemas/apps/evolution/calendar/notify/last_notification_time - /apps/evolution/calendar/notify/last_notification_time - evolution-calendar - int - -1 - - Last alarm time - Time the last alarm ran, in time_t. - - - - - /schemas/apps/evolution/calendar/notify/calendars - /apps/evolution/calendar/notify/calendars - evolution-calendar - list - string - [] - - Calendars to run alarms for - - - - - /schemas/apps/evolution/calendar/notify/programs - /apps/evolution/calendar/notify/programs - evolution-calendar - list - string - [] - - Alarm programs - Programs that are allowed to be run by alarms. - - - - - /schemas/apps/evolution/calendar/notify/notify_with_tray - /apps/evolution/calendar/notify/notify_with_tray - evolution-calendar - bool - false - - Show display alarms in notification tray - Whether or not to use the notification tray for display alarms. - - - - - /schemas/apps/evolution/calendar/publish/uris - /apps/evolution/calendar/publish/uris - evolution-calendar - list - string - [] - - Free/busy server URLs - List of server URLs for free/busy publishing. - - - - - /schemas/apps/evolution/calendar/publish/template - /apps/evolution/calendar/publish/template - evolution-calendar - string - - Free/busy template URL - The URL template to use as a free/busy data fallback, %u is replaced by the user part of the mail address and %d is replaced by the domain. - - - - - /schemas/apps/evolution/calendar/audio_dir - /apps/evolution/calendar/audio_dir - evolution-calendar - string - - Save directory for alarm audio - - Directory for saving alarm audio files - - - - - - /schemas/apps/evolution/calendar/display/error_timeout - /apps/evolution/calendar/display/error_timeout - evolution-calendar - int - 60 - - Amount of time in seconds the error should be shown on the status bar. - Amount of time in seconds the error should be shown on the status bar. - - - - - /schemas/apps/evolution/calendar/display/error_level - /apps/evolution/calendar/display/error_level - evolution-calendar - int - 0 - - Level beyond which the message should be logged. - This can have three possible values. 0 for errors. 1 for warnings. - 2 for debug messages. - - - - - diff --git a/calendar/gui/calendar-config-keys.h b/calendar/gui/calendar-config-keys.h index 1dc43a68db..09c53478fb 100644 --- a/calendar/gui/calendar-config-keys.h +++ b/calendar/gui/calendar-config-keys.h @@ -31,7 +31,6 @@ G_BEGIN_DECLS #define CALENDAR_CONFIG_TIMEZONE CALENDAR_CONFIG_PREFIX "/display/timezone" #define CALENDAR_CONFIG_SELECTED_CALENDARS CALENDAR_CONFIG_PREFIX "/display/selected_calendars" #define CALENDAR_CONFIG_24HOUR CALENDAR_CONFIG_PREFIX "/display/use_24hour_format" -#define CALENDAR_CONFIG_WEEK_START CALENDAR_CONFIG_PREFIX "/display/week_start_day" #define CALENDAR_CONFIG_DAY_START_HOUR CALENDAR_CONFIG_PREFIX "/display/day_start_hour" #define CALENDAR_CONFIG_DAY_START_MINUTE CALENDAR_CONFIG_PREFIX "/display/day_start_minute" #define CALENDAR_CONFIG_DAY_END_HOUR CALENDAR_CONFIG_PREFIX "/display/day_end_hour" @@ -71,8 +70,6 @@ G_BEGIN_DECLS #define CALENDAR_CONFIG_BA_REMINDER_INTERVAL CALENDAR_CONFIG_PREFIX "/other/ba_reminder_interval" #define CALENDAR_CONFIG_BA_REMINDER_UNITS CALENDAR_CONFIG_PREFIX "/other/ba_reminder_units" -#define CALENDAR_CONFIG_DEF_RECUR_COUNT CALENDAR_CONFIG_PREFIX "/other/def_recur_count" - /* drawing of events */ #define CALENDAR_CONFIG_DISPLAY_EVENTS_GRADIENT CALENDAR_CONFIG_PREFIX "/display/events_gradient" #define CALENDAR_CONFIG_DISPLAY_EVENTS_ALPHA CALENDAR_CONFIG_PREFIX "/display/events_transparency" diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index a572ac004e..b5f57cebc3 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -41,8 +41,6 @@ #include "calendar-config.h" static GConfClient *config = NULL; -static gboolean display_events_gradient = TRUE; -static gfloat display_events_alpha = 1.0; static void do_cleanup (void) @@ -61,9 +59,6 @@ calendar_config_init (void) g_atexit ((GVoidFunc) do_cleanup); gconf_client_add_dir (config, CALENDAR_CONFIG_PREFIX, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL); - - display_events_gradient = gconf_client_get_bool (config, CALENDAR_CONFIG_DISPLAY_EVENTS_GRADIENT, NULL); - display_events_alpha = gconf_client_get_float (config, CALENDAR_CONFIG_DISPLAY_EVENTS_ALPHA, NULL); } void @@ -88,62 +83,10 @@ calendar_config_locale_supports_12_hour_format (void) return s[0] != '\0'; } -/* Returns the string representation of a units value */ -static const gchar * -units_to_string (EDurationType units) -{ - switch (units) { - case E_DURATION_DAYS: - return "days"; - - case E_DURATION_HOURS: - return "hours"; - - case E_DURATION_MINUTES: - return "minutes"; - - default: - g_return_val_if_reached (NULL); - } -} - -/* opposite function to 'units_to_string' */ -static EDurationType -string_to_units (const gchar *units) -{ - EDurationType res; - - if (units && !strcmp (units, "days")) - res = E_DURATION_DAYS; - else if (units && !strcmp (units, "hours")) - res = E_DURATION_HOURS; - else - res = E_DURATION_MINUTES; - - return res; -} - /* * Calendar Settings. */ -/* The current list of calendars selected */ -GSList * -calendar_config_get_calendars_selected (void) -{ - calendar_config_init (); - - return gconf_client_get_list (config, CALENDAR_CONFIG_SELECTED_CALENDARS, GCONF_VALUE_STRING, NULL); -} - -void -calendar_config_set_calendars_selected (GSList *selected) -{ - calendar_config_init (); - - gconf_client_set_list (config, CALENDAR_CONFIG_SELECTED_CALENDARS, GCONF_VALUE_STRING, selected, NULL); -} - static gchar * calendar_config_get_timezone_stored (void) { @@ -204,97 +147,6 @@ calendar_config_get_24_hour_format (void) return TRUE; } -/* The start day of the week (0 = Sun to 6 = Mon). */ -gint -calendar_config_get_week_start_day (void) -{ - calendar_config_init (); - - return gconf_client_get_int (config, CALENDAR_CONFIG_WEEK_START, NULL); -} - -/* The start and end times of the work-day. */ -gint -calendar_config_get_day_start_hour (void) -{ - calendar_config_init (); - - return gconf_client_get_int (config, CALENDAR_CONFIG_DAY_START_HOUR, NULL); -} - -void -calendar_config_set_day_start_hour (gint day_start_hour) -{ - calendar_config_init (); - - gconf_client_set_int (config, CALENDAR_CONFIG_DAY_START_HOUR, day_start_hour, NULL); -} - -gint -calendar_config_get_day_start_minute (void) -{ - calendar_config_init (); - - return gconf_client_get_int (config, CALENDAR_CONFIG_DAY_START_MINUTE, NULL); -} - -void -calendar_config_set_day_start_minute (gint day_start_min) -{ - calendar_config_init (); - - gconf_client_set_int (config, CALENDAR_CONFIG_DAY_START_MINUTE, day_start_min, NULL); -} - -gint -calendar_config_get_day_end_hour (void) -{ - calendar_config_init (); - - return gconf_client_get_int (config, CALENDAR_CONFIG_DAY_END_HOUR, NULL); -} - -void -calendar_config_set_day_end_hour (gint day_end_hour) -{ - calendar_config_init (); - - gconf_client_set_int (config, CALENDAR_CONFIG_DAY_END_HOUR, day_end_hour, NULL); -} - -gint -calendar_config_get_day_end_minute (void) -{ - calendar_config_init (); - - return gconf_client_get_int (config, CALENDAR_CONFIG_DAY_END_MINUTE, NULL); -} - -void -calendar_config_set_day_end_minute (gint day_end_min) -{ - calendar_config_init (); - - gconf_client_set_int (config, CALENDAR_CONFIG_DAY_END_MINUTE, day_end_min, NULL); -} - -/* The time divisions in the Day/Work-Week view in minutes (5/10/15/30/60). */ -gint -calendar_config_get_time_divisions (void) -{ - calendar_config_init (); - - return gconf_client_get_int (config, CALENDAR_CONFIG_TIME_DIVISIONS, NULL); -} - -void -calendar_config_set_time_divisions (gint divisions) -{ - calendar_config_init (); - - gconf_client_set_int (config, CALENDAR_CONFIG_TIME_DIVISIONS, divisions, NULL); -} - /* Scroll in a month view by a week, not by a month */ gboolean calendar_config_get_month_scroll_by_week (void) @@ -304,14 +156,6 @@ calendar_config_get_month_scroll_by_week (void) return gconf_client_get_bool (config, CALENDAR_CONFIG_MONTH_SCROLL_BY_WEEK, NULL); } -void -calendar_config_set_month_scroll_by_week (gboolean value) -{ - calendar_config_init (); - - gconf_client_set_bool (config, CALENDAR_CONFIG_MONTH_SCROLL_BY_WEEK, value, NULL); -} - guint calendar_config_add_notification_month_scroll_by_week (GConfClientNotifyFunc func, gpointer data) { @@ -324,53 +168,8 @@ calendar_config_add_notification_month_scroll_by_week (GConfClientNotifyFunc fun return id; } -/* The current list of task lists selected */ -GSList * -calendar_config_get_tasks_selected (void) -{ - calendar_config_init (); - - return gconf_client_get_list (config, CALENDAR_CONFIG_TASKS_SELECTED_TASKS, GCONF_VALUE_STRING, NULL); -} - -void -calendar_config_set_tasks_selected (GSList *selected) -{ - calendar_config_init (); - - gconf_client_set_list (config, CALENDAR_CONFIG_TASKS_SELECTED_TASKS, GCONF_VALUE_STRING, selected, NULL); -} - -/***************************************/ - -/* The current list of memo lists selected */ -GSList * -calendar_config_get_memos_selected (void) -{ - calendar_config_init (); - - return gconf_client_get_list (config, CALENDAR_CONFIG_MEMOS_SELECTED_MEMOS, GCONF_VALUE_STRING, NULL); -} - -void -calendar_config_set_memos_selected (GSList *selected) -{ - calendar_config_init (); - - gconf_client_set_list (config, CALENDAR_CONFIG_MEMOS_SELECTED_MEMOS, GCONF_VALUE_STRING, selected, NULL); -} - /***************************************/ -/* Whether we compress the weekend in the week/month views. */ -gboolean -calendar_config_get_compress_weekend (void) -{ - calendar_config_init (); - - return gconf_client_get_bool (config, CALENDAR_CONFIG_COMPRESS_WEEKEND, NULL); -} - /* The working days of the week, a bit-wise combination of flags. */ CalWeekdays calendar_config_get_working_days (void) @@ -389,15 +188,7 @@ calendar_config_get_hide_completed_tasks (void) return gconf_client_get_bool (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED, NULL); } -void -calendar_config_set_hide_completed_tasks (gboolean hide) -{ - calendar_config_init (); - - gconf_client_set_bool (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED, hide, NULL); -} - -EDurationType +static EDurationType calendar_config_get_hide_completed_tasks_units (void) { gchar *units; @@ -419,215 +210,6 @@ calendar_config_get_hide_completed_tasks_units (void) return cu; } -void -calendar_config_set_hide_completed_tasks_units (EDurationType cu) -{ - gchar *units; - - calendar_config_init (); - - switch (cu) { - case E_DURATION_MINUTES : - units = g_strdup ("minutes"); - break; - case E_DURATION_HOURS : - units = g_strdup ("hours"); - break; - default : - units = g_strdup ("days"); - } - - gconf_client_set_string (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_UNITS, units, NULL); - - g_free (units); -} - -gint -calendar_config_get_hide_completed_tasks_value (void) -{ - calendar_config_init (); - - return gconf_client_get_int (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_VALUE, NULL); -} - -void -calendar_config_set_hide_completed_tasks_value (gint value) -{ - calendar_config_init (); - - gconf_client_set_int (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_VALUE, value, NULL); -} - -/** - * calendar_config_get_confirm_delete: - * - * Queries the configuration value for whether a confirmation dialog is - * presented when deleting calendar/tasks items. - * - * Return value: Whether confirmation is required when deleting items. - **/ -gboolean -calendar_config_get_confirm_delete (void) -{ - calendar_config_init (); - - return gconf_client_get_bool (config, CALENDAR_CONFIG_PROMPT_DELETE, NULL); -} - -/** - * calendar_config_get_use_default_reminder: - * - * Queries whether new appointments should be created with a default reminder. - * - * Return value: Boolean value indicating whether new appointments should be - * created with a default reminder from the values of - * calendar_config_get_default_reminder_interval() and - * calendar_config_get_default_reminder_units(). - **/ -gboolean -calendar_config_get_use_default_reminder (void) -{ - calendar_config_init (); - - return gconf_client_get_bool (config, CALENDAR_CONFIG_DEFAULT_REMINDER, NULL); -} - -/** - * calendar_config_set_use_default_reminder: - * @value: Whether to create new appointments with a default reminder. - * - * Sets whether newly-created appointments should get a default reminder set - * them. - **/ -void -calendar_config_set_use_default_reminder (gboolean value) -{ - calendar_config_init (); - - gconf_client_set_bool (config, CALENDAR_CONFIG_DEFAULT_REMINDER, value, NULL); -} - -/** - * calendar_config_get_default_reminder_interval: - * - * Queries the interval for the default reminder of newly-created - * appointments, i.e. 5 in "5 minutes". - * - * Return value: Interval for default reminders. - **/ -gint -calendar_config_get_default_reminder_interval (void) -{ - calendar_config_init (); - - return gconf_client_get_int (config, CALENDAR_CONFIG_DEFAULT_REMINDER_INTERVAL, NULL); -} - -/** - * calendar_config_set_default_reminder_interval: - * @interval: Interval value, e.g. 5 for "5 minutes". - * - * Sets the interval that should be used for the default reminder in new - * appointments. - **/ -void -calendar_config_set_default_reminder_interval (gint interval) -{ - calendar_config_init (); - - gconf_client_set_int (config, CALENDAR_CONFIG_DEFAULT_REMINDER_INTERVAL, interval, NULL); -} - -/** - * calendar_config_get_default_reminder_units: - * - * Queries the units of time in which default reminders should be created for - * new appointments, e.g. E_DURATION_MINUTES for "5 minutes". - * - * Return value: Time units for default reminders. - **/ -EDurationType -calendar_config_get_default_reminder_units (void) -{ - gchar *units; - EDurationType cu; - - calendar_config_init (); - - units = gconf_client_get_string (config, CALENDAR_CONFIG_DEFAULT_REMINDER_UNITS, NULL); - cu = string_to_units (units); - g_free (units); - - return cu; -} - -/** - * calendar_config_set_default_reminder_units: - * @units: Time units, e.g. E_DURATION_MINUTES for "5 minutes". - * - * Sets the units to be used for default reminders in new appointments. - **/ -void -calendar_config_set_default_reminder_units (EDurationType units) -{ - calendar_config_init (); - - gconf_client_set_string (config, CALENDAR_CONFIG_DEFAULT_REMINDER_UNITS, units_to_string (units), NULL); -} - -/** - * calendar_config_get_ba_reminder: - * Retrieves setup of the Birthdays & Anniversaries reminder. - * - * @interval: Retrieves the interval setup for the reminder; can be NULL. - * @units: Retrieves units for the interval; can be NULL. - * - * Returns whether the reminder is on or off. The values for interval and/or units - * are retrieved even when returns FALSE. - **/ -gboolean -calendar_config_get_ba_reminder (gint *interval, EDurationType *units) -{ - calendar_config_init (); - - if (interval) { - *interval = gconf_client_get_int (config, CALENDAR_CONFIG_BA_REMINDER_INTERVAL, NULL); - } - - if (units) { - gchar *str; - - str = gconf_client_get_string (config, CALENDAR_CONFIG_BA_REMINDER_UNITS, NULL); - *units = string_to_units (str); - g_free (str); - } - - return gconf_client_get_bool (config, CALENDAR_CONFIG_BA_REMINDER, NULL); -} - -/** - * calendar_config_set_ba_reminder: - * Stores new values for Birthdays & Anniversaries reminder to GConf. Only those, which are not NULL. - * - * @enabled: The enabled state; can be NULL. - * @interval: The reminder interval; can be NULL. - * @units: The units of the reminder; can be NULL. - **/ -void -calendar_config_set_ba_reminder (gboolean *enabled, gint *interval, EDurationType *units) -{ - calendar_config_init (); - - if (enabled) - gconf_client_set_bool (config, CALENDAR_CONFIG_BA_REMINDER, *enabled, NULL); - - if (interval) - gconf_client_set_int (config, CALENDAR_CONFIG_BA_REMINDER_INTERVAL, *interval, NULL); - - if (units) - gconf_client_set_string (config, CALENDAR_CONFIG_BA_REMINDER_UNITS, units_to_string (*units), NULL); -} - /** * calendar_config_get_hide_completed_tasks_sexp: * @@ -646,7 +228,7 @@ calendar_config_get_hide_completed_tasks_sexp (gboolean get_completed) gint value; units = calendar_config_get_hide_completed_tasks_units (); - value = calendar_config_get_hide_completed_tasks_value (); + value = gconf_client_get_int (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_VALUE, NULL); if (value == 0) { /* If the value is 0, we want to hide completed tasks @@ -852,34 +434,3 @@ calendar_config_add_notification_day_second_zone (GConfClientNotifyFunc func, gp return id; } - -/* default count for recurring events */ -gint -calendar_config_get_default_count (void) -{ - gint res; - - calendar_config_init (); - - res = gconf_client_get_int (config, CALENDAR_CONFIG_DEF_RECUR_COUNT, NULL); - if (res <= 0 && res != -1) - res = 2; - - return res; -} - -gboolean -calendar_config_get_display_events_gradient (void) -{ - calendar_config_init (); - - return display_events_gradient; -} - -gfloat -calendar_config_get_display_events_alpha (void) -{ - calendar_config_init (); - - return display_events_alpha; -} diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h index 8f41276b89..d8cbb32cf3 100644 --- a/calendar/gui/calendar-config.h +++ b/calendar/gui/calendar-config.h @@ -54,77 +54,20 @@ void calendar_config_remove_notification (guint id); * Calendar Settings. */ -/* The current list of calendars selected */ -GSList *calendar_config_get_calendars_selected (void); -void calendar_config_set_calendars_selected (GSList *selected); - /* The current timezone, e.g. "Europe/London". */ icaltimezone *calendar_config_get_icaltimezone (void); /* The working days of the week, a bit-wise combination of flags. */ CalWeekdays calendar_config_get_working_days (void); -/* The start day of the week (0 = Sun to 6 = Sat). */ -gint calendar_config_get_week_start_day (void); - -/* The start and end times of the work-day. */ -gint calendar_config_get_day_start_hour (void); -void calendar_config_set_day_start_hour (gint day_start_hour); - -gint calendar_config_get_day_start_minute (void); -void calendar_config_set_day_start_minute (gint day_start_min); - -gint calendar_config_get_day_end_hour (void); -void calendar_config_set_day_end_hour (gint day_end_hour); - -gint calendar_config_get_day_end_minute (void); -void calendar_config_set_day_end_minute (gint day_end_min); - /* Whether we use 24-hour format or 12-hour format (AM/PM). */ gboolean calendar_config_get_24_hour_format (void); -/* The time divisions in the Day/Work-Week view in minutes (5/10/15/30/60). */ -gint calendar_config_get_time_divisions (void); -void calendar_config_set_time_divisions (gint divisions); - -/* Whether we compress the weekend in the week/month views. */ -gboolean calendar_config_get_compress_weekend (void); - -/* The current list of task lists selected */ -GSList *calendar_config_get_tasks_selected (void); -void calendar_config_set_tasks_selected (GSList *selected); - -/* The current list of memo lists selected */ -GSList *calendar_config_get_memos_selected (void); -void calendar_config_set_memos_selected (GSList *selected); - /* Settings to hide completed tasks. */ gboolean calendar_config_get_hide_completed_tasks (void); -void calendar_config_set_hide_completed_tasks (gboolean hide); - -EDurationType - calendar_config_get_hide_completed_tasks_units (void); -void calendar_config_set_hide_completed_tasks_units (EDurationType units); - -gint calendar_config_get_hide_completed_tasks_value (void); -void calendar_config_set_hide_completed_tasks_value (gint value); gchar * calendar_config_get_hide_completed_tasks_sexp (gboolean get_completed); -/* Confirmation options */ -gboolean calendar_config_get_confirm_delete (void); - -/* Default reminder options */ -gboolean calendar_config_get_use_default_reminder (void); -void calendar_config_set_use_default_reminder (gboolean value); - -gint calendar_config_get_default_reminder_interval (void); -void calendar_config_set_default_reminder_interval (gint interval); - -EDurationType - calendar_config_get_default_reminder_units (void); -void calendar_config_set_default_reminder_units (EDurationType units); - /* 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); @@ -139,20 +82,8 @@ gchar * calendar_config_get_day_second_zone (void); void calendar_config_select_day_second_zone (void); guint calendar_config_add_notification_day_second_zone (GConfClientNotifyFunc func, gpointer data); -/* Birthdays & Anniversaries reminder settings */ -gboolean calendar_config_get_ba_reminder (gint *interval, EDurationType *units); -void calendar_config_set_ba_reminder (gboolean *enabled, gint *interval, EDurationType *units); - /* Scroll in a month view by a week, not by a month */ gboolean calendar_config_get_month_scroll_by_week (void); -void calendar_config_set_month_scroll_by_week (gboolean value); guint calendar_config_add_notification_month_scroll_by_week (GConfClientNotifyFunc func, gpointer data); -/* default count for recurring events */ -gint calendar_config_get_default_count (void); - -/* event drawing customization, one-time read on start only */ -gboolean calendar_config_get_display_events_gradient (void); -gfloat calendar_config_get_display_events_alpha (void); - #endif /* _CALENDAR_CONFIG_H_ */ diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index d0182a0f8d..7dae1826de 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -285,12 +285,14 @@ is_icalcomp_on_the_server (icalcomponent *icalcomp, ECal *client) * Return value: A newly-created calendar component. **/ ECalComponent * -cal_comp_event_new_with_defaults (ECal *client, gboolean all_day) +cal_comp_event_new_with_defaults (ECal *client, + gboolean all_day, + gboolean use_default_reminder, + gint default_reminder_interval, + EDurationType default_reminder_units) { icalcomponent *icalcomp; ECalComponent *comp; - gint interval; - EDurationType units; ECalComponentAlarm *alarm; icalproperty *icalprop; ECalComponentAlarmTrigger trigger; @@ -305,12 +307,9 @@ cal_comp_event_new_with_defaults (ECal *client, gboolean all_day) e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT); } - if (all_day || !calendar_config_get_use_default_reminder ()) + if (all_day || !use_default_reminder) return comp; - interval = calendar_config_get_default_reminder_interval (); - units = calendar_config_get_default_reminder_units (); - alarm = e_cal_component_alarm_new (); /* We don't set the description of the alarm; we'll copy it from the @@ -330,21 +329,21 @@ cal_comp_event_new_with_defaults (ECal *client, gboolean all_day) trigger.u.rel_duration.is_neg = TRUE; - switch (units) { + switch (default_reminder_units) { case E_DURATION_MINUTES: - trigger.u.rel_duration.minutes = interval; + trigger.u.rel_duration.minutes = default_reminder_interval; break; case E_DURATION_HOURS: - trigger.u.rel_duration.hours = interval; + trigger.u.rel_duration.hours = default_reminder_interval; break; case E_DURATION_DAYS: - trigger.u.rel_duration.days = interval; + trigger.u.rel_duration.days = default_reminder_interval; break; default: - g_warning ("wrong units %d\n", units); + g_warning ("wrong units %d\n", default_reminder_units); } e_cal_component_alarm_set_trigger (alarm, trigger); @@ -356,18 +355,22 @@ cal_comp_event_new_with_defaults (ECal *client, gboolean all_day) } ECalComponent * -cal_comp_event_new_with_current_time (ECal *client, gboolean all_day) +cal_comp_event_new_with_current_time (ECal *client, + gboolean all_day, + icaltimezone *zone, + gboolean use_default_reminder, + gint default_reminder_interval, + EDurationType default_reminder_units) { ECalComponent *comp; struct icaltimetype itt; ECalComponentDateTime dt; - icaltimezone *zone; - - comp = cal_comp_event_new_with_defaults (client, all_day); - g_return_val_if_fail (comp, NULL); + comp = cal_comp_event_new_with_defaults ( + client, all_day, use_default_reminder, + default_reminder_interval, default_reminder_units); + g_return_val_if_fail (comp != NULL, NULL); - zone = calendar_config_get_icaltimezone (); if (all_day) { itt = icaltime_from_timet_with_zone (time (NULL), 1, zone); diff --git a/calendar/gui/comp-util.h b/calendar/gui/comp-util.h index 7b1bf28626..0467f31d67 100644 --- a/calendar/gui/comp-util.h +++ b/calendar/gui/comp-util.h @@ -28,6 +28,7 @@ #include #include #include +#include struct _EShell; @@ -47,8 +48,19 @@ gboolean cal_comp_is_on_server (ECalComponent *comp, ECal *client); gboolean is_icalcomp_on_the_server (icalcomponent *icalcomp, ECal *client); -ECalComponent *cal_comp_event_new_with_defaults (ECal *client, gboolean all_day); -ECalComponent *cal_comp_event_new_with_current_time (ECal *client, gboolean all_day); +ECalComponent * cal_comp_event_new_with_defaults + (ECal *client, + gboolean all_day, + gboolean use_default_reminder, + gint default_reminder_interval, + EDurationType default_reminder_units); +ECalComponent * cal_comp_event_new_with_current_time + (ECal *client, + gboolean all_day, + icaltimezone *zone, + gboolean use_default_reminder, + gint default_reminder_interval, + EDurationType default_reminder_units); ECalComponent *cal_comp_task_new_with_defaults (ECal *client); ECalComponent *cal_comp_memo_new_with_defaults (ECal *client); diff --git a/calendar/gui/dialogs/Makefile.am b/calendar/gui/dialogs/Makefile.am index 0bd89de799..38e0c47e62 100644 --- a/calendar/gui/dialogs/Makefile.am +++ b/calendar/gui/dialogs/Makefile.am @@ -20,101 +20,97 @@ libcal_dialogs_la_CPPFLAGS = \ ecalendarincludedir = $(privincludedir)/calendar/gui/dialogs -ecalendarinclude_HEADERS = \ - comp-editor-page.h \ - comp-editor.h \ - alarm-dialog.h \ - alarm-list-dialog.h \ - cal-prefs-dialog.h \ - calendar-setup.h \ - cancel-comp.h \ - changed-comp.h \ - comp-editor-util.h \ - copy-source-dialog.h \ - delete-comp.h \ - delete-error.h \ - e-delegate-dialog.h \ - e-send-options-utils.h \ - event-editor.h \ - event-page.h \ - memo-editor.h \ - memo-page.h \ - recurrence-page.h \ - recur-comp.h \ - save-comp.h \ - schedule-page.h \ - select-source-dialog.h \ - send-comp.h \ - task-editor.h \ - task-details-page.h \ - task-page.h +ecalendarinclude_HEADERS = \ + comp-editor-page.h \ + comp-editor.h \ + alarm-dialog.h \ + alarm-list-dialog.h \ + calendar-setup.h \ + cancel-comp.h \ + changed-comp.h \ + comp-editor-util.h \ + copy-source-dialog.h \ + delete-comp.h \ + delete-error.h \ + e-delegate-dialog.h \ + e-send-options-utils.h \ + event-editor.h \ + event-page.h \ + memo-editor.h \ + memo-page.h \ + recurrence-page.h \ + recur-comp.h \ + save-comp.h \ + schedule-page.h \ + select-source-dialog.h \ + send-comp.h \ + task-editor.h \ + task-details-page.h \ + task-page.h libcal_dialogs_la_LIBADD = \ $(top_builddir)/addressbook/util/libeabutil.la \ $(CAMEL_LIBS) \ $(GNOME_PLATFORM_LIBS) -libcal_dialogs_la_SOURCES = \ - $(IDL_GENERATED) \ - alarm-dialog.c \ - alarm-dialog.h \ - alarm-list-dialog.c \ - alarm-list-dialog.h \ - cal-prefs-dialog.c \ - cal-prefs-dialog.h \ - calendar-setup.c \ - calendar-setup.h \ - cancel-comp.c \ - cancel-comp.h \ - changed-comp.c \ - changed-comp.h \ - comp-editor.c \ - comp-editor.h \ - comp-editor-page.c \ - comp-editor-page.h \ - comp-editor-util.c \ - comp-editor-util.h \ - copy-source-dialog.c \ - copy-source-dialog.h \ - delete-comp.c \ - delete-comp.h \ - delete-error.c \ - delete-error.h \ - e-delegate-dialog.c \ - e-delegate-dialog.h \ - e-send-options-utils.c \ - e-send-options-utils.h \ - event-editor.c \ - event-editor.h \ - event-page.c \ - event-page.h \ - memo-editor.c \ - memo-editor.h \ - memo-page.c \ - memo-page.h \ - recurrence-page.c \ - recurrence-page.h \ - recur-comp.c \ - recur-comp.h \ - save-comp.c \ - save-comp.h \ - schedule-page.c \ - schedule-page.h \ - select-source-dialog.c \ - select-source-dialog.h \ - send-comp.c \ - send-comp.h \ - task-editor.c \ - task-editor.h \ - task-details-page.c \ - task-details-page.h \ - task-page.c \ +libcal_dialogs_la_SOURCES = \ + $(IDL_GENERATED) \ + alarm-dialog.c \ + alarm-dialog.h \ + alarm-list-dialog.c \ + alarm-list-dialog.h \ + calendar-setup.c \ + calendar-setup.h \ + cancel-comp.c \ + cancel-comp.h \ + changed-comp.c \ + changed-comp.h \ + comp-editor.c \ + comp-editor.h \ + comp-editor-page.c \ + comp-editor-page.h \ + comp-editor-util.c \ + comp-editor-util.h \ + copy-source-dialog.c \ + copy-source-dialog.h \ + delete-comp.c \ + delete-comp.h \ + delete-error.c \ + delete-error.h \ + e-delegate-dialog.c \ + e-delegate-dialog.h \ + e-send-options-utils.c \ + e-send-options-utils.h \ + event-editor.c \ + event-editor.h \ + event-page.c \ + event-page.h \ + memo-editor.c \ + memo-editor.h \ + memo-page.c \ + memo-page.h \ + recurrence-page.c \ + recurrence-page.h \ + recur-comp.c \ + recur-comp.h \ + save-comp.c \ + save-comp.h \ + schedule-page.c \ + schedule-page.h \ + select-source-dialog.c \ + select-source-dialog.h \ + send-comp.c \ + send-comp.h \ + task-editor.c \ + task-editor.h \ + task-details-page.c \ + task-details-page.h \ + task-page.c \ task-page.h ui_DATA = \ alarm-dialog.ui \ alarm-list-dialog.ui \ - cal-prefs-dialog.ui \ e-delegate-dialog.ui \ event-page.ui \ memo-page.ui \ diff --git a/calendar/gui/dialogs/cal-prefs-dialog.c b/calendar/gui/dialogs/cal-prefs-dialog.c deleted file mode 100644 index f404d08927..0000000000 --- a/calendar/gui/dialogs/cal-prefs-dialog.c +++ /dev/null @@ -1,915 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Damon Chaplin - * Ettore Perazzoli - * David Trowbridge - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "../e-cal-config.h" -#include "../e-timezone-entry.h" -#include "../calendar-config.h" -#include "cal-prefs-dialog.h" -#include -#include "e-util/e-util.h" -#include "e-util/e-datetime-format.h" -#include "e-util/e-dialog-widgets.h" -#include "e-util/e-util-private.h" -#include "shell/e-shell-utils.h" -#include -#include - -static const gint time_division_map[] = { - 60, 30, 15, 10, 5, -1 -}; - -/* The following two are kept separate in case we need to re-order each menu individually */ -static const gint hide_completed_units_map[] = { - E_DURATION_MINUTES, E_DURATION_HOURS, E_DURATION_DAYS, -1 -}; - -/* same is used for Birthdays & Anniversaries calendar */ -static const gint default_reminder_units_map[] = { - E_DURATION_MINUTES, E_DURATION_HOURS, E_DURATION_DAYS, -1 -}; - -static GtkVBoxClass *parent_class = NULL; - -static void -calendar_prefs_dialog_finalize (GObject *obj) -{ - CalendarPrefsDialog *prefs = (CalendarPrefsDialog *) obj; - - g_object_unref (prefs->builder); - - if (prefs->gconf) { - g_object_unref (prefs->gconf); - prefs->gconf = NULL; - } - - ((GObjectClass *)(parent_class))->finalize (obj); -} - -static void -calendar_prefs_dialog_class_init (CalendarPrefsDialogClass *klass) -{ - GObjectClass *object_class; - - object_class = (GObjectClass *) klass; - parent_class = g_type_class_ref (GTK_TYPE_VBOX); - - object_class->finalize = calendar_prefs_dialog_finalize; -} - -static void -calendar_prefs_dialog_init (CalendarPrefsDialog *dialog) -{ -} - -static GtkWidget * -eccp_widget_glade (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget *old, gpointer data) -{ - CalendarPrefsDialog *prefs = data; - - return e_builder_get_widget (prefs->builder, item->label); -} - -static void -update_day_second_zone_caption (CalendarPrefsDialog *prefs) -{ - gchar *location; - const gchar *caption; - icaltimezone *zone; - - g_return_if_fail (prefs != NULL); - - /* Translators: "None" indicates no second time zone set for a day view */ - caption = C_("cal-second-zone", "None"); - - location = calendar_config_get_day_second_zone (); - if (location && *location) { - zone = icaltimezone_get_builtin_timezone (location); - if (zone && icaltimezone_get_display_name (zone)) { - caption = icaltimezone_get_display_name (zone); - } - } - g_free (location); - - gtk_button_set_label (GTK_BUTTON (prefs->day_second_zone), caption); -} - -static void -on_set_day_second_zone (GtkWidget *item, CalendarPrefsDialog *prefs) -{ - if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (item))) - return; - - calendar_config_set_day_second_zone (g_object_get_data (G_OBJECT (item), "timezone")); - update_day_second_zone_caption (prefs); -} - -static void -on_select_day_second_zone (GtkWidget *item, CalendarPrefsDialog *prefs) -{ - g_return_if_fail (prefs != NULL); - - calendar_config_select_day_second_zone (); - update_day_second_zone_caption (prefs); -} - -static void -day_second_zone_clicked (GtkWidget *widget, CalendarPrefsDialog *prefs) -{ - GtkWidget *menu, *item; - GSList *group = NULL, *recent_zones, *s; - gchar *location; - icaltimezone *zone, *second_zone = NULL; - - menu = gtk_menu_new (); - - location = calendar_config_get_day_second_zone (); - if (location && *location) - second_zone = icaltimezone_get_builtin_timezone (location); - g_free (location); - - group = NULL; - item = gtk_radio_menu_item_new_with_label (group, C_("cal-second-zone", "None")); - group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (item)); - if (!second_zone) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - g_signal_connect (item, "toggled", G_CALLBACK (on_set_day_second_zone), prefs); - - recent_zones = calendar_config_get_day_second_zones (); - for (s = recent_zones; s != NULL; s = s->next) { - zone = icaltimezone_get_builtin_timezone (s->data); - if (!zone) - continue; - - item = gtk_radio_menu_item_new_with_label (group, icaltimezone_get_display_name (zone)); - group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (item)); - /* both comes from builtin, thus no problem to compare pointers */ - if (zone == second_zone) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - g_object_set_data_full (G_OBJECT (item), "timezone", g_strdup (s->data), g_free); - g_signal_connect (item, "toggled", G_CALLBACK (on_set_day_second_zone), prefs); - } - calendar_config_free_day_second_zones (recent_zones); - - item = gtk_separator_menu_item_new (); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - - item = gtk_menu_item_new_with_label (_("Select...")); - g_signal_connect (item, "activate", G_CALLBACK (on_select_day_second_zone), prefs); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); - - gtk_widget_show_all (menu); - - gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, - 0, gtk_get_current_event_time ()); -} - -static void -start_of_day_changed (GtkWidget *widget, CalendarPrefsDialog *prefs) -{ - gint start_hour, start_minute, end_hour, end_minute; - EDateEdit *start, *end; - - start = E_DATE_EDIT (prefs->start_of_day); - end = E_DATE_EDIT (prefs->end_of_day); - - e_date_edit_get_time_of_day (start, &start_hour, &start_minute); - e_date_edit_get_time_of_day (end, &end_hour, &end_minute); - - if ((start_hour > end_hour) || (start_hour == end_hour && start_minute > end_minute)) { - if (start_hour < 23) - e_date_edit_set_time_of_day (end, start_hour + 1, start_minute); - else - e_date_edit_set_time_of_day (end, 23, 59); - - return; - } - - calendar_config_set_day_start_hour (start_hour); - calendar_config_set_day_start_minute (start_minute); -} - -static void -end_of_day_changed (GtkWidget *widget, CalendarPrefsDialog *prefs) -{ - gint start_hour, start_minute, end_hour, end_minute; - EDateEdit *start, *end; - - start = E_DATE_EDIT (prefs->start_of_day); - end = E_DATE_EDIT (prefs->end_of_day); - - e_date_edit_get_time_of_day (start, &start_hour, &start_minute); - e_date_edit_get_time_of_day (end, &end_hour, &end_minute); - - if ((end_hour < start_hour) || (end_hour == start_hour && end_minute < start_minute)) { - if (end_hour < 1) - e_date_edit_set_time_of_day (start, 0, 0); - else - e_date_edit_set_time_of_day (start, end_hour - 1, end_minute); - - return; - } - - calendar_config_set_day_end_hour (end_hour); - calendar_config_set_day_end_minute (end_minute); -} - -static void -time_divisions_changed (GtkWidget *widget, CalendarPrefsDialog *prefs) -{ - gint time_divisions; - - time_divisions = e_dialog_combo_box_get (prefs->time_divisions, time_division_map); - calendar_config_set_time_divisions (time_divisions); -} - -static void -month_scroll_by_week_toggled (GtkToggleButton *toggle, CalendarPrefsDialog *prefs) -{ - calendar_config_set_month_scroll_by_week (gtk_toggle_button_get_active (toggle)); -} - -static void -hide_completed_tasks_toggled (GtkToggleButton *toggle, CalendarPrefsDialog *prefs) -{ - gboolean hide; - - hide = gtk_toggle_button_get_active (toggle); - - gtk_widget_set_sensitive (prefs->tasks_hide_completed_interval, hide); - gtk_widget_set_sensitive (prefs->tasks_hide_completed_units, hide); - - calendar_config_set_hide_completed_tasks (hide); -} - -static void -hide_completed_tasks_changed (GtkWidget *widget, CalendarPrefsDialog *prefs) -{ - calendar_config_set_hide_completed_tasks_value ( - gtk_spin_button_get_value_as_int ( - GTK_SPIN_BUTTON (prefs->tasks_hide_completed_interval))); -} - -static void -hide_completed_tasks_units_changed (GtkWidget *widget, CalendarPrefsDialog *prefs) -{ - calendar_config_set_hide_completed_tasks_units ( - e_dialog_combo_box_get (prefs->tasks_hide_completed_units, hide_completed_units_map)); -} - -static void -default_reminder_toggled (GtkToggleButton *toggle, CalendarPrefsDialog *prefs) -{ - calendar_config_set_use_default_reminder (gtk_toggle_button_get_active (toggle)); -} - -static void -default_reminder_interval_changed (GtkWidget *widget, CalendarPrefsDialog *prefs) -{ - const gchar *str; - gdouble value; - - str = gtk_entry_get_text (GTK_ENTRY (widget)); - value = g_ascii_strtod (str, NULL); - - calendar_config_set_default_reminder_interval (value); -} - -static void -default_reminder_units_changed (GtkWidget *widget, CalendarPrefsDialog *prefs) -{ - calendar_config_set_default_reminder_units ( - e_dialog_combo_box_get (prefs->default_reminder_units, default_reminder_units_map)); -} - -static void -ba_reminder_toggled (GtkToggleButton *toggle, CalendarPrefsDialog *prefs) -{ - gboolean enabled = gtk_toggle_button_get_active (toggle); - - calendar_config_set_ba_reminder (&enabled, NULL, NULL); -} - -static void -ba_reminder_interval_changed (GtkWidget *widget, CalendarPrefsDialog *prefs) -{ - const gchar *str; - gint value; - - str = gtk_entry_get_text (GTK_ENTRY (widget)); - value = (gint) g_ascii_strtod (str, NULL); - - calendar_config_set_ba_reminder (NULL, &value, NULL); -} - -static void -ba_reminder_units_changed (GtkWidget *widget, CalendarPrefsDialog *prefs) -{ - EDurationType units = e_dialog_combo_box_get (prefs->ba_reminder_units, default_reminder_units_map); - - calendar_config_set_ba_reminder (NULL, NULL, &units); -} - -static void -notify_with_tray_toggled (GtkToggleButton *toggle, CalendarPrefsDialog *prefs) -{ - GConfClient *gconf; - - g_return_if_fail (toggle != NULL); - - gconf = gconf_client_get_default (); - gconf_client_set_bool (gconf, "/apps/evolution/calendar/notify/notify_with_tray", gtk_toggle_button_get_active (toggle), NULL); - g_object_unref (gconf); -} - -static void -alarms_selection_changed (ESourceSelector *selector, CalendarPrefsDialog *prefs) -{ - ESourceList *source_list = prefs->alarms_list; - GSList *selection; - GSList *l; - GSList *groups; - ESource *source; - const gchar *alarm; - - /* first we clear all the alarm flags from all sources */ - for (groups = e_source_list_peek_groups (source_list); groups; groups = groups->next) { - ESourceGroup *group = E_SOURCE_GROUP (groups->data); - GSList *sources; - for (sources = e_source_group_peek_sources (group); sources; sources = sources->next) { - source = E_SOURCE (sources->data); - - alarm = e_source_get_property (source, "alarm"); - if (alarm && !g_ascii_strcasecmp (alarm, "never")) - continue; - - e_source_set_property (source, "alarm", "false"); - } - } - - /* then we loop over the selector's selection, setting the - property on those sources */ - selection = e_source_selector_get_selection (selector); - for (l = selection; l; l = l->next) { - source = E_SOURCE (l->data); - - alarm = (gchar *)e_source_get_property (source, "alarm"); - if (alarm && !g_ascii_strcasecmp (alarm, "never")) - continue; - - e_source_set_property (E_SOURCE (l->data), "alarm", "true"); - } - e_source_selector_free_selection (selection); - - /* FIXME show an error if this fails? */ - e_source_list_sync (source_list, NULL); -} - -static void -update_system_tz_widgets (EShellSettings *shell_settings, - GParamSpec *pspec, - CalendarPrefsDialog *prefs) -{ - GtkWidget *widget; - icaltimezone *zone; - const gchar *display_name; - gchar *text; - - widget = e_builder_get_widget (prefs->builder, "system-tz-label"); - g_return_if_fail (GTK_IS_LABEL (widget)); - - zone = e_cal_util_get_system_timezone (); - if (zone != NULL) - display_name = gettext (icaltimezone_get_display_name (zone)); - else - display_name = "UTC"; - - text = g_strdup_printf ("(%s)", display_name); - gtk_label_set_text (GTK_LABEL (widget), text); - g_free (text); -} - -static void -setup_changes (CalendarPrefsDialog *prefs) -{ - g_signal_connect (G_OBJECT (prefs->day_second_zone), "clicked", G_CALLBACK (day_second_zone_clicked), prefs); - - g_signal_connect (G_OBJECT (prefs->start_of_day), "changed", G_CALLBACK (start_of_day_changed), prefs); - g_signal_connect (G_OBJECT (prefs->end_of_day), "changed", G_CALLBACK (end_of_day_changed), prefs); - - g_signal_connect (G_OBJECT (prefs->time_divisions), "changed", G_CALLBACK (time_divisions_changed), prefs); - - g_signal_connect (G_OBJECT (prefs->month_scroll_by_week), "toggled", G_CALLBACK (month_scroll_by_week_toggled), prefs); - - g_signal_connect (G_OBJECT (prefs->tasks_hide_completed), "toggled", - G_CALLBACK (hide_completed_tasks_toggled), prefs); - g_signal_connect (G_OBJECT (prefs->tasks_hide_completed_interval), "value-changed", - G_CALLBACK (hide_completed_tasks_changed), prefs); - g_signal_connect (G_OBJECT (prefs->tasks_hide_completed_units), "changed", G_CALLBACK (hide_completed_tasks_units_changed), prefs); - - g_signal_connect (G_OBJECT (prefs->default_reminder), "toggled", G_CALLBACK (default_reminder_toggled), prefs); - g_signal_connect (G_OBJECT (prefs->default_reminder_interval), "changed", - G_CALLBACK (default_reminder_interval_changed), prefs); - g_signal_connect (G_OBJECT (prefs->default_reminder_units), "changed", G_CALLBACK (default_reminder_units_changed), prefs); - - g_signal_connect (G_OBJECT (prefs->ba_reminder), "toggled", G_CALLBACK (ba_reminder_toggled), prefs); - g_signal_connect (G_OBJECT (prefs->ba_reminder_interval), "changed", - G_CALLBACK (ba_reminder_interval_changed), prefs); - g_signal_connect (G_OBJECT (prefs->ba_reminder_units), "changed", G_CALLBACK (ba_reminder_units_changed), prefs); - - g_signal_connect (G_OBJECT (prefs->notify_with_tray), "toggled", G_CALLBACK (notify_with_tray_toggled), prefs); - g_signal_connect (G_OBJECT (prefs->alarm_list_widget), "selection_changed", G_CALLBACK (alarms_selection_changed), prefs); -} - -/* Shows the current task list settings in the dialog */ -static void -show_task_list_config (CalendarPrefsDialog *prefs) -{ - EDurationType units; - gboolean hide_completed_tasks; - - /* Hide Completed Tasks. */ - hide_completed_tasks = calendar_config_get_hide_completed_tasks (); - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (prefs->tasks_hide_completed), - hide_completed_tasks); - - /* Hide Completed Tasks Units. */ - units = calendar_config_get_hide_completed_tasks_units (); - e_dialog_combo_box_set (prefs->tasks_hide_completed_units, units, hide_completed_units_map); - - /* Hide Completed Tasks Value. */ - gtk_spin_button_set_value ( - GTK_SPIN_BUTTON (prefs->tasks_hide_completed_interval), - calendar_config_get_hide_completed_tasks_value ()); - - gtk_widget_set_sensitive (prefs->tasks_hide_completed_interval, hide_completed_tasks); - gtk_widget_set_sensitive (prefs->tasks_hide_completed_units, hide_completed_tasks); -} - -static void -initialize_selection (ESourceSelector *selector, ESourceList *source_list) -{ - GSList *groups; - - for (groups = e_source_list_peek_groups (source_list); groups; groups = groups->next) { - ESourceGroup *group = E_SOURCE_GROUP (groups->data); - GSList *sources; - for (sources = e_source_group_peek_sources (group); sources; sources = sources->next) { - ESource *source = E_SOURCE (sources->data); - const gchar *completion = e_source_get_property (source, "alarm"); - if (!completion || !g_ascii_strcasecmp (completion, "true")) { - if (!completion) - e_source_set_property (E_SOURCE (source), "alarm", "true"); - e_source_selector_select_source (selector, source); - } - } - } -} - -static void -show_alarms_config (CalendarPrefsDialog *prefs) -{ - GConfClient *gconf; - - if (e_cal_get_sources (&prefs->alarms_list, E_CAL_SOURCE_TYPE_EVENT, NULL)) { - prefs->alarm_list_widget = e_source_selector_new (prefs->alarms_list); - atk_object_set_name (gtk_widget_get_accessible (prefs->alarm_list_widget), _("Selected Calendars for Alarms")); - gtk_container_add (GTK_CONTAINER (prefs->scrolled_window), prefs->alarm_list_widget); - gtk_widget_show (prefs->alarm_list_widget); - initialize_selection (E_SOURCE_SELECTOR (prefs->alarm_list_widget), prefs->alarms_list); - } - - gconf = gconf_client_get_default (); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefs->notify_with_tray), gconf_client_get_bool (gconf, "/apps/evolution/calendar/notify/notify_with_tray", NULL)); - g_object_unref (gconf); -} - -/* Shows the current config settings in the dialog. */ -static void -show_config (CalendarPrefsDialog *prefs) -{ - gint time_divisions; - gboolean set = FALSE; - EDurationType units; - gint interval; - - /* Day's second zone */ - update_day_second_zone_caption (prefs); - - /* Day's second zone */ - update_day_second_zone_caption (prefs); - - /* Start of Day. */ - e_date_edit_set_time_of_day (E_DATE_EDIT (prefs->start_of_day), calendar_config_get_day_start_hour (), calendar_config_get_day_start_minute ()); - - /* End of Day. */ - e_date_edit_set_time_of_day (E_DATE_EDIT (prefs->end_of_day), calendar_config_get_day_end_hour (), calendar_config_get_day_end_minute ()); - - /* Time Divisions. */ - time_divisions = calendar_config_get_time_divisions (); - e_dialog_combo_box_set (prefs->time_divisions, time_divisions, time_division_map); - - /* Month View - Scroll by a week */ - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (prefs->month_scroll_by_week), - calendar_config_get_month_scroll_by_week ()); - - /* Task list */ - show_task_list_config (prefs); - - /* Alarms list*/ - show_alarms_config (prefs); - - /* Other page */ - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (prefs->default_reminder), - calendar_config_get_use_default_reminder ()); - gtk_spin_button_set_value ( - GTK_SPIN_BUTTON (prefs->default_reminder_interval), - calendar_config_get_default_reminder_interval ()); - e_dialog_combo_box_set (prefs->default_reminder_units, calendar_config_get_default_reminder_units (), default_reminder_units_map); - - /* Birthdays & Anniversaries reminder */ - set = calendar_config_get_ba_reminder (&interval, &units); - - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (prefs->ba_reminder), set); - gtk_spin_button_set_value ( - GTK_SPIN_BUTTON (prefs->ba_reminder_interval), interval); - e_dialog_combo_box_set (prefs->ba_reminder_units, units, default_reminder_units_map); -} - -/* plugin meta-data */ -static ECalConfigItem eccp_items[] = { - { E_CONFIG_BOOK, (gchar *) "", (gchar *) "toplevel-notebook", eccp_widget_glade }, - { E_CONFIG_PAGE, (gchar *) "00.general", (gchar *) "general", eccp_widget_glade }, - { E_CONFIG_SECTION_TABLE, (gchar *) "00.general/00.time", (gchar *) "time", eccp_widget_glade }, - { E_CONFIG_SECTION_TABLE, (gchar *) "00.general/10.workWeek", (gchar *) "workWeek", eccp_widget_glade }, - { E_CONFIG_SECTION, (gchar *) "00.general/20.alerts", (gchar *) "alerts", eccp_widget_glade }, - { E_CONFIG_PAGE, (gchar *) "10.display", (gchar *) "display", eccp_widget_glade }, - { E_CONFIG_SECTION, (gchar *) "10.display/00.general", (gchar *) "displayGeneral", eccp_widget_glade }, - { E_CONFIG_SECTION, (gchar *) "10.display/10.taskList", (gchar *) "taskList", eccp_widget_glade }, - { E_CONFIG_PAGE, (gchar *) "15.alarms", (gchar *) "alarms", eccp_widget_glade }, - { E_CONFIG_PAGE, (gchar *) "20.freeBusy", (gchar *) "freebusy", eccp_widget_glade }, - { E_CONFIG_SECTION, (gchar *) "20.freeBusy/00.defaultServer", (gchar *) "default-freebusy-vbox", eccp_widget_glade }, -}; - -static void -eccp_free (EConfig *ec, GSList *items, gpointer data) -{ - g_slist_free (items); -} - -static void -calendar_prefs_dialog_construct (CalendarPrefsDialog *prefs, - EShell *shell) -{ - ECalConfig *ec; - ECalConfigTargetPrefs *target; - EShellSettings *shell_settings; - gboolean locale_supports_12_hour_format; - gint i; - GtkWidget *toplevel; - GtkWidget *widget; - GtkWidget *table; - GSList *l; - - shell_settings = e_shell_get_shell_settings (shell); - - locale_supports_12_hour_format = - calendar_config_locale_supports_12_hour_format (); - - /* Force 24 hour format for locales which don't support 12 hour format */ - if (!locale_supports_12_hour_format - && !e_shell_settings_get_boolean (shell_settings, "cal-use-24-hour-format")) - e_shell_settings_set_boolean (shell_settings, "cal-use-24-hour-format", TRUE); - - /* Make sure our custom widget classes are registered with - * GType before we load the GtkBuilder definition file. */ - E_TYPE_DATE_EDIT; - E_TYPE_TIMEZONE_ENTRY; - - prefs->builder = gtk_builder_new (); - e_load_ui_builder_definition (prefs->builder, "cal-prefs-dialog.ui"); - - prefs->gconf = gconf_client_get_default (); - - /** @HookPoint-ECalConfig: Calendar Preferences Page - * @Id: org.gnome.evolution.calendar.prefs - * @Type: E_CONFIG_BOOK - * @Class: org.gnome.evolution.calendar.config:1.0 - * @Target: ECalConfigTargetPrefs - * - * The mail calendar preferences page - */ - ec = e_cal_config_new (E_CONFIG_BOOK, "org.gnome.evolution.calendar.prefs"); - l = NULL; - for (i = 0; i < G_N_ELEMENTS (eccp_items); i++) - l = g_slist_prepend (l, &eccp_items[i]); - e_config_add_items ((EConfig *) ec, l, NULL, NULL, eccp_free, prefs); - - widget = e_builder_get_widget (prefs->builder, "use-system-tz-check"); - g_object_bind_property ( - shell_settings, "cal-use-system-timezone", - widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - g_signal_connect ( - shell_settings, "notify::cal-use-system-timezone", - G_CALLBACK (update_system_tz_widgets), prefs); - g_object_notify (G_OBJECT (shell_settings), "cal-use-system-timezone"); - - widget = e_builder_get_widget (prefs->builder, "timezone"); - g_object_bind_property ( - shell_settings, "cal-timezone", - widget, "timezone", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - g_object_bind_property ( - shell_settings, "cal-use-system-timezone", - widget, "sensitive", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE | - G_BINDING_INVERT_BOOLEAN); - - /* General tab */ - prefs->day_second_zone = e_builder_get_widget (prefs->builder, "day_second_zone"); - - widget = e_builder_get_widget (prefs->builder, "sun_button"); - g_object_bind_property ( - shell_settings, "cal-working-days-sunday", - widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - - widget = e_builder_get_widget (prefs->builder, "mon_button"); - g_object_bind_property ( - shell_settings, "cal-working-days-monday", - widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - - widget = e_builder_get_widget (prefs->builder, "tue_button"); - g_object_bind_property ( - shell_settings, "cal-working-days-tuesday", - widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - - widget = e_builder_get_widget (prefs->builder, "wed_button"); - g_object_bind_property ( - shell_settings, "cal-working-days-wednesday", - widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - - widget = e_builder_get_widget (prefs->builder, "thu_button"); - g_object_bind_property ( - shell_settings, "cal-working-days-thursday", - widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - - widget = e_builder_get_widget (prefs->builder, "fri_button"); - g_object_bind_property ( - shell_settings, "cal-working-days-friday", - widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - - widget = e_builder_get_widget (prefs->builder, "sat_button"); - g_object_bind_property ( - shell_settings, "cal-working-days-saturday", - widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - - widget = e_builder_get_widget (prefs->builder, "week_start_day"); - g_object_bind_property ( - shell_settings, "cal-week-start-day", - widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - - widget = e_builder_get_widget (prefs->builder, "start_of_day"); - prefs->start_of_day = widget; /* XXX delete this */ - if (locale_supports_12_hour_format) - g_object_bind_property ( - shell_settings, "cal-use-24-hour-format", - widget, "use-24-hour-format", - G_BINDING_SYNC_CREATE); - - widget = e_builder_get_widget (prefs->builder, "end_of_day"); - prefs->end_of_day = widget; /* XXX delete this */ - if (locale_supports_12_hour_format) - g_object_bind_property ( - shell_settings, "cal-use-24-hour-format", - widget, "use-24-hour-format", - G_BINDING_SYNC_CREATE); - - widget = e_builder_get_widget (prefs->builder, "use_12_hour"); - gtk_widget_set_sensitive (widget, locale_supports_12_hour_format); - g_object_bind_property ( - shell_settings, "cal-use-24-hour-format", - widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE | - G_BINDING_INVERT_BOOLEAN); - - widget = e_builder_get_widget (prefs->builder, "use_24_hour"); - gtk_widget_set_sensitive (widget, locale_supports_12_hour_format); - g_object_bind_property ( - shell_settings, "cal-use-24-hour-format", - widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - - widget = e_builder_get_widget (prefs->builder, "confirm_delete"); - g_object_bind_property ( - shell_settings, "cal-confirm-delete", - widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - - prefs->default_reminder = e_builder_get_widget (prefs->builder, "default_reminder"); - prefs->default_reminder_interval = e_builder_get_widget (prefs->builder, "default_reminder_interval"); - prefs->default_reminder_units = e_builder_get_widget (prefs->builder, "default_reminder_units"); - prefs->ba_reminder = e_builder_get_widget (prefs->builder, "ba_reminder"); - prefs->ba_reminder_interval = e_builder_get_widget (prefs->builder, "ba_reminder_interval"); - prefs->ba_reminder_units = e_builder_get_widget (prefs->builder, "ba_reminder_units"); - - /* Display tab */ - prefs->time_divisions = e_builder_get_widget (prefs->builder, "time_divisions"); - - widget = e_builder_get_widget (prefs->builder, "show_end_times"); - g_object_bind_property ( - shell_settings, "cal-show-event-end-times", - widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - - widget = e_builder_get_widget (prefs->builder, "compress_weekend"); - g_object_bind_property ( - shell_settings, "cal-compress-weekend", - widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - - widget = e_builder_get_widget (prefs->builder, "show_week_numbers"); - g_object_bind_property ( - shell_settings, "cal-show-week-numbers", - widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - - widget = e_builder_get_widget (prefs->builder, "recur_events_italic"); - g_object_bind_property ( - shell_settings, "cal-recur-events-italic", - widget, "active", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - - prefs->month_scroll_by_week = e_builder_get_widget (prefs->builder, "month_scroll_by_week"); - - widget = e_builder_get_widget (prefs->builder, "tasks_due_today_color"); - g_object_bind_property_full ( - shell_settings, "cal-tasks-color-due-today", - widget, "color", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - e_binding_transform_string_to_color, - e_binding_transform_color_to_string, - NULL, (GDestroyNotify) NULL); - - widget = e_builder_get_widget (prefs->builder, "tasks_overdue_color"); - g_object_bind_property_full ( - shell_settings, "cal-tasks-color-overdue", - widget, "color", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE, - e_binding_transform_string_to_color, - e_binding_transform_color_to_string, - (GDestroyNotify) NULL, NULL); - - prefs->tasks_hide_completed = e_builder_get_widget (prefs->builder, "tasks_hide_completed"); - prefs->tasks_hide_completed_interval = e_builder_get_widget (prefs->builder, "tasks_hide_completed_interval"); - prefs->tasks_hide_completed_units = e_builder_get_widget (prefs->builder, "tasks_hide_completed_units"); - - /* Alarms tab */ - prefs->notify_with_tray = e_builder_get_widget (prefs->builder, "notify_with_tray"); - prefs->scrolled_window = e_builder_get_widget (prefs->builder, "calendar-source-scrolled-window"); - - /* Free/Busy tab */ - widget = e_builder_get_widget (prefs->builder, "template_url"); - g_object_bind_property ( - shell_settings, "cal-free-busy-template", - widget, "text", - G_BINDING_BIDIRECTIONAL | - G_BINDING_SYNC_CREATE); - - /* date/time format */ - table = e_builder_get_widget (prefs->builder, "datetime_format_table"); - e_datetime_format_add_setup_widget (table, 0, "calendar", "table", DTFormatKindDateTime, _("Ti_me and date:")); - e_datetime_format_add_setup_widget (table, 1, "calendar", "table", DTFormatKindDate, _("_Date only:")); - - /* Hide senseless preferences when running in Express mode */ - e_shell_hide_widgets_for_express_mode (shell, prefs->builder, - "label_second_zone", - "hbox_second_zone", - "timezone", - "timezone_label", - "hbox_use_system_timezone", - "hbox_time_divisions", - "show_end_times", - "month_scroll_by_week", - NULL); - - /* HACK: GTK+ 2.18 and 2.20 has a GtkTable which includes row/column spacing even for empty rows/columns. - * When Evo runs in Express mode, we hide all the rows in the Time section of the calendar's General - * preferences page. However, due to that behavior in GTK+, we get a lot of extra spacing in that - * section. Since we know that in Express mode we only leave a single row visible, we'll make the - * table's row spacing equal to 0 in that case. - */ - if (e_shell_get_express_mode (shell)) { - widget = e_builder_get_widget (prefs->builder, "time"); - gtk_table_set_row_spacings (GTK_TABLE (widget), 0); - } - - /* Hook up and add the toplevel widget */ - - target = e_cal_config_target_new_prefs (ec, prefs->gconf); - e_config_set_target ((EConfig *)ec, (EConfigTarget *) target); - toplevel = e_config_create_widget ((EConfig *)ec); - gtk_container_add (GTK_CONTAINER (prefs), toplevel); - - show_config (prefs); - /* FIXME: weakref? */ - setup_changes (prefs); -} - -GType -calendar_prefs_dialog_get_type (void) -{ - static GType type = 0; - - if (!type) { - static GTypeInfo type_info = { - sizeof (CalendarPrefsDialogClass), - NULL, NULL, - (GClassInitFunc) calendar_prefs_dialog_class_init, - NULL, NULL, - sizeof (CalendarPrefsDialog), - 0, - (GInstanceInitFunc) calendar_prefs_dialog_init, - }; - - type = g_type_register_static (GTK_TYPE_VBOX, "CalendarPrefsDialog", &type_info, 0); - } - - return type; -} - -GtkWidget * -calendar_prefs_dialog_new (EPreferencesWindow *window) -{ - EShell *shell; - CalendarPrefsDialog *dialog; - - shell = e_preferences_window_get_shell (window); - - g_return_val_if_fail (E_IS_SHELL (shell), NULL); - - dialog = g_object_new (CALENDAR_TYPE_PREFS_DIALOG, NULL); - - /* FIXME Kill this function. */ - calendar_prefs_dialog_construct (dialog, shell); - - return GTK_WIDGET (dialog); -} diff --git a/calendar/gui/dialogs/cal-prefs-dialog.h b/calendar/gui/dialogs/cal-prefs-dialog.h deleted file mode 100644 index 869003f664..0000000000 --- a/calendar/gui/dialogs/cal-prefs-dialog.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * David Trowbridge - * Damon Chaplin - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef CAL_PREFS_DIALOG_H -#define CAL_PREFS_DIALOG_H - -#include -#include -#include -#include - -/* Standard GObject macros */ -#define CALENDAR_TYPE_PREFS_DIALOG \ - (calendar_prefs_dialog_get_type ()) -#define CALENDAR_PREFS_DIALOG(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), CALENDAR_TYPE_PREFS_DIALOG, CalendarPrefsDialog)) -#define CALENDAR_PREFS_DIALOG_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), CALENDAR_TYPE_PREFS_DIALOG, CalendarPrefsDialogClass)) -#define CALENDAR_IS_PREFS_DIALOG(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), CALENDAR_TYPE_PREFS_DIALOG)) -#define CALENDAR_IS_PREFS_DIALOG_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), CALENDAR_TYPE_PREFS_DIALOG)) -#define CALENDAR_PREFS_DIALOG_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), CALENDAR_TYPE_PREFS_DIALOG, CalendarPrefsDialogClass)) - -G_BEGIN_DECLS - -typedef struct _CalendarPrefsDialog CalendarPrefsDialog; -typedef struct _CalendarPrefsDialogClass CalendarPrefsDialogClass; - -struct _CalendarPrefsDialog { - GtkVBox parent; - - GtkBuilder *builder; - - GConfClient *gconf; - - /* General tab */ - GtkWidget *day_second_zone; - GtkWidget *working_days[7]; - GtkWidget *week_start_day; - GtkWidget *start_of_day; - GtkWidget *end_of_day; - GtkWidget *confirm_delete; - GtkWidget *default_reminder; - GtkWidget *default_reminder_interval; - GtkWidget *default_reminder_units; - GtkWidget *ba_reminder; - GtkWidget *ba_reminder_interval; - GtkWidget *ba_reminder_units; - - /* Display tab */ - GtkWidget *time_divisions; - GtkWidget *show_end_times; - GtkWidget *compress_weekend; - GtkWidget *month_scroll_by_week; - GtkWidget *tasks_hide_completed; - GtkWidget *tasks_hide_completed_interval; - GtkWidget *tasks_hide_completed_units; - - /* Alarms tab */ - GtkWidget *notify_with_tray; - GtkWidget *scrolled_window; - ESourceList *alarms_list; - GtkWidget *alarm_list_widget; - - /* Free/Busy tab */ - GtkWidget *url_add; - GtkWidget *url_edit; - GtkWidget *url_remove; - GtkWidget *url_enable; - GtkWidget *url_enable_label; - GtkWidget *url_enable_image; - GtkWidget *url_list; - GtkWidget *template_url; - guint destroyed : 1; -}; - -struct _CalendarPrefsDialogClass { - GtkVBoxClass parent; -}; - -GType calendar_prefs_dialog_get_type (void); -GtkWidget * calendar_prefs_dialog_new (EPreferencesWindow *window); - -G_END_DECLS - -#endif /* CAL_PREFS_DIALOG_H */ diff --git a/calendar/gui/dialogs/cal-prefs-dialog.ui b/calendar/gui/dialogs/cal-prefs-dialog.ui deleted file mode 100644 index 7e581cf4ad..0000000000 --- a/calendar/gui/dialogs/cal-prefs-dialog.ui +++ /dev/null @@ -1,1440 +0,0 @@ - - - - - - - 9999 - 1 - 10 - - - 9999 - 1 - 10 - - - 1 - 9999 - 1 - 10 - - - - - - - - - Monday - - - Tuesday - - - Wednesday - - - Thursday - - - Friday - - - Saturday - - - Sunday - - - - - - - - - - - Minutes - - - Hours - - - Days - - - - - - - - - - - Minutes - - - Hours - - - Days - - - - - - - - - - - 60 minutes - - - 30 minutes - - - 15 minutes - - - 10 minutes - - - 05 minutes - - - - - - - - - - - Minutes - - - Hours - - - Days - - - - - True - True - - - True - 12 - 12 - - - True - 0 - Time - - - - - - False - False - 0 - - - - - True - 12 - - - True - - - False - False - 0 - - - - - True - 4 - 2 - 6 - 6 - - - True - 0 - Se_cond zone: - True - day_second_zone - - - 3 - 4 - GTK_FILL - - - - - - True - - - None - True - True - False - True - - - 0 - - - - - True - 6 - (Shown in a Day View) - - - False - False - 1 - - - - - 1 - 2 - 3 - 4 - GTK_FILL - GTK_FILL - - - - - True - - - - - - 1 - 2 - 2 - 3 - GTK_FILL - - - - - True - 0 - Time _zone: - True - timezone - - - 1 - 2 - GTK_FILL - - - - - - True - - - Use s_ystem time zone - True - True - False - True - True - - - False - 0 - - - - - True - 5 - (system/tz) - - - False - False - 1 - - - - - 1 - 2 - 1 - 2 - GTK_FILL - - - - - True - 0 - Time format: - - - GTK_FILL - - - - - - True - 6 - - - _12 hour (AM/PM) - True - True - False - True - True - True - - - False - False - 0 - - - - - _24 hour - True - True - False - True - True - use_12_hour - - - False - False - 1 - - - - - 1 - 2 - GTK_FILL - GTK_FILL - - - - - - - - 1 - - - - - False - 1 - - - - - True - 0 - Work Week - - - - - - False - False - 2 - - - - - True - 12 - - - True - - - False - False - 0 - - - - - True - 3 - 2 - 6 - 6 - - - True - 0 - Wee_k starts on: - True - week_start_day - - - GTK_FILL - - - - - - True - 0 - Work days: - - - 1 - 2 - GTK_FILL - - - - - - True - 0 - _Day begins: - True - - - 2 - 3 - GTK_FILL - - - - - - True - 6 - - - _Mon - True - True - False - True - True - - - Monday - - - - - False - False - 0 - - - - - _Tue - True - True - False - True - True - - - Tuesday - - - - - False - False - 1 - - - - - _Wed - True - True - False - True - True - - - Wednesday - - - - - False - False - 2 - - - - - T_hu - True - True - False - True - True - - - Thursday - - - - - False - False - 3 - - - - - _Fri - True - True - False - True - True - - - Friday - - - - - False - False - 4 - - - - - _Sat - True - True - False - True - True - - - Saturday - - - - - False - False - 5 - - - - - S_un - True - True - False - True - True - - - Sunday - - - - - False - False - 6 - - - - - 1 - 2 - 1 - 2 - GTK_FILL - GTK_FILL - - - - - True - model1 - - - - 0 - - - - - 1 - 2 - GTK_FILL - GTK_FILL - - - - - True - 12 - - - True - False - False - - - False - False - 0 - - - - - True - 0 - Day _ends: - True - - - False - end - 2 - - - - - True - False - False - - - False - False - end - 1 - - - - - 1 - 2 - 2 - 3 - GTK_FILL - - - - - 1 - - - - - False - 3 - - - - - True - 0 - Alerts - - - - - - False - False - 4 - - - - - True - 12 - - - True - - - False - False - 0 - - - - - True - 6 - - - _Ask for confirmation when deleting items - True - True - False - True - True - - - False - False - 0 - - - - - True - 4 - - - Sh_ow a reminder - True - True - False - True - True - - - False - False - 0 - - - - - True - True - adjustment1 - 1 - - - 1 - - - - - True - model2 - - - - 0 - - - - - 2 - - - - - True - before every appointment - - - False - False - 3 - - - - - 1 - - - - - True - 4 - - - Show a _reminder - True - True - False - True - True - - - False - False - 0 - - - - - True - True - adjustment2 - 1 - - - 1 - - - - - True - model3 - - - - 0 - - - - - 2 - - - - - True - before every anniversary/birthday - - - False - False - 3 - - - - - 2 - - - - - 1 - - - - - False - 5 - - - - - - - True - General - - - False - - - - - True - 12 - 12 - - - True - 0 - General - - - - - - False - False - 0 - - - - - True - 12 - - - True - - - False - False - 0 - - - - - True - 6 - - - True - 6 - - - True - _Time divisions: - True - time_divisions - - - False - False - 0 - - - - - True - model4 - - - - 0 - - - - - 1 - - - - - 0 - - - - - _Show appointment end times in week and month view - True - True - False - True - True - - - False - False - 1 - - - - - _Compress weekends in month view - True - True - False - True - True - - - False - False - 2 - - - - - Show week _numbers - True - True - False - True - True - - - False - False - 3 - - - - - Show r_ecurring events in italic in bottom left calendar - True - True - False - True - True - - - False - False - 4 - - - - - Sc_roll Month View by a week - True - True - False - True - True - - - False - False - 5 - - - - - 1 - - - - - False - 1 - - - - - True - 0 - Task List - - - - - - False - False - 2 - - - - - True - 12 - - - True - - - False - False - 0 - - - - - True - 6 - - - True - 12 - - - True - 0 - T_asks due today: - True - tasks_due_today_color - - - False - False - 0 - - - - - True - True - True - Pick a color - #000000000000 - - - False - False - 1 - - - - - True - 0 - _Overdue tasks: - True - tasks_overdue_color - - - False - False - end - 3 - - - - - True - True - True - Pick a color - #000000000000 - - - False - False - end - 2 - - - - - False - False - 0 - - - - - True - 6 - - - _Hide completed tasks after - True - True - False - True - True - - - False - False - 0 - - - - - True - True - adjustment3 - 1 - - - 1 - - - - - True - model5 - - - - 0 - - - - - 2 - - - - - 1 - - - - - 1 - - - - - False - 3 - - - - - True - 0 - Date/Time Format - - - - - - False - False - 4 - - - - - True - 12 - - - True - - - False - False - 0 - - - - - True - 3 - - - - - - - - - - - - 1 - - - - - 5 - - - - - 1 - - - - - True - Display - - - 1 - False - - - - - True - 12 - vertical - 6 - - - True - 0 - Alarms - - - - - - False - False - 0 - - - - - True - 10 - - - Display alarms in _notification area only - True - True - False - True - True - - - - - False - 1 - - - - - True - 0 - Select the calendars for alarm notification - - - False - False - 2 - - - - - True - True - automatic - automatic - in - - - - - - 3 - - - - - 2 - - - - - True - Alarms - - - 2 - False - - - - - True - 12 - vertical - 12 - - - True - 0 - Default Free/Busy Server - - - - - - False - False - 0 - - - - - True - 12 - - - True - vertical - 6 - - - True - 6 - - - True - Template: - - - False - False - 0 - - - - - True - True - - - - 1 - - - - - 0 - - - - - True - %u and %d will be replaced by user and domain from the email address. - True - - - - - - False - False - 1 - - - - - - - False - False - 1 - - - - - 3 - - - - - True - Free/Busy - - - 3 - False - - - - - - - - - - diff --git a/calendar/gui/dialogs/comp-editor-util.c b/calendar/gui/dialogs/comp-editor-util.c index 69ec171917..a29d75739c 100644 --- a/calendar/gui/dialogs/comp-editor-util.c +++ b/calendar/gui/dialogs/comp-editor-util.c @@ -33,7 +33,6 @@ #include #include #include "widgets/misc/e-dateedit.h" -#include "../calendar-config.h" #include "../itip-utils.h" #include #include "comp-editor-util.h" @@ -147,14 +146,15 @@ comp_editor_new_date_edit (gboolean show_date, FIXME: Should probably use the timezone from somewhere in the component rather than the current timezone. */ struct tm -comp_editor_get_current_time (GObject *object, gpointer data) +comp_editor_get_current_time (EDateEdit *date_edit, + CompEditor *editor) { icaltimezone *zone; struct icaltimetype tt; struct tm tmp_tm = { 0 }; /* Get the current timezone. */ - zone = calendar_config_get_icaltimezone (); + zone = comp_editor_get_timezone (editor); tt = icaltime_from_timet_with_zone (time (NULL), FALSE, zone); diff --git a/calendar/gui/dialogs/comp-editor-util.h b/calendar/gui/dialogs/comp-editor-util.h index 07ba65a799..a4ecc468a7 100644 --- a/calendar/gui/dialogs/comp-editor-util.h +++ b/calendar/gui/dialogs/comp-editor-util.h @@ -26,8 +26,9 @@ #define _COMP_EDITOR_UTIL_H_ #include -#include "comp-editor-page.h" +#include "comp-editor.h" #include "../e-meeting-attendee.h" +#include void comp_editor_dates (CompEditorPageDates *date, ECalComponent *comp); void comp_editor_free_dates (CompEditorPageDates *dates); @@ -38,7 +39,7 @@ GtkWidget * comp_editor_new_date_edit (gboolean show_date, gboolean show_time, gboolean make_time_insensitive); -struct tm comp_editor_get_current_time (GObject *object, gpointer data); +struct tm comp_editor_get_current_time (EDateEdit *date_edit, CompEditor *editor); gchar *comp_editor_strip_categories (const gchar *categories); diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index af5b23d384..1714ef405d 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -112,6 +113,14 @@ struct _CompEditorPrivate { below */ CompEditorFlags flags; + icaltimezone *zone; + gboolean use_24_hour_format; + + gint work_day_end_hour; + gint work_day_end_minute; + gint work_day_start_hour; + gint work_day_start_minute; + gboolean changed; gboolean needs_send; @@ -131,7 +140,13 @@ enum { PROP_FLAGS, PROP_FOCUS_TRACKER, PROP_SHELL, - PROP_SUMMARY + PROP_SUMMARY, + PROP_TIMEZONE, + PROP_USE_24_HOUR_FORMAT, + PROP_WORK_DAY_END_HOUR, + PROP_WORK_DAY_END_MINUTE, + PROP_WORK_DAY_START_HOUR, + PROP_WORK_DAY_START_MINUTE }; static const gchar *ui = @@ -731,11 +746,12 @@ action_print_cb (GtkAction *action, CompEditor *editor) { CompEditorPrivate *priv = editor->priv; - GtkPrintOperationAction print_action; ECalComponent *comp; GList *l; icalcomponent *component; icalcomponent *clone; + icaltimezone *zone; + gboolean use_24_hour_format; comp = e_cal_component_new (); component = e_cal_component_get_icalcomponent (priv->comp); @@ -745,8 +761,12 @@ action_print_cb (GtkAction *action, for (l = priv->pages; l != NULL; l = l->next) comp_editor_page_fill_component (l->data, comp); - print_action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG; - print_comp (comp, priv->client, print_action); + zone = comp_editor_get_timezone (editor); + use_24_hour_format = comp_editor_get_use_24_hour_format (editor); + + print_comp ( + comp, priv->client, zone, use_24_hour_format, + GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG); g_object_unref (comp); } @@ -756,11 +776,12 @@ action_print_preview_cb (GtkAction *action, CompEditor *editor) { CompEditorPrivate *priv = editor->priv; - GtkPrintOperationAction print_action; ECalComponent *comp; GList *l; icalcomponent *component; icalcomponent *clone; + icaltimezone *zone; + gboolean use_24_hour_format; comp = e_cal_component_new (); component = e_cal_component_get_icalcomponent (priv->comp); @@ -770,8 +791,12 @@ action_print_preview_cb (GtkAction *action, for (l = priv->pages; l != NULL; l = l->next) comp_editor_page_fill_component (l->data, comp); - print_action = GTK_PRINT_OPERATION_ACTION_PREVIEW; - print_comp (comp, priv->client, print_action); + zone = comp_editor_get_timezone (editor); + use_24_hour_format = comp_editor_get_use_24_hour_format (editor); + + print_comp ( + comp, priv->client, zone, use_24_hour_format, + GTK_PRINT_OPERATION_ACTION_PREVIEW); g_object_unref (comp); } @@ -1271,6 +1296,42 @@ comp_editor_set_property (GObject *object, COMP_EDITOR (object), g_value_get_string (value)); return; + + case PROP_TIMEZONE: + comp_editor_set_timezone ( + COMP_EDITOR (object), + g_value_get_pointer (value)); + return; + + case PROP_USE_24_HOUR_FORMAT: + comp_editor_set_use_24_hour_format ( + COMP_EDITOR (object), + g_value_get_boolean (value)); + return; + + case PROP_WORK_DAY_END_HOUR: + comp_editor_set_work_day_end_hour ( + COMP_EDITOR (object), + g_value_get_int (value)); + return; + + case PROP_WORK_DAY_END_MINUTE: + comp_editor_set_work_day_end_minute ( + COMP_EDITOR (object), + g_value_get_int (value)); + return; + + case PROP_WORK_DAY_START_HOUR: + comp_editor_set_work_day_start_hour ( + COMP_EDITOR (object), + g_value_get_int (value)); + return; + + case PROP_WORK_DAY_START_MINUTE: + comp_editor_set_work_day_start_minute ( + COMP_EDITOR (object), + g_value_get_int (value)); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -1318,6 +1379,42 @@ comp_editor_get_property (GObject *object, value, comp_editor_get_summary ( COMP_EDITOR (object))); return; + + case PROP_TIMEZONE: + g_value_set_pointer ( + value, comp_editor_get_timezone ( + COMP_EDITOR (object))); + return; + + case PROP_USE_24_HOUR_FORMAT: + g_value_set_boolean ( + value, comp_editor_get_use_24_hour_format ( + COMP_EDITOR (object))); + return; + + case PROP_WORK_DAY_END_HOUR: + g_value_set_int ( + value, comp_editor_get_work_day_end_hour ( + COMP_EDITOR (object))); + return; + + case PROP_WORK_DAY_END_MINUTE: + g_value_set_int ( + value, comp_editor_get_work_day_end_minute ( + COMP_EDITOR (object))); + return; + + case PROP_WORK_DAY_START_HOUR: + g_value_set_int ( + value, comp_editor_get_work_day_start_hour ( + COMP_EDITOR (object))); + return; + + case PROP_WORK_DAY_START_MINUTE: + g_value_set_int ( + value, comp_editor_get_work_day_start_minute ( + COMP_EDITOR (object))); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -1605,14 +1702,81 @@ comp_editor_class_init (CompEditorClass *class) NULL, G_PARAM_READWRITE)); - signals[OBJECT_CREATED] = - g_signal_new ("object_created", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CompEditorClass, object_created), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); + g_object_class_install_property ( + object_class, + PROP_TIMEZONE, + g_param_spec_pointer ( + "timezone", + "Time Zone", + NULL, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_USE_24_HOUR_FORMAT, + g_param_spec_boolean ( + "use-24-hour-format", + "Use 24-hour Format", + NULL, + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_WORK_DAY_END_HOUR, + g_param_spec_int ( + "work-day-end-hour", + "Work Day End Hour", + NULL, + 0, + 23, + 0, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_WORK_DAY_END_MINUTE, + g_param_spec_int ( + "work-day-end-minute", + "Work Day End Minute", + NULL, + 0, + 59, + 0, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_WORK_DAY_START_HOUR, + g_param_spec_int ( + "work-day-start-hour", + "Work Day Start Hour", + NULL, + 0, + 23, + 0, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_WORK_DAY_START_MINUTE, + g_param_spec_int ( + "work-day-start-minute", + "Work Day Start Minute", + NULL, + 0, + 59, + 0, + G_PARAM_READWRITE)); + + signals[OBJECT_CREATED] = g_signal_new ( + "object_created", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (CompEditorClass, object_created), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); } static void @@ -2091,6 +2255,120 @@ comp_editor_get_summary (CompEditor *editor) return editor->priv->summary; } +icaltimezone * +comp_editor_get_timezone (CompEditor *editor) +{ + g_return_val_if_fail (IS_COMP_EDITOR (editor), NULL); + + return editor->priv->zone; +} + +void +comp_editor_set_timezone (CompEditor *editor, + icaltimezone *zone) +{ + g_return_if_fail (IS_COMP_EDITOR (editor)); + + editor->priv->zone = zone; + + g_object_notify (G_OBJECT (editor), "timezone"); +} + +gboolean +comp_editor_get_use_24_hour_format (CompEditor *editor) +{ + g_return_val_if_fail (IS_COMP_EDITOR (editor), FALSE); + + return editor->priv->use_24_hour_format; +} + +void +comp_editor_set_use_24_hour_format (CompEditor *editor, + gboolean use_24_hour_format) +{ + g_return_if_fail (IS_COMP_EDITOR (editor)); + + editor->priv->use_24_hour_format = use_24_hour_format; + + g_object_notify (G_OBJECT (editor), "use-24-hour-format"); +} + +gint +comp_editor_get_work_day_end_hour (CompEditor *editor) +{ + g_return_val_if_fail (IS_COMP_EDITOR (editor), 0); + + return editor->priv->work_day_end_hour; +} + +void +comp_editor_set_work_day_end_hour (CompEditor *editor, + gint work_day_end_hour) +{ + g_return_if_fail (IS_COMP_EDITOR (editor)); + + editor->priv->work_day_end_hour = work_day_end_hour; + + g_object_notify (G_OBJECT (editor), "work-day-end-hour"); +} + +gint +comp_editor_get_work_day_end_minute (CompEditor *editor) +{ + g_return_val_if_fail (IS_COMP_EDITOR (editor), 0); + + return editor->priv->work_day_end_minute; +} + +void +comp_editor_set_work_day_end_minute (CompEditor *editor, + gint work_day_end_minute) +{ + g_return_if_fail (IS_COMP_EDITOR (editor)); + + editor->priv->work_day_end_minute = work_day_end_minute; + + g_object_notify (G_OBJECT (editor), "work-day-end-minute"); +} + +gint +comp_editor_get_work_day_start_hour (CompEditor *editor) +{ + g_return_val_if_fail (IS_COMP_EDITOR (editor), 0); + + return editor->priv->work_day_start_hour; +} + +void +comp_editor_set_work_day_start_hour (CompEditor *editor, + gint work_day_start_hour) +{ + g_return_if_fail (IS_COMP_EDITOR (editor)); + + editor->priv->work_day_start_hour = work_day_start_hour; + + g_object_notify (G_OBJECT (editor), "work-day-start-hour"); +} + +gint +comp_editor_get_work_day_start_minute (CompEditor *editor) +{ + g_return_val_if_fail (IS_COMP_EDITOR (editor), 0); + + return editor->priv->work_day_start_minute; +} + +void +comp_editor_set_work_day_start_minute (CompEditor *editor, + gint work_day_start_minute) +{ + g_return_if_fail (IS_COMP_EDITOR (editor)); + + editor->priv->work_day_start_minute = work_day_start_minute; + + g_object_notify (G_OBJECT (editor), "work-day-start-minute"); +} + /** * comp_editor_set_changed: * @editor: A component editor diff --git a/calendar/gui/dialogs/comp-editor.h b/calendar/gui/dialogs/comp-editor.h index 09ced8f533..591300ffd2 100644 --- a/calendar/gui/dialogs/comp-editor.h +++ b/calendar/gui/dialogs/comp-editor.h @@ -123,6 +123,34 @@ EShell * comp_editor_get_shell (CompEditor *editor); void comp_editor_set_summary (CompEditor *editor, const gchar *summary); const gchar * comp_editor_get_summary (CompEditor *editor); +icaltimezone * comp_editor_get_timezone (CompEditor *editor); +void comp_editor_set_timezone (CompEditor *editor, + icaltimezone *zone); +gboolean comp_editor_get_use_24_hour_format + (CompEditor *editor); +void comp_editor_set_use_24_hour_format + (CompEditor *editor, + gboolean use_24_hour_format); +gint comp_editor_get_work_day_end_hour + (CompEditor *editor); +void comp_editor_set_work_day_end_hour + (CompEditor *editor, + gint work_day_end_hour); +gint comp_editor_get_work_day_end_minute + (CompEditor *editor); +void comp_editor_set_work_day_end_minute + (CompEditor *editor, + gint work_day_end_minute); +gint comp_editor_get_work_day_start_hour + (CompEditor *editor); +void comp_editor_set_work_day_start_hour + (CompEditor *editor, + gint work_day_start_hour); +gint comp_editor_get_work_day_start_minute + (CompEditor *editor); +void comp_editor_set_work_day_start_minute + (CompEditor *editor, + gint work_day_start_minute); void comp_editor_append_page (CompEditor *editor, CompEditorPage *page, const gchar *label, diff --git a/calendar/gui/dialogs/delete-comp.c b/calendar/gui/dialogs/delete-comp.c index ecdaf58762..b0ccb953b2 100644 --- a/calendar/gui/dialogs/delete-comp.c +++ b/calendar/gui/dialogs/delete-comp.c @@ -28,7 +28,6 @@ #include #include "e-util/e-alert-dialog.h" -#include "../calendar-config.h" #include "delete-comp.h" @@ -57,9 +56,10 @@ **/ gboolean delete_component_dialog (ECalComponent *comp, - gboolean consider_as_untitled, - gint n_comps, ECalComponentVType vtype, - GtkWidget *widget) + gboolean consider_as_untitled, + gint n_comps, + ECalComponentVType vtype, + GtkWidget *widget) { const gchar *id; gchar *arg0 = NULL; @@ -74,12 +74,8 @@ delete_component_dialog (ECalComponent *comp, g_return_val_if_fail (vtype != E_CAL_COMPONENT_NO_TYPE, FALSE); } - g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); - if (!calendar_config_get_confirm_delete ()) - return TRUE; - if (comp) { ECalComponentText summary; diff --git a/calendar/gui/dialogs/e-send-options-utils.c b/calendar/gui/dialogs/e-send-options-utils.c index c56caab8bf..b21352d6f3 100644 --- a/calendar/gui/dialogs/e-send-options-utils.c +++ b/calendar/gui/dialogs/e-send-options-utils.c @@ -23,7 +23,6 @@ */ #include "e-send-options-utils.h" -#include "../calendar-config.h" #include #include @@ -151,7 +150,9 @@ e_send_options_utils_set_default_data (ESendOptionsDialog *sod, ESource *source, } void -e_send_options_utils_fill_component (ESendOptionsDialog *sod, ECalComponent *comp) +e_send_options_utils_fill_component (ESendOptionsDialog *sod, + ECalComponent *comp, + icaltimezone *zone) { gint i = 1; icalproperty *prop; @@ -189,7 +190,6 @@ e_send_options_utils_fill_component (ESendOptionsDialog *sod, ECalComponent *com struct icaltimetype temp; gchar *str; - icaltimezone *zone = calendar_config_get_icaltimezone (); temp = icaltime_from_timet_with_zone (gopts->delay_until, FALSE, zone); str = icaltime_as_ical_string_r (temp); diff --git a/calendar/gui/dialogs/e-send-options-utils.h b/calendar/gui/dialogs/e-send-options-utils.h index d6852b8f5a..c1a63a291a 100644 --- a/calendar/gui/dialogs/e-send-options-utils.h +++ b/calendar/gui/dialogs/e-send-options-utils.h @@ -29,6 +29,13 @@ #include #include -void e_send_options_utils_set_default_data (ESendOptionsDialog *sod, ESource *source, const gchar *type); -void e_send_options_utils_fill_component (ESendOptionsDialog *sod, ECalComponent *comp); +void e_send_options_utils_set_default_data + (ESendOptionsDialog *sod, + ESource *source, + const gchar *type); +void e_send_options_utils_fill_component + (ESendOptionsDialog *sod, + ECalComponent *comp, + icaltimezone *zone); + #endif diff --git a/calendar/gui/dialogs/event-editor.c b/calendar/gui/dialogs/event-editor.c index ad3c963ca6..11dbe134c0 100644 --- a/calendar/gui/dialogs/event-editor.c +++ b/calendar/gui/dialogs/event-editor.c @@ -330,7 +330,7 @@ event_editor_constructor (GType type, content_area = gtk_dialog_get_content_area (GTK_DIALOG (priv->recur_window)); - priv->recur_page = recurrence_page_new (editor); + priv->recur_page = recurrence_page_new (priv->model, editor); page = COMP_EDITOR_PAGE (priv->recur_page); if (!e_shell_get_express_mode (shell)) { gtk_container_add ( diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index 0418c7f5df..32c2c18653 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -40,7 +40,6 @@ #include "misc/e-send-options.h" #include "misc/e-buffer-tagger.h" #include -#include "../calendar-config.h" #include "../e-timezone-entry.h" #include "e-util/e-util.h" @@ -166,7 +165,7 @@ struct _EventPagePrivate { GtkWidget *attendees_label; /* ListView stuff */ - EMeetingStore *model; + EMeetingStore *meeting_store; EMeetingListView *list_view; gint row; @@ -380,7 +379,9 @@ set_all_day (EventPage *epage, gboolean all_day) } static void -update_time (EventPage *epage, ECalComponentDateTime *start_date, ECalComponentDateTime *end_date) +update_time (EventPage *epage, + ECalComponentDateTime *start_date, + ECalComponentDateTime *end_date) { EventPagePrivate *priv = epage->priv; CompEditor *editor; @@ -431,7 +432,8 @@ update_time (EventPage *epage, ECalComponentDateTime *start_date, ECalComponentD timezone, so that if the user toggles the 'All Day Event' checkbox the event uses the current timezone rather than none at all. */ if (all_day_event) - start_zone = calendar_config_get_icaltimezone (); + start_zone = e_meeting_store_get_timezone ( + epage->priv->meeting_store); g_signal_handlers_block_matched (priv->start_time, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, epage); g_signal_handlers_block_matched (priv->end_time, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, epage); @@ -457,7 +459,7 @@ update_time (EventPage *epage, ECalComponentDateTime *start_date, ECalComponentD if (start_zone) e_timezone_entry_set_timezone (E_TIMEZONE_ENTRY (priv->start_timezone), start_zone); - def_zone = calendar_config_get_icaltimezone (); + def_zone = e_meeting_store_get_timezone (epage->priv->meeting_store); if (!def_zone || !start_zone || strcmp (icaltimezone_get_tzid (def_zone), icaltimezone_get_tzid (start_zone))) homezone = FALSE; @@ -1126,7 +1128,7 @@ event_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) a = get_current_account (epage); if (a != NULL) { - priv->ia = e_meeting_store_add_attendee_with_defaults (priv->model); + priv->ia = e_meeting_store_add_attendee_with_defaults (priv->meeting_store); g_object_ref (priv->ia); if (!(backend_addr && *backend_addr) || !g_ascii_strcasecmp (backend_addr, a->id->address)) { @@ -1403,8 +1405,10 @@ event_page_fill_component (CompEditorPage *page, ECalComponent *comp) e_cal_component_set_transparency (comp, busy ? E_CAL_COMPONENT_TRANSP_OPAQUE : E_CAL_COMPONENT_TRANSP_TRANSPARENT); /* send options */ - if (priv->sendoptions_shown && priv->sod) - e_send_options_utils_fill_component (priv->sod, comp); + if (priv->sendoptions_shown && priv->sod) { + icaltimezone *zone = comp_editor_get_timezone (editor); + e_send_options_utils_fill_component (priv->sod, comp, zone); + } /* Alarm */ e_cal_component_remove_all_alarms (comp); @@ -1491,7 +1495,7 @@ event_page_fill_component (CompEditorPage *page, ECalComponent *comp) break; case ALARM_USER_TIME: - switch (calendar_config_get_default_reminder_units ()) { + switch (e_meeting_store_get_default_reminder_units (priv->meeting_store)) { case E_DURATION_DAYS: trigger.u.rel_duration.days = priv->alarm_interval; break; @@ -1559,7 +1563,7 @@ event_page_fill_component (CompEditorPage *page, ECalComponent *comp) g_free (sentby); } - if (e_meeting_store_count_actual_attendees (priv->model) < 1) { + if (e_meeting_store_count_actual_attendees (priv->meeting_store) < 1) { e_notice (priv->main, GTK_MESSAGE_ERROR, _("At least one attendee is required.")); return FALSE; @@ -1568,7 +1572,7 @@ event_page_fill_component (CompEditorPage *page, ECalComponent *comp) if (flags & COMP_EDITOR_DELEGATE) { GSList *attendee_list, *l; gint i; - const GPtrArray *attendees = e_meeting_store_get_attendees (priv->model); + const GPtrArray *attendees = e_meeting_store_get_attendees (priv->meeting_store); e_cal_component_get_attendee_list (priv->comp, &attendee_list); @@ -1595,7 +1599,7 @@ event_page_fill_component (CompEditorPage *page, ECalComponent *comp) e_cal_component_set_attendee_list (comp, attendee_list); e_cal_component_free_attendee_list (attendee_list); } else - set_attendees (comp, e_meeting_store_get_attendees (priv->model)); + set_attendees (comp, e_meeting_store_get_attendees (priv->meeting_store)); } return TRUE; @@ -1767,7 +1771,7 @@ add_clicked_cb (GtkButton *btn, EventPage *epage) editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage)); flags = comp_editor_get_flags (editor); - attendee = e_meeting_store_add_attendee_with_defaults (epage->priv->model); + attendee = e_meeting_store_add_attendee_with_defaults (epage->priv->meeting_store); if (flags & COMP_EDITOR_DELEGATE) { e_meeting_attendee_set_delfrom (attendee, g_strdup_printf ("MAILTO:%s", epage->priv->user_add)); @@ -1837,7 +1841,7 @@ remove_attendee (EventPage *epage, EMeetingAttendee *ia) if (e_meeting_attendee_is_set_delfrom (ia)) { EMeetingAttendee *ib; - ib = e_meeting_store_find_attendee (priv->model, e_meeting_attendee_get_delfrom (ia), &pos); + ib = e_meeting_store_find_attendee (priv->meeting_store, e_meeting_attendee_get_delfrom (ia), &pos); if (ib != NULL) { e_meeting_attendee_set_delto (ib, NULL); @@ -1857,11 +1861,11 @@ remove_attendee (EventPage *epage, EMeetingAttendee *ia) } if (e_meeting_attendee_get_delto (ia) != NULL) - ib = e_meeting_store_find_attendee (priv->model, e_meeting_attendee_get_delto (ia), NULL); + ib = e_meeting_store_find_attendee (priv->meeting_store, e_meeting_attendee_get_delto (ia), NULL); comp_editor_manage_new_attendees (priv->comp, ia, FALSE); e_meeting_list_view_remove_attendee_from_name_selector (priv->list_view, ia); - e_meeting_store_remove_attendee (priv->model, ia); + e_meeting_store_remove_attendee (priv->meeting_store, ia); ia = ib; } @@ -1885,7 +1889,7 @@ remove_clicked_cb (GtkButton *btn, EventPage *epage) priv = epage->priv; selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->list_view)); - model = GTK_TREE_MODEL (priv->model); + model = GTK_TREE_MODEL (priv->meeting_store); if (!(paths = gtk_tree_selection_get_selected_rows (selection, &model ))) { g_warning ("Could not get a selection to delete."); return; @@ -1895,10 +1899,10 @@ remove_clicked_cb (GtkButton *btn, EventPage *epage) for (tmp = paths; tmp; tmp=tmp->next) { path = tmp->data; - gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->model), &iter, path); + gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->meeting_store), &iter, path); - gtk_tree_model_get (GTK_TREE_MODEL (priv->model), &iter, E_MEETING_STORE_ADDRESS_COL, &address, -1); - ia = e_meeting_store_find_attendee (priv->model, address, NULL); + gtk_tree_model_get (GTK_TREE_MODEL (priv->meeting_store), &iter, E_MEETING_STORE_ADDRESS_COL, &address, -1); + ia = e_meeting_store_find_attendee (priv->meeting_store, address, NULL); g_free (address); if (!ia) { g_warning ("Cannot delete attendee\n"); @@ -1912,10 +1916,10 @@ remove_clicked_cb (GtkButton *btn, EventPage *epage) } /* Select closest item after removal */ - valid_iter = gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->model), &iter, path); + valid_iter = gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->meeting_store), &iter, path); if (!valid_iter) { gtk_tree_path_prev (path); - valid_iter = gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->model), &iter, path); + valid_iter = gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->meeting_store), &iter, path); } if (valid_iter) { @@ -1963,7 +1967,7 @@ attendee_added_cb (EMeetingListView *emlv, gtk_widget_set_sensitive (priv->add, FALSE); gtk_widget_set_sensitive (priv->edit, FALSE); - delegator = e_meeting_store_find_attendee (priv->model, priv->user_add, NULL); + delegator = e_meeting_store_find_attendee (priv->meeting_store, priv->user_add, NULL); g_return_if_fail (delegator != NULL); e_meeting_attendee_set_delto (delegator, g_strdup (e_meeting_attendee_get_address (ia))); @@ -1983,7 +1987,7 @@ list_view_event (EMeetingListView *list_view, GdkEvent *event, EventPage *epage) if (event->type == GDK_2BUTTON_PRESS && flags & COMP_EDITOR_USER_ORG) { EMeetingAttendee *attendee; - attendee = e_meeting_store_add_attendee_with_defaults (priv->model); + attendee = e_meeting_store_add_attendee_with_defaults (priv->meeting_store); if (flags & COMP_EDITOR_DELEGATE) { e_meeting_attendee_set_delfrom (attendee, g_strdup_printf ("MAILTO:%s", epage->priv->user_add)); @@ -2081,8 +2085,10 @@ event_page_set_all_day_event (EventPage *epage, gboolean all_day) /* The event is within one day, so we set the event start to the start of the working day, and the end to one hour later. */ - start_tt.hour = calendar_config_get_day_start_hour (); - start_tt.minute = calendar_config_get_day_start_minute (); + start_tt.hour = + comp_editor_get_work_day_start_hour (editor); + start_tt.minute = + comp_editor_get_work_day_start_minute (editor); start_tt.second = 0; end_tt = start_tt; @@ -2271,7 +2277,7 @@ get_widgets (EventPage *epage) priv->attendee_box = GW ("attendee-box"); priv->org_cal_label = GW ("org-cal-label"); - priv->list_view = e_meeting_list_view_new (priv->model); + priv->list_view = e_meeting_list_view_new (priv->meeting_store); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); @@ -2630,7 +2636,7 @@ source_changed_cb (ESourceComboBox *source_combo_box, EventPage *epage) if (client) { icaltimezone *zone; - zone = calendar_config_get_icaltimezone (); + zone = e_meeting_store_get_timezone (epage->priv->meeting_store); e_cal_set_default_timezone (client, zone, NULL); } @@ -2743,7 +2749,7 @@ alarm_changed_cb (GtkWidget *widget, case ALARM_USER_TIME: e_alarm_list_clear (priv->alarm_list_store); - switch (calendar_config_get_default_reminder_units ()) { + switch (e_meeting_store_get_default_reminder_units (priv->meeting_store)) { case E_DURATION_DAYS: trigger.u.rel_duration.days = priv->alarm_interval; break; @@ -2859,12 +2865,16 @@ init_widgets (EventPage *epage) /* Make sure the EDateEdit widgets use our timezones to get the current time. */ - e_date_edit_set_get_time_callback (E_DATE_EDIT (priv->start_time), - (EDateEditGetTimeCallback) comp_editor_get_current_time, - epage, NULL); - e_date_edit_set_get_time_callback (E_DATE_EDIT (priv->end_time), - (EDateEditGetTimeCallback) comp_editor_get_current_time, - epage, NULL); + e_date_edit_set_get_time_callback ( + E_DATE_EDIT (priv->start_time), + (EDateEditGetTimeCallback) comp_editor_get_current_time, + g_object_ref (editor), + (GDestroyNotify) g_object_unref); + e_date_edit_set_get_time_callback ( + E_DATE_EDIT (priv->end_time), + (EDateEditGetTimeCallback) comp_editor_get_current_time, + g_object_ref (editor), + (GDestroyNotify) g_object_unref); /* Generic informative messages */ gtk_widget_hide (priv->info_hbox); @@ -2987,8 +2997,12 @@ init_widgets (EventPage *epage) g_signal_connect (priv->minute_selector, "value-changed", G_CALLBACK (minute_sel_changed), epage); /* Add the user defined time if necessary */ - priv->alarm_units = calendar_config_get_default_reminder_units (); - priv->alarm_interval = calendar_config_get_default_reminder_interval (); + priv->alarm_units = + e_meeting_store_get_default_reminder_units ( + priv->meeting_store); + priv->alarm_interval = + e_meeting_store_get_default_reminder_interval ( + priv->meeting_store); combo_label = NULL; switch (priv->alarm_units) { @@ -3057,7 +3071,7 @@ init_widgets (EventPage *epage) G_CALLBACK (comp_editor_page_changed), epage); /* Set the default timezone, so the timezone entry may be hidden. */ - zone = calendar_config_get_icaltimezone (); + zone = e_meeting_store_get_timezone (priv->meeting_store); e_timezone_entry_set_default_timezone (E_TIMEZONE_ENTRY (priv->start_timezone), zone); e_timezone_entry_set_default_timezone (E_TIMEZONE_ENTRY (priv->end_timezone), zone); @@ -3137,15 +3151,15 @@ event_page_select_organizer (EventPage *epage, const gchar *backend_address) * created. **/ EventPage * -event_page_construct (EventPage *epage, EMeetingStore *model) +event_page_construct (EventPage *epage, + EMeetingStore *meeting_store) { EventPagePrivate *priv; EIterator *it; EAccount *a; priv = epage->priv; - g_object_ref (model); - priv->model = model; + priv->meeting_store = g_object_ref (meeting_store); /* Make sure our custom widget classes are registered with * GType before we load the GtkBuilder definition file. */ @@ -3210,12 +3224,13 @@ event_page_construct (EventPage *epage, EMeetingStore *model) * not be created. **/ EventPage * -event_page_new (EMeetingStore *model, CompEditor *editor) +event_page_new (EMeetingStore *meeting_store, + CompEditor *editor) { EventPage *epage; epage = g_object_new (TYPE_EVENT_PAGE, "editor", editor, NULL); - if (!event_page_construct (epage, model)) { + if (!event_page_construct (epage, meeting_store)) { g_object_unref (epage); g_return_val_if_reached (NULL); } @@ -3298,7 +3313,7 @@ event_page_add_attendee (EventPage *epage, EMeetingAttendee *attendee) e_meeting_attendee_set_delfrom (attendee, g_strdup_printf ("MAILTO:%s", epage->priv->user_add)); } - e_meeting_store_add_attendee (priv->model, attendee); + e_meeting_store_add_attendee (priv->meeting_store, attendee); e_meeting_list_view_add_attendee_to_name_selector (E_MEETING_LIST_VIEW (priv->list_view), attendee); } @@ -3317,7 +3332,7 @@ event_page_remove_all_attendees (EventPage *epage) priv = epage->priv; - e_meeting_store_remove_all_attendees (priv->model); + e_meeting_store_remove_all_attendees (priv->meeting_store); e_meeting_list_view_remove_all_attendees_from_name_selector (E_MEETING_LIST_VIEW (priv->list_view)); } diff --git a/calendar/gui/dialogs/event-page.h b/calendar/gui/dialogs/event-page.h index 3cfff34b89..04665eb9de 100644 --- a/calendar/gui/dialogs/event-page.h +++ b/calendar/gui/dialogs/event-page.h @@ -70,8 +70,8 @@ struct _EventPageClass { GType event_page_get_type (void); EventPage * event_page_construct (EventPage *epage, - EMeetingStore *model); -EventPage * event_page_new (EMeetingStore *model, + EMeetingStore *meeting_store); +EventPage * event_page_new (EMeetingStore *meeting_store, CompEditor *editor); ECalComponent * event_page_get_cancel_comp (EventPage *page); void event_page_show_options (EventPage *page); diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c index f5ef574efd..dd8cda94fa 100644 --- a/calendar/gui/dialogs/recurrence-page.c +++ b/calendar/gui/dialogs/recurrence-page.c @@ -36,7 +36,6 @@ #include #include #include -#include "../calendar-config.h" #include "../tag-calendar.h" #include "../weekday-picker.h" #include "comp-editor-util.h" @@ -190,6 +189,9 @@ struct _RecurrencePagePrivate { /* For the recurrence preview, the actual widget */ GtkWidget *preview_calendar; + + /* This just holds some settings we need */ + EMeetingStore *meeting_store; }; @@ -324,6 +326,11 @@ recurrence_page_dispose (GObject *object) priv->exception_list_store = NULL; } + if (priv->meeting_store != NULL) { + g_object_unref (priv->meeting_store); + priv->meeting_store = NULL; + } + /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (recurrence_page_parent_class)->dispose (object); } @@ -436,7 +443,7 @@ clear_widgets (RecurrencePage *rpage) g_signal_handlers_unblock_matched (priv->interval_unit_combo, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); priv->ending_date_tt = icaltime_today (); - priv->ending_count = calendar_config_get_default_count (); + priv->ending_count = 2; g_signal_handlers_block_matched (priv->ending_combo, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); e_dialog_combo_box_set (priv->ending_combo, @@ -672,7 +679,7 @@ simple_recur_to_comp (RecurrencePage *rpage, ECalComponent *comp) r.interval = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON (priv->interval_value)); r.week_start = ICAL_SUNDAY_WEEKDAY - + calendar_config_get_week_start_day (); + + e_meeting_store_get_week_start_day (priv->meeting_store); /* Frequency-specific data */ @@ -947,6 +954,7 @@ make_weekly_special (RecurrencePage *rpage) GtkWidget *hbox; GtkWidget *label; WeekdayPicker *wp; + gint week_start_day; priv = rpage->priv; @@ -972,7 +980,8 @@ make_weekly_special (RecurrencePage *rpage) /* Set the weekdays */ - weekday_picker_set_week_start_day (wp, calendar_config_get_week_start_day ()); + week_start_day = e_meeting_store_get_week_start_day (priv->meeting_store); + weekday_picker_set_week_start_day (wp, week_start_day); weekday_picker_set_days (wp, priv->weekday_day_mask); g_signal_connect_swapped ( @@ -1381,9 +1390,11 @@ make_ending_until_special (RecurrencePage *rpage) /* Make sure the EDateEdit widget uses our timezones to get the current time. */ - e_date_edit_set_get_time_callback (de, - (EDateEditGetTimeCallback) comp_editor_get_current_time, - rpage, NULL); + e_date_edit_set_get_time_callback ( + de, + (EDateEditGetTimeCallback) comp_editor_get_current_time, + g_object_ref (editor), + (GDestroyNotify) g_object_unref); } /* Creates the special contents for the occurrence count case */ @@ -1504,7 +1515,7 @@ fill_ending_date (RecurrencePage *rpage, struct icalrecurrencetype *r) e_cal_component_get_dtstart (priv->comp, &dt); if (dt.value->is_date) - to_zone = calendar_config_get_icaltimezone (); + to_zone = e_meeting_store_get_timezone (priv->meeting_store); else if (dt.tzid == NULL) to_zone = icaltimezone_get_utc_timezone (); else @@ -2282,9 +2293,11 @@ init_widgets (RecurrencePage *rpage) priv->preview_calendar); gtk_widget_show (priv->preview_calendar); - e_calendar_item_set_get_time_callback (ecal->calitem, - (ECalendarItemGetTimeCallback) comp_editor_get_current_time, - rpage, NULL); + e_calendar_item_set_get_time_callback ( + ecal->calitem, + (ECalendarItemGetTimeCallback) comp_editor_get_current_time, + g_object_ref (editor), + (GDestroyNotify) g_object_unref); /* Recurrence types */ @@ -2334,6 +2347,11 @@ init_widgets (RecurrencePage *rpage) gtk_tree_view_set_model (GTK_TREE_VIEW (priv->exception_list), GTK_TREE_MODEL (priv->exception_list_store)); + g_object_bind_property ( + editor, "use-24-hour-format", + priv->exception_list_store, "use-24-hour-format", + G_BINDING_SYNC_CREATE); + /* View */ column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("Date/Time")); @@ -2356,11 +2374,15 @@ init_widgets (RecurrencePage *rpage) * created. **/ RecurrencePage * -recurrence_page_construct (RecurrencePage *rpage) +recurrence_page_construct (RecurrencePage *rpage, + EMeetingStore *meeting_store) { - RecurrencePagePrivate *priv = rpage->priv; + RecurrencePagePrivate *priv; CompEditor *editor; + priv = rpage->priv; + priv->meeting_store = g_object_ref (meeting_store); + editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (rpage)); priv->builder = gtk_builder_new (); @@ -2390,14 +2412,16 @@ recurrence_page_construct (RecurrencePage *rpage) * be created. **/ RecurrencePage * -recurrence_page_new (CompEditor *editor) +recurrence_page_new (EMeetingStore *meeting_store, + CompEditor *editor) { RecurrencePage *rpage; + g_return_val_if_fail (E_IS_MEETING_STORE (meeting_store), NULL); g_return_val_if_fail (IS_COMP_EDITOR (editor), NULL); rpage = g_object_new (TYPE_RECURRENCE_PAGE, "editor", editor, NULL); - if (!recurrence_page_construct (rpage)) { + if (!recurrence_page_construct (rpage, meeting_store)) { g_object_unref (rpage); g_return_val_if_reached (NULL); } diff --git a/calendar/gui/dialogs/recurrence-page.h b/calendar/gui/dialogs/recurrence-page.h index 1dce00d2c9..709b5ae14b 100644 --- a/calendar/gui/dialogs/recurrence-page.h +++ b/calendar/gui/dialogs/recurrence-page.h @@ -32,6 +32,7 @@ #include "comp-editor.h" #include "comp-editor-page.h" +#include "../e-meeting-store.h" /* Standard GObject macros */ #define TYPE_RECURRENCE_PAGE \ @@ -68,8 +69,10 @@ struct _RecurrencePageClass { }; GType recurrence_page_get_type (void); -RecurrencePage *recurrence_page_construct (RecurrencePage *rpage); -RecurrencePage *recurrence_page_new (CompEditor *editor); +RecurrencePage *recurrence_page_construct (RecurrencePage *rpage, + EMeetingStore *meeting_store); +RecurrencePage *recurrence_page_new (EMeetingStore *meeting_store, + CompEditor *editor); G_END_DECLS diff --git a/calendar/gui/dialogs/schedule-page.c b/calendar/gui/dialogs/schedule-page.c index efc6795834..4d234880b4 100644 --- a/calendar/gui/dialogs/schedule-page.c +++ b/calendar/gui/dialogs/schedule-page.c @@ -34,7 +34,6 @@ #include #include #include -#include "../calendar-config.h" #include "../e-meeting-time-sel.h" #include "../itip-utils.h" #include "comp-editor-util.h" @@ -385,11 +384,12 @@ schedule_page_construct (SchedulePage *spage, EMeetingStore *ems) /* Selector */ priv->sel = E_MEETING_TIME_SELECTOR (e_meeting_time_selector_new (ems)); gtk_widget_set_size_request ((GtkWidget *) priv->sel, -1, 400); - e_meeting_time_selector_set_working_hours (priv->sel, - calendar_config_get_day_start_hour (), - calendar_config_get_day_start_minute (), - calendar_config_get_day_end_hour (), - calendar_config_get_day_end_minute ()); + e_meeting_time_selector_set_working_hours ( + priv->sel, + comp_editor_get_work_day_start_hour (editor), + comp_editor_get_work_day_start_minute (editor), + comp_editor_get_work_day_end_hour (editor), + comp_editor_get_work_day_end_minute (editor)); gtk_widget_show (GTK_WIDGET (priv->sel)); gtk_box_pack_start (GTK_BOX (priv->main), GTK_WIDGET (priv->sel), TRUE, TRUE, 6); diff --git a/calendar/gui/dialogs/task-details-page.c b/calendar/gui/dialogs/task-details-page.c index ec63458d81..43f38a20a5 100644 --- a/calendar/gui/dialogs/task-details-page.c +++ b/calendar/gui/dialogs/task-details-page.c @@ -33,7 +33,6 @@ #include #include #include -#include "../calendar-config.h" #include "../e-timezone-entry.h" #include "comp-editor-util.h" #include "task-details-page.h" @@ -227,12 +226,15 @@ task_details_page_fill_widgets (CompEditorPage *page, gint *priority_value, *percent = NULL; TaskEditorPriority priority; icalproperty_status status; + CompEditor *editor; const gchar *url; struct icaltimetype *completed = NULL; tdpage = TASK_DETAILS_PAGE (page); priv = tdpage->priv; + editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tdpage)); + /* Clean the screen */ clear_widgets (tdpage); @@ -274,7 +276,7 @@ task_details_page_fill_widgets (CompEditorPage *page, /* Completed is in UTC, but that would confuse the user, so we convert it to local time. */ utc_zone = icaltimezone_get_utc_timezone (); - zone = calendar_config_get_icaltimezone (); + zone = comp_editor_get_timezone (editor); icaltimezone_convert_time (completed, utc_zone, zone); @@ -316,14 +318,18 @@ task_details_page_fill_component (CompEditorPage *page, struct icaltimetype icalcomplete, icaltoday; icalproperty_status status; TaskEditorPriority priority; + CompEditor *editor; gint priority_value, percent; gchar *url; gboolean date_set; - icaltimezone *zone = calendar_config_get_icaltimezone (); + icaltimezone *zone; tdpage = TASK_DETAILS_PAGE (page); priv = tdpage->priv; + editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tdpage)); + zone = comp_editor_get_timezone (editor); + /* Percent Complete. */ percent = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON (priv->percent_complete)); @@ -661,14 +667,19 @@ init_widgets (TaskDetailsPage *tdpage) { TaskDetailsPagePrivate *priv; GtkAdjustment *adjustment; + CompEditor *editor; priv = tdpage->priv; + editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tdpage)); + /* Make sure the EDateEdit widgets use our timezones to get the current time. */ - e_date_edit_set_get_time_callback (E_DATE_EDIT (priv->completed_date), - (EDateEditGetTimeCallback) comp_editor_get_current_time, - tdpage, NULL); + e_date_edit_set_get_time_callback ( + E_DATE_EDIT (priv->completed_date), + (EDateEditGetTimeCallback) comp_editor_get_current_time, + g_object_ref (editor), + (GDestroyNotify) g_object_unref); /* These are created by hand, so hook the mnemonics manually */ gtk_label_set_mnemonic_widget ( diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c index 68fa61c36e..9b2df7d546 100644 --- a/calendar/gui/dialogs/task-page.c +++ b/calendar/gui/dialogs/task-page.c @@ -40,7 +40,6 @@ #include #include "common/authentication.h" #include "../e-timezone-entry.h" -#include "../calendar-config.h" #include "comp-editor.h" #include "comp-editor-util.h" #include "e-send-options-utils.h" @@ -588,7 +587,7 @@ task_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) e_cal_component_free_text_list (l); e_buffer_tagger_update_tags (GTK_TEXT_VIEW (priv->description)); - default_zone = calendar_config_get_icaltimezone (); + default_zone = comp_editor_get_timezone (editor); /* Due Date. */ e_cal_component_get_due (comp, &d); @@ -938,8 +937,10 @@ task_page_fill_component (CompEditorPage *page, ECalComponent *comp) e_cal_component_set_classification (comp, classification); /* send options */ - if (priv->sendoptions_shown && priv->sod) - e_send_options_utils_fill_component (priv->sod, comp); + if (priv->sendoptions_shown && priv->sod) { + icaltimezone *zone = comp_editor_get_timezone (editor); + e_send_options_utils_fill_component (priv->sod, comp, zone); + } /* Categories */ cat = e_dialog_editable_get (priv->categories); @@ -1726,7 +1727,7 @@ source_changed_cb (ESourceComboBox *source_combo_box, TaskPage *tpage) if (client) { icaltimezone *zone; - zone = calendar_config_get_icaltimezone (); + zone = comp_editor_get_timezone (editor); e_cal_set_default_timezone (client, zone, NULL); } @@ -1842,12 +1843,16 @@ init_widgets (TaskPage *tpage) /* Make sure the EDateEdit widgets use our timezones to get the current time. */ - e_date_edit_set_get_time_callback (E_DATE_EDIT (priv->start_date), - (EDateEditGetTimeCallback) comp_editor_get_current_time, - tpage, NULL); - e_date_edit_set_get_time_callback (E_DATE_EDIT (priv->due_date), - (EDateEditGetTimeCallback) comp_editor_get_current_time, - tpage, NULL); + e_date_edit_set_get_time_callback ( + E_DATE_EDIT (priv->start_date), + (EDateEditGetTimeCallback) comp_editor_get_current_time, + g_object_ref (editor), + (GDestroyNotify) g_object_unref); + e_date_edit_set_get_time_callback ( + E_DATE_EDIT (priv->due_date), + (EDateEditGetTimeCallback) comp_editor_get_current_time, + g_object_ref (editor), + (GDestroyNotify) g_object_unref); /* Generic informative messages */ gtk_widget_hide (priv->info_hbox); @@ -1931,7 +1936,7 @@ init_widgets (TaskPage *tpage) g_signal_connect (priv->list_view, "attendee_added", G_CALLBACK (attendee_added_cb), tpage); /* Set the default timezone, so the timezone entry may be hidden. */ - zone = calendar_config_get_icaltimezone (); + zone = comp_editor_get_timezone (editor); e_timezone_entry_set_default_timezone (E_TIMEZONE_ENTRY (priv->timezone), zone); action = comp_editor_get_action (editor, "view-time-zone"); diff --git a/calendar/gui/e-cal-component-preview.c b/calendar/gui/e-cal-component-preview.c index da7e853863..dc23153997 100644 --- a/calendar/gui/e-cal-component-preview.c +++ b/calendar/gui/e-cal-component-preview.c @@ -33,15 +33,12 @@ #include #include #include -#include "calendar-config.h" #define E_CAL_COMPONENT_PREVIEW_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ ((obj), E_TYPE_CAL_COMPONENT_PREVIEW, ECalComponentPreviewPrivate)) struct _ECalComponentPreviewPrivate { - icaltimezone *zone; - /* information about currently showing component in a preview; if it didn't change then the preview is not updated */ gchar *cal_uid; @@ -132,7 +129,8 @@ update_comp_info (ECalComponentPreview *preview, static gchar * timet_to_str_with_zone (ECalComponentDateTime *dt, ECal *ecal, - icaltimezone *default_zone) + icaltimezone *default_zone, + gboolean use_24_hour_format) { struct icaltimetype itt; icaltimezone *zone; @@ -154,8 +152,9 @@ timet_to_str_with_zone (ECalComponentDateTime *dt, icaltimezone_convert_time (&itt, zone, default_zone); tm = icaltimetype_to_tm (&itt); - e_time_format_date_and_time (&tm, calendar_config_get_24_hour_format (), - FALSE, FALSE, buf, sizeof (buf)); + e_time_format_date_and_time ( + &tm, use_24_hour_format, + FALSE, FALSE, buf, sizeof (buf)); return g_locale_to_utf8 (buf, -1, NULL, NULL, NULL); } @@ -164,7 +163,8 @@ static void cal_component_preview_write_html (GString *buffer, ECal *ecal, ECalComponent *comp, - icaltimezone *default_zone) + icaltimezone *default_zone, + gboolean use_24_hour_format) { ECalComponentText text; ECalComponentDateTime dt; @@ -239,7 +239,8 @@ cal_component_preview_write_html (GString *buffer, /* write start date */ e_cal_component_get_dtstart (comp, &dt); if (dt.value != NULL) { - str = timet_to_str_with_zone (&dt, ecal, default_zone); + str = timet_to_str_with_zone ( + &dt, ecal, default_zone, use_24_hour_format); g_string_append_printf ( buffer, "" "%s%s", @@ -252,7 +253,8 @@ cal_component_preview_write_html (GString *buffer, /* write end date */ e_cal_component_get_dtend (comp, &dt); if (dt.value != NULL) { - str = timet_to_str_with_zone (&dt, ecal, default_zone); + str = timet_to_str_with_zone ( + &dt, ecal, default_zone, use_24_hour_format); g_string_append_printf ( buffer, "" "%s%s", @@ -265,7 +267,8 @@ cal_component_preview_write_html (GString *buffer, /* write Due Date */ e_cal_component_get_due (comp, &dt); if (dt.value != NULL) { - str = timet_to_str_with_zone (&dt, ecal, default_zone); + str = timet_to_str_with_zone ( + &dt, ecal, default_zone, use_24_hour_format); g_string_append_printf ( buffer, "" "%s%s", @@ -402,8 +405,6 @@ static void cal_component_preview_init (ECalComponentPreview *preview) { preview->priv = E_CAL_COMPONENT_PREVIEW_GET_PRIVATE (preview); - - preview->priv->zone = icaltimezone_get_utc_timezone (); } GType @@ -439,28 +440,12 @@ e_cal_component_preview_new (void) return g_object_new (E_TYPE_CAL_COMPONENT_PREVIEW, NULL); } -icaltimezone * -e_cal_component_preview_get_default_timezone (ECalComponentPreview *preview) -{ - g_return_val_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview), NULL); - - return preview->priv->zone; -} - -void -e_cal_component_preview_set_default_timezone (ECalComponentPreview *preview, - icaltimezone *zone) -{ - g_return_if_fail (E_IS_CAL_COMPONENT_PREVIEW (preview)); - g_return_if_fail (zone != NULL); - - preview->priv->zone = zone; -} - void e_cal_component_preview_display (ECalComponentPreview *preview, ECal *ecal, - ECalComponent *comp) + ECalComponent *comp, + icaltimezone *zone, + gboolean use_24_hour_format) { GString *buffer; @@ -476,7 +461,7 @@ e_cal_component_preview_display (ECalComponentPreview *preview, buffer = g_string_sized_new (4096); cal_component_preview_write_html ( - buffer, ecal, comp, preview->priv->zone); + buffer, ecal, comp, zone, use_24_hour_format); e_web_view_load_string (E_WEB_VIEW (preview), buffer->str); g_string_free (buffer, TRUE); } diff --git a/calendar/gui/e-cal-component-preview.h b/calendar/gui/e-cal-component-preview.h index 89888afde0..f713df7321 100644 --- a/calendar/gui/e-cal-component-preview.h +++ b/calendar/gui/e-cal-component-preview.h @@ -62,19 +62,17 @@ struct _ECalComponentPreviewClass { EWebViewClass parent_class; /* Notification signals */ - void (* selection_changed) (ECalComponentPreview *preview, gint n_selected); + void (*selection_changed) (ECalComponentPreview *preview, + gint n_selected); }; GType e_cal_component_preview_get_type (void); GtkWidget * e_cal_component_preview_new (void); -icaltimezone * e_cal_component_preview_get_default_timezone - (ECalComponentPreview *preview); -void e_cal_component_preview_set_default_timezone - (ECalComponentPreview *preview, - icaltimezone *zone); void e_cal_component_preview_display (ECalComponentPreview *preview, ECal *ecal, - ECalComponent *comp); + ECalComponent *comp, + icaltimezone *zone, + gboolean use_24_hour_format); void e_cal_component_preview_clear (ECalComponentPreview *preview); G_END_DECLS diff --git a/calendar/gui/e-cal-config.c b/calendar/gui/e-cal-config.c index 0454706fec..10dc316ffa 100644 --- a/calendar/gui/e-cal-config.c +++ b/calendar/gui/e-cal-config.c @@ -56,7 +56,6 @@ ecp_target_free (EConfig *ec, EConfigTarget *t) } break; } case EC_CONFIG_TARGET_PREFS: { - /* ECalConfigTargetPrefs *s = (ECalConfigTargetPrefs *)t; */ break; } } } @@ -155,13 +154,11 @@ e_cal_config_target_new_source (ECalConfig *ecp, struct _ESource *source) } ECalConfigTargetPrefs * -e_cal_config_target_new_prefs (ECalConfig *ecp, struct _GConfClient *gconf) +e_cal_config_target_new_prefs (ECalConfig *ecp) { ECalConfigTargetPrefs *t = e_config_target_new (&ecp->config, EC_CONFIG_TARGET_PREFS, sizeof (*t)); - t->gconf = gconf; - if (gconf) - g_object_ref (gconf); + t->gconf = gconf_client_get_default (); return t; } diff --git a/calendar/gui/e-cal-config.h b/calendar/gui/e-cal-config.h index 30e12bbf0c..68dca3e3aa 100644 --- a/calendar/gui/e-cal-config.h +++ b/calendar/gui/e-cal-config.h @@ -69,7 +69,7 @@ GType e_cal_config_get_type (void); ECalConfig *e_cal_config_new (gint type, const gchar *menuid); ECalConfigTargetSource *e_cal_config_target_new_source (ECalConfig *ecp, struct _ESource *source); -ECalConfigTargetPrefs *e_cal_config_target_new_prefs (ECalConfig *ecp, struct _GConfClient *gconf); +ECalConfigTargetPrefs *e_cal_config_target_new_prefs (ECalConfig *ecp); G_END_DECLS diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c index ddea112fb9..294b54c760 100644 --- a/calendar/gui/e-cal-model.c +++ b/calendar/gui/e-cal-model.c @@ -36,8 +36,9 @@ #include "e-cal-model.h" #include "itip-utils.h" #include "misc.h" -#include "e-util/e-extensible.h" #include "e-util/e-util.h" +#include "e-util/e-extensible.h" +#include "e-util/e-util-enumtypes.h" #define E_CAL_MODEL_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -87,13 +88,30 @@ struct _ECalModelPrivate { /* Whether we display dates in 24-hour format. */ gboolean use_24_hour_format; + /* Whether to compress weekends into one cell. */ + gboolean compress_weekend; + /* First day of the week: 0 (Monday) to 6 (Sunday) */ gint week_start_day; + /* Work day timespan */ + gint work_day_start_hour; + gint work_day_start_minute; + gint work_day_end_hour; + gint work_day_end_minute; + /* callback, to retrieve start time for newly added rows by click-to-add */ ECalModelDefaultTimeFunc get_default_time; gpointer get_default_time_user_data; + /* Default reminder for events */ + gboolean use_default_reminder; + gint default_reminder_interval; + EDurationType default_reminder_units; + + /* Ask user to confirm before deleting components. */ + gboolean confirm_delete; + gboolean in_added; gboolean in_modified; gboolean in_removed; @@ -126,10 +144,19 @@ static void remove_client (ECalModel *model, ECalModelClient *client_data); enum { PROP_0, + PROP_COMPRESS_WEEKEND, + PROP_CONFIRM_DELETE, PROP_DEFAULT_CLIENT, + PROP_DEFAULT_REMINDER_INTERVAL, + PROP_DEFAULT_REMINDER_UNITS, PROP_TIMEZONE, PROP_USE_24_HOUR_FORMAT, - PROP_WEEK_START_DAY + PROP_USE_DEFAULT_REMINDER, + PROP_WEEK_START_DAY, + PROP_WORK_DAY_END_HOUR, + PROP_WORK_DAY_END_MINUTE, + PROP_WORK_DAY_START_HOUR, + PROP_WORK_DAY_START_MINUTE }; enum { @@ -160,12 +187,36 @@ cal_model_set_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_COMPRESS_WEEKEND: + e_cal_model_set_compress_weekend ( + E_CAL_MODEL (object), + g_value_get_boolean (value)); + return; + + case PROP_CONFIRM_DELETE: + e_cal_model_set_confirm_delete ( + E_CAL_MODEL (object), + g_value_get_boolean (value)); + return; + case PROP_DEFAULT_CLIENT: e_cal_model_set_default_client ( E_CAL_MODEL (object), g_value_get_object (value)); return; + case PROP_DEFAULT_REMINDER_INTERVAL: + e_cal_model_set_default_reminder_interval ( + E_CAL_MODEL (object), + g_value_get_int (value)); + return; + + case PROP_DEFAULT_REMINDER_UNITS: + e_cal_model_set_default_reminder_units ( + E_CAL_MODEL (object), + g_value_get_enum (value)); + return; + case PROP_TIMEZONE: e_cal_model_set_timezone ( E_CAL_MODEL (object), @@ -178,11 +229,41 @@ cal_model_set_property (GObject *object, g_value_get_boolean (value)); return; + case PROP_USE_DEFAULT_REMINDER: + e_cal_model_set_use_default_reminder ( + E_CAL_MODEL (object), + g_value_get_boolean (value)); + return; + case PROP_WEEK_START_DAY: e_cal_model_set_week_start_day ( E_CAL_MODEL (object), g_value_get_int (value)); return; + + case PROP_WORK_DAY_END_HOUR: + e_cal_model_set_work_day_end_hour ( + E_CAL_MODEL (object), + g_value_get_int (value)); + return; + + case PROP_WORK_DAY_END_MINUTE: + e_cal_model_set_work_day_end_minute ( + E_CAL_MODEL (object), + g_value_get_int (value)); + return; + + case PROP_WORK_DAY_START_HOUR: + e_cal_model_set_work_day_start_hour ( + E_CAL_MODEL (object), + g_value_get_int (value)); + return; + + case PROP_WORK_DAY_START_MINUTE: + e_cal_model_set_work_day_start_minute ( + E_CAL_MODEL (object), + g_value_get_int (value)); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -195,6 +276,20 @@ cal_model_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_COMPRESS_WEEKEND: + g_value_set_boolean ( + value, + e_cal_model_get_compress_weekend ( + E_CAL_MODEL (object))); + return; + + case PROP_CONFIRM_DELETE: + g_value_set_boolean ( + value, + e_cal_model_get_confirm_delete ( + E_CAL_MODEL (object))); + return; + case PROP_DEFAULT_CLIENT: g_value_set_object ( value, @@ -202,6 +297,20 @@ cal_model_get_property (GObject *object, E_CAL_MODEL (object))); return; + case PROP_DEFAULT_REMINDER_INTERVAL: + g_value_set_int ( + value, + e_cal_model_get_default_reminder_interval ( + E_CAL_MODEL (object))); + return; + + case PROP_DEFAULT_REMINDER_UNITS: + g_value_set_enum ( + value, + e_cal_model_get_default_reminder_units ( + E_CAL_MODEL (object))); + return; + case PROP_TIMEZONE: g_value_set_pointer ( value, @@ -216,12 +325,47 @@ cal_model_get_property (GObject *object, E_CAL_MODEL (object))); return; + case PROP_USE_DEFAULT_REMINDER: + g_value_set_boolean ( + value, + e_cal_model_get_use_default_reminder ( + E_CAL_MODEL (object))); + return; + case PROP_WEEK_START_DAY: g_value_set_int ( value, e_cal_model_get_week_start_day ( E_CAL_MODEL (object))); return; + + case PROP_WORK_DAY_END_HOUR: + g_value_set_int ( + value, + e_cal_model_get_work_day_end_hour ( + E_CAL_MODEL (object))); + return; + + case PROP_WORK_DAY_END_MINUTE: + g_value_set_int ( + value, + e_cal_model_get_work_day_end_minute ( + E_CAL_MODEL (object))); + return; + + case PROP_WORK_DAY_START_HOUR: + g_value_set_int ( + value, + e_cal_model_get_work_day_start_hour ( + E_CAL_MODEL (object))); + return; + + case PROP_WORK_DAY_START_MINUTE: + g_value_set_int ( + value, + e_cal_model_get_work_day_start_minute ( + E_CAL_MODEL (object))); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -333,6 +477,26 @@ e_cal_model_class_init (ECalModelClass *class) class->get_color_for_component = ecm_get_color_for_component; class->fill_component_from_model = NULL; + g_object_class_install_property ( + object_class, + PROP_COMPRESS_WEEKEND, + g_param_spec_boolean ( + "compress-weekend", + "Compress Weekend", + NULL, + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_CONFIRM_DELETE, + g_param_spec_boolean ( + "confirm-delete", + "Confirm Delete", + NULL, + TRUE, + G_PARAM_READWRITE)); + g_object_class_install_property ( object_class, PROP_DEFAULT_CLIENT, @@ -343,6 +507,29 @@ e_cal_model_class_init (ECalModelClass *class) E_TYPE_CAL, G_PARAM_READWRITE)); + g_object_class_install_property ( + object_class, + PROP_DEFAULT_REMINDER_INTERVAL, + g_param_spec_int ( + "default-reminder-interval", + "Default Reminder Interval", + NULL, + G_MININT, + G_MAXINT, + 0, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_DEFAULT_REMINDER_UNITS, + g_param_spec_enum ( + "default-reminder-units", + "Default Reminder Units", + NULL, + E_TYPE_DURATION_TYPE, + E_DURATION_MINUTES, + G_PARAM_READWRITE)); + g_object_class_install_property ( object_class, PROP_TIMEZONE, @@ -362,6 +549,16 @@ e_cal_model_class_init (ECalModelClass *class) TRUE, G_PARAM_READWRITE)); + g_object_class_install_property ( + object_class, + PROP_USE_DEFAULT_REMINDER, + g_param_spec_boolean ( + "use-default-reminder", + "Use Default Reminder", + NULL, + FALSE, + G_PARAM_READWRITE)); + g_object_class_install_property ( object_class, PROP_WEEK_START_DAY, @@ -374,6 +571,54 @@ e_cal_model_class_init (ECalModelClass *class) 0, G_PARAM_READWRITE)); + g_object_class_install_property ( + object_class, + PROP_WORK_DAY_END_HOUR, + g_param_spec_int ( + "work-day-end-hour", + "Work Day End Hour", + NULL, + 0, + 23, + 0, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_WORK_DAY_END_MINUTE, + g_param_spec_int ( + "work-day-end-minute", + "Work Day End Minute", + NULL, + 0, + 59, + 0, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_WORK_DAY_START_HOUR, + g_param_spec_int ( + "work-day-start-hour", + "Work Day Start Hour", + NULL, + 0, + 23, + 0, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_WORK_DAY_START_MINUTE, + g_param_spec_int ( + "work-day-start-minute", + "Work Day Start Minute", + NULL, + 0, + 59, + 0, + G_PARAM_READWRITE)); + signals[TIME_RANGE_CHANGED] = g_signal_new ("time_range_changed", G_TYPE_FROM_CLASS (class), @@ -1351,26 +1596,39 @@ ecm_get_color_for_component (ECalModel *model, ECalModelComponent *comp_data) return assigned_colors[first_empty].color; } +gboolean +e_cal_model_get_confirm_delete (ECalModel *model) +{ + g_return_val_if_fail (E_IS_CAL_MODEL (model), FALSE); + + return model->priv->confirm_delete; +} + +void +e_cal_model_set_confirm_delete (ECalModel *model, + gboolean confirm_delete) +{ + g_return_if_fail (E_IS_CAL_MODEL (model)); + + model->priv->confirm_delete = confirm_delete; + + g_object_notify (G_OBJECT (model), "confirm-delete"); +} + icalcomponent_kind e_cal_model_get_component_kind (ECalModel *model) { - ECalModelPrivate *priv; - g_return_val_if_fail (E_IS_CAL_MODEL (model), ICAL_NO_COMPONENT); - priv = model->priv; - return priv->kind; + return model->priv->kind; } void e_cal_model_set_component_kind (ECalModel *model, icalcomponent_kind kind) { - ECalModelPrivate *priv; - g_return_if_fail (E_IS_CAL_MODEL (model)); - priv = model->priv; - priv->kind = kind; + model->priv->kind = kind; } ECalModelFlags @@ -1420,6 +1678,25 @@ e_cal_model_set_timezone (ECalModel *model, old_zone, zone); } +gboolean +e_cal_model_get_compress_weekend (ECalModel *model) +{ + g_return_val_if_fail (E_IS_CAL_MODEL (model), FALSE); + + return model->priv->compress_weekend; +} + +void +e_cal_model_set_compress_weekend (ECalModel *model, + gboolean compress_weekend) +{ + g_return_if_fail (E_IS_CAL_MODEL (model)); + + model->priv->compress_weekend = compress_weekend; + + g_object_notify (G_OBJECT (model), "compress-weekend"); +} + void e_cal_model_set_default_category (ECalModel *model, const gchar *default_category) @@ -1430,6 +1707,44 @@ e_cal_model_set_default_category (ECalModel *model, model->priv->default_category = g_strdup (default_category); } +gint +e_cal_model_get_default_reminder_interval (ECalModel *model) +{ + g_return_val_if_fail (E_IS_CAL_MODEL (model), 0); + + return model->priv->default_reminder_interval; +} + +void +e_cal_model_set_default_reminder_interval (ECalModel *model, + gint default_reminder_interval) +{ + g_return_if_fail (E_IS_CAL_MODEL (model)); + + model->priv->default_reminder_interval = default_reminder_interval; + + g_object_notify (G_OBJECT (model), "default-reminder-interval"); +} + +EDurationType +e_cal_model_get_default_reminder_units (ECalModel *model) +{ + g_return_val_if_fail (E_IS_CAL_MODEL (model), 0); + + return model->priv->default_reminder_units; +} + +void +e_cal_model_set_default_reminder_units (ECalModel *model, + EDurationType default_reminder_units) +{ + g_return_if_fail (E_IS_CAL_MODEL (model)); + + model->priv->default_reminder_units = default_reminder_units; + + g_object_notify (G_OBJECT (model), "default-reminder-units"); +} + gboolean e_cal_model_get_use_24_hour_format (ECalModel *model) { @@ -1456,6 +1771,25 @@ e_cal_model_set_use_24_hour_format (ECalModel *model, g_object_notify (G_OBJECT (model), "use-24-hour-format"); } +gboolean +e_cal_model_get_use_default_reminder (ECalModel *model) +{ + g_return_val_if_fail (E_IS_CAL_MODEL (model), FALSE); + + return model->priv->use_default_reminder; +} + +void +e_cal_model_set_use_default_reminder (ECalModel *model, + gboolean use_default_reminder) +{ + g_return_if_fail (E_IS_CAL_MODEL (model)); + + model->priv->use_default_reminder = use_default_reminder; + + g_object_notify (G_OBJECT (model), "use-default-reminder"); +} + gint e_cal_model_get_week_start_day (ECalModel *model) { @@ -1480,6 +1814,82 @@ e_cal_model_set_week_start_day (ECalModel *model, g_object_notify (G_OBJECT (model), "week-start-day"); } +gint +e_cal_model_get_work_day_end_hour (ECalModel *model) +{ + g_return_val_if_fail (E_IS_CAL_MODEL (model), 0); + + return model->priv->work_day_end_hour; +} + +void +e_cal_model_set_work_day_end_hour (ECalModel *model, + gint work_day_end_hour) +{ + g_return_if_fail (E_IS_CAL_MODEL (model)); + + model->priv->work_day_end_hour = work_day_end_hour; + + g_object_notify (G_OBJECT (model), "work-day-end-hour"); +} + +gint +e_cal_model_get_work_day_end_minute (ECalModel *model) +{ + g_return_val_if_fail (E_IS_CAL_MODEL (model), 0); + + return model->priv->work_day_end_minute; +} + +void +e_cal_model_set_work_day_end_minute (ECalModel *model, + gint work_day_end_minute) +{ + g_return_if_fail (E_IS_CAL_MODEL (model)); + + model->priv->work_day_end_minute = work_day_end_minute; + + g_object_notify (G_OBJECT (model), "work-day-end-minute"); +} + +gint +e_cal_model_get_work_day_start_hour (ECalModel *model) +{ + g_return_val_if_fail (E_IS_CAL_MODEL (model), 0); + + return model->priv->work_day_start_hour; +} + +void +e_cal_model_set_work_day_start_hour (ECalModel *model, + gint work_day_start_hour) +{ + g_return_if_fail (E_IS_CAL_MODEL (model)); + + model->priv->work_day_start_hour = work_day_start_hour; + + g_object_notify (G_OBJECT (model), "work-day-start-hour"); +} + +gint +e_cal_model_get_work_day_start_minute (ECalModel *model) +{ + g_return_val_if_fail (E_IS_CAL_MODEL (model), 0); + + return model->priv->work_day_start_minute; +} + +void +e_cal_model_set_work_day_start_minute (ECalModel *model, + gint work_day_start_minute) +{ + g_return_if_fail (E_IS_CAL_MODEL (model)); + + model->priv->work_day_start_minute = work_day_start_minute; + + g_object_notify (G_OBJECT (model), "work-day-start-minute"); +} + ECal * e_cal_model_get_default_client (ECalModel *model) { @@ -2558,7 +2968,11 @@ e_cal_model_create_component_with_defaults (ECalModel *model, gboolean all_day) switch (priv->kind) { case ICAL_VEVENT_COMPONENT : - comp = cal_comp_event_new_with_defaults (client, all_day); + comp = cal_comp_event_new_with_defaults ( + client, all_day, + e_cal_model_get_use_default_reminder (model), + e_cal_model_get_default_reminder_interval (model), + e_cal_model_get_default_reminder_units (model)); break; case ICAL_VTODO_COMPONENT : comp = cal_comp_task_new_with_defaults (client); diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h index ec883a7df2..db744d3d32 100644 --- a/calendar/gui/e-cal-model.h +++ b/calendar/gui/e-cal-model.h @@ -26,6 +26,7 @@ #ifndef E_CAL_MODEL_H #define E_CAL_MODEL_H +#include #include #include #include "e-cell-date-edit-text.h" @@ -185,22 +186,66 @@ icalcomponent_kind e_cal_model_get_component_kind (ECalModel *model); void e_cal_model_set_component_kind (ECalModel *model, icalcomponent_kind kind); +gboolean e_cal_model_get_confirm_delete (ECalModel *model); +void e_cal_model_set_confirm_delete (ECalModel *model, + gboolean confirm_delete); ECalModelFlags e_cal_model_get_flags (ECalModel *model); void e_cal_model_set_flags (ECalModel *model, ECalModelFlags flags); icaltimezone * e_cal_model_get_timezone (ECalModel *model); void e_cal_model_set_timezone (ECalModel *model, icaltimezone *zone); -void e_cal_model_set_default_category (ECalModel *model, +gboolean e_cal_model_get_compress_weekend + (ECalModel *model); +void e_cal_model_set_compress_weekend + (ECalModel *model, + gboolean compress_weekend); +void e_cal_model_set_default_category + (ECalModel *model, const gchar *default_cat); +gint e_cal_model_get_default_reminder_interval + (ECalModel *model); +void e_cal_model_set_default_reminder_interval + (ECalModel *model, + gint def_reminder_interval); +EDurationType e_cal_model_get_default_reminder_units + (ECalModel *model); +void e_cal_model_set_default_reminder_units + (ECalModel *model, + EDurationType def_reminder_units); gboolean e_cal_model_get_use_24_hour_format (ECalModel *model); void e_cal_model_set_use_24_hour_format (ECalModel *model, gboolean use24); +gboolean e_cal_model_get_use_default_reminder + (ECalModel *model); +void e_cal_model_set_use_default_reminder + (ECalModel *model, + gboolean use_def_reminder); gint e_cal_model_get_week_start_day (ECalModel *model); void e_cal_model_set_week_start_day (ECalModel *model, gint week_start_day); +gint e_cal_model_get_work_day_end_hour + (ECalModel *model); +void e_cal_model_set_work_day_end_hour + (ECalModel *model, + gint work_day_end_hour); +gint e_cal_model_get_work_day_end_minute + (ECalModel *model); +void e_cal_model_set_work_day_end_minute + (ECalModel *model, + gint work_day_end_minute); +gint e_cal_model_get_work_day_start_hour + (ECalModel *model); +void e_cal_model_set_work_day_start_hour + (ECalModel *model, + gint work_day_start_hour); +gint e_cal_model_get_work_day_start_minute + (ECalModel *model); +void e_cal_model_set_work_day_start_minute + (ECalModel *model, + gint work_day_start_minute); ECal * e_cal_model_get_default_client (ECalModel *model); void e_cal_model_set_default_client (ECalModel *model, ECal *client); diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index 94f4579788..a9e6d68f49 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -44,7 +44,6 @@ #include #include "common/authentication.h" -#include "calendar-config.h" #include "comp-util.h" #include "ea-calendar.h" #include "e-cal-model-calendar.h" @@ -76,8 +75,8 @@ struct _ECalendarViewPrivate { /* The calendar model we are monitoring */ ECalModel *model; - /* The default category */ gchar *default_category; + gint time_divisions; GtkTargetList *copy_target_list; GtkTargetList *paste_target_list; @@ -87,7 +86,8 @@ enum { PROP_0, PROP_COPY_TARGET_LIST, PROP_MODEL, - PROP_PASTE_TARGET_LIST + PROP_PASTE_TARGET_LIST, + PROP_TIME_DIVISIONS }; /* FIXME Why are we emitting these event signals here? Can't the model just be listened to? */ @@ -168,14 +168,17 @@ static void calendar_view_delete_event (ECalendarView *cal_view, ECalendarViewEvent *event) { + ECalModel *model; ECalComponent *comp; ECalComponentVType vtype; - gboolean delete = FALSE; + gboolean delete = TRUE; GError *error = NULL; if (!is_comp_data_valid (event)) return; + model = e_calendar_view_get_model (cal_view); + comp = e_cal_component_new (); e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); vtype = e_cal_component_get_vtype (comp); @@ -214,8 +217,9 @@ calendar_view_delete_event (ECalendarView *cal_view, } } } - } else - delete = delete_component_dialog (comp, FALSE, 1, vtype, GTK_WIDGET (cal_view)); + } else if (e_cal_model_get_confirm_delete (model)) + delete = delete_component_dialog ( + comp, FALSE, 1, vtype, GTK_WIDGET (cal_view)); if (delete) { const gchar *uid; @@ -270,6 +274,12 @@ calendar_view_set_property (GObject *object, E_CALENDAR_VIEW (object), g_value_get_object (value)); return; + + case PROP_TIME_DIVISIONS: + e_calendar_view_set_time_divisions ( + E_CALENDAR_VIEW (object), + g_value_get_int (value)); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -299,6 +309,12 @@ calendar_view_get_property (GObject *object, value, e_calendar_view_get_paste_target_list ( E_CALENDAR_VIEW (object))); return; + + case PROP_TIME_DIVISIONS: + g_value_set_int ( + value, e_calendar_view_get_time_divisions ( + E_CALENDAR_VIEW (object))); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -632,7 +648,7 @@ clipboard_get_calendar_data (ECalendarView *cal_view, if (!icalcomp) return; - default_zone = calendar_config_get_icaltimezone (); + default_zone = e_cal_model_get_timezone (cal_view->priv->model); client = e_cal_model_get_default_client (cal_view->priv->model); /* check the type of the component */ @@ -800,6 +816,18 @@ e_calendar_view_class_init (ECalendarViewClass *class) PROP_PASTE_TARGET_LIST, "paste-target-list"); + g_object_class_install_property ( + object_class, + PROP_TIME_DIVISIONS, + g_param_spec_int ( + "time-divisions", + "Time Divisions", + NULL, + G_MININT, + G_MAXINT, + 30, + G_PARAM_READWRITE)); + signals[POPUP_EVENT] = g_signal_new ( "popup-event", G_TYPE_FROM_CLASS (class), @@ -895,6 +923,9 @@ e_calendar_view_init (ECalendarView *calendar_view) calendar_view->priv = E_CALENDAR_VIEW_GET_PRIVATE (calendar_view); + /* Set this early to avoid a divide-by-zero during init. */ + calendar_view->priv->time_divisions = 30; + target_list = gtk_target_list_new (NULL, 0); e_target_list_add_calendar_targets (target_list, 0); calendar_view->priv->copy_target_list = target_list; @@ -971,7 +1002,7 @@ e_calendar_view_add_event (ECalendarView *cal_view, ECal *client, time_t dtstart /* copy & paste from top canvas to main canvas */ gint time_divisions; - time_divisions = calendar_config_get_time_divisions (); + time_divisions = e_calendar_view_get_time_divisions (cal_view); ic_dur = icaldurationtype_from_int (time_divisions * 60); } @@ -1136,6 +1167,25 @@ e_calendar_view_get_paste_target_list (ECalendarView *cal_view) return cal_view->priv->paste_target_list; } +gint +e_calendar_view_get_time_divisions (ECalendarView *cal_view) +{ + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), 0); + + return cal_view->priv->time_divisions; +} + +void +e_calendar_view_set_time_divisions (ECalendarView *cal_view, + gint time_divisions) +{ + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); + + cal_view->priv->time_divisions = time_divisions; + + g_object_notify (G_OBJECT (cal_view), "time-divisions"); +} + GList * e_calendar_view_get_selected_events (ECalendarView *cal_view) { @@ -1213,12 +1263,15 @@ void e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view) { GList *selected; + ECalModel *model; ECalComponent *comp; ECalendarViewEvent *event; ECalComponentVType vtype; - gboolean delete = FALSE; + gboolean delete = TRUE; GError *error = NULL; + model = e_calendar_view_get_model (cal_view); + selected = e_calendar_view_get_selected_events (cal_view); if (!selected) return; @@ -1258,8 +1311,9 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view) } } } - } else - delete = delete_component_dialog (comp, FALSE, 1, vtype, GTK_WIDGET (cal_view)); + } else if (e_cal_model_get_confirm_delete (model)) + delete = delete_component_dialog ( + comp, FALSE, 1, vtype, GTK_WIDGET (cal_view)); if (delete) { const gchar *uid; @@ -1466,13 +1520,19 @@ e_calendar_view_new_appointment_for (ECalendarView *cal_view, * to the 'day begins' from preferences in other selected day. */ void -e_calendar_view_new_appointment_full (ECalendarView *cal_view, gboolean all_day, gboolean meeting, gboolean no_past_date) +e_calendar_view_new_appointment_full (ECalendarView *cal_view, + gboolean all_day, + gboolean meeting, + gboolean no_past_date) { + ECalModel *model; time_t dtstart, dtend, now; gboolean do_rounding = FALSE; g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); + model = e_calendar_view_get_model (cal_view); + now = time (NULL); if (!e_calendar_view_get_selected_time_range (cal_view, &dtstart, &dtend)) { @@ -1490,7 +1550,7 @@ e_calendar_view_new_appointment_full (ECalendarView *cal_view, gboolean all_day, /* time in this cases; dtstart should be a midnight in this case */ if (do_rounding || (!all_day && (dtend - dtstart) == (60 * 60 * 24))) { struct tm local = *localtime (&now); - gint time_div = calendar_config_get_time_divisions (); + gint time_div = e_calendar_view_get_time_divisions (cal_view); gint hours, mins; if (!time_div) /* Possible if your gconf values aren't so nice */ @@ -1507,8 +1567,8 @@ e_calendar_view_new_appointment_full (ECalendarView *cal_view, gboolean all_day, mins = (mins - (mins % time_div)); } else { /* other day than today */ - hours = calendar_config_get_day_start_hour (); - mins = calendar_config_get_day_start_minute (); + hours = e_cal_model_get_work_day_start_hour (model); + mins = e_cal_model_get_work_day_start_minute (model); } dtstart = dtstart + (60 * 60 * hours) + (mins * 60); diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h index 1b3759eb2d..7804eed1ca 100644 --- a/calendar/gui/e-calendar-view.h +++ b/calendar/gui/e-calendar-view.h @@ -163,6 +163,11 @@ const gchar * e_calendar_view_get_default_category void e_calendar_view_set_default_category (ECalendarView *cal_view, const gchar *category); +gint e_calendar_view_get_time_divisions + (ECalendarView *cal_view); +void e_calendar_view_set_time_divisions + (ECalendarView *cal_view, + gint time_divisions); void e_calendar_view_set_status_message (ECalendarView *cal_view, const gchar *message, diff --git a/calendar/gui/e-date-time-list.c b/calendar/gui/e-date-time-list.c index ab343a16f1..0b6afa34a6 100644 --- a/calendar/gui/e-date-time-list.c +++ b/calendar/gui/e-date-time-list.c @@ -26,133 +26,57 @@ #include #include "e-date-time-list.h" #include -#include "calendar-config.h" + +/* XXX Was it really necessary to implement a custom GtkTreeModel for a + * one-column list store? There's no mention of why this was done. */ #define G_LIST(x) ((GList *) x) #define E_DATE_TIME_LIST_IS_SORTED(list) (E_DATE_TIME_LIST (list)->sort_column_id != -2) #define IS_VALID_ITER(dt_list, iter) (iter!= NULL && iter->user_data != NULL && \ dt_list->stamp == iter->stamp) -static GType column_types[E_DATE_TIME_LIST_NUM_COLUMNS]; +enum { + PROP_0, + PROP_USE_24_HOUR_FORMAT +}; -static void e_date_time_list_init (EDateTimeList *file_list); -static void e_date_time_list_class_init (EDateTimeListClass *class); -static void e_date_time_list_tree_model_init (GtkTreeModelIface *iface); -static void e_date_time_list_finalize (GObject *object); -static GtkTreeModelFlags e_date_time_list_get_flags (GtkTreeModel *tree_model); -static gint e_date_time_list_get_n_columns (GtkTreeModel *tree_model); -static GType e_date_time_list_get_column_type (GtkTreeModel *tree_model, - gint index); -static gboolean e_date_time_list_get_iter (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreePath *path); -static GtkTreePath *e_date_time_list_get_path (GtkTreeModel *tree_model, - GtkTreeIter *iter); -static void e_date_time_list_get_value (GtkTreeModel *tree_model, - GtkTreeIter *iter, - gint column, - GValue *value); -static gboolean e_date_time_list_iter_next (GtkTreeModel *tree_model, - GtkTreeIter *iter); -static gboolean e_date_time_list_iter_children (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *parent); -static gboolean e_date_time_list_iter_has_child (GtkTreeModel *tree_model, - GtkTreeIter *iter); -static gint e_date_time_list_iter_n_children (GtkTreeModel *tree_model, - GtkTreeIter *iter); -static gboolean e_date_time_list_iter_nth_child (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *parent, - gint n); -static gboolean e_date_time_list_iter_parent (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *child); - -static GObjectClass *parent_class = NULL; - -GType -e_date_time_list_get_type (void) -{ - static GType date_time_list_type = 0; - - if (!date_time_list_type) { - static const GTypeInfo date_time_list_info = - { - sizeof (EDateTimeListClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_date_time_list_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EDateTimeList), - 0, - (GInstanceInitFunc) e_date_time_list_init, - }; - - static const GInterfaceInfo tree_model_info = - { - (GInterfaceInitFunc) e_date_time_list_tree_model_init, - NULL, - NULL - }; - - column_types[E_DATE_TIME_LIST_COLUMN_DESCRIPTION] = G_TYPE_STRING; +static GType column_types[E_DATE_TIME_LIST_NUM_COLUMNS]; - date_time_list_type = g_type_register_static (G_TYPE_OBJECT, "EDateTimeList", - &date_time_list_info, 0); - g_type_add_interface_static (date_time_list_type, - GTK_TYPE_TREE_MODEL, - &tree_model_info); - } +static void e_date_time_list_tree_model_init (GtkTreeModelIface *iface); - return date_time_list_type; -} +G_DEFINE_TYPE_WITH_CODE ( + EDateTimeList, e_date_time_list, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE ( + GTK_TYPE_TREE_MODEL, e_date_time_list_tree_model_init)) static void -e_date_time_list_class_init (EDateTimeListClass *class) +free_datetime (ECalComponentDateTime *datetime) { - GObjectClass *object_class; - - parent_class = g_type_class_peek_parent (class); - object_class = (GObjectClass*) class; - - object_class->finalize = e_date_time_list_finalize; + g_free (datetime->value); + if (datetime->tzid) + g_free ((gchar *) datetime->tzid); + g_free (datetime); } -static void -e_date_time_list_tree_model_init (GtkTreeModelIface *iface) +static ECalComponentDateTime * +copy_datetime (const ECalComponentDateTime *datetime) { - iface->get_flags = e_date_time_list_get_flags; - iface->get_n_columns = e_date_time_list_get_n_columns; - iface->get_column_type = e_date_time_list_get_column_type; - iface->get_iter = e_date_time_list_get_iter; - iface->get_path = e_date_time_list_get_path; - iface->get_value = e_date_time_list_get_value; - iface->iter_next = e_date_time_list_iter_next; - iface->iter_children = e_date_time_list_iter_children; - iface->iter_has_child = e_date_time_list_iter_has_child; - iface->iter_n_children = e_date_time_list_iter_n_children; - iface->iter_nth_child = e_date_time_list_iter_nth_child; - iface->iter_parent = e_date_time_list_iter_parent; -} + ECalComponentDateTime *datetime_copy; -static void -e_date_time_list_init (EDateTimeList *date_time_list) -{ - date_time_list->stamp = g_random_int (); - date_time_list->columns_dirty = FALSE; - date_time_list->list = NULL; -} + datetime_copy = g_new0 (ECalComponentDateTime, 1); + datetime_copy->value = g_new (struct icaltimetype, 1); + *datetime_copy->value = *datetime->value; -EDateTimeList * -e_date_time_list_new (void) -{ - EDateTimeList *date_time_list; + if (datetime->tzid) + datetime_copy->tzid = g_strdup (datetime->tzid); - date_time_list = E_DATE_TIME_LIST (g_object_new (e_date_time_list_get_type (), NULL)); + return datetime_copy; +} - return date_time_list; +static gint +compare_datetime (const ECalComponentDateTime *datetime1, const ECalComponentDateTime *datetime2) +{ + return icaltime_compare (*datetime1->value, *datetime2->value); } static void @@ -217,16 +141,74 @@ row_updated (EDateTimeList *date_time_list, gint n) gtk_tree_path_free (path); } +/* Builds a static string out of an exception date */ +static gchar * +get_exception_string (EDateTimeList *date_time_list, + ECalComponentDateTime *dt) +{ + static gchar buf[256]; + struct tm tmp_tm; + gboolean use_24_hour_format; + + use_24_hour_format = + e_date_time_list_get_use_24_hour_format (date_time_list); + + tmp_tm.tm_year = dt->value->year - 1900; + tmp_tm.tm_mon = dt->value->month - 1; + tmp_tm.tm_mday = dt->value->day; + tmp_tm.tm_hour = dt->value->hour; + tmp_tm.tm_min = dt->value->minute; + tmp_tm.tm_sec = dt->value->second; + tmp_tm.tm_isdst = -1; + + tmp_tm.tm_wday = time_day_of_week (dt->value->day, + dt->value->month - 1, + dt->value->year); + + e_time_format_date_and_time ( + &tmp_tm, use_24_hour_format, + FALSE, FALSE, buf, sizeof (buf)); + + return buf; +} + +static void +date_time_list_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_USE_24_HOUR_FORMAT: + e_date_time_list_set_use_24_hour_format ( + E_DATE_TIME_LIST (object), + g_value_get_boolean (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + static void -e_date_time_list_finalize (GObject *object) +date_time_list_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); + switch (property_id) { + case PROP_USE_24_HOUR_FORMAT: + g_value_set_boolean ( + value, + e_date_time_list_get_use_24_hour_format ( + E_DATE_TIME_LIST (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } -/* Fulfill the GtkTreeModel requirements */ static GtkTreeModelFlags -e_date_time_list_get_flags (GtkTreeModel *tree_model) +date_time_list_get_flags (GtkTreeModel *tree_model) { g_return_val_if_fail (E_IS_DATE_TIME_LIST (tree_model), 0); @@ -234,7 +216,7 @@ e_date_time_list_get_flags (GtkTreeModel *tree_model) } static gint -e_date_time_list_get_n_columns (GtkTreeModel *tree_model) +date_time_list_get_n_columns (GtkTreeModel *tree_model) { EDateTimeList *date_time_list = (EDateTimeList *) tree_model; @@ -245,8 +227,8 @@ e_date_time_list_get_n_columns (GtkTreeModel *tree_model) } static GType -e_date_time_list_get_column_type (GtkTreeModel *tree_model, - gint index) +date_time_list_get_column_type (GtkTreeModel *tree_model, + gint index) { EDateTimeList *date_time_list = (EDateTimeList *) tree_model; @@ -258,105 +240,10 @@ e_date_time_list_get_column_type (GtkTreeModel *tree_model, return column_types[index]; } -const ECalComponentDateTime * -e_date_time_list_get_date_time (EDateTimeList *date_time_list, GtkTreeIter *iter) -{ - g_return_val_if_fail (IS_VALID_ITER (date_time_list, iter), NULL); - - return G_LIST (iter->user_data)->data; -} - -static void -free_datetime (ECalComponentDateTime *datetime) -{ - g_free (datetime->value); - if (datetime->tzid) - g_free ((gchar *) datetime->tzid); - g_free (datetime); -} - -static ECalComponentDateTime * -copy_datetime (const ECalComponentDateTime *datetime) -{ - ECalComponentDateTime *datetime_copy; - - datetime_copy = g_new0 (ECalComponentDateTime, 1); - datetime_copy->value = g_new (struct icaltimetype, 1); - *datetime_copy->value = *datetime->value; - - if (datetime->tzid) - datetime_copy->tzid = g_strdup (datetime->tzid); - - return datetime_copy; -} - -static gint -compare_datetime (const ECalComponentDateTime *datetime1, const ECalComponentDateTime *datetime2) -{ - return icaltime_compare (*datetime1->value, *datetime2->value); -} - -void -e_date_time_list_set_date_time (EDateTimeList *date_time_list, GtkTreeIter *iter, - const ECalComponentDateTime *datetime) -{ - ECalComponentDateTime *datetime_old; - - g_return_if_fail (IS_VALID_ITER (date_time_list, iter)); - - datetime_old = G_LIST (iter->user_data)->data; - free_datetime (datetime_old); - G_LIST (iter->user_data)->data = copy_datetime (datetime); - row_updated (date_time_list, g_list_position (date_time_list->list, G_LIST (iter->user_data))); -} - -void -e_date_time_list_append (EDateTimeList *date_time_list, GtkTreeIter *iter, - const ECalComponentDateTime *datetime) -{ - g_return_if_fail (datetime != NULL); - - if (g_list_find_custom (date_time_list->list, datetime, (GCompareFunc)compare_datetime) == NULL) { - date_time_list->list = g_list_append (date_time_list->list, copy_datetime (datetime)); - row_added (date_time_list, g_list_length (date_time_list->list) - 1); - } - - if (iter) { - iter->user_data = g_list_last (date_time_list->list); - iter->stamp = date_time_list->stamp; - } -} - -void -e_date_time_list_remove (EDateTimeList *date_time_list, GtkTreeIter *iter) -{ - gint n; - - g_return_if_fail (IS_VALID_ITER (date_time_list, iter)); - - n = g_list_position (date_time_list->list, G_LIST (iter->user_data)); - free_datetime ((ECalComponentDateTime *) G_LIST (iter->user_data)->data); - date_time_list->list = g_list_delete_link (date_time_list->list, G_LIST (iter->user_data)); - row_deleted (date_time_list, n); -} - -void -e_date_time_list_clear (EDateTimeList *date_time_list) -{ - GList *l; - - all_rows_deleted (date_time_list); - - for (l = date_time_list->list; l; l = g_list_next (l)) { - free_datetime ((ECalComponentDateTime *) l->data); - } - - g_list_free (date_time_list->list); - date_time_list->list = NULL; -} - static gboolean -e_date_time_list_get_iter (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreePath *path) +date_time_list_get_iter (GtkTreeModel *tree_model, + GtkTreeIter *iter, + GtkTreePath *path) { EDateTimeList *date_time_list = (EDateTimeList *) tree_model; GList *l; @@ -381,8 +268,8 @@ e_date_time_list_get_iter (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeP } static GtkTreePath * -e_date_time_list_get_path (GtkTreeModel *tree_model, - GtkTreeIter *iter) +date_time_list_get_path (GtkTreeModel *tree_model, + GtkTreeIter *iter) { EDateTimeList *date_time_list = (EDateTimeList *) tree_model; GtkTreePath *retval; @@ -397,36 +284,11 @@ e_date_time_list_get_path (GtkTreeModel *tree_model, return retval; } -/* Builds a static string out of an exception date */ -static gchar * -get_exception_string (ECalComponentDateTime *dt) -{ - static gchar buf[256]; - struct tm tmp_tm; - - tmp_tm.tm_year = dt->value->year - 1900; - tmp_tm.tm_mon = dt->value->month - 1; - tmp_tm.tm_mday = dt->value->day; - tmp_tm.tm_hour = dt->value->hour; - tmp_tm.tm_min = dt->value->minute; - tmp_tm.tm_sec = dt->value->second; - tmp_tm.tm_isdst = -1; - - tmp_tm.tm_wday = time_day_of_week (dt->value->day, - dt->value->month - 1, - dt->value->year); - - e_time_format_date_and_time (&tmp_tm, calendar_config_get_24_hour_format (), - FALSE, FALSE, buf, sizeof (buf)); - - return buf; -} - static void -e_date_time_list_get_value (GtkTreeModel *tree_model, - GtkTreeIter *iter, - gint column, - GValue *value) +date_time_list_get_value (GtkTreeModel *tree_model, + GtkTreeIter *iter, + gint column, + GValue *value) { EDateTimeList *date_time_list = E_DATE_TIME_LIST (tree_model); ECalComponentDateTime *datetime; @@ -451,15 +313,15 @@ e_date_time_list_get_value (GtkTreeModel *tree_model, switch (column) { case E_DATE_TIME_LIST_COLUMN_DESCRIPTION: - str = get_exception_string (datetime); + str = get_exception_string (date_time_list, datetime); g_value_set_string (value, str); break; } } static gboolean -e_date_time_list_iter_next (GtkTreeModel *tree_model, - GtkTreeIter *iter) +date_time_list_iter_next (GtkTreeModel *tree_model, + GtkTreeIter *iter) { GList *l; @@ -480,9 +342,9 @@ e_date_time_list_iter_next (GtkTreeModel *tree_model, } static gboolean -e_date_time_list_iter_children (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *parent) +date_time_list_iter_children (GtkTreeModel *tree_model, + GtkTreeIter *iter, + GtkTreeIter *parent) { EDateTimeList *date_time_list = E_DATE_TIME_LIST (tree_model); @@ -502,16 +364,16 @@ e_date_time_list_iter_children (GtkTreeModel *tree_model, } static gboolean -e_date_time_list_iter_has_child (GtkTreeModel *tree_model, - GtkTreeIter *iter) +date_time_list_iter_has_child (GtkTreeModel *tree_model, + GtkTreeIter *iter) { g_return_val_if_fail (IS_VALID_ITER (E_DATE_TIME_LIST (tree_model), iter), FALSE); return FALSE; } static gint -e_date_time_list_iter_n_children (GtkTreeModel *tree_model, - GtkTreeIter *iter) +date_time_list_iter_n_children (GtkTreeModel *tree_model, + GtkTreeIter *iter) { EDateTimeList *date_time_list = E_DATE_TIME_LIST (tree_model); @@ -525,10 +387,10 @@ e_date_time_list_iter_n_children (GtkTreeModel *tree_model, } static gboolean -e_date_time_list_iter_nth_child (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *parent, - gint n) +date_time_list_iter_nth_child (GtkTreeModel *tree_model, + GtkTreeIter *iter, + GtkTreeIter *parent, + gint n) { EDateTimeList *date_time_list = E_DATE_TIME_LIST (tree_model); @@ -553,9 +415,148 @@ e_date_time_list_iter_nth_child (GtkTreeModel *tree_model, } static gboolean -e_date_time_list_iter_parent (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *child) +date_time_list_iter_parent (GtkTreeModel *tree_model, + GtkTreeIter *iter, + GtkTreeIter *child) { return FALSE; } + +static void +e_date_time_list_class_init (EDateTimeListClass *class) +{ + GObjectClass *object_class; + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = date_time_list_set_property; + object_class->get_property = date_time_list_get_property; + + g_object_class_install_property ( + object_class, + PROP_USE_24_HOUR_FORMAT, + g_param_spec_boolean ( + "use-24-hour-format", + "Use 24-hour Format", + NULL, + FALSE, + G_PARAM_READWRITE)); + + column_types[E_DATE_TIME_LIST_COLUMN_DESCRIPTION] = G_TYPE_STRING; +} + +static void +e_date_time_list_init (EDateTimeList *date_time_list) +{ + date_time_list->stamp = g_random_int (); + date_time_list->columns_dirty = FALSE; + date_time_list->list = NULL; +} + +static void +e_date_time_list_tree_model_init (GtkTreeModelIface *iface) +{ + iface->get_flags = date_time_list_get_flags; + iface->get_n_columns = date_time_list_get_n_columns; + iface->get_column_type = date_time_list_get_column_type; + iface->get_iter = date_time_list_get_iter; + iface->get_path = date_time_list_get_path; + iface->get_value = date_time_list_get_value; + iface->iter_next = date_time_list_iter_next; + iface->iter_children = date_time_list_iter_children; + iface->iter_has_child = date_time_list_iter_has_child; + iface->iter_n_children = date_time_list_iter_n_children; + iface->iter_nth_child = date_time_list_iter_nth_child; + iface->iter_parent = date_time_list_iter_parent; +} + +EDateTimeList * +e_date_time_list_new (void) +{ + return g_object_new (E_TYPE_DATE_TIME_LIST, NULL); +} + +const ECalComponentDateTime * +e_date_time_list_get_date_time (EDateTimeList *date_time_list, GtkTreeIter *iter) +{ + g_return_val_if_fail (IS_VALID_ITER (date_time_list, iter), NULL); + + return G_LIST (iter->user_data)->data; +} + +void +e_date_time_list_set_date_time (EDateTimeList *date_time_list, GtkTreeIter *iter, + const ECalComponentDateTime *datetime) +{ + ECalComponentDateTime *datetime_old; + + g_return_if_fail (IS_VALID_ITER (date_time_list, iter)); + + datetime_old = G_LIST (iter->user_data)->data; + free_datetime (datetime_old); + G_LIST (iter->user_data)->data = copy_datetime (datetime); + row_updated (date_time_list, g_list_position (date_time_list->list, G_LIST (iter->user_data))); +} + +gboolean +e_date_time_list_get_use_24_hour_format (EDateTimeList *date_time_list) +{ + g_return_val_if_fail (E_IS_DATE_TIME_LIST (date_time_list), FALSE); + + return date_time_list->use_24_hour_format; +} + +void +e_date_time_list_set_use_24_hour_format (EDateTimeList *date_time_list, + gboolean use_24_hour_format) +{ + g_return_if_fail (E_IS_DATE_TIME_LIST (date_time_list)); + + date_time_list->use_24_hour_format = use_24_hour_format; + + g_object_notify (G_OBJECT (date_time_list), "use-24-hour-format"); +} + +void +e_date_time_list_append (EDateTimeList *date_time_list, GtkTreeIter *iter, + const ECalComponentDateTime *datetime) +{ + g_return_if_fail (datetime != NULL); + + if (g_list_find_custom (date_time_list->list, datetime, (GCompareFunc)compare_datetime) == NULL) { + date_time_list->list = g_list_append (date_time_list->list, copy_datetime (datetime)); + row_added (date_time_list, g_list_length (date_time_list->list) - 1); + } + + if (iter) { + iter->user_data = g_list_last (date_time_list->list); + iter->stamp = date_time_list->stamp; + } +} + +void +e_date_time_list_remove (EDateTimeList *date_time_list, GtkTreeIter *iter) +{ + gint n; + + g_return_if_fail (IS_VALID_ITER (date_time_list, iter)); + + n = g_list_position (date_time_list->list, G_LIST (iter->user_data)); + free_datetime ((ECalComponentDateTime *) G_LIST (iter->user_data)->data); + date_time_list->list = g_list_delete_link (date_time_list->list, G_LIST (iter->user_data)); + row_deleted (date_time_list, n); +} + +void +e_date_time_list_clear (EDateTimeList *date_time_list) +{ + GList *l; + + all_rows_deleted (date_time_list); + + for (l = date_time_list->list; l; l = g_list_next (l)) { + free_datetime ((ECalComponentDateTime *) l->data); + } + + g_list_free (date_time_list->list); + date_time_list->list = NULL; +} diff --git a/calendar/gui/e-date-time-list.h b/calendar/gui/e-date-time-list.h index cdf279a537..e0bbf1ed88 100644 --- a/calendar/gui/e-date-time-list.h +++ b/calendar/gui/e-date-time-list.h @@ -29,29 +29,37 @@ #include #include -G_BEGIN_DECLS +/* Standard GObject macros */ +#define E_TYPE_DATE_TIME_LIST \ + (e_date_time_list_get_type ()) +#define E_DATE_TIME_LIST(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_DATE_TIME_LIST, EDateTimeList)) +#define E_DATE_TIME_LIST_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_DATE_TIME_LIST, EDateTimeListClass)) +#define E_IS_DATE_TIME_LIST(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_DATE_TIME_LIST)) +#define E_IS_DATE_TIME_LIST_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_DATE_TIME_LIST)) +#define E_DATE_TIME_LIST_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_DATE_TIME_LIST, EDateTimeListClass)) -#define E_TYPE_DATE_TIME_LIST (e_date_time_list_get_type ()) -#define E_DATE_TIME_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_DATE_TIME_LIST, EDateTimeList)) -#define E_DATE_TIME_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_DATE_TIME_LIST, EDateTimeListClass)) -#define E_IS_DATE_TIME_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_DATE_TIME_LIST)) -#define E_IS_DATE_TIME_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_DATE_TIME_LIST)) -#define E_DATE_TIME_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_DATE_TIME_LIST, EDateTimeListClass)) +G_BEGIN_DECLS -typedef struct _EDateTimeList EDateTimeList; -typedef struct _EDateTimeListClass EDateTimeListClass; +typedef struct _EDateTimeList EDateTimeList; +typedef struct _EDateTimeListClass EDateTimeListClass; -typedef enum -{ +typedef enum { E_DATE_TIME_LIST_COLUMN_DESCRIPTION, - E_DATE_TIME_LIST_NUM_COLUMNS -} -EDateTimeListColumnType; +} EDateTimeListColumnType; -struct _EDateTimeList -{ - GObject parent; +struct _EDateTimeList { + GObject parent; /* Private */ @@ -59,27 +67,33 @@ struct _EDateTimeList GList *list; guint columns_dirty : 1; + + gboolean use_24_hour_format; }; -struct _EDateTimeListClass -{ +struct _EDateTimeListClass { GObjectClass parent_class; }; -GType e_date_time_list_get_type (void); -EDateTimeList *e_date_time_list_new (void); - -const ECalComponentDateTime *e_date_time_list_get_date_time (EDateTimeList *date_time_list, - GtkTreeIter *iter); -void e_date_time_list_set_date_time (EDateTimeList *date_time_list, - GtkTreeIter *iter, - const ECalComponentDateTime *datetime); -void e_date_time_list_append (EDateTimeList *date_time_list, - GtkTreeIter *iter, - const ECalComponentDateTime *datetime); -void e_date_time_list_remove (EDateTimeList *date_time_list, - GtkTreeIter *iter); -void e_date_time_list_clear (EDateTimeList *date_time_list); +GType e_date_time_list_get_type (void); +EDateTimeList * e_date_time_list_new (void); +const ECalComponentDateTime * + e_date_time_list_get_date_time (EDateTimeList *date_time_list, + GtkTreeIter *iter); +void e_date_time_list_set_date_time (EDateTimeList *date_time_list, + GtkTreeIter *iter, + const ECalComponentDateTime *datetime); +gboolean e_date_time_list_get_use_24_hour_format + (EDateTimeList *date_time_list); +void e_date_time_list_set_use_24_hour_format + (EDateTimeList *date_time_list, + gboolean use_24_hour_format); +void e_date_time_list_append (EDateTimeList *date_time_list, + GtkTreeIter *iter, + const ECalComponentDateTime *datetime); +void e_date_time_list_remove (EDateTimeList *date_time_list, + GtkTreeIter *iter); +void e_date_time_list_clear (EDateTimeList *date_time_list); G_END_DECLS diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c index 08793c9c53..98c15152d0 100644 --- a/calendar/gui/e-day-view-main-item.c +++ b/calendar/gui/e-day-view-main-item.c @@ -39,7 +39,6 @@ #include "ea-calendar.h" #include "e-calendar-view.h" #include "comp-util.h" -#include "calendar-config.h" /* backward-compatibility cruft */ #include "e-util/gtk-compat.h" @@ -100,12 +99,17 @@ day_view_main_item_draw_long_events_in_vbars (EDayViewMainItem *main_item, { EDayView *day_view; EDayViewEvent *event; + ECalendarView *cal_view; + gint time_divisions; gint event_num, start_day, end_day, day, bar_y1, bar_y2, grid_x; cairo_t *cr = NULL; GdkColor bg_color; day_view = e_day_view_main_item_get_day_view (main_item); + cal_view = E_CALENDAR_VIEW (day_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); + for (event_num = 0; event_num < day_view->long_events->len; event_num++) { gboolean first = TRUE; event = &g_array_index (day_view->long_events, EDayViewEvent, event_num); @@ -136,13 +140,13 @@ day_view_main_item_draw_long_events_in_vbars (EDayViewMainItem *main_item, if (event->start <= day_view->day_starts[day]) { bar_y1 = 0; } else { - bar_y1 = event->start_minute * day_view->row_height / day_view->mins_per_row - y; + bar_y1 = event->start_minute * day_view->row_height / time_divisions - y; } if (event->end >= day_view->day_starts[day + 1]) { bar_y2 = height; } else { - bar_y2 = event->end_minute * day_view->row_height / day_view->mins_per_row - y; + bar_y2 = event->end_minute * day_view->row_height / time_divisions - y; } if (bar_y1 < height && bar_y2 > 0 && bar_y2 > bar_y1 && can_draw_in_region (draw_region, grid_x, bar_y1, E_DAY_VIEW_BAR_WIDTH - 2, bar_y2 - bar_y1)) { @@ -191,6 +195,8 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item, EDayView *day_view; EDayViewEvent *event; ECalModel *model; + ECalendarView *cal_view; + gint time_divisions; gint item_x, item_y, item_w, item_h, bar_y1, bar_y2; GdkColor bg_color; ECalComponent *comp; @@ -205,8 +211,6 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item, guint16 red, green, blue; gint i; gdouble radius, x0, y0, rect_height, rect_width, text_x_offset = 0.0; - gfloat alpha; - gboolean gradient; gdouble cc = 65535.0; gdouble date_fraction; gboolean short_event = FALSE, resize_flag = FALSE, is_editing; @@ -223,7 +227,10 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item, gint row_y; day_view = e_day_view_main_item_get_day_view (main_item); - model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); + + cal_view = E_CALENDAR_VIEW (day_view); + model = e_calendar_view_get_model (cal_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); /* If the event is currently being dragged, don't draw it. It will be drawn in the special drag items. */ @@ -246,9 +253,6 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item, gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR]); - gradient = calendar_config_get_display_events_gradient (); - alpha = calendar_config_get_display_events_alpha (); - font_options = get_font_options (); if (!is_array_index_in_bounds (day_view->events[day], event_num)) { @@ -441,7 +445,7 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item, draw_curved_rectangle (cr, x0, y0, rect_width, rect_height, radius); - cairo_set_source_rgba (cr, 1, 1, 1, alpha); + cairo_set_source_rgba (cr, 1, 1, 1, 1.0); cairo_fill (cr); cairo_restore (cr); @@ -478,10 +482,11 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item, date_fraction = rect_height / day_view->row_height; interval = event->end_minute - event->start_minute; - if ((interval/day_view->mins_per_row) >= 2) + if ((interval / time_divisions) >= 2) short_event = FALSE; - else if ((interval%day_view->mins_per_row)==0) { - if (((event->end_minute%day_view->mins_per_row) == 0) || ((event->start_minute%day_view->mins_per_row) == 0)) + else if ((interval % time_divisions) == 0) { + if (((event->end_minute % time_divisions) == 0) || + ((event->start_minute % time_divisions) == 0)) short_event = TRUE; } else @@ -490,25 +495,20 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item, if (is_editing) short_event = TRUE; - if (gradient) { - pat = cairo_pattern_create_linear (item_x + E_DAY_VIEW_BAR_WIDTH + 1.75, item_y + 7.75, - item_x + E_DAY_VIEW_BAR_WIDTH + 1.75, item_y + item_h - 7.75); - if (!short_event) { - cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8); - cairo_pattern_add_color_stop_rgba (pat, 1/(date_fraction + (rect_height/18)), red/cc, green/cc, blue/cc, 0.8); - cairo_pattern_add_color_stop_rgba (pat, 1/(date_fraction + (rect_height/18)), red/cc, green/cc, blue/cc, 0.4); - cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8); - } else { - cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8); - cairo_pattern_add_color_stop_rgba (pat, 0, red/cc, green/cc, blue/cc, 0.4); - } - cairo_set_source (cr, pat); - cairo_fill_preserve (cr); - cairo_pattern_destroy (pat); + pat = cairo_pattern_create_linear (item_x + E_DAY_VIEW_BAR_WIDTH + 1.75, item_y + 7.75, + item_x + E_DAY_VIEW_BAR_WIDTH + 1.75, item_y + item_h - 7.75); + if (!short_event) { + cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8); + cairo_pattern_add_color_stop_rgba (pat, 1/(date_fraction + (rect_height/18)), red/cc, green/cc, blue/cc, 0.8); + cairo_pattern_add_color_stop_rgba (pat, 1/(date_fraction + (rect_height/18)), red/cc, green/cc, blue/cc, 0.4); + cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8); } else { - cairo_set_source_rgba (cr, red/cc, green/cc, blue/cc, 0.8); - cairo_fill_preserve (cr); + cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8); + cairo_pattern_add_color_stop_rgba (pat, 0, red/cc, green/cc, blue/cc, 0.4); } + cairo_set_source (cr, pat); + cairo_fill_preserve (cr); + cairo_pattern_destroy (pat); cairo_set_source_rgba (cr, red/cc, green/cc, blue/cc, 0.2); cairo_set_line_width (cr, 0.5); @@ -530,8 +530,8 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item, /* Draw the vertical colored bar showing when the appointment begins & ends. */ - bar_y1 = event->start_minute * day_view->row_height / day_view->mins_per_row - y; - bar_y2 = event->end_minute * day_view->row_height / day_view->mins_per_row - y; + bar_y1 = event->start_minute * day_view->row_height / time_divisions - y; + bar_y2 = event->end_minute * day_view->row_height / time_divisions - y; scroll_flag = bar_y2; @@ -588,9 +588,9 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item, } if (bar_y2 > scroll_flag) - event->end_minute += day_view->mins_per_row; + event->end_minute += time_divisions; else if (bar_y2 < scroll_flag) - event->end_minute -= day_view->mins_per_row; + event->end_minute -= time_divisions; comp = e_cal_component_new (); e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); @@ -735,9 +735,9 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item, if (!short_event) { - if (event->start_minute % day_view->mins_per_row != 0 + if (event->start_minute % time_divisions != 0 || (day_view->show_event_end_times - && event->end_minute % day_view->mins_per_row != 0)) { + && event->end_minute % time_divisions != 0)) { offset = day_view->first_hour_shown * 60 + day_view->first_minute_shown; show_span = TRUE; @@ -747,7 +747,7 @@ day_view_main_item_draw_day_event (EDayViewMainItem *main_item, start_minute = offset + event->start_minute; end_minute = offset + event->end_minute; - format_time = (((end_minute - start_minute)/day_view->mins_per_row) >= 2) ? TRUE : FALSE; + format_time = (((end_minute - start_minute) / time_divisions) >= 2) ? TRUE : FALSE; start_hour = start_minute / 60; start_minute = start_minute % 60; @@ -865,12 +865,17 @@ day_view_main_item_draw_events_in_vbars (EDayViewMainItem *main_item, { EDayView *day_view; EDayViewEvent *event; + ECalendarView *cal_view; + gint time_divisions; gint grid_x, event_num, bar_y, bar_h; cairo_t *cr = NULL; GdkColor bg_color; day_view = e_day_view_main_item_get_day_view (main_item); + cal_view = E_CALENDAR_VIEW (day_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); + grid_x = day_view->day_offsets[day] + 1 - x; /* Draw the busy times corresponding to the events in the day. */ @@ -886,8 +891,8 @@ day_view_main_item_draw_events_in_vbars (EDayViewMainItem *main_item, continue; } - bar_y = event->start_minute * day_view->row_height / day_view->mins_per_row; - bar_h = event->end_minute * day_view->row_height / day_view->mins_per_row - bar_y; + bar_y = event->start_minute * day_view->row_height / time_divisions; + bar_h = event->end_minute * day_view->row_height / time_divisions - bar_y; bar_y -= y; /* Skip it if it isn't visible. */ @@ -1005,6 +1010,13 @@ day_view_main_item_draw (GnomeCanvasItem *canvas_item, { EDayViewMainItem *main_item; EDayView *day_view; + ECalendarView *cal_view; + ECalModel *model; + gint time_divisions; + gint work_day_start_hour; + gint work_day_start_minute; + gint work_day_end_hour; + gint work_day_end_minute; gint row, row_y, grid_x1, grid_x2; gint day, grid_y1, grid_y2; gint work_day_start_y, work_day_end_y; @@ -1023,6 +1035,15 @@ day_view_main_item_draw (GnomeCanvasItem *canvas_item, day_view = e_day_view_main_item_get_day_view (main_item); g_return_if_fail (day_view != NULL); + cal_view = E_CALENDAR_VIEW (day_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); + + model = e_calendar_view_get_model (cal_view); + work_day_start_hour = e_cal_model_get_work_day_start_hour (model); + work_day_start_minute = e_cal_model_get_work_day_start_minute (model); + work_day_end_hour = e_cal_model_get_work_day_end_hour (model); + work_day_end_minute = e_cal_model_get_work_day_end_minute (model); + rect.x = 0; rect.y = 0; rect.width = width; @@ -1030,8 +1051,10 @@ day_view_main_item_draw (GnomeCanvasItem *canvas_item, draw_region = gdk_region_rectangle (&rect); /* Paint the background colors. */ - work_day_start_y = e_day_view_convert_time_to_position (day_view, day_view->work_day_start_hour, day_view->work_day_start_minute) - y; - work_day_end_y = e_day_view_convert_time_to_position (day_view, day_view->work_day_end_hour, day_view->work_day_end_minute) - y; + work_day_start_y = e_day_view_convert_time_to_position ( + day_view, work_day_start_hour, work_day_start_minute) - y; + work_day_end_y = e_day_view_convert_time_to_position ( + day_view, work_day_end_hour, work_day_end_minute) - y; today_tt = icaltime_from_timet_with_zone (time (NULL), FALSE, e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); @@ -1220,7 +1243,7 @@ day_view_main_item_draw (GnomeCanvasItem *canvas_item, grid_x1 = day_view->day_offsets[day] - x + E_DAY_VIEW_BAR_WIDTH; grid_x2 = day_view->day_offsets[day + 1] - x - 1; - marcus_bains_y = (time_now.hour * 60 + time_now.minute) * day_view->row_height / day_view->mins_per_row - y; + marcus_bains_y = (time_now.hour * 60 + time_now.minute) * day_view->row_height / time_divisions - y; cairo_set_line_width (cr, 1.5); cairo_move_to (cr, grid_x1, marcus_bains_y); cairo_line_to (cr, grid_x2, marcus_bains_y); diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c index e163e278ac..35a8e3ebda 100644 --- a/calendar/gui/e-day-view-time-item.c +++ b/calendar/gui/e-day-view-time-item.c @@ -87,7 +87,7 @@ static gint e_day_view_time_item_event (GnomeCanvasItem *item, GdkEvent *event); static void e_day_view_time_item_increment_time (gint *hour, gint *minute, - gint mins_per_row); + gint time_divisions); static void e_day_view_time_item_show_popup_menu (EDayViewTimeItem *time_item, GdkEvent *event); static void e_day_view_time_item_on_set_divisions (GtkWidget *item, @@ -285,10 +285,12 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, { EDayView *day_view; EDayViewTimeItem *time_item; + ECalendarView *cal_view; ECalModel *model; GtkStyle *style; const gchar *suffix; gchar buffer[64], *midnight_day = NULL, *midnight_month = NULL; + gint time_divisions; gint hour, display_hour, minute, row; gint row_y, start_y, large_hour_y_offset, small_font_y_offset; gint long_line_x1, long_line_x2, short_line_x1; @@ -309,7 +311,9 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, day_view = e_day_view_time_item_get_day_view (time_item); g_return_if_fail (day_view != NULL); - model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); + cal_view = E_CALENDAR_VIEW (day_view); + model = e_calendar_view_get_model (cal_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); style = gtk_widget_get_style (GTK_WIDGET (day_view)); small_font_desc = style->font_desc; @@ -327,7 +331,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, long_line_x1 = (use_zone ? 0 : E_DVTMI_TIME_GRID_X_PAD) - x + x_offset; long_line_x2 = time_item->priv->column_width - E_DVTMI_TIME_GRID_X_PAD - x - (use_zone ? E_DVTMI_TIME_GRID_X_PAD : 0) + x_offset; - if (day_view->mins_per_row == 60) { + if (time_divisions == 60) { /* The right edge of the complete time string in 60-min divisions, e.g. "14:00" or "2 pm". */ minute_x2 = long_line_x2 - E_DVTMI_60_MIN_X_PAD; @@ -437,7 +441,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, mb_color = day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE]; time_now = icaltime_current_time_with_zone (e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); - marcus_bains_y = (time_now.hour * 60 + time_now.minute) * day_view->row_height / day_view->mins_per_row - y; + marcus_bains_y = (time_now.hour * 60 + time_now.minute) * day_view->row_height / time_divisions - y; cairo_set_line_width (cr, 1.5); cairo_move_to (cr, long_line_x1 - (use_zone ? E_DVTMI_TIME_GRID_X_PAD : 0), marcus_bains_y); cairo_line_to (cr, long_line_x2, marcus_bains_y); @@ -461,13 +465,13 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, for (row = 0, row_y = 0 - y; row < day_view->rows && row_y < height; row++, row_y += day_view->row_height) { - gboolean show_midnight_date = use_zone && hour == 0 && (minute == 0 || day_view->mins_per_row == 60) && midnight_day && midnight_month; + gboolean show_midnight_date = use_zone && hour == 0 && (minute == 0 || time_divisions == 60) && midnight_day && midnight_month; /* If the row is above the first row we want to draw just increment the time and skip to the next row. */ if (row_y < start_y) { e_day_view_time_item_increment_time (&hour, &minute, - day_view->mins_per_row); + time_divisions); continue; } @@ -477,7 +481,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, &display_hour, &suffix, &suffix_width); - if (day_view->mins_per_row == 60) { + if (time_divisions == 60) { /* 60 minute intervals - draw a long horizontal line between hours and display as one long string, e.g. "14:00" or "2 pm". */ @@ -568,7 +572,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, /* Normally we display the minute in each interval, but when using 30-minute intervals we don't display the '30'. */ - if (day_view->mins_per_row != 30 || minute != 30) { + if (time_divisions != 30 || minute != 30) { /* In 12-hour format we display 'am' or 'pm' instead of '00'. */ if (show_midnight_date) @@ -600,7 +604,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, } e_day_view_time_item_increment_time (&hour, &minute, - day_view->mins_per_row); + time_divisions); } pango_font_metrics_unref (large_font_metrics); @@ -631,14 +635,14 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item, } /* Increment the time by the 5/10/15/30/60 minute interval. - Note that mins_per_row is never > 60, so we never have to + Note that time_divisions is never > 60, so we never have to worry about adding more than 60 minutes. */ static void e_day_view_time_item_increment_time (gint *hour, gint *minute, - gint mins_per_row) + gint time_divisions) { - *minute += mins_per_row; + *minute += time_divisions; if (*minute >= 60) { *minute -= 60; /* Currently we never wrap around to the next day, but @@ -728,6 +732,7 @@ e_day_view_time_item_show_popup_menu (EDayViewTimeItem *time_item, { static gint divisions[] = { 60, 30, 15, 10, 5 }; EDayView *day_view; + ECalendarView *cal_view; GtkWidget *menu, *item, *submenu; gchar buffer[256]; GSList *group = NULL, *recent_zones, *s; @@ -737,7 +742,8 @@ e_day_view_time_item_show_popup_menu (EDayViewTimeItem *time_item, day_view = e_day_view_time_item_get_day_view (time_item); g_return_if_fail (day_view != NULL); - current_divisions = e_day_view_get_mins_per_row (day_view); + cal_view = E_CALENDAR_VIEW (day_view); + current_divisions = e_calendar_view_get_time_divisions (cal_view); menu = gtk_menu_new (); @@ -832,6 +838,7 @@ e_day_view_time_item_on_set_divisions (GtkWidget *item, EDayViewTimeItem *time_item) { EDayView *day_view; + ECalendarView *cal_view; gint divisions; day_view = e_day_view_time_item_get_day_view (time_item); @@ -841,8 +848,9 @@ e_day_view_time_item_on_set_divisions (GtkWidget *item, return; divisions = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "divisions")); - e_day_view_set_mins_per_row (day_view, divisions); - calendar_config_set_time_divisions (divisions); + + cal_view = E_CALENDAR_VIEW (day_view); + e_calendar_view_set_time_divisions (cal_view, divisions); } static void diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c index 1703467840..c58f057903 100644 --- a/calendar/gui/e-day-view-top-item.c +++ b/calendar/gui/e-day-view-top-item.c @@ -34,7 +34,6 @@ #include #include #include -#include "calendar-config.h" #include "e-calendar-view.h" #include "e-day-view-top-item.h" @@ -174,16 +173,11 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item, cairo_pattern_t *pat; guint16 red, green, blue; gdouble cc = 65535.0; - gboolean gradient; - gfloat alpha; gdouble x0, y0, rect_height, rect_width, radius; day_view = e_day_view_top_item_get_day_view (top_item); model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); - gradient = calendar_config_get_display_events_gradient (); - alpha = calendar_config_get_display_events_alpha (); - /* If the event is currently being dragged, don't draw it. It will be drawn in the special drag items. */ if (day_view->drag_event_day == E_DAY_VIEW_LONG_EVENT @@ -245,7 +239,7 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item, draw_curved_rectangle (cr, x0, y0, rect_width, rect_height, radius); - cairo_set_source_rgba (cr, 1, 1, 1, alpha); + cairo_set_source_rgba (cr, 1, 1, 1, 1.0); cairo_fill_preserve (cr); cairo_restore (cr); @@ -280,18 +274,14 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item, draw_curved_rectangle (cr, x0, y0, rect_width, rect_height, radius); - if (gradient) { - pat = cairo_pattern_create_linear (item_x - x + 5.5, item_y + 2.5 - y, - item_x - x + 5, item_y - y + item_h + 7.5); - cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8); - cairo_pattern_add_color_stop_rgba (pat, 0, red/cc, green/cc, blue/cc, 0.4); - cairo_set_source (cr, pat); - cairo_fill_preserve (cr); - cairo_pattern_destroy (pat); - } else { - cairo_set_source_rgba (cr, red/cc, green/cc, blue/cc, 0.8); - cairo_fill_preserve (cr); - } + pat = cairo_pattern_create_linear (item_x - x + 5.5, item_y + 2.5 - y, + item_x - x + 5, item_y - y + item_h + 7.5); + cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8); + cairo_pattern_add_color_stop_rgba (pat, 0, red/cc, green/cc, blue/cc, 0.4); + cairo_set_source (cr, pat); + cairo_fill_preserve (cr); + cairo_pattern_destroy (pat); + cairo_set_source_rgba (cr, red/cc, green/cc, blue/cc, 0); cairo_set_line_width (cr, 0.5); cairo_stroke (cr); diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 1482398367..f81afae485 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -51,7 +51,6 @@ #include "print.h" #include "comp-util.h" #include "itip-utils.h" -#include "calendar-config.h" #include "goto.h" #include "e-cal-model-calendar.h" #include "e-day-view-time-item.h" @@ -430,16 +429,42 @@ enum { PROP_MARCUS_BAINS_SHOW_LINE, PROP_MARCUS_BAINS_DAY_VIEW_COLOR, PROP_MARCUS_BAINS_TIME_BAR_COLOR, - PROP_MINS_PER_ROW, - PROP_WORK_DAY_END_HOUR, - PROP_WORK_DAY_END_MINUTE, - PROP_WORK_DAY_START_HOUR, - PROP_WORK_DAY_START_MINUTE, PROP_WORKING_DAYS }; G_DEFINE_TYPE (EDayView, e_day_view, E_TYPE_CALENDAR_VIEW) +static void +day_view_notify_time_divisions_cb (EDayView *day_view) +{ + gint day; + + e_day_view_recalc_num_rows (day_view); + + /* If we aren't visible, we'll sort it out later. */ + if (!E_CALENDAR_VIEW (day_view)->in_focus) { + e_day_view_free_events (day_view); + day_view->requires_update = TRUE; + return; + } + + for (day = 0; day < E_DAY_VIEW_MAX_DAYS; day++) + day_view->need_layout[day] = TRUE; + + /* We need to update all the day event labels since the start & end + times may or may not be on row boundaries any more. */ + e_day_view_foreach_event (day_view, + e_day_view_set_show_times_cb, NULL); + + /* We must layout the events before updating the scroll region, since + that will result in a redraw which would crash otherwise. */ + e_day_view_check_layout (day_view); + gtk_widget_queue_draw (day_view->time_canvas); + gtk_widget_queue_draw (day_view->main_canvas); + + e_day_view_update_scroll_regions (day_view); +} + static void day_view_notify_week_start_day_cb (EDayView *day_view) { @@ -474,36 +499,6 @@ day_view_set_property (GObject *object, g_value_get_string (value)); return; - case PROP_MINS_PER_ROW: - e_day_view_set_mins_per_row ( - E_DAY_VIEW (object), - g_value_get_int (value)); - return; - - case PROP_WORK_DAY_END_HOUR: - e_day_view_set_work_day_end_hour ( - E_DAY_VIEW (object), - g_value_get_int (value)); - return; - - case PROP_WORK_DAY_END_MINUTE: - e_day_view_set_work_day_end_minute ( - E_DAY_VIEW (object), - g_value_get_int (value)); - return; - - case PROP_WORK_DAY_START_HOUR: - e_day_view_set_work_day_start_hour ( - E_DAY_VIEW (object), - g_value_get_int (value)); - return; - - case PROP_WORK_DAY_START_MINUTE: - e_day_view_set_work_day_start_minute ( - E_DAY_VIEW (object), - g_value_get_int (value)); - return; - case PROP_WORKING_DAYS: e_day_view_set_working_days ( E_DAY_VIEW (object), @@ -542,41 +537,6 @@ day_view_get_property (GObject *object, E_DAY_VIEW (object))); return; - case PROP_MINS_PER_ROW: - g_value_set_int ( - value, - e_day_view_get_mins_per_row ( - E_DAY_VIEW (object))); - return; - - case PROP_WORK_DAY_END_HOUR: - g_value_set_int ( - value, - e_day_view_get_work_day_end_hour ( - E_DAY_VIEW (object))); - return; - - case PROP_WORK_DAY_END_MINUTE: - g_value_set_int ( - value, - e_day_view_get_work_day_end_minute ( - E_DAY_VIEW (object))); - return; - - case PROP_WORK_DAY_START_HOUR: - g_value_set_int ( - value, - e_day_view_get_work_day_start_hour ( - E_DAY_VIEW (object))); - return; - - case PROP_WORK_DAY_START_MINUTE: - g_value_set_int ( - value, - e_day_view_get_work_day_start_minute ( - E_DAY_VIEW (object))); - return; - case PROP_WORKING_DAYS: g_value_set_int ( value, @@ -591,16 +551,39 @@ day_view_get_property (GObject *object, static void day_view_constructed (GObject *object) { + EDayView *day_view; ECalModel *model; + day_view = E_DAY_VIEW (object); + /* Chain up to parent's constructed() method. */ G_OBJECT_CLASS (e_day_view_parent_class)->constructed (object); - model = e_calendar_view_get_model (E_CALENDAR_VIEW (object)); + model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); + + g_signal_connect_swapped ( + model, "notify::time-divisions", + G_CALLBACK (day_view_notify_time_divisions_cb), day_view); g_signal_connect_swapped ( model, "notify::week-start-day", - G_CALLBACK (day_view_notify_week_start_day_cb), object); + G_CALLBACK (day_view_notify_week_start_day_cb), day_view); + + g_signal_connect_swapped ( + model, "notify::work-day-start-hour", + G_CALLBACK (gtk_widget_queue_draw), day_view->main_canvas); + + g_signal_connect_swapped ( + model, "notify::work-day-start-minute", + G_CALLBACK (gtk_widget_queue_draw), day_view->main_canvas); + + g_signal_connect_swapped ( + model, "notify::work-day-end-hour", + G_CALLBACK (gtk_widget_queue_draw), day_view->main_canvas); + + g_signal_connect_swapped ( + model, "notify::work-day-end-minute", + G_CALLBACK (gtk_widget_queue_draw), day_view->main_canvas); } static void @@ -666,66 +649,6 @@ e_day_view_class_init (EDayViewClass *class) NULL, G_PARAM_READWRITE)); - g_object_class_install_property ( - object_class, - PROP_MINS_PER_ROW, - g_param_spec_int ( - "mins-per-row", - "Minutes Per Row", - NULL, - 5, /* not a continuous range */ - 60, /* valid values: 5, 10, 15, 30, 60 */ - 30, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - object_class, - PROP_WORK_DAY_END_HOUR, - g_param_spec_int ( - "work-day-end-hour", - "Work Day End Hour", - NULL, - G_MININT, - G_MAXINT, - 0, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - object_class, - PROP_WORK_DAY_END_MINUTE, - g_param_spec_int ( - "work-day-end-minute", - "Work Day End Minute", - NULL, - G_MININT, - G_MAXINT, - 0, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - object_class, - PROP_WORK_DAY_START_HOUR, - g_param_spec_int ( - "work-day-start-hour", - "Work Day Start Hour", - NULL, - G_MININT, - G_MAXINT, - 0, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - object_class, - PROP_WORK_DAY_START_MINUTE, - g_param_spec_int ( - "work-day-start-minute", - "Work Day Start Minute", - NULL, - G_MININT, - G_MAXINT, - 0, - G_PARAM_READWRITE)); - /* FIXME Make this a real GFlags type. */ g_object_class_install_property ( object_class, @@ -1024,7 +947,6 @@ e_day_view_init (EDayView *day_view) day_view->work_week_view = FALSE; day_view->days_shown = 1; - day_view->mins_per_row = 30; day_view->date_format = E_DAY_VIEW_DATE_FULL; day_view->rows_in_top_display = 0; @@ -1042,10 +964,6 @@ e_day_view_init (EDayView *day_view) | E_DAY_VIEW_WEDNESDAY | E_DAY_VIEW_THURSDAY | E_DAY_VIEW_FRIDAY; - day_view->work_day_start_hour = 9; - day_view->work_day_start_minute = 0; - day_view->work_day_end_hour = 17; - day_view->work_day_end_minute = 0; day_view->show_event_end_times = TRUE; day_view->scroll_to_work_day = TRUE; @@ -1772,9 +1690,16 @@ e_day_view_style_set (GtkWidget *widget, static void e_day_view_recalc_main_canvas_size (EDayView *day_view) { + ECalModel *model; + gint work_day_start_hour; + gint work_day_start_minute; gint day, scroll_y; gboolean need_reshape; + model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); + work_day_start_hour = e_cal_model_get_work_day_start_hour (model); + work_day_start_minute = e_cal_model_get_work_day_start_minute (model); + /* Set the scroll region of the top canvas */ e_day_view_update_top_scroll (day_view, TRUE); @@ -1785,7 +1710,8 @@ e_day_view_recalc_main_canvas_size (EDayView *day_view) /* Scroll to the start of the working day, if this is the initial allocation. */ if (day_view->scroll_to_work_day) { - scroll_y = e_day_view_convert_time_to_position (day_view, day_view->work_day_start_hour, day_view->work_day_start_minute); + scroll_y = e_day_view_convert_time_to_position ( + day_view, work_day_start_hour, work_day_start_minute); gnome_canvas_scroll_to (GNOME_CANVAS (day_view->main_canvas), 0, scroll_y); day_view->scroll_to_work_day = FALSE; @@ -2165,9 +2091,11 @@ e_day_view_update_event_label (EDayView *day_view, gint event_num) { EDayViewEvent *event; + ECalendarView *cal_view; gboolean free_text = FALSE, editing_event = FALSE, short_event = FALSE; const gchar *summary; gchar *text; + gint time_divisions; gint interval; if (!is_array_index_in_bounds (day_view->events[day], event_num)) @@ -2188,10 +2116,14 @@ e_day_view_update_event_label (EDayView *day_view, interval = event->end_minute - event->start_minute; - if ((interval/day_view->mins_per_row) >= 2) + cal_view = E_CALENDAR_VIEW (day_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); + + if ((interval / time_divisions) >= 2) short_event = FALSE; - else if ((interval%day_view->mins_per_row)==0) { - if (((event->end_minute%day_view->mins_per_row)==0) || ((event->start_minute%day_view->mins_per_row)==0)) { + else if ((interval % time_divisions) == 0) { + if (((event->end_minute % time_divisions) == 0) || + ((event->start_minute % time_divisions) == 0)) { short_event = TRUE; } } else @@ -2417,11 +2349,18 @@ e_day_view_set_selected_time_range_visible (EDayView *day_view, time_t start_time, time_t end_time) { + ECalModel *model; + gint work_day_start_hour; + gint work_day_start_minute; gint start_row, start_col, end_row, end_col; gboolean need_redraw = FALSE, start_in_grid, end_in_grid; g_return_if_fail (E_IS_DAY_VIEW (day_view)); + model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); + work_day_start_hour = e_cal_model_get_work_day_start_hour (model); + work_day_start_minute = e_cal_model_get_work_day_start_minute (model); + /* Set the selection. */ start_in_grid = e_day_view_convert_time_to_grid_position (day_view, start_time, @@ -2439,7 +2378,8 @@ e_day_view_set_selected_time_range_visible (EDayView *day_view, || (start_row == 0 && end_row == day_view->rows - 1)) { end_col = start_col; - start_row = e_day_view_convert_time_to_row (day_view, day_view->work_day_start_hour, day_view->work_day_start_minute); + start_row = e_day_view_convert_time_to_row ( + day_view, work_day_start_hour, work_day_start_minute); start_row = CLAMP (start_row, 0, day_view->rows - 1); end_row = start_row; } @@ -2524,9 +2464,17 @@ e_day_view_set_selected_time_range (ECalendarView *cal_view, time_t start_time, time_t end_time) { + ECalModel *model; + EDayView *day_view; + gint work_day_start_hour; + gint work_day_start_minute; gint start_row, start_col, end_row, end_col; gboolean need_redraw = FALSE, start_in_grid, end_in_grid; - EDayView *day_view = E_DAY_VIEW (cal_view); + + day_view = E_DAY_VIEW (cal_view); + model = e_calendar_view_get_model (cal_view); + work_day_start_hour = e_cal_model_get_work_day_start_hour (model); + work_day_start_minute = e_cal_model_get_work_day_start_minute (model); /* Set the selection. */ start_in_grid = e_day_view_convert_time_to_grid_position (day_view, @@ -2545,7 +2493,8 @@ e_day_view_set_selected_time_range (ECalendarView *cal_view, || (start_row == 0 && end_row == day_view->rows - 1)) { end_col = start_col; - start_row = e_day_view_convert_time_to_row (day_view, day_view->work_day_start_hour, day_view->work_day_start_minute); + start_row = e_day_view_convert_time_to_row ( + day_view, work_day_start_hour, work_day_start_minute); start_row = CLAMP (start_row, 0, day_view->rows - 1); end_row = start_row; } @@ -2721,60 +2670,6 @@ e_day_view_set_days_shown (EDayView *day_view, e_day_view_update_query (day_view); } -gint -e_day_view_get_mins_per_row (EDayView *day_view) -{ - g_return_val_if_fail (E_IS_DAY_VIEW (day_view), -1); - - return day_view->mins_per_row; -} - -void -e_day_view_set_mins_per_row (EDayView *day_view, - gint mins_per_row) -{ - gint day; - - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - - if (mins_per_row != 5 && mins_per_row != 10 && mins_per_row != 15 - && mins_per_row != 30 && mins_per_row != 60) { - g_warning ("Invalid minutes per row setting"); - return; - } - - if (day_view->mins_per_row == mins_per_row) - return; - - day_view->mins_per_row = mins_per_row; - e_day_view_recalc_num_rows (day_view); - - g_object_notify (G_OBJECT (day_view), "mins-per-row"); - - /* If we aren't visible, we'll sort it out later. */ - if (!E_CALENDAR_VIEW (day_view)->in_focus) { - e_day_view_free_events (day_view); - day_view->requires_update = TRUE; - return; - } - - for (day = 0; day < E_DAY_VIEW_MAX_DAYS; day++) - day_view->need_layout[day] = TRUE; - - /* We need to update all the day event labels since the start & end - times may or may not be on row boundaries any more. */ - e_day_view_foreach_event (day_view, - e_day_view_set_show_times_cb, NULL); - - /* We must layout the events before updating the scroll region, since - that will result in a redraw which would crash otherwise. */ - e_day_view_check_layout (day_view); - gtk_widget_queue_draw (day_view->time_canvas); - gtk_widget_queue_draw (day_view->main_canvas); - - e_day_view_update_scroll_regions (day_view); -} - /* This specifies the working days in the week. The value is a bitwise combination of day flags. Defaults to Mon-Fri. */ EDayViewDays @@ -2846,92 +2741,6 @@ e_day_view_recalc_work_week_days_shown (EDayView *day_view) e_day_view_set_days_shown (day_view, days_shown); } -/* The start and end time of the working day. This only affects the background - colors. */ -gint -e_day_view_get_work_day_start_hour (EDayView *day_view) -{ - g_return_val_if_fail (E_IS_DAY_VIEW (day_view), -1); - - return day_view->work_day_start_hour; -} - -void -e_day_view_set_work_day_start_hour (EDayView *day_view, - gint work_day_start_hour) -{ - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - - day_view->work_day_start_hour = work_day_start_hour; - - gtk_widget_queue_draw (day_view->main_canvas); - - g_object_notify (G_OBJECT (day_view), "work-day-start-hour"); -} - -gint -e_day_view_get_work_day_start_minute (EDayView *day_view) -{ - g_return_val_if_fail (E_IS_DAY_VIEW (day_view), -1); - - return day_view->work_day_start_minute; -} - -void -e_day_view_set_work_day_start_minute (EDayView *day_view, - gint work_day_start_minute) -{ - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - - day_view->work_day_start_minute = work_day_start_minute; - - gtk_widget_queue_draw (day_view->main_canvas); - - g_object_notify (G_OBJECT (day_view), "work-day-start-minute"); -} - -gint -e_day_view_get_work_day_end_hour (EDayView *day_view) -{ - g_return_val_if_fail (E_IS_DAY_VIEW (day_view), -1); - - return day_view->work_day_end_hour; -} - -void -e_day_view_set_work_day_end_hour (EDayView *day_view, - gint work_day_end_hour) -{ - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - - day_view->work_day_end_hour = work_day_end_hour; - - gtk_widget_queue_draw (day_view->main_canvas); - - g_object_notify (G_OBJECT (day_view), "work-day-end-hour"); -} - -gint -e_day_view_get_work_day_end_minute (EDayView *day_view) -{ - g_return_val_if_fail (E_IS_DAY_VIEW (day_view), -1); - - return day_view->work_day_end_minute; -} - -void -e_day_view_set_work_day_end_minute (EDayView *day_view, - gint work_day_end_minute) -{ - g_return_if_fail (E_IS_DAY_VIEW (day_view)); - - day_view->work_day_end_minute = work_day_end_minute; - - gtk_widget_queue_draw (day_view->main_canvas); - - g_object_notify (G_OBJECT (day_view), "work-day-end-minute"); -} - /* Force a redraw of the Marcus Bains Lines */ void e_day_view_marcus_bains_update (EDayView *day_view) @@ -3124,13 +2933,18 @@ e_day_view_update_scroll_regions (EDayView *day_view) static void e_day_view_recalc_num_rows (EDayView *day_view) { + ECalendarView *cal_view; + gint time_divisions; gint hours, minutes, total_minutes; + cal_view = E_CALENDAR_VIEW (day_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); + hours = day_view->last_hour_shown - day_view->first_hour_shown; /* This could be negative but it works out OK. */ minutes = day_view->last_minute_shown - day_view->first_minute_shown; total_minutes = hours * 60 + minutes; - day_view->rows = total_minutes / day_view->mins_per_row; + day_view->rows = total_minutes / time_divisions; } /* Converts an hour and minute to a row in the canvas. Note that if we aren't @@ -3141,8 +2955,13 @@ e_day_view_convert_time_to_row (EDayView *day_view, gint hour, gint minute) { + ECalendarView *cal_view; + gint time_divisions; gint total_minutes, start_minute, offset; + cal_view = E_CALENDAR_VIEW (day_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); + total_minutes = hour * 60 + minute; start_minute = day_view->first_hour_shown * 60 + day_view->first_minute_shown; @@ -3150,7 +2969,7 @@ e_day_view_convert_time_to_row (EDayView *day_view, if (offset < 0) return -1; else - return offset / day_view->mins_per_row; + return offset / time_divisions; } /* Converts an hour and minute to a y coordinate in the canvas. */ @@ -3159,14 +2978,19 @@ e_day_view_convert_time_to_position (EDayView *day_view, gint hour, gint minute) { + ECalendarView *cal_view; + gint time_divisions; gint total_minutes, start_minute, offset; + cal_view = E_CALENDAR_VIEW (day_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); + total_minutes = hour * 60 + minute; start_minute = day_view->first_hour_shown * 60 + day_view->first_minute_shown; offset = total_minutes - start_minute; - return offset * day_view->row_height / day_view->mins_per_row; + return offset * day_view->row_height / time_divisions; } static gboolean @@ -3625,10 +3449,15 @@ e_day_view_on_event_click (EDayView *day_view, gint event_y) { EDayViewEvent *event; + ECalendarView *cal_view; GtkLayout *layout; GdkWindow *window; + gint time_divisions; gint tmp_day, row, start_row; + cal_view = E_CALENDAR_VIEW (day_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); + if (!is_array_index_in_bounds (day_view->events[day], event_num)) return; @@ -3671,8 +3500,8 @@ e_day_view_on_event_click (EDayView *day_view, day_view->resize_event_day = day; day_view->resize_event_num = event_num; day_view->resize_drag_pos = pos; - day_view->resize_start_row = event->start_minute / day_view->mins_per_row; - day_view->resize_end_row = (event->end_minute - 1) / day_view->mins_per_row; + day_view->resize_start_row = event->start_minute / time_divisions; + day_view->resize_end_row = (event->end_minute - 1) / time_divisions; if (day_view->resize_end_row < day_view->resize_start_row) day_view->resize_end_row = day_view->resize_start_row; @@ -3698,7 +3527,7 @@ e_day_view_on_event_click (EDayView *day_view, event_x, event_y, &tmp_day, &row, NULL); - start_row = event->start_minute / day_view->mins_per_row; + start_row = event->start_minute / time_divisions; day_view->drag_event_offset = row - start_row; } } @@ -4754,9 +4583,14 @@ e_day_view_add_event (ECalComponent *comp, void e_day_view_check_layout (EDayView *day_view) { + ECalendarView *cal_view; + gint time_divisions; gint day, rows_in_top_display; gint max_cols = -1; + cal_view = E_CALENDAR_VIEW (day_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); + /* Don't bother if we aren't visible. */ if (!E_CALENDAR_VIEW (day_view)->in_focus) { e_day_view_free_events (day_view); @@ -4771,11 +4605,13 @@ e_day_view_check_layout (EDayView *day_view) if (day_view->need_layout[day]) { gint cols; - cols = e_day_view_layout_day_events (day_view->events[day], - day_view->rows, - day_view->mins_per_row, - day_view->cols_per_row[day], - day_view->days_shown == 1 ? -1 : E_DAY_VIEW_MULTI_DAY_MAX_COLUMNS); + cols = e_day_view_layout_day_events ( + day_view->events[day], + day_view->rows, + time_divisions, + day_view->cols_per_row[day], + day_view->days_shown == 1 ? -1 : + E_DAY_VIEW_MULTI_DAY_MAX_COLUMNS); max_cols = MAX (cols, max_cols); } @@ -5462,15 +5298,20 @@ e_day_view_key_press (GtkWidget *widget, GdkEventKey *event) static void e_day_view_goto_start_of_work_day (EDayView *day_view) { - g_return_if_fail (day_view!=NULL); + ECalModel *model; + gint work_day_start_hour; + gint work_day_start_minute; + + model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); + work_day_start_hour = e_cal_model_get_work_day_start_hour (model); + work_day_start_minute = e_cal_model_get_work_day_start_minute (model); if (day_view->selection_in_top_canvas) return; else day_view->selection_start_row = - e_day_view_convert_time_to_row (day_view, - day_view->work_day_start_hour, - day_view->work_day_start_minute); + e_day_view_convert_time_to_row ( + day_view, work_day_start_hour, work_day_start_minute); day_view->selection_end_row = day_view->selection_start_row; e_day_view_ensure_rows_visible (day_view, @@ -5488,13 +5329,20 @@ e_day_view_goto_start_of_work_day (EDayView *day_view) static void e_day_view_goto_end_of_work_day (EDayView *day_view) { + ECalModel *model; + gint work_day_end_hour; + gint work_day_end_minute; + + model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); + work_day_end_hour = e_cal_model_get_work_day_end_hour (model); + work_day_end_minute = e_cal_model_get_work_day_end_minute (model); + if (day_view->selection_in_top_canvas) return; else day_view->selection_start_row = - e_day_view_convert_time_to_row (day_view, - day_view->work_day_end_hour-1, - day_view->work_day_end_minute+30); + e_day_view_convert_time_to_row ( + day_view, work_day_end_hour-1, work_day_end_minute+30); day_view->selection_end_row = day_view->selection_start_row; e_day_view_ensure_rows_visible (day_view, @@ -5512,8 +5360,16 @@ e_day_view_goto_end_of_work_day (EDayView *day_view) static void e_day_view_change_duration_to_start_of_work_day (EDayView *day_view) { + ECalModel *model; + gint work_day_start_hour; + gint work_day_start_minute; + g_return_if_fail (day_view != NULL); + model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); + work_day_start_hour = e_cal_model_get_work_day_start_hour (model); + work_day_start_minute = e_cal_model_get_work_day_start_minute (model); + if (day_view->selection_in_top_canvas) return; else { @@ -5521,9 +5377,7 @@ e_day_view_change_duration_to_start_of_work_day (EDayView *day_view) gint work_start_row,selection_start_row; work_start_row = e_day_view_convert_time_to_row ( - day_view, - day_view->work_day_start_hour, - day_view->work_day_start_minute); + day_view, work_day_start_hour, work_day_start_minute); selection_start_row = day_view->selection_start_row; if (selection_start_row < work_start_row) day_view->selection_end_row = work_start_row - 1; @@ -5545,17 +5399,23 @@ e_day_view_change_duration_to_start_of_work_day (EDayView *day_view) static void e_day_view_change_duration_to_end_of_work_day (EDayView *day_view) { + ECalModel *model; + gint work_day_end_hour; + gint work_day_end_minute; + g_return_if_fail (day_view != NULL); + model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); + work_day_end_hour = e_cal_model_get_work_day_end_hour (model); + work_day_end_minute = e_cal_model_get_work_day_end_minute (model); + if (day_view->selection_in_top_canvas) return; else { gint work_end_row,selection_start_row; work_end_row = e_day_view_convert_time_to_row ( - day_view, - day_view->work_day_end_hour-1, - day_view->work_day_end_minute+30); + day_view, work_day_end_hour-1, work_day_end_minute+30); selection_start_row = day_view->selection_start_row; if (selection_start_row <= work_end_row) day_view->selection_end_row = work_end_row; @@ -6471,10 +6331,12 @@ e_day_view_on_text_item_event (GnomeCanvasItem *item, } static gboolean -e_day_view_event_move (ECalendarView *cal_view, ECalViewMoveDirection direction) +e_day_view_event_move (ECalendarView *cal_view, + ECalViewMoveDirection direction) { EDayViewEvent *event; EDayView *day_view; + gint time_divisions; gint day, event_num, resize_start_row, resize_end_row; time_t start_dt, end_dt; struct icaltimetype start_time, end_time; @@ -6483,6 +6345,8 @@ e_day_view_event_move (ECalendarView *cal_view, ECalViewMoveDirection direction) day = day_view->editing_event_day; event_num = day_view->editing_event_num; + time_divisions = e_calendar_view_get_time_divisions (cal_view); + if ((day == -1) || (day == E_DAY_VIEW_LONG_EVENT)) return FALSE; @@ -6495,8 +6359,8 @@ e_day_view_event_move (ECalendarView *cal_view, ECalViewMoveDirection direction) day_view->resize_event_num = event_num; day_view->resize_bars_event_day = day; day_view->resize_bars_event_num = event_num; - resize_start_row = event->start_minute / day_view->mins_per_row; - resize_end_row = (event->end_minute - 1) / day_view->mins_per_row; + resize_start_row = event->start_minute / time_divisions; + resize_end_row = (event->end_minute - 1) / time_divisions; if (resize_end_row < resize_start_row) resize_end_row = resize_start_row; @@ -6642,6 +6506,8 @@ static void e_day_view_change_event_end_time_up (EDayView *day_view) { EDayViewEvent *event; + ECalendarView *cal_view; + gint time_divisions; gint day, event_num, resize_start_row, resize_end_row; day = day_view->editing_event_day; @@ -6652,14 +6518,17 @@ e_day_view_change_event_end_time_up (EDayView *day_view) if (!is_array_index_in_bounds (day_view->events[day], event_num)) return; + cal_view = E_CALENDAR_VIEW (day_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); + event = &g_array_index (day_view->events[day], EDayViewEvent, event_num); day_view->resize_event_day = day; day_view->resize_event_num = event_num; day_view->resize_bars_event_day = day; day_view->resize_bars_event_num = event_num; - resize_start_row = event->start_minute / day_view->mins_per_row; - resize_end_row = (event->end_minute - 1) / day_view->mins_per_row; + resize_start_row = event->start_minute / time_divisions; + resize_end_row = (event->end_minute - 1) / time_divisions; if (resize_end_row < resize_start_row) resize_end_row = resize_start_row; if (resize_end_row == resize_start_row) @@ -6676,8 +6545,13 @@ static void e_day_view_change_event_end_time_down (EDayView *day_view) { EDayViewEvent *event; + ECalendarView *cal_view; + gint time_divisions; gint day, event_num, resize_start_row, resize_end_row; + cal_view = E_CALENDAR_VIEW (day_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); + day = day_view->editing_event_day; event_num = day_view->editing_event_num; if ((day == -1) || (day == E_DAY_VIEW_LONG_EVENT)) @@ -6692,8 +6566,8 @@ e_day_view_change_event_end_time_down (EDayView *day_view) day_view->resize_event_num = event_num; day_view->resize_bars_event_day = day; day_view->resize_bars_event_num = event_num; - resize_start_row = event->start_minute / day_view->mins_per_row; - resize_end_row = (event->end_minute - 1) / day_view->mins_per_row; + resize_start_row = event->start_minute / time_divisions; + resize_end_row = (event->end_minute - 1) / time_divisions; if (resize_end_row < resize_start_row) resize_end_row = resize_start_row; if (resize_end_row == day_view->rows -1) @@ -6954,14 +6828,19 @@ e_day_view_convert_grid_position_to_time (EDayView *day_view, gint col, gint row) { + ECalendarView *cal_view; + gint time_divisions; struct icaltimetype tt; time_t val; gint minutes; + cal_view = E_CALENDAR_VIEW (day_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); + /* Calulate the number of minutes since the start of the day. */ minutes = day_view->first_hour_shown * 60 + day_view->first_minute_shown - + row * day_view->mins_per_row; + + row * time_divisions; /* A special case for midnight, where we can use the start of the next day. */ @@ -6985,11 +6864,16 @@ e_day_view_convert_time_to_grid_position (EDayView *day_view, gint *col, gint *row) { + ECalendarView *cal_view; struct icaltimetype tt; + gint time_divisions; gint day, minutes; *col = *row = 0; + cal_view = E_CALENDAR_VIEW (day_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); + if (time < day_view->lower || time >= day_view->upper) return FALSE; @@ -7009,7 +6893,7 @@ e_day_view_convert_time_to_grid_position (EDayView *day_view, minutes = tt.hour * 60 + tt.minute; minutes -= day_view->first_hour_shown * 60 + day_view->first_minute_shown; - *row = minutes / day_view->mins_per_row; + *row = minutes / time_divisions; if (*row < 0 || *row >= day_view->rows) return FALSE; @@ -7151,8 +7035,10 @@ e_day_view_get_event_rows (EDayView *day_view, gint *start_row_out, gint *end_row_out) { - gint start_row, end_row; + ECalendarView *cal_view; EDayViewEvent *event; + gint time_divisions; + gint start_row, end_row; g_return_val_if_fail (day >= 0, FALSE); g_return_val_if_fail (day < E_DAY_VIEW_LONG_EVENT, FALSE); @@ -7161,10 +7047,13 @@ e_day_view_get_event_rows (EDayView *day_view, if (!is_array_index_in_bounds (day_view->events[day], event_num)) return FALSE; + cal_view = E_CALENDAR_VIEW (day_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); + event = &g_array_index (day_view->events[day], EDayViewEvent, event_num); - start_row = event->start_minute / day_view->mins_per_row; - end_row = (event->end_minute - 1) / day_view->mins_per_row; + start_row = event->start_minute / time_divisions; + end_row = (event->end_minute - 1) / time_divisions; if (end_row < start_row) end_row = start_row; @@ -7653,10 +7542,15 @@ e_day_view_update_main_canvas_drag (EDayView *day_view, gint day) { EDayViewEvent *event = NULL; + ECalendarView *cal_view; + gint time_divisions; gint cols_in_row, start_col, num_columns, num_rows, start_row, end_row; gdouble item_x, item_y, item_w, item_h; gchar *text; + cal_view = E_CALENDAR_VIEW (day_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); + /* If the position hasn't changed, just return. */ if (day_view->drag_last_day == day && day_view->drag_last_row == row @@ -7687,8 +7581,8 @@ e_day_view_update_main_canvas_drag (EDayView *day_view, event = &g_array_index (day_view->events[day_view->drag_event_day], EDayViewEvent, day_view->drag_event_num); - start_row = event->start_minute / day_view->mins_per_row; - end_row = (event->end_minute - 1) / day_view->mins_per_row; + start_row = event->start_minute / time_divisions; + end_row = (event->end_minute - 1) / time_divisions; if (end_row < start_row) end_row = start_row; @@ -7955,6 +7849,8 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, time_t dt; gboolean all_day_event; ECal *client; + ECalModel *model; + ECalendarView *cal_view; gboolean drag_from_same_window; const guchar *data; gint format, length; @@ -7968,7 +7864,9 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, else drag_from_same_window = FALSE; - client = e_cal_model_get_default_client (e_calendar_view_get_model (E_CALENDAR_VIEW (day_view))); + cal_view = E_CALENDAR_VIEW (day_view); + model = e_calendar_view_get_model (cal_view); + client = e_cal_model_get_default_client (model); /* Note that we only support DnD within the EDayView at present. */ if (length >= 0 && format == 8 && day_view->drag_event_day != -1) { @@ -8128,7 +8026,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, if (!icalcomp) goto error; - default_zone = calendar_config_get_icaltimezone (); + default_zone = e_cal_model_get_timezone (model); /* check the type of the component */ kind = icalcomponent_isa (icalcomp); @@ -8185,10 +8083,13 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, guint time, EDayView *day_view) { + ECalendarView *cal_view; EDayViewEvent *event = NULL; ECalendarViewPosition pos; + gint time_divisions; gint day, row, start_row, end_row, num_rows, scroll_x, scroll_y; gint start_offset, end_offset; + ECalModel *model; ECalComponent *comp; ECalComponentDateTime date; struct icaltimetype itt; @@ -8198,6 +8099,10 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, const guchar *data; gint format, length; + cal_view = E_CALENDAR_VIEW (day_view); + model = e_calendar_view_get_model (cal_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); + data = gtk_selection_data_get_data (selection_data); format = gtk_selection_data_get_format (selection_data); length = gtk_selection_data_get_length (selection_data); @@ -8252,17 +8157,17 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, row -= day_view->drag_event_offset; /* Calculate time offset from start row. */ - start_row = event->start_minute / day_view->mins_per_row; - end_row = (event->end_minute - 1) / day_view->mins_per_row; + start_row = event->start_minute / time_divisions; + end_row = (event->end_minute - 1) / time_divisions; if (end_row < start_row) end_row = start_row; num_rows = end_row - start_row + 1; - start_offset = event->start_minute % day_view->mins_per_row; - end_offset = event->end_minute % day_view->mins_per_row; + start_offset = event->start_minute % time_divisions; + end_offset = event->end_minute % time_divisions; if (end_offset != 0) - end_offset = day_view->mins_per_row - end_offset; + end_offset = time_divisions - end_offset; } client = event->comp_data->client; @@ -8348,7 +8253,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, if (!icalcomp) goto error; - default_zone = calendar_config_get_icaltimezone (); + default_zone = e_cal_model_get_timezone (model); /* check the type of the component */ kind = icalcomponent_isa (icalcomp); diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h index 04f41867d4..8728b24283 100644 --- a/calendar/gui/e-day-view.h +++ b/calendar/gui/e-day-view.h @@ -275,9 +275,6 @@ struct _EDayView { /* The ID of the timeout function for doing a new layout. */ gint layout_timeout_id; - /* The number of minutes per row. 5, 10, 15, 30 or 60. */ - gint mins_per_row; - /* The number of rows needed, depending on the times shown and the minutes per row. */ gint rows; @@ -301,12 +298,6 @@ struct _EDayView { /* Bitwise combination of working days. Defaults to Mon-Fri. */ EDayViewDays working_days; - /* The start and end of the work day, rounded to the nearest row. */ - gint work_day_start_hour; - gint work_day_start_minute; - gint work_day_end_hour; - gint work_day_end_minute; - /* Whether we show the Marcus Bains Line in the main canvas and time canvas. */ gboolean marcus_bains_show_line; gchar *marcus_bains_day_view_color; @@ -506,33 +497,12 @@ gint e_day_view_get_days_shown (EDayView *day_view); void e_day_view_set_days_shown (EDayView *day_view, gint days_shown); -/* This specifies how many minutes are represented by one row in the display. - It can be 60, 30, 15, 10 or 5. The default is 30. */ -gint e_day_view_get_mins_per_row (EDayView *day_view); -void e_day_view_set_mins_per_row (EDayView *day_view, - gint mins_per_row); - /* This specifies the working days in the week. The value is a bitwise combination of day flags. Defaults to Mon-Fri. */ EDayViewDays e_day_view_get_working_days (EDayView *day_view); void e_day_view_set_working_days (EDayView *day_view, EDayViewDays days); -/* The start and end time of the working day. This only affects the background - colors. */ -gint e_day_view_get_work_day_start_hour (EDayView *day_view); -void e_day_view_set_work_day_start_hour (EDayView *day_view, - gint work_day_start_hour); -gint e_day_view_get_work_day_start_minute (EDayView *day_view); -void e_day_view_set_work_day_start_minute (EDayView *day_view, - gint work_day_start_minute); -gint e_day_view_get_work_day_end_hour (EDayView *day_view); -void e_day_view_set_work_day_end_hour (EDayView *day_view, - gint work_day_end_hour); -gint e_day_view_get_work_day_end_minute (EDayView *day_view); -void e_day_view_set_work_day_end_minute (EDayView *day_view, - gint work_day_end_minute); - /* Whether we display the Marcus Bains Line in the main canvas and time canvas. */ void e_day_view_marcus_bains_update (EDayView *day_view); diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c deleted file mode 100644 index 6c96b1a4e6..0000000000 --- a/calendar/gui/e-itip-control.c +++ /dev/null @@ -1,2604 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * JP Rosevear - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "dialogs/delete-error.h" -#include "calendar-config.h" -#include "itip-utils.h" -#include "e-itip-control.h" -#include "common/authentication.h" -#include "widgets/misc/e-web-view.h" -#include - -struct _EItipControlPrivate { - GtkWidget *web_view; - - ESourceList *source_lists[E_CAL_SOURCE_TYPE_LAST]; - GHashTable *ecals[E_CAL_SOURCE_TYPE_LAST]; - - ECal *current_ecal; - ECalSourceType type; - - gchar action; - gboolean rsvp; - - /* Use the gpointer variants for weak pointers. */ - union { - GtkWidget *widget; - gpointer pointer; - } ok; - union { - GtkWidget *widget; - gpointer pointer; - } hbox; - union { - GtkWidget *widget; - gpointer pointer; - } vbox; - - gchar *vcalendar; - ECalComponent *comp; - icalcomponent *main_comp; - icalcomponent *ical_comp; - icalcomponent *top_level; - icalcompiter iter; - icalproperty_method method; - - gint current; - gint total; - - gchar *calendar_uid; - - EAccountList *accounts; - - gchar *from_address; - gchar *delegator_address; - gchar *delegator_name; - gchar *my_address; - gint view_only; -}; - -/* HTML Strings */ -#define HTML_BODY_START "" -#define HTML_SEP "
" -#define HTML_BODY_END "" -#define HTML_FOOTER "" - -static void e_itip_control_dispose (GObject *obj); - -static void find_my_address (EItipControl *itip, icalcomponent *ical_comp, icalparameter_partstat *status); -static gboolean object_requested_cb (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data); -static void ok_clicked_cb (GtkWidget *widget, gpointer data); - -G_DEFINE_TYPE (EItipControl, e_itip_control, GTK_TYPE_VBOX) - -static void -e_itip_control_class_init (EItipControlClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - - object_class->dispose = e_itip_control_dispose; -} - -static void -set_ok_sens (EItipControl *itip) -{ - EItipControlPrivate *priv; - gboolean read_only = TRUE; - - priv = itip->priv; - - if (!priv->ok.widget) - return; - - if (priv->current_ecal) - e_cal_is_read_only (priv->current_ecal, &read_only, NULL); - - gtk_widget_set_sensitive (priv->ok.widget, priv->current_ecal != NULL && !read_only); -} - -static void -cal_opened_cb (ECal *ecal, const GError *error, gpointer data) -{ - EItipControl *itip = data; - EItipControlPrivate *priv; - ESource *source; - ECalSourceType source_type; - - priv = itip->priv; - - source_type = e_cal_get_source_type (ecal); - source = e_cal_get_source (ecal); - - g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, cal_opened_cb, NULL); - - if (error) { - g_hash_table_remove (priv->ecals[source_type], e_source_peek_uid (source)); - - return; - } - - priv->current_ecal = ecal; - set_ok_sens (itip); -} - -typedef void (* EItipControlOpenFunc) (ECal *ecal, const GError *error, gpointer data); - -static ECal * -start_calendar_server (EItipControl *itip, ESource *source, ECalSourceType type, EItipControlOpenFunc func, gpointer data) -{ - EItipControlPrivate *priv; - ECal *ecal; - icaltimezone *zone; - - priv = itip->priv; - - ecal = g_hash_table_lookup (priv->ecals[type], e_source_peek_uid (source)); - if (ecal) { - priv->current_ecal = ecal; - set_ok_sens (itip); - return ecal; - } - - ecal = e_auth_new_cal_from_source (source, type); - - zone = calendar_config_get_icaltimezone (); - e_cal_set_default_timezone (ecal, zone, NULL); - - g_signal_connect (G_OBJECT (ecal), "cal_opened_ex", G_CALLBACK (func), data); - - g_hash_table_insert (priv->ecals[type], g_strdup (e_source_peek_uid (source)), ecal); - - e_cal_open_async (ecal, TRUE); - - return ecal; -} - -static ECal * -start_calendar_server_by_uid (EItipControl *itip, const gchar *uid, ECalSourceType type) -{ - EItipControlPrivate *priv; - gint i; - - priv = itip->priv; - - for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) { - ESource *source; - - source = e_source_list_peek_source_by_uid (priv->source_lists[i], uid); - if (source) - return start_calendar_server (itip, source, type, cal_opened_cb, itip); - } - - return NULL; -} - -typedef struct { - EItipControl *itip; - gchar *uid; - gint count; - gboolean show_selector; -} EItipControlFindData; - -static void -source_changed_cb (ESourceComboBox *escb, EItipControl *itip) -{ - EItipControlPrivate *priv = itip->priv; - ESource *source; - - source = e_source_combo_box_get_active (escb); - - if (priv->ok.widget) - gtk_widget_set_sensitive (priv->ok.widget, FALSE); - - start_calendar_server (itip, source, priv->type, cal_opened_cb, itip); -} - -static void -find_cal_opened_cb (ECal *ecal, const GError *error, gpointer data) -{ - EShell *shell; - EShellSettings *shell_settings; - EItipControlFindData *fd = data; - EItipControlPrivate *priv; - ESource *source; - ECalSourceType source_type; - icalcomponent *icalcomp; - - /* FIXME Pass this in. */ - shell = e_shell_get_default (); - shell_settings = e_shell_get_shell_settings (shell); - - source_type = e_cal_get_source_type (ecal); - source = e_cal_get_source (ecal); - - priv = fd->itip->priv; - - fd->count--; - - g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, find_cal_opened_cb, NULL); - - if (error) { - g_hash_table_remove (priv->ecals[source_type], e_source_peek_uid (source)); - - goto cleanup; - } - - if (e_cal_get_object (ecal, fd->uid, NULL, &icalcomp, NULL)) { - icalcomponent_free (icalcomp); - - priv->current_ecal = ecal; - set_ok_sens (fd->itip); - } - - cleanup: - if (fd->count == 0) { - if (fd->show_selector && !priv->current_ecal && priv->vbox.widget) { - GtkWidget *escb; - const gchar *property_name; - gchar *uid; - - switch (priv->type) { - case E_CAL_SOURCE_TYPE_EVENT: - property_name = "cal-primary-calendar"; - break; - case E_CAL_SOURCE_TYPE_TODO: - property_name = "cal-primary-tasks"; - break; - default: - uid = NULL; - g_return_if_reached (); - } - - uid = e_shell_settings_get_string ( - shell_settings, property_name); - - if (uid) { - source = e_source_list_peek_source_by_uid (priv->source_lists[priv->type], uid); - g_free (uid); - } - - /* Try to create a default if there isn't one */ - if (!source) - source = e_source_list_peek_source_any (priv->source_lists[priv->type]); - - escb = e_source_combo_box_new (priv->source_lists[priv->type]); - g_signal_connect_object ( - escb, "changed", - G_CALLBACK (source_changed_cb), fd->itip, 0); - - gtk_box_pack_start (GTK_BOX (priv->vbox.widget), escb, FALSE, TRUE, 0); - gtk_widget_show (escb); - - /* FIXME What if there is no source? */ - if (source) - e_source_combo_box_set_active (E_SOURCE_COMBO_BOX (escb), source); - } else { - /* FIXME Display error message to user */ - } - - g_free (fd->uid); - g_free (fd); - } -} - -static void -find_server (EItipControl *itip, ECalComponent *comp, gboolean show_selector) -{ - EItipControlPrivate *priv; - EItipControlFindData *fd = NULL; - GSList *groups, *l; - const gchar *uid; - - priv = itip->priv; - - e_cal_component_get_uid (comp, &uid); - - groups = e_source_list_peek_groups (priv->source_lists[priv->type]); - for (l = groups; l; l = l->next) { - ESourceGroup *group; - GSList *sources, *m; - - group = l->data; - - sources = e_source_group_peek_sources (group); - for (m = sources; m; m = m->next) { - ESource *source; - - source = m->data; - - if (!fd) { - fd = g_new0 (EItipControlFindData, 1); - fd->itip = itip; - fd->uid = g_strdup (uid); - fd->show_selector = show_selector; - } - fd->count++; - /* Check this return too? */ - start_calendar_server (itip, source, priv->type, find_cal_opened_cb, fd); - } - } -} - -static void -cleanup_ecal (gpointer data) -{ - ECal *ecal = data; - - /* Clean up any signals */ - g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, cal_opened_cb, NULL); - g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, find_cal_opened_cb, NULL); - - g_object_unref (ecal); -} - -static void -html_destroyed (gpointer data) -{ - EItipControl *itip = data; - EItipControlPrivate *priv; - - priv = itip->priv; - - priv->web_view = NULL; -} - -static void -e_itip_control_init (EItipControl *itip) -{ - EItipControlPrivate *priv; - GtkWidget *scrolled_window; - gint i; - - priv = g_new0 (EItipControlPrivate, 1); - itip->priv = priv; - - /* Addresses */ - priv->accounts = itip_addresses_get (); - - /* Source Lists */ - for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) - priv->source_lists[i] = NULL; - - priv->source_lists[E_CAL_SOURCE_TYPE_EVENT] = e_source_list_new_for_gconf_default ("/apps/evolution/calendar/sources"); - priv->source_lists[E_CAL_SOURCE_TYPE_TODO] = e_source_list_new_for_gconf_default ("/apps/evolution/tasks/sources"); - - /* Initialize the ecal hashes */ - for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) - priv->ecals[i] = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, cleanup_ecal); - priv->current_ecal = NULL; - - /* Other fields to init */ - priv->calendar_uid = NULL; - priv->from_address = NULL; - priv->delegator_address = NULL; - priv->delegator_name = NULL; - priv->my_address = NULL; - priv->view_only = 0; - - /* Html Widget */ - priv->web_view = e_web_view_new (); - gtk_widget_show (priv->web_view); - - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_widget_show (scrolled_window); - - gtk_container_add (GTK_CONTAINER (scrolled_window), priv->web_view); - g_object_weak_ref (G_OBJECT (priv->web_view), (GWeakNotify)html_destroyed, itip); - gtk_widget_set_size_request (scrolled_window, 600, 400); - gtk_box_pack_start (GTK_BOX (itip), scrolled_window, FALSE, FALSE, 6); - - g_signal_connect ( - priv->web_view, "object-requested", - G_CALLBACK (object_requested_cb), itip); - g_signal_connect ( - priv->web_view, "submit", - G_CALLBACK (ok_clicked_cb), itip); -} - -static void -clean_up (EItipControl *itip) -{ - EItipControlPrivate *priv; - - priv = itip->priv; - if (!priv) - return; - - g_free (priv->vcalendar); - priv->vcalendar = NULL; - - if (priv->comp) { - g_object_unref (priv->comp); - priv->comp = NULL; - } - - if (priv->top_level) { - icalcomponent_free (priv->top_level); - priv->top_level = NULL; - } - - if (priv->main_comp) { - icalcomponent_free (priv->main_comp); - priv->main_comp = NULL; - } - priv->ical_comp = NULL; - - priv->current = 0; - priv->total = 0; - - g_free (priv->calendar_uid); - priv->calendar_uid = NULL; - - g_free (priv->from_address); - priv->from_address = NULL; - g_free (priv->delegator_address); - priv->delegator_address = NULL; - g_free (priv->delegator_name); - priv->delegator_name = NULL; - g_free (priv->my_address); - priv->my_address = NULL; -} - -static void -e_itip_control_dispose (GObject *obj) -{ - EItipControl *itip = E_ITIP_CONTROL (obj); - EItipControlPrivate *priv; - - priv = itip->priv; - - if (priv) { - gint i; - - clean_up (itip); - - priv->accounts = NULL; - - for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) { - if (priv->ecals[i]) { - g_hash_table_destroy (priv->ecals[i]); - priv->ecals[i] = NULL; - } - } - - if (priv->web_view) { - g_signal_handlers_disconnect_matched (priv->web_view, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, itip); - g_object_weak_unref (G_OBJECT (priv->web_view), (GWeakNotify)html_destroyed, itip); - } - - g_free (priv); - itip->priv = NULL; - } - - if (G_OBJECT_CLASS (e_itip_control_parent_class)->dispose) - G_OBJECT_CLASS (e_itip_control_parent_class)->dispose (obj); -} - -GtkWidget * -e_itip_control_new (void) -{ - return g_object_new (E_TYPE_ITIP_CONTROL, NULL); -} - -static void -find_my_address (EItipControl *itip, icalcomponent *ical_comp, icalparameter_partstat *status) -{ - EItipControlPrivate *priv; - icalproperty *prop; - gchar *my_alt_address = NULL; - - priv = itip->priv; - - for (prop = icalcomponent_get_first_property (ical_comp, ICAL_ATTENDEE_PROPERTY); - prop != NULL; - prop = icalcomponent_get_next_property (ical_comp, ICAL_ATTENDEE_PROPERTY)) { - icalvalue *value; - icalparameter *param; - const gchar *attendee, *name; - gchar *attendee_clean, *name_clean; - EIterator *it; - - value = icalproperty_get_value (prop); - if (value != NULL) { - attendee = icalvalue_get_string (value); - attendee_clean = g_strdup (itip_strip_mailto (attendee)); - attendee_clean = g_strstrip (attendee_clean); - } else { - attendee = NULL; - attendee_clean = NULL; - } - - param = icalproperty_get_first_parameter (prop, ICAL_CN_PARAMETER); - if (param != NULL) { - name = icalparameter_get_cn (param); - name_clean = g_strdup (name); - name_clean = g_strstrip (name_clean); - } else { - name = NULL; - name_clean = NULL; - } - - if (priv->delegator_address) { - gchar *delegator_clean; - - delegator_clean = g_strdup (itip_strip_mailto (attendee)); - delegator_clean = g_strstrip (delegator_clean); - - /* If the mailer told us the address to use, use that */ - if (delegator_clean != NULL - && !g_ascii_strcasecmp (attendee_clean, delegator_clean)) { - priv->my_address = g_strdup (itip_strip_mailto (priv->delegator_address)); - priv->my_address = g_strstrip (priv->my_address); - - if (status) { - param = icalproperty_get_first_parameter (prop, ICAL_PARTSTAT_PARAMETER); - *status = param ? icalparameter_get_partstat (param) : ICAL_PARTSTAT_NEEDSACTION; - } - } - - g_free (delegator_clean); - } else { - it = e_list_get_iterator ((EList *)priv->accounts); - while (e_iterator_is_valid (it)) { - const EAccount *account = e_iterator_get (it); - - /* Check for a matching address */ - if (attendee_clean != NULL - && !g_ascii_strcasecmp (account->id->address, attendee_clean)) { - priv->my_address = g_strdup (account->id->address); - if (status) { - param = icalproperty_get_first_parameter (prop, ICAL_PARTSTAT_PARAMETER); - *status = param ? icalparameter_get_partstat (param) : ICAL_PARTSTAT_NEEDSACTION; - } - g_free (attendee_clean); - g_free (name_clean); - g_free (my_alt_address); - g_object_unref (it); - return; - } - - /* Check for a matching cname to fall back on */ - if (name_clean != NULL - && !g_ascii_strcasecmp (account->id->name, name_clean)) - my_alt_address = g_strdup (attendee_clean); - - e_iterator_next (it); - } - g_object_unref (it); - } - - g_free (attendee_clean); - g_free (name_clean); - } - - priv->my_address = my_alt_address; - if (status) - *status = ICAL_PARTSTAT_NEEDSACTION; -} - -static icalproperty * -find_attendee (icalcomponent *ical_comp, const gchar *address) -{ - icalproperty *prop; - - if (address == NULL) - return NULL; - - for (prop = icalcomponent_get_first_property (ical_comp, ICAL_ATTENDEE_PROPERTY); - prop != NULL; - prop = icalcomponent_get_next_property (ical_comp, ICAL_ATTENDEE_PROPERTY)) { - icalvalue *value; - const gchar *attendee; - gchar *text; - - value = icalproperty_get_value (prop); - if (!value) - continue; - - attendee = icalvalue_get_string (value); - - text = g_strdup (itip_strip_mailto (attendee)); - text = g_strstrip (text); - if (!g_ascii_strcasecmp (address, text)) { - g_free (text); - break; - } - g_free (text); - } - - return prop; -} - -static void -write_label_piece (EItipControl *itip, ECalComponentDateTime *dt, - GString *buffer, - const gchar *stext, const gchar *etext, - gboolean just_date) -{ - EItipControlPrivate *priv; - struct tm tmp_tm; - gchar time_buf[64]; - icaltimezone *zone = NULL; - const gchar *display_name; - - priv = itip->priv; - - /* UTC times get converted to the current timezone. This is done for - the COMPLETED property, which is always in UTC, and also because - Outlook sends simple events as UTC times. */ - if (dt->value->is_utc) { - zone = calendar_config_get_icaltimezone (); - icaltimezone_convert_time (dt->value, icaltimezone_get_utc_timezone (), zone); - } - - tmp_tm = icaltimetype_to_tm (dt->value); - if (just_date) - tmp_tm.tm_hour = tmp_tm.tm_min = tmp_tm.tm_sec = 0; - - if (stext != NULL) - g_string_append (buffer, stext); - - e_time_format_date_and_time (&tmp_tm, - calendar_config_get_24_hour_format (), - FALSE, FALSE, - time_buf, sizeof (time_buf)); - g_string_append (buffer, time_buf); - - if (!dt->value->is_utc && dt->tzid) { - zone = icalcomponent_get_timezone (priv->top_level, dt->tzid); - } - - /* Output timezone after time, e.g. " America/New_York". */ - if (zone && !just_date) { - /* Note that this returns UTF-8, since all iCalendar data is - UTF-8. But it probably is not translated. */ - display_name = icaltimezone_get_display_name (zone); - if (display_name && *display_name) { - g_string_append_len (buffer, " [", 16); - - /* We check if it is one of our builtin timezone names, - in which case we call gettext to translate it. */ - if (icaltimezone_get_builtin_timezone (display_name)) { - g_string_append_printf (buffer, "%s", _(display_name)); - } else { - g_string_append_printf (buffer, "%s", display_name); - } - g_string_append_len (buffer, "]", 8); - } - } - - if (etext != NULL) - g_string_append (buffer, etext); -} - -static const gchar * -nth (gint n) -{ - if (n == -1) - return "last"; - else if (n < 1 || n > 31) - return "?"; - else - return e_cal_recur_nth[n]; -} - -static const gchar *dayname[] = { - N_("Sunday"), - N_("Monday"), - N_("Tuesday"), - N_("Wednesday"), - N_("Thursday"), - N_("Friday"), - N_("Saturday") -}; - -static const gchar * -get_dayname (struct icalrecurrencetype *r, gint i) -{ - enum icalrecurrencetype_weekday day; - - day = icalrecurrencetype_day_day_of_week (r->by_day[i]); - g_return_val_if_fail (day > 0 && day < 8, "?"); - - return _(dayname[day - 1]); -} - -static void -write_recurrence_piece (EItipControl *itip, ECalComponent *comp, - GString *buffer) -{ - GSList *rrules; - struct icalrecurrencetype *r; - gint i; - - g_string_append_printf (buffer, "%s ", _("Recurring:")); - - if (!e_cal_component_has_simple_recurrence (comp)) { - g_string_append_printf ( - buffer, "%s", _("Yes. (Complex Recurrence)")); - return; - } - - e_cal_component_get_rrule_list (comp, &rrules); - g_return_if_fail (rrules && !rrules->next); - - r = rrules->data; - - switch (r->freq) { - case ICAL_DAILY_RECURRENCE: - /* For Translators: In this can also be translated as "With the period of %d - day/days", where %d is a number. The entire sentence is of the form "Recurring: - Every %d day/days" */ - /* For Translators : 'Every day' is event Recurring every day */ - /* For Translators : 'Every %d days' is event Recurring every %d days. %d is a digit */ - g_string_append_printf ( - buffer, ngettext ("Every day", - "Every %d days", r->interval), - r->interval); - break; - - case ICAL_WEEKLY_RECURRENCE: - if (r->by_day[0] == ICAL_RECURRENCE_ARRAY_MAX) { - /* For Translators: In this can also be translated as "With the period of %d - week/weeks", where %d is a number. The entire sentence is of the form "Recurring: - Every %d week/weeks" */ - /* For Translators : 'Every week' is event Recurring every week */ - /* For Translators : 'Every %d weeks' is event Recurring every %d weeks. %d is a digit */ - g_string_append_printf ( - buffer, ngettext ("Every week", - "Every %d weeks", r->interval), - r->interval); - } else { - /* For Translators : 'Every week on' is event Recurring every week on (dayname) and (dayname) and (dayname) */ - /* For Translators : 'Every %d weeks on' is event Recurring: every %d weeks on (dayname) and (dayname). %d is a digit */ - g_string_append_printf ( - buffer, ngettext ("Every week on ", - "Every %d weeks on ", r->interval), - r->interval); - - for (i = 1; i < 8 && r->by_day[i] != ICAL_RECURRENCE_ARRAY_MAX; i++) { - if (i > 1) - g_string_append_len (buffer, ", ", 2); - g_string_append (buffer, get_dayname (r, i - 1)); - } - if (i > 1) - /* For Translators : 'and' is part of the sentence 'event recurring every week on (dayname) and (dayname)' */ - g_string_append_printf (buffer, "%s", _(" and ")); - g_string_append (buffer, get_dayname (r, i - 1)); - } - break; - - case ICAL_MONTHLY_RECURRENCE: - if (r->by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { - /* For Translators : 'The %s day of' is part of the sentence 'event recurring on the (nth) day of every month.' */ - g_string_append_printf ( - buffer, _("The %s day of "), - nth (r->by_month_day[0])); - } else { - gint pos; - - /* Outlook 2000 uses BYDAY=TU;BYSETPOS=2, and will not - accept BYDAY=2TU. So we now use the same as Outlook - by default. */ - - pos = icalrecurrencetype_day_position (r->by_day[0]); - if (pos == 0) - pos = r->by_set_pos[0]; - - /* For Translators : 'The %s %s of' is part of the sentence 'event recurring on the (nth) (dayname) of every month.' - eg,third monday of every month */ - g_string_append_printf ( - buffer, _("The %s %s of "), - nth (pos), get_dayname (r, 0)); - } - - /* For Translators: In this can also be translated as "With the period of %d - month/months", where %d is a number. The entire sentence is of the form "Recurring: - Every %d month/months" */ - /* For Translators : 'every month' is part of the sentence 'event recurring on the (nth) day of every month.' */ - /* For Translators : 'every %d months' is part of the sentence 'event recurring on the (nth) day of every %d months.' - %d is a digit */ - g_string_append_printf ( - buffer, ngettext ("every month", - "every %d months", r->interval), - r->interval); - break; - - case ICAL_YEARLY_RECURRENCE: - /* For Translators: In this can also be translated as "With the period of %d - year/years", where %d is a number. The entire sentence is of the form "Recurring: - Every %d year/years" */ - /* For Translators : 'Every year' is event Recurring every year */ - /* For Translators : 'Every %d years' is event Recurring every %d years. %d is a digit */ - g_string_append_printf ( - buffer, ngettext ("Every year", - "Every %d years", r->interval), - r->interval); - break; - - default: - g_return_if_reached (); - } - - if (r->count) { - /* For Translators:'a total of %d time' is part of the sentence of the form 'event recurring every day,a total of % time.' %d is a digit*/ - /* For Translators:'a total of %d times' is part of the sentence of the form 'event recurring every day,a total of % times.' %d is a digit*/ - g_string_append_printf ( - buffer, ngettext ("a total of %d time", - "a total of %d times", r->count), r->count); - } else if (!icaltime_is_null_time (r->until)) { - ECalComponentDateTime dt; - - /* FIXME This should get the tzid id, not the whole zone */ - dt.value = &r->until; - dt.tzid = icaltimezone_get_tzid ((icaltimezone *)r->until.zone); - - write_label_piece (itip, &dt, buffer, - /* For Translators : ', ending on' is part of the sentence of the form 'event recurring every day, ending on (date).'*/ - _(", ending on "), NULL, TRUE); - } - - g_string_append_len (buffer, "
", 4); -} - -static void -set_date_label (EItipControl *itip, - GString *buffer, - ECalComponent *comp) -{ - ECalComponentDateTime datetime; - gchar *str; - gboolean wrote = FALSE, task_completed = FALSE; - ECalComponentVType type; - - type = e_cal_component_get_vtype (comp); - - e_cal_component_get_dtstart (comp, &datetime); - if (datetime.value) { - /* For Translators : 'Starts' is part of "Starts: date", showing when the event starts */ - str = g_strdup_printf ("%s:", _("Starts")); - write_label_piece (itip, &datetime, buffer, str, "
", FALSE); - wrote = TRUE; - g_free (str); - } - e_cal_component_free_datetime (&datetime); - - e_cal_component_get_dtend (comp, &datetime); - if (datetime.value) { - /* For Translators : 'Ends' is part of "Ends: date", showing when the event ends */ - str = g_strdup_printf ("%s:", _("Ends")); - write_label_piece (itip, &datetime, buffer, str, "
", FALSE); - wrote = TRUE; - g_free (str); - } - e_cal_component_free_datetime (&datetime); - - if (e_cal_component_has_recurrences (comp)) { - write_recurrence_piece (itip, comp, buffer); - wrote = TRUE; - } - - datetime.tzid = NULL; - e_cal_component_get_completed (comp, &datetime.value); - if (type == E_CAL_COMPONENT_TODO && datetime.value) { - str = g_strdup_printf ("%s:", _("Completed")); - /* Pass TRUE as is_utc, so it gets converted to the current timezone. */ - datetime.value->is_utc = TRUE; - write_label_piece (itip, &datetime, buffer, str, "
", FALSE); - wrote = TRUE; - task_completed = TRUE; - g_free (str); - } - e_cal_component_free_datetime (&datetime); - - e_cal_component_get_due (comp, &datetime); - if (type == E_CAL_COMPONENT_TODO && !task_completed && datetime.value) { - str = g_strdup_printf ("%s:", _("Due")); - write_label_piece (itip, &datetime, buffer, str, "
", FALSE); - wrote = TRUE; - g_free (str); - } - - e_cal_component_free_datetime (&datetime); - - if (wrote) - g_string_append (buffer, "
"); -} - -static void -set_message (GString *buffer, - const gchar *message, - gboolean err) -{ - if (message == NULL) - return; - - if (err) { - g_string_append_printf ( - buffer, "%s" - "

", message); - } else { - g_string_append_printf ( - buffer, "%s

", message); - } -} - -static void -write_error_html (EItipControl *itip, const gchar *itip_err) -{ - EItipControlPrivate *priv; - GString *buffer; - gchar *filename; - - priv = itip->priv; - - buffer = g_string_sized_new (1024); - - g_string_append_printf ( - buffer, "%s", - _("iCalendar Information")); - - g_string_append (buffer, HTML_BODY_START); - - /* The table */ - g_string_append ( - buffer, "
"); - /* The column for the image */ - g_string_append ( - buffer, "", filename); - g_free (filename); - - g_string_append (buffer, "
"); - /* The image */ - filename = e_icon_factory_get_icon_filename ( - "stock_new-meeting", GTK_ICON_SIZE_DIALOG); - g_string_append_printf ( - buffer, ""); - - /* Title */ - set_message (buffer, _("iCalendar Error"), TRUE); - - /* Error */ - g_string_append_printf (buffer, "%s", itip_err); - - /* Clean up */ - g_string_append (buffer, "
"); - - g_string_append (buffer, HTML_BODY_END); - g_string_append (buffer, HTML_FOOTER); - - e_web_view_load_string (E_WEB_VIEW (priv->web_view), buffer->str); - - g_string_free (buffer, TRUE); -} - -static gchar * -dupe_first_bold (const gchar *format, const gchar *organizer, const gchar *delegator) -{ - gchar *tmp, *res; - - tmp = g_strconcat ("", organizer ? organizer : "", "", NULL); - res = g_strdup_printf (format, tmp, delegator ? delegator : ""); - g_free (tmp); - - return res; -} - -static void -write_html (EItipControl *itip, const gchar *itip_desc, const gchar *itip_title, const gchar *options) -{ - EItipControlPrivate *priv; - ECalComponentText text; - ECalComponentOrganizer organizer; - ECalComponentAttendee *attendee; - GSList *attendees, *l = NULL; - GString *buffer; - const gchar *string; - gchar *html; - gchar *filename; - gchar *str; - - priv = itip->priv; - - if (priv->web_view == NULL) - return; - - buffer = g_string_sized_new (4096); - - g_string_append_printf ( - buffer, "%s", - _("iCalendar Information")); - g_string_append (buffer, HTML_BODY_START); - - /* The table */ - g_string_append ( - buffer, ""); - - /* The column for the image */ - g_string_append ( - buffer, "", filename); - g_free (filename); - - g_string_append (buffer, "
"); - - /* The image */ - filename = e_icon_factory_get_icon_filename ( - "stock_new-meeting", GTK_ICON_SIZE_DIALOG); - g_string_append_printf (buffer, ""); - - switch (priv->method) { - case ICAL_METHOD_REFRESH: - case ICAL_METHOD_REPLY: - /* An attendee sent this */ - e_cal_component_get_attendee_list (priv->comp, &attendees); - if (attendees != NULL) { - attendee = attendees->data; - html = dupe_first_bold (itip_desc, - attendee->cn ? - attendee->cn : - itip_strip_mailto (attendee->value), NULL); - } else { - html = dupe_first_bold (itip_desc, _("An unknown person"), NULL); - } - break; - case ICAL_METHOD_REQUEST: - /* The organizer sent this */ - e_cal_component_get_organizer (priv->comp, &organizer); - if (priv->delegator_address != NULL) { - if (organizer.value != NULL) - html = dupe_first_bold (itip_desc, - organizer.cn ? - organizer.cn : - itip_strip_mailto (organizer.value), - priv->delegator_name ? - priv->delegator_name : - priv->delegator_address); - else - html = dupe_first_bold (itip_desc, _("An unknown person"), - priv->delegator_name ? - priv->delegator_name : - priv->delegator_address); - } else { - if (organizer.value != NULL) - html = dupe_first_bold (itip_desc, - organizer.cn ? - organizer.cn : - itip_strip_mailto (organizer.value), NULL); - else - html = dupe_first_bold (itip_desc, _("An unknown person"), NULL); - } - - break; - - case ICAL_METHOD_PUBLISH: - case ICAL_METHOD_ADD: - case ICAL_METHOD_CANCEL: - default: - /* The organizer sent this */ - e_cal_component_get_organizer (priv->comp, &organizer); - if (organizer.value != NULL) - html = dupe_first_bold (itip_desc, - organizer.cn ? - organizer.cn : - itip_strip_mailto (organizer.value), NULL); - else - html = dupe_first_bold (itip_desc, _("An unknown person"), NULL); - break; - } - g_string_append_printf (buffer, "%s", html); - g_free (html); - - g_string_append (buffer, "
"); - /* Describe what the user can do */ - g_string_append ( - buffer, _("Please review the following information, " - "and then select an action from the menu below.")); - - /* Separator */ - g_string_append (buffer, HTML_SEP); - - /* Title */ - set_message (buffer, itip_title, FALSE); - - /* Date information */ - set_date_label (itip, buffer, priv->comp); - - /* Summary */ - e_cal_component_get_summary (priv->comp, &text); - /* Translators: "None" used as a default value for events without Summary received by mail */ - str = g_strdup_printf ("%s", C_("cal-itip", "None")); - - html = text.value ? e_text_to_html_full (text.value, E_TEXT_TO_HTML_CONVERT_NL, 0) : str; - g_string_append_printf ( - buffer, "%s
%s

", _("Summary:"), html); - g_free (str); - if (text.value) - g_free (html); - - /* Location */ - e_cal_component_get_location (priv->comp, &string); - if (string != NULL) { - html = e_text_to_html_full (string, E_TEXT_TO_HTML_CONVERT_NL, 0); - g_string_append_printf ( - buffer, "%s
%s

", - _("Location:"), html); - g_free (html); - } - - /* Status */ - if (priv->method == ICAL_METHOD_REPLY) { - GSList *alist; - - e_cal_component_get_attendee_list (priv->comp, &alist); - - if (alist != NULL) { - ECalComponentAttendee *a = alist->data; - - g_string_append_printf ( - buffer, "%s
", _("Status:")); - - switch (a->status) { - case ICAL_PARTSTAT_ACCEPTED: - g_string_append_printf ( - buffer, "%s

", - _("Accepted")); - break; - case ICAL_PARTSTAT_TENTATIVE: - g_string_append_printf ( - buffer, "%s

", - _("Tentatively Accepted")); - break; - case ICAL_PARTSTAT_DECLINED: - g_string_append_printf ( - buffer, "%s

", - _("Declined")); - break; - default: - g_string_append_printf ( - buffer, "%s

", - _("Unknown")); - } - } - - e_cal_component_free_attendee_list (alist); - } - - /* Description */ - e_cal_component_get_description_list (priv->comp, &l); - if (l) - text = *((ECalComponentText *)l->data); - - if (l && text.value) { - html = e_text_to_html_full ( - text.value, E_TEXT_TO_HTML_CONVERT_NL, 0); - g_string_append_printf ( - buffer, "%s
%s", - _("Description:"), html); - g_free (html); - } - e_cal_component_free_text_list (l); - - /* Separator */ - g_string_append (buffer, HTML_SEP); - - /* Options */ - if (!e_itip_control_get_view_only (itip)) { - if (options != NULL) { - g_string_append ( - buffer, "
"); - g_string_append_printf (buffer, "%s", options); - } - } - - g_string_append (buffer, "
"); - - g_string_append (buffer, HTML_BODY_END); - g_string_append (buffer, HTML_FOOTER); - - e_web_view_load_string (E_WEB_VIEW (priv->web_view), buffer->str); - - g_string_free (buffer, TRUE); -} - -static gchar * -get_publish_options (void) -{ - return g_strdup_printf (""); -} - -static gchar * -get_request_options (void) -{ - return g_strdup_printf (""); -} - -static gchar * -get_request_fb_options (void) -{ - return g_strdup_printf (""); -} - -static gchar * -get_reply_options (void) -{ - return g_strdup_printf (""); -} - -static gchar * -get_refresh_options (void) -{ - return g_strdup_printf (""); -} - -static gchar * -get_cancel_options (gboolean found, icalcomponent_kind kind) -{ - if (!found) { - switch (kind) { - case ICAL_VEVENT_COMPONENT: - return g_strdup_printf ("%s", _("The meeting has been canceled, however it could not be found in your calendars")); - case ICAL_VTODO_COMPONENT: - return g_strdup_printf ("%s", _("The task has been canceled, however it could not be found in your task lists")); - default: - g_return_val_if_reached (NULL); - } - } - - return g_strdup_printf (""); -} - -static ECalComponent * -get_real_item (EItipControl *itip) -{ - EItipControlPrivate *priv; - ECalComponent *comp; - icalcomponent *icalcomp; - gboolean found = FALSE; - const gchar *uid; - - priv = itip->priv; - - e_cal_component_get_uid (priv->comp, &uid); - - found = e_cal_get_object (priv->current_ecal, uid, NULL, &icalcomp, NULL); - if (!found) - return NULL; - - comp = e_cal_component_new (); - if (!e_cal_component_set_icalcomponent (comp, icalcomp)) { - g_object_unref (comp); - icalcomponent_free (icalcomp); - return NULL; - } - - return comp; -} - -static void -adjust_item (EItipControl *itip, ECalComponent *comp) -{ - ECalComponent *real_comp; - - real_comp = get_real_item (itip); - if (real_comp != NULL) { - ECalComponentText text; - const gchar *string; - GSList *l; - - e_cal_component_get_summary (real_comp, &text); - e_cal_component_set_summary (comp, &text); - e_cal_component_get_location (real_comp, &string); - e_cal_component_set_location (comp, string); - e_cal_component_get_description_list (real_comp, &l); - e_cal_component_set_description_list (comp, l); - e_cal_component_free_text_list (l); - - g_object_unref (real_comp); - } else { - ECalComponentText text = {_("Unknown"), NULL}; - - e_cal_component_set_summary (comp, &text); - } -} - -static void -show_current_event (EItipControl *itip) -{ - EItipControlPrivate *priv; - const gchar *itip_title, *itip_desc; - gchar *options; - gboolean show_selector = FALSE; - - priv = itip->priv; - - priv->type = E_CAL_SOURCE_TYPE_EVENT; - - switch (priv->method) { - case ICAL_METHOD_PUBLISH: - itip_desc = _("%s has published meeting information."); - itip_title = _("Meeting Information"); - options = get_publish_options (); - show_selector = TRUE; - break; - case ICAL_METHOD_REQUEST: - if (priv->delegator_address != NULL) - itip_desc = _("%s requests the presence of %s at a meeting."); - else - itip_desc = _("%s requests your presence at a meeting."); - itip_title = _("Meeting Proposal"); - options = get_request_options (); - show_selector = TRUE; - break; - case ICAL_METHOD_ADD: - /* FIXME Whats going on here? */ - itip_desc = _("%s wishes to be added to an existing meeting."); - itip_title = _("Meeting Update"); - options = get_publish_options (); - break; - case ICAL_METHOD_REFRESH: - itip_desc = _("%s wishes to receive the latest meeting information."); - itip_title = _("Meeting Update Request"); - options = get_refresh_options (); - - /* Provide extra info, since its not in the component */ - adjust_item (itip, priv->comp); - break; - case ICAL_METHOD_REPLY: - itip_desc = _("%s has replied to a meeting request."); - itip_title = _("Meeting Reply"); - options = get_reply_options (); - - /* Provide extra info, since might not be in the component */ - adjust_item (itip, priv->comp); - break; - case ICAL_METHOD_CANCEL: - itip_desc = _("%s has canceled a meeting."); - itip_title = _("Meeting Cancelation"); - /* FIXME priv->current_ecal will always be NULL so the - * user won't see an error message, the OK button will - * just be de-sensitized */ - options = get_cancel_options (TRUE, ICAL_VEVENT_COMPONENT); - - /* Provide extra info, since might not be in the component */ - adjust_item (itip, priv->comp); - break; - default: - itip_desc = _("%s has sent an unintelligible message."); - itip_title = _("Bad Meeting Message"); - options = NULL; - } - - write_html (itip, itip_desc, itip_title, options); - g_free (options); - - if (priv->calendar_uid) - priv->current_ecal = start_calendar_server_by_uid (itip, priv->calendar_uid, priv->type); - else - find_server (itip, priv->comp, show_selector); -} - -static void -show_current_todo (EItipControl *itip) -{ - EItipControlPrivate *priv; - const gchar *itip_title, *itip_desc; - gchar *options; - gboolean show_selector = FALSE; - - priv = itip->priv; - - priv->type = E_CAL_SOURCE_TYPE_TODO; - - switch (priv->method) { - case ICAL_METHOD_PUBLISH: - itip_desc = _("%s has published task information."); - itip_title = _("Task Information"); - options = get_publish_options (); - show_selector = TRUE; - break; - case ICAL_METHOD_REQUEST: - /* FIXME Does this need to handle like events above? */ - if (priv->delegator_address != NULL) - itip_desc = _("%s requests %s to perform a task."); - else - itip_desc = _("%s requests you perform a task."); - itip_title = _("Task Proposal"); - options = get_request_options (); - show_selector = TRUE; - break; - case ICAL_METHOD_ADD: - /* FIXME Whats going on here? */ - itip_desc = _("%s wishes to be added to an existing task."); - itip_title = _("Task Update"); - options = get_publish_options (); - break; - case ICAL_METHOD_REFRESH: - itip_desc = _("%s wishes to receive the latest task information."); - itip_title = _("Task Update Request"); - options = get_refresh_options (); - - /* Provide extra info, since its not in the component */ - adjust_item (itip, priv->comp); - break; - case ICAL_METHOD_REPLY: - itip_desc = _("%s has replied to a task assignment."); - itip_title = _("Task Reply"); - options = get_reply_options (); - - /* Provide extra info, since might not be in the component */ - adjust_item (itip, priv->comp); - break; - case ICAL_METHOD_CANCEL: - itip_desc = _("%s has canceled a task."); - itip_title = _("Task Cancelation"); - /* FIXME priv->current_ecal will always be NULL so the - * user won't see an error message, the OK button will - * just be de-sensitized */ - options = get_cancel_options (TRUE, ICAL_VTODO_COMPONENT); - - /* Provide extra info, since might not be in the component */ - adjust_item (itip, priv->comp); - break; - default: - itip_desc = _("%s has sent an unintelligible message."); - itip_title = _("Bad Task Message"); - options = NULL; - } - - write_html (itip, itip_desc, itip_title, options); - g_free (options); - - if (priv->calendar_uid) - priv->current_ecal = start_calendar_server_by_uid (itip, priv->calendar_uid, priv->type); - else - find_server (itip, priv->comp, show_selector); -} - -static void -show_current_freebusy (EItipControl *itip) -{ - EItipControlPrivate *priv; - const gchar *itip_title, *itip_desc; - gchar *options; - - priv = itip->priv; - - switch (priv->method) { - case ICAL_METHOD_PUBLISH: - itip_desc = _("%s has published free/busy information."); - itip_title = _("Free/Busy Information"); - options = NULL; - break; - case ICAL_METHOD_REQUEST: - itip_desc = _("%s requests your free/busy information."); - itip_title = _("Free/Busy Request"); - options = get_request_fb_options (); - break; - case ICAL_METHOD_REPLY: - itip_desc = _("%s has replied to a free/busy request."); - itip_title = _("Free/Busy Reply"); - options = NULL; - break; - default: - itip_desc = _("%s has sent an unintelligible message."); - itip_title = _("Bad Free/Busy Message"); - options = NULL; - } - - write_html (itip, itip_desc, itip_title, options); - g_free (options); -} - -static icalcomponent * -get_next (icalcompiter *iter) -{ - icalcomponent *ret = NULL; - icalcomponent_kind kind; - - do { - icalcompiter_next (iter); - ret = icalcompiter_deref (iter); - if (ret == NULL) - break; - kind = icalcomponent_isa (ret); - } while (ret != NULL - && kind != ICAL_VEVENT_COMPONENT - && kind != ICAL_VTODO_COMPONENT - && kind != ICAL_VFREEBUSY_COMPONENT); - - return ret; -} - -static void -show_current (EItipControl *itip) -{ - EItipControlPrivate *priv; - ECalComponentVType type; - icalcomponent *alarm_comp; - icalcompiter alarm_iter; - icalproperty *prop; - - priv = itip->priv; - - g_object_ref (itip); - - if (priv->comp) - g_object_unref (priv->comp); - priv->current_ecal = NULL; - - /* Determine any delegate sections */ - prop = icalcomponent_get_first_property (priv->ical_comp, ICAL_X_PROPERTY); - while (prop) { - const gchar *x_name, *x_val; - - x_name = icalproperty_get_x_name (prop); - x_val = icalproperty_get_x (prop); - - if (!strcmp (x_name, "X-EVOLUTION-DELEGATOR-CALENDAR-UID")) - e_itip_control_set_calendar_uid (itip, x_val); - else if (!strcmp (x_name, "X-EVOLUTION-DELEGATOR-CALENDAR-URI")) - g_warning (G_STRLOC ": X-EVOLUTION-DELEGATOR-CALENDAR-URI used"); - else if (!strcmp (x_name, "X-EVOLUTION-DELEGATOR-ADDRESS")) - e_itip_control_set_delegator_address (itip, x_val); - else if (!strcmp (x_name, "X-EVOLUTION-DELEGATOR-NAME")) - e_itip_control_set_delegator_name (itip, x_val); - - prop = icalcomponent_get_next_property (priv->ical_comp, ICAL_X_PROPERTY); - } - - /* Strip out alarms for security purposes */ - alarm_iter = icalcomponent_begin_component (priv->ical_comp, ICAL_VALARM_COMPONENT); - while ((alarm_comp = icalcompiter_deref (&alarm_iter)) != NULL) { - icalcompiter_next (&alarm_iter); - - icalcomponent_remove_component (priv->ical_comp, alarm_comp); - icalcomponent_free (alarm_comp); - } - - priv->comp = e_cal_component_new (); - if (!e_cal_component_set_icalcomponent (priv->comp, priv->ical_comp)) { - write_error_html (itip, _("The message does not appear to be properly formed")); - g_object_unref (priv->comp); - priv->comp = NULL; - g_object_unref (itip); - return; - }; - - /* Add default reminder if the config says so */ - if (calendar_config_get_use_default_reminder ()) { - ECalComponentAlarm *acomp; - gint interval; - EDurationType units; - ECalComponentAlarmTrigger trigger; - - interval = calendar_config_get_default_reminder_interval (); - units = calendar_config_get_default_reminder_units (); - - acomp = e_cal_component_alarm_new (); - - e_cal_component_alarm_set_action (acomp, E_CAL_COMPONENT_ALARM_DISPLAY); - - trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START; - memset (&trigger.u.rel_duration, 0, sizeof (trigger.u.rel_duration)); - - trigger.u.rel_duration.is_neg = TRUE; - - switch (units) { - case E_DURATION_MINUTES: - trigger.u.rel_duration.minutes = interval; - break; - case E_DURATION_HOURS: - trigger.u.rel_duration.hours = interval; - break; - case E_DURATION_DAYS: - trigger.u.rel_duration.days = interval; - break; - default: - g_return_if_reached (); - } - - e_cal_component_alarm_set_trigger (acomp, trigger); - e_cal_component_add_alarm (priv->comp, acomp); - - e_cal_component_alarm_free (acomp); - } - - type = e_cal_component_get_vtype (priv->comp); - - switch (type) { - case E_CAL_COMPONENT_EVENT: - show_current_event (itip); - break; - case E_CAL_COMPONENT_TODO: - show_current_todo (itip); - break; - case E_CAL_COMPONENT_FREEBUSY: - show_current_freebusy (itip); - break; - default: - write_error_html (itip, _("The message contains only unsupported requests.")); - } - - find_my_address (itip, priv->ical_comp, NULL); - - g_object_unref (itip); -} - -void -e_itip_control_set_data (EItipControl *itip, const gchar *text) -{ - EItipControlPrivate *priv; - icalproperty *prop; - icalcomponent_kind kind = ICAL_NO_COMPONENT; - icalcomponent *tz_comp; - icalcompiter tz_iter; - - priv = itip->priv; - if (priv == NULL) - return; - - clean_up (itip); - - if (text == NULL || *text == '\0') { - e_web_view_clear (E_WEB_VIEW (priv->web_view)); - return; - } - - priv->vcalendar = g_strdup (text); - priv->top_level = e_cal_util_new_top_level (); - - priv->main_comp = icalparser_parse_string (priv->vcalendar); - if (priv->main_comp == NULL || !is_icalcomp_valid (priv->main_comp)) { - write_error_html (itip, _("The attachment does not contain a valid calendar message")); - - if (priv->main_comp) { - icalcomponent_free (priv->main_comp); - priv->main_comp = NULL; - } - - return; - } - - prop = icalcomponent_get_first_property (priv->main_comp, ICAL_METHOD_PROPERTY); - if (prop == NULL) { - priv->method = ICAL_METHOD_PUBLISH; - } else { - priv->method = icalproperty_get_method (prop); - } - - tz_iter = icalcomponent_begin_component (priv->main_comp, ICAL_VTIMEZONE_COMPONENT); - while ((tz_comp = icalcompiter_deref (&tz_iter)) != NULL) { - icalcomponent *clone; - - clone = icalcomponent_new_clone (tz_comp); - icalcomponent_add_component (priv->top_level, clone); - - icalcompiter_next (&tz_iter); - } - - priv->iter = icalcomponent_begin_component (priv->main_comp, ICAL_ANY_COMPONENT); - priv->ical_comp = icalcompiter_deref (&priv->iter); - if (priv->ical_comp != NULL) { - kind = icalcomponent_isa (priv->ical_comp); - if (kind != ICAL_VEVENT_COMPONENT - && kind != ICAL_VTODO_COMPONENT - && kind != ICAL_VFREEBUSY_COMPONENT) - priv->ical_comp = get_next (&priv->iter); - } - - if (priv->ical_comp == NULL) { - write_error_html (itip, _("The attachment has no viewable calendar items")); - return; - } - - priv->total = icalcomponent_count_components (priv->main_comp, ICAL_VEVENT_COMPONENT); - priv->total += icalcomponent_count_components (priv->main_comp, ICAL_VTODO_COMPONENT); - priv->total += icalcomponent_count_components (priv->main_comp, ICAL_VFREEBUSY_COMPONENT); - - if (priv->total > 0) - priv->current = 1; - else - priv->current = 0; - - show_current (itip); -} - -gchar * -e_itip_control_get_data (EItipControl *itip) -{ - EItipControlPrivate *priv; - - priv = itip->priv; - - return g_strdup (priv->vcalendar); -} - -gint -e_itip_control_get_data_size (EItipControl *itip) -{ - EItipControlPrivate *priv; - - priv = itip->priv; - - if (priv->vcalendar == NULL) - return 0; - - return strlen (priv->vcalendar); -} - -void -e_itip_control_set_from_address (EItipControl *itip, const gchar *address) -{ - EItipControlPrivate *priv; - - priv = itip->priv; - - if (priv->from_address) - g_free (priv->from_address); - - priv->from_address = g_strdup (address); -} - -const gchar * -e_itip_control_get_from_address (EItipControl *itip) -{ - EItipControlPrivate *priv; - - priv = itip->priv; - - return priv->from_address; -} - -void -e_itip_control_set_view_only (EItipControl *itip, gint view_only) -{ - EItipControlPrivate *priv; - - priv = itip->priv; - - priv->view_only = view_only; -} - -gint -e_itip_control_get_view_only (EItipControl *itip) -{ - EItipControlPrivate *priv; - - priv = itip->priv; - - return priv->view_only; -} - -void -e_itip_control_set_delegator_address (EItipControl *itip, const gchar *address) -{ - EItipControlPrivate *priv; - - priv = itip->priv; - - if (priv->delegator_address) - g_free (priv->delegator_address); - - priv->delegator_address = g_strdup (address); -} - -const gchar * -e_itip_control_get_delegator_address (EItipControl *itip) -{ - EItipControlPrivate *priv; - - priv = itip->priv; - - return priv->delegator_address; -} - -void -e_itip_control_set_delegator_name (EItipControl *itip, const gchar *name) -{ - EItipControlPrivate *priv; - - priv = itip->priv; - - if (priv->delegator_name) - g_free (priv->delegator_name); - - priv->delegator_name = g_strdup (name); -} - -const gchar * -e_itip_control_get_delegator_name (EItipControl *itip) -{ - EItipControlPrivate *priv; - - priv = itip->priv; - - return priv->delegator_name; -} - -void -e_itip_control_set_calendar_uid (EItipControl *itip, const gchar *uri) -{ - EItipControlPrivate *priv; - - priv = itip->priv; - - if (priv->calendar_uid) - g_free (priv->calendar_uid); - - priv->calendar_uid = g_strdup (uri); -} - -const gchar * -e_itip_control_get_calendar_uid (EItipControl *itip) -{ - EItipControlPrivate *priv; - - priv = itip->priv; - - return priv->calendar_uid; -} - -static gboolean -change_status (icalcomponent *ical_comp, const gchar *address, icalparameter_partstat status) -{ - icalproperty *prop; - - prop = find_attendee (ical_comp, address); - if (prop) { - icalparameter *param; - - icalproperty_remove_parameter (prop, ICAL_PARTSTAT_PARAMETER); - param = icalparameter_new_partstat (status); - icalproperty_add_parameter (prop, param); - } else { - icalparameter *param; - - if (address != NULL) { - prop = icalproperty_new_attendee (address); - icalcomponent_add_property (ical_comp, prop); - - param = icalparameter_new_role (ICAL_ROLE_OPTPARTICIPANT); - icalproperty_add_parameter (prop, param); - - param = icalparameter_new_partstat (status); - icalproperty_add_parameter (prop, param); - } else { - EAccount *a; - - a = itip_addresses_get_default (); - - prop = icalproperty_new_attendee (a->id->address); - icalcomponent_add_property (ical_comp, prop); - - param = icalparameter_new_cn (a->id->name); - icalproperty_add_parameter (prop, param); - - param = icalparameter_new_role (ICAL_ROLE_REQPARTICIPANT); - icalproperty_add_parameter (prop, param); - - param = icalparameter_new_partstat (status); - icalproperty_add_parameter (prop, param); - } - } - - return TRUE; -} - -static void -update_item (EItipControl *itip) -{ - EItipControlPrivate *priv; - struct icaltimetype stamp; - gchar *str; - icalproperty *prop; - icalcomponent *clone; - GtkWidget *dialog; - GError *error = NULL; - - priv = itip->priv; - - /* Set X-MICROSOFT-CDO-REPLYTIME to record the time at which - * the user accepted/declined the request. (Outlook ignores - * SEQUENCE in REPLY reponses and instead requires that each - * updated response have a later REPLYTIME than the previous - * one.) This also ends up getting saved in our own copy of - * the meeting, though there's currently no way to see that - * information (unless it's being saved to an Exchange folder - * and you then look at it in Outlook). - */ - stamp = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ()); - str = icaltime_as_ical_string_r (stamp); - prop = icalproperty_new_x (str); - g_free (str); - icalproperty_set_x_name (prop, "X-MICROSOFT-CDO-REPLYTIME"); - icalcomponent_add_property (priv->ical_comp, prop); - - clone = icalcomponent_new_clone (priv->ical_comp); - icalcomponent_add_component (priv->top_level, clone); - icalcomponent_set_method (priv->top_level, priv->method); - - if (!e_cal_receive_objects (priv->current_ecal, priv->top_level, &error)) { - dialog = gtk_message_dialog_new ( - NULL, 0, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - "%s", error->message); - g_error_free (error); - } else { - dialog = gtk_message_dialog_new ( - NULL, 0, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - "%s", _("Update complete\n")); - } - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - - icalcomponent_remove_component (priv->top_level, clone); - icalcomponent_free (clone); -} - -static void -update_attendee_status (EItipControl *itip) -{ - EItipControlPrivate *priv; - ECalComponent *comp = NULL; - icalcomponent *icalcomp = NULL; - const gchar *uid; - GtkWidget *dialog; - GError *error = NULL; - - priv = itip->priv; - - /* Obtain our version */ - e_cal_component_get_uid (priv->comp, &uid); - if (e_cal_get_object (priv->current_ecal, uid, NULL, &icalcomp, NULL)) { - GSList *attendees; - - comp = e_cal_component_new (); - if (!e_cal_component_set_icalcomponent (comp, icalcomp)) { - icalcomponent_free (icalcomp); - - dialog = gtk_message_dialog_new ( - NULL, 0, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_OK, - "%s", _("Object is invalid and " - "cannot be updated\n")); - goto run; - } else { - e_cal_component_get_attendee_list (priv->comp, &attendees); - if (attendees != NULL) { - ECalComponentAttendee *a = attendees->data; - icalproperty *prop; - - prop = find_attendee (icalcomp, itip_strip_mailto (a->value)); - - if (prop == NULL) { - gint response; - - dialog = gtk_message_dialog_new ( - NULL, GTK_DIALOG_MODAL, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_YES_NO, - "%s", _("This response is not from a " - "current attendee. Add as an attendee?")); - response = gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - - if (response == GTK_RESPONSE_YES) { - change_status (icalcomp, - itip_strip_mailto (a->value), - a->status); - e_cal_component_rescan (comp); - } else { - goto cleanup; - } - } else if (a->status == ICAL_PARTSTAT_NONE || a->status == ICAL_PARTSTAT_X) { - dialog = gtk_message_dialog_new ( - NULL, 0, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_OK, - "%s", _("Attendee status could not be " - "updated because of an invalid status!\n")); - goto run; - } else { - change_status (icalcomp, - itip_strip_mailto (a->value), - a->status); - e_cal_component_rescan (comp); - } - } - } - - if (!e_cal_modify_object (priv->current_ecal, icalcomp, CALOBJ_MOD_ALL, &error)) { - dialog = gtk_message_dialog_new ( - NULL, 0, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_OK, - "%s", error->message); - g_error_free (error); - } else { - dialog = gtk_message_dialog_new ( - NULL, 0, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - "%s", _("Attendee status updated\n")); - } - } else { - dialog = gtk_message_dialog_new ( - NULL, 0, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_OK, - "%s", _("Attendee status can not be updated " - "because the item no longer exists")); - } - - run: - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - - cleanup: - if (comp != NULL) - g_object_unref (comp); -} - -static void -send_item (EItipControl *itip) -{ - EItipControlPrivate *priv; - ECalComponent *comp; - GtkWidget *dialog; - - priv = itip->priv; - - comp = get_real_item (itip); - - if (comp != NULL) { - itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, priv->current_ecal, NULL, NULL, NULL, TRUE, FALSE); - g_object_unref (comp); - dialog = gtk_message_dialog_new ( - NULL, 0, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - "%s", _("Item sent!\n")); - } else { - dialog = gtk_message_dialog_new ( - NULL, 0, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_OK, - "%s", _("The item could not be sent!\n")); - } - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); -} - -static void -send_freebusy (EItipControl *itip) -{ - EItipControlPrivate *priv; - ECalComponentDateTime datetime; - time_t start, end; - GtkWidget *dialog; - GList *comp_list = NULL; - icaltimezone *zone; - - priv = itip->priv; - - e_cal_component_get_dtstart (priv->comp, &datetime); - if (datetime.tzid) { - zone = icalcomponent_get_timezone (priv->top_level, - datetime.tzid); - } else { - zone = NULL; - } - start = icaltime_as_timet_with_zone (*datetime.value, zone); - e_cal_component_free_datetime (&datetime); - - e_cal_component_get_dtend (priv->comp, &datetime); - if (datetime.tzid) { - zone = icalcomponent_get_timezone (priv->top_level, - datetime.tzid); - } else { - zone = NULL; - } - end = icaltime_as_timet_with_zone (*datetime.value, zone); - e_cal_component_free_datetime (&datetime); - - if (e_cal_get_free_busy (priv->current_ecal, NULL, start, end, &comp_list, NULL)) { - GList *l; - - for (l = comp_list; l; l = l->next) { - ECalComponent *comp = E_CAL_COMPONENT (l->data); - itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, priv->current_ecal, NULL, NULL, NULL, TRUE, FALSE); - - g_object_unref (comp); - } - dialog = gtk_message_dialog_new ( - NULL, 0, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - "%s", _("Item sent!\n")); - - g_list_free (comp_list); - } else { - dialog = gtk_message_dialog_new ( - NULL, 0, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_OK, - "%s", _("The item could not be sent!\n")); - } - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); -} - -static GtkWidget * -create_combo_box (void) -{ - GtkComboBox *combo; - GtkCellRenderer *cell; - GtkListStore *store; - - combo = GTK_COMBO_BOX (gtk_combo_box_new ()); - - store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); - gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store)); - g_object_unref (store); - - gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo)); - - cell = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell, - "text", 0, - NULL); - - return GTK_WIDGET (combo); -} - -static void -option_activated_cb (GtkWidget *widget, gpointer data) -{ - EItipControl *itip = E_ITIP_CONTROL (data); - EItipControlPrivate *priv; - GtkTreeIter iter; - gint act; - - priv = itip->priv; - - g_return_if_fail (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)); - - gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (widget)), &iter, 1, &act, -1); - - priv->action = act; -} - -static void -add_option (EItipControl *itip, GtkWidget *combo, const gchar *text, gchar action) -{ - GtkTreeIter iter; - GtkListStore *store; - - store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (combo))); - - gtk_list_store_append (store, &iter); - gtk_list_store_set ( - store, &iter, - 0, text, - 1, (gint) action, - -1); - - if (gtk_combo_box_get_active (GTK_COMBO_BOX (combo)) == -1) { - gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0); - g_signal_connect (combo, "changed", G_CALLBACK (option_activated_cb), itip); - } -} - -static void -insert_boxes (GtkHTMLEmbedded *eb, EItipControl *itip) -{ - EItipControlPrivate *priv; - - priv = itip->priv; - - priv->vbox.widget = gtk_vbox_new (FALSE, 12); - g_object_add_weak_pointer (G_OBJECT (priv->vbox.widget), &priv->vbox.pointer); - gtk_container_add (GTK_CONTAINER (eb), priv->vbox.widget); - gtk_widget_show (priv->vbox.widget); - - priv->hbox.widget = gtk_hbox_new (FALSE, 6); - g_object_add_weak_pointer (G_OBJECT (priv->hbox.widget), &priv->hbox.pointer); - - gtk_box_pack_start (GTK_BOX (priv->vbox.widget), priv->hbox.widget, FALSE, TRUE, 0); - gtk_widget_show (priv->hbox.widget); -} - -static void -insert_label (GtkWidget *hbox) -{ - GtkWidget *label; - gchar *text; - - text = g_strdup_printf ("%s", _("Choose an action:")); - label = gtk_label_new (NULL); - gtk_label_set_markup (GTK_LABEL (label), text); - g_free (text); - - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0); - gtk_widget_show (label); -} - -static void -rsvp_clicked_cb (GtkWidget *widget, gpointer data) -{ - EItipControl *itip = E_ITIP_CONTROL (data); - EItipControlPrivate *priv; - - priv = itip->priv; - - priv->rsvp = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); -} - -static void -insert_rsvp (GtkWidget *hbox, EItipControl *itip) -{ - EItipControlPrivate *priv; - GtkWidget *btn; - - priv = itip->priv; - - /* To translators: RSVP means "please reply" */ - btn = gtk_check_button_new_with_label (_("RSVP")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (btn), TRUE); - priv->rsvp = TRUE; - - g_signal_connect (btn, "clicked", G_CALLBACK (rsvp_clicked_cb), itip); - - gtk_box_pack_start (GTK_BOX (hbox), btn, FALSE, TRUE, 0); - gtk_widget_show (btn); -} - -static void -insert_ok (GtkWidget *hbox, EItipControl *itip) -{ - EItipControlPrivate *priv; - priv = itip->priv; - - priv->ok.widget = gtk_button_new_from_stock (GTK_STOCK_OK); - g_object_add_weak_pointer (G_OBJECT (priv->ok.widget), &priv->ok.pointer); - - g_signal_connect (priv->ok.widget, "clicked", G_CALLBACK (ok_clicked_cb), itip); - - set_ok_sens (itip); - - gtk_box_pack_start (GTK_BOX (hbox), priv->ok.widget, FALSE, TRUE, 0); - gtk_widget_show (priv->ok.widget); -} - -static gboolean -publish_options_object (EItipControl *itip, GtkHTML *html, GtkHTMLEmbedded *eb) -{ - EItipControlPrivate *priv; - GtkWidget *combo; - - priv = itip->priv; - - insert_boxes (eb, itip); - insert_label (priv->hbox.widget); - - combo = create_combo_box (); - - add_option (itip, combo, _("Update"), 'U'); - priv->action = 'U'; - - gtk_box_pack_start (GTK_BOX (priv->hbox.widget), combo, FALSE, TRUE, 0); - gtk_widget_show (combo); - - insert_ok (priv->hbox.widget, itip); - - return TRUE; -} - -static gboolean -request_options_object (EItipControl *itip, GtkHTML *html, GtkHTMLEmbedded *eb) -{ - EItipControlPrivate *priv; - GtkWidget *combo; - - priv = itip->priv; - - insert_boxes (eb, itip); - insert_label (priv->hbox.widget); - - combo = create_combo_box (); - - add_option (itip, combo, _("Accept"), 'A'); - add_option (itip, combo, _("Tentatively accept"), 'T'); - add_option (itip, combo, _("Decline"), 'D'); - priv->action = 'A'; - - gtk_box_pack_start (GTK_BOX (priv->hbox.widget), combo, FALSE, TRUE, 0); - gtk_widget_show (combo); - - insert_rsvp (priv->hbox.widget, itip); - insert_ok (priv->hbox.widget, itip); - - return TRUE; -} - -static gboolean -freebusy_options_object (EItipControl *itip, GtkHTML *html, GtkHTMLEmbedded *eb) -{ - EItipControlPrivate *priv; - GtkWidget *combo; - - priv = itip->priv; - - insert_boxes (eb, itip); - insert_label (priv->hbox.widget); - - combo = create_combo_box (); - - add_option (itip, combo, _("Send Free/Busy Information"), 'F'); - priv->action = 'F'; - - gtk_container_add (GTK_CONTAINER (priv->hbox.widget), combo); - gtk_widget_show (combo); - - insert_ok (priv->hbox.widget, itip); - - return TRUE; -} - -static gboolean -reply_options_object (EItipControl *itip, GtkHTML *html, GtkHTMLEmbedded *eb) -{ - EItipControlPrivate *priv; - GtkWidget *combo; - - priv = itip->priv; - - insert_boxes (eb, itip); - insert_label (priv->hbox.widget); - - combo = create_combo_box (); - - add_option (itip, combo, _("Update respondent status"), 'R'); - priv->action = 'R'; - - gtk_container_add (GTK_CONTAINER (priv->hbox.widget), combo); - gtk_widget_show (combo); - - insert_ok (priv->hbox.widget, itip); - - return TRUE; -} - -static gboolean -refresh_options_object (EItipControl *itip, GtkHTML *html, GtkHTMLEmbedded *eb) -{ - EItipControlPrivate *priv; - GtkWidget *combo; - - priv = itip->priv; - - insert_boxes (eb, itip); - insert_label (priv->hbox.widget); - - combo = create_combo_box (); - - add_option (itip, combo, _("Send Latest Information"), 'S'); - priv->action = 'S'; - - gtk_container_add (GTK_CONTAINER (priv->hbox.widget), combo); - gtk_widget_show (combo); - - insert_ok (priv->hbox.widget, itip); - - return TRUE; -} - -static gboolean -cancel_options_object (EItipControl *itip, GtkHTML *html, GtkHTMLEmbedded *eb) -{ - EItipControlPrivate *priv; - GtkWidget *combo; - - priv = itip->priv; - - insert_boxes (eb, itip); - insert_label (priv->hbox.widget); - - combo = create_combo_box (); - - add_option (itip, combo, _("Cancel"), 'C'); - priv->action = 'C'; - - gtk_container_add (GTK_CONTAINER (priv->hbox.widget), combo); - gtk_widget_show (combo); - - insert_ok (priv->hbox.widget, itip); - - return TRUE; -} - -static gboolean -object_requested_cb (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data) -{ - EItipControl *itip = E_ITIP_CONTROL (data); - - if (!strcmp (eb->classid, "itip:publish_options")) - return publish_options_object (itip, html, eb); - else if (!strcmp (eb->classid, "itip:request_options")) - return request_options_object (itip, html, eb); - else if (!strcmp (eb->classid, "itip:freebusy_options")) - return freebusy_options_object (itip, html, eb); - else if (!strcmp (eb->classid, "itip:reply_options")) - return reply_options_object (itip, html, eb); - else if (!strcmp (eb->classid, "itip:refresh_options")) - return refresh_options_object (itip, html, eb); - else if (!strcmp (eb->classid, "itip:cancel_options")) - return cancel_options_object (itip, html, eb); - - return FALSE; -} - -static void -ok_clicked_cb (GtkWidget *widget, gpointer data) -{ - EItipControl *itip = E_ITIP_CONTROL (data); - EItipControlPrivate *priv; - gboolean status = FALSE; - - priv = itip->priv; - - if (!priv->my_address && priv->current_ecal != NULL) - e_cal_get_cal_address (priv->current_ecal, &priv->my_address, NULL); - - switch (priv->action) { - case 'U': - update_item (itip); - break; - case 'A': - status = change_status (priv->ical_comp, priv->my_address, - ICAL_PARTSTAT_ACCEPTED); - if (status) { - e_cal_component_rescan (priv->comp); - update_item (itip); - } - break; - case 'T': - status = change_status (priv->ical_comp, priv->my_address, - ICAL_PARTSTAT_TENTATIVE); - if (status) { - e_cal_component_rescan (priv->comp); - update_item (itip); - } - break; - case 'D': - status = change_status (priv->ical_comp, priv->my_address, - ICAL_PARTSTAT_DECLINED); - if (status) { - e_cal_component_rescan (priv->comp); - update_item (itip); - } - break; - case 'F': - send_freebusy (itip); - break; - case 'R': - update_attendee_status (itip); - break; - case 'S': - send_item (itip); - break; - case 'C': - update_item (itip); - break; - } - - if (e_cal_get_save_schedules (priv->current_ecal)) - return; - - if (priv->rsvp && status) { - ECalComponent *comp = NULL; - icalcomponent *ical_comp; - icalproperty *prop; - icalvalue *value; - const gchar *attendee; - GSList *l, *list = NULL; - - comp = e_cal_component_clone (priv->comp); - if (comp == NULL) - return; - - if (priv->my_address == NULL) - find_my_address (itip, priv->ical_comp, NULL); - g_return_if_fail (priv->my_address != NULL); - - ical_comp = e_cal_component_get_icalcomponent (comp); - - for (prop = icalcomponent_get_first_property (ical_comp, ICAL_ATTENDEE_PROPERTY); - prop != NULL; - prop = icalcomponent_get_next_property (ical_comp, ICAL_ATTENDEE_PROPERTY)) - { - gchar *text; - - value = icalproperty_get_value (prop); - if (!value) - continue; - - attendee = icalvalue_get_string (value); - - text = g_strdup (itip_strip_mailto (attendee)); - text = g_strstrip (text); - if (g_ascii_strcasecmp (priv->my_address, text)) - list = g_slist_prepend (list, prop); - g_free (text); - } - - for (l = list; l; l = l->next) { - prop = l->data; - icalcomponent_remove_property (ical_comp, prop); - icalproperty_free (prop); - } - g_slist_free (list); - - e_cal_component_rescan (comp); - itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, priv->current_ecal, priv->top_level, NULL, NULL, TRUE, FALSE); - - g_object_unref (comp); - } -} diff --git a/calendar/gui/e-itip-control.h b/calendar/gui/e-itip-control.h deleted file mode 100644 index 38dce21bf1..0000000000 --- a/calendar/gui/e-itip-control.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * JP Rosevear - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef _E_ITIP_CONTROL_H_ -#define _E_ITIP_CONTROL_H_ - -#include - -G_BEGIN_DECLS - -#define E_TYPE_ITIP_CONTROL (e_itip_control_get_type ()) -#define E_ITIP_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_ITIP_CONTROL, EItipControl)) -#define E_ITIP_CONTROL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_ITIP_CONTROL, EItipControlClass)) -#define E_IS_ITIP_CONTROL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_ITIP_CONTROL)) -#define E_IS_ITIP_CONTROL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_ITIP_CONTROL)) - - -typedef struct _EItipControl EItipControl; -typedef struct _EItipControlPrivate EItipControlPrivate; -typedef struct _EItipControlClass EItipControlClass; - -struct _EItipControl { - GtkVBox parent; - - EItipControlPrivate *priv; -}; - -struct _EItipControlClass { - GtkVBoxClass parent_class; -}; - - - -GType e_itip_control_get_type (void); -GtkWidget * e_itip_control_new (void); -void e_itip_control_set_data (EItipControl *itip, - const gchar *text); -gchar * e_itip_control_get_data (EItipControl *itip); -gint e_itip_control_get_data_size (EItipControl *itip); -void e_itip_control_set_from_address (EItipControl *itip, - const gchar *address); -const gchar *e_itip_control_get_from_address (EItipControl *itip); -void e_itip_control_set_view_only (EItipControl *itip, - gboolean view_only); -gboolean e_itip_control_get_view_only (EItipControl *itip); -void e_itip_control_set_delegator_address (EItipControl *itip, - const gchar *address); -const gchar *e_itip_control_get_delegator_address (EItipControl *itip); -void e_itip_control_set_delegator_name (EItipControl *itip, - const gchar *name); -const gchar *e_itip_control_get_delegator_name (EItipControl *itip); -void e_itip_control_set_calendar_uid (EItipControl *itip, - const gchar *uid); -const gchar *e_itip_control_get_calendar_uid (EItipControl *itip); - -G_END_DECLS - -#endif /* _E_ITIP_CONTROL_H_ */ diff --git a/calendar/gui/e-itip-control.ui b/calendar/gui/e-itip-control.ui deleted file mode 100644 index b258301b46..0000000000 --- a/calendar/gui/e-itip-control.ui +++ /dev/null @@ -1,464 +0,0 @@ - - - - - 100 - 0 - 10 - 1 - 10 - 0 - - - no - window1 - GTK_WINDOW_TOPLEVEL - no - no - yes - GTK_WIN_POS_CENTER_ON_PARENT - - - 4 - Calendar Message - 0 - GTK_SHADOW_ETCHED_IN - yes - - - GTK_POLICY_NEVER - GTK_POLICY_NEVER - yes - - - GTK_SHADOW_NONE - yes - - - no - 0 - yes - - - 3 - no - 3 - 3 - 4 - 2 - yes - - - yes - no - - 0 - yes - yes - - - 1 - 2 - 0 - 1 - 0 - 0 - expand|fill - - - - - - yes - no - - 0 - yes - yes - - - 1 - 2 - 2 - 3 - 0 - 0 - expand|fill - - - - - - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - yes - - - yes - no - GTK_WRAP_WORD - yes - - - - - GTK_UPDATE_CONTINUOUS - yes - - - - - GTK_UPDATE_CONTINUOUS - yes - - - - - 1 - 2 - 3 - 4 - 0 - 0 - fill - fill - - - - - 0 - 0 - 1 - 1 - yes - - - no - 0 - yes - - - date-start - GTK_JUSTIFY_CENTER - no - 0.5 - 0 - 0 - 0 - yes - - - 0 - no - no - - - - - --to-- - GTK_JUSTIFY_CENTER - no - 0.5 - 0 - 19 - 0 - yes - - - 0 - no - no - - - - - date-end - GTK_JUSTIFY_CENTER - no - 0.5 - 0.5 - 0 - 0 - yes - - - 0 - no - no - - - - - - - 1 - 2 - 1 - 2 - 0 - 0 - expand|fill - fill - - - - - Organizer: - GTK_JUSTIFY_LEFT - no - 0 - 0.5 - 0 - 0 - yes - - - 0 - 1 - 0 - 1 - 0 - 0 - fill - - - - - - Date: - GTK_JUSTIFY_LEFT - no - 0 - 0 - 0 - 0 - yes - - - 0 - 1 - 1 - 2 - 0 - 0 - fill - - - - - - Summary: - GTK_JUSTIFY_LEFT - no - 0 - 0.5 - 0 - 0 - yes - - - 0 - 1 - 2 - 3 - 0 - 0 - fill - - - - - - Description: - GTK_JUSTIFY_LEFT - no - 0 - 0 - 0 - 0 - yes - - - 0 - 1 - 3 - 4 - 0 - 0 - fill - fill - - - - - 6 - yes - yes - - - - - Server Message: - GTK_JUSTIFY_LEFT - no - 7.45058e-09 - 0.5 - 3 - 0 - yes - - - 0 - no - no - - - - - 3 - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - 365 - yes - - - yes - no - GTK_WRAP_WORD - yes - - - - - GTK_UPDATE_CONTINUOUS - yes - - - - - GTK_UPDATE_CONTINUOUS - yes - - - - - 0 - yes - no - - - - - 3 - no - 0 - 30 - yes - - - - - - 0 - no - no - - - - - - - - - GTK_UPDATE_CONTINUOUS - yes - - - - - GTK_UPDATE_CONTINUOUS - yes - - - - - - - - - no - Loading Calendar - GTK_WINDOW_DIALOG - no - no - yes - GTK_WIN_POS_CENTER - - - 4 - - 0 - GTK_SHADOW_ETCHED_OUT - yes - - - 7 - no - 1 - yes - - - 6 - no - 9 - yes - - - Loading calendar... - GTK_JUSTIFY_CENTER - no - 0.5 - 0.5 - 0 - 0 - yes - - - 0 - no - no - - - - - GTK_PROGRESS_CONTINUOUS - GTK_PROGRESS_LEFT_TO_RIGHT - no - no - %P %% - 0.5 - 0.5 - yes - adjustment1 - - - 0 - no - no - - - - - 0 - no - no - - - - - - - - diff --git a/calendar/gui/e-meeting-store.c b/calendar/gui/e-meeting-store.c index dd746e32db..4893728a45 100644 --- a/calendar/gui/e-meeting-store.c +++ b/calendar/gui/e-meeting-store.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "itip-utils.h" #include "e-meeting-utils.h" #include "e-meeting-attendee.h" @@ -51,6 +52,11 @@ struct _EMeetingStorePrivate { ECal *client; icaltimezone *zone; + gint default_reminder_interval; + EDurationType default_reminder_units; + + gint week_start_day; + gchar *fb_uri; GPtrArray *refresh_queue; @@ -84,8 +90,11 @@ struct _EMeetingStoreQueueData { enum { PROP_0, PROP_CLIENT, + PROP_DEFAULT_REMINDER_INTERVAL, + PROP_DEFAULT_REMINDER_UNITS, PROP_FREE_BUSY_TEMPLATE, - PROP_TIMEZONE + PROP_TIMEZONE, + PROP_WEEK_START_DAY }; /* Forward Declarations */ @@ -580,6 +589,18 @@ meeting_store_set_property (GObject *object, g_value_get_object (value)); return; + case PROP_DEFAULT_REMINDER_INTERVAL: + e_meeting_store_set_default_reminder_interval ( + E_MEETING_STORE (object), + g_value_get_int (value)); + return; + + case PROP_DEFAULT_REMINDER_UNITS: + e_meeting_store_set_default_reminder_units ( + E_MEETING_STORE (object), + g_value_get_enum (value)); + return; + case PROP_FREE_BUSY_TEMPLATE: e_meeting_store_set_free_busy_template ( E_MEETING_STORE (object), @@ -591,6 +612,12 @@ meeting_store_set_property (GObject *object, E_MEETING_STORE (object), g_value_get_pointer (value)); return; + + case PROP_WEEK_START_DAY: + e_meeting_store_set_week_start_day ( + E_MEETING_STORE (object), + g_value_get_int (value)); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -610,6 +637,20 @@ meeting_store_get_property (GObject *object, E_MEETING_STORE (object))); return; + case PROP_DEFAULT_REMINDER_INTERVAL: + g_value_set_int ( + value, + e_meeting_store_get_default_reminder_interval ( + E_MEETING_STORE (object))); + return; + + case PROP_DEFAULT_REMINDER_UNITS: + g_value_set_enum ( + value, + e_meeting_store_get_default_reminder_units ( + E_MEETING_STORE (object))); + return; + case PROP_FREE_BUSY_TEMPLATE: g_value_set_string ( value, @@ -623,6 +664,13 @@ meeting_store_get_property (GObject *object, e_meeting_store_get_timezone ( E_MEETING_STORE (object))); return; + + case PROP_WEEK_START_DAY: + g_value_set_int ( + value, + e_meeting_store_get_week_start_day ( + E_MEETING_STORE (object))); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -683,6 +731,29 @@ e_meeting_store_class_init (EMeetingStoreClass *class) E_TYPE_CAL, G_PARAM_READWRITE)); + g_object_class_install_property ( + object_class, + PROP_DEFAULT_REMINDER_INTERVAL, + g_param_spec_int ( + "default-reminder-interval", + "Default Reminder Interval", + NULL, + G_MININT, + G_MAXINT, + 0, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_DEFAULT_REMINDER_UNITS, + g_param_spec_enum ( + "default-reminder-units", + "Default Reminder Units", + NULL, + E_TYPE_DURATION_TYPE, + E_DURATION_MINUTES, + G_PARAM_READWRITE)); + g_object_class_install_property ( object_class, PROP_FREE_BUSY_TEMPLATE, @@ -701,6 +772,18 @@ e_meeting_store_class_init (EMeetingStoreClass *class) "Timezone", NULL, G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_WEEK_START_DAY, + g_param_spec_int ( + "week-start-day", + "Week Start Day", + NULL, + 0, /* Monday */ + 6, /* Sunday */ + 0, + G_PARAM_READWRITE)); } static void @@ -752,6 +835,44 @@ e_meeting_store_set_client (EMeetingStore *store, g_object_notify (G_OBJECT (store), "client"); } +gint +e_meeting_store_get_default_reminder_interval (EMeetingStore *store) +{ + g_return_val_if_fail (E_IS_MEETING_STORE (store), 0); + + return store->priv->default_reminder_interval; +} + +void +e_meeting_store_set_default_reminder_interval (EMeetingStore *store, + gint default_reminder_interval) +{ + g_return_if_fail (E_IS_MEETING_STORE (store)); + + store->priv->default_reminder_interval = default_reminder_interval; + + g_object_notify (G_OBJECT (store), "default-reminder-interval"); +} + +EDurationType +e_meeting_store_get_default_reminder_units (EMeetingStore *store) +{ + g_return_val_if_fail (E_IS_MEETING_STORE (store), 0); + + return store->priv->default_reminder_units; +} + +void +e_meeting_store_set_default_reminder_units (EMeetingStore *store, + EDurationType default_reminder_units) +{ + g_return_if_fail (E_IS_MEETING_STORE (store)); + + store->priv->default_reminder_units = default_reminder_units; + + g_object_notify (G_OBJECT (store), "default-reminder-units"); +} + const gchar * e_meeting_store_get_free_busy_template (EMeetingStore *store) { @@ -791,6 +912,25 @@ e_meeting_store_set_timezone (EMeetingStore *store, g_object_notify (G_OBJECT (store), "timezone"); } +gint +e_meeting_store_get_week_start_day (EMeetingStore *store) +{ + g_return_val_if_fail (E_IS_MEETING_STORE (store), 0); + + return store->priv->week_start_day; +} + +void +e_meeting_store_set_week_start_day (EMeetingStore *store, + gint week_start_day) +{ + g_return_if_fail (E_IS_MEETING_STORE (store)); + + store->priv->week_start_day = week_start_day; + + g_object_notify (G_OBJECT (store), "week-start-day"); +} + static void attendee_changed_cb (EMeetingAttendee *attendee, gpointer data) { diff --git a/calendar/gui/e-meeting-store.h b/calendar/gui/e-meeting-store.h index 62287a7b7e..3565657429 100644 --- a/calendar/gui/e-meeting-store.h +++ b/calendar/gui/e-meeting-store.h @@ -25,6 +25,7 @@ #include #include +#include #include "e-meeting-attendee.h" /* Standard GObject macros */ @@ -88,6 +89,16 @@ void e_meeting_store_set_value (EMeetingStore *meeting_store, ECal * e_meeting_store_get_client (EMeetingStore *meeting_store); void e_meeting_store_set_client (EMeetingStore *meeting_store, ECal *client); +gint e_meeting_store_get_default_reminder_interval + (EMeetingStore *meeting_store); +void e_meeting_store_set_default_reminder_interval + (EMeetingStore *meeting_store, + gint default_reminder_interval); +EDurationType e_meeting_store_get_default_reminder_units + (EMeetingStore *meeting_store); +void e_meeting_store_set_default_reminder_units + (EMeetingStore *meeting_store, + EDurationType default_reminder_units); const gchar * e_meeting_store_get_free_busy_template (EMeetingStore *meeting_store); void e_meeting_store_set_free_busy_template @@ -96,6 +107,11 @@ void e_meeting_store_set_free_busy_template icaltimezone * e_meeting_store_get_timezone (EMeetingStore *meeting_store); void e_meeting_store_set_timezone (EMeetingStore *meeting_store, icaltimezone *timezone); +gint e_meeting_store_get_week_start_day + (EMeetingStore *meeting_store); +void e_meeting_store_set_week_start_day + (EMeetingStore *meeting_store, + gint week_start_day); void e_meeting_store_add_attendee (EMeetingStore *meeting_store, EMeetingAttendee *attendee); EMeetingAttendee * diff --git a/calendar/gui/e-meeting-time-sel-item.c b/calendar/gui/e-meeting-time-sel-item.c index f7c600c75d..b04591220a 100644 --- a/calendar/gui/e-meeting-time-sel-item.c +++ b/calendar/gui/e-meeting-time-sel-item.c @@ -203,19 +203,19 @@ static void draw_strikeout_box (EMeetingTimeSelectorItem *mts_item, cairo_t *cr, int x, int y, int width, int height) { - GnomeCanvas *canvas = GNOME_CANVAS_ITEM (mts_item)->canvas; - EMeetingTimeSelector *mts = mts_item->mts; + GnomeCanvas *canvas = GNOME_CANVAS_ITEM (mts_item)->canvas; + EMeetingTimeSelector *mts = mts_item->mts; - cairo_save (cr); + cairo_save (cr); - cairo_rectangle (cr, x, y, width, height); - cairo_clip (cr); + cairo_rectangle (cr, x, y, width, height); + cairo_clip (cr); - cairo_translate (cr, -canvas->draw_xofs, -canvas->draw_yofs); - cairo_set_source (cr, mts->no_info_pattern); - cairo_paint (cr); + cairo_translate (cr, -canvas->draw_xofs, -canvas->draw_yofs); + cairo_set_source (cr, mts->no_info_pattern); + cairo_paint (cr); - cairo_restore (cr); + cairo_restore (cr); } static void @@ -382,9 +382,9 @@ e_meeting_time_selector_item_paint_day_top (EMeetingTimeSelectorItem *mts_item, gint hour, hour_x, hour_y; PangoLayout *layout; - cairo_save (cr); + cairo_save (cr); - cairo_set_line_width (cr, 1.0); + cairo_set_line_width (cr, 1.0); mts = mts_item->mts; @@ -395,36 +395,36 @@ e_meeting_time_selector_item_paint_day_top (EMeetingTimeSelectorItem *mts_item, gdk_cairo_set_source_color (cr, &mts->grid_color); cairo_move_to (cr, x + 0.5, y + 0.5); - cairo_rel_line_to (cr, mts->day_width - 1, 0); - cairo_stroke (cr); + cairo_rel_line_to (cr, mts->day_width - 1, 0); + cairo_stroke (cr); gdk_cairo_set_source_color (cr, &mts->grid_shadow_color); cairo_move_to (cr, x + 0.5, y + 1.5); - cairo_rel_line_to (cr, mts->day_width - 1, 0); - cairo_stroke (cr); + cairo_rel_line_to (cr, mts->day_width - 1, 0); + cairo_stroke (cr); gdk_cairo_set_source_color (cr, &mts->grid_color); y += mts->row_height; - cairo_move_to (cr, x + 0.5, y + 0.5); - cairo_rel_line_to (cr, mts->day_width - 1, 0); + cairo_move_to (cr, x + 0.5, y + 0.5); + cairo_rel_line_to (cr, mts->day_width - 1, 0); y += mts->row_height; - cairo_move_to (cr, x + 0.5, y + 0.5); - cairo_rel_line_to (cr, mts->day_width - 1, 0); + cairo_move_to (cr, x + 0.5, y + 0.5); + cairo_rel_line_to (cr, mts->day_width - 1, 0); /* Draw the vertical grid lines. */ for (grid_x = mts->col_width - 1; grid_x < mts->day_width - mts->col_width; grid_x += mts->col_width) { - cairo_move_to (cr, x + grid_x + 0.5, mts->row_height * 2 - 1 - scroll_y + 0.5); - cairo_line_to (cr, x + grid_x + 0.5, height + 0.5); + cairo_move_to (cr, x + grid_x + 0.5, mts->row_height * 2 - 1 - scroll_y + 0.5); + cairo_line_to (cr, x + grid_x + 0.5, height + 0.5); } grid_x = mts->day_width - 2; - cairo_move_to (cr, x + grid_x + 0.5, 0.5); - cairo_rel_line_to (cr, 0, height); + cairo_move_to (cr, x + grid_x + 0.5, 0.5); + cairo_rel_line_to (cr, 0, height); grid_x++; - cairo_move_to (cr, x + grid_x + 0.5, 0.5); - cairo_rel_line_to (cr, 0, height); - cairo_stroke (cr); + cairo_move_to (cr, x + grid_x + 0.5, 0.5); + cairo_rel_line_to (cr, 0, height); + cairo_stroke (cr); /* Draw the date. Set a clipping rectangle so we don't draw over the next day. */ @@ -443,36 +443,36 @@ e_meeting_time_selector_item_paint_day_top (EMeetingTimeSelectorItem *mts_item, g_date_strftime (buffer, sizeof (buffer), format, date); - cairo_save (cr); + cairo_save (cr); - cairo_rectangle (cr, x, -scroll_y, mts->day_width - 2, mts->row_height - 2); - cairo_clip (cr); + cairo_rectangle (cr, x, -scroll_y, mts->day_width - 2, mts->row_height - 2); + cairo_clip (cr); pango_layout_set_text (layout, buffer, -1); - cairo_move_to (cr, x + 2, 4 - scroll_y); - pango_cairo_show_layout (cr, layout); + cairo_move_to (cr, x + 2, 4 - scroll_y); + pango_cairo_show_layout (cr, layout); - cairo_restore (cr); + cairo_restore (cr); /* Draw the hours. */ hour = mts->first_hour_shown; hour_x = x + 2; hour_y = mts->row_height + 4 - scroll_y; while (hour < mts->last_hour_shown) { - if (calendar_config_get_24_hour_format ()) + if (e_meeting_time_selector_get_use_24_hour_format (mts)) pango_layout_set_text (layout, EMeetingTimeSelectorHours[hour], -1); else pango_layout_set_text (layout, EMeetingTimeSelectorHours12[hour], -1); - cairo_move_to (cr, hour_x, hour_y); - pango_cairo_show_layout (cr, layout); + cairo_move_to (cr, hour_x, hour_y); + pango_cairo_show_layout (cr, layout); hour += mts->zoomed_out ? 3 : 1; hour_x += mts->col_width; } g_object_unref (layout); - cairo_restore (cr); + cairo_restore (cr); } /* This paints the colored bars representing busy periods for the combined @@ -522,8 +522,8 @@ e_meeting_time_selector_item_paint_day (EMeetingTimeSelectorItem *mts_item, EMeetingTimeSelector *mts; gint grid_x, grid_y, attendee_index, unused_y; - cairo_save (cr); - cairo_set_line_width (cr, 1.0); + cairo_save (cr); + cairo_set_line_width (cr, 1.0); mts = mts_item->mts; @@ -545,9 +545,9 @@ e_meeting_time_selector_item_paint_day (EMeetingTimeSelectorItem *mts_item, } else { gdk_cairo_set_source_color (cr, &mts->grid_unused_color); } - cairo_move_to (cr, 0, grid_y); - cairo_rel_line_to (cr, width, 0); - cairo_stroke (cr); + cairo_move_to (cr, 0, grid_y); + cairo_rel_line_to (cr, width, 0); + cairo_stroke (cr); attendee_index++; } @@ -560,14 +560,14 @@ e_meeting_time_selector_item_paint_day (EMeetingTimeSelectorItem *mts_item, grid_x += mts->col_width) { cairo_move_to (cr, x + grid_x, 0); - cairo_line_to (cr, x + grid_x, unused_y - 1); + cairo_line_to (cr, x + grid_x, unused_y - 1); } - cairo_stroke (cr); + cairo_stroke (cr); - cairo_rectangle (cr, - x + mts->day_width - 2, 0, - 2, unused_y); - cairo_fill (cr); + cairo_rectangle (cr, + x + mts->day_width - 2, 0, + 2, unused_y); + cairo_fill (cr); } if (unused_y < height) { @@ -577,17 +577,17 @@ e_meeting_time_selector_item_paint_day (EMeetingTimeSelectorItem *mts_item, grid_x += mts->col_width) { cairo_move_to (cr, x + grid_x, unused_y); - cairo_line_to (cr, x + grid_x, height); + cairo_line_to (cr, x + grid_x, height); } - cairo_stroke (cr); + cairo_stroke (cr); - cairo_rectangle (cr, - x + mts->day_width - 2, unused_y, - 2, height - unused_y); - cairo_fill (cr); + cairo_rectangle (cr, + x + mts->day_width - 2, unused_y, + 2, height - unused_y); + cairo_fill (cr); } - cairo_restore (cr); + cairo_restore (cr); } /* This paints the colored bars representing busy periods for the individual diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c index b634f92e24..802e90d9d4 100644 --- a/calendar/gui/e-memo-table.c +++ b/calendar/gui/e-memo-table.c @@ -981,12 +981,15 @@ get_selected_comp (EMemoTable *memo_table) static void memo_table_delete_selection (ESelectable *selectable) { + ECalModel *model; EMemoTable *memo_table; ECalComponent *comp = NULL; ECalModelComponent *comp_data; + gboolean delete = TRUE; gint n_selected; memo_table = E_MEMO_TABLE (selectable); + model = e_memo_table_get_model (memo_table); n_selected = e_table_selected_count (E_TABLE (memo_table)); if (n_selected <= 0) @@ -1005,9 +1008,13 @@ memo_table_delete_selection (ESelectable *selectable) comp, icalcomponent_new_clone (comp_data->icalcomp)); } - if (delete_component_dialog ( - comp, FALSE, n_selected, E_CAL_COMPONENT_JOURNAL, - GTK_WIDGET (memo_table))) + if (e_cal_model_get_confirm_delete (model)) + delete = delete_component_dialog ( + comp, FALSE, n_selected, + E_CAL_COMPONENT_JOURNAL, + GTK_WIDGET (memo_table)); + + if (delete) delete_selected_components (memo_table); /* free memory */ diff --git a/calendar/gui/e-task-table.c b/calendar/gui/e-task-table.c index 04187348f9..fd6b2c1286 100644 --- a/calendar/gui/e-task-table.c +++ b/calendar/gui/e-task-table.c @@ -1245,14 +1245,16 @@ check_for_retract (ECalComponent *comp, ECal *client) static void task_table_delete_selection (ESelectable *selectable) { + ECalModel *model; ETaskTable *task_table; ECalModelComponent *comp_data; ECalComponent *comp = NULL; - gboolean delete = FALSE; + gboolean delete = TRUE; gint n_selected; GError *error = NULL; task_table = E_TASK_TABLE (selectable); + model = e_task_table_get_model (task_table); n_selected = e_table_selected_count (E_TABLE (task_table)); if (n_selected <= 0) @@ -1302,11 +1304,11 @@ task_table_delete_selection (ESelectable *selectable) } } - } else { + } else if (e_cal_model_get_confirm_delete (model)) delete = delete_component_dialog ( comp, FALSE, n_selected, - E_CAL_COMPONENT_TODO, GTK_WIDGET (task_table)); - } + E_CAL_COMPONENT_TODO, + GTK_WIDGET (task_table)); if (delete) delete_selected_components (task_table); diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c index 1054770607..569449fe34 100644 --- a/calendar/gui/e-week-view-event-item.c +++ b/calendar/gui/e-week-view-event-item.c @@ -35,7 +35,6 @@ #include #include "e-calendar-view.h" -#include "calendar-config.h" #include "comp-util.h" #include @@ -731,7 +730,6 @@ week_view_event_item_draw (GnomeCanvasItem *canvas_item, cairo_pattern_t *pat; guint16 red, green, blue; gdouble radius, cx0, cy0, rect_height, rect_width; - gboolean gradient; gdouble cc = 65535.0; GdkRegion *draw_region; GdkRectangle rect; @@ -790,7 +788,6 @@ week_view_event_item_draw (GnomeCanvasItem *canvas_item, } cr = gdk_cairo_create (drawable); - gradient = calendar_config_get_display_events_gradient (); icon_y = y1 + E_WEEK_VIEW_EVENT_BORDER_HEIGHT + E_WEEK_VIEW_ICON_Y_PAD; @@ -863,17 +860,12 @@ week_view_event_item_draw (GnomeCanvasItem *canvas_item, cairo_save (cr); draw_curved_rectangle (cr, cx0, cy0, rect_width, rect_height, radius); - if (gradient) { - pat = cairo_pattern_create_linear (rect_x + 2, y1 + 1, rect_x + 2, y2 - 7.25); - cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8); - cairo_pattern_add_color_stop_rgba (pat, 0, red/cc, green/cc, blue/cc, 0.4); - cairo_set_source (cr, pat); - cairo_fill_preserve (cr); - cairo_pattern_destroy (pat); - } else { - cairo_set_source_rgba (cr, red/cc, green/cc, blue/cc, 0.8); - cairo_fill_preserve (cr); - } + pat = cairo_pattern_create_linear (rect_x + 2, y1 + 1, rect_x + 2, y2 - 7.25); + cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8); + cairo_pattern_add_color_stop_rgba (pat, 0, red/cc, green/cc, blue/cc, 0.4); + cairo_set_source (cr, pat); + cairo_fill_preserve (cr); + cairo_pattern_destroy (pat); cairo_set_source_rgba (cr, red/cc, green/cc, blue/cc, 0.2); cairo_set_line_width (cr, 0.5); cairo_stroke (cr); @@ -981,17 +973,12 @@ week_view_event_item_draw (GnomeCanvasItem *canvas_item, cairo_save (cr); draw_curved_rectangle (cr, cx0, cy0, rect_width, rect_height, radius); - if (gradient) { - pat = cairo_pattern_create_linear (rect_x + 2, y1 + 1, rect_x + 2, y2 - 7.25); - cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8); - cairo_pattern_add_color_stop_rgba (pat, 0, red/cc, green/cc, blue/cc, 0.4); - cairo_set_source (cr, pat); - cairo_fill_preserve (cr); - cairo_pattern_destroy (pat); - } else { - cairo_set_source_rgba (cr, red/cc, green/cc, blue/cc, 0.8); - cairo_fill_preserve (cr); - } + pat = cairo_pattern_create_linear (rect_x + 2, y1 + 1, rect_x + 2, y2 - 7.25); + cairo_pattern_add_color_stop_rgba (pat, 1, red/cc, green/cc, blue/cc, 0.8); + cairo_pattern_add_color_stop_rgba (pat, 0, red/cc, green/cc, blue/cc, 0.4); + cairo_set_source (cr, pat); + cairo_fill_preserve (cr); + cairo_pattern_destroy (pat); cairo_set_source_rgba (cr, red/cc, green/cc, blue/cc, 0.2); cairo_set_line_width (cr, 0.5); cairo_stroke (cr); diff --git a/calendar/gui/ea-day-view-main-item.c b/calendar/gui/ea-day-view-main-item.c index a4cb0267d9..7d95e8f4b3 100644 --- a/calendar/gui/ea-day-view-main-item.c +++ b/calendar/gui/ea-day-view-main-item.c @@ -553,7 +553,9 @@ ea_day_view_main_item_get_row_label (EaDayViewMainItem *ea_main_item, GObject *g_obj; EDayViewMainItem *main_item; EDayView *day_view; + ECalendarView *cal_view; const gchar *suffix; + gint time_divisions; gint hour, minute, suffix_width; g_return_val_if_fail (ea_main_item, 0); @@ -566,9 +568,12 @@ ea_day_view_main_item_get_row_label (EaDayViewMainItem *ea_main_item, main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); day_view = e_day_view_main_item_get_day_view (main_item); + cal_view = E_CALENDAR_VIEW (day_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); + hour = day_view->first_hour_shown; minute = day_view->first_minute_shown; - minute += row * day_view->mins_per_row; + minute += row * time_divisions; hour = (hour + minute / 60) % 24; minute %= 60; diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c index fdb22641a6..bf24c3c097 100644 --- a/calendar/gui/goto.c +++ b/calendar/gui/goto.c @@ -217,6 +217,7 @@ goto_dialog (GtkWindow *parent, GnomeCalendar *gcal) time_t start_time; struct icaltimetype tt; icaltimezone *timezone; + gint week_start_day; gint b; if (dlg) { @@ -262,7 +263,8 @@ goto_dialog (GtkWindow *parent, GnomeCalendar *gcal) dlg->ecal->calitem->selection_end_day = tt.day; /* Set week_start_day. Convert it to 0 (Mon) to 6 (Sun), which is what we use. */ - dlg->ecal->calitem->week_start_day = (calendar_config_get_week_start_day () + 6) % 7; + week_start_day = e_cal_model_get_week_start_day (model); + dlg->ecal->calitem->week_start_day = (week_start_day + 6) % 7; gnome_canvas_item_grab_focus (GNOME_CANVAS_ITEM (dlg->ecal->calitem)); diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c index 448d394d9a..05b5f0a24a 100644 --- a/calendar/gui/itip-utils.c +++ b/calendar/gui/itip-utils.c @@ -32,7 +32,6 @@ #include #include #include -#include "calendar-config.h" #include "itip-utils.h" #include #include "dialogs/comp-editor-util.h" @@ -279,18 +278,18 @@ itip_strip_mailto (const gchar *address) } static gchar * -get_label (struct icaltimetype *tt) +get_label (struct icaltimetype *tt, + gboolean use_24_hour_format) { - gchar buffer[1000]; - struct tm tmp_tm; + gchar buffer[1000]; + struct tm tmp_tm; tmp_tm = icaltimetype_to_tm (tt); - e_time_format_date_and_time (&tmp_tm, - calendar_config_get_24_hour_format (), - FALSE, FALSE, - buffer, 1000); - return g_strdup (buffer); + e_time_format_date_and_time ( + &tmp_tm, use_24_hour_format, FALSE, FALSE, buffer, 1000); + + return g_strdup (buffer); } typedef struct { @@ -771,7 +770,8 @@ comp_filename (ECalComponent *comp) } static gchar * -comp_description (ECalComponent *comp) +comp_description (ECalComponent *comp, + gboolean use_24_hour_format) { gchar *description; ECalComponentDateTime dt; @@ -790,12 +790,12 @@ comp_description (ECalComponent *comp) case E_CAL_COMPONENT_FREEBUSY: e_cal_component_get_dtstart (comp, &dt); if (dt.value) - start = get_label (dt.value); + start = get_label (dt.value, use_24_hour_format); e_cal_component_free_datetime (&dt); e_cal_component_get_dtend (comp, &dt); if (dt.value) - end = get_label (dt.value); + end = get_label (dt.value, use_24_hour_format); e_cal_component_free_datetime (&dt); if (start != NULL && end != NULL) @@ -1068,7 +1068,12 @@ strip_x_microsoft_props (ECalComponent *comp) } static ECalComponent * -comp_compliant (ECalComponentItipMethod method, ECalComponent *comp, ECal *client, icalcomponent *zones, gboolean strip_alarms) +comp_compliant (ECalComponentItipMethod method, + ECalComponent *comp, + ECal *client, + icalcomponent *zones, + icaltimezone *default_zone, + gboolean strip_alarms) { ECalComponent *clone, *temp_clone; struct icaltimetype itt; @@ -1094,7 +1099,7 @@ comp_compliant (ECalComponentItipMethod method, ECalComponent *comp, ECal *clien e_cal_component_get_dtstart (clone, &dt); if (dt.value->is_date) { - from_zone = calendar_config_get_icaltimezone (); + from_zone = default_zone; } else if (dt.tzid == NULL) { from_zone = icaltimezone_get_utc_timezone (); } else { @@ -1301,21 +1306,39 @@ setup_from (ECalComponentItipMethod method, ECalComponent *comp, ECal *client, E } gboolean -itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp, - ECal *client, icalcomponent *zones, GSList *attachments_list, GList *users, - gboolean strip_alarms, gboolean only_new_attendees) +itip_send_comp (ECalComponentItipMethod method, + ECalComponent *send_comp, + ECal *client, + icalcomponent *zones, + GSList *attachments_list, + GList *users, + gboolean strip_alarms, + gboolean only_new_attendees) { EShell *shell; + EShellSettings *shell_settings; EMsgComposer *composer; EComposerHeaderTable *table; EDestination **destinations; ECalComponent *comp = NULL; icalcomponent *top_level = NULL; + icaltimezone *default_zone; gchar *ical_string = NULL; gchar *content_type = NULL; gchar *subject = NULL; + gboolean use_24_hour_format; gboolean retval = FALSE; + /* FIXME Pass this in. */ + shell = e_shell_get_default (); + shell_settings = e_shell_get_shell_settings (shell); + + default_zone = e_shell_settings_get_pointer ( + shell_settings, "cal-timezone"); + + use_24_hour_format = e_shell_settings_get_boolean ( + shell_settings, "cal-use-24-hour-format"); + /* check whether backend could handle auto-saving requests/updates */ if (method != E_CAL_COMPONENT_METHOD_PUBLISH && e_cal_get_save_schedules (client)) return TRUE; @@ -1336,7 +1359,8 @@ itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp, } /* Tidy up the comp */ - comp = comp_compliant (method, send_comp, client, zones, strip_alarms); + comp = comp_compliant ( + method, send_comp, client, zones, default_zone, strip_alarms); if (comp == NULL) goto cleanup; @@ -1354,9 +1378,6 @@ itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp, /* Subject information */ subject = comp_subject (method, comp); - /* FIXME Pass this in. */ - shell = e_shell_get_default (); - composer = e_msg_composer_new (shell); table = e_msg_composer_get_header_table (composer); @@ -1381,7 +1402,7 @@ itip_send_comp (ECalComponentItipMethod method, ECalComponent *send_comp, gchar *body; filename = comp_filename (comp); - description = comp_description (comp); + description = comp_description (comp, use_24_hour_format); body = camel_text_to_html ( description, CAMEL_MIME_FILTER_TOHTML_PRE, 0); @@ -1439,18 +1460,28 @@ reply_to_calendar_comp (ECalComponentItipMethod method, GSList *attachments_list) { EShell *shell; + EShellSettings *shell_settings; EMsgComposer *composer; EComposerHeaderTable *table; EDestination **destinations; ECalComponent *comp = NULL; icalcomponent *top_level = NULL; + icaltimezone *default_zone; GList *users = NULL; gchar *subject = NULL; gchar *ical_string = NULL; gboolean retval = FALSE; + /* FIXME Pass this in. */ + shell = e_shell_get_default (); + shell_settings = e_shell_get_shell_settings (shell); + + default_zone = e_shell_settings_get_pointer ( + shell_settings, "cal-timezone"); + /* Tidy up the comp */ - comp = comp_compliant (method, send_comp, client, zones, TRUE); + comp = comp_compliant ( + method, send_comp, client, zones, default_zone, TRUE); if (comp == NULL) goto cleanup; @@ -1460,9 +1491,6 @@ reply_to_calendar_comp (ECalComponentItipMethod method, /* Subject information */ subject = comp_subject (method, comp); - /* FIXME Pass this in. */ - shell = e_shell_get_default (); - composer = e_msg_composer_new (shell); table = e_msg_composer_get_header_table (composer); @@ -1526,7 +1554,7 @@ reply_to_calendar_comp (ECalComponentItipMethod method, } if (!start_zone || dtstart.value->is_date) - start_zone = calendar_config_get_icaltimezone (); + start_zone = default_zone; start = icaltime_as_timet_with_zone (*dtstart.value, start_zone); time = g_strdup (ctime (&start)); diff --git a/calendar/gui/print.c b/calendar/gui/print.c index abd844b34a..7378ca719f 100644 --- a/calendar/gui/print.c +++ b/calendar/gui/print.c @@ -43,7 +43,6 @@ #include #include #include -#include "calendar-config.h" #include "e-cal-model.h" #include "e-day-view.h" #include "e-day-view-layout.h" @@ -61,6 +60,8 @@ typedef struct PrintCalItem PrintCalItem; struct PrintCompItem { ECal *client; ECalComponent *comp; + icaltimezone *zone; + gboolean use_24_hour_format; }; struct PrintCalItem { @@ -198,6 +199,7 @@ struct pdinfo gint mins_per_row; guint8 cols_per_row[DAY_VIEW_ROWS]; gboolean use_24_hour_format; + icaltimezone *zone; }; struct psinfo @@ -217,31 +219,31 @@ struct psinfo gboolean use_24_hour_format; gdouble row_height; gdouble header_row_height; + icaltimezone *zone; }; /* Convenience function to help the transition to timezone functions. It converts a time_t to a struct tm. */ -static struct tm* -convert_timet_to_struct_tm (time_t time, icaltimezone *zone) +static void +convert_timet_to_struct_tm (time_t time, + icaltimezone *zone, + struct tm *tm) { - static struct tm my_tm; struct icaltimetype tt; /* Convert it to an icaltimetype. */ tt = icaltime_from_timet_with_zone (time, FALSE, zone); /* Fill in the struct tm. */ - my_tm.tm_year = tt.year - 1900; - my_tm.tm_mon = tt.month - 1; - my_tm.tm_mday = tt.day; - my_tm.tm_hour = tt.hour; - my_tm.tm_min = tt.minute; - my_tm.tm_sec = tt.second; - my_tm.tm_isdst = tt.is_daylight; - - my_tm.tm_wday = time_day_of_week (tt.day, tt.month - 1, tt.year); - - return &my_tm; + tm->tm_year = tt.year - 1900; + tm->tm_mon = tt.month - 1; + tm->tm_mday = tt.day; + tm->tm_hour = tt.hour; + tm->tm_min = tt.minute; + tm->tm_sec = tt.second; + tm->tm_isdst = tt.is_daylight; + + tm->tm_wday = time_day_of_week (tt.day, tt.month - 1, tt.year); } /* Fills the 42-element days array with the day numbers for the specified @@ -249,7 +251,12 @@ convert_timet_to_struct_tm (time_t time, icaltimezone *zone) * The starting and ending indexes of the days are returned in the start * and end arguments. */ static void -build_month (gint month, gint year, gint *days, gint *start, gint *end) +build_month (ECalModel *model, + gint month, + gint year, + gint *days, + gint *start, + gint *end) { gint i; gint d_month, d_week, week_start_day; @@ -277,7 +284,7 @@ build_month (gint month, gint year, gint *days, gint *start, gint *end) /* Get the configuration setting specifying which weekday we put on the left column, 0=Sun to 6=Sat. */ - week_start_day = calendar_config_get_week_start_day (); + week_start_day = e_cal_model_get_week_start_day (model); /* Figure out which square we want to put the 1 in. */ d_week = (d_week + 7 - week_start_day) % 7; @@ -545,13 +552,12 @@ static const gchar *days[] = { format the date 'nicely' and consistently for various headers */ static gchar * -format_date (time_t time, gint flags, gchar *buffer, gint bufflen) +format_date (struct tm *tm, + gint flags, + gchar *buffer, + gint bufflen) { - icaltimezone *zone = calendar_config_get_icaltimezone (); gchar fmt[64]; - struct tm tm; - - tm = *convert_timet_to_struct_tm (time, zone); fmt[0] = 0; if (flags & DATE_DAYNAME) { @@ -560,7 +566,7 @@ format_date (time_t time, gint flags, gchar *buffer, gint bufflen) if (flags & DATE_DAY) { if (flags & DATE_DAYNAME) strcat(fmt, " "); - strcat (fmt, gettext (days[tm.tm_mday-1])); + strcat (fmt, gettext (days[tm->tm_mday-1])); } if (flags & DATE_MONTH) { if (flags & (DATE_DAY|DATE_DAYNAME)) @@ -574,7 +580,7 @@ format_date (time_t time, gint flags, gchar *buffer, gint bufflen) strcat(fmt, " "); strcat(fmt, "%Y"); } - e_utf8_strftime (buffer, bufflen, fmt, &tm); + e_utf8_strftime (buffer, bufflen, fmt, tm); buffer[bufflen - 1] = '\0'; return buffer; @@ -633,8 +639,9 @@ print_month_small (GtkPrintContext *context, GnomeCalendar *gcal, time_t month, gint titleflags, time_t greystart, time_t greyend, gint bordertitle) { - icaltimezone *zone = calendar_config_get_icaltimezone (); + icaltimezone *zone; PangoFontDescription *font, *font_bold, *font_normal; + ECalModel *model; time_t now, next; gint x, y; gint days[42]; @@ -647,10 +654,14 @@ print_month_small (GtkPrintContext *context, GnomeCalendar *gcal, time_t month, gboolean week_numbers; cairo_t *cr; + model = gnome_calendar_get_model (gcal); + zone = e_cal_model_get_timezone (model); + week_numbers = get_show_week_numbers (); /* Print the title, e.g. 'June 2001', in the top 16% of the area. */ - format_date (month, titleflags, buf, 100); + convert_timet_to_struct_tm (month, zone, &tm); + format_date (&tm, titleflags, buf, 100); header_size = ABS (y2 - y1) * 0.16; @@ -673,8 +684,8 @@ print_month_small (GtkPrintContext *context, GnomeCalendar *gcal, time_t month, font_size = row_height; /* get month days */ - tm = *convert_timet_to_struct_tm (month, zone); - build_month (tm.tm_mon, tm.tm_year + 1900, days, NULL, NULL); + convert_timet_to_struct_tm (month, zone, &tm); + build_month (model, tm.tm_mon, tm.tm_year + 1900, days, NULL, NULL); font_normal = get_font_for_size (font_size, PANGO_WEIGHT_NORMAL); font_bold = get_font_for_size (font_size, PANGO_WEIGHT_BOLD); @@ -689,7 +700,7 @@ print_month_small (GtkPrintContext *context, GnomeCalendar *gcal, time_t month, cairo_set_source_rgb (cr, 0, 0, 0); /* Print the abbreviated day names across the top in bold. */ - week_start_day = calendar_config_get_week_start_day (); + week_start_day = e_cal_model_get_week_start_day (model); weekday = week_start_day; for (x = 0; x < 7; x++) { print_text ( @@ -727,7 +738,7 @@ print_month_small (GtkPrintContext *context, GnomeCalendar *gcal, time_t month, if (day != 0) { time_t week_begin = time_week_begin_with_zone (now, week_start_day, zone); - tm = *convert_timet_to_struct_tm (week_begin, zone); + convert_timet_to_struct_tm (week_begin, zone, &tm); /* month in e_calendar_item_get_week_number is also zero-based */ sprintf (buf, "%d", e_calendar_item_get_week_number (NULL, tm.tm_mday, tm.tm_mon, tm.tm_year + 1900)); @@ -843,6 +854,7 @@ print_day_background (GtkPrintContext *context, GnomeCalendar *gcal, time_t whence, struct pdinfo *pdi, double left, double right, double top, double bottom) { + ECalModel *model; PangoFontDescription *font_hour, *font_minute; gdouble yinc, y; gdouble width = DAY_VIEW_TIME_COLUMN_WIDTH; @@ -854,7 +866,8 @@ print_day_background (GtkPrintContext *context, GnomeCalendar *gcal, gdouble hour_minute_x, hour_minute_width; cairo_t *cr; - use_24_hour = calendar_config_get_24_hour_format (); + model = gnome_calendar_get_model (gcal); + use_24_hour = e_cal_model_get_use_24_hour_format (model); /* Fill the time column in light-gray. */ print_border (context, left, left + width, top, bottom, -1.0, 0.9); @@ -948,13 +961,13 @@ static gint print_day_add_event (ECalModelComponent *comp_data, time_t start, time_t end, + icaltimezone *zone, gint days_shown, time_t *day_starts, GArray *long_events, GArray **events) { - icaltimezone *zone = calendar_config_get_icaltimezone (); EDayViewEvent event; gint day, offset; struct icaltimetype start_tt, end_tt; @@ -1025,7 +1038,7 @@ print_day_details_cb (ECalComponent *comp, time_t istart, time_t iend, struct pdinfo *pdi = (struct pdinfo *) mdata->cb_data; print_day_add_event (mdata->comp_data, istart, iend, - pdi->days_shown, pdi->day_starts, + pdi->zone, pdi->days_shown, pdi->day_starts, pdi->long_events, pdi->events); return TRUE; @@ -1338,7 +1351,8 @@ static void print_day_details (GtkPrintContext *context, GnomeCalendar *gcal, time_t whence, double left, double right, double top, double bottom) { - icaltimezone *zone = calendar_config_get_icaltimezone (); + ECalModel *model; + icaltimezone *zone; EDayViewEvent *event; PangoFontDescription *font; time_t start, end; @@ -1350,7 +1364,8 @@ print_day_details (GtkPrintContext *context, GnomeCalendar *gcal, time_t whence, #define LONG_DAY_EVENTS_TOP_SPACING 4 #define LONG_DAY_EVENTS_BOTTOM_SPACING 2 - ECalModel *model = gnome_calendar_get_model (gcal); + model = gnome_calendar_get_model (gcal); + zone = e_cal_model_get_timezone (model); start = time_day_begin_with_zone (whence, zone); end = time_day_end_with_zone (start, zone); @@ -1360,15 +1375,16 @@ print_day_details (GtkPrintContext *context, GnomeCalendar *gcal, time_t whence, pdi.day_starts[1] = end; pdi.long_events = g_array_new (FALSE, FALSE, sizeof (EDayViewEvent)); pdi.events[0] = g_array_new (FALSE, FALSE, sizeof (EDayViewEvent)); - pdi.start_hour = calendar_config_get_day_start_hour (); - pdi.end_hour = calendar_config_get_day_end_hour (); - if (calendar_config_get_day_end_minute () != 0) + pdi.start_hour = e_cal_model_get_work_day_start_hour (model); + pdi.end_hour = e_cal_model_get_work_day_end_hour (model); + if (e_cal_model_get_work_day_end_minute (model) != 0) pdi.end_hour++; pdi.rows = (pdi.end_hour - pdi.start_hour) * 2; pdi.mins_per_row = 30; pdi.start_minute_offset = pdi.start_hour * 60; pdi.end_minute_offset = pdi.end_hour * 60; - pdi.use_24_hour_format = calendar_config_get_24_hour_format (); + pdi.use_24_hour_format = e_cal_model_get_use_24_hour_format (model); + pdi.zone = e_cal_model_get_timezone (model); /* Get the events from the server. */ e_cal_model_generate_instances (model, start, end, print_day_details_cb, &pdi); @@ -1777,7 +1793,6 @@ print_week_view_background (GtkPrintContext *context, double left, double top, double cell_width, double cell_height) { - icaltimezone *zone = calendar_config_get_icaltimezone (); struct tm tm; gint day, day_x, day_y, day_h; gdouble x1, x2, y1, y2, font_size, fillcolor; @@ -1798,7 +1813,7 @@ print_week_view_background (GtkPrintContext *context, y1 = top + day_y * cell_height; y2 = y1 + day_h * cell_height; - tm = *convert_timet_to_struct_tm (psi->day_starts[day], zone); + convert_timet_to_struct_tm (psi->day_starts[day], psi->zone, &tm); /* In the month view we draw a grey background for the end of the previous month and the start of the following. */ @@ -1848,7 +1863,6 @@ print_week_summary_cb (ECalComponent *comp, gpointer data) { - icaltimezone *zone = calendar_config_get_icaltimezone (); EWeekViewEvent event; struct icaltimetype start_tt, end_tt; ECalModelGenerateInstancesData *mdata = (ECalModelGenerateInstancesData *) data; @@ -1866,8 +1880,8 @@ print_week_summary_cb (ECalComponent *comp, g_return_val_if_fail (start < psi->day_starts[psi->days_shown], TRUE); g_return_val_if_fail (end > psi->day_starts[0], TRUE); - start_tt = icaltime_from_timet_with_zone (start, FALSE, zone); - end_tt = icaltime_from_timet_with_zone (end, FALSE, zone); + start_tt = icaltime_from_timet_with_zone (start, FALSE, psi->zone); + end_tt = icaltime_from_timet_with_zone (end, FALSE, psi->zone); event.comp_data = g_object_ref (mdata->comp_data); @@ -1892,7 +1906,7 @@ print_week_summary (GtkPrintContext *context, GnomeCalendar *gcal, gint month, double font_size, double left, double right, double top, double bottom) { - icaltimezone *zone = calendar_config_get_icaltimezone (); + icaltimezone *zone; EWeekViewEvent *event; struct psinfo psi; time_t day_start; @@ -1900,23 +1914,27 @@ print_week_summary (GtkPrintContext *context, GnomeCalendar *gcal, GArray *spans; PangoFontDescription *font; gdouble cell_width, cell_height; - ECalModel *model = gnome_calendar_get_model (gcal); + ECalModel *model; + + model = gnome_calendar_get_model (gcal); + zone = e_cal_model_get_timezone (model); psi.days_shown = weeks_shown * 7; psi.events = g_array_new (FALSE, FALSE, sizeof (EWeekViewEvent)); psi.multi_week_view = multi_week_view; psi.weeks_shown = weeks_shown; psi.month = month; + psi.zone = zone; /* Get a few config settings. */ if (multi_week_view) - psi.compress_weekend = calendar_config_get_compress_weekend (); + psi.compress_weekend = e_cal_model_get_compress_weekend (model); else psi.compress_weekend = TRUE; - psi.use_24_hour_format = calendar_config_get_24_hour_format (); + psi.use_24_hour_format = e_cal_model_get_use_24_hour_format (model); /* We convert this from (0 = Sun, 6 = Sat) to (0 = Mon, 6 = Sun). */ - psi.display_start_weekday = calendar_config_get_week_start_day (); + psi.display_start_weekday = e_cal_model_get_week_start_day (model); psi.display_start_weekday = (psi.display_start_weekday + 6) % 7; /* If weekends are compressed then we can't start on a Sunday. */ @@ -1986,68 +2004,30 @@ print_week_summary (GtkPrintContext *context, GnomeCalendar *gcal, g_array_free (spans, TRUE); } -/* XXX Evolution doesn't have a "year" view. */ -#if 0 -static void -print_year_summary (GtkPrintContext *context, GnomeCalendar *gcal, time_t whence, - double left, double right, double top, double bottom, - gint morerows) -{ - icaltimezone *zone = calendar_config_get_icaltimezone (); - gdouble row_height, col_width, l, r, t, b; - time_t now; - gint col, row, rows, cols; - - l = left; - t = top; - - /* If morerows is set we do 4 rows and 3 columns instead of 3 rows and - 4 columns. This is useful if we switch paper orientation. */ - if (morerows) { - rows = 4; - cols = 3; - } else { - rows = 3; - cols = 4; - } - - row_height = (top - bottom) / rows; - col_width = (right - left) / cols; - r = l + col_width; - b = top - row_height; - now = time_year_begin_with_zone (whence, zone); - - for (row = 0; row < rows; row++) { - t = top - row_height * row; - b = t - row_height; - for (col = 0; col < cols; col++) { - l = left + col_width * col; - r = l + col_width; - print_month_small (context, gcal, now, - l + 8, t - 8, r - 8 - (get_show_week_numbers () ? 1 : 0), b + 8, - DATE_MONTH, 0, 0, TRUE); - now = time_add_month_with_zone (now, 1, zone); - } - } -} -#endif - static void -print_month_summary (GtkPrintContext *context, GnomeCalendar *gcal, time_t whence, - double left, double right, double top, double bottom) +print_month_summary (GtkPrintContext *context, + GnomeCalendar *gcal, + time_t whence, + gdouble left, + gdouble right, + gdouble top, + gdouble bottom) { - icaltimezone *zone = calendar_config_get_icaltimezone (); + icaltimezone *zone; time_t date; struct tm tm; struct icaltimetype tt; gchar buffer[100]; + ECalModel *model; PangoFontDescription *font; gboolean compress_weekend; gint columns, col, weekday, month, weeks; gdouble font_size, cell_width, x1, x2, y1, y2; - weekday = calendar_config_get_week_start_day (); - compress_weekend = calendar_config_get_compress_weekend (); + model = gnome_calendar_get_model (gcal); + zone = e_cal_model_get_timezone (model); + weekday = e_cal_model_get_week_start_day (model); + compress_weekend = e_cal_model_get_compress_weekend (model); date = 0; weeks = 6; @@ -2088,7 +2068,7 @@ print_month_summary (GtkPrintContext *context, GnomeCalendar *gcal, time_t whenc to be able to step through the week without worrying about overflows making strftime choke, so we move near to the start of the month. */ - tm = *convert_timet_to_struct_tm (date, zone); + convert_timet_to_struct_tm (date, zone, &tm); tm.tm_mday = (tm.tm_mday % 7) + 7; font = get_font_for_size (MONTH_NORMAL_FONT_SIZE, PANGO_WEIGHT_BOLD); @@ -2228,12 +2208,17 @@ print_todo_details (GtkPrintContext *context, GnomeCalendar *gcal, static void print_day_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) { + ECalModel *model; GtkPageSetup *setup; - icaltimezone *zone = calendar_config_get_icaltimezone (); + icaltimezone *zone; gint i, days = 1; gdouble todo, l, week_numbers_inc, small_month_width; gchar buf[100]; gdouble width, height; + struct tm tm; + + model = gnome_calendar_get_model (gcal); + zone = e_cal_model_get_timezone (model); setup = gtk_print_context_get_page_setup (context); @@ -2273,7 +2258,8 @@ print_day_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) DATE_MONTH | DATE_YEAR, 0, 0, FALSE); /* Print the date, e.g. '8th May, 2001'. */ - format_date (date, DATE_DAY | DATE_MONTH | DATE_YEAR, + convert_timet_to_struct_tm (date, zone, &tm); + format_date (&tm, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100); print_text_size_bold (context, buf, PANGO_ALIGN_LEFT, @@ -2281,7 +2267,7 @@ print_day_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) 4 + 24); /* Print the day, e.g. 'Tuesday'. */ - format_date (date, DATE_DAYNAME, buf, 100); + format_date (&tm, DATE_DAYNAME, buf, 100); print_text_size_bold (context, buf, PANGO_ALIGN_LEFT, 4, todo, @@ -2297,6 +2283,7 @@ print_work_week_background (GtkPrintContext *context, GnomeCalendar *gcal, time_t whence, struct pdinfo *pdi, double left, double right, double top, double bottom) { + ECalModel *model; PangoFontDescription *font_hour, *font_minute; gdouble yinc, y; gdouble width = DAY_VIEW_TIME_COLUMN_WIDTH; @@ -2310,7 +2297,8 @@ print_work_week_background (GtkPrintContext *context, GnomeCalendar *gcal, gdouble hour_minute_xl, hour_minute_xr; cairo_t *cr; - use_24_hour = calendar_config_get_24_hour_format (); + model = gnome_calendar_get_model (gcal); + use_24_hour = e_cal_model_get_use_24_hour_format (model); /* Fill the left time column in light-gray. */ print_border (context, left, left + width, top, bottom, -1.0, 0.9); @@ -2440,7 +2428,8 @@ print_work_week_day_details (GtkPrintContext *context, GnomeCalendar *gcal, time_t whence, double left, double right, double top, double bottom, struct pdinfo *_pdi) { - icaltimezone *zone = calendar_config_get_icaltimezone (); + ECalModel *model; + icaltimezone *zone; EDayViewEvent *event; PangoFontDescription *font; time_t start, end; @@ -2452,7 +2441,8 @@ print_work_week_day_details (GtkPrintContext *context, GnomeCalendar *gcal, #define LONG_DAY_EVENTS_TOP_SPACING 4 #define LONG_DAY_EVENTS_BOTTOM_SPACING 2 - ECalModel *model = gnome_calendar_get_model (gcal); + model = gnome_calendar_get_model (gcal); + zone = e_cal_model_get_timezone (model); start = time_day_begin_with_zone (whence, zone); end = time_day_end_with_zone (start, zone); @@ -2462,15 +2452,15 @@ print_work_week_day_details (GtkPrintContext *context, GnomeCalendar *gcal, pdi.day_starts[1] = end; pdi.long_events = g_array_new (FALSE, FALSE, sizeof (EDayViewEvent)); pdi.events[0] = g_array_new (FALSE, FALSE, sizeof (EDayViewEvent)); - pdi.start_hour = calendar_config_get_day_start_hour (); - pdi.end_hour = calendar_config_get_day_end_hour (); - if (calendar_config_get_day_end_minute () != 0) + pdi.start_hour = e_cal_model_get_work_day_start_hour (model); + pdi.end_hour = e_cal_model_get_work_day_end_hour (model); + if (e_cal_model_get_work_day_end_minute (model) != 0) pdi.end_hour++; pdi.rows = (pdi.end_hour - pdi.start_hour) * 2; pdi.mins_per_row = 30; pdi.start_minute_offset = pdi.start_hour * 60; pdi.end_minute_offset = pdi.end_hour * 60; - pdi.use_24_hour_format = calendar_config_get_24_hour_format (); + pdi.use_24_hour_format = e_cal_model_get_use_24_hour_format (model); /* Get the events from the server. */ e_cal_model_generate_instances (model, start, end, print_day_details_cb, &pdi); @@ -2610,18 +2600,19 @@ print_work_week_day_details (GtkPrintContext *context, GnomeCalendar *gcal, /* Figure out what the overal hour limits are */ static gboolean -print_work_week_view_cb (ECalComponent *comp, time_t istart, time_t iend, - gpointer data) +print_work_week_view_cb (ECalComponent *comp, + time_t istart, + time_t iend, + gpointer data) { ECalModelGenerateInstancesData *mdata = (ECalModelGenerateInstancesData *) data; struct pdinfo *pdi = (struct pdinfo *) mdata->cb_data; - icaltimezone *zone = calendar_config_get_icaltimezone (); struct icaltimetype tt; - tt = icaltime_from_timet_with_zone (istart, FALSE, zone); + tt = icaltime_from_timet_with_zone (istart, FALSE, pdi->zone); pdi->start_hour = MIN (pdi->start_hour, tt.hour); - tt = icaltime_from_timet_with_zone (iend, FALSE, zone); + tt = icaltime_from_timet_with_zone (iend, FALSE, pdi->zone); /* If we're past the hour, use the next one */ pdi->end_hour = MAX(pdi->end_hour, tt.minute ? tt.hour + 1 : tt.hour); @@ -2632,17 +2623,21 @@ static void print_work_week_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) { GtkPageSetup *setup; - icaltimezone *zone = calendar_config_get_icaltimezone (); + icaltimezone *zone; time_t when, start, end; gdouble width, height, l, small_month_width = calc_small_month_width (context, HEADER_HEIGHT); gint i, days = 5; char buf[100]; const int LONG_EVENT_OFFSET = 6; struct pdinfo pdi; + struct tm tm; gdouble day_width, day_x; - ECalModel *model = gnome_calendar_get_model (gcal); + ECalModel *model; gdouble weeknum_inc = get_show_week_numbers () ? small_month_width / 7.0 : 0; + model = gnome_calendar_get_model (gcal); + zone = e_cal_model_get_timezone (model); + setup = gtk_print_context_get_page_setup (context); width = gtk_page_setup_get_page_width (setup, GTK_UNIT_POINTS); @@ -2653,8 +2648,8 @@ print_work_week_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date end = time_add_day_with_zone (start, days, zone); pdi.days_shown = days; - pdi.start_hour = calendar_config_get_day_start_hour (); - pdi.end_hour = calendar_config_get_day_end_hour (); + pdi.start_hour = e_cal_model_get_work_day_start_hour (model); + pdi.end_hour = e_cal_model_get_work_day_end_hour (model); e_cal_model_generate_instances (model, start, end, print_work_week_view_cb, &pdi); @@ -2679,15 +2674,17 @@ print_work_week_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date DATE_MONTH | DATE_YEAR, 0, 0, FALSE); /* Print the start day of the week, e.g. '7th May 2001'. */ - format_date (start, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100); + convert_timet_to_struct_tm (start, zone, &tm); + format_date (&tm, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100); print_text_size_bold (context, buf, PANGO_ALIGN_LEFT, 3, width, 4, 4 + 24); /* Print the end day of the week, e.g. '13th May 2001'. */ /* We need to substract one or the wrong day will be printed */ - format_date (time_add_day_with_zone (end, -1, zone), - DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100); + convert_timet_to_struct_tm ( + time_add_day_with_zone (end, -1, zone), zone, &tm); + format_date (&tm, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100); print_text_size_bold (context, buf, PANGO_ALIGN_LEFT, 3, width, 24 + 3, 24 + 3 + 24); @@ -2699,7 +2696,8 @@ print_work_week_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date day_x = DAY_VIEW_TIME_COLUMN_WIDTH + day_width * i; /* Print the day, e.g. 'Tuesday'. */ - format_date (when, DATE_DAYNAME, buf, 100); + convert_timet_to_struct_tm (when, zone, &tm); + format_date (&tm, DATE_DAYNAME, buf, 100); print_text_size_bold (context, buf, PANGO_ALIGN_LEFT, day_x + 4, day_x + day_width, @@ -2716,7 +2714,8 @@ static void print_week_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) { GtkPageSetup *setup; - icaltimezone *zone = calendar_config_get_icaltimezone (); + ECalModel *model; + icaltimezone *zone; gdouble l, week_numbers_inc, small_month_width; gchar buf[100]; time_t when; @@ -2731,8 +2730,11 @@ print_week_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) small_month_width = calc_small_month_width (context, HEADER_HEIGHT); week_numbers_inc = get_show_week_numbers () ? small_month_width / 7.0 : 0; - tm = *convert_timet_to_struct_tm (date, zone); - week_start_day = calendar_config_get_week_start_day (); + model = gnome_calendar_get_model (gcal); + zone = e_cal_model_get_timezone (model); + + convert_timet_to_struct_tm (date, zone, &tm); + week_start_day = e_cal_model_get_week_start_day (model); when = time_week_begin_with_zone (date, week_start_day, zone); /* If the week starts on a Sunday, we have to show the Saturday first, @@ -2774,14 +2776,16 @@ print_week_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) time_add_week_with_zone (when, 1, zone), FALSE); /* Print the start day of the week, e.g. '7th May 2001'. */ - format_date (when, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100); + convert_timet_to_struct_tm (when, zone, &tm); + format_date (&tm, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100); print_text_size_bold (context, buf, PANGO_ALIGN_LEFT, 3, width, 4, 4 + 24); /* Print the end day of the week, e.g. '13th May 2001'. */ when = time_add_day_with_zone (when, 6, zone); - format_date (when, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100); + convert_timet_to_struct_tm (when, zone, &tm); + format_date (&tm, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100); print_text_size_bold (context, buf, PANGO_ALIGN_LEFT, 3, width, 24 + 3, 24 + 3 + 24); @@ -2790,11 +2794,16 @@ print_week_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) static void print_month_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) { + ECalModel *model; GtkPageSetup *setup; - icaltimezone *zone = calendar_config_get_icaltimezone (); + icaltimezone *zone; gchar buf[100]; gdouble width, height; gdouble l, week_numbers_inc, small_month_width; + struct tm tm; + + model = gnome_calendar_get_model (gcal); + zone = e_cal_model_get_timezone (model); setup = gtk_print_context_get_page_setup (context); @@ -2823,51 +2832,20 @@ print_month_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) DATE_MONTH | DATE_YEAR, 0, 0, FALSE); /* Print the month, e.g. 'May 2001'. */ - format_date (date, DATE_MONTH | DATE_YEAR, buf, 100); + convert_timet_to_struct_tm (date, zone, &tm); + format_date (&tm, DATE_MONTH | DATE_YEAR, buf, 100); print_text_size_bold (context, buf, PANGO_ALIGN_CENTER, 3, width - 3, 3, 3 + 24); } -/* XXX Evolution doesn't have a "year" view. */ -#if 0 -static void -print_year_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date) -{ - GtkPageSetup *setup; - gchar buf[100]; - cairo_t *cr; - gdouble width, height; - - setup = gtk_print_context_get_page_setup (context); - - width = gtk_page_setup_get_page_width (setup, GTK_UNIT_POINTS); - height = gtk_page_setup_get_page_height (setup, GTK_UNIT_POINTS); - - cr = gtk_print_context_get_cairo_context (context); - - cairo_show_page (cr); - print_year_summary (context, gcal, date, 0.0, - width, 50, - height, TRUE); - - /* centered title */ - format_date (date, DATE_YEAR, buf, 100); - print_text_size_bold (context, buf, PANGO_ALIGN_CENTER, - 3, width, - 3, 27); - cr=gtk_print_context_get_cairo_context (context); - cairo_show_page (cr); -} -#endif - static gboolean same_date (struct tm tm1, time_t t2, icaltimezone *zone) { struct tm tm2; - tm2 = *convert_timet_to_struct_tm (t2, zone); + convert_timet_to_struct_tm (t2, zone, &tm2); return tm1.tm_mday == tm2.tm_mday && @@ -2877,32 +2855,31 @@ same_date (struct tm tm1, time_t t2, icaltimezone *zone) static void write_label_piece (time_t t, - time_t *start_cmp, + time_t *start_cmp, + icaltimezone *zone, + gboolean use_24_hour_format, gchar *buffer, gint size, gchar *stext, const gchar *etext) { - icaltimezone *zone = calendar_config_get_icaltimezone (); struct tm tmp_tm; gint len; - tmp_tm = *convert_timet_to_struct_tm (t, zone); + convert_timet_to_struct_tm (t, zone, &tmp_tm); if (stext != NULL) strcat (buffer, stext); len = strlen (buffer); if (start_cmp && same_date (tmp_tm, *start_cmp, zone)) - e_time_format_time (&tmp_tm, - calendar_config_get_24_hour_format (), - FALSE, - &buffer[len], size - len); + e_time_format_time ( + &tmp_tm, use_24_hour_format, + FALSE, &buffer[len], size - len); else - e_time_format_date_and_time (&tmp_tm, - calendar_config_get_24_hour_format (), - FALSE, FALSE, - &buffer[len], size - len); + e_time_format_date_and_time ( + &tmp_tm, use_24_hour_format, FALSE, + FALSE, &buffer[len], size - len); if (etext != NULL) strcat (buffer, etext); } @@ -2926,8 +2903,15 @@ get_zone_from_tzid (ECal *client, const gchar *tzid) } static void -print_date_label (GtkPrintContext *context, ECalComponent *comp, ECal *client, - double left, double right, double top, double bottom) +print_date_label (GtkPrintContext *context, + ECalComponent *comp, + ECal *client, + icaltimezone *zone, + gboolean use_24_hour_format, + gdouble left, + gdouble right, + gdouble top, + gdouble bottom) { icaltimezone *start_zone, *end_zone, *due_zone, *completed_zone; ECalComponentDateTime datetime; @@ -2938,7 +2922,7 @@ print_date_label (GtkPrintContext *context, ECalComponent *comp, ECal *client, if (datetime.value) { start_zone = get_zone_from_tzid (client, datetime.tzid); if (!start_zone || datetime.value->is_date) - start_zone = calendar_config_get_icaltimezone (); + start_zone = zone; start = icaltime_as_timet_with_zone (*datetime.value, start_zone); } @@ -2948,7 +2932,7 @@ print_date_label (GtkPrintContext *context, ECalComponent *comp, ECal *client, if (datetime.value) { end_zone = get_zone_from_tzid (client, datetime.tzid); if (!end_zone || datetime.value->is_date) - end_zone = calendar_config_get_icaltimezone (); + end_zone = zone; end = icaltime_as_timet_with_zone (*datetime.value, end_zone); } @@ -2958,7 +2942,7 @@ print_date_label (GtkPrintContext *context, ECalComponent *comp, ECal *client, if (datetime.value) { due_zone = get_zone_from_tzid (client, datetime.tzid); if (!due_zone || datetime.value->is_date) - due_zone = calendar_config_get_icaltimezone (); + due_zone = zone; due = icaltime_as_timet_with_zone (*datetime.value, due_zone); } @@ -2975,12 +2959,16 @@ print_date_label (GtkPrintContext *context, ECalComponent *comp, ECal *client, buffer[0] = '\0'; if (start > 0) - write_label_piece (start, NULL, buffer, 1024, NULL, NULL); + write_label_piece ( + start, NULL, zone, use_24_hour_format, + buffer, 1024, NULL, NULL); if (end > 0 && start > 0) { /* Translators: This is part of "START to END" text, * where START and END are date/times. */ - write_label_piece (end, &start, buffer, 1024, _(" to "), NULL); + write_label_piece ( + end, &start, zone, use_24_hour_format, + buffer, 1024, _(" to "), NULL); } if (complete > 0) { @@ -2988,11 +2976,15 @@ print_date_label (GtkPrintContext *context, ECalComponent *comp, ECal *client, /* Translators: This is part of "START to END * (Completed COMPLETED)", where COMPLETED is a * completed date/time. */ - write_label_piece (complete, NULL, buffer, 1024, _(" (Completed "), ")"); + write_label_piece ( + complete, NULL, zone, use_24_hour_format, + buffer, 1024, _(" (Completed "), ")"); } else { /* Translators: This is part of "Completed COMPLETED", * where COMPLETED is a completed date/time. */ - write_label_piece (complete, &start, buffer, 1024, _("Completed "), NULL); + write_label_piece ( + complete, &start, zone, use_24_hour_format, + buffer, 1024, _("Completed "), NULL); } } @@ -3000,12 +2992,16 @@ print_date_label (GtkPrintContext *context, ECalComponent *comp, ECal *client, if (start > 0) { /* Translators: This is part of "START (Due DUE)", * where START and DUE are dates/times. */ - write_label_piece (due, NULL, buffer, 1024, _(" (Due "), ")"); + write_label_piece ( + due, NULL, zone, use_24_hour_format, + buffer, 1024, _(" (Due "), ")"); } else { /* Translators: This is part of "Due DUE", * where DUE is a date/time due the event * should be finished. */ - write_label_piece (due, &start, buffer, 1024, _("Due "), NULL); + write_label_piece ( + due, &start, zone, use_24_hour_format, + buffer, 1024, _("Due "), NULL); } } @@ -3188,7 +3184,10 @@ print_comp_draw_real (GtkPrintOperation *operation, /* Date information */ if (page_nr == 0) - print_date_label (context, comp, client, 0.0, width, top + 3, top + 15); + print_date_label ( + context, comp, client, + pci->zone, pci->use_24_hour_format, + 0.0, width, top + 3, top + 15); top += 20; /* Attendees */ @@ -3374,7 +3373,11 @@ print_comp_begin_print (GtkPrintOperation *operation, } void -print_comp (ECalComponent *comp, ECal *client, GtkPrintOperationAction action) +print_comp (ECalComponent *comp, + ECal *client, + icaltimezone *zone, + gboolean use_24_hour_format, + GtkPrintOperationAction action) { GtkPrintOperation *operation; PrintCompItem pci; @@ -3383,6 +3386,8 @@ print_comp (ECalComponent *comp, ECal *client, GtkPrintOperationAction action) pci.comp = comp; pci.client = client; + pci.zone = zone; + pci.use_24_hour_format = use_24_hour_format; operation = e_print_operation_new (); gtk_print_operation_set_n_pages (operation, 1); diff --git a/calendar/gui/print.h b/calendar/gui/print.h index 5217c473a1..85397b0356 100644 --- a/calendar/gui/print.h +++ b/calendar/gui/print.h @@ -36,15 +36,17 @@ typedef enum { PRINT_VIEW_LIST } PrintView; -void print_calendar (GnomeCalendar *gcal, - GtkPrintOperationAction action, - time_t start); -void print_comp (ECalComponent *comp, - ECal *client, - GtkPrintOperationAction action); -void print_table (ETable *table, - const gchar *dialog_title, - const gchar *print_header, - GtkPrintOperationAction action); +void print_calendar (GnomeCalendar *gcal, + GtkPrintOperationAction action, + time_t start); +void print_comp (ECalComponent *comp, + ECal *client, + icaltimezone *zone, + gboolean use_24_hour_format, + GtkPrintOperationAction action); +void print_table (ETable *table, + const gchar *dialog_title, + const gchar *print_header, + GtkPrintOperationAction action); #endif -- cgit From a891b81cfb3430a764dab0d5644114c4dab22297 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 7 Nov 2010 21:13:03 -0500 Subject: Coding style and whitespace cleanup. --- calendar/gui/e-alarm-list.c | 2 +- calendar/gui/e-day-view-top-item.c | 8 ++++---- calendar/gui/e-meeting-time-sel-item.c | 4 ++-- calendar/gui/e-week-view-event-item.c | 14 +++++++------- calendar/gui/print.c | 22 ++++++++++------------ 5 files changed, 24 insertions(+), 26 deletions(-) (limited to 'calendar') diff --git a/calendar/gui/e-alarm-list.c b/calendar/gui/e-alarm-list.c index 48b55bbc02..c7f7ff9691 100644 --- a/calendar/gui/e-alarm-list.c +++ b/calendar/gui/e-alarm-list.c @@ -556,7 +556,7 @@ e_alarm_list_get_value (GtkTreeModel *tree_model, EAlarmList *alarm_list = E_ALARM_LIST (tree_model); ECalComponentAlarm *alarm; GList *l; - gchar *str; + gchar *str; g_return_if_fail (E_IS_ALARM_LIST (tree_model)); g_return_if_fail (column < E_ALARM_LIST_NUM_COLUMNS); diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c index c58f057903..e517e75781 100644 --- a/calendar/gui/e-day-view-top-item.c +++ b/calendar/gui/e-day-view-top-item.c @@ -360,7 +360,7 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item, cairo_rectangle (cr, item_x - x, item_y - y, - item_w - E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH, item_h); + item_w - E_DAY_VIEW_LONG_EVENT_BORDER_WIDTH, item_h); cairo_clip (cr); time_x = item_x + E_DAY_VIEW_LONG_EVENT_X_PAD - x; @@ -368,7 +368,7 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item, time_x += day_view->digit_width; layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), buffer); - cairo_move_to (cr, + cairo_move_to (cr, time_x, item_y + E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT + E_DAY_VIEW_LONG_EVENT_Y_PAD - y); @@ -413,7 +413,7 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item, time_x += day_view->digit_width; layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), buffer); - cairo_move_to (cr, + cairo_move_to (cr, time_x, item_y + E_DAY_VIEW_LONG_EVENT_Y_PAD + 1 - y); pango_cairo_show_layout (cr, layout); @@ -486,7 +486,7 @@ day_view_top_item_draw_long_event (EDayViewTopItem *top_item, if (icon_x <= max_icon_x) { gdk_cairo_set_source_pixbuf (cr, pixbuf, icon_x, icon_y); - cairo_rectangle (cr, + cairo_rectangle (cr, icon_x, icon_y, E_DAY_VIEW_ICON_WIDTH, E_DAY_VIEW_ICON_HEIGHT); diff --git a/calendar/gui/e-meeting-time-sel-item.c b/calendar/gui/e-meeting-time-sel-item.c index b04591220a..7a50f13a1d 100644 --- a/calendar/gui/e-meeting-time-sel-item.c +++ b/calendar/gui/e-meeting-time-sel-item.c @@ -201,7 +201,7 @@ e_meeting_time_selector_item_update (GnomeCanvasItem *item, const cairo_matrix_t static void draw_strikeout_box (EMeetingTimeSelectorItem *mts_item, cairo_t *cr, - int x, int y, int width, int height) + gint x, gint y, gint width, gint height) { GnomeCanvas *canvas = GNOME_CANVAS_ITEM (mts_item)->canvas; EMeetingTimeSelector *mts = mts_item->mts; @@ -291,7 +291,7 @@ e_meeting_time_selector_item_draw (GnomeCanvasItem *item, GdkDrawable *drawable, if (e_meeting_attendee_get_has_calendar_info (ia)) { if (e_meeting_time_selector_item_calculate_busy_range (mts, row, x, width, &start_x, &end_x)) { if (start_x >= width || end_x <= 0) { - draw_strikeout_box (mts_item, cr, 0, row_y, width, mts->row_height); + draw_strikeout_box (mts_item, cr, 0, row_y, width, mts->row_height); } else { if (start_x >= 0) { draw_strikeout_box (mts_item, cr, 0, row_y, start_x, mts->row_height); diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c index 569449fe34..8a525ebfd6 100644 --- a/calendar/gui/e-week-view-event-item.c +++ b/calendar/gui/e-week-view-event-item.c @@ -329,13 +329,13 @@ week_view_draw_time (EWeekView *week_view, /* Draw the hour. */ if (hour_to_display < 10) { pango_layout_set_text (layout, buffer + 1, 1); - cairo_move_to (cr, + cairo_move_to (cr, time_x + week_view->digit_width, time_y_normal_font); pango_cairo_show_layout (cr, layout); } else { pango_layout_set_text (layout, buffer, 2); - cairo_move_to (cr, + cairo_move_to (cr, time_x, time_y_normal_font); pango_cairo_show_layout (cr, layout); @@ -346,7 +346,7 @@ week_view_draw_time (EWeekView *week_view, /* Draw the start minute, in the small font. */ pango_layout_set_font_description (layout, week_view->small_font_desc); pango_layout_set_text (layout, buffer + 3, 2); - cairo_move_to (cr, + cairo_move_to (cr, time_x, time_y_small_font); pango_cairo_show_layout (cr, layout); @@ -359,7 +359,7 @@ week_view_draw_time (EWeekView *week_view, if (!e_cal_model_get_use_24_hour_format (model)) { pango_layout_set_text (layout, suffix, -1); - cairo_move_to (cr, + cairo_move_to (cr, time_x, time_y_normal_font); pango_cairo_show_layout (cr, layout); @@ -1051,9 +1051,9 @@ week_view_event_item_draw (GnomeCanvasItem *canvas_item, cairo_rectangle (cr, x1, y1, - x2 - x1 - E_WEEK_VIEW_EVENT_R_PAD - - E_WEEK_VIEW_EVENT_BORDER_WIDTH + 1, - y2 - y1 + 1); + x2 - x1 - E_WEEK_VIEW_EVENT_R_PAD + - E_WEEK_VIEW_EVENT_BORDER_WIDTH + 1, + y2 - y1 + 1); cairo_clip (cr); week_view_draw_time ( diff --git a/calendar/gui/print.c b/calendar/gui/print.c index 7378ca719f..051dbc7cce 100644 --- a/calendar/gui/print.c +++ b/calendar/gui/print.c @@ -91,8 +91,8 @@ evo_calendar_print_renderer_get_width (GtkPrintContext *context, static gdouble evo_calendar_print_renderer_get_height (GtkPrintContext *context, - PangoFontDescription *font, - const gchar *text) + PangoFontDescription *font, + const gchar *text) { PangoLayout *layout; gint layout_width, layout_height; @@ -2291,7 +2291,7 @@ print_work_week_background (GtkPrintContext *context, GnomeCalendar *gcal, gdouble font_size, max_font_size, hour_font_size, minute_font_size; gchar buf[20]; const gchar *minute; - const int LONG_EVENT_OFFSET = 6; + const gint LONG_EVENT_OFFSET = 6; gboolean use_24_hour; gint i, hour, row; gdouble hour_minute_xl, hour_minute_xr; @@ -2322,7 +2322,6 @@ print_work_week_background (GtkPrintContext *context, GnomeCalendar *gcal, cairo_line_to (cr, right - width, top); cairo_stroke (cr); - /* Calculate the row height. */ if (top > bottom) yinc = (top - bottom) / (pdi->end_hour - pdi->start_hour); @@ -2382,7 +2381,6 @@ print_work_week_background (GtkPrintContext *context, GnomeCalendar *gcal, hour_minute_xr, right - 3, y - yinc, y - yinc + minute_font_size); - /* Draw the horizontal line between hours, across the entire width of the day view. */ cr = gtk_print_context_get_cairo_context (context); @@ -2397,12 +2395,12 @@ print_work_week_background (GtkPrintContext *context, GnomeCalendar *gcal, cairo_line_to (cr, right, y - yinc / 2); cairo_set_line_width (cr, 1); cairo_stroke (cr); - row ++; + row++; } /* Draw the vertical lines for the days */ day_width = (right - left - 2*width) / pdi->days_shown; - for(i = 0; i < pdi->days_shown - 1; ++i){ + for (i = 0; i < pdi->days_shown - 1; ++i) { cr = gtk_print_context_get_cairo_context (context); cairo_move_to (cr, left + width + day_width * (i + 1), top); cairo_line_to (cr, left + width + day_width * (i + 1), bottom); @@ -2579,7 +2577,7 @@ print_work_week_day_details (GtkPrintContext *context, GnomeCalendar *gcal, max_font_size = ((top - bottom) / pdi.rows) - 4; else max_font_size = ((bottom - top ) / pdi.rows) - 4; - font_size = MIN(DAY_NORMAL_FONT_SIZE, max_font_size); + font_size = MIN (DAY_NORMAL_FONT_SIZE, max_font_size); font = get_font_for_size (font_size, PANGO_WEIGHT_NORMAL); for (i = 0; i < pdi.events[0]->len; i++) { @@ -2614,7 +2612,7 @@ print_work_week_view_cb (ECalComponent *comp, tt = icaltime_from_timet_with_zone (iend, FALSE, pdi->zone); /* If we're past the hour, use the next one */ - pdi->end_hour = MAX(pdi->end_hour, tt.minute ? tt.hour + 1 : tt.hour); + pdi->end_hour = MAX (pdi->end_hour, tt.minute ? tt.hour + 1 : tt.hour); return TRUE; } @@ -2627,8 +2625,8 @@ print_work_week_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date time_t when, start, end; gdouble width, height, l, small_month_width = calc_small_month_width (context, HEADER_HEIGHT); gint i, days = 5; - char buf[100]; - const int LONG_EVENT_OFFSET = 6; + gchar buf[100]; + const gint LONG_EVENT_OFFSET = 6; struct pdinfo pdi; struct tm tm; gdouble day_width, day_x; @@ -2692,7 +2690,7 @@ print_work_week_view (GtkPrintContext *context, GnomeCalendar *gcal, time_t date /* Now print each days' events */ day_width = (width - 2*DAY_VIEW_TIME_COLUMN_WIDTH) / days; when = start; - for(i = 0; i < days; ++i){ + for (i = 0; i < days; ++i) { day_x = DAY_VIEW_TIME_COLUMN_WIDTH + day_width * i; /* Print the day, e.g. 'Tuesday'. */ -- cgit From b09b3e9ccacea345fee998ff20ef01ae043eaeac Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 18 Nov 2010 13:35:36 +0100 Subject: Bug #633779 - GtkComboBoxText issues --- calendar/gui/dialogs/event-page.c | 21 +++++++++++++++++---- calendar/gui/dialogs/event-page.ui | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'calendar') diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index 32c2c18653..06ba14751b 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -2859,6 +2859,8 @@ init_widgets (EventPage *epage) GtkTreeSelection *selection; gboolean active; ECal *client; + GtkTreeIter iter; + GtkListStore *store; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (epage)); client = comp_editor_get_client (editor); @@ -3025,17 +3027,28 @@ init_widgets (EventPage *epage) break; } + store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (priv->alarm_time_combo))); if (combo_label) { - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (priv->alarm_time_combo), combo_label); + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, + 0, combo_label, + -1); g_free (combo_label); priv->alarm_map = alarm_map_with_user_time; } else { priv->alarm_map = alarm_map_without_user_time; } - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (priv->alarm_time_combo), _("Customize")); - /* Translators: "None" for "No alarm set" */ - gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (priv->alarm_time_combo), C_("cal-alarms", "None")); + gtk_list_store_append (store, &iter); + gtk_list_store_set (store, &iter, + 0, _("Customize"), + -1); + + gtk_list_store_insert (store, &iter, 0); + gtk_list_store_set (store, &iter, + /* Translators: "None" for "No alarm set" */ + 0, C_("cal-alarms", "None"), + -1); g_signal_connect_swapped ( priv->alarm_time_combo, "changed", diff --git a/calendar/gui/dialogs/event-page.ui b/calendar/gui/dialogs/event-page.ui index fe3ece21ca..17919048a6 100644 --- a/calendar/gui/dialogs/event-page.ui +++ b/calendar/gui/dialogs/event-page.ui @@ -1059,7 +1059,7 @@
- + True False True -- cgit From eeec90235abe465e9cc49194b55ee2635faf023f Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 24 Nov 2010 14:28:53 +0100 Subject: Bug #635673 - Stack overflow when opening slow calendar --- calendar/common/authentication.c | 1 + calendar/gui/e-cal-model.c | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'calendar') diff --git a/calendar/common/authentication.c b/calendar/common/authentication.c index 0420f1f5b5..286b7d6c46 100644 --- a/calendar/common/authentication.c +++ b/calendar/common/authentication.c @@ -274,6 +274,7 @@ fail: } else if (g_error_matches ( error, E_CALENDAR_ERROR, E_CALENDAR_STATUS_BUSY)) { g_clear_error (&error); + g_usleep (250000); goto try_again; } else { diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c index 294b54c760..f33a6f55c1 100644 --- a/calendar/gui/e-cal-model.c +++ b/calendar/gui/e-cal-model.c @@ -2524,6 +2524,19 @@ backend_died_cb (ECal *client, gpointer user_data) e_cal_model_remove_client (model, client); } +static gboolean +wait_open_cb (gpointer data) +{ + ECal *client = data; + + g_return_val_if_fail (client != NULL, FALSE); + g_return_val_if_fail (E_IS_CAL (client), FALSE); + + e_cal_open_async (client, FALSE); + + return FALSE; +} + static void cal_opened_cb (ECal *client, const GError *error, gpointer user_data) { @@ -2531,10 +2544,13 @@ cal_opened_cb (ECal *client, const GError *error, gpointer user_data) ECalModelClient *client_data; if (g_error_matches (error, E_CALENDAR_ERROR, E_CALENDAR_STATUS_BUSY)) { - e_cal_open_async (client, FALSE); + g_timeout_add (250, wait_open_cb, client); return; } + /* Stop listening for this calendar to be opened */ + g_signal_handlers_disconnect_matched (client, G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, cal_opened_cb, model); + if (error) { e_cal_model_remove_client (model, client); e_cal_model_update_status_message (model, NULL, -1.0); @@ -2543,9 +2559,6 @@ cal_opened_cb (ECal *client, const GError *error, gpointer user_data) e_cal_model_update_status_message (model, NULL, -1.0); - /* Stop listening for this calendar to be opened */ - g_signal_handlers_disconnect_matched (client, G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, cal_opened_cb, model); - client_data = find_client_data (model, client); g_return_if_fail (client_data); -- cgit From d5453070876d5992b93973250cb01a949e119828 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 26 Nov 2010 12:23:01 +0100 Subject: Bug #635828 - Do not send meeting mails with no recipient --- calendar/gui/dialogs/send-comp.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'calendar') diff --git a/calendar/gui/dialogs/send-comp.c b/calendar/gui/dialogs/send-comp.c index 4a9f80ef21..a965c3d4da 100644 --- a/calendar/gui/dialogs/send-comp.c +++ b/calendar/gui/dialogs/send-comp.c @@ -43,6 +43,37 @@ component_has_new_attendees (ECalComponent *comp) return g_object_get_data (G_OBJECT (comp), "new-attendees") != NULL; } + +static gboolean +component_has_recipients (ECalComponent *comp) +{ + GSList *attendees = NULL; + ECalComponentAttendee *attendee; + ECalComponentOrganizer organizer; + gboolean res = FALSE; + + g_return_val_if_fail (comp != NULL, FALSE); + + e_cal_component_get_attendee_list (comp, &attendees); + + if (!attendees) + return FALSE; + + if (g_slist_length (attendees) > 1 || !e_cal_component_has_organizer (comp)) { + e_cal_component_free_attendee_list (attendees); + return TRUE; + } + + attendee = attendees->data; + + e_cal_component_get_organizer (comp, &organizer); + res = organizer.value && attendee && attendee->value && g_ascii_strcasecmp (organizer.value, attendee->value) != 0; + + e_cal_component_free_attendee_list (attendees); + + return res; +} + static gboolean have_nonprocedural_alarm (ECalComponent *comp) { @@ -114,7 +145,7 @@ send_component_dialog (GtkWindow *parent, ECal *client, ECalComponent *comp, gbo if (strip_alarms) *strip_alarms = TRUE; - if (e_cal_get_save_schedules (client)) + if (e_cal_get_save_schedules (client) || !component_has_recipients (comp)) return FALSE; vtype = e_cal_component_get_vtype (comp); -- cgit From a1a842ac20eee58037c3c3db159f3d2768ca9efe Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 30 Nov 2010 16:18:42 +0100 Subject: Default to beginning of the day for the last alarm notification --- calendar/gui/alarm-notify/alarm-queue.c | 2 +- calendar/gui/alarm-notify/config-data.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'calendar') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index e8b3f86201..38db9368e6 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -1867,7 +1867,7 @@ alarm_queue_init (gpointer data) queue_midnight_refresh (); if (config_data_get_last_notification_time (NULL) == -1) { - time_t tmval = time (NULL); + time_t tmval = time_day_begin (time (NULL)); d(printf("%s:%d (alarm_queue_init) - Setting last notification time to %s\n",__FILE__, __LINE__, e_ctime(&tmval))); config_data_set_last_notification_time (NULL, tmval); } diff --git a/calendar/gui/alarm-notify/config-data.c b/calendar/gui/alarm-notify/config-data.c index 00cb0dc7ba..65e3e15a87 100644 --- a/calendar/gui/alarm-notify/config-data.c +++ b/calendar/gui/alarm-notify/config-data.c @@ -336,7 +336,7 @@ config_data_get_last_notification_time (ECal *cal) return val; } - return time (NULL); + return -1; } /** -- cgit From 5549b3311ff09e4ea83eeedd5e48e16e5530a0d3 Mon Sep 17 00:00:00 2001 From: Vibha Yadav Date: Wed, 1 Dec 2010 17:24:46 +0530 Subject: Bug #602183 (bnc) - Crash in Mini Calendar View Calendar view crashes on updating the scroll bar of newly created layout for events. Hence tries to access the event's canvas which is not yet drawn. Hence calling scroll bar update after drawing long events. --- calendar/gui/e-day-view.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'calendar') diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index f81afae485..ea2b13c2f7 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -4633,17 +4633,18 @@ e_day_view_check_layout (EDayView *day_view) day_view->days_shown, day_view->day_starts, &rows_in_top_display); - - if (day_view->rows_in_top_display != rows_in_top_display) { - day_view->rows_in_top_display = rows_in_top_display; - e_day_view_update_top_scroll (day_view, FALSE); - } } if (day_view->long_events_need_layout || day_view->long_events_need_reshape) e_day_view_reshape_long_events (day_view); + if (day_view->long_events_need_layout + && day_view->rows_in_top_display != rows_in_top_display) { + day_view->rows_in_top_display = rows_in_top_display; + e_day_view_update_top_scroll (day_view, FALSE); + } + day_view->long_events_need_layout = FALSE; day_view->long_events_need_reshape = FALSE; -- cgit From ab0430a3f37b01f104d8a4556fdb527c0bd92116 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 3 Dec 2010 21:33:01 +0100 Subject: Show calendar backend errors in an alert sink --- calendar/calendar.error.xml | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'calendar') diff --git a/calendar/calendar.error.xml b/calendar/calendar.error.xml index 3d1f2c94a5..3d7d657f9d 100644 --- a/calendar/calendar.error.xml +++ b/calendar/calendar.error.xml @@ -289,6 +289,14 @@