diff options
author | Federico Mena Quintero <federico@nuclecu.unam.mx> | 1998-04-09 15:36:54 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1998-04-09 15:36:54 +0800 |
commit | a4b297a8d4fbcbfc6afe5df3b8844d3e3fbce8c3 (patch) | |
tree | f67e1349246b009e89f8a2e819b99908394b0268 /calendar | |
parent | 8e5a66e2c304f3cae73838495868941b6f66c7dc (diff) | |
download | gsoc2013-evolution-a4b297a8d4fbcbfc6afe5df3b8844d3e3fbce8c3.tar gsoc2013-evolution-a4b297a8d4fbcbfc6afe5df3b8844d3e3fbce8c3.tar.gz gsoc2013-evolution-a4b297a8d4fbcbfc6afe5df3b8844d3e3fbce8c3.tar.bz2 gsoc2013-evolution-a4b297a8d4fbcbfc6afe5df3b8844d3e3fbce8c3.tar.lz gsoc2013-evolution-a4b297a8d4fbcbfc6afe5df3b8844d3e3fbce8c3.tar.xz gsoc2013-evolution-a4b297a8d4fbcbfc6afe5df3b8844d3e3fbce8c3.tar.zst gsoc2013-evolution-a4b297a8d4fbcbfc6afe5df3b8844d3e3fbce8c3.zip |
Show instead of just map the child widget (otherwise the text widget gets
1998-04-09 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gncal-full-day.c (child_map): Show instead of just map the child
widget (otherwise the text widget gets confused and will not focus).
* calobj.c (ical_object_to_vobject): Quote chars as 'x', not "x".
* calobj.h: Added prototype for ical_object_to_vobject().
* gnome-cal.c (gnome_calendar_object_changed): New function. This
should be called when a calendar object is changed.
* gncal-full-day.c (update_from_drag_info): Call
gnome_calendar_object_changed() instead of updating manually.
* calendar.c (calendar_add_object):
(calendar_remove_object): Set the modified flag to true.
* gncal-full-day.c (gncal_full_day_draw): Finished implementing
this function.
svn path=/trunk/; revision=120
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 21 | ||||
-rw-r--r-- | calendar/TODO | 5 | ||||
-rw-r--r-- | calendar/cal-util/calobj.c | 5 | ||||
-rw-r--r-- | calendar/cal-util/calobj.h | 1 | ||||
-rw-r--r-- | calendar/calendar.c | 6 | ||||
-rw-r--r-- | calendar/calendar.h | 18 | ||||
-rw-r--r-- | calendar/calobj.c | 5 | ||||
-rw-r--r-- | calendar/calobj.h | 1 | ||||
-rw-r--r-- | calendar/gncal-full-day.c | 262 | ||||
-rw-r--r-- | calendar/gnome-cal.c | 19 | ||||
-rw-r--r-- | calendar/gnome-cal.h | 15 | ||||
-rw-r--r-- | calendar/gui/calendar.c | 6 | ||||
-rw-r--r-- | calendar/gui/calendar.h | 18 | ||||
-rw-r--r-- | calendar/gui/gncal-full-day.c | 262 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 19 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.h | 15 | ||||
-rw-r--r-- | calendar/gui/test.vcf | 8 | ||||
-rw-r--r-- | calendar/pcs/calobj.c | 5 | ||||
-rw-r--r-- | calendar/pcs/calobj.h | 1 | ||||
-rw-r--r-- | calendar/test.vcf | 8 |
20 files changed, 401 insertions, 299 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 26f1712396..9f5ab624cf 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,24 @@ +1998-04-09 Federico Mena Quintero <federico@nuclecu.unam.mx> + + * gncal-full-day.c (child_map): Show instead of just map the child + widget (otherwise the text widget gets confused and will not focus). + + * calobj.c (ical_object_to_vobject): Quote chars as 'x', not "x". + + * calobj.h: Added prototype for ical_object_to_vobject(). + + * gnome-cal.c (gnome_calendar_object_changed): New function. This + should be called when a calendar object is changed. + + * gncal-full-day.c (update_from_drag_info): Call + gnome_calendar_object_changed() instead of updating manually. + + * calendar.c (calendar_add_object): + (calendar_remove_object): Set the modified flag to true. + + * gncal-full-day.c (gncal_full_day_draw): Finished implementing + this function. + 1998-04-08 Raja R Harinath <harinath@cs.umn.edu> * gncal.c (update_calendar): Say `#if 0', not `#ifdef 0'. diff --git a/calendar/TODO b/calendar/TODO index 23be8e5b32..f4f2c2148f 100644 --- a/calendar/TODO +++ b/calendar/TODO @@ -15,8 +15,9 @@ Event editor dialog: Full day view widget: -- Notify the calendar when a child changes. Look for the FIXMEs in - the code. +- Check notification to calendar when an object changes. Maybe we + need some flags to tell gnome_calendar_object_changed() whether + summary/dates/etc. changed. Maybe not. - Select a range in the full day `background' and hit enter to create a new appointment in that date. diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c index 8c5605c688..8504d7a95b 100644 --- a/calendar/cal-util/calobj.c +++ b/calendar/cal-util/calobj.c @@ -349,7 +349,7 @@ ical_object_to_vobject (iCalObject *ical) /* resources */ if (ical->categories) - store_list (o, VCCategoriesProp, ical->resources, ";"); + store_list (o, VCCategoriesProp, ical->resources, ';'); /* priority */ addPropValue (o, VCPriorityProp, to_str (ical->priority)); @@ -358,7 +358,7 @@ ical_object_to_vobject (iCalObject *ical) addPropValue (o, VCTranspProp, to_str (ical->transp)); /* related */ - store_list (o, VCRelatedToProp, ical->related, ";"); + store_list (o, VCRelatedToProp, ical->related, ';'); /* attach */ for (l = ical->attach; l; l = l->next) @@ -371,4 +371,3 @@ ical_object_to_vobject (iCalObject *ical) /* FIXME: alarms */ return o; } - diff --git a/calendar/cal-util/calobj.h b/calendar/cal-util/calobj.h index 00dbd5c63e..0fe85c6ca3 100644 --- a/calendar/cal-util/calobj.h +++ b/calendar/cal-util/calobj.h @@ -120,6 +120,7 @@ iCalObject *ical_new (char *comment, char *organizer, char *summary); iCalObject *ical_object_new (void); void ical_object_destroy (iCalObject *ico); iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name); +VObject *ical_object_to_vobject (iCalObject *ical); END_GNOME_DECLS diff --git a/calendar/calendar.c b/calendar/calendar.c index c06414a571..ebece3aadc 100644 --- a/calendar/calendar.c +++ b/calendar/calendar.c @@ -48,6 +48,10 @@ calendar_add_object (Calendar *cal, iCalObject *obj) default: g_assert_not_reached (); } + + cal->modified = TRUE; + + /* FIXME: do we have to set the last_mod field in the object? */ } void @@ -68,6 +72,8 @@ calendar_remove_object (Calendar *cal, iCalObject *obj) default: g_assert_not_reached (); } + + cal->modified = TRUE; } void diff --git a/calendar/calendar.h b/calendar/calendar.h index 8f4e4c1497..f93946315c 100644 --- a/calendar/calendar.h +++ b/calendar/calendar.h @@ -17,15 +17,15 @@ typedef struct { void *temp; } Calendar; -Calendar *calendar_new (char *title); -void calendar_load (Calendar *cal, char *fname); -void calendar_add_object (Calendar *cal, iCalObject *obj); -void calendar_remove_object (Calendar *cal, iCalObject *obj); -void calendar_destroy (Calendar *cal); -GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); -GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); -GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); -gint calendar_compare_by_dtstart (gpointer a, gpointer b); +Calendar *calendar_new (char *title); +void calendar_load (Calendar *cal, char *fname); +void calendar_add_object (Calendar *cal, iCalObject *obj); +void calendar_remove_object (Calendar *cal, iCalObject *obj); +void calendar_destroy (Calendar *cal); +GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); +GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); +GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); +gint calendar_compare_by_dtstart (gpointer a, gpointer b); END_GNOME_DECLS diff --git a/calendar/calobj.c b/calendar/calobj.c index 8c5605c688..8504d7a95b 100644 --- a/calendar/calobj.c +++ b/calendar/calobj.c @@ -349,7 +349,7 @@ ical_object_to_vobject (iCalObject *ical) /* resources */ if (ical->categories) - store_list (o, VCCategoriesProp, ical->resources, ";"); + store_list (o, VCCategoriesProp, ical->resources, ';'); /* priority */ addPropValue (o, VCPriorityProp, to_str (ical->priority)); @@ -358,7 +358,7 @@ ical_object_to_vobject (iCalObject *ical) addPropValue (o, VCTranspProp, to_str (ical->transp)); /* related */ - store_list (o, VCRelatedToProp, ical->related, ";"); + store_list (o, VCRelatedToProp, ical->related, ';'); /* attach */ for (l = ical->attach; l; l = l->next) @@ -371,4 +371,3 @@ ical_object_to_vobject (iCalObject *ical) /* FIXME: alarms */ return o; } - diff --git a/calendar/calobj.h b/calendar/calobj.h index 00dbd5c63e..0fe85c6ca3 100644 --- a/calendar/calobj.h +++ b/calendar/calobj.h @@ -120,6 +120,7 @@ iCalObject *ical_new (char *comment, char *organizer, char *summary); iCalObject *ical_object_new (void); void ical_object_destroy (iCalObject *ico); iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name); +VObject *ical_object_to_vobject (iCalObject *ical); END_GNOME_DECLS diff --git a/calendar/gncal-full-day.c b/calendar/gncal-full-day.c index 90a4813947..db743431ee 100644 --- a/calendar/gncal-full-day.c +++ b/calendar/gncal-full-day.c @@ -127,9 +127,7 @@ static void child_map (GncalFullDay *fullday, Child *child) { gdk_window_show (child->window); - - if (!GTK_WIDGET_MAPPED (child->widget)) - gtk_widget_map (child->widget); + gtk_widget_show (child->widget); /* OK, not just a map... */ } static void @@ -203,16 +201,13 @@ static void child_draw (GncalFullDay *fullday, Child *child, GdkRectangle *area, int draw_child) { GdkRectangle arect, rect, dest; - gint w, h; - - gdk_window_get_size (child->window, &w, &h); if (!area) { arect.x = 0; arect.y = 0; - arect.width = w; - arect.height = h; + arect.width = child->width; + arect.height = child->height; area = &arect; } @@ -221,7 +216,7 @@ child_draw (GncalFullDay *fullday, Child *child, GdkRectangle *area, int draw_ch rect.x = 0; rect.y = 0; - rect.width = w; + rect.width = child->width; rect.height = HANDLE_SIZE; if (gdk_rectangle_intersect (&rect, area, &dest)) @@ -229,7 +224,7 @@ child_draw (GncalFullDay *fullday, Child *child, GdkRectangle *area, int draw_ch /* Bottom handle */ - rect.y = h - HANDLE_SIZE; + rect.y = child->height - HANDLE_SIZE; if (gdk_rectangle_intersect (&rect, area, &dest)) view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window, &rect, GTK_SHADOW_OUT); @@ -284,6 +279,8 @@ child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data) child->ico->summary = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1); + /* FIXME: need notify calendar of change? */ + return FALSE; } @@ -457,11 +454,10 @@ calc_labels_width (GncalFullDay *fullday) } static void -layout_child (GncalFullDay *fullday, Child *child, struct layout_row *rows) +layout_child (GncalFullDay *fullday, Child *child, struct layout_row *rows, int left_x) { - int c_x, c_y, c_width, c_height; + int c_y, c_width, c_height; GtkWidget *widget; - int labels_width; int height, f_rows; int row_height; @@ -469,26 +465,23 @@ layout_child (GncalFullDay *fullday, Child *child, struct layout_row *rows) widget = GTK_WIDGET (fullday); - labels_width = calc_labels_width (fullday); /* FIXME: this is expensive to do for each child */ - get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows); height = widget->allocation.height - 2 * widget->style->klass->ythickness; row_height = height / f_rows; - c_x = 2 * (widget->style->klass->xthickness + TEXT_BORDER) + labels_width; c_y = widget->style->klass->ythickness; /* FIXME: for now, the children overlap. Make it layout them nicely. */ - c_width = widget->allocation.width - (widget->style->klass->xthickness + c_x); + c_width = widget->allocation.width - (widget->style->klass->xthickness + left_x); c_y += child->lower_row * row_height; c_height = child->rows_used * row_height; /* Position child */ - child_set_pos (fullday, child, c_x, c_y, c_width, c_height); + child_set_pos (fullday, child, left_x, c_y, c_width, c_height); } static void @@ -496,11 +489,17 @@ layout_children (GncalFullDay *fullday) { struct layout_row *rows; GList *children; + GtkWidget *widget; + int left_x; rows = layout_get_rows (fullday); + widget = GTK_WIDGET (fullday); + + left_x = 2 * (widget->style->klass->xthickness + TEXT_BORDER) + calc_labels_width (fullday); + for (children = fullday->children; children; children = children->next) - layout_child (fullday, children->data, rows); + layout_child (fullday, children->data, rows, left_x); g_free (rows); } @@ -722,9 +721,111 @@ gncal_full_day_unrealize (GtkWidget *widget) } static void +paint_back (GncalFullDay *fullday, GdkRectangle *area) +{ + GtkWidget *widget; + GdkRectangle rect, dest; + int x1, y1, width, height; + int labels_width, division_x; + int rows, row_height; + int i, y; + struct tm tm; + char buf[256]; + + widget = GTK_WIDGET (fullday); + + x1 = widget->style->klass->xthickness; + y1 = widget->style->klass->ythickness; + width = widget->allocation.width - 2 * x1; + height = widget->allocation.height - 2 * y1; + + /* Clear and paint frame shadow */ + + gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); + + gtk_draw_shadow (widget->style, widget->window, + GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_IN, + 0, 0, + widget->allocation.width, + widget->allocation.height); + + /* Clear space for labels */ + + labels_width = calc_labels_width (fullday); + + rect.x = x1; + rect.y = y1; + rect.width = 2 * TEXT_BORDER + labels_width; + rect.height = height; + + if (gdk_rectangle_intersect (&rect, area, &dest)) + gdk_draw_rectangle (widget->window, + widget->style->bg_gc[GTK_STATE_NORMAL], + TRUE, + dest.x, dest.y, + dest.width, dest.height); + + /* Vertical division */ + + division_x = x1 + 2 * TEXT_BORDER + labels_width; + + gtk_draw_vline (widget->style, widget->window, + GTK_STATE_NORMAL, + y1, + y1 + height - 1, + division_x); + + /* Horizontal divisions */ + + get_tm_range (fullday, fullday->lower, fullday->upper, &tm, NULL, NULL, &rows); + + row_height = height / rows; /* includes division line at bottom of row */ + + y = y1 + row_height - 1; + + for (i = 1; i < rows; i++) { + gdk_draw_line (widget->window, + widget->style->black_gc, + x1, y, + x1 + width - 1, y); + + y += row_height; + } + + /* Labels */ + + y = y1 + ((row_height - 1) - (widget->style->font->ascent + widget->style->font->descent)) / 2; + + rect.height = row_height - 1; + + for (i = 0; i < rows; i++) { + mktime (&tm); + + if (gdk_rectangle_intersect (&rect, area, &dest)) { + strftime (buf, 256, "%X", &tm); + + gdk_draw_string (widget->window, + widget->style->font, + widget->style->fg_gc[GTK_STATE_NORMAL], + x1 + TEXT_BORDER, + y + widget->style->font->ascent, + buf); + } + + rect.y += row_height; + y += row_height; + + tm.tm_min += fullday->interval; + } +} + +static void gncal_full_day_draw (GtkWidget *widget, GdkRectangle *area) { GncalFullDay *fullday; + GList *children; + Child *child; + GdkRectangle rect, dest; g_return_if_fail (widget != NULL); g_return_if_fail (GNCAL_IS_FULL_DAY (widget)); @@ -735,7 +836,23 @@ gncal_full_day_draw (GtkWidget *widget, GdkRectangle *area) fullday = GNCAL_FULL_DAY (widget); - /* FIXME */ + paint_back (fullday, area); + + for (children = fullday->children; children; children = children->next) { + child = children->data; + + rect.x = child->x; + rect.y = child->y; + rect.width = child->width; + rect.height = child->height; + + if (gdk_rectangle_intersect (&rect, area, &dest)) { + dest.x -= child->x; + dest.y -= child->y; + + child_draw (fullday, child, &dest, TRUE); + } + } } static void @@ -957,11 +1074,9 @@ update_from_drag_info (GncalFullDay *fullday) child_range_changed (fullday, di->child); - /* FIXME: notify calendar of change */ + /* Notify calendar of change */ - /* FIXME: re-layout or let notification do it? */ - - layout_children (fullday); + gnome_calendar_object_changed (fullday->calendar, di->child->ico); } static gint @@ -1021,105 +1136,6 @@ gncal_full_day_motion (GtkWidget *widget, GdkEventMotion *event) return FALSE; } -static void -paint_back (GncalFullDay *fullday, GdkRectangle *area) -{ - GtkWidget *widget; - GdkRectangle rect, dest; - int x1, y1, width, height; - int labels_width, division_x; - int rows, row_height; - int i, y; - struct tm tm; - char buf[256]; - - widget = GTK_WIDGET (fullday); - - x1 = widget->style->klass->xthickness; - y1 = widget->style->klass->ythickness; - width = widget->allocation.width - 2 * x1; - height = widget->allocation.height - 2 * y1; - - /* Clear and paint frame shadow */ - - gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); - - gtk_draw_shadow (widget->style, widget->window, - GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_IN, - 0, 0, - widget->allocation.width, - widget->allocation.height); - - /* Clear space for labels */ - - labels_width = calc_labels_width (fullday); - - rect.x = x1; - rect.y = y1; - rect.width = 2 * TEXT_BORDER + labels_width; - rect.height = height; - - if (gdk_rectangle_intersect (&rect, area, &dest)) - gdk_draw_rectangle (widget->window, - widget->style->bg_gc[GTK_STATE_NORMAL], - TRUE, - dest.x, dest.y, - dest.width, dest.height); - - /* Vertical division */ - - division_x = x1 + 2 * TEXT_BORDER + labels_width; - - gtk_draw_vline (widget->style, widget->window, - GTK_STATE_NORMAL, - y1, - y1 + height - 1, - division_x); - - /* Horizontal divisions */ - - get_tm_range (fullday, fullday->lower, fullday->upper, &tm, NULL, NULL, &rows); - - row_height = height / rows; /* includes division line at bottom of row */ - - y = y1 + row_height - 1; - - for (i = 1; i < rows; i++) { - gdk_draw_line (widget->window, - widget->style->black_gc, - x1, y, - x1 + width - 1, y); - - y += row_height; - } - - /* Labels */ - - y = y1 + ((row_height - 1) - (widget->style->font->ascent + widget->style->font->descent)) / 2; - - rect.height = row_height - 1; - - for (i = 0; i < rows; i++) { - mktime (&tm); - - if (gdk_rectangle_intersect (&rect, area, &dest)) { - strftime (buf, 256, "%X", &tm); - - gdk_draw_string (widget->window, - widget->style->font, - widget->style->fg_gc[GTK_STATE_NORMAL], - x1 + TEXT_BORDER, - y + widget->style->font->ascent, - buf); - } - - rect.y += row_height; - y += row_height; - - tm.tm_min += fullday->interval; - } -} - static gint gncal_full_day_expose (GtkWidget *widget, GdkEventExpose *event) { diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c index b202422e2d..873ee3f908 100644 --- a/calendar/gnome-cal.c +++ b/calendar/gnome-cal.c @@ -189,10 +189,27 @@ gnome_calendar_load (GnomeCalendar *gcal, char *file) } void -gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj) +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); } + +void +gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj) +{ + g_return_if_fail (gcal != NULL); + g_return_if_fail (GNOME_IS_CALENDAR (gcal)); + g_return_if_fail (obj != NULL); + + /* FIXME: for now we only update the views. Most likely we + * need to do something else like set the last_mod field on + * the iCalObject and such - Federico + */ + + gcal->cal->modified = TRUE; + + gnome_calendar_update_all (gcal); +} diff --git a/calendar/gnome-cal.h b/calendar/gnome-cal.h index 053737fd4f..2a91237f81 100644 --- a/calendar/gnome-cal.h +++ b/calendar/gnome-cal.h @@ -34,13 +34,14 @@ typedef struct { GnomeAppClass parent_class; } GnomeCalendarClass; -guint gnome_calendar_get_type (void); -GtkWidget *gnome_calendar_new (char *title); -void gnome_calendar_load (GnomeCalendar *gcal, char *file); -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); +guint gnome_calendar_get_type (void); +GtkWidget *gnome_calendar_new (char *title); +void gnome_calendar_load (GnomeCalendar *gcal, char *file); +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); END_GNOME_DECLS diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c index c06414a571..ebece3aadc 100644 --- a/calendar/gui/calendar.c +++ b/calendar/gui/calendar.c @@ -48,6 +48,10 @@ calendar_add_object (Calendar *cal, iCalObject *obj) default: g_assert_not_reached (); } + + cal->modified = TRUE; + + /* FIXME: do we have to set the last_mod field in the object? */ } void @@ -68,6 +72,8 @@ calendar_remove_object (Calendar *cal, iCalObject *obj) default: g_assert_not_reached (); } + + cal->modified = TRUE; } void diff --git a/calendar/gui/calendar.h b/calendar/gui/calendar.h index 8f4e4c1497..f93946315c 100644 --- a/calendar/gui/calendar.h +++ b/calendar/gui/calendar.h @@ -17,15 +17,15 @@ typedef struct { void *temp; } Calendar; -Calendar *calendar_new (char *title); -void calendar_load (Calendar *cal, char *fname); -void calendar_add_object (Calendar *cal, iCalObject *obj); -void calendar_remove_object (Calendar *cal, iCalObject *obj); -void calendar_destroy (Calendar *cal); -GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); -GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); -GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); -gint calendar_compare_by_dtstart (gpointer a, gpointer b); +Calendar *calendar_new (char *title); +void calendar_load (Calendar *cal, char *fname); +void calendar_add_object (Calendar *cal, iCalObject *obj); +void calendar_remove_object (Calendar *cal, iCalObject *obj); +void calendar_destroy (Calendar *cal); +GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); +GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); +GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); +gint calendar_compare_by_dtstart (gpointer a, gpointer b); END_GNOME_DECLS diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c index 90a4813947..db743431ee 100644 --- a/calendar/gui/gncal-full-day.c +++ b/calendar/gui/gncal-full-day.c @@ -127,9 +127,7 @@ static void child_map (GncalFullDay *fullday, Child *child) { gdk_window_show (child->window); - - if (!GTK_WIDGET_MAPPED (child->widget)) - gtk_widget_map (child->widget); + gtk_widget_show (child->widget); /* OK, not just a map... */ } static void @@ -203,16 +201,13 @@ static void child_draw (GncalFullDay *fullday, Child *child, GdkRectangle *area, int draw_child) { GdkRectangle arect, rect, dest; - gint w, h; - - gdk_window_get_size (child->window, &w, &h); if (!area) { arect.x = 0; arect.y = 0; - arect.width = w; - arect.height = h; + arect.width = child->width; + arect.height = child->height; area = &arect; } @@ -221,7 +216,7 @@ child_draw (GncalFullDay *fullday, Child *child, GdkRectangle *area, int draw_ch rect.x = 0; rect.y = 0; - rect.width = w; + rect.width = child->width; rect.height = HANDLE_SIZE; if (gdk_rectangle_intersect (&rect, area, &dest)) @@ -229,7 +224,7 @@ child_draw (GncalFullDay *fullday, Child *child, GdkRectangle *area, int draw_ch /* Bottom handle */ - rect.y = h - HANDLE_SIZE; + rect.y = child->height - HANDLE_SIZE; if (gdk_rectangle_intersect (&rect, area, &dest)) view_utils_draw_textured_frame (GTK_WIDGET (fullday), child->window, &rect, GTK_SHADOW_OUT); @@ -284,6 +279,8 @@ child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data) child->ico->summary = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1); + /* FIXME: need notify calendar of change? */ + return FALSE; } @@ -457,11 +454,10 @@ calc_labels_width (GncalFullDay *fullday) } static void -layout_child (GncalFullDay *fullday, Child *child, struct layout_row *rows) +layout_child (GncalFullDay *fullday, Child *child, struct layout_row *rows, int left_x) { - int c_x, c_y, c_width, c_height; + int c_y, c_width, c_height; GtkWidget *widget; - int labels_width; int height, f_rows; int row_height; @@ -469,26 +465,23 @@ layout_child (GncalFullDay *fullday, Child *child, struct layout_row *rows) widget = GTK_WIDGET (fullday); - labels_width = calc_labels_width (fullday); /* FIXME: this is expensive to do for each child */ - get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows); height = widget->allocation.height - 2 * widget->style->klass->ythickness; row_height = height / f_rows; - c_x = 2 * (widget->style->klass->xthickness + TEXT_BORDER) + labels_width; c_y = widget->style->klass->ythickness; /* FIXME: for now, the children overlap. Make it layout them nicely. */ - c_width = widget->allocation.width - (widget->style->klass->xthickness + c_x); + c_width = widget->allocation.width - (widget->style->klass->xthickness + left_x); c_y += child->lower_row * row_height; c_height = child->rows_used * row_height; /* Position child */ - child_set_pos (fullday, child, c_x, c_y, c_width, c_height); + child_set_pos (fullday, child, left_x, c_y, c_width, c_height); } static void @@ -496,11 +489,17 @@ layout_children (GncalFullDay *fullday) { struct layout_row *rows; GList *children; + GtkWidget *widget; + int left_x; rows = layout_get_rows (fullday); + widget = GTK_WIDGET (fullday); + + left_x = 2 * (widget->style->klass->xthickness + TEXT_BORDER) + calc_labels_width (fullday); + for (children = fullday->children; children; children = children->next) - layout_child (fullday, children->data, rows); + layout_child (fullday, children->data, rows, left_x); g_free (rows); } @@ -722,9 +721,111 @@ gncal_full_day_unrealize (GtkWidget *widget) } static void +paint_back (GncalFullDay *fullday, GdkRectangle *area) +{ + GtkWidget *widget; + GdkRectangle rect, dest; + int x1, y1, width, height; + int labels_width, division_x; + int rows, row_height; + int i, y; + struct tm tm; + char buf[256]; + + widget = GTK_WIDGET (fullday); + + x1 = widget->style->klass->xthickness; + y1 = widget->style->klass->ythickness; + width = widget->allocation.width - 2 * x1; + height = widget->allocation.height - 2 * y1; + + /* Clear and paint frame shadow */ + + gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); + + gtk_draw_shadow (widget->style, widget->window, + GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_IN, + 0, 0, + widget->allocation.width, + widget->allocation.height); + + /* Clear space for labels */ + + labels_width = calc_labels_width (fullday); + + rect.x = x1; + rect.y = y1; + rect.width = 2 * TEXT_BORDER + labels_width; + rect.height = height; + + if (gdk_rectangle_intersect (&rect, area, &dest)) + gdk_draw_rectangle (widget->window, + widget->style->bg_gc[GTK_STATE_NORMAL], + TRUE, + dest.x, dest.y, + dest.width, dest.height); + + /* Vertical division */ + + division_x = x1 + 2 * TEXT_BORDER + labels_width; + + gtk_draw_vline (widget->style, widget->window, + GTK_STATE_NORMAL, + y1, + y1 + height - 1, + division_x); + + /* Horizontal divisions */ + + get_tm_range (fullday, fullday->lower, fullday->upper, &tm, NULL, NULL, &rows); + + row_height = height / rows; /* includes division line at bottom of row */ + + y = y1 + row_height - 1; + + for (i = 1; i < rows; i++) { + gdk_draw_line (widget->window, + widget->style->black_gc, + x1, y, + x1 + width - 1, y); + + y += row_height; + } + + /* Labels */ + + y = y1 + ((row_height - 1) - (widget->style->font->ascent + widget->style->font->descent)) / 2; + + rect.height = row_height - 1; + + for (i = 0; i < rows; i++) { + mktime (&tm); + + if (gdk_rectangle_intersect (&rect, area, &dest)) { + strftime (buf, 256, "%X", &tm); + + gdk_draw_string (widget->window, + widget->style->font, + widget->style->fg_gc[GTK_STATE_NORMAL], + x1 + TEXT_BORDER, + y + widget->style->font->ascent, + buf); + } + + rect.y += row_height; + y += row_height; + + tm.tm_min += fullday->interval; + } +} + +static void gncal_full_day_draw (GtkWidget *widget, GdkRectangle *area) { GncalFullDay *fullday; + GList *children; + Child *child; + GdkRectangle rect, dest; g_return_if_fail (widget != NULL); g_return_if_fail (GNCAL_IS_FULL_DAY (widget)); @@ -735,7 +836,23 @@ gncal_full_day_draw (GtkWidget *widget, GdkRectangle *area) fullday = GNCAL_FULL_DAY (widget); - /* FIXME */ + paint_back (fullday, area); + + for (children = fullday->children; children; children = children->next) { + child = children->data; + + rect.x = child->x; + rect.y = child->y; + rect.width = child->width; + rect.height = child->height; + + if (gdk_rectangle_intersect (&rect, area, &dest)) { + dest.x -= child->x; + dest.y -= child->y; + + child_draw (fullday, child, &dest, TRUE); + } + } } static void @@ -957,11 +1074,9 @@ update_from_drag_info (GncalFullDay *fullday) child_range_changed (fullday, di->child); - /* FIXME: notify calendar of change */ + /* Notify calendar of change */ - /* FIXME: re-layout or let notification do it? */ - - layout_children (fullday); + gnome_calendar_object_changed (fullday->calendar, di->child->ico); } static gint @@ -1021,105 +1136,6 @@ gncal_full_day_motion (GtkWidget *widget, GdkEventMotion *event) return FALSE; } -static void -paint_back (GncalFullDay *fullday, GdkRectangle *area) -{ - GtkWidget *widget; - GdkRectangle rect, dest; - int x1, y1, width, height; - int labels_width, division_x; - int rows, row_height; - int i, y; - struct tm tm; - char buf[256]; - - widget = GTK_WIDGET (fullday); - - x1 = widget->style->klass->xthickness; - y1 = widget->style->klass->ythickness; - width = widget->allocation.width - 2 * x1; - height = widget->allocation.height - 2 * y1; - - /* Clear and paint frame shadow */ - - gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); - - gtk_draw_shadow (widget->style, widget->window, - GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_IN, - 0, 0, - widget->allocation.width, - widget->allocation.height); - - /* Clear space for labels */ - - labels_width = calc_labels_width (fullday); - - rect.x = x1; - rect.y = y1; - rect.width = 2 * TEXT_BORDER + labels_width; - rect.height = height; - - if (gdk_rectangle_intersect (&rect, area, &dest)) - gdk_draw_rectangle (widget->window, - widget->style->bg_gc[GTK_STATE_NORMAL], - TRUE, - dest.x, dest.y, - dest.width, dest.height); - - /* Vertical division */ - - division_x = x1 + 2 * TEXT_BORDER + labels_width; - - gtk_draw_vline (widget->style, widget->window, - GTK_STATE_NORMAL, - y1, - y1 + height - 1, - division_x); - - /* Horizontal divisions */ - - get_tm_range (fullday, fullday->lower, fullday->upper, &tm, NULL, NULL, &rows); - - row_height = height / rows; /* includes division line at bottom of row */ - - y = y1 + row_height - 1; - - for (i = 1; i < rows; i++) { - gdk_draw_line (widget->window, - widget->style->black_gc, - x1, y, - x1 + width - 1, y); - - y += row_height; - } - - /* Labels */ - - y = y1 + ((row_height - 1) - (widget->style->font->ascent + widget->style->font->descent)) / 2; - - rect.height = row_height - 1; - - for (i = 0; i < rows; i++) { - mktime (&tm); - - if (gdk_rectangle_intersect (&rect, area, &dest)) { - strftime (buf, 256, "%X", &tm); - - gdk_draw_string (widget->window, - widget->style->font, - widget->style->fg_gc[GTK_STATE_NORMAL], - x1 + TEXT_BORDER, - y + widget->style->font->ascent, - buf); - } - - rect.y += row_height; - y += row_height; - - tm.tm_min += fullday->interval; - } -} - static gint gncal_full_day_expose (GtkWidget *widget, GdkEventExpose *event) { diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index b202422e2d..873ee3f908 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -189,10 +189,27 @@ gnome_calendar_load (GnomeCalendar *gcal, char *file) } void -gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj) +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); } + +void +gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj) +{ + g_return_if_fail (gcal != NULL); + g_return_if_fail (GNOME_IS_CALENDAR (gcal)); + g_return_if_fail (obj != NULL); + + /* FIXME: for now we only update the views. Most likely we + * need to do something else like set the last_mod field on + * the iCalObject and such - Federico + */ + + gcal->cal->modified = TRUE; + + gnome_calendar_update_all (gcal); +} diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 053737fd4f..2a91237f81 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -34,13 +34,14 @@ typedef struct { GnomeAppClass parent_class; } GnomeCalendarClass; -guint gnome_calendar_get_type (void); -GtkWidget *gnome_calendar_new (char *title); -void gnome_calendar_load (GnomeCalendar *gcal, char *file); -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); +guint gnome_calendar_get_type (void); +GtkWidget *gnome_calendar_new (char *title); +void gnome_calendar_load (GnomeCalendar *gcal, char *file); +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); END_GNOME_DECLS diff --git a/calendar/gui/test.vcf b/calendar/gui/test.vcf index 7cd47a9cbf..c85355b494 100644 --- a/calendar/gui/test.vcf +++ b/calendar/gui/test.vcf @@ -8,8 +8,8 @@ DCREATED:19980402T023552 UID:KOrganizer - 1804289383 SEQUENCE:1 LAST-MODIFIED:19980330T225948 -DTSTART:19980408T003000 -DTEND:19980408T010000 +DTSTART:19980409T003000 +DTEND:19980409T010000 SUMMARY:asdfasdfasfasdfasdf STATUS:NEEDS ACTION CLASS:PUBLIC @@ -25,8 +25,8 @@ DCREATED:19980402T023558 UID:KOrganizer - 846930886 SEQUENCE:1 LAST-MODIFIED:19980402T023558 -DTSTART:19980408T140000 -DTEND:19980408T160000 +DTSTART:19980409T140000 +DTEND:19980409T160000 SUMMARY:asdfasfdasfasdfasfd STATUS:NEEDS ACTION CLASS:PUBLIC diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c index 8c5605c688..8504d7a95b 100644 --- a/calendar/pcs/calobj.c +++ b/calendar/pcs/calobj.c @@ -349,7 +349,7 @@ ical_object_to_vobject (iCalObject *ical) /* resources */ if (ical->categories) - store_list (o, VCCategoriesProp, ical->resources, ";"); + store_list (o, VCCategoriesProp, ical->resources, ';'); /* priority */ addPropValue (o, VCPriorityProp, to_str (ical->priority)); @@ -358,7 +358,7 @@ ical_object_to_vobject (iCalObject *ical) addPropValue (o, VCTranspProp, to_str (ical->transp)); /* related */ - store_list (o, VCRelatedToProp, ical->related, ";"); + store_list (o, VCRelatedToProp, ical->related, ';'); /* attach */ for (l = ical->attach; l; l = l->next) @@ -371,4 +371,3 @@ ical_object_to_vobject (iCalObject *ical) /* FIXME: alarms */ return o; } - diff --git a/calendar/pcs/calobj.h b/calendar/pcs/calobj.h index 00dbd5c63e..0fe85c6ca3 100644 --- a/calendar/pcs/calobj.h +++ b/calendar/pcs/calobj.h @@ -120,6 +120,7 @@ iCalObject *ical_new (char *comment, char *organizer, char *summary); iCalObject *ical_object_new (void); void ical_object_destroy (iCalObject *ico); iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name); +VObject *ical_object_to_vobject (iCalObject *ical); END_GNOME_DECLS diff --git a/calendar/test.vcf b/calendar/test.vcf index 7cd47a9cbf..c85355b494 100644 --- a/calendar/test.vcf +++ b/calendar/test.vcf @@ -8,8 +8,8 @@ DCREATED:19980402T023552 UID:KOrganizer - 1804289383 SEQUENCE:1 LAST-MODIFIED:19980330T225948 -DTSTART:19980408T003000 -DTEND:19980408T010000 +DTSTART:19980409T003000 +DTEND:19980409T010000 SUMMARY:asdfasdfasfasdfasdf STATUS:NEEDS ACTION CLASS:PUBLIC @@ -25,8 +25,8 @@ DCREATED:19980402T023558 UID:KOrganizer - 846930886 SEQUENCE:1 LAST-MODIFIED:19980402T023558 -DTSTART:19980408T140000 -DTEND:19980408T160000 +DTSTART:19980409T140000 +DTEND:19980409T160000 SUMMARY:asdfasfdasfasdfasfd STATUS:NEEDS ACTION CLASS:PUBLIC |