diff options
author | Federico Mena Quintero <federico@nuclecu.unam.mx> | 1998-04-14 12:06:58 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1998-04-14 12:06:58 +0800 |
commit | 49a388705e5085a963c3c1b5cdcd324af5d8b1b5 (patch) | |
tree | f2815ebbad01062c49dc016aa26352898ecd6bc1 /calendar | |
parent | 23ef00df35512cfe6285ba45c0b20f635faee111 (diff) | |
download | gsoc2013-evolution-49a388705e5085a963c3c1b5cdcd324af5d8b1b5.tar gsoc2013-evolution-49a388705e5085a963c3c1b5cdcd324af5d8b1b5.tar.gz gsoc2013-evolution-49a388705e5085a963c3c1b5cdcd324af5d8b1b5.tar.bz2 gsoc2013-evolution-49a388705e5085a963c3c1b5cdcd324af5d8b1b5.tar.lz gsoc2013-evolution-49a388705e5085a963c3c1b5cdcd324af5d8b1b5.tar.xz gsoc2013-evolution-49a388705e5085a963c3c1b5cdcd324af5d8b1b5.tar.zst gsoc2013-evolution-49a388705e5085a963c3c1b5cdcd324af5d8b1b5.zip |
Now takes object and flags parameters. Likewise. Likewise.
1998-04-13 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gncal-week-view.c (gncal_week_view_update): Now takes object and
flags parameters.
* gncal-day-view.c (gncal_day_view_update): Likewise.
* gncal-full-day.c (gncal_full_day_update): Likewise.
(child_focus_in): New function. In conjunction with
child_focus_out(), these only display the handles in the child
when it is focused. The result is that the user can see more of
the child's text when nothing is focused, and we can also display
fatter and nicer drag handles.
* gnome-cal.c (gnome_calendar_object_changed): Now takes an
additional flags parameter
(gnome_calendar_update_all): Made function static. Now takes
changed object and flags parameters as well.
(gnome_calendar_object_changed): Now takes additional flags
parameter to indicate what changed in the specified object.
* calobj.h (CalObjectChange): New enum with flags to describe what
has been changed in an object.
svn path=/trunk/; revision=132
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 20 | ||||
-rw-r--r-- | calendar/cal-util/calobj.h | 7 | ||||
-rw-r--r-- | calendar/calobj.h | 7 | ||||
-rw-r--r-- | calendar/gncal-day-view.c | 6 | ||||
-rw-r--r-- | calendar/gncal-day-view.h | 2 | ||||
-rw-r--r-- | calendar/gncal-full-day.c | 75 | ||||
-rw-r--r-- | calendar/gncal-full-day.h | 4 | ||||
-rw-r--r-- | calendar/gncal-week-view.c | 10 | ||||
-rw-r--r-- | calendar/gncal-week-view.h | 8 | ||||
-rw-r--r-- | calendar/gnome-cal.c | 16 | ||||
-rw-r--r-- | calendar/gnome-cal.h | 4 | ||||
-rw-r--r-- | calendar/gui/gncal-day-view.c | 6 | ||||
-rw-r--r-- | calendar/gui/gncal-day-view.h | 2 | ||||
-rw-r--r-- | calendar/gui/gncal-full-day.c | 75 | ||||
-rw-r--r-- | calendar/gui/gncal-full-day.h | 4 | ||||
-rw-r--r-- | calendar/gui/gncal-week-view.c | 10 | ||||
-rw-r--r-- | calendar/gui/gncal-week-view.h | 8 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 16 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.h | 4 | ||||
-rw-r--r-- | calendar/pcs/calobj.h | 7 |
20 files changed, 215 insertions, 76 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 87c6dc9358..c986771afc 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,5 +1,25 @@ 1998-04-13 Federico Mena Quintero <federico@nuclecu.unam.mx> + * gncal-week-view.c (gncal_week_view_update): Now takes object and + flags parameters. + * gncal-day-view.c (gncal_day_view_update): Likewise. + * gncal-full-day.c (gncal_full_day_update): Likewise. + (child_focus_in): New function. In conjunction with + child_focus_out(), these only display the handles in the child + when it is focused. The result is that the user can see more of + the child's text when nothing is focused, and we can also display + fatter and nicer drag handles. + + * gnome-cal.c (gnome_calendar_object_changed): Now takes an + additional flags parameter + (gnome_calendar_update_all): Made function static. Now takes + changed object and flags parameters as well. + (gnome_calendar_object_changed): Now takes additional flags + parameter to indicate what changed in the specified object. + + * calobj.h (CalObjectChange): New enum with flags to describe what + has been changed in an object. + * gncal-full-day.h: * gncal-full-day.c (gncal_full_day_focus_child): New function to let the outside world decide which child to focus. diff --git a/calendar/cal-util/calobj.h b/calendar/cal-util/calobj.h index 37ea79040d..7dc810b459 100644 --- a/calendar/cal-util/calobj.h +++ b/calendar/cal-util/calobj.h @@ -85,6 +85,13 @@ typedef struct { int frequency; } Recurrence; +/* Flags to indicate what has changed in an object */ +typedef enum { + CHANGE_NEW = 1 << 0, /* new object */ + CHANGE_SUMMARY = 1 << 1, /* summary */ + CHANGE_DATES = 1 << 2 /* dtstart / dtend */ +} CalObjectChange; + /* * This describes an iCalendar object, note that we never store durations, instead we * always compute the end time computed from the start + duration. diff --git a/calendar/calobj.h b/calendar/calobj.h index 37ea79040d..7dc810b459 100644 --- a/calendar/calobj.h +++ b/calendar/calobj.h @@ -85,6 +85,13 @@ typedef struct { int frequency; } Recurrence; +/* Flags to indicate what has changed in an object */ +typedef enum { + CHANGE_NEW = 1 << 0, /* new object */ + CHANGE_SUMMARY = 1 << 1, /* summary */ + CHANGE_DATES = 1 << 2 /* dtstart / dtend */ +} CalObjectChange; + /* * This describes an iCalendar object, note that we never store durations, instead we * always compute the end time computed from the start + duration. diff --git a/calendar/gncal-day-view.c b/calendar/gncal-day-view.c index 951b0eb5ae..5337f0058b 100644 --- a/calendar/gncal-day-view.c +++ b/calendar/gncal-day-view.c @@ -114,7 +114,7 @@ gncal_day_view_new (GnomeCalendar *calendar, time_t lower, time_t upper) dview->upper = upper; dview->events = 0; - gncal_day_view_update (dview); + gncal_day_view_update (dview, NULL, 0); return GTK_WIDGET (dview); } @@ -284,7 +284,7 @@ gncal_day_view_expose (GtkWidget *widget, GdkEventExpose *event) } void -gncal_day_view_update (GncalDayView *dview) +gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags) { struct tm tm; char buf[256]; @@ -323,7 +323,7 @@ gncal_day_view_set_bounds (GncalDayView *dview, time_t lower, time_t upper) dview->lower = lower; dview->upper = upper; - gncal_day_view_update (dview); + gncal_day_view_update (dview, NULL, 0); } } diff --git a/calendar/gncal-day-view.h b/calendar/gncal-day-view.h index 80e8a6299f..f2a4ae6e93 100644 --- a/calendar/gncal-day-view.h +++ b/calendar/gncal-day-view.h @@ -46,7 +46,7 @@ struct _GncalDayViewClass { guint gncal_day_view_get_type (void); GtkWidget *gncal_day_view_new (GnomeCalendar *calendar, time_t lower, time_t upper); -void gncal_day_view_update (GncalDayView *dview); +void gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags); void gncal_day_view_set_bounds (GncalDayView *dview, time_t lower, time_t upper); void gncal_day_view_set_shadow (GncalDayView *dview, GtkShadowType shadow_type); diff --git a/calendar/gncal-full-day.c b/calendar/gncal-full-day.c index f32c8c482c..ce64db9173 100644 --- a/calendar/gncal-full-day.c +++ b/calendar/gncal-full-day.c @@ -14,7 +14,7 @@ #define TEXT_BORDER 2 -#define HANDLE_SIZE 3 +#define HANDLE_SIZE 8 #define MIN_WIDTH 200 #define XOR_RECT_WIDTH 2 #define UNSELECT_TIMEOUT 150 /* ms */ @@ -173,9 +173,9 @@ child_set_text_pos (Child *child) GtkAllocation allocation; allocation.x = 0; - allocation.y = HANDLE_SIZE; + allocation.y = (GTK_WIDGET_HAS_FOCUS (child->widget) ? HANDLE_SIZE : 0); allocation.width = child->width; - allocation.height = child->height - 2 * HANDLE_SIZE; + allocation.height = child->height - (GTK_WIDGET_HAS_FOCUS (child->widget) ? (2 * HANDLE_SIZE) : 0); gtk_widget_size_request (child->widget, &child->widget->requisition); /* FIXME: is this needed? */ gtk_widget_size_allocate (child->widget, &allocation); @@ -297,18 +297,43 @@ child_realized_setup (GtkWidget *widget, gpointer data) } static gint +child_focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer data) +{ + Child *child; + + child = data; + + /* Paint handles on child */ + + child_set_text_pos (child); + + return FALSE; +} + +static gint child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data) { Child *child; + GncalFullDay *fullday; child = data; + /* Update summary in calendar object */ + if (child->ico->summary) g_free (child->ico->summary); child->ico->summary = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1); - /* FIXME: need notify calendar of change? */ + /* Erase handles from child */ + + child_set_text_pos (child); + + /* Notify calendar of change */ + + fullday = gtk_object_get_user_data (GTK_OBJECT (widget)); + + gnome_calendar_object_changed (fullday->calendar, child->ico, CHANGE_SUMMARY); return FALSE; } @@ -328,6 +353,8 @@ child_new (GncalFullDay *fullday, iCalObject *ico) child->width = 0; child->height = 0; + gtk_object_set_user_data (GTK_OBJECT (child->widget), fullday); + child_range_changed (fullday, child); /* We set the i-beam cursor and the initial summary text upon realization */ @@ -336,11 +363,13 @@ child_new (GncalFullDay *fullday, iCalObject *ico) (GtkSignalFunc) child_realized_setup, child); - /* Update the iCalObject summary when the text widget loses focus */ + gtk_signal_connect_after (GTK_OBJECT (child->widget), "focus_in_event", + (GtkSignalFunc) child_focus_in, + child); - gtk_signal_connect (GTK_OBJECT (child->widget), "focus_out_event", - (GtkSignalFunc) child_focus_out, - child); + gtk_signal_connect_after (GTK_OBJECT (child->widget), "focus_out_event", + (GtkSignalFunc) child_focus_out, + child); /* Finish setup */ @@ -1354,7 +1383,7 @@ update_from_drag_info (GncalFullDay *fullday) /* Notify calendar of change */ - gnome_calendar_object_changed (fullday->calendar, di->child->ico); + gnome_calendar_object_changed (fullday->calendar, di->child->ico, CHANGE_DATES); } static gint @@ -1569,7 +1598,7 @@ gncal_full_day_foreach (GtkContainer *container, GtkCallback callback, gpointer } void -gncal_full_day_update (GncalFullDay *fullday) +gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags) { GList *children; GList *l_events, *events; @@ -1581,6 +1610,24 @@ gncal_full_day_update (GncalFullDay *fullday) if (!fullday->calendar->cal) return; + /* Try to find child that changed */ + + for (children = fullday->children; children; children = children->next) { + child = children->data; + + if (child->ico == ico) + break; + } + + /* If child was found and nothing but the summary changed, we can just paint the child and return */ + + if (children && !(flags & ~CHANGE_SUMMARY)) { + child_draw (fullday, child, NULL, TRUE); + return; + } + + /* We have to regenerate and layout our list of children */ + for (children = fullday->children; children; children = children->next) child_destroy (fullday, children->data); @@ -1633,7 +1680,7 @@ gncal_full_day_set_bounds (GncalFullDay *fullday, time_t lower, time_t upper) di->sel_rows_used = 0; /* clear selection */ - gncal_full_day_update (fullday); + gncal_full_day_update (fullday, NULL, 0); } } @@ -1663,19 +1710,19 @@ gncal_full_day_selection_range (GncalFullDay *fullday, time_t *lower, time_t *up } void -gncal_full_day_focus_child (GncalFullDay *fullday, iCalObject *object) +gncal_full_day_focus_child (GncalFullDay *fullday, iCalObject *ico) { GList *children; Child *child; GdkEvent event; g_return_if_fail (fullday != NULL); - g_return_if_fail (object != NULL); + g_return_if_fail (ico != NULL); for (children = fullday->children; children; children = children->next) { child = children->data; - if (child->ico == object) { + if (child->ico == ico) { gtk_widget_grab_focus (child->widget); /* We synthesize a click because GtkText will not set the cursor and diff --git a/calendar/gncal-full-day.h b/calendar/gncal-full-day.h index 289accd136..1e8e779582 100644 --- a/calendar/gncal-full-day.h +++ b/calendar/gncal-full-day.h @@ -52,7 +52,7 @@ struct _GncalFullDayClass { guint gncal_full_day_get_type (void); GtkWidget *gncal_full_day_new (GnomeCalendar *calendar, time_t lower, time_t upper); -void gncal_full_day_update (GncalFullDay *fullday); +void gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags); void gncal_full_day_set_bounds (GncalFullDay *fullday, time_t lower, time_t upper); /* Returns the selected range in lower and upper. If nothing is @@ -60,7 +60,7 @@ void gncal_full_day_set_bounds (GncalFullDay *fullday, time_t lower, */ int gncal_full_day_selection_range (GncalFullDay *fullday, time_t *lower, time_t *upper); -void gncal_full_day_focus_child (GncalFullDay *fullday, iCalObject *object); +void gncal_full_day_focus_child (GncalFullDay *fullday, iCalObject *ico); END_GNOME_DECLS diff --git a/calendar/gncal-week-view.c b/calendar/gncal-week-view.c index 4adf7ba283..1cf35fac5f 100644 --- a/calendar/gncal-week-view.c +++ b/calendar/gncal-week-view.c @@ -105,24 +105,24 @@ gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week) } static void -update (GncalWeekView *wview, int update_days) +update (GncalWeekView *wview, int update_days, iCalObject *object, int flags) { int i; if (update_days) for (i = 0; i < 7; i++) - gncal_day_view_update (wview->days[i]); + gncal_day_view_update (wview->days[i], object, flags); /* FIXME: update extra widgets */ } void -gncal_week_view_update (GncalWeekView *wview) +gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags) { g_return_if_fail (wview != NULL); g_return_if_fail (GNCAL_IS_WEEK_VIEW (wview)); - update (wview, TRUE); + update (wview, TRUE, ico, flags); } void @@ -166,5 +166,5 @@ gncal_week_view_set (GncalWeekView *wview, time_t start_of_week) day_start = day_end; } - update (wview, FALSE); + update (wview, FALSE, NULL, 0); } diff --git a/calendar/gncal-week-view.h b/calendar/gncal-week-view.h index 6bf29e40c4..81bc44c816 100644 --- a/calendar/gncal-week-view.h +++ b/calendar/gncal-week-view.h @@ -42,11 +42,11 @@ struct _GncalWeekViewClass { }; -guint gncal_week_view_get_type (void); -GtkWidget *gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week); +guint gncal_week_view_get_type (void); +GtkWidget *gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week); -void gncal_week_view_update (GncalWeekView *wview); -void gncal_week_view_set (GncalWeekView *wview, time_t start_of_week); +void gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags); +void gncal_week_view_set (GncalWeekView *wview, time_t start_of_week); END_GNOME_DECLS diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c index 6a9b7b044f..0b2da0a0e2 100644 --- a/calendar/gnome-cal.c +++ b/calendar/gnome-cal.c @@ -185,18 +185,18 @@ gnome_calendar_new (char *title) return retval; } -void -gnome_calendar_update_all (GnomeCalendar *cal) +static void +gnome_calendar_update_all (GnomeCalendar *cal, iCalObject *object, int flags) { - gncal_full_day_update (GNCAL_FULL_DAY (cal->day_view)); - gncal_week_view_update (GNCAL_WEEK_VIEW (cal->week_view)); + gncal_full_day_update (GNCAL_FULL_DAY (cal->day_view), object, flags); + gncal_week_view_update (GNCAL_WEEK_VIEW (cal->week_view), object, flags); } void gnome_calendar_load (GnomeCalendar *gcal, char *file) { calendar_load (gcal->cal, file); - gnome_calendar_update_all (gcal); + gnome_calendar_update_all (gcal, NULL, 0); } void @@ -205,11 +205,11 @@ gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj) printf ("Adding object at: "); print_time_t (obj->dtstart); calendar_add_object (gcal->cal, obj); - gnome_calendar_update_all (gcal); + gnome_calendar_update_all (gcal, obj, CHANGE_NEW); } void -gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj) +gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags) { g_return_if_fail (gcal != NULL); g_return_if_fail (GNOME_IS_CALENDAR (gcal)); @@ -222,5 +222,5 @@ gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj) gcal->cal->modified = TRUE; - gnome_calendar_update_all (gcal); + gnome_calendar_update_all (gcal, obj, flags); } diff --git a/calendar/gnome-cal.h b/calendar/gnome-cal.h index 5a4d8e8d09..8e765bda15 100644 --- a/calendar/gnome-cal.h +++ b/calendar/gnome-cal.h @@ -42,7 +42,9 @@ void gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj); void gnome_calendar_next (GnomeCalendar *gcal); void gnome_calendar_previous (GnomeCalendar *gcal); void gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time); -void gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj); + +/* Flags is a bitmask of CalObjectChange values */ +void gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags); END_GNOME_DECLS diff --git a/calendar/gui/gncal-day-view.c b/calendar/gui/gncal-day-view.c index 951b0eb5ae..5337f0058b 100644 --- a/calendar/gui/gncal-day-view.c +++ b/calendar/gui/gncal-day-view.c @@ -114,7 +114,7 @@ gncal_day_view_new (GnomeCalendar *calendar, time_t lower, time_t upper) dview->upper = upper; dview->events = 0; - gncal_day_view_update (dview); + gncal_day_view_update (dview, NULL, 0); return GTK_WIDGET (dview); } @@ -284,7 +284,7 @@ gncal_day_view_expose (GtkWidget *widget, GdkEventExpose *event) } void -gncal_day_view_update (GncalDayView *dview) +gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags) { struct tm tm; char buf[256]; @@ -323,7 +323,7 @@ gncal_day_view_set_bounds (GncalDayView *dview, time_t lower, time_t upper) dview->lower = lower; dview->upper = upper; - gncal_day_view_update (dview); + gncal_day_view_update (dview, NULL, 0); } } diff --git a/calendar/gui/gncal-day-view.h b/calendar/gui/gncal-day-view.h index 80e8a6299f..f2a4ae6e93 100644 --- a/calendar/gui/gncal-day-view.h +++ b/calendar/gui/gncal-day-view.h @@ -46,7 +46,7 @@ struct _GncalDayViewClass { guint gncal_day_view_get_type (void); GtkWidget *gncal_day_view_new (GnomeCalendar *calendar, time_t lower, time_t upper); -void gncal_day_view_update (GncalDayView *dview); +void gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags); void gncal_day_view_set_bounds (GncalDayView *dview, time_t lower, time_t upper); void gncal_day_view_set_shadow (GncalDayView *dview, GtkShadowType shadow_type); diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c index f32c8c482c..ce64db9173 100644 --- a/calendar/gui/gncal-full-day.c +++ b/calendar/gui/gncal-full-day.c @@ -14,7 +14,7 @@ #define TEXT_BORDER 2 -#define HANDLE_SIZE 3 +#define HANDLE_SIZE 8 #define MIN_WIDTH 200 #define XOR_RECT_WIDTH 2 #define UNSELECT_TIMEOUT 150 /* ms */ @@ -173,9 +173,9 @@ child_set_text_pos (Child *child) GtkAllocation allocation; allocation.x = 0; - allocation.y = HANDLE_SIZE; + allocation.y = (GTK_WIDGET_HAS_FOCUS (child->widget) ? HANDLE_SIZE : 0); allocation.width = child->width; - allocation.height = child->height - 2 * HANDLE_SIZE; + allocation.height = child->height - (GTK_WIDGET_HAS_FOCUS (child->widget) ? (2 * HANDLE_SIZE) : 0); gtk_widget_size_request (child->widget, &child->widget->requisition); /* FIXME: is this needed? */ gtk_widget_size_allocate (child->widget, &allocation); @@ -297,18 +297,43 @@ child_realized_setup (GtkWidget *widget, gpointer data) } static gint +child_focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer data) +{ + Child *child; + + child = data; + + /* Paint handles on child */ + + child_set_text_pos (child); + + return FALSE; +} + +static gint child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data) { Child *child; + GncalFullDay *fullday; child = data; + /* Update summary in calendar object */ + if (child->ico->summary) g_free (child->ico->summary); child->ico->summary = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1); - /* FIXME: need notify calendar of change? */ + /* Erase handles from child */ + + child_set_text_pos (child); + + /* Notify calendar of change */ + + fullday = gtk_object_get_user_data (GTK_OBJECT (widget)); + + gnome_calendar_object_changed (fullday->calendar, child->ico, CHANGE_SUMMARY); return FALSE; } @@ -328,6 +353,8 @@ child_new (GncalFullDay *fullday, iCalObject *ico) child->width = 0; child->height = 0; + gtk_object_set_user_data (GTK_OBJECT (child->widget), fullday); + child_range_changed (fullday, child); /* We set the i-beam cursor and the initial summary text upon realization */ @@ -336,11 +363,13 @@ child_new (GncalFullDay *fullday, iCalObject *ico) (GtkSignalFunc) child_realized_setup, child); - /* Update the iCalObject summary when the text widget loses focus */ + gtk_signal_connect_after (GTK_OBJECT (child->widget), "focus_in_event", + (GtkSignalFunc) child_focus_in, + child); - gtk_signal_connect (GTK_OBJECT (child->widget), "focus_out_event", - (GtkSignalFunc) child_focus_out, - child); + gtk_signal_connect_after (GTK_OBJECT (child->widget), "focus_out_event", + (GtkSignalFunc) child_focus_out, + child); /* Finish setup */ @@ -1354,7 +1383,7 @@ update_from_drag_info (GncalFullDay *fullday) /* Notify calendar of change */ - gnome_calendar_object_changed (fullday->calendar, di->child->ico); + gnome_calendar_object_changed (fullday->calendar, di->child->ico, CHANGE_DATES); } static gint @@ -1569,7 +1598,7 @@ gncal_full_day_foreach (GtkContainer *container, GtkCallback callback, gpointer } void -gncal_full_day_update (GncalFullDay *fullday) +gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags) { GList *children; GList *l_events, *events; @@ -1581,6 +1610,24 @@ gncal_full_day_update (GncalFullDay *fullday) if (!fullday->calendar->cal) return; + /* Try to find child that changed */ + + for (children = fullday->children; children; children = children->next) { + child = children->data; + + if (child->ico == ico) + break; + } + + /* If child was found and nothing but the summary changed, we can just paint the child and return */ + + if (children && !(flags & ~CHANGE_SUMMARY)) { + child_draw (fullday, child, NULL, TRUE); + return; + } + + /* We have to regenerate and layout our list of children */ + for (children = fullday->children; children; children = children->next) child_destroy (fullday, children->data); @@ -1633,7 +1680,7 @@ gncal_full_day_set_bounds (GncalFullDay *fullday, time_t lower, time_t upper) di->sel_rows_used = 0; /* clear selection */ - gncal_full_day_update (fullday); + gncal_full_day_update (fullday, NULL, 0); } } @@ -1663,19 +1710,19 @@ gncal_full_day_selection_range (GncalFullDay *fullday, time_t *lower, time_t *up } void -gncal_full_day_focus_child (GncalFullDay *fullday, iCalObject *object) +gncal_full_day_focus_child (GncalFullDay *fullday, iCalObject *ico) { GList *children; Child *child; GdkEvent event; g_return_if_fail (fullday != NULL); - g_return_if_fail (object != NULL); + g_return_if_fail (ico != NULL); for (children = fullday->children; children; children = children->next) { child = children->data; - if (child->ico == object) { + if (child->ico == ico) { gtk_widget_grab_focus (child->widget); /* We synthesize a click because GtkText will not set the cursor and diff --git a/calendar/gui/gncal-full-day.h b/calendar/gui/gncal-full-day.h index 289accd136..1e8e779582 100644 --- a/calendar/gui/gncal-full-day.h +++ b/calendar/gui/gncal-full-day.h @@ -52,7 +52,7 @@ struct _GncalFullDayClass { guint gncal_full_day_get_type (void); GtkWidget *gncal_full_day_new (GnomeCalendar *calendar, time_t lower, time_t upper); -void gncal_full_day_update (GncalFullDay *fullday); +void gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags); void gncal_full_day_set_bounds (GncalFullDay *fullday, time_t lower, time_t upper); /* Returns the selected range in lower and upper. If nothing is @@ -60,7 +60,7 @@ void gncal_full_day_set_bounds (GncalFullDay *fullday, time_t lower, */ int gncal_full_day_selection_range (GncalFullDay *fullday, time_t *lower, time_t *upper); -void gncal_full_day_focus_child (GncalFullDay *fullday, iCalObject *object); +void gncal_full_day_focus_child (GncalFullDay *fullday, iCalObject *ico); END_GNOME_DECLS diff --git a/calendar/gui/gncal-week-view.c b/calendar/gui/gncal-week-view.c index 4adf7ba283..1cf35fac5f 100644 --- a/calendar/gui/gncal-week-view.c +++ b/calendar/gui/gncal-week-view.c @@ -105,24 +105,24 @@ gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week) } static void -update (GncalWeekView *wview, int update_days) +update (GncalWeekView *wview, int update_days, iCalObject *object, int flags) { int i; if (update_days) for (i = 0; i < 7; i++) - gncal_day_view_update (wview->days[i]); + gncal_day_view_update (wview->days[i], object, flags); /* FIXME: update extra widgets */ } void -gncal_week_view_update (GncalWeekView *wview) +gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags) { g_return_if_fail (wview != NULL); g_return_if_fail (GNCAL_IS_WEEK_VIEW (wview)); - update (wview, TRUE); + update (wview, TRUE, ico, flags); } void @@ -166,5 +166,5 @@ gncal_week_view_set (GncalWeekView *wview, time_t start_of_week) day_start = day_end; } - update (wview, FALSE); + update (wview, FALSE, NULL, 0); } diff --git a/calendar/gui/gncal-week-view.h b/calendar/gui/gncal-week-view.h index 6bf29e40c4..81bc44c816 100644 --- a/calendar/gui/gncal-week-view.h +++ b/calendar/gui/gncal-week-view.h @@ -42,11 +42,11 @@ struct _GncalWeekViewClass { }; -guint gncal_week_view_get_type (void); -GtkWidget *gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week); +guint gncal_week_view_get_type (void); +GtkWidget *gncal_week_view_new (GnomeCalendar *calendar, time_t start_of_week); -void gncal_week_view_update (GncalWeekView *wview); -void gncal_week_view_set (GncalWeekView *wview, time_t start_of_week); +void gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags); +void gncal_week_view_set (GncalWeekView *wview, time_t start_of_week); END_GNOME_DECLS diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 6a9b7b044f..0b2da0a0e2 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -185,18 +185,18 @@ gnome_calendar_new (char *title) return retval; } -void -gnome_calendar_update_all (GnomeCalendar *cal) +static void +gnome_calendar_update_all (GnomeCalendar *cal, iCalObject *object, int flags) { - gncal_full_day_update (GNCAL_FULL_DAY (cal->day_view)); - gncal_week_view_update (GNCAL_WEEK_VIEW (cal->week_view)); + gncal_full_day_update (GNCAL_FULL_DAY (cal->day_view), object, flags); + gncal_week_view_update (GNCAL_WEEK_VIEW (cal->week_view), object, flags); } void gnome_calendar_load (GnomeCalendar *gcal, char *file) { calendar_load (gcal->cal, file); - gnome_calendar_update_all (gcal); + gnome_calendar_update_all (gcal, NULL, 0); } void @@ -205,11 +205,11 @@ gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj) printf ("Adding object at: "); print_time_t (obj->dtstart); calendar_add_object (gcal->cal, obj); - gnome_calendar_update_all (gcal); + gnome_calendar_update_all (gcal, obj, CHANGE_NEW); } void -gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj) +gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags) { g_return_if_fail (gcal != NULL); g_return_if_fail (GNOME_IS_CALENDAR (gcal)); @@ -222,5 +222,5 @@ gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj) gcal->cal->modified = TRUE; - gnome_calendar_update_all (gcal); + gnome_calendar_update_all (gcal, obj, flags); } diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 5a4d8e8d09..8e765bda15 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -42,7 +42,9 @@ void gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj); void gnome_calendar_next (GnomeCalendar *gcal); void gnome_calendar_previous (GnomeCalendar *gcal); void gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time); -void gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj); + +/* Flags is a bitmask of CalObjectChange values */ +void gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags); END_GNOME_DECLS diff --git a/calendar/pcs/calobj.h b/calendar/pcs/calobj.h index 37ea79040d..7dc810b459 100644 --- a/calendar/pcs/calobj.h +++ b/calendar/pcs/calobj.h @@ -85,6 +85,13 @@ typedef struct { int frequency; } Recurrence; +/* Flags to indicate what has changed in an object */ +typedef enum { + CHANGE_NEW = 1 << 0, /* new object */ + CHANGE_SUMMARY = 1 << 1, /* summary */ + CHANGE_DATES = 1 << 2 /* dtstart / dtend */ +} CalObjectChange; + /* * This describes an iCalendar object, note that we never store durations, instead we * always compute the end time computed from the start + duration. |