aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/alarm-notify/config-data.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-10-25 01:27:22 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-10-25 01:27:22 +0800
commitc3876df777704e70f1d91689b4b29a69f8bf3e66 (patch)
treefe1e0265b9c69c3c5159a173177bf3102fb29d3b /calendar/gui/alarm-notify/config-data.c
parent4d26929f07c5c34713671a36fb397dcc4522fcab (diff)
downloadgsoc2013-evolution-c3876df777704e70f1d91689b4b29a69f8bf3e66.tar
gsoc2013-evolution-c3876df777704e70f1d91689b4b29a69f8bf3e66.tar.gz
gsoc2013-evolution-c3876df777704e70f1d91689b4b29a69f8bf3e66.tar.bz2
gsoc2013-evolution-c3876df777704e70f1d91689b4b29a69f8bf3e66.tar.lz
gsoc2013-evolution-c3876df777704e70f1d91689b4b29a69f8bf3e66.tar.xz
gsoc2013-evolution-c3876df777704e70f1d91689b4b29a69f8bf3e66.tar.zst
gsoc2013-evolution-c3876df777704e70f1d91689b4b29a69f8bf3e66.zip
Fixes bug #5282.
2001-10-24 Federico Mena Quintero <federico@ximian.com> Fixes bug #5282. * cal-util/timeutil.c (icaltimetype_to_tm_with_zone): New function to avoid copying the same code all over the place. (icaltimetype_to_tm): Also set the tm.tm_wday. * gui/alarm-notify/alarm-queue.c (queue_midnight_refresh): Use time_day_end_with_zone(). (load_alarms_for_today): Likewise. And oops, we were only computing the times and not loading the alarms. (obj_updated_cb): Likewise. (load_alarms): Removed assertion that is no longer valid because we may load the alarms for a client in two stages. * gui/dialogs/alarm-page.c (get_alarm_string): Convert absolute trigger times to the local timezone. * gui/alarm-notify/alarm-notify-dialog.c (write_html_heading): Convert the times to the local timezone. (alarm_notify_dialog): Likewise, for the window title. (alarm_notify_dialog): Set the window layer to WIN_LAYER_ONTOP. * gui/e-cell-date-edit-text.c (ecd_get_text): Use icaltimetype_to_tm_with_zone(). * gui/alarm-notify/save.c (get_config_db): Made public. (discard_config_db): Made public. * gui/alarm-notify/config-data.[ch]: New files with functions to fetch the calendar configuration data used by the alarm daemon. svn path=/trunk/; revision=13986
Diffstat (limited to 'calendar/gui/alarm-notify/config-data.c')
-rw-r--r--calendar/gui/alarm-notify/config-data.c111
1 files changed, 111 insertions, 0 deletions
diff --git a/calendar/gui/alarm-notify/config-data.c b/calendar/gui/alarm-notify/config-data.c
new file mode 100644
index 0000000000..ece37cd10e
--- /dev/null
+++ b/calendar/gui/alarm-notify/config-data.c
@@ -0,0 +1,111 @@
+/* Evolution calendar - Configuration values for the alarm notification daemon
+ *
+ * Copyright (C) 2001 Ximian, Inc.
+ *
+ * Authors: Federico Mena-Quintero <federico@ximian.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "config-data.h"
+#include "save.h"
+
+
+
+/* Whether we have initied ourselves by reading the data from the configuration engine */
+static gboolean inited;
+
+/* Configuration values */
+static icaltimezone *local_timezone;
+static gboolean use_24_hour_format;
+
+
+
+/* Copied from ../calendar-config.c; returns whether the locale has 'am' and
+ * 'pm' strings defined.
+ */
+static gboolean
+locale_supports_12_hour_format (void)
+{
+ char s[16];
+ time_t t = 0;
+
+ strftime (s, sizeof s, "%p", gmtime (&t));
+ return s[0] != '\0';
+}
+
+/* Ensures that the configuration values have been read */
+static void
+ensure_inited (void)
+{
+ Bonobo_ConfigDatabase db;
+ char *location;
+
+ if (inited)
+ return;
+
+ inited = TRUE;
+
+ db = get_config_db ();
+ if (db == CORBA_OBJECT_NIL) {
+ /* This sucks */
+ local_timezone = icaltimezone_get_utc_timezone ();
+
+ /* This sucks as well */
+ use_24_hour_format = TRUE;
+
+ return;
+ }
+
+ location = bonobo_config_get_string (db, "/Calendar/Display/Timezone", NULL);
+ if (location) {
+ local_timezone = icaltimezone_get_builtin_timezone (location);
+ g_free (location);
+ } else
+ local_timezone = icaltimezone_get_utc_timezone ();
+
+ if (locale_supports_12_hour_format ()) {
+ /* Wasn't the whole point of a configuration engine *NOT* to
+ * have apps specify their own stupid defaults everywhere, but
+ * just in a schema file?
+ */
+ use_24_hour_format = bonobo_config_get_boolean_with_default (
+ db,
+ "/Calendar/Display/Use24HourFormat", FALSE, NULL);
+ } else
+ use_24_hour_format = TRUE;
+
+ discard_config_db (db);
+}
+
+icaltimezone *
+config_data_get_timezone (void)
+{
+ ensure_inited ();
+
+ return local_timezone;
+}
+
+gboolean
+config_data_get_24_hour_format (void)
+{
+ ensure_inited ();
+
+ return use_24_hour_format;
+}