diff options
author | JP Rosevear <jpr@ximian.com> | 2003-10-28 06:46:10 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2003-10-28 06:46:10 +0800 |
commit | 238350ee212d14e29fbf849450039b2d6fea761d (patch) | |
tree | 3bcf99cc9feb3f5d1013ff6153991163e92f2161 /calendar | |
parent | aa7103dfa113dca7b1da05f73ed71790da2557e8 (diff) | |
download | gsoc2013-evolution-238350ee212d14e29fbf849450039b2d6fea761d.tar.gz gsoc2013-evolution-238350ee212d14e29fbf849450039b2d6fea761d.tar.zst gsoc2013-evolution-238350ee212d14e29fbf849450039b2d6fea761d.zip |
store config objects as well (gnome_calendar_set_default_uri): return
2003-10-27 JP Rosevear <jpr@ximian.com>
* gui/gnome-cal.c (setup_widgets): store config objects as well
(gnome_calendar_set_default_uri): return FALSE if the
pre-condition fails
(gnome_calendar_update_config_settings): remove settings that are
now handled by the config objects
* gui/e-week-view.c (e_week_view_set_compress_weekend): queue a
draw
* gui/e-itip-control.c (start_default_server): comment out
* gui/e-day-view-config.[hc]: a class to track config changes of
interest to day views
* gui/e-week-view.[hc]: ditto for week views
* gui/calendar-config.h: add protos
* gui/calendar-config.c: use the #defines for the keys and add
notification routines
* gui/calendar-config-keys.h: a list of defines for gconf keys
* gui/Makefile.am: build new files
svn path=/trunk/; revision=23094
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 27 | ||||
-rw-r--r-- | calendar/gui/Makefile.am | 5 | ||||
-rw-r--r-- | calendar/gui/calendar-config-keys.h | 71 | ||||
-rw-r--r-- | calendar/gui/calendar-config.c | 273 | ||||
-rw-r--r-- | calendar/gui/calendar-config.h | 17 | ||||
-rw-r--r-- | calendar/gui/e-day-view-config.c | 443 | ||||
-rw-r--r-- | calendar/gui/e-day-view-config.h | 59 | ||||
-rw-r--r-- | calendar/gui/e-itip-control.c | 3 | ||||
-rw-r--r-- | calendar/gui/e-week-view-config.c | 299 | ||||
-rw-r--r-- | calendar/gui/e-week-view-config.h | 59 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 4 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 78 |
12 files changed, 1158 insertions, 180 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index ac913678b6..64d3db8b87 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,30 @@ +2003-10-27 JP Rosevear <jpr@ximian.com> + + * gui/gnome-cal.c (setup_widgets): store config objects as well + (gnome_calendar_set_default_uri): return FALSE if the + pre-condition fails + (gnome_calendar_update_config_settings): remove settings that are + now handled by the config objects + + * gui/e-week-view.c (e_week_view_set_compress_weekend): queue a + draw + + * gui/e-itip-control.c (start_default_server): comment out + + * gui/e-day-view-config.[hc]: a class to track config changes of + interest to day views + + * gui/e-week-view.[hc]: ditto for week views + + * gui/calendar-config.h: add protos + + * gui/calendar-config.c: use the #defines for the keys and add + notification routines + + * gui/calendar-config-keys.h: a list of defines for gconf keys + + * gui/Makefile.am: build new files + 2003-10-27 Rodrigo Moya <rodrigo@ximian.com> * gui/e-cal-model.h: changed fill_component_from_model virtual diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 0106a248c6..5b65905f60 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -81,6 +81,7 @@ libevolution_calendar_la_SOURCES = \ cal-search-bar.h \ calendar-config.c \ calendar-config.h \ + calendar-config-keys.h \ calendar-commands.c \ calendar-commands.h \ calendar-component.c \ @@ -117,6 +118,8 @@ libevolution_calendar_la_SOURCES = \ e-comp-editor-registry.h \ e-date-time-list.c \ e-date-time-list.h \ + e-day-view-config.c \ + e-day-view-config.h \ e-day-view-layout.c \ e-day-view-layout.h \ e-day-view-main-item.c \ @@ -146,6 +149,8 @@ libevolution_calendar_la_SOURCES = \ e-select-names-editable.h \ e-select-names-renderer.c \ e-select-names-renderer.h \ + e-week-view-config.c \ + e-week-view-config.h \ e-week-view-event-item.c \ e-week-view-event-item.h \ e-week-view-layout.c \ diff --git a/calendar/gui/calendar-config-keys.h b/calendar/gui/calendar-config-keys.h new file mode 100644 index 0000000000..f6e7c023c6 --- /dev/null +++ b/calendar/gui/calendar-config-keys.h @@ -0,0 +1,71 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Authors : + * JP Rosevear <jpr@ximian.com> + * + * Copyright 2003, Ximian, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +#ifndef _CALENDAR_CONFIG_KEYS_H_ +#define _CALENDAR_CONFIG_KEYS_H_ + +G_BEGIN_DECLS + +#define CALENDAR_CONFIG_PREFIX "/apps/evolution/calendar" + +/* Display settings */ +#define CALENDAR_CONFIG_TIMEZONE CALENDAR_CONFIG_PREFIX "/display/timezone" +#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" +#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_TIME_DIVISIONS CALENDAR_CONFIG_PREFIX "/display/time_divisions" +#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_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" + +/* Date navigator settings */ +#define CALENDAR_CONFIG_DN_SHOW_WEEK_NUMBERS CALENDAR_CONFIG_PREFIX "/date_navigator/show_week_numbers" + +/* Task display settings */ +#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" + +/* 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" +#define CALENDAR_CONFIG_DEFAULT_REMINDER_INTERVAL CALENDAR_CONFIG_PREFIX "/other/default_reminder_interval" +#define CALENDAR_CONFIG_DEFAULT_REMINDER_UNITS CALENDAR_CONFIG_PREFIX "/other/default_reminder_units" + +G_END_DECLS + +#endif diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index 2ac2a4062b..fe5bb487d4 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -27,7 +27,10 @@ * calendar-config.c - functions to load/save/get/set user settings. */ +#ifdef HAVE_CONFIG_H #include <config.h> +#endif + #include <string.h> #include <time.h> #include <gtk/gtksignal.h> @@ -41,11 +44,12 @@ #include "calendar-commands.h" #include "e-tasks.h" #include "e-cell-date-edit-text.h" +#include "calendar-config-keys.h" #include "calendar-config.h" -#include "e-util/e-config-listener.h" -static EConfigListener *config = NULL; + +static GConfClient *config = NULL; static void on_timezone_set (GnomeDialog *dialog, int button, @@ -67,8 +71,16 @@ calendar_config_init (void) if (config) return; - config = e_config_listener_new (); + config = gconf_client_get_default (); g_atexit ((GVoidFunc) do_cleanup); + + gconf_client_add_dir (config, CALENDAR_CONFIG_PREFIX, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL); +} + +void +calendar_config_remove_notification (guint id) +{ + gconf_client_notify_remove (config, id); } /* Returns TRUE if the locale has 'am' and 'pm' strings defined, in which @@ -110,33 +122,23 @@ units_to_string (CalUnits units) /* The current timezone, e.g. "Europe/London". It may be NULL, in which case you should assume UTC (though Evolution will show the timezone-setting dialog the next time a calendar or task folder is selected). */ -gchar* +gchar * calendar_config_get_timezone (void) { - static char *timezone = NULL; - - if (timezone) - g_free (timezone); - - timezone = e_config_listener_get_string_with_default (config, - "/apps/evolution/calendar/display/timezone", - "UTC", NULL); - if (!timezone) - timezone = g_strdup ("UTC"); - - return timezone; + /* FIXME Guard against NULL? */ + return gconf_client_get_string (config, CALENDAR_CONFIG_TIMEZONE, NULL); } /* Sets the timezone. If set to NULL it defaults to UTC. FIXME: Should check it is being set to a valid timezone. */ void -calendar_config_set_timezone (gchar *timezone) +calendar_config_set_timezone (gchar *timezone) { if (timezone && timezone[0]) - e_config_listener_set_string (config, "/apps/evolution/calendar/display/timezone", timezone); + gconf_client_set_string (config, CALENDAR_CONFIG_TIMEZONE, timezone, NULL); else - e_config_listener_set_string (config, "/apps/evolution/calendar/display/timezone", "UTC"); + gconf_client_set_string (config, CALENDAR_CONFIG_TIMEZONE, "UTC", NULL); } @@ -148,10 +150,8 @@ calendar_config_get_24_hour_format (void) choice of 12-hour or 24-hour time format, with 12-hour as the default. If the locale doesn't have 'am' and 'pm' strings we have to use 24-hour format, or strftime()/strptime() won't work. */ - if (calendar_config_locale_supports_12_hour_format ()) { - return e_config_listener_get_boolean_with_default ( - config, "/apps/evolution/calendar/display/use_24hour_format", FALSE, NULL); - } + if (calendar_config_locale_supports_12_hour_format ()) + return gconf_client_get_bool (config, CALENDAR_CONFIG_24HOUR, NULL); return TRUE; } @@ -160,109 +160,172 @@ calendar_config_get_24_hour_format (void) void calendar_config_set_24_hour_format (gboolean use_24_hour) { - e_config_listener_set_boolean (config, "/apps/evolution/calendar/display/use_24hour_format", use_24_hour); + gconf_client_set_bool (config, CALENDAR_CONFIG_24HOUR, use_24_hour, NULL); } +guint +calendar_config_add_notification_24_hour_format (GConfClientNotifyFunc func, gpointer data) +{ + guint id; + + id = gconf_client_notify_add (config, CALENDAR_CONFIG_24HOUR, func, data, NULL, NULL); + + return id; +} /* The start day of the week (0 = Sun to 6 = Mon). */ gint calendar_config_get_week_start_day (void) { - return e_config_listener_get_long_with_default (config, "/apps/evolution/calendar/display/week_start_day", 1, NULL); + return gconf_client_get_int (config, CALENDAR_CONFIG_WEEK_START, NULL); } void calendar_config_set_week_start_day (gint week_start_day) { - e_config_listener_set_long (config, "/apps/evolution/calendar/display/week_start_day", week_start_day); + gconf_client_set_int (config, CALENDAR_CONFIG_WEEK_START, week_start_day, NULL); } +guint +calendar_config_add_notification_week_start_day (GConfClientNotifyFunc func, gpointer data) +{ + guint id; + + id = gconf_client_notify_add (config, CALENDAR_CONFIG_WEEK_START, func, data, NULL, NULL); + + return id; +} /* The start and end times of the work-day. */ gint calendar_config_get_day_start_hour (void) { - return e_config_listener_get_long_with_default (config, "/apps/evolution/calendar/display/day_start_hour", 9, NULL); + return gconf_client_get_int (config, CALENDAR_CONFIG_DAY_START_HOUR, NULL); } void calendar_config_set_day_start_hour (gint day_start_hour) { - e_config_listener_set_long (config, "/apps/evolution/calendar/display/day_start_hour", day_start_hour); + gconf_client_set_int (config, CALENDAR_CONFIG_DAY_START_HOUR, day_start_hour, NULL); } +guint +calendar_config_add_notification_day_start_hour (GConfClientNotifyFunc func, gpointer data) +{ + guint id; + + id = gconf_client_notify_add (config, CALENDAR_CONFIG_DAY_START_HOUR, func, data, NULL, NULL); + + return id; +} gint calendar_config_get_day_start_minute (void) { - return e_config_listener_get_long_with_default (config, "/apps/evolution/calendar/display/day_start_minute", 0, NULL); + return gconf_client_get_int (config, CALENDAR_CONFIG_DAY_START_MINUTE, NULL); } void calendar_config_set_day_start_minute (gint day_start_min) { - e_config_listener_set_long (config, "/apps/evolution/calendar/display/day_start_minute", day_start_min); + gconf_client_set_int (config, CALENDAR_CONFIG_DAY_START_MINUTE, day_start_min, NULL); } +guint +calendar_config_add_notification_day_start_minute (GConfClientNotifyFunc func, gpointer data) +{ + guint id; + + id = gconf_client_notify_add (config, CALENDAR_CONFIG_DAY_START_MINUTE, func, data, NULL, NULL); + + return id; +} gint calendar_config_get_day_end_hour (void) { - return e_config_listener_get_long_with_default (config, "/apps/evolution/calendar/display/day_end_hour", 17, NULL); + return gconf_client_get_int (config, CALENDAR_CONFIG_DAY_END_HOUR, NULL); } void calendar_config_set_day_end_hour (gint day_end_hour) { - e_config_listener_set_long (config, "/apps/evolution/calendar/display/day_end_hour", day_end_hour); + gconf_client_set_int (config, CALENDAR_CONFIG_DAY_END_HOUR, day_end_hour, NULL); } +guint +calendar_config_add_notification_day_end_hour (GConfClientNotifyFunc func, gpointer data) +{ + guint id; + + id = gconf_client_notify_add (config, CALENDAR_CONFIG_DAY_END_HOUR, func, data, NULL, NULL); + + return id; +} gint calendar_config_get_day_end_minute (void) { - return e_config_listener_get_long_with_default (config, "/apps/evolution/calendar/display/day_end_minute", 0, NULL); + return gconf_client_get_int (config, CALENDAR_CONFIG_DAY_END_MINUTE, NULL); } void calendar_config_set_day_end_minute (gint day_end_min) { - e_config_listener_set_long (config, "/apps/evolution/calendar/display/day_end_minute", day_end_min); + gconf_client_set_int (config, CALENDAR_CONFIG_DAY_END_MINUTE, day_end_min, NULL); } +guint +calendar_config_add_notification_day_end_minute (GConfClientNotifyFunc func, gpointer data) +{ + guint id; + + id = gconf_client_notify_add (config, CALENDAR_CONFIG_DAY_END_MINUTE, func, data, NULL, NULL); + + return id; +} /* The time divisions in the Day/Work-Week view in minutes (5/10/15/30/60). */ gint calendar_config_get_time_divisions (void) { - return e_config_listener_get_long_with_default (config, "/apps/evolution/calendar/display/time_divisions", 30, NULL); + return gconf_client_get_int (config, CALENDAR_CONFIG_TIME_DIVISIONS, NULL); } void calendar_config_set_time_divisions (gint divisions) { - e_config_listener_set_long (config, "/apps/evolution/calendar/display/time_divisions", divisions); + gconf_client_set_int (config, CALENDAR_CONFIG_TIME_DIVISIONS, divisions, NULL); } +guint +calendar_config_add_notification_time_divisions (GConfClientNotifyFunc func, gpointer data) +{ + guint id; + + id = gconf_client_notify_add (config, CALENDAR_CONFIG_TIME_DIVISIONS, func, data, NULL, NULL); + + return id; +} /* Whether we show week numbers in the Date Navigator. */ gboolean calendar_config_get_dnav_show_week_no (void) { - return e_config_listener_get_boolean_with_default (config, "/apps/evolution/calendar/date_navigator/show_week_numbers", FALSE, NULL); + return gconf_client_get_bool (config, CALENDAR_CONFIG_DN_SHOW_WEEK_NUMBERS, NULL); } void calendar_config_set_dnav_show_week_no (gboolean show_week_no) { - e_config_listener_set_boolean (config, "/apps/evolution/calendar/date_navigator/show_week_numbers", show_week_no); + gconf_client_set_bool (config, CALENDAR_CONFIG_DN_SHOW_WEEK_NUMBERS, show_week_no, NULL); } @@ -270,14 +333,14 @@ calendar_config_set_dnav_show_week_no (gboolean show_week_no) gint calendar_config_get_default_view (void) { - return e_config_listener_get_long_with_default (config, "/apps/evolution/calendar/display/default_view", 0, NULL); + return gconf_client_get_int (config, CALENDAR_CONFIG_DEFAULT_VIEW, NULL); } void calendar_config_set_default_view (gint view) { - e_config_listener_set_long (config, "/apps/evolution/calendar/display/default_view", view); + gconf_client_set_int (config, CALENDAR_CONFIG_DEFAULT_VIEW, view, NULL); } @@ -285,71 +348,69 @@ calendar_config_set_default_view (gint view) gint calendar_config_get_hpane_pos (void) { - return e_config_listener_get_long_with_default (config, - "/apps/evolution/calendar/display/hpane_position", - 400, NULL); + return gconf_client_get_int (config, CALENDAR_CONFIG_HPANE_POS, NULL); } void calendar_config_set_hpane_pos (gint hpane_pos) { - e_config_listener_set_long (config, "/apps/evolution/calendar/display/hpane_position", hpane_pos); + gconf_client_set_int (config, CALENDAR_CONFIG_HPANE_POS, hpane_pos, NULL); } gint calendar_config_get_vpane_pos (void) { - return e_config_listener_get_long_with_default (config, "/apps/evolution/calendar/display/vpane_position", 150, NULL); + return gconf_client_get_int (config, CALENDAR_CONFIG_VPANE_POS, NULL); } void calendar_config_set_vpane_pos (gint vpane_pos) { - e_config_listener_set_long (config, "/apps/evolution/calendar/display/vpane_position", vpane_pos); + gconf_client_set_int (config, CALENDAR_CONFIG_VPANE_POS, vpane_pos, NULL); } gint calendar_config_get_month_hpane_pos (void) { - return e_config_listener_get_long_with_default (config, "/apps/evolution/calendar/display/month_hpane_position", 32000, NULL); + return gconf_client_get_int (config, CALENDAR_CONFIG_MONTH_HPANE_POS, NULL); } void calendar_config_set_month_hpane_pos (gint hpane_pos) { - e_config_listener_set_long (config, "/apps/evolution/calendar/display/month_hpane_position", hpane_pos); + gconf_client_set_int (config, CALENDAR_CONFIG_MONTH_HPANE_POS, hpane_pos, NULL); } gint calendar_config_get_month_vpane_pos (void) { - return e_config_listener_get_long_with_default (config, "/apps/evolution/calendar/display/month_vpane_position", 150, NULL); + return gconf_client_get_int (config, CALENDAR_CONFIG_MONTH_VPANE_POS, NULL); } void calendar_config_set_month_vpane_pos (gint vpane_pos) { - e_config_listener_set_long (config, "/apps/evolution/calendar/display/month_vpane_position", vpane_pos); + gconf_client_set_int (config, CALENDAR_CONFIG_MONTH_VPANE_POS, vpane_pos, NULL); } gint calendar_config_get_task_vpane_pos (void) { - return e_config_listener_get_long_with_default (config, "/apps/evolution/calendar/display/task_vpane_position", 400, NULL); + return gconf_client_get_int (config, CALENDAR_CONFIG_TASK_VPANE_POS, NULL); } void calendar_config_set_task_vpane_pos (gint vpane_pos) { - e_config_listener_set_long (config, "/apps/evolution/calendar/display/task_vpane_position", vpane_pos); + gconf_client_set_int (config, CALENDAR_CONFIG_TASK_VPANE_POS, vpane_pos, NULL); } @@ -357,61 +418,86 @@ calendar_config_set_task_vpane_pos (gint vpane_pos) gboolean calendar_config_get_compress_weekend (void) { - return e_config_listener_get_boolean_with_default (config, "/apps/evolution/calendar/display/compress_weekend", TRUE, NULL); + return gconf_client_get_bool (config, CALENDAR_CONFIG_COMPRESS_WEEKEND, NULL); } void calendar_config_set_compress_weekend (gboolean compress) { - e_config_listener_set_boolean (config, "/apps/evolution/calendar/display/compress_weekend", compress); + gconf_client_set_bool (config, CALENDAR_CONFIG_COMPRESS_WEEKEND, compress, NULL); } +guint +calendar_config_add_notification_compress_weekend (GConfClientNotifyFunc func, gpointer data) +{ + guint id; + + id = gconf_client_notify_add (config, CALENDAR_CONFIG_COMPRESS_WEEKEND, func, data, NULL, NULL); + + return id; +} /* Whether we show event end times. */ gboolean calendar_config_get_show_event_end (void) { - return e_config_listener_get_boolean_with_default (config, "/apps/evolution/calendar/display/show_event_end", TRUE, NULL); + return gconf_client_get_bool (config, CALENDAR_CONFIG_SHOW_EVENT_END, NULL); } void calendar_config_set_show_event_end (gboolean show_end) { - e_config_listener_set_boolean (config, "/apps/evolution/calendar/display/show_event_end", show_end); + gconf_client_set_bool (config, CALENDAR_CONFIG_SHOW_EVENT_END, show_end, NULL); } +guint +calendar_config_add_notification_show_event_end (GConfClientNotifyFunc func, gpointer data) +{ + guint id; + + id = gconf_client_notify_add (config, CALENDAR_CONFIG_SHOW_EVENT_END, func, data, NULL, NULL); + + return id; +} /* The working days of the week, a bit-wise combination of flags. */ CalWeekdays calendar_config_get_working_days (void) { - return e_config_listener_get_long_with_default (config, - "/apps/evolution/calendar/display/working_days", CAL_MONDAY | CAL_TUESDAY | - CAL_WEDNESDAY | CAL_THURSDAY | CAL_FRIDAY, NULL); + return gconf_client_get_int (config, CALENDAR_CONFIG_WORKING_DAYS, NULL); } void calendar_config_set_working_days (CalWeekdays days) { - e_config_listener_set_long (config, "/apps/evolution/calendar/display/working_days", days); + gconf_client_set_int (config, CALENDAR_CONFIG_WORKING_DAYS, days, NULL); } +guint +calendar_config_add_notification_working_days (GConfClientNotifyFunc func, gpointer data) +{ + guint id; + + id = gconf_client_notify_add (config, CALENDAR_CONFIG_WORKING_DAYS , func, data, NULL, NULL); + + return id; +} /* Settings to hide completed tasks. */ gboolean calendar_config_get_hide_completed_tasks (void) { - return e_config_listener_get_boolean_with_default (config, "/apps/evolution/calendar/tasks/hide_completed", FALSE, NULL); + return gconf_client_get_bool (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED, NULL); } void calendar_config_set_hide_completed_tasks (gboolean hide) { - e_config_listener_set_boolean (config, "/apps/evolution/calendar/tasks/hide_completed", hide); + gconf_client_set_bool (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED, hide, NULL); } @@ -421,7 +507,7 @@ calendar_config_get_hide_completed_tasks_units (void) char *units; CalUnits cu; - units = e_config_listener_get_string_with_default (config, "/apps/evolution/calendar/tasks/hide_completed_units", "days", NULL); + units = gconf_client_get_string (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_UNITS, NULL); if (!strcmp (units, "minutes")) cu = CAL_MINUTES; @@ -452,7 +538,7 @@ calendar_config_set_hide_completed_tasks_units (CalUnits cu) units = g_strdup ("days"); } - e_config_listener_set_string (config, "/apps/evolution/calendar/tasks/hide_completed_sunits", units); + gconf_client_set_string (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_UNITS, units, NULL); g_free (units); } @@ -461,14 +547,14 @@ calendar_config_set_hide_completed_tasks_units (CalUnits cu) gint calendar_config_get_hide_completed_tasks_value (void) { - return e_config_listener_get_long_with_default (config, "/apps/evolution/calendar/tasks/hide_completed_value", 1, NULL); + return gconf_client_get_int (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_VALUE, NULL); } void calendar_config_set_hide_completed_tasks_value (gint value) { - e_config_listener_set_long (config, "/apps/evolution/calendar/tasks/hide_completed_value", value); + gconf_client_set_int (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_VALUE, value, NULL); } /** @@ -482,7 +568,7 @@ calendar_config_set_hide_completed_tasks_value (gint value) gboolean calendar_config_get_confirm_delete (void) { - return e_config_listener_get_boolean_with_default (config, "/apps/evolution/calendar/prompts/confirm_delete", TRUE, NULL); + return gconf_client_get_bool (config, CALENDAR_CONFIG_PROMPT_DELETE, NULL); } /** @@ -495,7 +581,7 @@ calendar_config_get_confirm_delete (void) void calendar_config_set_confirm_delete (gboolean confirm) { - e_config_listener_set_boolean (config, "/apps/evolution/calendar/prompts/confirm_delete", confirm); + gconf_client_set_bool (config, CALENDAR_CONFIG_PROMPT_DELETE, confirm, NULL); } /** @@ -509,7 +595,7 @@ calendar_config_set_confirm_delete (gboolean confirm) gboolean calendar_config_get_confirm_purge (void) { - return e_config_listener_get_boolean_with_default (config, "/apps/evolution/calendar/prompts/confirm_purge", TRUE, NULL); + return gconf_client_get_bool (config, CALENDAR_CONFIG_PROMPT_PURGE, NULL); } /** @@ -522,7 +608,7 @@ calendar_config_get_confirm_purge (void) void calendar_config_set_confirm_purge (gboolean confirm) { - e_config_listener_set_boolean (config, "/apps/evolution/calendar/prompts/confirm_purge", confirm); + gconf_client_set_bool (config, CALENDAR_CONFIG_PROMPT_PURGE, confirm, NULL); } /* This sets all the common config settings for an ECalendar widget. @@ -725,7 +811,7 @@ calendar_config_get_tasks_due_today_color (void) if (color) g_free (color); - color = e_config_listener_get_string_with_default (config, "/apps/evolution/calendar/tasks/colors/due_today", "blue", NULL); + color = gconf_client_get_string (config, CALENDAR_CONFIG_TASKS_DUE_TODAY_COLOR, NULL); return color; } @@ -740,7 +826,7 @@ calendar_config_set_tasks_due_today_color (const char *color) { g_return_if_fail (color != NULL); - e_config_listener_set_string (config, "/apps/evolution/calendar/tasks/colors/due_today", color); + gconf_client_set_string (config, CALENDAR_CONFIG_TASKS_DUE_TODAY_COLOR, color, NULL); } /** @@ -758,7 +844,7 @@ calendar_config_get_tasks_overdue_color (void) if (color) g_free (color); - color = e_config_listener_get_string_with_default (config, "/apps/evolution/calendar/tasks/colors/overdue", "red", NULL); + color = gconf_client_get_string (config, CALENDAR_CONFIG_TASKS_OVERDUE_COLOR, NULL); return color; } @@ -773,7 +859,7 @@ calendar_config_set_tasks_overdue_color (const char *color) { g_return_if_fail (color != NULL); - e_config_listener_set_string (config, "/apps/evolution/calendar/tasks/colors/overdue", color); + gconf_client_set_string (config, CALENDAR_CONFIG_TASKS_OVERDUE_COLOR, color, NULL); } /** @@ -789,7 +875,7 @@ calendar_config_set_tasks_overdue_color (const char *color) gboolean calendar_config_get_use_default_reminder (void) { - return e_config_listener_get_boolean_with_default (config, "/apps/evolution/calendar/other/use_default_reminder", FALSE, NULL); + return gconf_client_get_bool (config, CALENDAR_CONFIG_DEFAULT_REMINDER, NULL); } /** @@ -802,7 +888,7 @@ calendar_config_get_use_default_reminder (void) void calendar_config_set_use_default_reminder (gboolean value) { - e_config_listener_set_boolean (config, "/apps/evolution/calendar/other/use_default_reminder", value); + gconf_client_set_bool (config, CALENDAR_CONFIG_DEFAULT_REMINDER, value, NULL); } /** @@ -816,7 +902,7 @@ calendar_config_set_use_default_reminder (gboolean value) int calendar_config_get_default_reminder_interval (void) { - return e_config_listener_get_long_with_default (config, "/apps/evolution/calendar/other/default_reminder_interval", 15, NULL); + return gconf_client_get_int (config, CALENDAR_CONFIG_DEFAULT_REMINDER_INTERVAL, NULL); } /** @@ -829,7 +915,7 @@ calendar_config_get_default_reminder_interval (void) void calendar_config_set_default_reminder_interval (int interval) { - e_config_listener_set_long (config, "/apps/evolution/calendar/other/default_reminder_interval", interval); + gconf_client_set_int (config, CALENDAR_CONFIG_DEFAULT_REMINDER_INTERVAL, interval, NULL); } /** @@ -846,17 +932,14 @@ calendar_config_get_default_reminder_units (void) char *units; CalUnits cu; - units = e_config_listener_get_string_with_default (config, "/apps/evolution/calendar/other/default_reminder_units", "minutes", NULL); + units = gconf_client_get_string (config, CALENDAR_CONFIG_DEFAULT_REMINDER_UNITS, NULL); - if (!strcmp (units, "days")) + if (units && !strcmp (units, "days")) cu = CAL_DAYS; - else if (!strcmp (units, "hours")) + else if (units && !strcmp (units, "hours")) cu = CAL_HOURS; else - cu = CAL_MINUTES; /* changed from above because - * if bonobo-config fucks up - * we want minutes, not days! - */ + cu = CAL_MINUTES; g_free (units); return cu; @@ -871,7 +954,7 @@ calendar_config_get_default_reminder_units (void) void calendar_config_set_default_reminder_units (CalUnits units) { - e_config_listener_set_string (config, "/apps/evolution/calendar/other/default_reminder_units", units_to_string(units)); + gconf_client_set_string (config, CALENDAR_CONFIG_DEFAULT_REMINDER_UNITS, units_to_string(units), NULL); } /** @@ -934,21 +1017,3 @@ calendar_config_get_hide_completed_tasks_sexp (void) return sexp; } -char * -calendar_config_default_calendar_folder (void) -{ - char *uri; - - uri = e_config_listener_get_string_with_default (config, "/apps/evolution/shell/default_folders/calendar_uri", NULL, NULL); - return uri; -} - -char * -calendar_config_default_tasks_folder (void) -{ - char *uri; - - uri = e_config_listener_get_string_with_default (config, "/apps/evolution/shell/default_folders/tasks_uri", NULL, NULL); - return uri; -} - diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h index 48f2e4f2e0..fa695673b6 100644 --- a/calendar/gui/calendar-config.h +++ b/calendar/gui/calendar-config.h @@ -30,6 +30,7 @@ #ifndef _CALENDAR_CONFIG_H_ #define _CALENDAR_CONFIG_H_ +#include <gconf/gconf-client.h> #include <widgets/misc/e-calendar.h> #include <widgets/misc/e-dateedit.h> #include <widgets/misc/e-cell-date-edit.h> @@ -61,7 +62,7 @@ typedef enum void calendar_config_init (void); - +void calendar_config_remove_notification (guint id); /* * Calendar Settings. @@ -74,39 +75,49 @@ void calendar_config_set_timezone (gchar *timezone); /* The working days of the week, a bit-wise combination of flags. */ CalWeekdays calendar_config_get_working_days (void); void calendar_config_set_working_days (CalWeekdays days); +guint calendar_config_add_notification_working_days (GConfClientNotifyFunc func, gpointer data); /* The start day of the week (0 = Sun to 6 = Sat). */ gint calendar_config_get_week_start_day (void); void calendar_config_set_week_start_day (gint week_start_day); +guint calendar_config_add_notification_week_start_day (GConfClientNotifyFunc func, gpointer data); /* 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); +guint calendar_config_add_notification_day_start_hour (GConfClientNotifyFunc func, gpointer data); gint calendar_config_get_day_start_minute (void); void calendar_config_set_day_start_minute (gint day_start_min); +guint calendar_config_add_notification_day_start_minute (GConfClientNotifyFunc func, gpointer data); gint calendar_config_get_day_end_hour (void); void calendar_config_set_day_end_hour (gint day_end_hour); +guint calendar_config_add_notification_day_end_hour (GConfClientNotifyFunc func, gpointer data); gint calendar_config_get_day_end_minute (void); void calendar_config_set_day_end_minute (gint day_end_min); +guint calendar_config_add_notification_day_end_minute (GConfClientNotifyFunc func, gpointer data); /* Whether we use 24-hour format or 12-hour format (AM/PM). */ gboolean calendar_config_get_24_hour_format (void); void calendar_config_set_24_hour_format (gboolean use_24_hour); +guint calendar_config_add_notification_24_hour_format (GConfClientNotifyFunc func, gpointer data); /* 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); +guint calendar_config_add_notification_time_divisions (GConfClientNotifyFunc func, gpointer data); /* Whether we show event end times. */ gboolean calendar_config_get_show_event_end (void); void calendar_config_set_show_event_end (gboolean show_end); +guint calendar_config_add_notification_show_event_end (GConfClientNotifyFunc func, gpointer data); /* Whether we compress the weekend in the week/month views. */ gboolean calendar_config_get_compress_weekend (void); void calendar_config_set_compress_weekend (gboolean compress); +guint calendar_config_add_notification_compress_weekend (GConfClientNotifyFunc func, gpointer data); /* Whether we show week numbers in the Date Navigator. */ gboolean calendar_config_get_dnav_show_week_no (void); @@ -183,8 +194,4 @@ void calendar_config_check_timezone_set (void); supports 12-hour time format. */ gboolean calendar_config_locale_supports_12_hour_format(void); -/* Default folders, read-only */ -char *calendar_config_default_calendar_folder (void); -char *calendar_config_default_tasks_folder (void); - #endif /* _CALENDAR_CONFIG_H_ */ diff --git a/calendar/gui/e-day-view-config.c b/calendar/gui/e-day-view-config.c new file mode 100644 index 0000000000..4e34370aff --- /dev/null +++ b/calendar/gui/e-day-view-config.c @@ -0,0 +1,443 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/* + * Author : + * Rodrigo Moya <rodrigo@ximian.com> + * + * Copyright 2003, Ximian, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +#include "calendar-config.h" +#include "e-day-view-config.h" + +struct _EDayViewConfigPrivate { + EDayView *view; + + GList *notifications; +}; + +static GObjectClass *parent_class = NULL; + +/* Property IDs */ +enum props { + PROP_0, + PROP_VIEW, +}; + +static void +e_day_view_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + EDayViewConfig *view_config; + EDayViewConfigPrivate *priv; + + view_config = E_DAY_VIEW_CONFIG (object); + priv = view_config->priv; + + switch (property_id) { + case PROP_VIEW: + e_day_view_config_set_view (view_config, g_value_get_object (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +e_day_view_config_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +{ + EDayViewConfig *view_config; + EDayViewConfigPrivate *priv; + + view_config = E_DAY_VIEW_CONFIG (object); + priv = view_config->priv; + + switch (property_id) { + case PROP_VIEW: + g_value_set_object (value, e_day_view_config_get_view (view_config)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +e_day_view_config_dispose (GObject *object) +{ + EDayViewConfig *view_config = E_DAY_VIEW_CONFIG (object); + EDayViewConfigPrivate *priv; + + priv = view_config->priv; + + e_day_view_config_set_view (view_config, NULL); + + if (G_OBJECT_CLASS (parent_class)->dispose) + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +e_day_view_config_finalize (GObject *object) +{ + EDayViewConfig *view_config = E_DAY_VIEW_CONFIG (object); + EDayViewConfigPrivate *priv; + + priv = view_config->priv; + + g_free (priv); + + if (G_OBJECT_CLASS (parent_class)->finalize) + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +e_day_view_config_class_init (ECalViewClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GParamSpec *spec; + + parent_class = g_type_class_peek_parent (klass); + + /* Method override */ + gobject_class->set_property = e_day_view_config_set_property; + gobject_class->get_property = e_day_view_config_get_property; + gobject_class->dispose = e_day_view_config_dispose; + gobject_class->finalize = e_day_view_config_finalize; + + spec = g_param_spec_object ("view", NULL, NULL, e_day_view_get_type (), + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT); + g_object_class_install_property (gobject_class, PROP_VIEW, spec); +} + +static void +e_day_view_config_init (EDayViewConfig *view_config, EDayViewConfigClass *klass) +{ + view_config->priv = g_new0 (EDayViewConfigPrivate, 1); + +} + +E_MAKE_TYPE (e_day_view_config, "EDayViewConfig", EDayViewConfig, e_day_view_config_class_init, + e_day_view_config_init, G_TYPE_OBJECT); + +EDayViewConfig * +e_day_view_config_new (EDayView *day_view) +{ + EDayViewConfig *view_config; + + view_config = g_object_new (e_day_view_config_get_type (), "view", day_view, NULL); + + return view_config; +} + +EDayView * +e_day_view_config_get_view (EDayViewConfig *view_config) +{ + EDayViewConfigPrivate *priv; + + g_return_val_if_fail (view_config != NULL, NULL); + g_return_val_if_fail (E_IS_DAY_VIEW_CONFIG (view_config), NULL); + + priv = view_config->priv; + + return priv->view; +} + +static void +set_week_start (EDayView *day_view) +{ + int week_start_day; + + week_start_day = calendar_config_get_week_start_day (); + + /* Convert it to 0 (Mon) to 6 (Sun), which is what we use. */ + week_start_day = (week_start_day + 6) % 7; + + e_day_view_set_week_start_day (day_view, week_start_day); +} + +static void +week_start_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + EDayViewConfig *view_config = data; + EDayViewConfigPrivate *priv; + + priv = view_config->priv; + + set_week_start (priv->view); +} + +static void +set_twentyfour_hour (EDayView *day_view) +{ + gboolean use_24_hour; + + use_24_hour = calendar_config_get_24_hour_format (); + + e_day_view_set_24_hour_format (day_view, use_24_hour); +} + +static void +twentyfour_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + EDayViewConfig *view_config = data; + EDayViewConfigPrivate *priv; + + priv = view_config->priv; + + set_twentyfour_hour (priv->view); +} + +static void +set_working_days (EDayView *day_view) +{ + CalWeekdays working_days; + + working_days = calendar_config_get_working_days (); + + e_day_view_set_working_days (day_view, working_days); +} + +static void +working_days_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + EDayViewConfig *view_config = data; + EDayViewConfigPrivate *priv; + + priv = view_config->priv; + + set_working_days (priv->view); +} + +static void +set_day_start_hour (EDayView *day_view) +{ + int start_hour, start_minute, end_hour, end_minute; + + e_day_view_get_working_day (day_view, &start_hour, &start_minute, &end_hour, &end_minute); + + start_hour = calendar_config_get_day_start_hour (); + + e_day_view_set_working_day (day_view, start_hour, start_minute, end_hour, end_minute); +} + +static void +day_start_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + EDayViewConfig *view_config = data; + EDayViewConfigPrivate *priv; + + priv = view_config->priv; + + set_day_start_hour (priv->view); +} + +static void +set_day_start_minute (EDayView *day_view) +{ + int start_hour, start_minute, end_hour, end_minute; + + e_day_view_get_working_day (day_view, &start_hour, &start_minute, &end_hour, &end_minute); + + start_minute = calendar_config_get_day_start_minute (); + + e_day_view_set_working_day (day_view, start_hour, start_minute, end_hour, end_minute); +} + +static void +day_start_minute_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + EDayViewConfig *view_config = data; + EDayViewConfigPrivate *priv; + + priv = view_config->priv; + + set_day_start_minute (priv->view); +} + +static void +set_day_end_hour (EDayView *day_view) +{ + int start_hour, start_minute, end_hour, end_minute; + + e_day_view_get_working_day (day_view, &start_hour, &start_minute, &end_hour, &end_minute); + + end_hour = calendar_config_get_day_end_hour (); + + e_day_view_set_working_day (day_view, start_hour, start_minute, end_hour, end_minute); +} + +static void +day_end_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + EDayViewConfig *view_config = data; + EDayViewConfigPrivate *priv; + + priv = view_config->priv; + + set_day_end_hour (priv->view); +} + + +static void +set_day_end_minute (EDayView *day_view) +{ + int start_hour, start_minute, end_hour, end_minute; + + e_day_view_get_working_day (day_view, &start_hour, &start_minute, &end_hour, &end_minute); + + end_minute = calendar_config_get_day_end_minute (); + + e_day_view_set_working_day (day_view, start_hour, start_minute, end_hour, end_minute); +} + +static void +day_end_minute_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + EDayViewConfig *view_config = data; + EDayViewConfigPrivate *priv; + + priv = view_config->priv; + + set_day_end_minute (priv->view); +} + +static void +set_time_divisions (EDayView *day_view) +{ + int time_divisions; + + time_divisions = calendar_config_get_time_divisions (); + + e_day_view_set_mins_per_row (day_view, time_divisions); +} + +static void +time_divisions_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + EDayViewConfig *view_config = data; + EDayViewConfigPrivate *priv; + + priv = view_config->priv; + + set_time_divisions (priv->view); +} + +static void +set_show_event_end (EDayView *day_view) +{ + gboolean show_event_end; + + show_event_end = calendar_config_get_show_event_end (); + + e_day_view_set_show_event_end_times (day_view, show_event_end); +} + +static void +show_event_end_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + EDayViewConfig *view_config = data; + EDayViewConfigPrivate *priv; + + priv = view_config->priv; + + set_show_event_end (priv->view); +} + +void +e_day_view_config_set_view (EDayViewConfig *view_config, EDayView *day_view) +{ + EDayViewConfigPrivate *priv; + guint not; + GList *l; + + g_return_if_fail (view_config != NULL); + g_return_if_fail (E_IS_DAY_VIEW_CONFIG (view_config)); + + priv = view_config->priv; + + if (priv->view) { + g_object_unref (priv->view); + priv->view = NULL; + } + + for (l = priv->notifications; l; l = l->next) + calendar_config_remove_notification (GPOINTER_TO_UINT (l->data)); + + g_list_free (priv->notifications); + priv->notifications = NULL; + + /* If the new view is NULL, return right now */ + if (!day_view) + return; + + priv->view = g_object_ref (day_view); + + /* Week start */ + set_week_start (day_view); + + not = calendar_config_add_notification_week_start_day (week_start_changed_cb, view_config); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + + /* 24 Hour format */ + set_twentyfour_hour (day_view); + + not = calendar_config_add_notification_24_hour_format (twentyfour_hour_changed_cb, view_config); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + + /* Working days */ + set_working_days (day_view); + + not = calendar_config_add_notification_working_days (working_days_changed_cb, view_config); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + + /* Day start hour */ + set_day_start_hour (day_view); + + not = calendar_config_add_notification_day_start_hour (day_start_hour_changed_cb, view_config); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + + /* Day start minute */ + set_day_start_minute (day_view); + + not = calendar_config_add_notification_day_start_minute (day_start_minute_changed_cb, view_config); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + + /* Day end hour */ + set_day_end_hour (day_view); + + not = calendar_config_add_notification_day_end_hour (day_end_hour_changed_cb, view_config); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + + /* Day start minute */ + set_day_end_minute (day_view); + + not = calendar_config_add_notification_day_end_minute (day_end_minute_changed_cb, view_config); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + + /* Time divisions */ + set_time_divisions (day_view); + + not = calendar_config_add_notification_time_divisions (time_divisions_changed_cb, view_config); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + + /* Showing event end */ + set_show_event_end (day_view); + + not = calendar_config_add_notification_show_event_end (show_event_end_changed_cb, view_config); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); +} + diff --git a/calendar/gui/e-day-view-config.h b/calendar/gui/e-day-view-config.h new file mode 100644 index 0000000000..79e49513bd --- /dev/null +++ b/calendar/gui/e-day-view-config.h @@ -0,0 +1,59 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Author : + * JP Rosevear <jpr@ximian.com> + * + * Copyright 2003, Ximian, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +#ifndef _E_DAY_VIEW_CONFIG_H_ +#define _E_DAY_VIEW_CONFIG_H_ + +#include "e-day-view.h" + +G_BEGIN_DECLS + +/* + * EView - base widget class for the calendar views. + */ + +#define E_DAY_VIEW_CONFIG(obj) GTK_CHECK_CAST (obj, e_day_view_config_get_type (), EDayViewConfig) +#define E_DAY_VIEW_CONFIG_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_day_view_config_get_type (), EDayViewConfigClass) +#define E_IS_DAY_VIEW_CONFIG(obj) GTK_CHECK_TYPE (obj, e_day_view_config_get_type ()) + +typedef struct _EDayViewConfig EDayViewConfig; +typedef struct _EDayViewConfigClass EDayViewConfigClass; +typedef struct _EDayViewConfigPrivate EDayViewConfigPrivate; + +struct _EDayViewConfig { + ECalView parent; + + EDayViewConfigPrivate *priv; +}; + +struct _EDayViewConfigClass { + ECalViewClass parent_class; +}; + +GType e_day_view_config_get_type (void); +EDayViewConfig *e_day_view_config_new (EDayView *day_view); +EDayView *e_day_view_config_get_view (EDayViewConfig *view_config); +void e_day_view_config_set_view (EDayViewConfig *view_config, EDayView *day_view); + +G_END_DECLS + +#endif diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c index d5e24c8936..257d10fd71 100644 --- a/calendar/gui/e-itip-control.c +++ b/calendar/gui/e-itip-control.c @@ -151,10 +151,12 @@ start_calendar_server (EItipControl *itip, char *uri) static gboolean start_default_server (EItipControl *itip, CalClient *client, gboolean tasks) { +#if 0 if (tasks) return cal_client_open_default_tasks (client, FALSE); else return cal_client_open_default_calendar (client, FALSE); +#endif } #if 0 /* EPFIXME, rewrite this */ @@ -2206,7 +2208,6 @@ object_requested_cb (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data) context->itip = itip; context->eb = eb; - /* FIXME: use the default URIs */ switch (vtype) { case CAL_COMPONENT_EVENT: context->client = cal_client_new ("", CALOBJ_TYPE_EVENT); diff --git a/calendar/gui/e-week-view-config.c b/calendar/gui/e-week-view-config.c new file mode 100644 index 0000000000..8c9e2cfb70 --- /dev/null +++ b/calendar/gui/e-week-view-config.c @@ -0,0 +1,299 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/* + * Author : + * Rodrigo Moya <rodrigo@ximian.com> + * + * Copyright 2003, Ximian, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +#include "calendar-config.h" +#include "e-week-view-config.h" + +struct _EWeekViewConfigPrivate { + EWeekView *view; + + GList *notifications; +}; + +static GObjectClass *parent_class = NULL; + +/* Property IDs */ +enum props { + PROP_0, + PROP_VIEW, +}; + +static void +e_week_view_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + EWeekViewConfig *view_config; + EWeekViewConfigPrivate *priv; + + view_config = E_WEEK_VIEW_CONFIG (object); + priv = view_config->priv; + + switch (property_id) { + case PROP_VIEW: + e_week_view_config_set_view (view_config, g_value_get_object (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +e_week_view_config_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +{ + EWeekViewConfig *view_config; + EWeekViewConfigPrivate *priv; + + view_config = E_WEEK_VIEW_CONFIG (object); + priv = view_config->priv; + + switch (property_id) { + case PROP_VIEW: + g_value_set_object (value, e_week_view_config_get_view (view_config)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +e_week_view_config_dispose (GObject *object) +{ + EWeekViewConfig *view_config = E_WEEK_VIEW_CONFIG (object); + EWeekViewConfigPrivate *priv; + + priv = view_config->priv; + + e_week_view_config_set_view (view_config, NULL); + + if (G_OBJECT_CLASS (parent_class)->dispose) + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +e_week_view_config_finalize (GObject *object) +{ + EWeekViewConfig *view_config = E_WEEK_VIEW_CONFIG (object); + EWeekViewConfigPrivate *priv; + + priv = view_config->priv; + + g_free (priv); + + if (G_OBJECT_CLASS (parent_class)->finalize) + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +e_week_view_config_class_init (ECalViewClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GParamSpec *spec; + + parent_class = g_type_class_peek_parent (klass); + + /* Method override */ + gobject_class->set_property = e_week_view_config_set_property; + gobject_class->get_property = e_week_view_config_get_property; + gobject_class->dispose = e_week_view_config_dispose; + gobject_class->finalize = e_week_view_config_finalize; + + spec = g_param_spec_object ("view", NULL, NULL, e_week_view_get_type (), + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT); + g_object_class_install_property (gobject_class, PROP_VIEW, spec); +} + +static void +e_week_view_config_init (EWeekViewConfig *view_config, EWeekViewConfigClass *klass) +{ + view_config->priv = g_new0 (EWeekViewConfigPrivate, 1); + +} + +E_MAKE_TYPE (e_week_view_config, "EWeekViewConfig", EWeekViewConfig, e_week_view_config_class_init, + e_week_view_config_init, G_TYPE_OBJECT); + +EWeekViewConfig * +e_week_view_config_new (EWeekView *week_view) +{ + EWeekViewConfig *view_config; + + view_config = g_object_new (e_week_view_config_get_type (), "view", week_view, NULL); + + return view_config; +} + +EWeekView * +e_week_view_config_get_view (EWeekViewConfig *view_config) +{ + EWeekViewConfigPrivate *priv; + + g_return_val_if_fail (view_config != NULL, NULL); + g_return_val_if_fail (E_IS_WEEK_VIEW_CONFIG (view_config), NULL); + + priv = view_config->priv; + + return priv->view; +} + +static void +set_week_start (EWeekView *week_view) +{ + int week_start_week; + + week_start_week = calendar_config_get_week_start_day (); + + /* Convert it to 0 (Mon) to 6 (Sun), which is what we use. */ + week_start_week = (week_start_week + 6) % 7; + + e_week_view_set_week_start_day (week_view, week_start_week); +} + +static void +week_start_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + EWeekViewConfig *view_config = data; + EWeekViewConfigPrivate *priv; + + priv = view_config->priv; + + set_week_start (priv->view); +} + +static void +set_twentyfour_hour (EWeekView *week_view) +{ + gboolean use_24_hour; + + use_24_hour = calendar_config_get_24_hour_format (); + + e_week_view_set_24_hour_format (week_view, use_24_hour); +} + +static void +twentyfour_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + EWeekViewConfig *view_config = data; + EWeekViewConfigPrivate *priv; + + priv = view_config->priv; + + set_twentyfour_hour (priv->view); +} + +static void +set_show_event_end (EWeekView *week_view) +{ + gboolean show_event_end; + + show_event_end = calendar_config_get_show_event_end (); + + e_week_view_set_show_event_end_times (week_view, show_event_end); +} + +static void +show_event_end_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + EWeekViewConfig *view_config = data; + EWeekViewConfigPrivate *priv; + + priv = view_config->priv; + + set_show_event_end (priv->view); +} + +static void +set_compress_weekend (EWeekView *week_view) +{ + gboolean compress_weekend; + + compress_weekend = calendar_config_get_compress_weekend (); + + e_week_view_set_compress_weekend (week_view, compress_weekend); +} + +static void +compress_weekend_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + EWeekViewConfig *view_config = data; + EWeekViewConfigPrivate *priv; + + priv = view_config->priv; + + set_compress_weekend (priv->view); +} + +void +e_week_view_config_set_view (EWeekViewConfig *view_config, EWeekView *week_view) +{ + EWeekViewConfigPrivate *priv; + guint not; + GList *l; + + g_return_if_fail (view_config != NULL); + g_return_if_fail (E_IS_WEEK_VIEW_CONFIG (view_config)); + + priv = view_config->priv; + + if (priv->view) { + g_object_unref (priv->view); + priv->view = NULL; + } + + for (l = priv->notifications; l; l = l->next) + calendar_config_remove_notification (GPOINTER_TO_UINT (l->data)); + + g_list_free (priv->notifications); + priv->notifications = NULL; + + /* If the new view is NULL, return right now */ + if (!week_view) + return; + + priv->view = g_object_ref (week_view); + + /* Week start */ + set_week_start (week_view); + + not = calendar_config_add_notification_week_start_day (week_start_changed_cb, view_config); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + + /* 24 Hour format */ + set_twentyfour_hour (week_view); + + not = calendar_config_add_notification_24_hour_format (twentyfour_hour_changed_cb, view_config); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + + /* Show event end */ + set_show_event_end (week_view); + + not = calendar_config_add_notification_show_event_end (show_event_end_changed_cb, view_config); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + + /* Compress weekend */ + set_compress_weekend (week_view); + + not = calendar_config_add_notification_compress_weekend (compress_weekend_changed_cb, view_config); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); +} + diff --git a/calendar/gui/e-week-view-config.h b/calendar/gui/e-week-view-config.h new file mode 100644 index 0000000000..ab2fa6b025 --- /dev/null +++ b/calendar/gui/e-week-view-config.h @@ -0,0 +1,59 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Author : + * JP Rosevear <jpr@ximian.com> + * + * Copyright 2003, Ximian, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +#ifndef _E_WEEK_VIEW_CONFIG_H_ +#define _E_WEEK_VIEW_CONFIG_H_ + +#include "e-week-view.h" + +G_BEGIN_DECLS + +/* + * EView - base widget class for the calendar views. + */ + +#define E_WEEK_VIEW_CONFIG(obj) GTK_CHECK_CAST (obj, e_week_view_config_get_type (), EWeekViewConfig) +#define E_WEEK_VIEW_CONFIG_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_week_view_config_get_type (), EWeekViewConfigClass) +#define E_IS_WEEK_VIEW_CONFIG(obj) GTK_CHECK_TYPE (obj, e_week_view_config_get_type ()) + +typedef struct _EWeekViewConfig EWeekViewConfig; +typedef struct _EWeekViewConfigClass EWeekViewConfigClass; +typedef struct _EWeekViewConfigPrivate EWeekViewConfigPrivate; + +struct _EWeekViewConfig { + ECalView parent; + + EWeekViewConfigPrivate *priv; +}; + +struct _EWeekViewConfigClass { + ECalViewClass parent_class; +}; + +GType e_week_view_config_get_type (void); +EWeekViewConfig *e_week_view_config_new (EWeekView *week_view); +EWeekView *e_week_view_config_get_view (EWeekViewConfig *view_config); +void e_week_view_config_set_view (EWeekViewConfig *view_config, EWeekView *week_view); + +G_END_DECLS + +#endif diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 9e622ff381..4a042f36e3 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -1644,9 +1644,11 @@ e_week_view_set_compress_weekend (EWeekView *week_view, week_view->events_need_reshape = TRUE; e_week_view_check_layout (week_view); } -} + gtk_widget_queue_draw (week_view->main_canvas); +} + /* Whether we display event end times. */ gboolean e_week_view_get_show_event_end_times (EWeekView *week_view) diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 6e572484c8..da0bacdd91 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -46,8 +46,10 @@ #include "comp-util.h" #include "e-cal-model-calendar.h" #include "e-day-view.h" +#include "e-day-view-config.h" #include "e-day-view-time-item.h" #include "e-week-view.h" +#include "e-week-view-config.h" #include "e-cal-list-view.h" #include "evolution-calendar.h" #include "gnome-cal.h" @@ -121,6 +123,7 @@ struct _GnomeCalendarPrivate { positions of the panes. range_selected is TRUE if a range of dates was selected in the date navigator to show the view. */ ECalView *views[GNOME_CAL_LAST_VIEW]; + GObject *configs[GNOME_CAL_LAST_VIEW]; GnomeCalendarViewType current_view_type; gboolean range_selected; @@ -949,10 +952,15 @@ setup_widgets (GnomeCalendar *gcal) connect_list_view_focus (gcal, E_CAL_LIST_VIEW (priv->list_view)); priv->views[GNOME_CAL_DAY_VIEW] = E_CAL_VIEW (priv->day_view); + priv->configs[GNOME_CAL_DAY_VIEW] = e_day_view_config_new (E_DAY_VIEW (priv->views[GNOME_CAL_DAY_VIEW])); priv->views[GNOME_CAL_WORK_WEEK_VIEW] = E_CAL_VIEW (priv->work_week_view); + priv->configs[GNOME_CAL_WORK_WEEK_VIEW] = e_day_view_config_new (E_DAY_VIEW (priv->views[GNOME_CAL_WORK_WEEK_VIEW])); priv->views[GNOME_CAL_WEEK_VIEW] = E_CAL_VIEW (priv->week_view); + priv->configs[GNOME_CAL_WEEK_VIEW] = e_week_view_config_new (E_WEEK_VIEW (priv->views[GNOME_CAL_WEEK_VIEW])); priv->views[GNOME_CAL_MONTH_VIEW] = E_CAL_VIEW (priv->month_view); + priv->configs[GNOME_CAL_MONTH_VIEW] = e_week_view_config_new (E_WEEK_VIEW (priv->views[GNOME_CAL_MONTH_VIEW])); priv->views[GNOME_CAL_LIST_VIEW] = E_CAL_VIEW (priv->list_view); + priv->configs[GNOME_CAL_LIST_VIEW] = NULL; for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) { gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), @@ -2220,7 +2228,7 @@ gnome_calendar_set_default_uri (GnomeCalendar *gcal, const char *uri) CalClient *client; int i; - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); + g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), FALSE); priv = gcal->priv; @@ -2246,10 +2254,6 @@ gnome_calendar_update_config_settings (GnomeCalendar *gcal, gboolean initializing) { GnomeCalendarPrivate *priv; - CalWeekdays working_days; - gint week_start_day, time_divisions; - gint start_hour, start_minute, end_hour, end_minute; - gboolean use_24_hour, show_event_end, compress_weekend; char *location; GList *l; int i; @@ -2258,70 +2262,6 @@ gnome_calendar_update_config_settings (GnomeCalendar *gcal, priv = gcal->priv; - working_days = calendar_config_get_working_days (); - /* CalWeekdays and EDayViewDays use the same bit-masks, so we can - use the same value. */ - e_day_view_set_working_days (E_DAY_VIEW (priv->day_view), - (EDayViewDays) working_days); - e_day_view_set_working_days (E_DAY_VIEW (priv->work_week_view), - (EDayViewDays) working_days); - - /* Note that this is 0 (Sun) to 6 (Sat). */ - week_start_day = calendar_config_get_week_start_day (); - - /* Convert it to 0 (Mon) to 6 (Sun), which is what we use. */ - week_start_day = (week_start_day + 6) % 7; - - e_day_view_set_week_start_day (E_DAY_VIEW (priv->day_view), - week_start_day); - e_day_view_set_week_start_day (E_DAY_VIEW (priv->work_week_view), - week_start_day); - e_week_view_set_week_start_day (E_WEEK_VIEW (priv->week_view), - week_start_day); - e_week_view_set_week_start_day (E_WEEK_VIEW (priv->month_view), - week_start_day); - - start_hour = calendar_config_get_day_start_hour (); - start_minute = calendar_config_get_day_start_minute (); - end_hour = calendar_config_get_day_end_hour (); - end_minute = calendar_config_get_day_end_minute (); - e_day_view_set_working_day (E_DAY_VIEW (priv->day_view), - start_hour, start_minute, - end_hour, end_minute); - e_day_view_set_working_day (E_DAY_VIEW (priv->work_week_view), - start_hour, start_minute, - end_hour, end_minute); - - use_24_hour = calendar_config_get_24_hour_format (); - e_day_view_set_24_hour_format (E_DAY_VIEW (priv->day_view), - use_24_hour); - e_day_view_set_24_hour_format (E_DAY_VIEW (priv->work_week_view), - use_24_hour); - e_week_view_set_24_hour_format (E_WEEK_VIEW (priv->week_view), - use_24_hour); - e_week_view_set_24_hour_format (E_WEEK_VIEW (priv->month_view), - use_24_hour); - - time_divisions = calendar_config_get_time_divisions (); - e_day_view_set_mins_per_row (E_DAY_VIEW (priv->day_view), - time_divisions); - e_day_view_set_mins_per_row (E_DAY_VIEW (priv->work_week_view), - time_divisions); - - show_event_end = calendar_config_get_show_event_end (); - e_day_view_set_show_event_end_times (E_DAY_VIEW (priv->day_view), - show_event_end); - e_day_view_set_show_event_end_times (E_DAY_VIEW (priv->work_week_view), - show_event_end); - e_week_view_set_show_event_end_times (E_WEEK_VIEW (priv->week_view), - show_event_end); - e_week_view_set_show_event_end_times (E_WEEK_VIEW (priv->month_view), - show_event_end); - - compress_weekend = calendar_config_get_compress_weekend (); - e_week_view_set_compress_weekend (E_WEEK_VIEW (priv->month_view), - compress_weekend); - calendar_config_configure_e_calendar (E_CALENDAR (priv->date_navigator)); calendar_config_configure_e_calendar_table (E_CALENDAR_TABLE (priv->todo)); |