aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendar/gui/calendar-component.c3
-rw-r--r--calendar/gui/e-cal-list-view-config.c4
-rw-r--r--calendar/gui/e-cal-list-view.c23
-rw-r--r--calendar/gui/e-cal-list-view.h37
-rw-r--r--calendar/gui/e-cal-model.c19
-rw-r--r--calendar/gui/e-calendar-view.c31
-rw-r--r--calendar/gui/e-calendar-view.h3
-rw-r--r--calendar/gui/e-day-view-config.c4
-rw-r--r--calendar/gui/e-day-view-main-item.c6
-rw-r--r--calendar/gui/e-day-view-time-item.c7
-rw-r--r--calendar/gui/e-day-view-top-item.c7
-rw-r--r--calendar/gui/e-day-view.c25
-rw-r--r--calendar/gui/e-day-view.h28
-rw-r--r--calendar/gui/e-month-view.c2
-rw-r--r--calendar/gui/e-month-view.h2
-rw-r--r--calendar/gui/e-week-view-config.c4
-rw-r--r--calendar/gui/e-week-view-event-item.c5
-rw-r--r--calendar/gui/e-week-view.c21
-rw-r--r--calendar/gui/e-week-view.h4
-rw-r--r--calendar/gui/gnome-cal.c404
-rw-r--r--calendar/gui/gnome-cal.h5
-rw-r--r--modules/calendar/e-cal-shell-content.c33
-rw-r--r--modules/calendar/e-cal-shell-sidebar.c2
23 files changed, 344 insertions, 335 deletions
diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c
index 02bf9a0072..e9629c70ee 100644
--- a/calendar/gui/calendar-component.c
+++ b/calendar/gui/calendar-component.c
@@ -337,8 +337,7 @@ impl_handleURI (PortableServer_Servant servant, const gchar *uri, CORBA_Environm
if (start != -1) {
if (end == -1)
- end = start;
- gnome_calendar_set_selected_time_range (view->calendar, start, end);
+ gnome_calendar_set_selected_time_range (view->calendar, start);
}
if (src_uid && uid)
gnome_calendar_edit_appointment (view->calendar, src_uid, uid, rid);
diff --git a/calendar/gui/e-cal-list-view-config.c b/calendar/gui/e-cal-list-view-config.c
index 543b5e8eb7..047e89261d 100644
--- a/calendar/gui/e-cal-list-view-config.c
+++ b/calendar/gui/e-cal-list-view-config.c
@@ -146,11 +146,13 @@ e_cal_list_view_config_get_view (ECalListViewConfig *view_config)
static void
set_twentyfour_hour (ECalListView *list_view)
{
+ ECalModel *model;
gboolean use_24_hour;
use_24_hour = calendar_config_get_24_hour_format ();
- e_calendar_view_set_use_24_hour_format (E_CALENDAR_VIEW (list_view), use_24_hour);
+ 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
diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c
index 65a8ec5f9d..2bd1311c8e 100644
--- a/calendar/gui/e-cal-list-view.c
+++ b/calendar/gui/e-cal-list-view.c
@@ -291,35 +291,24 @@ setup_e_table (ECalListView *cal_list_view)
gtk_widget_show (GTK_WIDGET (cal_list_view->table_scrolled));
}
-GtkWidget *
-e_cal_list_view_construct (ECalListView *cal_list_view)
-{
- setup_e_table (cal_list_view);
-
- return GTK_WIDGET (cal_list_view);
-}
-
/**
* e_cal_list_view_new:
* @Returns: a new #ECalListView.
*
* Creates a new #ECalListView.
**/
-GtkWidget *
+ECalendarView *
e_cal_list_view_new (ECalModel *model)
{
- ECalListView *cal_list_view;
+ ECalendarView *cal_list_view;
- cal_list_view = g_object_new (e_cal_list_view_get_type (), "model", model, NULL);
- if (!e_cal_list_view_construct (cal_list_view)) {
- g_message (G_STRLOC ": Could not construct the calendar list GUI");
- g_object_unref (cal_list_view);
- return NULL;
- }
+ cal_list_view = g_object_new (
+ E_TYPE_CAL_LIST_VIEW, "model", model, NULL);
+ setup_e_table (E_CAL_LIST_VIEW (cal_list_view));
g_object_unref (model);
- return GTK_WIDGET (cal_list_view);
+ return cal_list_view;
}
static void
diff --git a/calendar/gui/e-cal-list-view.h b/calendar/gui/e-cal-list-view.h
index df5b3dbeab..f4f71a6269 100644
--- a/calendar/gui/e-cal-list-view.h
+++ b/calendar/gui/e-cal-list-view.h
@@ -30,22 +30,36 @@
#include "e-calendar-view.h"
#include "gnome-cal.h"
-G_BEGIN_DECLS
-
/*
* ECalListView - displays calendar events in an ETable.
*/
-#define E_CAL_LIST_VIEW(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_cal_list_view_get_type (), ECalListView)
-#define E_CAL_LIST_VIEW_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_cal_list_view_get_type (), ECalListViewClass)
-#define E_IS_CAL_LIST_VIEW(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_cal_list_view_get_type ())
+/* Standard GObject macros */
+#define E_TYPE_CAL_LIST_VIEW \
+ (e_cal_list_view_get_type ())
+#define E_CAL_LIST_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_CAL_LIST_VIEW, ECalListView))
+#define E_CAL_LIST_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_CAL_LIST_VIEW, ECalListViewClass))
+#define E_IS_CAL_LIST_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_CAL_LIST_VIEW))
+#define E_IS_CAL_LIST_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_CAL_LIST_VIEW))
+#define E_CAL_LIST_VIEW_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_CAL_LIST_VIEW, ECalListViewClass))
+
+G_BEGIN_DECLS
typedef struct _ECalListView ECalListView;
typedef struct _ECalListViewClass ECalListViewClass;
-struct _ECalListView
-{
- ECalendarView cal_view;
+struct _ECalListView {
+ ECalendarView parent;
/* The main display table */
ETableScrolled *table_scrolled;
@@ -66,15 +80,12 @@ struct _ECalListView
gint set_table_id;
};
-struct _ECalListViewClass
-{
+struct _ECalListViewClass {
ECalendarViewClass parent_class;
};
GType e_cal_list_view_get_type (void);
-GtkWidget *e_cal_list_view_construct (ECalListView *cal_list_view);
-
-GtkWidget *e_cal_list_view_new (ECalModel *cal_model);
+ECalendarView *e_cal_list_view_new (ECalModel *cal_model);
void e_cal_list_view_load_state (ECalListView *cal_list_view, gchar *filename);
void e_cal_list_view_save_state (ECalListView *cal_list_view, gchar *filename);
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index 0ddcc20d07..747635998e 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -1245,16 +1245,21 @@ e_cal_model_get_use_24_hour_format (ECalModel *model)
* e_cal_model_set_use_24_hour_format
*/
void
-e_cal_model_set_use_24_hour_format (ECalModel *model, gboolean use24)
+e_cal_model_set_use_24_hour_format (ECalModel *model,
+ gboolean use_24_hour_format)
{
g_return_if_fail (E_IS_CAL_MODEL (model));
- if (model->priv->use_24_hour_format != use24) {
- e_table_model_pre_change (E_TABLE_MODEL (model));
- model->priv->use_24_hour_format = use24;
- /* Get the views to redraw themselves. */
- e_table_model_changed (E_TABLE_MODEL (model));
- }
+ if (model->priv->use_24_hour_format == use_24_hour_format)
+ return;
+
+ e_table_model_pre_change (E_TABLE_MODEL (model));
+ model->priv->use_24_hour_format = use_24_hour_format;
+
+ /* Get the views to redraw themselves. */
+ e_table_model_changed (E_TABLE_MODEL (model));
+
+ g_object_notify (G_OBJECT (model), "use-24-hour-format");
}
/**
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index 9897354e5a..a9b717f0eb 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -500,37 +500,6 @@ e_calendar_view_set_default_category (ECalendarView *cal_view, const gchar *cate
cal_view->priv->default_category = g_strdup (category);
}
-/**
- * e_calendar_view_get_use_24_hour_format:
- * @cal_view: A calendar view.
- *
- * Gets whether the view is using 24 hour times or not.
- *
- * Returns: the 24 hour setting.
- */
-gboolean
-e_calendar_view_get_use_24_hour_format (ECalendarView *cal_view)
-{
- g_return_val_if_fail (E_IS_CALENDAR_VIEW (cal_view), FALSE);
-
- return e_cal_model_get_use_24_hour_format (cal_view->priv->model);
-}
-
-/**
- * e_calendar_view_set_use_24_hour_format
- * @cal_view: A calendar view.
- * @use_24_hour: Whether to use 24 hour times or not.
- *
- * Sets the 12/24 hour times setting for the given view.
- */
-void
-e_calendar_view_set_use_24_hour_format (ECalendarView *cal_view, gboolean use_24_hour)
-{
- g_return_if_fail (E_IS_CALENDAR_VIEW (cal_view));
-
- e_cal_model_set_use_24_hour_format (cal_view->priv->model, use_24_hour);
-}
-
GList *
e_calendar_view_get_selected_events (ECalendarView *cal_view)
{
diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h
index 5f554720f8..84d3d3c65f 100644
--- a/calendar/gui/e-calendar-view.h
+++ b/calendar/gui/e-calendar-view.h
@@ -135,9 +135,6 @@ icaltimezone *e_calendar_view_get_timezone (ECalendarView *cal_view);
void e_calendar_view_set_timezone (ECalendarView *cal_view, icaltimezone *zone);
const gchar *e_calendar_view_get_default_category (ECalendarView *cal_view);
void e_calendar_view_set_default_category (ECalendarView *cal_view, const gchar *category);
-gboolean e_calendar_view_get_use_24_hour_format (ECalendarView *view);
-void e_calendar_view_set_use_24_hour_format (ECalendarView *view, gboolean use_24_hour);
-
void e_calendar_view_set_status_message (ECalendarView *cal_view, const gchar *message, gint percent);
GList *e_calendar_view_get_selected_events (ECalendarView *cal_view);
diff --git a/calendar/gui/e-day-view-config.c b/calendar/gui/e-day-view-config.c
index a193e7bfa0..b9eff43bcd 100644
--- a/calendar/gui/e-day-view-config.c
+++ b/calendar/gui/e-day-view-config.c
@@ -170,11 +170,13 @@ week_start_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointe
static void
set_twentyfour_hour (EDayView *day_view)
{
+ ECalModel *model;
gboolean use_24_hour;
use_24_hour = calendar_config_get_24_hour_format ();
- e_calendar_view_set_use_24_hour_format (E_CALENDAR_VIEW (day_view), use_24_hour);
+ 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);
diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c
index b55dba425c..9f63d25b93 100644
--- a/calendar/gui/e-day-view-main-item.c
+++ b/calendar/gui/e-day-view-main-item.c
@@ -602,6 +602,7 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
{
EDayView *day_view;
EDayViewEvent *event;
+ ECalModel *model;
gint item_x, item_y, item_w, item_h, bar_y1, bar_y2;
GdkGC *gc;
GdkColor bg_color;
@@ -637,6 +638,7 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
GConfClient *gconf;
day_view = dvmitem->day_view;
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
cr = gdk_cairo_create (drawable);
gdk_cairo_set_source_color (cr,
@@ -976,7 +978,7 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
cairo_clip (cr);
cairo_new_path (cr);
- if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) {
+ if (e_cal_model_get_use_24_hour_format (model)) {
cairo_translate (cr, item_x + item_w - E_DAY_VIEW_BAR_WIDTH - 32, item_y + item_h - 8);
end_regsizeime = g_strdup_printf ("%2i:%02i",
end_display_hour, end_minute);
@@ -1253,7 +1255,7 @@ e_day_view_main_item_draw_day_event (EDayViewMainItem *dvmitem,
&end_suffix,
&end_suffix_width);
- if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) {
+ if (e_cal_model_get_use_24_hour_format (model)) {
if (day_view->show_event_end_times && show_span) {
/* 24 hour format with end time. */
text = g_strdup_printf
diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c
index 2c17e4e7d1..6d5f80062a 100644
--- a/calendar/gui/e-day-view-time-item.c
+++ b/calendar/gui/e-day-view-time-item.c
@@ -279,6 +279,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item,
{
EDayView *day_view;
EDayViewTimeItem *dvtmitem;
+ ECalModel *model;
GtkStyle *style;
const gchar *suffix;
gchar buffer[64], *midnight_day = NULL, *midnight_month = NULL;
@@ -302,6 +303,8 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item,
day_view = dvtmitem->day_view;
g_return_if_fail (day_view != NULL);
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
+
style = gtk_widget_get_style (GTK_WIDGET (day_view));
small_font_desc = style->font_desc;
@@ -485,7 +488,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item,
strcpy (buffer, midnight_day);
strcat (buffer, " ");
strcat (buffer, midnight_month);
- } else if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) {
+ } else if (e_cal_model_get_use_24_hour_format (model)) {
g_snprintf (buffer, sizeof (buffer), "%i:%02i",
display_hour, minute);
} else {
@@ -565,7 +568,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item,
if (show_midnight_date)
strcpy (buffer, midnight_month);
else if (minute == 0
- && !e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) {
+ && !e_cal_model_get_use_24_hour_format (model)) {
strcpy (buffer, suffix);
} else {
g_snprintf (buffer, sizeof (buffer),
diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c
index 09ed59e6e4..dd497e0f7b 100644
--- a/calendar/gui/e-day-view-top-item.c
+++ b/calendar/gui/e-day-view-top-item.c
@@ -369,6 +369,7 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
gint start_day, end_day;
gint item_x, item_y, item_w, item_h;
gint text_x, icon_x, icon_y, icon_x_inc;
+ ECalModel *model;
ECalComponent *comp;
gchar buffer[16];
gint hour, display_hour, minute, offset, time_width, time_x;
@@ -389,6 +390,8 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
gdouble x0, y0, rect_height, rect_width, radius;
day_view = dvtitem->day_view;
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
+
cr = gdk_cairo_create (drawable);
gconf_client = gconf_client_get_default ();
@@ -568,7 +571,7 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
e_day_view_convert_time_to_display (day_view, hour,
&display_hour,
&suffix, &suffix_width);
- if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) {
+ if (e_cal_model_get_use_24_hour_format (model)) {
g_snprintf (buffer, sizeof (buffer), "%i:%02i",
display_hour, minute);
} else {
@@ -617,7 +620,7 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
&display_hour,
&suffix,
&suffix_width);
- if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) {
+ if (e_cal_model_get_use_24_hour_format (model)) {
g_snprintf (buffer, sizeof (buffer),
"%i:%02i", display_hour, minute);
} else {
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 56233da889..42fe3f47a0 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -1059,16 +1059,16 @@ e_day_view_on_canvas_realized (GtkWidget *widget,
*
* Creates a new #EDayView.
**/
-GtkWidget *
+ECalendarView *
e_day_view_new (ECalModel *model)
{
- GObject *day_view;
+ ECalendarView *day_view;
- day_view = g_object_new (e_day_view_get_type (), NULL);
- e_calendar_view_set_model ((ECalendarView *)day_view, model);
- init_model ((EDayView *) day_view, model);
+ day_view = g_object_new (E_TYPE_DAY_VIEW, NULL);
+ e_calendar_view_set_model (day_view, model);
+ init_model (E_DAY_VIEW (day_view), model);
- return GTK_WIDGET (day_view);
+ return day_view;
}
static void
@@ -3513,8 +3513,7 @@ e_day_view_update_calendar_selection_time (EDayView *day_view)
#if 0
calendar = e_calendar_view_get_calendar (E_CALENDAR_VIEW (day_view));
if (calendar)
- gnome_calendar_set_selected_time_range (calendar,
- start, end);
+ gnome_calendar_set_selected_time_range (calendar, start);
#endif
}
@@ -7771,10 +7770,14 @@ e_day_view_convert_time_to_display (EDayView *day_view,
const gchar **suffix,
gint *suffix_width)
{
+ ECalModel *model;
+
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
+
/* Calculate the actual hour number to display. For 12-hour
format we convert 0-23 to 12-11am/12-11pm. */
*display_hour = hour;
- if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view))) {
+ if (e_cal_model_get_use_24_hour_format (model)) {
*suffix = "";
*suffix_width = 0;
} else {
@@ -7796,11 +7799,13 @@ e_day_view_convert_time_to_display (EDayView *day_view,
gint
e_day_view_get_time_string_width (EDayView *day_view)
{
+ ECalModel *model;
gint time_width;
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
time_width = day_view->digit_width * 4 + day_view->colon_width;
- if (!e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (day_view)))
+ if (!e_cal_model_get_use_24_hour_format (model))
time_width += MAX (day_view->am_string_width,
day_view->pm_string_width);
diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h
index d4f1ca680c..663252b7ba 100644
--- a/calendar/gui/e-day-view.h
+++ b/calendar/gui/e-day-view.h
@@ -182,16 +182,30 @@ struct _EDayViewEvent {
guint8 num_columns;
};
-#define E_DAY_VIEW(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_day_view_get_type (), EDayView)
-#define E_DAY_VIEW_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_day_view_get_type (), EDayViewClass)
-#define E_IS_DAY_VIEW(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_day_view_get_type ())
+/* Standard GObject macros */
+#define E_TYPE_DAY_VIEW \
+ (e_day_view_get_type ())
+#define E_DAY_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_DAY_VIEW, EDayView))
+#define E_DAY_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_DAY_VIEW, EDayViewClass))
+#define E_IS_DAY_VIEW(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_DAY_VIEW))
+#define E_IS_DAY_VIEW_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_DAY_VIEW))
+#define E_DAY_VIEW_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_DAY_VIEW, EDayViewClass))
typedef struct _EDayView EDayView;
typedef struct _EDayViewClass EDayViewClass;
-struct _EDayView
-{
- ECalendarView cal_view;
+struct _EDayView {
+ ECalendarView parent;
/* The top canvas where the dates are shown. */
GtkWidget *top_dates_canvas;
@@ -483,7 +497,7 @@ struct _EDayViewClass
};
GType e_day_view_get_type (void);
-GtkWidget* e_day_view_new (ECalModel *model);
+ECalendarView * e_day_view_new (ECalModel *model);
/* Whether we are displaying a work-week, in which case the display always
starts on the first day of the working week. */
diff --git a/calendar/gui/e-month-view.c b/calendar/gui/e-month-view.c
index 6f00e1d233..33e6058f9c 100644
--- a/calendar/gui/e-month-view.c
+++ b/calendar/gui/e-month-view.c
@@ -202,7 +202,7 @@ e_month_view_get_type (void)
return type;
}
-GtkWidget *
+ECalendarView *
e_month_view_new (ECalModel *model)
{
g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
diff --git a/calendar/gui/e-month-view.h b/calendar/gui/e-month-view.h
index c68346b3e2..0ff91a963f 100644
--- a/calendar/gui/e-month-view.h
+++ b/calendar/gui/e-month-view.h
@@ -59,7 +59,7 @@ struct _EMonthViewClass {
};
GType e_month_view_get_type (void);
-GtkWidget * e_month_view_new (ECalModel *model);
+ECalendarView * e_month_view_new (ECalModel *model);
G_END_DECLS
diff --git a/calendar/gui/e-week-view-config.c b/calendar/gui/e-week-view-config.c
index 641857e133..fddc8667c6 100644
--- a/calendar/gui/e-week-view-config.c
+++ b/calendar/gui/e-week-view-config.c
@@ -170,11 +170,13 @@ week_start_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointe
static void
set_twentyfour_hour (EWeekView *week_view)
{
+ ECalModel *model;
gboolean use_24_hour;
use_24_hour = calendar_config_get_24_hour_format ();
- e_calendar_view_set_use_24_hour_format (E_CALENDAR_VIEW (week_view), use_24_hour);
+ 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
diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c
index 66c1bed136..db67562c7c 100644
--- a/calendar/gui/e-week-view-event-item.c
+++ b/calendar/gui/e-week-view-event-item.c
@@ -628,6 +628,7 @@ e_week_view_draw_time (EWeekView *week_view,
gint hour,
gint minute)
{
+ ECalModel *model;
GtkStyle *style;
GdkGC *gc;
gint hour_to_display, suffix_width;
@@ -637,6 +638,8 @@ e_week_view_draw_time (EWeekView *week_view,
PangoLayout *layout;
PangoFontDescription *small_font_desc;
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view));
+
style = gtk_widget_get_style (GTK_WIDGET (week_view));
small_font_desc = week_view->small_font_desc;
gc = week_view->main_gc;
@@ -686,7 +689,7 @@ e_week_view_draw_time (EWeekView *week_view,
time_x += week_view->small_digit_width * 2;
/* Draw the 'am'/'pm' suffix, if 12-hour format. */
- if (!e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (week_view))) {
+ if (!e_cal_model_get_use_24_hour_format (model)) {
pango_layout_set_text (layout, suffix, -1);
gdk_draw_layout (drawable, gc,
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 4c3b940b4f..b671abb6c9 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -718,14 +718,14 @@ init_model (EWeekView *week_view, ECalModel *model)
*
* Creates a new #EWeekView.
**/
-GtkWidget *
+ECalendarView *
e_week_view_new (ECalModel *model)
{
- GtkWidget *week_view;
+ ECalendarView *week_view;
- week_view = GTK_WIDGET (g_object_new (E_TYPE_WEEK_VIEW, NULL));
- e_calendar_view_set_model ((ECalendarView *) week_view, model);
- init_model ((EWeekView *) week_view, model);
+ week_view = g_object_new (E_TYPE_WEEK_VIEW, NULL);
+ e_calendar_view_set_model (week_view, model);
+ init_model (E_WEEK_VIEW (week_view), model);
return week_view;
}
@@ -4285,10 +4285,14 @@ e_week_view_convert_time_to_display (EWeekView *week_view,
const gchar **suffix,
gint *suffix_width)
{
+ ECalModel *model;
+
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view));
+
/* Calculate the actual hour number to display. For 12-hour
format we convert 0-23 to 12-11am/12-11pm. */
*display_hour = hour;
- if (e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (week_view))) {
+ if (e_cal_model_get_use_24_hour_format (model)) {
*suffix = "";
*suffix_width = 0;
} else {
@@ -4310,8 +4314,11 @@ e_week_view_convert_time_to_display (EWeekView *week_view,
gint
e_week_view_get_time_string_width (EWeekView *week_view)
{
+ ECalModel *model;
gint time_width;
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (week_view));
+
if (week_view->use_small_font && week_view->small_font_desc)
time_width = week_view->digit_width * 2
+ week_view->small_digit_width * 2;
@@ -4319,7 +4326,7 @@ e_week_view_get_time_string_width (EWeekView *week_view)
time_width = week_view->digit_width * 4
+ week_view->colon_width;
- if (!e_calendar_view_get_use_24_hour_format (E_CALENDAR_VIEW (week_view)))
+ if (!e_cal_model_get_use_24_hour_format (model))
time_width += MAX (week_view->am_string_width,
week_view->pm_string_width);
diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h
index 10b4c27f49..0589dee739 100644
--- a/calendar/gui/e-week-view.h
+++ b/calendar/gui/e-week-view.h
@@ -170,7 +170,7 @@ typedef struct _EWeekView EWeekView;
typedef struct _EWeekViewClass EWeekViewClass;
struct _EWeekView {
- ECalendarView cal_view;
+ ECalendarView parent;
/* The top canvas where the dates are shown. */
GtkWidget *titles_canvas;
@@ -366,7 +366,7 @@ struct _EWeekViewClass {
};
GType e_week_view_get_type (void);
-GtkWidget * e_week_view_new (ECalModel *model);
+ECalendarView * e_week_view_new (ECalModel *model);
/* The first day shown. Note that it will be rounded down to the start of a
week when set. The returned value will be invalid if no date has been set
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index d249100b71..8714c01848 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -56,6 +56,7 @@
#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"
@@ -96,18 +97,10 @@ struct _GnomeCalendarPrivate {
/* Widgets */
GtkWidget *hpane;
- GtkWidget *notebook;
- GtkWidget *vpane;
ECalendar *date_navigator;
EMiniCalendarConfig *date_navigator_config;
- GtkWidget *day_view;
- GtkWidget *work_week_view;
- GtkWidget *week_view;
- GtkWidget *month_view;
- GtkWidget *list_view;
-
/* plugin menu managers */
ECalMenu *calendar_menu;
@@ -877,18 +870,18 @@ view_selection_changed_cb (GtkWidget *view, GnomeCalendar *gcal)
static void
set_week_start (GnomeCalendar *calendar)
{
- GnomeCalendarPrivate *priv;
+ time_t start_time;
+ gint ii;
- priv = calendar->priv;
-
- priv->week_start = calendar_config_get_week_start_day ();
+ calendar->priv->week_start = calendar_config_get_week_start_day ();
/* Only do this if views exist */
- if (priv->day_view && priv->work_week_view && priv->week_view && priv->month_view && priv->list_view) {
- update_view_times (calendar, priv->base_view_time);
- gnome_calendar_update_date_navigator (calendar);
- gnome_calendar_notify_dates_shown_changed (calendar);
- }
+ for (ii = 0; ii < GNOME_CAL_LAST_VIEW; ii++)
+ if (gnome_calendar_get_calendar_view (calendar, ii) == NULL)
+ return;
+
+ start_time = calendar->priv->base_view_time;
+ gnome_calendar_set_selected_time_range (calendar, start_time);
}
static void
@@ -902,16 +895,16 @@ week_start_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointe
static void
set_working_days (GnomeCalendar *calendar)
{
- GnomeCalendarPrivate *priv;
-
- priv = calendar->priv;
+ time_t start_time;
+ gint ii;
/* Only do this if views exist */
- if (priv->day_view && priv->work_week_view && priv->week_view && priv->month_view && priv->list_view) {
- update_view_times (calendar, priv->base_view_time);
- gnome_calendar_update_date_navigator (calendar);
- gnome_calendar_notify_dates_shown_changed (calendar);
- }
+ for (ii = 0; ii < GNOME_CAL_LAST_VIEW; ii++)
+ if (gnome_calendar_get_calendar_view (calendar, ii) == NULL)
+ return;
+
+ start_time = calendar->priv->base_view_time;
+ gnome_calendar_set_selected_time_range (calendar, start_time);
}
static void
@@ -1196,30 +1189,36 @@ update_adjustment (GnomeCalendar *gcal, GtkAdjustment *adjustment, EWeekView *we
lower = icaltime_as_timet_with_zone (start_tt, gcal->priv->zone);
e_week_view_set_update_base_date (week_view, FALSE);
- update_view_times (gcal, lower);
- gnome_calendar_update_date_navigator (gcal);
- gnome_calendar_notify_dates_shown_changed (gcal);
+ gnome_calendar_set_selected_time_range (gcal, lower);
e_week_view_set_update_base_date (week_view, TRUE);
}
static void
week_view_adjustment_changed_cb (GtkAdjustment *adjustment, GnomeCalendar *gcal)
{
- update_adjustment (gcal, adjustment, E_WEEK_VIEW (gcal->priv->week_view));
+ ECalendarView *view;
+
+ view = gnome_calendar_get_calendar_view (gcal, GNOME_CAL_WEEK_VIEW);
+ update_adjustment (gcal, adjustment, E_WEEK_VIEW (view));
}
static void
month_view_adjustment_changed_cb (GtkAdjustment *adjustment, GnomeCalendar *gcal)
{
- update_adjustment (gcal, adjustment, E_WEEK_VIEW (gcal->priv->month_view));
+ ECalendarView *view;
+
+ view = gnome_calendar_get_calendar_view (gcal, GNOME_CAL_MONTH_VIEW);
+ update_adjustment (gcal, adjustment, E_WEEK_VIEW (view));
}
static void
view_progress_cb (ECalModel *model, const gchar *message, gint percent, ECalSourceType type, GnomeCalendar *gcal)
{
#if 0 /* KILL-BONOBO */
- if (type == E_CAL_SOURCE_TYPE_EVENT)
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (gcal->priv->week_view), message, percent);
+ ECalendarView *view;
+
+ view = gnome_calendar_get_calendar_view (gcal, GNOME_CAL_WEEK_VIEW);
+ e_calendar_view_set_status_message (view, message, percent);
#endif
}
@@ -1227,8 +1226,10 @@ static void
view_done_cb (ECalModel *model, ECalendarStatus status, ECalSourceType type, GnomeCalendar *gcal)
{
#if 0 /* KILL-BONOBO */
- if (type == E_CAL_SOURCE_TYPE_EVENT)
- e_calendar_view_set_status_message (E_CALENDAR_VIEW (gcal->priv->week_view), NULL, -1);
+ ECalendarView *view;
+
+ view = gnome_calendar_get_calendar_view (gcal, GNOME_CAL_WEEK_VIEW);
+ e_calendar_view_set_status_message (view, NULL, -1);
#endif
}
@@ -1238,20 +1239,6 @@ gnome_calendar_get_tag (GnomeCalendar *gcal)
return GTK_WIDGET (gcal->priv->date_navigator);
}
-static time_t
-gc_get_default_time (ECalModel *model, gpointer user_data)
-{
- GnomeCalendar *gcal = user_data;
- time_t res = 0, end;
-
- g_return_val_if_fail (model != NULL, 0);
- g_return_val_if_fail (GNOME_IS_CALENDAR (user_data), 0);
-
- gnome_calendar_get_current_time_range (gcal, &res, &end);
-
- return res;
-}
-
static void
setup_widgets (GnomeCalendar *gcal)
{
@@ -1263,6 +1250,7 @@ setup_widgets (GnomeCalendar *gcal)
ECalModel *w_model;
GtkWidget *vbox;
GtkWidget *label;
+ ECalendarView *calendar_view;
ECalModel *cal_model;
gint i;
gchar *tmp;
@@ -1324,86 +1312,85 @@ setup_widgets (GnomeCalendar *gcal)
e_cal_model_set_flags (cal_model, E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES);
/* The Day View. */
- priv->day_view = e_day_view_new (cal_model);
- e_calendar_view_set_calendar (E_CALENDAR_VIEW (priv->day_view), gcal);
- e_calendar_view_set_timezone (E_CALENDAR_VIEW (priv->day_view), priv->zone);
- g_signal_connect (priv->day_view, "selection_changed",
- G_CALLBACK (view_selection_changed_cb), gcal);
+ calendar_view = e_day_view_new (cal_model);
+ 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",
+ G_CALLBACK (view_selection_changed_cb), gcal);
/* The Work Week View. */
- priv->work_week_view = e_day_view_new (cal_model);
- e_day_view_set_work_week_view (E_DAY_VIEW (priv->work_week_view),
- TRUE);
- e_day_view_set_days_shown (E_DAY_VIEW (priv->work_week_view), 5);
- e_calendar_view_set_calendar (E_CALENDAR_VIEW (priv->work_week_view), gcal);
- e_calendar_view_set_timezone (E_CALENDAR_VIEW (priv->work_week_view), priv->zone);
+ calendar_view = e_day_view_new (cal_model);
+ e_day_view_set_work_week_view (E_DAY_VIEW (calendar_view), TRUE);
+ e_day_view_set_days_shown (E_DAY_VIEW (calendar_view), 5);
+ 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);
/* The Week View. */
- priv->week_view = e_week_view_new (cal_model);
- e_calendar_view_set_calendar (E_CALENDAR_VIEW (priv->week_view), gcal);
- e_calendar_view_set_timezone (E_CALENDAR_VIEW (priv->week_view), priv->zone);
- g_signal_connect (priv->week_view, "selection_changed",
- G_CALLBACK (view_selection_changed_cb), gcal);
-
- adjustment = gtk_range_get_adjustment (GTK_RANGE (E_WEEK_VIEW (priv->week_view)->vscrollbar));
- g_signal_connect (adjustment, "value_changed",
- G_CALLBACK (week_view_adjustment_changed_cb),
- gcal);
- w_model = e_calendar_view_get_model ((ECalendarView *)priv->week_view);
- g_signal_connect (w_model, "cal_view_progress",
- G_CALLBACK (view_progress_cb), gcal);
- g_signal_connect (w_model, "cal_view_done",
- G_CALLBACK (view_done_cb), gcal);
+ calendar_view = e_week_view_new (cal_model);
+ 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",
+ G_CALLBACK (view_selection_changed_cb), gcal);
+
+ adjustment = gtk_range_get_adjustment (
+ GTK_RANGE (E_WEEK_VIEW (calendar_view)->vscrollbar));
+ g_signal_connect (
+ adjustment, "value-changed",
+ G_CALLBACK (week_view_adjustment_changed_cb), gcal);
+ w_model = e_calendar_view_get_model (calendar_view);
+ g_signal_connect (
+ w_model, "cal-view-progress",
+ G_CALLBACK (view_progress_cb), gcal);
+ g_signal_connect (w_model, "cal-view-done",
+ G_CALLBACK (view_done_cb), gcal);
/* The Month View. */
- priv->month_view = e_week_view_new (cal_model);
- e_calendar_view_set_calendar (E_CALENDAR_VIEW (priv->month_view), gcal);
- e_calendar_view_set_timezone (E_CALENDAR_VIEW (priv->month_view), priv->zone);
- e_week_view_set_multi_week_view (E_WEEK_VIEW (priv->month_view), TRUE);
- e_week_view_set_weeks_shown (E_WEEK_VIEW (priv->month_view), 6);
- g_signal_connect (priv->month_view, "selection_changed",
- G_CALLBACK (view_selection_changed_cb), gcal);
-
- adjustment = gtk_range_get_adjustment (GTK_RANGE (E_WEEK_VIEW (priv->month_view)->vscrollbar));
- g_signal_connect (adjustment, "value_changed",
- G_CALLBACK (month_view_adjustment_changed_cb),
- gcal);
+ calendar_view = e_month_view_new (cal_model);
+ e_calendar_view_set_calendar (calendar_view, gcal);
+ e_calendar_view_set_timezone (calendar_view, priv->zone);
+ 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",
+ G_CALLBACK (view_selection_changed_cb), gcal);
+
+ adjustment = gtk_range_get_adjustment (
+ GTK_RANGE (E_WEEK_VIEW (calendar_view)->vscrollbar));
+ g_signal_connect (
+ adjustment, "value-changed",
+ G_CALLBACK (month_view_adjustment_changed_cb), gcal);
/* The List View. */
- priv->list_view = e_cal_list_view_new (cal_model);
-
- e_calendar_view_set_calendar (E_CALENDAR_VIEW (priv->list_view), gcal);
- e_calendar_view_set_timezone (E_CALENDAR_VIEW (priv->list_view), priv->zone);
- g_signal_connect (priv->list_view, "selection_changed",
- G_CALLBACK (view_selection_changed_cb), gcal);
-
- priv->views[GNOME_CAL_DAY_VIEW] = E_CALENDAR_VIEW (priv->day_view);
- priv->configs[GNOME_CAL_DAY_VIEW] = G_OBJECT (e_day_view_config_new (E_DAY_VIEW (priv->views[GNOME_CAL_DAY_VIEW])));
- priv->views[GNOME_CAL_WORK_WEEK_VIEW] = E_CALENDAR_VIEW (priv->work_week_view);
- priv->configs[GNOME_CAL_WORK_WEEK_VIEW] = G_OBJECT (e_day_view_config_new (E_DAY_VIEW (priv->views[GNOME_CAL_WORK_WEEK_VIEW])));
- priv->views[GNOME_CAL_WEEK_VIEW] = E_CALENDAR_VIEW (priv->week_view);
- priv->configs[GNOME_CAL_WEEK_VIEW] = G_OBJECT (e_week_view_config_new (E_WEEK_VIEW (priv->views[GNOME_CAL_WEEK_VIEW])));
- priv->views[GNOME_CAL_MONTH_VIEW] = E_CALENDAR_VIEW (priv->month_view);
- priv->configs[GNOME_CAL_MONTH_VIEW] = G_OBJECT (e_week_view_config_new (E_WEEK_VIEW (priv->views[GNOME_CAL_MONTH_VIEW])));
- priv->views[GNOME_CAL_LIST_VIEW] = E_CALENDAR_VIEW (priv->list_view);
- priv->configs[GNOME_CAL_LIST_VIEW] = G_OBJECT (e_cal_list_view_config_new (E_CAL_LIST_VIEW (priv->views[GNOME_CAL_LIST_VIEW])));
-
- /* Memo view */
- vbox = gtk_vbox_new (FALSE, 0);
- label = gtk_label_new (NULL);
- tmp = g_strdup_printf ("<b> %s </b>", _("Memos"));
- gtk_label_set_markup ((GtkLabel *)label, tmp);
- g_free (tmp);
- gtk_box_pack_start ((GtkBox *)vbox, label, FALSE, TRUE, 0);
- gtk_widget_show (label);
- gtk_widget_show (vbox);
+ calendar_view = e_cal_list_view_new (cal_model);
+ 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)));
-#if 0 /* KILL-BONOBO */
- e_cal_model_set_default_time_func (e_memo_table_get_model (E_MEMO_TABLE (priv->memo)), gc_get_default_time, gcal);
-#endif
+ g_signal_connect (
+ calendar_view, "selection-changed",
+ G_CALLBACK (view_selection_changed_cb), gcal);
update_memo_view (gcal);
}
@@ -1453,6 +1440,7 @@ gnome_calendar_destroy (GtkObject *object)
GnomeCalendarPrivate *priv;
gchar *filename;
ECalModel *cal_model;
+ ECalendarView *view;
g_return_if_fail (object != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (object));
@@ -1533,11 +1521,13 @@ gnome_calendar_destroy (GtkObject *object)
}
/* Disconnect all handlers */
- cal_model = e_calendar_view_get_model ((ECalendarView *)priv->week_view);
- g_signal_handlers_disconnect_by_func (cal_model,
- G_CALLBACK (view_progress_cb), gcal);
- g_signal_handlers_disconnect_by_func (cal_model,
- G_CALLBACK (view_done_cb), gcal);
+ view = gnome_calendar_get_calendar_view (
+ gcal, GNOME_CAL_WEEK_VIEW);
+ cal_model = e_calendar_view_get_model (view);
+ g_signal_handlers_disconnect_by_func (
+ cal_model, view_progress_cb, gcal);
+ g_signal_handlers_disconnect_by_func (
+ cal_model, view_done_cb, gcal);
g_mutex_free (priv->todo_update_lock);
@@ -1623,9 +1613,7 @@ gnome_calendar_goto_date (GnomeCalendar *gcal,
}
if (need_updating) {
- update_view_times (gcal, new_time);
- gnome_calendar_update_date_navigator (gcal);
- gnome_calendar_notify_dates_shown_changed (gcal);
+ gnome_calendar_set_selected_time_range (gcal, new_time);
notify_selected_time_changed (gcal);
}
}
@@ -1642,9 +1630,7 @@ gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time)
priv = gcal->priv;
- update_view_times (gcal, new_time);
- gnome_calendar_update_date_navigator (gcal);
- gnome_calendar_notify_dates_shown_changed (gcal);
+ gnome_calendar_set_selected_time_range (gcal, new_time);
for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) {
if (E_CALENDAR_VIEW_CLASS (G_OBJECT_GET_CLASS (priv->views[i]))->set_selected_time_range)
@@ -1700,9 +1686,7 @@ gnome_calendar_direction (GnomeCalendar *gcal, gint direction)
g_return_if_reached ();
}
- update_view_times (gcal, priv->base_view_time);
- gnome_calendar_update_date_navigator (gcal);
- gnome_calendar_notify_dates_shown_changed (gcal);
+ gnome_calendar_set_selected_time_range (gcal, priv->base_view_time);
}
void
@@ -1739,26 +1723,19 @@ gnome_calendar_dayjump (GnomeCalendar *gcal, time_t time)
gnome_calendar_set_view (gcal, GNOME_CAL_DAY_VIEW);
}
-static void
-focus_current_view (GnomeCalendar *gcal)
+void
+gnome_calendar_goto_today (GnomeCalendar *gcal)
{
GnomeCalendarViewType view_type;
ECalendarView *view;
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
+
view_type = gnome_calendar_get_view (gcal);
view = gnome_calendar_get_calendar_view (gcal, view_type);
- gtk_widget_grab_focus (GTK_WIDGET (view));
-}
-
-void
-gnome_calendar_goto_today (GnomeCalendar *gcal)
-{
- g_return_if_fail (gcal != NULL);
- g_return_if_fail (GNOME_IS_CALENDAR (gcal));
-
gnome_calendar_goto (gcal, time (NULL));
- focus_current_view (gcal);
+ gtk_widget_grab_focus (GTK_WIDGET (view));
}
/**
@@ -1781,9 +1758,9 @@ static void
set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, gboolean range_selected)
{
GnomeCalendarPrivate *priv;
+ ECalendarView *view;
const gchar *view_id;
- g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
priv = gcal->priv;
@@ -1816,7 +1793,8 @@ set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, gboolean range_s
priv->range_selected = range_selected;
priv->current_view_type = view_type;
- focus_current_view (gcal);
+ view = gnome_calendar_get_calendar_view (gcal, view_type);
+ gtk_widget_grab_focus (GTK_WIDGET (view));
}
/**
@@ -1831,32 +1809,66 @@ set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, gboolean range_s
void
gnome_calendar_set_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type)
{
- g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
set_view (gcal, view_type, FALSE);
}
-/* Sets the view without changing the selection or updating the date
- * navigator. If a range of dates isn't selected it will also reset the number
- * of days/weeks shown to the default (i.e. 1 day for the day view or 5 weeks
- * for the month view).
- */
static void
-display_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, gboolean grab_focus)
+gnome_calendar_change_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type)
+{
+ if (gnome_calendar_get_view(gcal) == view_type)
+ return;
+
+ gnome_calendar_set_view(gcal, view_type);
+}
+
+/* Callback used when the view collection asks us to display a particular view */
+#if 0 /* KILL-BONOBO */
+static void
+display_view_cb (GalViewInstance *view_instance, GalView *view, gpointer data)
{
+ GnomeCalendar *gcal;
GnomeCalendarPrivate *priv;
+ CalendarView *cal_view;
+ GnomeCalendarViewType view_type;
+ ECalendarView *view;
gboolean preserve_day;
- gint i;
+ time_t start_time;
+ gint ii;
+ gcal = GNOME_CALENDAR (data);
priv = gcal->priv;
+ if (GAL_IS_VIEW_ETABLE(view)) {
+ ETable *table;
+
+ view_type = GNOME_CAL_LIST_VIEW;
+
+ table = e_table_scrolled_get_table (E_CAL_LIST_VIEW (priv->list_view)->table_scrolled);
+ gal_view_etable_attach_table (GAL_VIEW_ETABLE (view), table);
+ } else if (IS_CALENDAR_VIEW (view)) {
+ cal_view = CALENDAR_VIEW (view);
+
+ view_type = calendar_view_get_view_type (cal_view);
+ } else {
+ g_error (G_STRLOC ": Unknown type of view for GnomeCalendar");
+ return;
+ }
+
+ view = gnome_calendar_get_calendar_view (gcal, view_type);
+
+ /* Set the view without changing the selection or updating the date
+ * navigator. If a range of dates isn't selected, also reset the
+ * number of days/weeks shown to the default (i.e. 1 day for the
+ * day view or 6 weeks for the month view). */
+
preserve_day = FALSE;
switch (view_type) {
case GNOME_CAL_DAY_VIEW:
if (!priv->range_selected)
- e_day_view_set_days_shown (E_DAY_VIEW (priv->day_view), 1);
+ e_day_view_set_days_shown (E_DAY_VIEW (view), 1);
gtk_widget_show (GTK_WIDGET (gcal->priv->date_navigator));
break;
@@ -1873,7 +1885,7 @@ display_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, gboolean gra
case GNOME_CAL_MONTH_VIEW:
if (!priv->range_selected)
- e_week_view_set_weeks_shown (E_WEEK_VIEW (priv->month_view), 6);
+ e_week_view_set_weeks_shown (E_WEEK_VIEW (view), 6);
preserve_day = TRUE;
gtk_widget_show (GTK_WIDGET (gcal->priv->date_navigator));
@@ -1893,17 +1905,13 @@ display_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, gboolean gra
priv->current_view_type = view_type;
E_CALENDAR_VIEW (priv->views [view_type])->in_focus = TRUE;
- gtk_notebook_set_current_page (
- GTK_NOTEBOOK (priv->notebook), (gint) view_type);
-
for (i = 0; i < GNOME_CAL_LAST_VIEW; i++) {
if (i == view_type)
continue;
E_CALENDAR_VIEW (priv->views [i])->in_focus = FALSE;
}
- if (grab_focus)
- focus_current_view (gcal);
+ gtk_widget_grab_focus (GTK_WIDGET (view));
/* For the week & month views we want the selection in the date
navigator to be rounded to the nearest week when the arrow buttons
@@ -1911,54 +1919,13 @@ display_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type, gboolean gra
g_object_set (G_OBJECT (priv->date_navigator->calitem),
"preserve_day_when_moving", preserve_day,
NULL);
-}
-
-static void gnome_calendar_change_view (GnomeCalendar *gcal, GnomeCalendarViewType view_type)
-{
- if (gnome_calendar_get_view(gcal) == view_type)
- return;
-
- gnome_calendar_set_view(gcal, view_type);
-}
-
-/* Callback used when the view collection asks us to display a particular view */
-#if 0 /* KILL-BONOBO */
-static void
-display_view_cb (GalViewInstance *view_instance, GalView *view, gpointer data)
-{
- GnomeCalendar *gcal;
- GnomeCalendarPrivate *priv;
- CalendarView *cal_view;
- GnomeCalendarViewType view_type;
-
- gcal = GNOME_CALENDAR (data);
- priv = gcal->priv;
-
- if (GAL_IS_VIEW_ETABLE(view)) {
- ETable *table;
-
- view_type = GNOME_CAL_LIST_VIEW;
-
- table = e_table_scrolled_get_table (E_CAL_LIST_VIEW (priv->list_view)->table_scrolled);
- gal_view_etable_attach_table (GAL_VIEW_ETABLE (view), table);
- } else if (IS_CALENDAR_VIEW (view)) {
- cal_view = CALENDAR_VIEW (view);
-
- view_type = calendar_view_get_view_type (cal_view);
- } else {
- g_error (G_STRLOC ": Unknown type of view for GnomeCalendar");
- return;
- }
-
- display_view (gcal, view_type, TRUE);
if (!priv->base_view_time)
- update_view_times (gcal, time (NULL));
+ start_time = time (NULL);
else
- update_view_times (gcal, priv->base_view_time);
+ start_time = priv->base_view_time;
- gnome_calendar_update_date_navigator (gcal);
- gnome_calendar_notify_dates_shown_changed (gcal);
+ gnome_calendar_set_selected_time_range (gcal, start_time);
}
#endif
@@ -2485,8 +2452,7 @@ gnome_calendar_set_default_source (GnomeCalendar *gcal, ESource *source)
void
gnome_calendar_set_selected_time_range (GnomeCalendar *gcal,
- time_t start_time,
- time_t end_time)
+ time_t start_time)
{
update_view_times (gcal, start_time);
gnome_calendar_update_date_navigator (gcal);
@@ -2506,15 +2472,16 @@ gnome_calendar_get_selected_time_range (GnomeCalendar *gcal,
time_t *start_time,
time_t *end_time)
{
- GnomeCalendarPrivate *priv;
+ GnomeCalendarViewType view_type;
+ ECalendarView *view;
ECalModel *model;
- g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- priv = gcal->priv;
+ view_type = gnome_calendar_get_view (gcal);
+ view = gnome_calendar_get_calendar_view (gcal, view_type);
+ model = e_calendar_view_get_model (view);
- model = e_calendar_view_get_model (priv->views[priv->current_view_type]);
e_cal_model_get_time_range (model, start_time, end_time);
}
@@ -2658,6 +2625,7 @@ gnome_calendar_on_date_navigator_selection_changed (ECalendarItem *calitem, Gnom
{
GnomeCalendarPrivate *priv;
GnomeCalendarViewType view_type;
+ ECalendarView *view;
ECalModel *model;
GDate start_date, end_date, new_start_date, new_end_date;
gint new_days_shown;
@@ -2713,15 +2681,19 @@ gnome_calendar_on_date_navigator_selection_changed (ECalendarItem *calitem, Gnom
priv->range_selected = TRUE;
if (priv->current_view_type != GNOME_CAL_LIST_VIEW) {
- e_week_view_set_weeks_shown (E_WEEK_VIEW (priv->month_view),
- (new_days_shown + 6) / 7);
+ view = gnome_calendar_get_calendar_view (
+ gcal, GNOME_CAL_MONTH_VIEW);
+ e_week_view_set_weeks_shown (
+ E_WEEK_VIEW (view), (new_days_shown + 6) / 7);
view_type = GNOME_CAL_MONTH_VIEW;
} else
view_type = GNOME_CAL_LIST_VIEW;
} else if (new_days_shown == 7 && starts_on_week_start_day) {
view_type = GNOME_CAL_WEEK_VIEW;
} else {
- e_day_view_set_days_shown (E_DAY_VIEW (priv->day_view), new_days_shown);
+ view = gnome_calendar_get_calendar_view (
+ gcal, GNOME_CAL_DAY_VIEW);
+ e_day_view_set_days_shown (E_DAY_VIEW (view), new_days_shown);
if (new_days_shown == 5 && starts_on_week_start_day
&& priv->current_view_type == GNOME_CAL_WORK_WEEK_VIEW)
@@ -2787,6 +2759,7 @@ static gboolean
gnome_calendar_hpane_resized (GtkWidget *w, GdkEventButton *e, GnomeCalendar *gcal)
{
GnomeCalendarPrivate *priv;
+ ECalendarView *view;
gint times_width;
priv = gcal->priv;
@@ -2800,12 +2773,13 @@ gnome_calendar_hpane_resized (GtkWidget *w, GdkEventButton *e, GnomeCalendar *gc
}
/* adjust the size of the EDayView's time column */
+ view = gnome_calendar_get_calendar_view (gcal, GNOME_CAL_DAY_VIEW);
times_width = e_day_view_time_item_get_column_width (
- E_DAY_VIEW_TIME_ITEM (E_DAY_VIEW (priv->day_view)->time_canvas_item));
+ E_DAY_VIEW_TIME_ITEM (E_DAY_VIEW (view)->time_canvas_item));
if (times_width < priv->hpane_pos - 20)
- gtk_widget_set_size_request (E_DAY_VIEW (priv->day_view)->time_canvas, times_width, -1);
+ gtk_widget_set_size_request (E_DAY_VIEW (view)->time_canvas, times_width, -1);
else
- gtk_widget_set_size_request (E_DAY_VIEW (priv->day_view)->time_canvas, priv->hpane_pos - 20, -1);
+ gtk_widget_set_size_request (E_DAY_VIEW (view)->time_canvas, priv->hpane_pos - 20, -1);
return FALSE;
}
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index 2560a04215..f5e4534a75 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -139,8 +139,7 @@ GtkWidget *gnome_calendar_get_tag (GnomeCalendar *gcal);
ECalMenu *gnome_calendar_get_calendar_menu (GnomeCalendar *gcal);
void gnome_calendar_set_selected_time_range (GnomeCalendar *gcal,
- time_t start_time,
- time_t end_time);
+ time_t start_time);
void gnome_calendar_get_selected_time_range (GnomeCalendar *gcal,
time_t *start_time,
time_t *end_time);
@@ -176,8 +175,6 @@ void gnome_calendar_delete_selected_occurrence (GnomeCalendar *gcal);
void gnome_calendar_purge (GnomeCalendar *gcal,
time_t older_than);
-
-
/* Direct calendar component operations */
void gnome_calendar_edit_appointment (GnomeCalendar *gcal,
const gchar * src_uid,
diff --git a/modules/calendar/e-cal-shell-content.c b/modules/calendar/e-cal-shell-content.c
index 0f888c13e9..1a55c74d35 100644
--- a/modules/calendar/e-cal-shell-content.c
+++ b/modules/calendar/e-cal-shell-content.c
@@ -27,13 +27,13 @@
#include "e-util/gconf-bridge.h"
#include "calendar/gui/calendar-config.h"
-#include "calendar/gui/e-cal-list-view-config.h"
+#include "calendar/gui/calendar-view.h"
+#include "calendar/gui/e-cal-list-view.h"
#include "calendar/gui/e-cal-model-calendar.h"
#include "calendar/gui/e-calendar-table.h"
#include "calendar/gui/e-calendar-table-config.h"
-#include "calendar/gui/e-day-view-config.h"
+#include "calendar/gui/e-calendar-view.h"
#include "calendar/gui/e-memo-table-config.h"
-#include "calendar/gui/e-week-view-config.h"
#include "widgets/menus/gal-view-etable.h"
@@ -77,7 +77,32 @@ static void
cal_shell_content_display_view_cb (ECalShellContent *cal_shell_content,
GalView *gal_view)
{
- /* FIXME */
+ GnomeCalendar *calendar;
+ CalendarView *gal_calendar_view;
+ GnomeCalendarViewType view_type;
+
+ /* XXX This is confusing: we have CalendarView and ECalendarView.
+ * ECalendarView is an abstract base class for calendar view
+ * widgets (day view, week view, etc). CalendarView is a
+ * simple GalView subclass that represents a calendar view. */
+
+ calendar = e_cal_shell_content_get_calendar (cal_shell_content);
+
+ if (GAL_IS_VIEW_ETABLE (gal_view)) {
+ ECalendarView *calendar_view;
+ ETable *table;
+
+ view_type = GNOME_CAL_LIST_VIEW;
+ calendar_view = gnome_calendar_get_calendar_view (
+ calendar, view_type);
+ table = e_table_scrolled_get_table (
+ E_CAL_LIST_VIEW (calendar_view)->table_scrolled);
+ gal_view_etable_attach_table (
+ GAL_VIEW_ETABLE (gal_view), table);
+ } else {
+ view_type = calendar_view_get_view_type (
+ CALENDAR_VIEW (gal_view));
+ }
}
static void
diff --git a/modules/calendar/e-cal-shell-sidebar.c b/modules/calendar/e-cal-shell-sidebar.c
index dc7df596d6..dc618e2dda 100644
--- a/modules/calendar/e-cal-shell-sidebar.c
+++ b/modules/calendar/e-cal-shell-sidebar.c
@@ -349,7 +349,7 @@ cal_shell_sidebar_dispose (GObject *object)
if (priv->mini_calendar_config != NULL) {
g_object_unref (priv->mini_calendar_config);
- priv->mini_calendar = NULL;
+ priv->mini_calendar_config = NULL;
}
/* Chain up to parent's dispose() method. */