diff options
-rw-r--r-- | calendar/ChangeLog | 21 | ||||
-rw-r--r-- | calendar/cal-util/calobj.c | 34 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 25 | ||||
-rw-r--r-- | calendar/gui/e-week-view-event-item.c | 16 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 55 | ||||
-rw-r--r-- | calendar/gui/eventedit.c | 46 |
6 files changed, 117 insertions, 80 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 67dbc86aff..bba924c735 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,5 +1,26 @@ 2000-05-06 Damon Chaplin <damon@helixcode.com> + * gui/e-day-view.c: + * gui/e-week-view.c: finish editing event when user hits Return key. + (e_week_view_on_text_item_event): stop event signals after doing any + other calls, since otherwise it will also stop any other resulting + event signals. + + * gui/e-week-view-event-item.c (e_week_view_event_item_draw): don't + draw the start/end times while editing. + + * gui/eventedit.c: changed the Summary field to a GtkEntry, since we + now only want a single line of text. + + * cal-util/calobj.c (ical_object_normalize_summary): new function to + convert the summary field to a single line of text, by converting any + sequence of CR & LF characters to a single space. + (ical_object_create_from_vobject): call the above function. I think + all functions that load iCalObjects go through this. + (ical_new): called it here as well just in case. + +2000-05-06 Damon Chaplin <damon@helixcode.com> + * gui/week-view.[hc]: removed. 2000-05-06 Damon Chaplin <damon@helixcode.com> diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c index 9691d31c11..4ea3b495b0 100644 --- a/calendar/cal-util/calobj.c +++ b/calendar/cal-util/calobj.c @@ -22,6 +22,7 @@ #define PRODID "-//Helix Code//NONSGML Evolution Calendar//EN" static gint compare_exdates (gconstpointer a, gconstpointer b); +static void ical_object_normalize_summary (iCalObject *ico); @@ -90,6 +91,8 @@ ical_new (char *comment, char *organizer, char *summary) ico->malarm.type = ALARM_MAIL; ico->aalarm.type = ALARM_AUDIO; + ical_object_normalize_summary (ico); + return ico; } @@ -680,7 +683,11 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) if (has (o, VCSummaryProp)){ ical->summary = g_strdup (str_val (vo)); free (the_str); - } else + + /* Convert any CR/LF/CRLF sequences in the summary field to + spaces so we just have a one-line field. */ + ical_object_normalize_summary (ical); + } else ical->summary = g_strdup (""); /* status */ @@ -1762,3 +1769,28 @@ compare_exdates (gconstpointer a, gconstpointer b) time_t diff = *ca - *cb; return (diff < 0) ? -1 : (diff > 0) ? 1 : 0; } + + +/* Converts any CR/LF sequences in the summary field to spaces so we just + have a one-line field. The iCalObjects summary field is changed. */ +static void +ical_object_normalize_summary (iCalObject *ico) +{ + gchar *src, *dest, ch; + gboolean just_output_space = FALSE; + + src = dest = ico->summary; + while ((ch = *src++)) { + if (ch == '\n' || ch == '\r') { + /* We only output 1 space for each sequence of CR & LF + characters. */ + if (!just_output_space) { + *dest++ = ' '; + just_output_space = TRUE; + } + } else { + *dest++ = ch; + just_output_space = FALSE; + } + } +} diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 9524f26807..747f541997 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -1034,8 +1034,6 @@ e_day_view_focus_in (GtkWidget *widget, GdkEventFocus *event) g_return_val_if_fail (E_IS_DAY_VIEW (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - g_print ("In e_day_view_focus_in\n"); - day_view = E_DAY_VIEW (widget); GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS); @@ -1056,8 +1054,6 @@ e_day_view_focus_out (GtkWidget *widget, GdkEventFocus *event) g_return_val_if_fail (E_IS_DAY_VIEW (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - g_print ("In e_day_view_focus_out\n"); - day_view = E_DAY_VIEW (widget); GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); @@ -1142,7 +1138,6 @@ e_day_view_update_event (EDayView *day_view, update the event fairly easily without changing the events arrays or computing a new layout. */ if (e_day_view_find_event_from_uid (day_view, uid, &day, &event_num)) { - g_print (" updating existing event\n"); if (day == E_DAY_VIEW_LONG_EVENT) event = &g_array_index (day_view->long_events, EDayViewEvent, event_num); @@ -1151,7 +1146,6 @@ e_day_view_update_event (EDayView *day_view, EDayViewEvent, event_num); if (ical_object_compare_dates (event->ico, ico)) { - g_print (" unchanged dates\n"); e_day_view_foreach_event_with_uid (day_view, uid, e_day_view_update_event_cb, ico); ical_object_unref (ico); gtk_widget_queue_draw (day_view->top_canvas); @@ -1161,14 +1155,12 @@ e_day_view_update_event (EDayView *day_view, /* The dates have changed, so we need to remove the old occurrrences before adding the new ones. */ - g_print (" changed dates\n"); e_day_view_foreach_event_with_uid (day_view, uid, e_day_view_remove_event_cb, NULL); } /* Add the occurrences of the event. */ - g_print (" generating events\n"); ical_object_generate_events (ico, day_view->lower, day_view->upper, e_day_view_add_event, day_view); ical_object_unref (ico); @@ -1190,10 +1182,10 @@ e_day_view_update_event_cb (EDayView *day_view, iCalObject *ico; ico = data; - +#if 0 g_print ("In e_day_view_update_event_cb day:%i event_num:%i\n", day, event_num); - +#endif if (day == E_DAY_VIEW_LONG_EVENT) { event = &g_array_index (day_view->long_events, EDayViewEvent, event_num); @@ -3940,6 +3932,19 @@ e_day_view_on_text_item_event (GnomeCanvasItem *item, EDayView *day_view) { switch (event->type) { + case GDK_KEY_PRESS: + if (event && event->key.keyval == GDK_Return) { + /* We set the keyboard focus to the EDayView, so the + EText item loses it and stops the edit. */ + gtk_widget_grab_focus (GTK_WIDGET (day_view)); + + /* Stop the signal last or we will also stop any + other events getting to the EText item. */ + gtk_signal_emit_stop_by_name (GTK_OBJECT (item), + "event"); + return TRUE; + } + break; case GDK_BUTTON_PRESS: case GDK_BUTTON_RELEASE: /* Only let the EText handle the event while editing. */ diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c index 32d06381f4..55c5e48b85 100644 --- a/calendar/gui/e-week-view-event-item.c +++ b/calendar/gui/e-week-view-event-item.c @@ -241,7 +241,7 @@ e_week_view_event_item_draw (GnomeCanvasItem *canvas_item, gint x1, y1, x2, y2, time_x, time_y, time_y_small_min; gint icon_x, icon_y, time_width, min_end_time_x; gint rect_x, rect_w, rect_x2; - gboolean one_day_event; + gboolean one_day_event, editing_span = FALSE; gint start_minute, end_minute; gchar buffer[128]; gboolean draw_start_triangle = FALSE, draw_end_triangle = FALSE; @@ -394,12 +394,15 @@ e_week_view_event_item_draw (GnomeCanvasItem *canvas_item, gdk_draw_line (drawable, gc, rect_x2, y1, rect_x2, y2); } + if (span->text_item && E_TEXT (span->text_item)->editing) + editing_span = TRUE; /* Draw the start & end times, if necessary. */ min_end_time_x = x1 + E_WEEK_VIEW_EVENT_L_PAD + E_WEEK_VIEW_EVENT_BORDER_WIDTH + E_WEEK_VIEW_EVENT_TEXT_X_PAD; - if (event->start > week_view->day_starts[span->start_day]) { + if (!editing_span + && event->start > week_view->day_starts[span->start_day]) { sprintf (buffer, "%02i:%02i", start_minute / 60, start_minute % 60); time_x = x1 + E_WEEK_VIEW_EVENT_L_PAD @@ -432,8 +435,9 @@ e_week_view_event_item_draw (GnomeCanvasItem *canvas_item, min_end_time_x += time_width + 2; } - if (event->end < week_view->day_starts[span->start_day - + span->num_days]) { + if (!editing_span + && event->end < week_view->day_starts[span->start_day + + span->num_days]) { sprintf (buffer, "%02i:%02i", end_minute / 60, end_minute % 60); time_x = x2 - E_WEEK_VIEW_EVENT_R_PAD @@ -637,7 +641,7 @@ e_week_view_event_item_button_press (EWeekViewEventItem *wveitem, span = &g_array_index (week_view->spans, EWeekViewEventSpan, event->spans_index + wveitem->span_num); -#if 1 +#if 0 g_print ("In e_week_view_event_item_button_press\n"); #endif @@ -685,7 +689,7 @@ e_week_view_event_item_button_release (EWeekViewEventItem *wveitem, week_view = E_WEEK_VIEW (GTK_WIDGET (item->canvas)->parent); g_return_val_if_fail (E_IS_WEEK_VIEW (week_view), FALSE); -#if 1 +#if 0 g_print ("In e_week_view_event_item_button_release\n"); #endif diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 2c740d6df4..6b75b409ba 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -647,8 +647,6 @@ e_week_view_focus_in (GtkWidget *widget, GdkEventFocus *event) g_return_val_if_fail (E_IS_WEEK_VIEW (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - g_print ("In e_week_view_focus_in\n"); - week_view = E_WEEK_VIEW (widget); GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS); @@ -668,8 +666,6 @@ e_week_view_focus_out (GtkWidget *widget, GdkEventFocus *event) g_return_val_if_fail (E_IS_WEEK_VIEW (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); - g_print ("In e_week_view_focus_out\n"); - week_view = E_WEEK_VIEW (widget); GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); @@ -974,7 +970,7 @@ e_week_view_update_event (EWeekView *week_view, g_return_if_fail (E_IS_WEEK_VIEW (week_view)); -#if 1 +#if 0 g_print ("In e_week_view_update_event\n"); #endif @@ -1010,12 +1006,10 @@ e_week_view_update_event (EWeekView *week_view, 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)) { - g_print (" updating existing event\n"); event = &g_array_index (week_view->events, EWeekViewEvent, event_num); if (ical_object_compare_dates (event->ico, ico)) { - g_print (" dates unchanged\n"); e_week_view_foreach_event_with_uid (week_view, uid, e_week_view_update_event_cb, ico); ical_object_unref (ico); gtk_widget_queue_draw (week_view->main_canvas); @@ -1024,7 +1018,6 @@ e_week_view_update_event (EWeekView *week_view, /* The dates have changed, so we need to remove the old occurrrences before adding the new ones. */ - g_print (" dates changed\n"); e_week_view_foreach_event_with_uid (week_view, uid, e_week_view_remove_event_cb, NULL); @@ -2149,8 +2142,6 @@ e_week_view_start_editing_event (EWeekView *week_view, ETextEventProcessor *event_processor = NULL; ETextEventProcessorCommand command; - g_print ("In e_week_view_start_editing_event\n"); - /* If we are already editing the event, just return. */ if (event_num == week_view->editing_event_num && span_num == week_view->editing_span_num) @@ -2182,8 +2173,6 @@ e_week_view_start_editing_event (EWeekView *week_view, gtk_signal_emit_by_name (GTK_OBJECT (event_processor), "command", &command); } - - g_print ("Out e_week_view_start_editing_event\n"); } @@ -2217,8 +2206,20 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item, #endif switch (event->type) { + case GDK_KEY_PRESS: + if (event && event->key.keyval == GDK_Return) { + /* We set the keyboard focus to the EDayView, so the + EText item loses it and stops the edit. */ + gtk_widget_grab_focus (GTK_WIDGET (week_view)); + + /* Stop the signal last or we will also stop any + other events getting to the EText item. */ + gtk_signal_emit_stop_by_name (GTK_OBJECT (item), + "event"); + return TRUE; + } + break; case GDK_BUTTON_PRESS: - g_print (" button press\n"); if (!e_week_view_find_event_from_item (week_view, item, &event_num, &span_num)) return FALSE; @@ -2237,7 +2238,6 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item, /* Only let the EText handle the event while editing. */ if (!E_TEXT (item)->editing) { - g_print (" stopping signal\n"); gtk_signal_emit_stop_by_name (GTK_OBJECT (item), "event"); @@ -2254,13 +2254,8 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item, } break; case GDK_BUTTON_RELEASE: - g_print (" button release\n"); if (!E_TEXT (item)->editing) { - g_print (" stopping signal\n"); - - gtk_signal_emit_stop_by_name (GTK_OBJECT (item), - "event"); - + /* This shouldn't ever happen. */ if (!e_week_view_find_event_from_item (week_view, item, &event_num, @@ -2275,19 +2270,20 @@ e_week_view_on_text_item_event (GnomeCanvasItem *item, span_num, NULL); week_view->pressed_event_num = -1; - return TRUE; } - } else { - g_print (" EText may get button release event\n"); + + /* Stop the signal last or we will also stop any + other events getting to the EText item. */ + gtk_signal_emit_stop_by_name (GTK_OBJECT (item), + "event"); + return TRUE; } week_view->pressed_event_num = -1; break; case GDK_FOCUS_CHANGE: if (event->focus_change.in) { - g_print ("Item got keyboard focus\n"); e_week_view_on_editing_started (week_view, item); } else { - g_print ("Item lost keyboard focus\n"); e_week_view_on_editing_stopped (week_view, item); } @@ -2310,7 +2306,9 @@ e_week_view_on_editing_started (EWeekView *week_view, &event_num, &span_num)) return; +#if 0 g_print ("In e_week_view_on_editing_started event_num:%i span_num:%i\n", event_num, span_num); +#endif week_view->editing_event_num = event_num; week_view->editing_span_num = span_num; @@ -2321,8 +2319,6 @@ e_week_view_on_editing_started (EWeekView *week_view, e_week_view_reshape_event_span (week_view, event_num, span_num); } - - g_print ("Out e_week_view_on_editing_started\n"); } @@ -2335,11 +2331,6 @@ e_week_view_on_editing_stopped (EWeekView *week_view, EWeekViewEventSpan *span; gchar *text = NULL; - if (e_week_view_find_event_from_item (week_view, item, - &event_num, &span_num)) { - g_print ("In e_week_view_on_editing_stopped event_num:%i span_num:%i\n", event_num, span_num); - } - /* Note: the item we are passed here isn't reliable, so we just stop the edit of whatever item was being edited. We also receive this event twice for some reason. */ diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c index 7ad4afb8cb..f6b14aa67f 100644 --- a/calendar/gui/eventedit.c +++ b/calendar/gui/eventedit.c @@ -779,22 +779,8 @@ ee_create_buttons (EventEditor *ee) return; } -/* - * Load the contents in a delayed fashion, as the GtkText widget needs it - */ -static void -ee_fill_summary (GtkWidget *widget, EventEditor *ee) -{ - int pos = 0; - - gtk_editable_insert_text (GTK_EDITABLE (ee->general_summary), ee->ical->summary, - strlen (ee->ical->summary), &pos); - gtk_text_thaw (GTK_TEXT (ee->general_summary)); -} - enum { OWNER_LINE, - DESC_LINE, SUMMARY_LINE, TIME_LINE, ALARM_LINE, @@ -830,25 +816,23 @@ ee_init_general_page (EventEditor *ee) gtk_misc_set_alignment (GTK_MISC (ee->general_owner), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (hbox), ee->general_owner, TRUE, TRUE, 4); - l = gtk_label_new (_("Summary:")); - gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (ee->general_table), l, - 0, 1, DESC_LINE, DESC_LINE + 1, - GTK_EXPAND | GTK_FILL | GTK_SHRINK, - GTK_FILL | GTK_SHRINK, - 0, 0); - - ee->general_summary = gtk_text_new (NULL, NULL); - gtk_text_freeze (GTK_TEXT (ee->general_summary)); - gtk_signal_connect (GTK_OBJECT (ee->general_summary), "realize", - GTK_SIGNAL_FUNC (ee_fill_summary), ee); - gtk_widget_set_usize (ee->general_summary, 0, 60); - gtk_text_set_editable (GTK_TEXT (ee->general_summary), 1); - gtk_table_attach (GTK_TABLE (ee->general_table), ee->general_summary, - 0, 1, SUMMARY_LINE, SUMMARY_LINE+1, + hbox = gtk_hbox_new (FALSE, 0); + gtk_table_attach (GTK_TABLE (ee->general_table), hbox, + 0, 1, SUMMARY_LINE, SUMMARY_LINE + 1, GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, - 0, 0); + 0, 4); + + l = gtk_label_new (_("Summary:")); + gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (hbox), l, FALSE, FALSE, 0); + + ee->general_summary = gtk_entry_new (); + gtk_entry_set_editable (GTK_ENTRY (ee->general_summary), 1); + gtk_entry_set_text (GTK_ENTRY (ee->general_summary), + ee->ical->summary ? ee->ical->summary : ""); + gtk_box_pack_start (GTK_BOX (hbox), ee->general_summary, + TRUE, TRUE, 4); l = ee_alarm_widgets (ee); gtk_table_attach (GTK_TABLE (ee->general_table), l, |