diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-07-31 00:38:24 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-07-31 10:31:00 +0800 |
commit | 2fe24b4c136b4d5f255af3571c3d6e1082071809 (patch) | |
tree | 78568dcd907204107ca08afa1cfea84362c345a2 /calendar | |
parent | 41569bb778e228d4f5a04cb1e15bfa5b49bb044b (diff) | |
download | gsoc2013-evolution-2fe24b4c136b4d5f255af3571c3d6e1082071809.tar gsoc2013-evolution-2fe24b4c136b4d5f255af3571c3d6e1082071809.tar.gz gsoc2013-evolution-2fe24b4c136b4d5f255af3571c3d6e1082071809.tar.bz2 gsoc2013-evolution-2fe24b4c136b4d5f255af3571c3d6e1082071809.tar.lz gsoc2013-evolution-2fe24b4c136b4d5f255af3571c3d6e1082071809.tar.xz gsoc2013-evolution-2fe24b4c136b4d5f255af3571c3d6e1082071809.tar.zst gsoc2013-evolution-2fe24b4c136b4d5f255af3571c3d6e1082071809.zip |
Add properties to calendar classes.
So we can bind them to EShellSettings and kill off EDayViewConfig
and similar GConf notification classes.
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/gui/Makefile.am | 6 | ||||
-rw-r--r-- | calendar/gui/e-cal-list-view-config.c | 203 | ||||
-rw-r--r-- | calendar/gui/e-cal-list-view-config.h | 56 | ||||
-rw-r--r-- | calendar/gui/e-cal-model.c | 274 | ||||
-rw-r--r-- | calendar/gui/e-calendar-view.c | 67 | ||||
-rw-r--r-- | calendar/gui/e-day-view-config.c | 464 | ||||
-rw-r--r-- | calendar/gui/e-day-view-config.h | 56 | ||||
-rw-r--r-- | calendar/gui/e-day-view-main-item.c | 2 | ||||
-rw-r--r-- | calendar/gui/e-day-view-time-item.c | 2 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 518 | ||||
-rw-r--r-- | calendar/gui/e-day-view.h | 47 | ||||
-rw-r--r-- | calendar/gui/e-week-view-config.c | 288 | ||||
-rw-r--r-- | calendar/gui/e-week-view-config.h | 55 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 540 | ||||
-rw-r--r-- | calendar/gui/e-week-view.h | 4 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 21 |
16 files changed, 1003 insertions, 1600 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 7bc52c9e15..0878c0eae9 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -83,8 +83,6 @@ libcal_gui_la_SOURCES = \ e-cal-popup.c \ e-cal-list-view.c \ e-cal-list-view.h \ - e-cal-list-view-config.c \ - e-cal-list-view-config.h \ e-cal-model-memos.c \ e-cal-model-memos.h \ e-calendar-table-config.c \ @@ -101,8 +99,6 @@ libcal_gui_la_SOURCES = \ e-date-edit-config.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 \ @@ -144,8 +140,6 @@ libcal_gui_la_SOURCES = \ e-select-names-renderer.h \ e-task-list-selector.c \ e-task-list-selector.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/e-cal-list-view-config.c b/calendar/gui/e-cal-list-view-config.c deleted file mode 100644 index 047e89261d..0000000000 --- a/calendar/gui/e-cal-list-view-config.c +++ /dev/null @@ -1,203 +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 <http://www.gnu.org/licenses/> - * - * - * Authors: - * Rodrigo Moya <rodrigo@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include "calendar-config.h" -#include "e-cal-list-view-config.h" - -struct _ECalListViewConfigPrivate { - ECalListView *view; - - GList *notifications; -}; - -/* Property IDs */ -enum props { - PROP_0, - PROP_VIEW -}; - -G_DEFINE_TYPE (ECalListViewConfig, e_cal_list_view_config, G_TYPE_OBJECT) - -static void -e_cal_list_view_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - ECalListViewConfig *view_config; - - view_config = E_CAL_LIST_VIEW_CONFIG (object); - - switch (property_id) { - case PROP_VIEW: - e_cal_list_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_cal_list_view_config_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) -{ - ECalListViewConfig *view_config; - - view_config = E_CAL_LIST_VIEW_CONFIG (object); - - switch (property_id) { - case PROP_VIEW: - g_value_set_object (value, e_cal_list_view_config_get_view (view_config)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -e_cal_list_view_config_dispose (GObject *object) -{ - ECalListViewConfig *view_config = E_CAL_LIST_VIEW_CONFIG (object); - - e_cal_list_view_config_set_view (view_config, NULL); - - if (G_OBJECT_CLASS (e_cal_list_view_config_parent_class)->dispose) - G_OBJECT_CLASS (e_cal_list_view_config_parent_class)->dispose (object); -} - -static void -e_cal_list_view_config_finalize (GObject *object) -{ - ECalListViewConfig *view_config = E_CAL_LIST_VIEW_CONFIG (object); - ECalListViewConfigPrivate *priv; - - priv = view_config->priv; - - g_free (priv); - - if (G_OBJECT_CLASS (e_cal_list_view_config_parent_class)->finalize) - G_OBJECT_CLASS (e_cal_list_view_config_parent_class)->finalize (object); -} - -static void -e_cal_list_view_config_class_init (ECalListViewConfigClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GParamSpec *spec; - - /* Method override */ - gobject_class->set_property = e_cal_list_view_config_set_property; - gobject_class->get_property = e_cal_list_view_config_get_property; - gobject_class->dispose = e_cal_list_view_config_dispose; - gobject_class->finalize = e_cal_list_view_config_finalize; - - spec = g_param_spec_object ("view", NULL, NULL, e_cal_list_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_cal_list_view_config_init (ECalListViewConfig *view_config) -{ - view_config->priv = g_new0 (ECalListViewConfigPrivate, 1); - -} - -ECalListViewConfig * -e_cal_list_view_config_new (ECalListView *list_view) -{ - ECalListViewConfig *view_config; - - view_config = g_object_new (e_cal_list_view_config_get_type (), "view", list_view, NULL); - - return view_config; -} - -ECalListView * -e_cal_list_view_config_get_view (ECalListViewConfig *view_config) -{ - ECalListViewConfigPrivate *priv; - - g_return_val_if_fail (view_config != NULL, NULL); - g_return_val_if_fail (E_IS_CAL_LIST_VIEW_CONFIG (view_config), NULL); - - priv = view_config->priv; - - return priv->view; -} - -static void -set_twentyfour_hour (ECalListView *list_view) -{ - ECalModel *model; - gboolean use_24_hour; - - use_24_hour = calendar_config_get_24_hour_format (); - - model = e_calendar_view_get_model (E_CALENDAR_VIEW (list_view)); - e_cal_model_set_use_24_hour_format (model, use_24_hour); -} - -static void -twentyfour_hour_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) -{ - ECalListViewConfig *view_config = data; - ECalListViewConfigPrivate *priv; - - priv = view_config->priv; - - set_twentyfour_hour (priv->view); -} - -void -e_cal_list_view_config_set_view (ECalListViewConfig *view_config, ECalListView *list_view) -{ - ECalListViewConfigPrivate *priv; - guint not; - GList *l; - - g_return_if_fail (view_config != NULL); - g_return_if_fail (E_IS_CAL_LIST_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 (!list_view) - return; - - priv->view = g_object_ref (list_view); - - /* 24 Hour format */ - set_twentyfour_hour (list_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)); -} diff --git a/calendar/gui/e-cal-list-view-config.h b/calendar/gui/e-cal-list-view-config.h deleted file mode 100644 index 270228bed6..0000000000 --- a/calendar/gui/e-cal-list-view-config.h +++ /dev/null @@ -1,56 +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 <http://www.gnu.org/licenses/> - * - * - * Authors: - * JP Rosevear <jpr@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef _E_CAL_LIST_VIEW_CONFIG_H_ -#define _E_CAL_LIST_VIEW_CONFIG_H_ - -#include "e-cal-list-view.h" - -G_BEGIN_DECLS - -#define E_CAL_LIST_VIEW_CONFIG(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_cal_list_view_config_get_type (), ECalListViewConfig) -#define E_CAL_LIST_VIEW_CONFIG_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_cal_list_view_config_get_type (), ECalListViewConfigClass) -#define E_IS_CAL_LIST_VIEW_CONFIG(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_cal_list_view_config_get_type ()) - -typedef struct _ECalListViewConfig ECalListViewConfig; -typedef struct _ECalListViewConfigClass ECalListViewConfigClass; -typedef struct _ECalListViewConfigPrivate ECalListViewConfigPrivate; - -struct _ECalListViewConfig { - GObject parent; - - ECalListViewConfigPrivate *priv; -}; - -struct _ECalListViewConfigClass { - GObjectClass parent_class; -}; - -GType e_cal_list_view_config_get_type (void); -ECalListViewConfig *e_cal_list_view_config_new (ECalListView *list_view); -ECalListView *e_cal_list_view_config_get_view (ECalListViewConfig *view_config); -void e_cal_list_view_config_set_view (ECalListViewConfig *view_config, ECalListView *list_view); - -G_END_DECLS - -#endif diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c index 747635998e..c87674fcc7 100644 --- a/calendar/gui/e-cal-model.c +++ b/calendar/gui/e-cal-model.c @@ -38,6 +38,14 @@ #include "calendar-config.h" #include "e-util/e-util.h" +#define E_CAL_MODEL_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_CAL_MODEL, ECalModelPrivate)) + +#define E_CAL_MODEL_COMPONENT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_CAL_MODEL_COMPONENT, ECalModelComponentPrivate)) + typedef struct { ECal *client; ECalView *query; @@ -83,13 +91,6 @@ struct _ECalModelPrivate { gpointer get_default_time_user_data; }; -#define E_CAL_MODEL_COMPONENT_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), E_TYPE_CAL_MODEL_COMPONENT, ECalModelComponentPrivate)) - -static void e_cal_model_dispose (GObject *object); -static void e_cal_model_finalize (GObject *object); - static gint ecm_column_count (ETableModel *etm); static gint ecm_row_count (ETableModel *etm); static gpointer ecm_value_at (ETableModel *etm, gint col, gint row); @@ -109,7 +110,11 @@ static ECalModelClient *find_client_data (ECalModel *model, ECal *client); static void remove_client_objects (ECalModel *model, ECalModelClient *client_data); static void remove_client (ECalModel *model, ECalModelClient *client_data); -/* Signal IDs */ +enum { + PROP_0, + PROP_USE_24_HOUR_FORMAT +}; + enum { TIME_RANGE_CHANGED, ROW_APPENDED, @@ -119,19 +124,124 @@ enum { LAST_SIGNAL }; -static guint signals[LAST_SIGNAL] = { 0 }; +static gpointer parent_class; +static guint signals[LAST_SIGNAL]; G_DEFINE_TYPE (ECalModel, e_cal_model, E_TABLE_MODEL_TYPE) static void -e_cal_model_class_init (ECalModelClass *klass) +cal_model_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_USE_24_HOUR_FORMAT: + e_cal_model_set_use_24_hour_format ( + E_CAL_MODEL (object), + g_value_get_boolean (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +cal_model_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_USE_24_HOUR_FORMAT: + g_value_set_boolean ( + value, + e_cal_model_get_use_24_hour_format ( + E_CAL_MODEL (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +cal_model_dispose (GObject *object) +{ + ECalModelPrivate *priv; + + priv = E_CAL_MODEL_GET_PRIVATE (object); + + if (priv->clients) { + while (priv->clients != NULL) { + ECalModelClient *client_data = (ECalModelClient *) priv->clients->data; + + g_signal_handlers_disconnect_matched (client_data->client, G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, object); + if (client_data->query) + g_signal_handlers_disconnect_matched (client_data->query, G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, object); + + priv->clients = g_list_remove (priv->clients, client_data); + + g_object_unref (client_data->client); + if (client_data->query) + g_object_unref (client_data->query); + g_free (client_data); + } + + priv->clients = NULL; + priv->default_client = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +cal_model_finalize (GObject *object) +{ + ECalModelPrivate *priv; + gint ii; + + priv = E_CAL_MODEL_GET_PRIVATE (object); + + g_free (priv->search_sexp); + g_free (priv->full_sexp); + + g_free (priv->default_category); + + for (ii = 0; ii < priv->objects->len; ii++) { + ECalModelComponent *comp_data; + + comp_data = g_ptr_array_index (priv->objects, ii); + if (comp_data == NULL) { + g_warning ("comp_data is null\n"); + continue; + } + e_cal_model_free_component_data (comp_data); + } + g_ptr_array_free (priv->objects, FALSE); + + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void +e_cal_model_class_init (ECalModelClass *class) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); - ETableModelClass *etm_class = E_TABLE_MODEL_CLASS (klass); + GObjectClass *object_class; + ETableModelClass *etm_class; + + parent_class = g_type_class_peek_parent (class); + g_type_class_add_private (class, sizeof (ECalModelPrivate)); - object_class->dispose = e_cal_model_dispose; - object_class->finalize = e_cal_model_finalize; + object_class = G_OBJECT_CLASS (class); + object_class->set_property = cal_model_set_property; + object_class->get_property = cal_model_get_property; + object_class->dispose = cal_model_dispose; + object_class->finalize = cal_model_finalize; + etm_class = E_TABLE_MODEL_CLASS (class); etm_class->column_count = ecm_column_count; etm_class->row_count = ecm_row_count; etm_class->value_at = ecm_value_at; @@ -144,12 +254,22 @@ e_cal_model_class_init (ECalModelClass *klass) etm_class->value_is_empty = ecm_value_is_empty; etm_class->value_to_string = ecm_value_to_string; - klass->get_color_for_component = ecm_get_color_for_component; - klass->fill_component_from_model = NULL; + class->get_color_for_component = ecm_get_color_for_component; + class->fill_component_from_model = NULL; + + 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, + TRUE, + G_PARAM_READWRITE)); signals[TIME_RANGE_CHANGED] = g_signal_new ("time_range_changed", - G_TYPE_FROM_CLASS (klass), + G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ECalModelClass, time_range_changed), NULL, NULL, @@ -158,7 +278,7 @@ e_cal_model_class_init (ECalModelClass *klass) signals[ROW_APPENDED] = g_signal_new ("row_appended", - G_TYPE_FROM_CLASS (klass), + G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ECalModelClass, row_appended), NULL, NULL, @@ -167,7 +287,7 @@ e_cal_model_class_init (ECalModelClass *klass) signals[COMPS_DELETED] = g_signal_new ("comps_deleted", - G_TYPE_FROM_CLASS (klass), + G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ECalModelClass, comps_deleted), NULL, NULL, @@ -176,7 +296,7 @@ e_cal_model_class_init (ECalModelClass *klass) signals[CAL_VIEW_PROGRESS] = g_signal_new ("cal_view_progress", - G_TYPE_FROM_CLASS (klass), + G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ECalModelClass, cal_view_progress), NULL, NULL, @@ -184,7 +304,7 @@ e_cal_model_class_init (ECalModelClass *klass) G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT); signals[CAL_VIEW_DONE] = g_signal_new ("cal_view_done", - G_TYPE_FROM_CLASS (klass), + G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ECalModelClass, cal_view_done), NULL, NULL, @@ -198,101 +318,21 @@ e_cal_model_init (ECalModel *model) { ECalModelPrivate *priv; - priv = g_new0 (ECalModelPrivate, 1); - model->priv = priv; + model->priv = E_CAL_MODEL_GET_PRIVATE (model); /* match none by default */ - priv->start = -1; - priv->end = -1; - priv->search_sexp = NULL; - priv->full_sexp = g_strdup ("#f"); - - priv->objects = g_ptr_array_new (); - priv->kind = ICAL_NO_COMPONENT; - priv->flags = 0; - - priv->accounts = itip_addresses_get (); - - priv->use_24_hour_format = TRUE; -} - -static void -clear_objects_array (ECalModelPrivate *priv) -{ - gint i; - - for (i = 0; i < priv->objects->len; i++) { - ECalModelComponent *comp_data; - - comp_data = g_ptr_array_index (priv->objects, i); - if (comp_data == NULL) { - g_warning ("comp_data is null\n"); - continue; - } - e_cal_model_free_component_data (comp_data); - } - - g_ptr_array_set_size (priv->objects, 0); -} - -static void -e_cal_model_dispose (GObject *object) -{ - ECalModelPrivate *priv; - ECalModel *model = (ECalModel *) object; - - g_return_if_fail (E_IS_CAL_MODEL (model)); - - priv = model->priv; + model->priv->start = -1; + model->priv->end = -1; + model->priv->search_sexp = NULL; + model->priv->full_sexp = g_strdup ("#f"); - if (priv->clients) { - while (priv->clients != NULL) { - ECalModelClient *client_data = (ECalModelClient *) priv->clients->data; - - g_signal_handlers_disconnect_matched (client_data->client, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, model); - if (client_data->query) - g_signal_handlers_disconnect_matched (client_data->query, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, model); - - priv->clients = g_list_remove (priv->clients, client_data); - - g_object_unref (client_data->client); - if (client_data->query) - g_object_unref (client_data->query); - g_free (client_data); - } - - priv->clients = NULL; - priv->default_client = NULL; - } - - if (G_OBJECT_CLASS (e_cal_model_parent_class)->dispose) - G_OBJECT_CLASS (e_cal_model_parent_class)->dispose (object); -} - -static void -e_cal_model_finalize (GObject *object) -{ - ECalModelPrivate *priv; - ECalModel *model = (ECalModel *) object; - - g_return_if_fail (E_IS_CAL_MODEL (model)); - - priv = model->priv; - - g_free (priv->search_sexp); - g_free (priv->full_sexp); - - g_free (priv->default_category); - - clear_objects_array (priv); - g_ptr_array_free (priv->objects, FALSE); + model->priv->objects = g_ptr_array_new (); + model->priv->kind = ICAL_NO_COMPONENT; + model->priv->flags = 0; - g_free (priv); + model->priv->accounts = itip_addresses_get (); - if (G_OBJECT_CLASS (e_cal_model_parent_class)->finalize) - G_OBJECT_CLASS (e_cal_model_parent_class)->finalize (object); + model->priv->use_24_hour_format = TRUE; } /* ETableModel methods */ @@ -2327,17 +2367,17 @@ struct _ECalModelComponentPrivate { static void e_cal_model_component_finalize (GObject *object); -static GObjectClass *parent_class; +static GObjectClass *component_parent_class; /* Class initialization function for the calendar component object */ static void -e_cal_model_component_class_init (ECalModelComponentClass *klass) +e_cal_model_component_class_init (ECalModelComponentClass *class) { GObjectClass *object_class; - object_class = (GObjectClass *) klass; + object_class = (GObjectClass *) class; - parent_class = g_type_class_peek_parent (klass); + component_parent_class = g_type_class_peek_parent (class); object_class->finalize = e_cal_model_component_finalize; } @@ -2384,8 +2424,8 @@ e_cal_model_component_finalize (GObject *object) comp_data->color = NULL; } - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); + if (G_OBJECT_CLASS (component_parent_class)->finalize) + (* G_OBJECT_CLASS (component_parent_class)->finalize) (object); } /* Object initialization function for the calendar component object */ diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index a9b717f0eb..543623beaf 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -503,59 +503,72 @@ e_calendar_view_set_default_category (ECalendarView *cal_view, const gchar *cate GList * e_calendar_view_get_selected_events (ECalendarView *cal_view) { + ECalendarViewClass *class; + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), NULL); - if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_events) - return E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_events (cal_view); + class = E_CALENDAR_VIEW_GET_CLASS (cal_view); + g_return_val_if_fail (class->get_selected_events != NULL, NULL); - return NULL; + return class->get_selected_events (cal_view); } gboolean -e_calendar_view_get_selected_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time) +e_calendar_view_get_selected_time_range (ECalendarView *cal_view, + time_t *start_time, + time_t *end_time) { + ECalendarViewClass *class; + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), FALSE); - if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_time_range) { - return E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_selected_time_range ( - cal_view, start_time, end_time); - } + class = E_CALENDAR_VIEW_GET_CLASS (cal_view); + g_return_val_if_fail (class->get_selected_time_range != NULL, FALSE); - return FALSE; + return class->get_selected_time_range (cal_view, start_time, end_time); } void -e_calendar_view_set_selected_time_range (ECalendarView *cal_view, time_t start_time, time_t end_time) +e_calendar_view_set_selected_time_range (ECalendarView *cal_view, + time_t start_time, + time_t end_time) { + ECalendarViewClass *class; + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->set_selected_time_range) { - E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->set_selected_time_range ( - cal_view, start_time, end_time); - } + class = E_CALENDAR_VIEW_GET_CLASS (cal_view); + g_return_if_fail (class->set_selected_time_range != NULL); + + class->set_selected_time_range (cal_view, start_time, end_time); } gboolean -e_calendar_view_get_visible_time_range (ECalendarView *cal_view, time_t *start_time, time_t *end_time) +e_calendar_view_get_visible_time_range (ECalendarView *cal_view, + time_t *start_time, + time_t *end_time) { + ECalendarViewClass *class; + g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), FALSE); - if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_visible_time_range) { - return E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->get_visible_time_range ( - cal_view, start_time, end_time); - } + class = E_CALENDAR_VIEW_GET_CLASS (cal_view); + g_return_val_if_fail (class->get_visible_time_range != NULL, FALSE); - return FALSE; + class->get_visible_time_range (cal_view, start_time, end_time); } void e_calendar_view_update_query (ECalendarView *cal_view) { + ECalendarViewClass *class; + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->update_query) { - E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->update_query (cal_view); - } + class = E_CALENDAR_VIEW_GET_CLASS (cal_view); + g_return_if_fail (class->update_query != NULL); + + class->update_query (cal_view); } void @@ -846,10 +859,14 @@ clipboard_get_calendar_data (ECalendarView *cal_view, const gchar *text) static void e_calendar_view_paste_text (ECalendarView *cal_view) { + ECalendarViewClass *class; + g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view)); - if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->paste_text) - E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (cal_view))->paste_text (cal_view); + class = E_CALENDAR_VIEW_GET_CLASS (cal_view); + g_return_if_fail (class->paste_text != NULL); + + class->paste_text (cal_view); } static void diff --git a/calendar/gui/e-day-view-config.c b/calendar/gui/e-day-view-config.c deleted file mode 100644 index b9eff43bcd..0000000000 --- a/calendar/gui/e-day-view-config.c +++ /dev/null @@ -1,464 +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 <http://www.gnu.org/licenses/> - * - * - * Authors: - * Rodrigo Moya <rodrigo@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include "calendar-config.h" -#include "e-day-view-config.h" - -struct _EDayViewConfigPrivate { - EDayView *view; - - GList *notifications; -}; - -/* Property IDs */ -enum props { - PROP_0, - PROP_VIEW -}; - -G_DEFINE_TYPE (EDayViewConfig, e_day_view_config, G_TYPE_OBJECT) - -static void -e_day_view_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - EDayViewConfig *view_config; - - view_config = E_DAY_VIEW_CONFIG (object); - - 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; - - view_config = E_DAY_VIEW_CONFIG (object); - - 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); - - e_day_view_config_set_view (view_config, NULL); - - if (G_OBJECT_CLASS (e_day_view_config_parent_class)->dispose) - G_OBJECT_CLASS (e_day_view_config_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 (e_day_view_config_parent_class)->finalize) - G_OBJECT_CLASS (e_day_view_config_parent_class)->finalize (object); -} - -static void -e_day_view_config_class_init (EDayViewConfigClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GParamSpec *spec; - - /* 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) -{ - view_config->priv = g_new0 (EDayViewConfigPrivate, 1); - -} - -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) -{ - gint 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) -{ - ECalModel *model; - gboolean use_24_hour; - - use_24_hour = calendar_config_get_24_hour_format (); - - model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); - e_cal_model_set_use_24_hour_format (model, use_24_hour); - - /* To redraw the times */ - gtk_widget_queue_draw (day_view->time_canvas); -} - -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) -{ - gint 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) -{ - gint 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) -{ - gint 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) -{ - gint 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) -{ - gint 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_marcus_bains (EDayView *day_view) -{ - gboolean show_marcus_bains_line; - const gchar *dayview_color, *timebar_color; - - calendar_config_get_marcus_bains (&show_marcus_bains_line, &dayview_color, &timebar_color); - - e_day_view_set_marcus_bains (day_view, show_marcus_bains_line, dayview_color, timebar_color); -} - -static void -marcus_bains_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) -{ - EDayViewConfig *view_config = data; - EDayViewConfigPrivate *priv; - - priv = view_config->priv; - - set_marcus_bains (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; - gint not_1, not_2, mbnot; - 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 Marcus Bains Line */ - set_marcus_bains (day_view); - - calendar_config_add_notification_marcus_bains (marcus_bains_changed_cb, view_config, &mbnot, ¬_1, ¬_2); - priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (mbnot)); - priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not_1)); - priv->notifications = g_list_prepend (priv->notifications, GUINT_TO_POINTER (not_2)); - - /* 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 deleted file mode 100644 index 25d208b432..0000000000 --- a/calendar/gui/e-day-view-config.h +++ /dev/null @@ -1,56 +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 <http://www.gnu.org/licenses/> - * - * - * Authors: - * JP Rosevear <jpr@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef _E_DAY_VIEW_CONFIG_H_ -#define _E_DAY_VIEW_CONFIG_H_ - -#include "e-day-view.h" - -G_BEGIN_DECLS - -#define E_DAY_VIEW_CONFIG(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_day_view_config_get_type (), EDayViewConfig) -#define E_DAY_VIEW_CONFIG_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_day_view_config_get_type (), EDayViewConfigClass) -#define E_IS_DAY_VIEW_CONFIG(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_day_view_config_get_type ()) - -typedef struct _EDayViewConfig EDayViewConfig; -typedef struct _EDayViewConfigClass EDayViewConfigClass; -typedef struct _EDayViewConfigPrivate EDayViewConfigPrivate; - -struct _EDayViewConfig { - GObject parent; - - EDayViewConfigPrivate *priv; -}; - -struct _EDayViewConfigClass { - GObjectClass 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-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c index 9f63d25b93..afa4e8b5c6 100644 --- a/calendar/gui/e-day-view-main-item.c +++ b/calendar/gui/e-day-view-main-item.c @@ -367,7 +367,7 @@ e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable, day); } - if (e_day_view_get_show_marcus_bains (day_view)) { + if (e_day_view_marcus_bains_get_show_line (day_view)) { icaltimezone *zone; struct icaltimetype time_now, day_start; gint marcus_bains_y; diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c index 6d5f80062a..c3129b6aba 100644 --- a/calendar/gui/e-day-view-time-item.c +++ b/calendar/gui/e-day-view-time-item.c @@ -413,7 +413,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, E_DVTMI_LARGE_HOUR_Y_PAD); /* Draw the Marcus Bains Line first, so it appears under other elements. */ - if (e_day_view_get_show_marcus_bains (day_view)) { + if (e_day_view_marcus_bains_get_show_line (day_view)) { struct icaltimetype time_now; gint marcus_bains_y; diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 42fe3f47a0..117e69d1ff 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -431,38 +431,324 @@ static void e_day_view_queue_layout (EDayView *day_view); static void e_day_view_cancel_layout (EDayView *day_view); static gboolean e_day_view_layout_timeout_cb (gpointer data); +enum { + PROP_0, + PROP_MARCUS_BAINS_SHOW_LINE, + PROP_MARCUS_BAINS_DAY_VIEW_COLOR, + PROP_MARCUS_BAINS_TIME_BAR_COLOR, + PROP_MINS_PER_ROW, + PROP_WEEK_START_DAY, + 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_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_MARCUS_BAINS_SHOW_LINE: + e_day_view_marcus_bains_set_show_line ( + E_DAY_VIEW (object), + g_value_get_boolean (value)); + return; + + case PROP_MARCUS_BAINS_DAY_VIEW_COLOR: + e_day_view_marcus_bains_set_day_view_color ( + E_DAY_VIEW (object), + g_value_get_string (value)); + return; + + case PROP_MARCUS_BAINS_TIME_BAR_COLOR: + e_day_view_marcus_bains_set_time_bar_color ( + E_DAY_VIEW (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_WEEK_START_DAY: + e_day_view_set_week_start_day ( + 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), + g_value_get_int (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +day_view_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_MARCUS_BAINS_SHOW_LINE: + g_value_set_boolean ( + value, + e_day_view_marcus_bains_get_show_line ( + E_DAY_VIEW (object))); + return; + + case PROP_MARCUS_BAINS_DAY_VIEW_COLOR: + g_value_set_string ( + value, + e_day_view_marcus_bains_get_day_view_color ( + E_DAY_VIEW (object))); + return; + + case PROP_MARCUS_BAINS_TIME_BAR_COLOR: + g_value_set_string ( + value, + e_day_view_marcus_bains_get_time_bar_color ( + 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_WEEK_START_DAY: + g_value_set_int ( + value, + e_day_view_get_week_start_day ( + 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, + e_day_view_get_working_days ( + E_DAY_VIEW (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void e_day_view_class_init (EDayViewClass *class) { - GtkObjectClass *object_class; + GObjectClass *object_class; + GtkObjectClass *gtk_object_class; GtkWidgetClass *widget_class; ECalendarViewClass *view_class; - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - view_class = (ECalendarViewClass *) class; - - /* Method override */ - object_class->destroy = e_day_view_destroy; - - widget_class->realize = e_day_view_realize; - widget_class->unrealize = e_day_view_unrealize; - widget_class->style_set = e_day_view_style_set; - widget_class->size_allocate = e_day_view_size_allocate; - widget_class->focus_in_event = e_day_view_focus_in; - widget_class->focus_out_event = e_day_view_focus_out; - widget_class->key_press_event = e_day_view_key_press; - widget_class->focus = e_day_view_focus; - widget_class->popup_menu = e_day_view_popup_menu; - + object_class = G_OBJECT_CLASS (class); + object_class->set_property = day_view_set_property; + object_class->get_property = day_view_get_property; + + gtk_object_class = GTK_OBJECT_CLASS (class); + gtk_object_class->destroy = e_day_view_destroy; + + widget_class = GTK_WIDGET_CLASS (class); + widget_class->realize = e_day_view_realize; + widget_class->unrealize = e_day_view_unrealize; + widget_class->style_set = e_day_view_style_set; + widget_class->size_allocate = e_day_view_size_allocate; + widget_class->focus_in_event = e_day_view_focus_in; + widget_class->focus_out_event = e_day_view_focus_out; + widget_class->key_press_event = e_day_view_key_press; + widget_class->focus = e_day_view_focus; + widget_class->popup_menu = e_day_view_popup_menu; + + view_class = E_CALENDAR_VIEW_CLASS (class); view_class->get_selected_events = e_day_view_get_selected_events; view_class->get_selected_time_range = e_day_view_get_selected_time_range; view_class->set_selected_time_range = e_day_view_set_selected_time_range; view_class->get_visible_time_range = e_day_view_get_visible_time_range; view_class->paste_text = e_day_view_paste_text; + /* XXX Should these be constructor properties? */ + + g_object_class_install_property ( + object_class, + PROP_MARCUS_BAINS_SHOW_LINE, + g_param_spec_boolean ( + "marcus-bains-show-line", + "Marcus Bains Show Line", + NULL, + TRUE, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_MARCUS_BAINS_DAY_VIEW_COLOR, + g_param_spec_string ( + "marcus-bains-day-view-color", + "Marcus Bains Day View Color", + NULL, + NULL, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_MARCUS_BAINS_TIME_BAR_COLOR, + g_param_spec_string ( + "marcus-bains-time-bar-color", + "Marcus Bains Time Bar Color", + NULL, + 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_WEEK_START_DAY, + g_param_spec_int ( + "week-start-day", + "Week Start Day", + NULL, + 0, /* Monday */ + 6, /* Sunday */ + 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, + 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, + PROP_WORKING_DAYS, + g_param_spec_int ( + "working-days", + "Working Days", + NULL, + 0x00, + 0x7f, + 0, + G_PARAM_READWRITE)); + #if 0 /* KILL-BONOBO */ /* init the accessibility support for e_day_view */ e_day_view_a11y_init (); @@ -762,7 +1048,7 @@ e_day_view_init (EDayView *day_view) day_view->week_start_day = 0; day_view->scroll_to_work_day = TRUE; - day_view->show_marcus_bains_line = TRUE; + day_view->marcus_bains_show_line = TRUE; day_view->marcus_bains_day_view_color = NULL; day_view->marcus_bains_time_bar_color = NULL; @@ -2382,7 +2668,7 @@ e_day_view_set_days_shown (EDayView *day_view, } gint -e_day_view_get_mins_per_row (EDayView *day_view) +e_day_view_get_mins_per_row (EDayView *day_view) { g_return_val_if_fail (E_IS_DAY_VIEW (day_view), -1); @@ -2390,8 +2676,8 @@ 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) +e_day_view_set_mins_per_row (EDayView *day_view, + gint mins_per_row) { gint day; @@ -2409,6 +2695,8 @@ e_day_view_set_mins_per_row (EDayView *day_view, 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) return; @@ -2433,7 +2721,7 @@ e_day_view_set_mins_per_row (EDayView *day_view, /* 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) +e_day_view_get_working_days (EDayView *day_view) { g_return_val_if_fail (E_IS_DAY_VIEW (day_view), 0); @@ -2441,8 +2729,8 @@ e_day_view_get_working_days (EDayView *day_view) } void -e_day_view_set_working_days (EDayView *day_view, - EDayViewDays days) +e_day_view_set_working_days (EDayView *day_view, + EDayViewDays days) { g_return_if_fail (E_IS_DAY_VIEW (day_view)); @@ -2457,6 +2745,8 @@ e_day_view_set_working_days (EDayView *day_view, /* We have to do this, as the new working days may have no effect on the days shown, but we still want the background color to change. */ gtk_widget_queue_draw (day_view->main_canvas); + + g_object_notify (G_OBJECT (day_view), "working-days"); } static void @@ -2496,86 +2786,162 @@ e_day_view_recalc_work_week_days_shown (EDayView *day_view) /* 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_get_working_day (EDayView *day_view, - gint *start_hour, - gint *start_minute, - gint *end_hour, - gint *end_minute) +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)); - *start_hour = day_view->work_day_start_hour; - *start_minute = day_view->work_day_start_minute; - *end_hour = day_view->work_day_end_hour; - *end_minute = day_view->work_day_end_minute; + 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_working_day (EDayView *day_view, - gint start_hour, - gint start_minute, - gint end_hour, - gint end_minute) +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_start_hour = start_hour; - day_view->work_day_start_minute = start_minute; - day_view->work_day_end_hour = end_hour; - day_view->work_day_end_minute = end_minute; + 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"); } -/* Whether we display the Marcus Bains Line in the main canvas and time canvas. */ -gboolean -e_day_view_get_show_marcus_bains (EDayView *day_view) +gint +e_day_view_get_work_day_end_minute (EDayView *day_view) { - g_return_val_if_fail (E_IS_DAY_VIEW (day_view), TRUE); - return day_view->show_marcus_bains_line; + 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_update_marcus_bains (EDayView *day_view) +e_day_view_marcus_bains_update (EDayView *day_view) { g_return_if_fail (E_IS_DAY_VIEW (day_view)); gtk_widget_queue_draw (day_view->main_canvas); gtk_widget_queue_draw (day_view->time_canvas); } -/* Update the variables controlling the Marcus Bains Line (display toggle, and colors). */ +gboolean +e_day_view_marcus_bains_get_show_line (EDayView *day_view) +{ + g_return_val_if_fail (E_IS_DAY_VIEW (day_view), FALSE); + + return day_view->marcus_bains_show_line; +} + void -e_day_view_set_marcus_bains (EDayView *day_view, - gboolean show_line, - const gchar *dayview_color, - const gchar *timebar_color) +e_day_view_marcus_bains_set_show_line (EDayView *day_view, + gboolean show_line) { g_return_if_fail (E_IS_DAY_VIEW (day_view)); - if ((day_view->show_marcus_bains_line != show_line) | - (day_view->marcus_bains_day_view_color != dayview_color) | - (day_view->marcus_bains_time_bar_color != timebar_color)) { + day_view->marcus_bains_show_line = show_line; - if (day_view->marcus_bains_day_view_color) - g_free (day_view->marcus_bains_day_view_color); - if (day_view->marcus_bains_time_bar_color) - g_free (day_view->marcus_bains_time_bar_color); + e_day_view_marcus_bains_update (day_view); - day_view->show_marcus_bains_line = show_line; - if (dayview_color) - day_view->marcus_bains_day_view_color = g_strdup (dayview_color); - else - day_view->marcus_bains_day_view_color = NULL; + g_object_notify (G_OBJECT (day_view), "marcus-bains-show-line"); +} - if (timebar_color) - day_view->marcus_bains_time_bar_color = g_strdup (timebar_color); - else - day_view->marcus_bains_time_bar_color = NULL; +const gchar * +e_day_view_marcus_bains_get_day_view_color (EDayView *day_view) +{ + g_return_val_if_fail (E_IS_DAY_VIEW (day_view), NULL); - e_day_view_update_marcus_bains (day_view); - } + return day_view->marcus_bains_day_view_color; +} + +void +e_day_view_marcus_bains_set_day_view_color (EDayView *day_view, + const gchar *day_view_color) +{ + g_return_if_fail (E_IS_DAY_VIEW (day_view)); + + g_free (day_view->marcus_bains_day_view_color); + day_view->marcus_bains_day_view_color = g_strdup (day_view_color); + + e_day_view_marcus_bains_update (day_view); + + g_object_notify (G_OBJECT (day_view), "marcus-bains-day-view-color"); +} + +const gchar * +e_day_view_marcus_bains_get_time_bar_color (EDayView *day_view) +{ + g_return_val_if_fail (E_IS_DAY_VIEW (day_view), NULL); + + return day_view->marcus_bains_time_bar_color; +} + +void +e_day_view_marcus_bains_set_time_bar_color (EDayView *day_view, + const gchar *time_bar_color) +{ + g_return_if_fail (E_IS_DAY_VIEW (day_view)); + + g_free (day_view->marcus_bains_time_bar_color); + day_view->marcus_bains_time_bar_color = g_strdup (time_bar_color); + + e_day_view_marcus_bains_update (day_view); + + g_object_notify (G_OBJECT (day_view), "marcus-bains-time-bar-color"); } /* Whether we display event end times in the main canvas. */ @@ -2616,7 +2982,7 @@ e_day_view_set_show_times_cb (EDayView *day_view, /* The first day of the week, 0 (Monday) to 6 (Sunday). */ gint -e_day_view_get_week_start_day (EDayView *day_view) +e_day_view_get_week_start_day (EDayView *day_view) { g_return_val_if_fail (E_IS_DAY_VIEW (day_view), 0); @@ -2624,8 +2990,8 @@ e_day_view_get_week_start_day (EDayView *day_view) } void -e_day_view_set_week_start_day (EDayView *day_view, - gint week_start_day) +e_day_view_set_week_start_day (EDayView *day_view, + gint week_start_day) { g_return_if_fail (E_IS_DAY_VIEW (day_view)); g_return_if_fail (week_start_day >= 0); @@ -2638,6 +3004,8 @@ e_day_view_set_week_start_day (EDayView *day_view, if (day_view->work_week_view) e_day_view_recalc_work_week (day_view); + + g_object_notify (G_OBJECT (day_view), "week-start-day"); } static void diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h index 663252b7ba..8d778fa442 100644 --- a/calendar/gui/e-day-view.h +++ b/calendar/gui/e-day-view.h @@ -309,7 +309,7 @@ struct _EDayView { gint work_day_end_minute; /* Whether we show the Marcus Bains Line in the main canvas and time canvas. */ - gboolean show_marcus_bains_line; + gboolean marcus_bains_show_line; gchar *marcus_bains_day_view_color; gchar *marcus_bains_time_bar_color; @@ -525,23 +525,36 @@ void e_day_view_set_working_days (EDayView *day_view, /* The start and end time of the working day. This only affects the background colors. */ -void e_day_view_get_working_day (EDayView *day_view, - gint *start_hour, - gint *start_minute, - gint *end_hour, - gint *end_minute); -void e_day_view_set_working_day (EDayView *day_view, - gint start_hour, - gint start_minute, - gint end_hour, - gint end_minute); +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. */ -gboolean e_day_view_get_show_marcus_bains (EDayView *day_view); -void e_day_view_set_marcus_bains (EDayView *day_view, - gboolean show_line, - const gchar *dayview_color, - const gchar *timebar_color); +void e_day_view_marcus_bains_update (EDayView *day_view); +gboolean e_day_view_marcus_bains_get_show_line(EDayView *day_view); +void e_day_view_marcus_bains_set_show_line(EDayView *day_view, + gboolean show_line); +const gchar * + e_day_view_marcus_bains_get_day_view_color + (EDayView *day_view); +void e_day_view_marcus_bains_set_day_view_color + (EDayView *day_view, + const gchar *day_view_color); +const gchar * + e_day_view_marcus_bains_get_time_bar_color + (EDayView *day_view); +void e_day_view_marcus_bains_set_time_bar_color + (EDayView *day_view, + const gchar *time_bar_color); /* Whether we display event end times in the main canvas. */ gboolean e_day_view_get_show_event_end_times (EDayView *day_view); @@ -621,8 +634,6 @@ void e_day_view_ensure_rows_visible (EDayView *day_view, gint start_row, gint end_row); -void e_day_view_update_marcus_bains (EDayView *day_view); - /* Week number in upper-left corner of the day view widget */ gboolean e_day_view_get_show_week_number (EDayView *day_view); void e_day_view_set_show_week_number (EDayView *day_view, gboolean show); diff --git a/calendar/gui/e-week-view-config.c b/calendar/gui/e-week-view-config.c deleted file mode 100644 index fddc8667c6..0000000000 --- a/calendar/gui/e-week-view-config.c +++ /dev/null @@ -1,288 +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 <http://www.gnu.org/licenses/> - * - * - * Authors: - * Rodrigo Moya <rodrigo@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include "calendar-config.h" -#include "e-week-view-config.h" - -struct _EWeekViewConfigPrivate { - EWeekView *view; - - GList *notifications; -}; - -/* Property IDs */ -enum props { - PROP_0, - PROP_VIEW, -}; - -G_DEFINE_TYPE (EWeekViewConfig, e_week_view_config, G_TYPE_OBJECT) - -static void -e_week_view_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - EWeekViewConfig *view_config; - - view_config = E_WEEK_VIEW_CONFIG (object); - - 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; - - view_config = E_WEEK_VIEW_CONFIG (object); - - 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); - - e_week_view_config_set_view (view_config, NULL); - - if (G_OBJECT_CLASS (e_week_view_config_parent_class)->dispose) - G_OBJECT_CLASS (e_week_view_config_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 (e_week_view_config_parent_class)->finalize) - G_OBJECT_CLASS (e_week_view_config_parent_class)->finalize (object); -} - -static void -e_week_view_config_class_init (EWeekViewConfigClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GParamSpec *spec; - - /* 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_TYPE_WEEK_VIEW, - 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) -{ - view_config->priv = g_new0 (EWeekViewConfigPrivate, 1); - -} - -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) -{ - gint 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) -{ - ECalModel *model; - gboolean use_24_hour; - - use_24_hour = calendar_config_get_24_hour_format (); - - model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view)); - e_cal_model_set_use_24_hour_format (model, 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 deleted file mode 100644 index e86e0fa968..0000000000 --- a/calendar/gui/e-week-view-config.h +++ /dev/null @@ -1,55 +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 <http://www.gnu.org/licenses/> - * - * - * Authors: - * JP Rosevear <jpr@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef _E_WEEK_VIEW_CONFIG_H_ -#define _E_WEEK_VIEW_CONFIG_H_ - -#include "e-week-view.h" - -G_BEGIN_DECLS - -#define E_WEEK_VIEW_CONFIG(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_week_view_config_get_type (), EWeekViewConfig) -#define E_WEEK_VIEW_CONFIG_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_week_view_config_get_type (), EWeekViewConfigClass) -#define E_IS_WEEK_VIEW_CONFIG(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_week_view_config_get_type ()) - -typedef struct _EWeekViewConfig EWeekViewConfig; -typedef struct _EWeekViewConfigClass EWeekViewConfigClass; -typedef struct _EWeekViewConfigPrivate EWeekViewConfigPrivate; - -struct _EWeekViewConfig { - GObject parent; - - EWeekViewConfigPrivate *priv; -}; - -struct _EWeekViewConfigClass { - GObjectClass 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 b671abb6c9..397bb025ca 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -193,10 +193,109 @@ static gboolean e_week_view_layout_timeout_cb (gpointer data); G_DEFINE_TYPE (EWeekView, e_week_view, E_TYPE_CALENDAR_VIEW) +enum { + PROP_0, + PROP_COMPRESS_WEEKEND, + PROP_SHOW_EVENT_END_TIMES, + PROP_WEEK_START_DAY +}; + static gint map_left[] = {0, 1, 2, 0, 1, 2, 2}; static gint map_right[] = {3, 4, 5, 3, 4, 5, 6}; static void +timezone_changed_cb (ECalendarView *cal_view, + icaltimezone *old_zone, + icaltimezone *new_zone, + gpointer user_data) +{ + struct icaltimetype tt = icaltime_null_time (); + time_t lower; + EWeekView *week_view = (EWeekView *) cal_view; + + g_return_if_fail (E_IS_WEEK_VIEW (week_view)); + + if (!cal_view->in_focus) + return; + + /* If we don't have a valid date set yet, just return. */ + if (!g_date_valid (&week_view->first_day_shown)) + return; + + /* Recalculate the new start of the first week. We just use exactly + the same time, but with the new timezone. */ + tt.year = g_date_get_year (&week_view->first_day_shown); + tt.month = g_date_get_month (&week_view->first_day_shown); + tt.day = g_date_get_day (&week_view->first_day_shown); + + lower = icaltime_as_timet_with_zone (tt, new_zone); + + e_week_view_recalc_day_starts (week_view, lower); + e_week_view_update_query (week_view); +} + +static void +week_view_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_COMPRESS_WEEKEND: + e_week_view_set_compress_weekend ( + E_WEEK_VIEW (object), + g_value_get_boolean (value)); + return; + + case PROP_SHOW_EVENT_END_TIMES: + e_week_view_set_show_event_end_times ( + E_WEEK_VIEW (object), + g_value_get_boolean (value)); + return; + + case PROP_WEEK_START_DAY: + e_week_view_set_week_start_day ( + E_WEEK_VIEW (object), + g_value_get_int (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +week_view_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_COMPRESS_WEEKEND: + g_value_set_boolean ( + value, + e_week_view_get_compress_weekend ( + E_WEEK_VIEW (object))); + return; + + case PROP_SHOW_EVENT_END_TIMES: + g_value_set_boolean ( + value, + e_week_view_get_show_event_end_times ( + E_WEEK_VIEW (object))); + return; + + case PROP_WEEK_START_DAY: + g_value_set_int ( + value, + e_week_view_get_week_start_day ( + E_WEEK_VIEW (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void week_view_cursor_key_up (EWeekView *week_view) { if (week_view->selection_start_day == -1) @@ -259,28 +358,31 @@ week_view_cursor_key_right (EWeekView *week_view) static void e_week_view_class_init (EWeekViewClass *class) { - GtkObjectClass *object_class; + GObjectClass *object_class; + GtkObjectClass *gtk_object_class; GtkWidgetClass *widget_class; ECalendarViewClass *view_class; - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - view_class = (ECalendarViewClass *) class; - - /* Method override */ - object_class->destroy = e_week_view_destroy; - - widget_class->realize = e_week_view_realize; - widget_class->unrealize = e_week_view_unrealize; - widget_class->style_set = e_week_view_style_set; - widget_class->size_allocate = e_week_view_size_allocate; - widget_class->focus_in_event = e_week_view_focus_in; - widget_class->focus_out_event = e_week_view_focus_out; - widget_class->key_press_event = e_week_view_key_press; - widget_class->popup_menu = e_week_view_popup_menu; - widget_class->expose_event = e_week_view_expose_event; - widget_class->focus = e_week_view_focus; - + object_class = G_OBJECT_CLASS (class); + object_class->set_property = week_view_set_property; + object_class->get_property = week_view_get_property; + + gtk_object_class = GTK_OBJECT_CLASS (class); + gtk_object_class->destroy = e_week_view_destroy; + + widget_class = GTK_WIDGET_CLASS (class); + widget_class->realize = e_week_view_realize; + widget_class->unrealize = e_week_view_unrealize; + widget_class->style_set = e_week_view_style_set; + widget_class->size_allocate = e_week_view_size_allocate; + widget_class->focus_in_event = e_week_view_focus_in; + widget_class->focus_out_event = e_week_view_focus_out; + widget_class->key_press_event = e_week_view_key_press; + widget_class->popup_menu = e_week_view_popup_menu; + widget_class->expose_event = e_week_view_expose_event; + widget_class->focus = e_week_view_focus; + + view_class = E_CALENDAR_VIEW_CLASS (class); view_class->get_selected_events = e_week_view_get_selected_events; view_class->get_selected_time_range = e_week_view_get_selected_time_range; view_class->set_selected_time_range = e_week_view_set_selected_time_range; @@ -292,6 +394,40 @@ e_week_view_class_init (EWeekViewClass *class) class->cursor_key_left = week_view_cursor_key_left; class->cursor_key_right = week_view_cursor_key_right; + /* XXX This property really belongs in EMonthView, + * but too much drawing code is tied to it. */ + g_object_class_install_property ( + object_class, + PROP_COMPRESS_WEEKEND, + g_param_spec_boolean ( + "compress-weekend", + "Compress Weekend", + NULL, + TRUE, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_SHOW_EVENT_END_TIMES, + g_param_spec_boolean ( + "show-event-end-times", + "Show Event End Times", + NULL, + TRUE, + 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)); + #if 0 /* KILL-BONOBO */ /* init the accessibility support for e_week_view */ e_week_view_a11y_init (); @@ -299,6 +435,154 @@ e_week_view_class_init (EWeekViewClass *class) } static void +e_week_view_init (EWeekView *week_view) +{ + GnomeCanvasGroup *canvas_group; + GtkObject *adjustment; + GdkPixbuf *pixbuf; + gint i; + + GTK_WIDGET_SET_FLAGS (week_view, GTK_CAN_FOCUS); + + week_view->query = NULL; + week_view->event_destroyed = FALSE; + week_view->events = g_array_new (FALSE, FALSE, + sizeof (EWeekViewEvent)); + week_view->events_sorted = TRUE; + week_view->events_need_layout = FALSE; + week_view->events_need_reshape = FALSE; + + week_view->layout_timeout_id = 0; + + week_view->spans = NULL; + + week_view->multi_week_view = FALSE; + week_view->month_scroll_by_week = FALSE; + week_view->scroll_by_week_notif_id = 0; + week_view->update_base_date = TRUE; + week_view->weeks_shown = 6; + week_view->rows = 6; + week_view->columns = 2; + week_view->compress_weekend = TRUE; + week_view->show_event_end_times = TRUE; + week_view->week_start_day = 0; /* Monday. */ + week_view->display_start_day = 0; /* Monday. */ + + g_date_clear (&week_view->base_date, 1); + g_date_clear (&week_view->first_day_shown, 1); + + week_view->row_height = 10; + week_view->rows_per_cell = 1; + + week_view->selection_start_day = -1; + week_view->selection_drag_pos = E_WEEK_VIEW_DRAG_NONE; + + week_view->pressed_event_num = -1; + week_view->editing_event_num = -1; + + week_view->last_edited_comp_string = NULL; + + week_view->main_gc = NULL; + + /* Create the small font. */ + week_view->use_small_font = TRUE; + + week_view->small_font_desc = + pango_font_description_copy (gtk_widget_get_style (GTK_WIDGET (week_view))->font_desc); + pango_font_description_set_size (week_view->small_font_desc, + E_WEEK_VIEW_SMALL_FONT_PTSIZE * PANGO_SCALE); + + /* String to use in 12-hour time format for times in the morning. */ + week_view->am_string = _("am"); + + /* String to use in 12-hour time format for times in the afternoon. */ + week_view->pm_string = _("pm"); + + week_view->bc_event_time = 0; + week_view->before_click_dtstart = 0; + week_view->before_click_dtend = 0; + + /* + * Titles Canvas. Note that we don't show it is only shown in the + * Month view. + */ + week_view->titles_canvas = e_canvas_new (); + gtk_table_attach (GTK_TABLE (week_view), week_view->titles_canvas, + 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); + + canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->titles_canvas)->root); + + week_view->titles_canvas_item = + gnome_canvas_item_new (canvas_group, + e_week_view_titles_item_get_type (), + "EWeekViewTitlesItem::week_view", week_view, + NULL); + + /* + * Main Canvas + */ + week_view->main_canvas = e_canvas_new (); + gtk_table_attach (GTK_TABLE (week_view), week_view->main_canvas, + 1, 2, 1, 2, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 1, 1); + gtk_widget_show (week_view->main_canvas); + + canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->main_canvas)->root); + + week_view->main_canvas_item = + gnome_canvas_item_new (canvas_group, + e_week_view_main_item_get_type (), + "EWeekViewMainItem::week_view", week_view, + NULL); + + g_signal_connect_after (week_view->main_canvas, "button_press_event", + G_CALLBACK (e_week_view_on_button_press), week_view); + g_signal_connect (week_view->main_canvas, "button_release_event", + G_CALLBACK (e_week_view_on_button_release), week_view); + g_signal_connect (week_view->main_canvas, "scroll_event", + G_CALLBACK (e_week_view_on_scroll), week_view); + g_signal_connect (week_view->main_canvas, "motion_notify_event", + G_CALLBACK (e_week_view_on_motion), week_view); + + /* Create the buttons to jump to each days. */ + pixbuf = gdk_pixbuf_new_from_xpm_data ((const gchar **) jump_xpm); + + for (i = 0; i < E_WEEK_VIEW_MAX_WEEKS * 7; i++) { + week_view->jump_buttons[i] = gnome_canvas_item_new + (canvas_group, + gnome_canvas_pixbuf_get_type (), + "GnomeCanvasPixbuf::pixbuf", pixbuf, + NULL); + + g_signal_connect (week_view->jump_buttons[i], "event", + G_CALLBACK (e_week_view_on_jump_button_event), week_view); + } + week_view->focused_jump_button = E_WEEK_VIEW_JUMP_BUTTON_NO_FOCUS; + + g_object_unref (pixbuf); + + /* + * Scrollbar. + */ + adjustment = gtk_adjustment_new (0, -52, 52, 1, 1, 1); + + week_view->vscrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (adjustment)); + gtk_table_attach (GTK_TABLE (week_view), week_view->vscrollbar, + 2, 3, 1, 2, 0, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_show (week_view->vscrollbar); + + /* Create the cursors. */ + week_view->normal_cursor = gdk_cursor_new (GDK_LEFT_PTR); + week_view->move_cursor = gdk_cursor_new (GDK_FLEUR); + week_view->resize_width_cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW); + week_view->last_cursor_set = NULL; + + /* connect to ECalendarView's signals */ + g_signal_connect (G_OBJECT (week_view), "timezone_changed", + G_CALLBACK (timezone_changed_cb), NULL); +} + +static void time_range_changed_cb (ECalModel *model, time_t start_time, time_t end_time, gpointer user_data) { EWeekView *week_view = E_WEEK_VIEW (user_data); @@ -519,183 +803,6 @@ model_comps_deleted_cb (ETableModel *etm, gpointer data, gpointer user_data) } static void -timezone_changed_cb (ECalendarView *cal_view, icaltimezone *old_zone, - icaltimezone *new_zone, gpointer user_data) -{ - struct icaltimetype tt = icaltime_null_time (); - time_t lower; - EWeekView *week_view = (EWeekView *) cal_view; - - g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - - if (!cal_view->in_focus) - return; - - /* If we don't have a valid date set yet, just return. */ - if (!g_date_valid (&week_view->first_day_shown)) - return; - - /* Recalculate the new start of the first week. We just use exactly - the same time, but with the new timezone. */ - tt.year = g_date_get_year (&week_view->first_day_shown); - tt.month = g_date_get_month (&week_view->first_day_shown); - tt.day = g_date_get_day (&week_view->first_day_shown); - - lower = icaltime_as_timet_with_zone (tt, new_zone); - - e_week_view_recalc_day_starts (week_view, lower); - e_week_view_update_query (week_view); -} - -static void -e_week_view_init (EWeekView *week_view) -{ - GnomeCanvasGroup *canvas_group; - GtkObject *adjustment; - GdkPixbuf *pixbuf; - gint i; - - GTK_WIDGET_SET_FLAGS (week_view, GTK_CAN_FOCUS); - - week_view->query = NULL; - week_view->event_destroyed = FALSE; - week_view->events = g_array_new (FALSE, FALSE, - sizeof (EWeekViewEvent)); - week_view->events_sorted = TRUE; - week_view->events_need_layout = FALSE; - week_view->events_need_reshape = FALSE; - - week_view->layout_timeout_id = 0; - - week_view->spans = NULL; - - week_view->multi_week_view = FALSE; - week_view->month_scroll_by_week = FALSE; - week_view->scroll_by_week_notif_id = 0; - week_view->update_base_date = TRUE; - week_view->weeks_shown = 6; - week_view->rows = 6; - week_view->columns = 2; - week_view->compress_weekend = TRUE; - week_view->show_event_end_times = TRUE; - week_view->week_start_day = 0; /* Monday. */ - week_view->display_start_day = 0; /* Monday. */ - - g_date_clear (&week_view->base_date, 1); - g_date_clear (&week_view->first_day_shown, 1); - - week_view->row_height = 10; - week_view->rows_per_cell = 1; - - week_view->selection_start_day = -1; - week_view->selection_drag_pos = E_WEEK_VIEW_DRAG_NONE; - - week_view->pressed_event_num = -1; - week_view->editing_event_num = -1; - - week_view->last_edited_comp_string = NULL; - - week_view->main_gc = NULL; - - /* Create the small font. */ - week_view->use_small_font = TRUE; - - week_view->small_font_desc = - pango_font_description_copy (gtk_widget_get_style (GTK_WIDGET (week_view))->font_desc); - pango_font_description_set_size (week_view->small_font_desc, - E_WEEK_VIEW_SMALL_FONT_PTSIZE * PANGO_SCALE); - - /* String to use in 12-hour time format for times in the morning. */ - week_view->am_string = _("am"); - - /* String to use in 12-hour time format for times in the afternoon. */ - week_view->pm_string = _("pm"); - - week_view->bc_event_time = 0; - week_view->before_click_dtstart = 0; - week_view->before_click_dtend = 0; - - /* - * Titles Canvas. Note that we don't show it is only shown in the - * Month view. - */ - week_view->titles_canvas = e_canvas_new (); - gtk_table_attach (GTK_TABLE (week_view), week_view->titles_canvas, - 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - - canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->titles_canvas)->root); - - week_view->titles_canvas_item = - gnome_canvas_item_new (canvas_group, - e_week_view_titles_item_get_type (), - "EWeekViewTitlesItem::week_view", week_view, - NULL); - - /* - * Main Canvas - */ - week_view->main_canvas = e_canvas_new (); - gtk_table_attach (GTK_TABLE (week_view), week_view->main_canvas, - 1, 2, 1, 2, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 1, 1); - gtk_widget_show (week_view->main_canvas); - - canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->main_canvas)->root); - - week_view->main_canvas_item = - gnome_canvas_item_new (canvas_group, - e_week_view_main_item_get_type (), - "EWeekViewMainItem::week_view", week_view, - NULL); - - g_signal_connect_after (week_view->main_canvas, "button_press_event", - G_CALLBACK (e_week_view_on_button_press), week_view); - g_signal_connect (week_view->main_canvas, "button_release_event", - G_CALLBACK (e_week_view_on_button_release), week_view); - g_signal_connect (week_view->main_canvas, "scroll_event", - G_CALLBACK (e_week_view_on_scroll), week_view); - g_signal_connect (week_view->main_canvas, "motion_notify_event", - G_CALLBACK (e_week_view_on_motion), week_view); - - /* Create the buttons to jump to each days. */ - pixbuf = gdk_pixbuf_new_from_xpm_data ((const gchar **) jump_xpm); - - for (i = 0; i < E_WEEK_VIEW_MAX_WEEKS * 7; i++) { - week_view->jump_buttons[i] = gnome_canvas_item_new - (canvas_group, - gnome_canvas_pixbuf_get_type (), - "GnomeCanvasPixbuf::pixbuf", pixbuf, - NULL); - - g_signal_connect (week_view->jump_buttons[i], "event", - G_CALLBACK (e_week_view_on_jump_button_event), week_view); - } - week_view->focused_jump_button = E_WEEK_VIEW_JUMP_BUTTON_NO_FOCUS; - - g_object_unref (pixbuf); - - /* - * Scrollbar. - */ - adjustment = gtk_adjustment_new (0, -52, 52, 1, 1, 1); - - week_view->vscrollbar = gtk_vscrollbar_new (GTK_ADJUSTMENT (adjustment)); - gtk_table_attach (GTK_TABLE (week_view), week_view->vscrollbar, - 2, 3, 1, 2, 0, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (week_view->vscrollbar); - - /* Create the cursors. */ - week_view->normal_cursor = gdk_cursor_new (GDK_LEFT_PTR); - week_view->move_cursor = gdk_cursor_new (GDK_FLEUR); - week_view->resize_width_cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW); - week_view->last_cursor_set = NULL; - - /* connect to ECalendarView's signals */ - g_signal_connect (G_OBJECT (week_view), "timezone_changed", - G_CALLBACK (timezone_changed_cb), NULL); -} - -static void init_model (EWeekView *week_view, ECalModel *model) { /* connect to ECalModel's signals */ @@ -1861,7 +1968,7 @@ e_week_view_set_weeks_shown (EWeekView *week_view, } gboolean -e_week_view_get_compress_weekend (EWeekView *week_view) +e_week_view_get_compress_weekend (EWeekView *week_view) { g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE); @@ -1869,17 +1976,17 @@ e_week_view_get_compress_weekend (EWeekView *week_view) } void -e_week_view_set_compress_weekend (EWeekView *week_view, - gboolean compress) +e_week_view_set_compress_weekend (EWeekView *week_view, + gboolean compress_weekend) { gboolean need_reload = FALSE; g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - if (week_view->compress_weekend == compress) + if (week_view->compress_weekend == compress_weekend) return; - week_view->compress_weekend = compress; + week_view->compress_weekend = compress_weekend; /* The option only affects the month view. */ if (!week_view->multi_week_view) @@ -1903,11 +2010,13 @@ e_week_view_set_compress_weekend (EWeekView *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), "compress-weekend"); } /* Whether we display event end times. */ gboolean -e_week_view_get_show_event_end_times (EWeekView *week_view) +e_week_view_get_show_event_end_times (EWeekView *week_view) { g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), TRUE); @@ -1915,22 +2024,25 @@ e_week_view_get_show_event_end_times (EWeekView *week_view) } void -e_week_view_set_show_event_end_times (EWeekView *week_view, - gboolean show) +e_week_view_set_show_event_end_times (EWeekView *week_view, + gboolean show_event_end_times) { g_return_if_fail (E_IS_WEEK_VIEW (week_view)); - if (week_view->show_event_end_times != show) { - week_view->show_event_end_times = show; - e_week_view_recalc_cell_sizes (week_view); - week_view->events_need_reshape = TRUE; - e_week_view_check_layout (week_view); - } + if (week_view->show_event_end_times != show_event_end_times) + return; + + week_view->show_event_end_times = show_event_end_times; + e_week_view_recalc_cell_sizes (week_view); + week_view->events_need_reshape = TRUE; + e_week_view_check_layout (week_view); + + g_object_notify (G_OBJECT (week_view), "show-event-end-times"); } /* The first day of the week, 0 (Monday) to 6 (Sunday). */ gint -e_week_view_get_week_start_day (EWeekView *week_view) +e_week_view_get_week_start_day (EWeekView *week_view) { g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), 0); @@ -1938,8 +2050,8 @@ e_week_view_get_week_start_day (EWeekView *week_view) } void -e_week_view_set_week_start_day (EWeekView *week_view, - gint week_start_day) +e_week_view_set_week_start_day (EWeekView *week_view, + gint week_start_day) { g_return_if_fail (E_IS_WEEK_VIEW (week_view)); g_return_if_fail (week_start_day >= 0); @@ -1959,6 +2071,8 @@ e_week_view_set_week_start_day (EWeekView *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), "week-start-day"); } static gboolean diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h index 0589dee739..ef4a5c008d 100644 --- a/calendar/gui/e-week-view.h +++ b/calendar/gui/e-week-view.h @@ -403,14 +403,14 @@ void e_week_view_set_weeks_shown (EWeekView *week_view, view. In the Week view they are always compressed. */ gboolean e_week_view_get_compress_weekend(EWeekView *week_view); void e_week_view_set_compress_weekend(EWeekView *week_view, - gboolean compress); + gboolean compress_weekend); /* Whether we display event end times. */ gboolean e_week_view_get_show_event_end_times (EWeekView *week_view); void e_week_view_set_show_event_end_times (EWeekView *week_view, - gboolean show); + gboolean show_event_end_times); /* The first day of the week, 0 (Monday) to 6 (Sunday). */ gint e_week_view_get_week_start_day (EWeekView *week_view); diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 8714c01848..6befd21388 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -54,13 +54,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-month-view.h" #include "e-week-view.h" -#include "e-week-view-config.h" #include "e-cal-list-view.h" -#include "e-cal-list-view-config.h" #include "e-mini-calendar-config.h" #include "e-calendar-table-config.h" #include "gnome-cal.h" @@ -116,7 +113,6 @@ 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. */ ECalendarView *views[GNOME_CAL_LAST_VIEW]; - GObject *configs[GNOME_CAL_LAST_VIEW]; GnomeCalendarViewType current_view_type; GList *notifications; @@ -1087,7 +1083,7 @@ update_marcus_bains_line_cb (GnomeCalendar *gcal) view = gnome_calendar_get_calendar_view (gcal, view_type); if (E_IS_DAY_VIEW (view)) - e_day_view_update_marcus_bains (E_DAY_VIEW (view)); + e_day_view_marcus_bains_update (E_DAY_VIEW (view)); time (&now); day_begin = time_day_begin (now); @@ -1316,8 +1312,6 @@ setup_widgets (GnomeCalendar *gcal) e_calendar_view_set_calendar (calendar_view, gcal); e_calendar_view_set_timezone (calendar_view, priv->zone); priv->views[GNOME_CAL_DAY_VIEW] = calendar_view; - priv->configs[GNOME_CAL_DAY_VIEW] = - G_OBJECT (e_day_view_config_new (E_DAY_VIEW (calendar_view))); g_signal_connect ( calendar_view, "selection-changed", @@ -1330,8 +1324,6 @@ setup_widgets (GnomeCalendar *gcal) e_calendar_view_set_calendar (calendar_view, gcal); e_calendar_view_set_timezone (calendar_view, priv->zone); priv->views[GNOME_CAL_WORK_WEEK_VIEW] = calendar_view; - priv->configs[GNOME_CAL_WORK_WEEK_VIEW] = - G_OBJECT (e_day_view_config_new (E_DAY_VIEW (calendar_view))); /* The Marcus Bains line */ priv->update_marcus_bains_line_timeout = g_timeout_add_full (G_PRIORITY_LOW, 60000, (GSourceFunc) update_marcus_bains_line_cb, gcal, NULL); @@ -1341,8 +1333,6 @@ setup_widgets (GnomeCalendar *gcal) e_calendar_view_set_calendar (calendar_view, gcal); e_calendar_view_set_timezone (calendar_view, priv->zone); priv->views[GNOME_CAL_WEEK_VIEW] = calendar_view; - priv->configs[GNOME_CAL_WEEK_VIEW] = - G_OBJECT (e_week_view_config_new (E_WEEK_VIEW (calendar_view))); g_signal_connect ( calendar_view, "selection-changed", @@ -1367,8 +1357,6 @@ setup_widgets (GnomeCalendar *gcal) e_week_view_set_multi_week_view (E_WEEK_VIEW (calendar_view), TRUE); e_week_view_set_weeks_shown (E_WEEK_VIEW (calendar_view), 6); priv->views[GNOME_CAL_MONTH_VIEW] = calendar_view; - priv->configs[GNOME_CAL_MONTH_VIEW] = - G_OBJECT (e_week_view_config_new (E_WEEK_VIEW (calendar_view))); g_signal_connect ( calendar_view, "selection-changed", @@ -1385,8 +1373,6 @@ setup_widgets (GnomeCalendar *gcal) e_calendar_view_set_calendar (calendar_view, gcal); e_calendar_view_set_timezone (calendar_view, priv->zone); priv->views[GNOME_CAL_LIST_VIEW] = calendar_view; - priv->configs[GNOME_CAL_LIST_VIEW] = - G_OBJECT (e_cal_list_view_config_new (E_CAL_LIST_VIEW (calendar_view))); g_signal_connect ( calendar_view, "selection-changed", @@ -1472,11 +1458,6 @@ gnome_calendar_destroy (GtkObject *object) } priv->default_client = NULL; - for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) { - if (priv->configs[i]) - g_object_unref (priv->configs[i]); - priv->configs[i] = NULL; - } g_object_unref (priv->date_navigator_config); for (l = priv->notifications; l; l = l->next) |