aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-day-view.c
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui/e-day-view.c')
-rw-r--r--calendar/gui/e-day-view.c683
1 files changed, 515 insertions, 168 deletions
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index ed83c9d855..cb69eecf50 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -35,9 +35,10 @@
#include <misc/e-canvas-utils.h>
#include <misc/e-popup-menu.h>
#include <misc/e-gui-utils.h>
-#include <misc/e-unicode.h>
+#include <e-util/e-unicode.h>
#include <libgnomecanvas/gnome-canvas-rect-ellipse.h>
#include <glib/gi18n.h>
+#include <e-util/e-binding.h>
#include <e-util/e-categories-config.h>
#include <e-util/e-dialog-utils.h>
@@ -51,7 +52,6 @@
#include "print.h"
#include "comp-util.h"
#include "itip-utils.h"
-#include "calendar-commands.h"
#include "calendar-config.h"
#include "goto.h"
#include "e-cal-model-calendar.h"
@@ -261,7 +261,7 @@ static void e_day_view_on_event_right_click (EDayView *day_view,
gint day,
gint event_num);
static void e_day_view_show_popup_menu (EDayView *day_view,
- GdkEvent *gdk_event,
+ GdkEventButton *event,
gint day,
gint event_num);
@@ -432,38 +432,364 @@ 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_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
-e_day_view_class_init (EDayViewClass *class)
+day_view_notify_week_start_day_cb (EDayView *day_view)
{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- ECalendarViewClass *view_class;
+ /* XXX Write a EWorkWeekView subclass, like EMonthView. */
+
+ if (day_view->work_week_view)
+ e_day_view_recalc_work_week (day_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_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_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
+day_view_constructed (GObject *object)
+{
+ ECalModel *model;
+ EDayView *day_view;
+ EShellSettings *shell_settings;
+
+ day_view = E_DAY_VIEW (object);
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
+ shell_settings = e_cal_model_get_shell_settings (model);
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-day-view-show-week-numbers",
+ G_OBJECT (day_view->week_number_label), "visible");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-marcus-bains-show-line",
+ G_OBJECT (day_view), "marcus-bains-show-line");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-marcus-bains-day-view-color",
+ G_OBJECT (day_view), "marcus-bains-day-view-color");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-marcus-bains-time-bar-color",
+ G_OBJECT (day_view), "marcus-bains-time-bar-color");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-time-divisions",
+ G_OBJECT (day_view), "mins-per-row");
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
- view_class = (ECalendarViewClass *) class;
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-work-day-end-hour",
+ G_OBJECT (day_view), "work-day-end-hour");
- /* Method override */
- object_class->destroy = e_day_view_destroy;
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-work-day-end-minute",
+ G_OBJECT (day_view), "work-day-end-minute");
- 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;
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-work-day-start-hour",
+ G_OBJECT (day_view), "work-day-start-hour");
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-work-day-start-minute",
+ G_OBJECT (day_view), "work-day-start-minute");
+
+ e_binding_new (
+ G_OBJECT (shell_settings), "cal-working-days-bitset",
+ G_OBJECT (day_view), "working-days");
+
+ g_signal_connect_swapped (
+ model, "notify::week-start-day",
+ G_CALLBACK (day_view_notify_week_start_day_cb), day_view);
+}
+
+static void
+e_day_view_class_init (EDayViewClass *class)
+{
+ GObjectClass *object_class;
+ GtkObjectClass *gtk_object_class;
+ GtkWidgetClass *widget_class;
+ ECalendarViewClass *view_class;
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = day_view_set_property;
+ object_class->get_property = day_view_get_property;
+ object_class->constructed = day_view_constructed;
+
+ 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_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));
+
/* init the accessibility support for e_day_view */
e_day_view_a11y_init ();
}
@@ -703,12 +1029,6 @@ timezone_changed_cb (ECalendarView *cal_view, icaltimezone *old_zone,
}
static void
-dview_show_week_no_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
-{
- e_day_view_set_show_week_number (data, calendar_config_get_dview_show_week_no ());
-}
-
-static void
e_day_view_init (EDayView *day_view)
{
gint day;
@@ -764,10 +1084,9 @@ e_day_view_init (EDayView *day_view)
day_view->work_day_end_hour = 17;
day_view->work_day_end_minute = 0;
day_view->show_event_end_times = TRUE;
- 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;
@@ -813,9 +1132,6 @@ e_day_view_init (EDayView *day_view)
day_view->week_number_label = gtk_label_new ("");
gtk_table_attach (GTK_TABLE (day_view), day_view->week_number_label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
- day_view->wn_notif_id = calendar_config_add_notification_dview_show_week_no (dview_show_week_no_changed_cb, day_view);
- if (calendar_config_get_dview_show_week_no ())
- gtk_widget_show (day_view->week_number_label);
/*
* Top Canvas
@@ -1064,16 +1380,17 @@ 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);
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
- return GTK_WIDGET (day_view);
+ day_view = g_object_new (E_TYPE_DAY_VIEW, "model", model, NULL);
+ init_model (E_DAY_VIEW (day_view), model);
+
+ return day_view;
}
static void
@@ -1088,11 +1405,6 @@ e_day_view_destroy (GtkObject *object)
e_day_view_stop_auto_scroll (day_view);
- if (day_view->wn_notif_id) {
- calendar_config_remove_notification (day_view->wn_notif_id);
- day_view->wn_notif_id = 0;
- }
-
if (day_view->large_font_desc) {
pango_font_description_free (day_view->large_font_desc);
day_view->large_font_desc = NULL;
@@ -2127,10 +2439,15 @@ e_day_view_find_work_week_start (EDayView *day_view,
time_t start_time)
{
GDate date;
+ ECalModel *model;
+ gint week_start_day;
gint weekday, day, i;
guint offset;
struct icaltimetype tt = icaltime_null_time ();
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
+ week_start_day = e_cal_model_get_week_start_day (model);
+
time_to_gdate_with_zone (&date, start_time, e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)));
/* The start of the work-week is the first working day after the
@@ -2142,7 +2459,7 @@ e_day_view_find_work_week_start (EDayView *day_view,
/* Calculate the first working day of the week, 0 (Sun) to 6 (Sat).
It will automatically default to the week start day if no days
are set as working days. */
- day = (day_view->week_start_day + 1) % 7;
+ day = (week_start_day + 1) % 7;
for (i = 0; i < 7; i++) {
if (day_view->working_days & (1 << day))
break;
@@ -2311,27 +2628,6 @@ e_day_view_recalc_day_starts (EDayView *day_view,
g_free (str);
}
-gboolean
-e_day_view_get_show_week_number (EDayView *day_view)
-{
- g_return_val_if_fail (day_view != NULL, FALSE);
-
- return GTK_WIDGET_VISIBLE (day_view->week_number_label);
-}
-
-void
-e_day_view_set_show_week_number (EDayView *day_view, gboolean show)
-{
- g_return_if_fail (day_view != NULL);
-
- if (e_day_view_get_show_week_number (day_view) != show) {
- if (show)
- gtk_widget_show (day_view->week_number_label);
- else
- gtk_widget_hide (day_view->week_number_label);
- }
-}
-
/* Whether we are displaying a work-week, in which case the display always
starts on the first day of the working week. */
gboolean
@@ -2389,7 +2685,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);
@@ -2397,8 +2693,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;
@@ -2416,6 +2712,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;
@@ -2440,7 +2738,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);
@@ -2448,8 +2746,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));
@@ -2464,16 +2762,23 @@ 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
e_day_view_recalc_work_week_days_shown (EDayView *day_view)
{
+ ECalModel *model;
+ gint week_start_day;
gint first_day, last_day, i, days_shown;
gboolean has_working_days = FALSE;
+ model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view));
+ week_start_day = e_cal_model_get_week_start_day (model);
+
/* Find the first working day in the week, 0 (Sun) to 6 (Sat). */
- first_day = (day_view->week_start_day + 1) % 7;
+ first_day = (week_start_day + 1) % 7;
for (i = 0; i < 7; i++) {
if (day_view->working_days & (1 << first_day)) {
has_working_days = TRUE;
@@ -2484,7 +2789,7 @@ e_day_view_recalc_work_week_days_shown (EDayView *day_view)
if (has_working_days) {
/* Now find the last working day of the week, backwards. */
- last_day = day_view->week_start_day % 7;
+ last_day = week_start_day % 7;
for (i = 0; i < 7; i++) {
if (day_view->working_days & (1 << last_day))
break;
@@ -2503,86 +2808,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_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_hour (EDayView *day_view,
+ gint work_day_start_hour)
{
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_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_set_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));
- 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_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");
}
-/* 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_hour (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_hour;
+}
+
+void
+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_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");
+}
+
+gint
+e_day_view_get_work_day_end_minute (EDayView *day_view)
+{
+ 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. */
@@ -2621,32 +3002,6 @@ e_day_view_set_show_times_cb (EDayView *day_view,
return TRUE;
}
-/* The first day of the week, 0 (Monday) to 6 (Sunday). */
-gint
-e_day_view_get_week_start_day (EDayView *day_view)
-{
- g_return_val_if_fail (E_IS_DAY_VIEW (day_view), 0);
-
- return day_view->week_start_day;
-}
-
-void
-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);
- g_return_if_fail (week_start_day < 7);
-
- if (day_view->week_start_day == week_start_day)
- return;
-
- day_view->week_start_day = week_start_day;
-
- if (day_view->work_week_view)
- e_day_view_recalc_work_week (day_view);
-}
-
static void
e_day_view_recalc_work_week (EDayView *day_view)
{
@@ -3345,28 +3700,15 @@ e_day_view_on_event_double_click (EDayView *day_view,
}
static void
-popup_destroyed_cb (gpointer data, GObject *where_object_was)
-{
- EDayView *day_view = data;
-
- day_view->popup_event_day = -1;
- day_view->popup_event_num = -1;
-}
-
-static void
e_day_view_show_popup_menu (EDayView *day_view,
- GdkEvent *gdk_event,
+ GdkEventButton *event,
gint day,
gint event_num)
{
- GtkMenu *popup;
-
day_view->popup_event_day = day;
day_view->popup_event_num = event_num;
- popup = e_calendar_view_create_popup_menu (E_CALENDAR_VIEW (day_view));
- g_object_weak_ref (G_OBJECT (popup), popup_destroyed_cb, day_view);
- gtk_menu_popup (popup, NULL, NULL, NULL, NULL, gdk_event?gdk_event->button.button:0, gdk_event?gdk_event->button.time:gtk_get_current_event_time());
+ e_calendar_view_popup_event (E_CALENDAR_VIEW (day_view), event);
}
static gboolean
@@ -3448,8 +3790,7 @@ e_day_view_on_event_right_click (EDayView *day_view,
gint day,
gint event_num)
{
- e_day_view_show_popup_menu (day_view, (GdkEvent*)bevent,
- day, event_num);
+ e_day_view_show_popup_menu (day_view, bevent, day, event_num);
}
static gboolean
@@ -3521,8 +3862,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
}
@@ -6322,7 +6662,8 @@ e_day_view_on_editing_stopped (EDayView *day_view,
if (!e_cal_create_object (client, icalcomp, NULL, NULL))
g_message (G_STRLOC ": Could not create the object!");
else
- gnome_calendar_emit_user_created_signal (day_view, e_calendar_view_get_calendar (E_CALENDAR_VIEW (day_view)), client);
+ e_calendar_view_emit_user_created (
+ E_CALENDAR_VIEW (day_view));
/* we remove the object since we either got the update from the server or failed */
e_day_view_remove_event_cb (day_view, day, event_num, NULL);
@@ -7776,10 +8117,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 {
@@ -7801,11 +8146,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);