aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamon Chaplin <damon@helixcode.com>2001-01-18 02:45:40 +0800
committerDamon Chaplin <damon@src.gnome.org>2001-01-18 02:45:40 +0800
commit08ea9ff68d9b544242dfe7f0f4409e90f2f24ebd (patch)
tree511f5630856246bf8fa2a917b5d51dd11bf5240b
parent60d8fc824908c3522765003de4ef821005c415ff (diff)
downloadgsoc2013-evolution-08ea9ff68d9b544242dfe7f0f4409e90f2f24ebd.tar
gsoc2013-evolution-08ea9ff68d9b544242dfe7f0f4409e90f2f24ebd.tar.gz
gsoc2013-evolution-08ea9ff68d9b544242dfe7f0f4409e90f2f24ebd.tar.bz2
gsoc2013-evolution-08ea9ff68d9b544242dfe7f0f4409e90f2f24ebd.tar.lz
gsoc2013-evolution-08ea9ff68d9b544242dfe7f0f4409e90f2f24ebd.tar.xz
gsoc2013-evolution-08ea9ff68d9b544242dfe7f0f4409e90f2f24ebd.tar.zst
gsoc2013-evolution-08ea9ff68d9b544242dfe7f0f4409e90f2f24ebd.zip
gui/e-week-view*.c don't use the theme colors at all within the graphical
2001-01-17 Damon Chaplin <damon@helixcode.com> * gui/e-week-view*.c * gui/e-day-view*.c: don't use the theme colors at all within the graphical parts of the widgets, since they may clash with our colors. May make them configurable in future so people can tweak them to go with their theme. At least the calendars are usable in any theme now, even though the colors may not go well with the theme. Also set the font of all the EText items in style_set. * gui/e-week-view-event-item.c (e_week_view_event_item_draw): don't draw the icons if we are editing the event. * gui/e-day-view.c: * gui/e-week-view.c: reinstated the optimizations so we don't do a complete relayout if the event's dates haven't been changed. (Though we still do a re-layout when recurring events change, since comparing all the RDATES/RRULES/EXDATES/EXRULES is too much hassle.) A side-effect of this change is that the EWeekView won't crash so often - only recurring events will be a problem. * cal-util/cal-component.[hc]: added function to check if the start and end dates of a component match. Used for optimizing the updating of the EDayView & EWeekView. svn path=/trunk/; revision=7593
-rw-r--r--calendar/ChangeLog25
-rw-r--r--calendar/cal-util/cal-component.c73
-rw-r--r--calendar/cal-util/cal-component.h2
-rw-r--r--calendar/gui/e-day-view-main-item.c15
-rw-r--r--calendar/gui/e-day-view-top-item.c55
-rw-r--r--calendar/gui/e-day-view.c106
-rw-r--r--calendar/gui/e-day-view.h13
-rw-r--r--calendar/gui/e-week-view-event-item.c27
-rw-r--r--calendar/gui/e-week-view-main-item.c33
-rw-r--r--calendar/gui/e-week-view.c67
-rw-r--r--calendar/gui/e-week-view.h5
11 files changed, 324 insertions, 97 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 5505ce2b42..000cb7756d 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,28 @@
+2001-01-17 Damon Chaplin <damon@helixcode.com>
+
+ * gui/e-week-view*.c
+ * gui/e-day-view*.c: don't use the theme colors at all within
+ the graphical parts of the widgets, since they may clash with
+ our colors. May make them configurable in future so people can tweak
+ them to go with their theme. At least the calendars are usable in any
+ theme now, even though the colors may not go well with the theme.
+ Also set the font of all the EText items in style_set.
+
+ * gui/e-week-view-event-item.c (e_week_view_event_item_draw): don't
+ draw the icons if we are editing the event.
+
+ * gui/e-day-view.c:
+ * gui/e-week-view.c: reinstated the optimizations so we don't do a
+ complete relayout if the event's dates haven't been changed.
+ (Though we still do a re-layout when recurring events change, since
+ comparing all the RDATES/RRULES/EXDATES/EXRULES is too much hassle.)
+ A side-effect of this change is that the EWeekView won't crash so
+ often - only recurring events will be a problem.
+
+ * cal-util/cal-component.[hc]: added function to check if the start
+ and end dates of a component match. Used for optimizing the updating
+ of the EDayView & EWeekView.
+
2001-01-17 JP Rosevear <jpr@ximian.com>
* conduits/calendar/calendar-conduit.c (start_calendar_server): Check
diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c
index 2c01991a90..daf50600c8 100644
--- a/calendar/cal-util/cal-component.c
+++ b/calendar/cal-util/cal-component.c
@@ -3890,3 +3890,76 @@ cal_component_alarm_set_trigger (CalComponentAlarm *alarm, CalAlarmTrigger trigg
}
}
}
+
+
+/**
+ * cal_component_event_dates_match:
+ * @comp1: A calendar component object.
+ * @comp2: A calendar component object.
+ *
+ * Checks if the DTSTART and DTEND properties of the 2 components match.
+ * Note that the events may have different recurrence properties which are not
+ * taken into account here.
+ *
+ * Returns: TRUE if the DTSTART and DTEND properties of the 2 components match.
+ **/
+gboolean
+cal_component_event_dates_match (CalComponent *comp1,
+ CalComponent *comp2)
+{
+ CalComponentDateTime comp1_dtstart, comp1_dtend;
+ CalComponentDateTime comp2_dtstart, comp2_dtend;
+
+ cal_component_get_dtstart (comp1, &comp1_dtstart);
+ cal_component_get_dtend (comp1, &comp1_dtend);
+ cal_component_get_dtstart (comp2, &comp2_dtstart);
+ cal_component_get_dtend (comp2, &comp2_dtend);
+
+ /* If either value is NULL they must both be NULL to match. */
+ if (comp1_dtstart.value == NULL || comp2_dtstart.value == NULL) {
+ if (comp1_dtstart.value != comp2_dtstart.value)
+ return FALSE;
+ } else {
+ if (icaltime_compare (*comp1_dtstart.value,
+ *comp2_dtstart.value))
+ return FALSE;
+ }
+
+ if (comp1_dtend.value == NULL || comp2_dtend.value == NULL) {
+ if (comp1_dtend.value != comp2_dtend.value)
+ return FALSE;
+ } else {
+ if (icaltime_compare (*comp1_dtend.value,
+ *comp2_dtend.value))
+ return FALSE;
+ }
+
+ /* Now check the timezones. */
+ if (!cal_component_strings_match (comp1_dtstart.tzid,
+ comp2_dtstart.tzid))
+ return FALSE;
+
+ if (!cal_component_strings_match (comp1_dtend.tzid,
+ comp2_dtend.tzid))
+ return FALSE;
+
+ return TRUE;
+}
+
+
+/* Returns TRUE if both strings match, i.e. they are both NULL or the
+ strings are equal. */
+static gboolean
+cal_component_strings_match (const gchar *string1,
+ const gchar *string2)
+{
+ if (string1 == NULL || string2 == NULL)
+ return (string1 == string2) ? TRUE : FALSE;
+
+ if (!strcmp (string1, string2))
+ return TRUE;
+
+ return FALSE;
+}
+
+
diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h
index 7f77544467..b7d8b602e9 100644
--- a/calendar/cal-util/cal-component.h
+++ b/calendar/cal-util/cal-component.h
@@ -255,6 +255,8 @@ void cal_component_set_transparency (CalComponent *comp, CalComponentTransparenc
void cal_component_get_url (CalComponent *comp, const char **url);
void cal_component_set_url (CalComponent *comp, const char *url);
+gboolean cal_component_event_dates_match (CalComponent *comp1, CalComponent *comp2);
+
/* Functions to free returned values */
void cal_component_free_categories_list (GSList *categ_list);
diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c
index 6867434d53..3cab1f1a05 100644
--- a/calendar/gui/e-day-view-main-item.c
+++ b/calendar/gui/e-day-view-main-item.c
@@ -182,7 +182,7 @@ e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable,
EDayViewMainItem *dvmitem;
EDayView *day_view;
GtkStyle *style;
- GdkGC *fg_gc, *bg_gc, *light_gc, *dark_gc, *gc;
+ GdkGC *gc;
GdkFont *font;
gint row, row_y, grid_x1, grid_x2;
gint day, grid_y1, grid_y2;
@@ -202,10 +202,6 @@ e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable,
style = GTK_WIDGET (day_view)->style;
font = style->font;
- fg_gc = style->fg_gc[GTK_STATE_NORMAL];
- bg_gc = style->bg_gc[GTK_STATE_NORMAL];
- light_gc = style->light_gc[GTK_STATE_NORMAL];
- dark_gc = style->dark_gc[GTK_STATE_NORMAL];
/* Paint the background colors. */
gc = day_view->main_gc;
@@ -266,7 +262,7 @@ e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable,
rect_y = start_row * day_view->row_height - y;
rect_height = (end_row - start_row + 1) * day_view->row_height;
- gc = style->bg_gc[GTK_STATE_SELECTED];
+ gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED]);
gdk_draw_rectangle (drawable, gc, TRUE,
rect_x, rect_y,
rect_width, rect_height);
@@ -277,11 +273,12 @@ e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable,
grid_x1 = day_view->day_offsets[0] - x;
grid_x2 = day_view->day_offsets[day_view->days_shown] - x;
+ gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_GRID]);
for (row = 0, row_y = 0 - y;
row < day_view->rows && row_y < height;
row++, row_y += day_view->row_height) {
if (row_y >= 0 && row_y < height)
- gdk_draw_line (drawable, dark_gc,
+ gdk_draw_line (drawable, gc,
grid_x1, row_y, grid_x2, row_y);
}
@@ -295,10 +292,10 @@ e_day_view_main_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable,
if (grid_x1 >= width || grid_x1 + E_DAY_VIEW_BAR_WIDTH <= 0)
continue;
- gdk_draw_line (drawable, fg_gc,
+ gdk_draw_line (drawable, style->black_gc,
grid_x1, grid_y1,
grid_x1, grid_y2);
- gdk_draw_line (drawable, fg_gc,
+ gdk_draw_line (drawable, style->black_gc,
grid_x1 + E_DAY_VIEW_BAR_WIDTH - 1, grid_y1,
grid_x1 + E_DAY_VIEW_BAR_WIDTH - 1, grid_y2);
gdk_draw_rectangle (drawable, style->white_gc, TRUE,
diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c
index 145809893f..8995832399 100644
--- a/calendar/gui/e-day-view-top-item.c
+++ b/calendar/gui/e-day-view-top-item.c
@@ -182,7 +182,7 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
EDayViewTopItem *dvtitem;
EDayView *day_view;
GtkStyle *style;
- GdkGC *fg_gc, *bg_gc, *light_gc, *dark_gc;
+ GdkGC *gc, *fg_gc, *bg_gc, *light_gc, *dark_gc;
gchar buffer[128], *format;
GdkRectangle clip_rect;
GdkFont *font;
@@ -200,6 +200,7 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
style = GTK_WIDGET (day_view)->style;
font = style->font;
+ gc = day_view->main_gc;
fg_gc = style->fg_gc[GTK_STATE_NORMAL];
bg_gc = style->bg_gc[GTK_STATE_NORMAL];
light_gc = style->light_gc[GTK_STATE_NORMAL];
@@ -209,11 +210,6 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
left_edge = 0;
item_height = day_view->top_row_height - E_DAY_VIEW_TOP_CANVAS_Y_GAP;
- /* Clear the entire background. */
- gdk_draw_rectangle (drawable, dark_gc, TRUE,
- left_edge - x, 0,
- canvas_width - left_edge, height);
-
/* Draw the shadow around the dates. */
gdk_draw_line (drawable, light_gc,
left_edge + 1 - x, 1 - y,
@@ -221,6 +217,12 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
gdk_draw_line (drawable, light_gc,
left_edge + 1 - x, 2 - y,
left_edge + 1 - x, item_height - 1 - y);
+ gdk_draw_line (drawable, dark_gc,
+ left_edge + 2 - x, item_height - 1 - y,
+ canvas_width - 1 - x, item_height - 1 - y);
+ gdk_draw_line (drawable, dark_gc,
+ canvas_width - 1 - x, 1 - y,
+ canvas_width - 1 - x, item_height - 1 - y);
/* Draw the background for the dates. */
gdk_draw_rectangle (drawable, bg_gc, TRUE,
@@ -228,6 +230,13 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
canvas_width - left_edge - 3,
item_height - 3);
+ /* Clear the main area background. */
+ gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS]);
+ gdk_draw_rectangle (drawable, gc, TRUE,
+ left_edge - x, item_height - y,
+ canvas_width - left_edge,
+ canvas_height - item_height);
+
/* Draw the selection background. */
if (GTK_WIDGET_HAS_FOCUS (day_view)
&& day_view->selection_start_day != -1) {
@@ -244,7 +253,8 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
rect_w = day_view->day_offsets[end_col + 1] - rect_x;
rect_h = canvas_height - 1 - rect_y;
- gdk_draw_rectangle (drawable, style->white_gc, TRUE,
+ gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_SELECTED]);
+ gdk_draw_rectangle (drawable, gc, TRUE,
rect_x - x, rect_y - y,
rect_w, rect_h);
}
@@ -302,7 +312,8 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
/* Draw the lines between each column. */
if (day != 0) {
- gdk_draw_line (drawable, style->black_gc,
+ gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_GRID]);
+ gdk_draw_line (drawable, gc,
day_view->day_offsets[day] - x,
item_height - y,
day_view->day_offsets[day] - x,
@@ -371,15 +382,17 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
comp = event->comp;
/* Draw the lines across the top & bottom of the entire event. */
- gdk_draw_line (drawable, fg_gc,
+ gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER]);
+ gdk_draw_line (drawable, gc,
item_x - x, item_y - y,
item_x + item_w - 1 - x, item_y - y);
- gdk_draw_line (drawable, fg_gc,
+ gdk_draw_line (drawable, gc,
item_x - x, item_y + item_h - 1 - y,
item_x + item_w - 1 - x, item_y + item_h - 1 - y);
/* Fill it in. */
- gdk_draw_rectangle (drawable, bg_gc, TRUE,
+ gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND]);
+ gdk_draw_rectangle (drawable, gc, TRUE,
item_x - x, item_y + 1 - y,
item_w, item_h - 2);
@@ -405,7 +418,8 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
-E_DAY_VIEW_BAR_WIDTH,
item_h);
} else {
- gdk_draw_line (drawable, fg_gc,
+ gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER]);
+ gdk_draw_line (drawable, gc,
item_x - x, item_y - y,
item_x - x, item_y + item_h - 1 - y);
}
@@ -419,7 +433,8 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
E_DAY_VIEW_BAR_WIDTH,
item_h);
} else {
- gdk_draw_line (drawable, fg_gc,
+ gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER]);
+ gdk_draw_line (drawable, gc,
item_x + item_w - 1 - x,
item_y - y,
item_x + item_w - 1 - x,
@@ -565,15 +580,14 @@ e_day_view_top_item_draw_triangle (EDayViewTopItem *dvtitem,
{
EDayView *day_view;
GtkStyle *style;
- GdkGC *fg_gc, *bg_gc;
+ GdkGC *gc;
GdkPoint points[3];
gint c1, c2;
day_view = dvtitem->day_view;
style = GTK_WIDGET (day_view)->style;
- fg_gc = style->fg_gc[GTK_STATE_NORMAL];
- bg_gc = style->bg_gc[GTK_STATE_NORMAL];
+ gc = day_view->main_gc;
points[0].x = x;
points[0].y = y;
@@ -588,9 +602,12 @@ e_day_view_top_item_draw_triangle (EDayViewTopItem *dvtitem,
if (h % 2 == 0)
c1--;
- gdk_draw_polygon (drawable, bg_gc, TRUE, points, 3);
- gdk_draw_line (drawable, fg_gc, x, y, x + w, c1);
- gdk_draw_line (drawable, fg_gc, x, y + h - 1, x + w, c2);
+ gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND]);
+ gdk_draw_polygon (drawable, gc, TRUE, points, 3);
+
+ gdk_gc_set_foreground (gc, &day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER]);
+ gdk_draw_line (drawable, gc, x, y, x + w, c1);
+ gdk_draw_line (drawable, gc, x, y + h - 1, x + w, c2);
}
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 1960071cdd..47c19dff75 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -385,12 +385,10 @@ static void e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget
guint time,
EDayView *day_view);
-#if 0
static gboolean e_day_view_update_event_cb (EDayView *day_view,
gint day,
gint event_num,
gpointer data);
-#endif
static gboolean e_day_view_remove_event_cb (EDayView *day_view,
gint day,
gint event_num,
@@ -404,6 +402,10 @@ static time_t e_day_view_find_work_week_start (EDayView *day_view,
time_t start_time);
static void e_day_view_recalc_work_week (EDayView *day_view);
static void e_day_view_recalc_work_week_days_shown (EDayView *day_view);
+static gboolean e_day_view_set_event_font_cb (EDayView *day_view,
+ gint day,
+ gint event_num,
+ gpointer data);
static GtkTableClass *parent_class;
@@ -883,6 +885,26 @@ e_day_view_realize (GtkWidget *widget)
day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING].green = 216 * 257;
day_view->colors[E_DAY_VIEW_COLOR_BG_NOT_WORKING].blue = 214 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED].red = 0 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED].green = 0 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_SELECTED].blue = 156 * 257;
+
+ day_view->colors[E_DAY_VIEW_COLOR_BG_GRID].red = 148 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_GRID].green = 149 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_GRID].blue = 148 * 257;
+
+ day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS].red = 148 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS].green = 149 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS].blue = 148 * 257;
+
+ day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_SELECTED].red = 65535;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_SELECTED].green = 65535;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_SELECTED].blue = 65535;
+
+ day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_GRID].red = 0;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_GRID].green = 0;
+ day_view->colors[E_DAY_VIEW_COLOR_BG_TOP_CANVAS_GRID].blue = 0;
+
day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR].red = 0;
day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR].green = 0;
day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR].blue = 65535;
@@ -895,6 +917,14 @@ e_day_view_realize (GtkWidget *widget)
day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER].green = 0;
day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER].blue = 0;
+ day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND].red = 213 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND].green = 213 * 257;
+ day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND].blue = 213 * 257;
+
+ day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER].red = 0;
+ day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER].green = 0;
+ day_view->colors[E_DAY_VIEW_COLOR_LONG_EVENT_BORDER].blue = 0;
+
nfailed = gdk_colormap_alloc_colors (colormap, day_view->colors,
E_DAY_VIEW_COLOR_LAST, FALSE,
TRUE, success);
@@ -950,16 +980,6 @@ e_day_view_realize (GtkWidget *widget)
"fill_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_VBAR],
"outline_color_gdk", &day_view->colors[E_DAY_VIEW_COLOR_EVENT_BORDER],
NULL);
-
-
- /* Set the fonts for the text items used when dragging. */
- gnome_canvas_item_set (day_view->drag_long_event_item,
- "font_gdk", GTK_WIDGET (day_view)->style->font,
- NULL);
-
- gnome_canvas_item_set (day_view->drag_item,
- "font_gdk", GTK_WIDGET (day_view)->style->font,
- NULL);
}
@@ -1108,6 +1128,44 @@ e_day_view_style_set (GtkWidget *widget,
/* Calculate the width of the time column. */
times_width = e_day_view_time_item_get_column_width (E_DAY_VIEW_TIME_ITEM (day_view->time_canvas_item));
gtk_widget_set_usize (day_view->time_canvas, times_width, -1);
+
+ /* Set the font of all the EText items. */
+ e_day_view_foreach_event (day_view, e_day_view_set_event_font_cb,
+ font);
+
+ /* Set the fonts for the text items used when dragging. */
+ gnome_canvas_item_set (day_view->drag_long_event_item,
+ "font_gdk", GTK_WIDGET (day_view)->style->font,
+ NULL);
+
+ gnome_canvas_item_set (day_view->drag_item,
+ "font_gdk", GTK_WIDGET (day_view)->style->font,
+ NULL);
+}
+
+
+static gboolean
+e_day_view_set_event_font_cb (EDayView *day_view,
+ gint day,
+ gint event_num,
+ gpointer data)
+{
+ EDayViewEvent *event;
+ GdkFont *font = data;
+
+ if (day == E_DAY_VIEW_LONG_EVENT)
+ event = &g_array_index (day_view->long_events,
+ EDayViewEvent, event_num);
+ else
+ event = &g_array_index (day_view->events[day],
+ EDayViewEvent, event_num);
+
+ if (event->canvas_item)
+ gnome_canvas_item_set (event->canvas_item,
+ "font_gdk", font,
+ NULL);
+
+ return TRUE;
}
@@ -1367,21 +1425,20 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data)
else
event = &g_array_index (day_view->events[day],
EDayViewEvent, event_num);
-#ifndef NO_WARNINGS
-#warning "FIXME"
-#endif
- /* Do this the long way every time for now */
+ if (!cal_component_has_recurrences (comp)
+ && !cal_component_has_recurrences (event->comp)
+ && cal_component_event_dates_match (comp, event->comp)) {
#if 0
- if (ical_object_compare_dates (event->ico, ico)) {
g_print ("updated object's dates unchanged\n");
- e_day_view_foreach_event_with_uid (day_view, uid, e_day_view_update_event_cb, ico);
- ical_object_unref (ico);
+#endif
+ e_day_view_foreach_event_with_uid (day_view, uid, e_day_view_update_event_cb, comp);
+ gtk_object_unref (GTK_OBJECT (comp));
gtk_widget_queue_draw (day_view->top_canvas);
gtk_widget_queue_draw (day_view->main_canvas);
return;
}
-#endif
+
/* The dates have changed, so we need to remove the
old occurrrences before adding the new ones. */
#if 0
@@ -1405,6 +1462,7 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data)
gtk_widget_queue_draw (day_view->main_canvas);
}
+
/* Callback used when the calendar client tells us that an object was removed */
static void
obj_removed_cb (CalClient *client, const char *uid, gpointer data)
@@ -1466,7 +1524,7 @@ e_day_view_set_cal_client (EDayView *day_view,
e_day_view_queue_reload_events (day_view);
}
-#if 0
+
static gboolean
e_day_view_update_event_cb (EDayView *day_view,
gint day,
@@ -1502,10 +1560,10 @@ e_day_view_update_event_cb (EDayView *day_view,
}
return TRUE;
}
-#endif
+
/* This calls a given function for each event instance (in both views).
- If the callback returns TRUE the iteration is stopped.
+ If the callback returns FALSE the iteration is stopped.
Note that it is safe for the callback to remove the event (since we
step backwards through the arrays). */
static void
@@ -1542,7 +1600,7 @@ e_day_view_foreach_event (EDayView *day_view,
/* This calls a given function for each event instance that matches the given
- uid. If the callback returns TRUE the iteration is stopped.
+ uid. If the callback returns FALSE the iteration is stopped.
Note that it is safe for the callback to remove the event (since we
step backwards through the arrays). */
static void
diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h
index b02bcd7710..2379a76b87 100644
--- a/calendar/gui/e-day-view.h
+++ b/calendar/gui/e-day-view.h
@@ -136,11 +136,20 @@ typedef enum
{
E_DAY_VIEW_COLOR_BG_WORKING,
E_DAY_VIEW_COLOR_BG_NOT_WORKING,
- E_DAY_VIEW_COLOR_EVENT_VBAR,
+ E_DAY_VIEW_COLOR_BG_SELECTED,
+ E_DAY_VIEW_COLOR_BG_GRID,
+
+ E_DAY_VIEW_COLOR_BG_TOP_CANVAS,
+ E_DAY_VIEW_COLOR_BG_TOP_CANVAS_SELECTED,
+ E_DAY_VIEW_COLOR_BG_TOP_CANVAS_GRID,
+ E_DAY_VIEW_COLOR_EVENT_VBAR,
E_DAY_VIEW_COLOR_EVENT_BACKGROUND,
E_DAY_VIEW_COLOR_EVENT_BORDER,
-
+
+ E_DAY_VIEW_COLOR_LONG_EVENT_BACKGROUND,
+ E_DAY_VIEW_COLOR_LONG_EVENT_BORDER,
+
E_DAY_VIEW_COLOR_LAST
} EDayViewColors;
diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c
index 5615e86bb6..8adfdd96ff 100644
--- a/calendar/gui/e-week-view-event-item.c
+++ b/calendar/gui/e-week-view-event-item.c
@@ -416,13 +416,15 @@ e_week_view_event_item_draw (GnomeCanvasItem *canvas_item,
clip_rect.width = x2 - x1 - E_WEEK_VIEW_EVENT_R_PAD
- E_WEEK_VIEW_EVENT_BORDER_WIDTH + 1;
clip_rect.height = y2 - y1 + 1;
- gdk_gc_set_clip_rectangle (fg_gc, &clip_rect);
+ gdk_gc_set_clip_rectangle (gc, &clip_rect);
+
+ gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_TEXT]);
e_week_view_draw_time (week_view, drawable,
time_x, time_y,
start_hour, start_minute);
- gdk_gc_set_clip_rectangle (fg_gc, NULL);
+ gdk_gc_set_clip_rectangle (gc, NULL);
/* We don't want the end time to be drawn over the
start time, so we increase the minimum position. */
@@ -455,7 +457,9 @@ e_week_view_event_item_draw (GnomeCanvasItem *canvas_item,
}
/* Draw the icons. */
- if (span->text_item) {
+ if (span->text_item &&
+ week_view->editing_event_num != wveitem->event_num
+ && week_view->editing_span_num != wveitem->span_num) {
icon_x = span->text_item->x1 - x;
e_week_view_event_item_draw_icons (wveitem, drawable,
icon_x, icon_y,
@@ -474,7 +478,7 @@ e_week_view_draw_time (EWeekView *week_view,
gint minute)
{
GtkStyle *style;
- GdkGC *fg_gc;
+ GdkGC *gc;
GdkFont *font, *small_font;
gint hour_to_display, suffix_width;
gint time_y_normal_font, time_y_small_font;
@@ -483,7 +487,8 @@ e_week_view_draw_time (EWeekView *week_view,
style = GTK_WIDGET (week_view)->style;
font = style->font;
small_font = week_view->small_font;
- fg_gc = style->fg_gc[GTK_STATE_NORMAL];
+ gc = week_view->main_gc;
+
time_y_normal_font = time_y_small_font = time_y + font->ascent;
if (small_font)
@@ -498,24 +503,24 @@ e_week_view_draw_time (EWeekView *week_view,
/* Draw the hour. */
if (hour_to_display < 10)
- gdk_draw_text (drawable, font, fg_gc,
+ gdk_draw_text (drawable, font, gc,
time_x + week_view->digit_width,
time_y_normal_font, buffer + 1, 1);
else
- gdk_draw_text (drawable, font, fg_gc,
+ gdk_draw_text (drawable, font, gc,
time_x, time_y_normal_font, buffer, 2);
time_x += week_view->digit_width * 2;
/* Draw the start minute, in the small font. */
- gdk_draw_text (drawable, week_view->small_font, fg_gc,
+ gdk_draw_text (drawable, week_view->small_font, gc,
time_x, time_y_small_font, buffer + 3, 2);
time_x += week_view->small_digit_width * 2;
/* Draw the 'am'/'pm' suffix, if 12-hour format. */
if (!week_view->use_24_hour_format) {
- gdk_draw_string (drawable, font, fg_gc,
+ gdk_draw_string (drawable, font, gc,
time_x, time_y_normal_font, suffix);
}
} else {
@@ -523,11 +528,11 @@ e_week_view_draw_time (EWeekView *week_view,
g_snprintf (buffer, sizeof (buffer), "%2i:%02i%s",
hour_to_display, minute, suffix);
if (hour_to_display < 10)
- gdk_draw_string (drawable, font, fg_gc,
+ gdk_draw_string (drawable, font, gc,
time_x + week_view->digit_width,
time_y_normal_font, buffer + 1);
else
- gdk_draw_string (drawable, font, fg_gc,
+ gdk_draw_string (drawable, font, gc,
time_x, time_y_normal_font,
buffer);
diff --git a/calendar/gui/e-week-view-main-item.c b/calendar/gui/e-week-view-main-item.c
index 10990324ff..e1959489b1 100644
--- a/calendar/gui/e-week-view-main-item.c
+++ b/calendar/gui/e-week-view-main-item.c
@@ -223,8 +223,7 @@ e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem,
{
EWeekView *week_view;
GtkStyle *style;
- GdkGC *fg_gc, *bg_gc, *light_gc, *dark_gc, *gc, *date_gc;
- GdkGC *selected_fg_gc, *selected_bg_gc;
+ GdkGC *gc;
GdkFont *font;
gint right_edge, bottom_edge, date_width, date_x, line_y;
gboolean show_day_name, show_month_name, selected;
@@ -238,12 +237,6 @@ e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem,
week_view = wvmitem->week_view;
style = GTK_WIDGET (week_view)->style;
font = style->font;
- fg_gc = style->fg_gc[GTK_STATE_NORMAL];
- bg_gc = style->bg_gc[GTK_STATE_PRELIGHT];
- light_gc = style->light_gc[GTK_STATE_NORMAL];
- dark_gc = style->dark_gc[GTK_STATE_NORMAL];
- selected_fg_gc = style->fg_gc[GTK_STATE_SELECTED];
- selected_bg_gc = style->bg_gc[GTK_STATE_SELECTED];
gc = week_view->main_gc;
g_return_if_fail (gc != NULL);
@@ -272,9 +265,10 @@ e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem,
right_edge = x + width - 1;
bottom_edge = y + height - 1;
- gdk_draw_line (drawable, fg_gc,
+ gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_GRID]);
+ gdk_draw_line (drawable, gc,
right_edge, y, right_edge, bottom_edge);
- gdk_draw_line (drawable, fg_gc,
+ gdk_draw_line (drawable, gc,
x, bottom_edge, right_edge, bottom_edge);
/* If the day is selected, draw the blue background. */
@@ -285,16 +279,18 @@ e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem,
|| week_view->selection_end_day < day)
selected = FALSE;
if (selected) {
- if (week_view->multi_week_view)
- gdk_draw_rectangle (drawable, selected_bg_gc, TRUE,
+ gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_SELECTED]);
+ if (week_view->multi_week_view) {
+ gdk_draw_rectangle (drawable, gc, TRUE,
x + 2, y + 1,
width - 5,
E_WEEK_VIEW_DATE_T_PAD - 1
+ font->ascent + font->descent);
- else
- gdk_draw_rectangle (drawable, selected_bg_gc, TRUE,
+ } else {
+ gdk_draw_rectangle (drawable, gc, TRUE,
x + 2, y + 1,
width - 5, line_y - y);
+ }
}
/* Display the date in the top of the cell.
@@ -355,16 +351,17 @@ e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem,
date_x = MAX (date_x, x + 1);
if (selected)
- date_gc = selected_fg_gc;
+ gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_DATES_SELECTED]);
else
- date_gc = fg_gc;
- gdk_draw_string (drawable, font, date_gc,
+ gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_DATES]);
+ gdk_draw_string (drawable, font, gc,
date_x, y + E_WEEK_VIEW_DATE_T_PAD + font->ascent,
buffer);
/* Draw the line under the date. */
if (!week_view->multi_week_view) {
- gdk_draw_line (drawable, fg_gc,
+ gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_GRID]);
+ gdk_draw_line (drawable, gc,
x + E_WEEK_VIEW_DATE_LINE_L_PAD, line_y,
right_edge, line_y);
}
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index b205bdc34e..99d639688a 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -169,11 +169,9 @@ static void e_week_view_on_delete_appointment (GtkWidget *widget,
static void e_week_view_on_unrecur_appointment (GtkWidget *widget,
gpointer data);
-#ifndef NO_WARNINGS
static gboolean e_week_view_update_event_cb (EWeekView *week_view,
gint event_num,
gpointer data);
-#endif
static gboolean e_week_view_remove_event_cb (EWeekView *week_view,
gint event_num,
gpointer data);
@@ -458,6 +456,26 @@ e_week_view_realize (GtkWidget *widget)
week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER].green = 0;
week_view->colors[E_WEEK_VIEW_COLOR_EVENT_BORDER].blue = 0;
+ week_view->colors[E_WEEK_VIEW_COLOR_EVENT_TEXT].red = 0;
+ week_view->colors[E_WEEK_VIEW_COLOR_EVENT_TEXT].green = 0;
+ week_view->colors[E_WEEK_VIEW_COLOR_EVENT_TEXT].blue = 0;
+
+ week_view->colors[E_WEEK_VIEW_COLOR_GRID].red = 0 * 257;
+ week_view->colors[E_WEEK_VIEW_COLOR_GRID].green = 0 * 257;
+ week_view->colors[E_WEEK_VIEW_COLOR_GRID].blue = 0 * 257;
+
+ week_view->colors[E_WEEK_VIEW_COLOR_SELECTED].red = 0 * 257;
+ week_view->colors[E_WEEK_VIEW_COLOR_SELECTED].green = 0 * 257;
+ week_view->colors[E_WEEK_VIEW_COLOR_SELECTED].blue = 156 * 257;
+
+ week_view->colors[E_WEEK_VIEW_COLOR_DATES].red = 0 * 257;
+ week_view->colors[E_WEEK_VIEW_COLOR_DATES].green = 0 * 257;
+ week_view->colors[E_WEEK_VIEW_COLOR_DATES].blue = 0 * 257;
+
+ week_view->colors[E_WEEK_VIEW_COLOR_DATES_SELECTED].red = 65535;
+ week_view->colors[E_WEEK_VIEW_COLOR_DATES_SELECTED].green = 65535;
+ week_view->colors[E_WEEK_VIEW_COLOR_DATES_SELECTED].blue = 65535;
+
nfailed = gdk_colormap_alloc_colors (colormap, week_view->colors,
E_WEEK_VIEW_COLOR_LAST, FALSE,
TRUE, success);
@@ -502,9 +520,11 @@ e_week_view_style_set (GtkWidget *widget,
GtkStyle *previous_style)
{
EWeekView *week_view;
+ EWeekViewEventSpan *span;
GdkFont *font;
gint day, day_width, max_day_width, max_abbr_day_width;
gint month, month_width, max_month_width, max_abbr_month_width;
+ gint span_num;
GDate date;
gchar buffer[128];
@@ -574,6 +594,19 @@ e_week_view_style_set (GtkWidget *widget,
week_view->am_string);
week_view->pm_string_width = gdk_string_width (font,
week_view->pm_string);
+
+ /* Set the font of all the EText items. */
+ if (week_view->spans) {
+ for (span_num = 0; span_num < week_view->spans->len;
+ span_num++) {
+ span = &g_array_index (week_view->spans,
+ EWeekViewEventSpan, span_num);
+ if (span->text_item)
+ gnome_canvas_item_set (span->text_item,
+ "font_gdk", font,
+ NULL);
+ }
+ }
}
@@ -892,23 +925,26 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data)
update the event fairly easily without changing the events arrays
or computing a new layout. */
if (e_week_view_find_event_from_uid (week_view, uid, &event_num)) {
-#ifndef NO_WARNINGS
-#warning "FIXME"
-#endif
event = &g_array_index (week_view->events, EWeekViewEvent,
event_num);
- /* Do this the long way every time for now */
+ if (!cal_component_has_recurrences (comp)
+ && !cal_component_has_recurrences (event->comp)
+ && cal_component_event_dates_match (comp, event->comp)) {
#if 0
- if (ical_object_compare_dates (event->ico, ico)) {
+ g_print ("updated object's dates unchanged\n");
+#endif
e_week_view_foreach_event_with_uid (week_view, uid, e_week_view_update_event_cb, comp);
gtk_object_unref (GTK_OBJECT (comp));
gtk_widget_queue_draw (week_view->main_canvas);
return;
}
-#endif
+
/* The dates have changed, so we need to remove the
old occurrrences before adding the new ones. */
+#if 0
+ g_print ("dates changed - removing occurrences\n");
+#endif
e_week_view_foreach_event_with_uid (week_view, uid,
e_week_view_remove_event_cb,
NULL);
@@ -1473,7 +1509,6 @@ e_week_view_recalc_display_start_day (EWeekView *week_view)
}
-#ifndef NO_WARNINGS
static gboolean
e_week_view_update_event_cb (EWeekView *week_view,
gint event_num,
@@ -1513,7 +1548,6 @@ e_week_view_update_event_cb (EWeekView *week_view,
return TRUE;
}
-#endif
/* This calls a given function for each event instance that matches the given
@@ -2772,6 +2806,10 @@ e_week_view_start_editing_event (EWeekView *week_view,
NULL);
}
+ /* FIXME: This implicitly stops any edit of another item, causing it
+ to be sent to the server and resulting in a call to obj_updated_cb()
+ which may reload all the events and so our span and text item may
+ actually be destroyed. So we often get a SEGV. */
e_canvas_item_grab_focus (span->text_item);
/* Try to move the cursor to the end of the text. */
@@ -3137,10 +3175,11 @@ e_week_view_key_press (GtkWidget *widget, GdkEventKey *event)
*date.value = icaltime_from_timet (dtend, FALSE, TRUE);
cal_component_set_dtend (comp, &date);
- /* We add the event locally and start editing it. When we get the
- "update_event" callback from the server, we basically ignore it.
- If we were to wait for the "update_event" callback it wouldn't be
- as responsive and we may lose a few keystrokes. */
+ /* We add the event locally and start editing it. We don't send the
+ new event to the server until the edit is finished.
+ FIXME: If we get an obj-updated or obj-removed signal while editing
+ the event, and we have to do a re-layout, we may lose this new
+ event. */
e_week_view_add_event (comp, dtstart, dtend, week_view);
e_week_view_check_layout (week_view);
gtk_widget_queue_draw (week_view->main_canvas);
diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h
index be2f1057da..47362d0ee6 100644
--- a/calendar/gui/e-week-view.h
+++ b/calendar/gui/e-week-view.h
@@ -96,6 +96,11 @@ typedef enum
E_WEEK_VIEW_COLOR_ODD_MONTHS,
E_WEEK_VIEW_COLOR_EVENT_BACKGROUND,
E_WEEK_VIEW_COLOR_EVENT_BORDER,
+ E_WEEK_VIEW_COLOR_EVENT_TEXT,
+ E_WEEK_VIEW_COLOR_GRID,
+ E_WEEK_VIEW_COLOR_SELECTED,
+ E_WEEK_VIEW_COLOR_DATES,
+ E_WEEK_VIEW_COLOR_DATES_SELECTED,
E_WEEK_VIEW_COLOR_LAST
} EWeekViewColors;