From 741182663966e288b4de8666f336b70a7d4ee856 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Wed, 29 Oct 2003 19:29:47 +0000 Subject: build new files 2003-10-29 JP Rosevear * gui/Makefile.am: build new files * gui/dialogs/comp-editor-util.c (date_edit_destroy_cb): unref the config manager (comp_editor_new_date_edit): set up a config manager for the date editor * gui/e-date-edit-config.[hc]: config manager for e-date-edit svn path=/trunk/; revision=23122 --- calendar/ChangeLog | 13 +- calendar/gui/Makefile.am | 2 + calendar/gui/dialogs/comp-editor-util.c | 18 ++- calendar/gui/e-date-edit-config.c | 269 ++++++++++++++++++++++++++++++++ calendar/gui/e-date-edit-config.h | 55 +++++++ 5 files changed, 353 insertions(+), 4 deletions(-) create mode 100644 calendar/gui/e-date-edit-config.c create mode 100644 calendar/gui/e-date-edit-config.h (limited to 'calendar') diff --git a/calendar/ChangeLog b/calendar/ChangeLog index e6930b7ae8..0f14464655 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,9 +1,20 @@ +2003-10-29 JP Rosevear + + * gui/Makefile.am: build new files + + * gui/dialogs/comp-editor-util.c (date_edit_destroy_cb): unref the + config manager + (comp_editor_new_date_edit): set up a config manager for the date + editor + + * gui/e-date-edit-config.[hc]: config manager for e-date-edit + 2003-10-29 Dan Winship * gui/calendar-component.c (impl_createControls): set an exception if we fail, so evo won't crash. -2003-10-29 +2003-10-29 JP Rosevear * gui/dialogs/cal-prefs-dialog.c (update_config): no need to update config settings everywhere explicitly diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 26dfea9510..876834bfcb 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -122,6 +122,8 @@ libevolution_calendar_la_SOURCES = \ e-cell-date-edit-text.c \ e-comp-editor-registry.c \ e-comp-editor-registry.h \ + e-date-edit-config.c \ + e-date-edit-config.h \ e-date-time-list.c \ e-date-time-list.h \ e-day-view-config.c \ diff --git a/calendar/gui/dialogs/comp-editor-util.c b/calendar/gui/dialogs/comp-editor-util.c index d06234edda..4c3b683ec4 100644 --- a/calendar/gui/dialogs/comp-editor-util.c +++ b/calendar/gui/dialogs/comp-editor-util.c @@ -34,6 +34,7 @@ #include #include #include "../calendar-config.h" +#include "../e-date-edit-config.h" #include "comp-editor-util.h" @@ -202,6 +203,14 @@ comp_editor_date_label (CompEditorPageDates *dates, GtkWidget *label) gtk_label_set_text (GTK_LABEL (label), buffer); } +static void +date_edit_destroy_cb (EDateEdit *date_edit, gpointer data) +{ + EDateEditConfig *config = data; + + g_object_unref (config); +} + /** * comp_editor_new_date_edit: * @show_date: Whether to show a date picker in the widget. @@ -219,7 +228,8 @@ comp_editor_new_date_edit (gboolean show_date, gboolean show_time, gboolean make_time_insensitive) { EDateEdit *dedit; - + EDateEditConfig *config; + dedit = E_DATE_EDIT (e_date_edit_new ()); e_date_edit_set_show_date (dedit, show_date); @@ -229,8 +239,10 @@ comp_editor_new_date_edit (gboolean show_date, gboolean show_time, #else e_date_edit_set_make_time_insensitive (dedit, FALSE); #endif - calendar_config_configure_e_date_edit (dedit); - + + config = e_date_edit_config_new (dedit); + g_signal_connect (G_OBJECT (dedit), "destroy", G_CALLBACK (date_edit_destroy_cb), config); + return GTK_WIDGET (dedit); } diff --git a/calendar/gui/e-date-edit-config.c b/calendar/gui/e-date-edit-config.c new file mode 100644 index 0000000000..f3d88fdd53 --- /dev/null +++ b/calendar/gui/e-date-edit-config.c @@ -0,0 +1,269 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Author : + * JP Rosevear + * + * 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-date-edit-config.h" + +struct _EDateEditConfigPrivate { + EDateEdit *edit; + + GList *notifications; +}; + +static GObjectClass *parent_class = NULL; + +/* Property IDs */ +enum props { + PROP_0, + PROP_EDIT, +}; + +static void +e_date_edit_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + EDateEditConfig *edit_config; + EDateEditConfigPrivate *priv; + + edit_config = E_DATE_EDIT_CONFIG (object); + priv = edit_config->priv; + + switch (property_id) { + case PROP_EDIT: + e_date_edit_config_set_edit (edit_config, g_value_get_object (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +e_date_edit_config_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +{ + EDateEditConfig *edit_config; + EDateEditConfigPrivate *priv; + + edit_config = E_DATE_EDIT_CONFIG (object); + priv = edit_config->priv; + + switch (property_id) { + case PROP_EDIT: + g_value_set_object (value, e_date_edit_config_get_edit (edit_config)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +e_date_edit_config_dispose (GObject *object) +{ + EDateEditConfig *edit_config = E_DATE_EDIT_CONFIG (object); + EDateEditConfigPrivate *priv; + + priv = edit_config->priv; + + e_date_edit_config_set_edit (edit_config, NULL); + + if (G_OBJECT_CLASS (parent_class)->dispose) + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +e_date_edit_config_finalize (GObject *object) +{ + EDateEditConfig *edit_config = E_DATE_EDIT_CONFIG (object); + EDateEditConfigPrivate *priv; + + priv = edit_config->priv; + + g_free (priv); + + if (G_OBJECT_CLASS (parent_class)->finalize) + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +e_date_edit_config_class_init (EDateEditConfigClass *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_date_edit_config_set_property; + gobject_class->get_property = e_date_edit_config_get_property; + gobject_class->dispose = e_date_edit_config_dispose; + gobject_class->finalize = e_date_edit_config_finalize; + + spec = g_param_spec_object ("edit", NULL, NULL, e_date_edit_get_type (), + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT); + g_object_class_install_property (gobject_class, PROP_EDIT, spec); +} + +static void +e_date_edit_config_init (EDateEditConfig *edit_config, EDateEditConfigClass *klass) +{ + edit_config->priv = g_new0 (EDateEditConfigPrivate, 1); + +} + +E_MAKE_TYPE (e_date_edit_config, "EDateEditConfig", EDateEditConfig, e_date_edit_config_class_init, + e_date_edit_config_init, G_TYPE_OBJECT); + +EDateEditConfig * +e_date_edit_config_new (EDateEdit *date_edit) +{ + EDateEditConfig *edit_config; + + edit_config = g_object_new (e_date_edit_config_get_type (), "edit", date_edit, NULL); + + return edit_config; +} + +EDateEdit * +e_date_edit_config_get_edit (EDateEditConfig *edit_config) +{ + EDateEditConfigPrivate *priv; + + g_return_val_if_fail (edit_config != NULL, NULL); + g_return_val_if_fail (E_IS_DATE_EDIT_CONFIG (edit_config), NULL); + + priv = edit_config->priv; + + return priv->edit; +} + +static void +set_week_start (EDateEdit *date_edit) +{ + 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_date_edit_set_week_start_day (date_edit, week_start_day); +} + +static void +week_start_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + EDateEditConfig *edit_config = data; + EDateEditConfigPrivate *priv; + + priv = edit_config->priv; + + set_week_start (priv->edit); +} + +static void +set_twentyfour_hour (EDateEdit *date_edit) +{ + gboolean use_24_hour; + + use_24_hour = calendar_config_get_24_hour_format (); + + e_date_edit_set_use_24_hour_format (date_edit, use_24_hour); +} + +static void +twentyfour_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + EDateEditConfig *edit_config = data; + EDateEditConfigPrivate *priv; + + priv = edit_config->priv; + + set_twentyfour_hour (priv->edit); +} + +static void +set_dnav_show_week_no (EDateEdit *date_edit) +{ + gboolean show_week_no; + + show_week_no = calendar_config_get_dnav_show_week_no (); + + e_date_edit_set_show_week_numbers (date_edit, show_week_no); +} + +static void +dnav_show_week_no_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) +{ + EDateEditConfig *edit_config = data; + EDateEditConfigPrivate *priv; + + priv = edit_config->priv; + + set_dnav_show_week_no (priv->edit); +} +void +e_date_edit_config_set_edit (EDateEditConfig *edit_config, EDateEdit *date_edit) +{ + EDateEditConfigPrivate *priv; + guint not; + GList *l; + + g_return_if_fail (edit_config != NULL); + g_return_if_fail (E_IS_DATE_EDIT_CONFIG (edit_config)); + + priv = edit_config->priv; + + if (priv->edit) { + g_object_unref (priv->edit); + priv->edit = 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 edit is NULL, return right now */ + if (!date_edit) + return; + + priv->edit = g_object_ref (date_edit); + + /* Week start */ + set_week_start (date_edit); + + not = calendar_config_add_notification_week_start_day (week_start_changed_cb, edit_config); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + + /* 24 Hour format */ + set_twentyfour_hour (date_edit); + + not = calendar_config_add_notification_24_hour_format (twentyfour_hour_changed_cb, edit_config); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); + + /* Show week numbers */ + set_dnav_show_week_no (date_edit); + + not = calendar_config_add_notification_dnav_show_week_no (dnav_show_week_no_changed_cb, edit_config); + priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not)); +} diff --git a/calendar/gui/e-date-edit-config.h b/calendar/gui/e-date-edit-config.h new file mode 100644 index 0000000000..0707666bff --- /dev/null +++ b/calendar/gui/e-date-edit-config.h @@ -0,0 +1,55 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Author : + * JP Rosevear + * + * 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_DATE_EDIT_CONFIG_H_ +#define _E_DATE_EDIT_CONFIG_H_ + +#include + +G_BEGIN_DECLS + +#define E_DATE_EDIT_CONFIG(obj) GTK_CHECK_CAST (obj, e_date_edit_config_get_type (), EDateEditConfig) +#define E_DATE_EDIT_CONFIG_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_date_edit_config_get_type (), EDateEditConfigClass) +#define E_IS_DATE_EDIT_CONFIG(obj) GTK_CHECK_TYPE (obj, e_date_edit_config_get_type ()) + +typedef struct _EDateEditConfig EDateEditConfig; +typedef struct _EDateEditConfigClass EDateEditConfigClass; +typedef struct _EDateEditConfigPrivate EDateEditConfigPrivate; + +struct _EDateEditConfig { + GObject parent; + + EDateEditConfigPrivate *priv; +}; + +struct _EDateEditConfigClass { + GObjectClass parent_class; +}; + +GType e_date_edit_config_get_type (void); +EDateEditConfig *e_date_edit_config_new (EDateEdit *date_edit); +EDateEdit *e_date_edit_config_get_edit (EDateEditConfig *edit_config); +void e_date_edit_config_set_edit (EDateEditConfig *edit_config, EDateEdit *date_edit); + +G_END_DECLS + +#endif -- cgit