diff options
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/gncal-full-day.c | 85 | ||||
-rw-r--r-- | calendar/gui/gncal-full-day.c | 85 | ||||
-rw-r--r-- | calendar/gui/test.vcf | 8 | ||||
-rw-r--r-- | calendar/test.vcf | 8 |
4 files changed, 158 insertions, 28 deletions
diff --git a/calendar/gncal-full-day.c b/calendar/gncal-full-day.c index b6a61a3a9d..067b119efa 100644 --- a/calendar/gncal-full-day.c +++ b/calendar/gncal-full-day.c @@ -142,7 +142,7 @@ child_unmap (GncalFullDay *fullday, Child *child) } static void -child_move_text (Child *child) +child_set_text_pos (Child *child) { GtkAllocation allocation; @@ -188,7 +188,7 @@ child_realize (GncalFullDay *fullday, Child *child) gtk_widget_set_parent_window (child->widget, child->window); - child_move_text (child); + child_set_text_pos (child); } static void @@ -241,11 +241,34 @@ child_draw (GncalFullDay *fullday, Child *child, GdkRectangle *area, int draw_ch } static void -child_set_beam_cursor (GtkWidget *widget, gpointer data) +child_realized_setup (GtkWidget *widget, gpointer data) { - GncalFullDay *fullday = data; + Child *child; + GncalFullDay *fullday; + + child = data; + fullday = GNCAL_FULL_DAY (widget->parent); gdk_window_set_cursor (widget->window, fullday->beam_cursor); + + gtk_text_insert (GTK_TEXT (widget), NULL, NULL, NULL, + child->ico->summary, + strlen (child->ico->summary)); +} + +static gint +child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data) +{ + Child *child; + + child = data; + + if (child->ico->summary) + g_free (child->ico->summary); + + child->ico->summary = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1); + + return FALSE; } static Child * @@ -274,11 +297,19 @@ child_new (GncalFullDay *fullday, iCalObject *ico) child->lower_row = lower_row - f_lower_row; child->rows_used = rows_used; - /* Finish setup */ + /* We set the i-beam cursor and the initial summary text upon realization */ gtk_signal_connect (GTK_OBJECT (child->widget), "realize", - (GtkSignalFunc) child_set_beam_cursor, - fullday); + (GtkSignalFunc) child_realized_setup, + child); + + /* Update the iCalObject summary when the text widget loses focus */ + + gtk_signal_connect (GTK_OBJECT (child->widget), "focus_out_event", + (GtkSignalFunc) child_focus_out, + child); + + /* Finish setup */ gtk_text_set_editable (GTK_TEXT (child->widget), TRUE); gtk_text_set_word_wrap (GTK_TEXT (child->widget), TRUE); @@ -306,7 +337,7 @@ child_set_pos (GncalFullDay *fullday, Child *child, int x, int y, int width, int if (!GTK_WIDGET_REALIZED (fullday)) return; - child_move_text (child); + child_set_text_pos (child); gdk_window_move_resize (child->window, x, y, width, height); } @@ -763,7 +794,7 @@ draw_xor_rect (GncalFullDay *fullday) di->child->x + i, di->new_y + i, di->child->width - 2 * i - 1, - di->new_height - 2 * i - 1); + di->new_height - 2 * i - 2); gdk_gc_set_function (widget->style->white_gc, GDK_COPY); gdk_gc_set_subwindow (widget->style->white_gc, GDK_CLIP_BY_CHILDREN); @@ -867,6 +898,40 @@ recompute_motion (GncalFullDay *fullday, int y) } } +static void +update_from_drag_info (GncalFullDay *fullday) +{ + struct drag_info *di; + GtkWidget *widget; + struct tm tm; + int f_rows; + int row_height; + int start_row, used_rows; + + di = fullday->drag_info; + + widget = GTK_WIDGET (fullday); + + get_tm_range (fullday, fullday->lower, fullday->upper, &tm, NULL, NULL, &f_rows); + + row_height = (widget->allocation.height - 2 * widget->style->klass->ythickness) / f_rows; + + start_row = (di->new_y - widget->style->klass->ythickness) / row_height; + used_rows = di->new_height / row_height; + + tm.tm_min += fullday->interval * start_row; + di->child->ico->dtstart = mktime (&tm); + + tm.tm_min += fullday->interval * used_rows; + di->child->ico->dtend = mktime (&tm); + + /* FIXME: notify calendar of change */ + + /* FIXME: re-layout or let notification do it? */ + + layout_children (fullday); +} + static gint gncal_full_day_button_release (GtkWidget *widget, GdkEventButton *event) { @@ -891,7 +956,7 @@ gncal_full_day_button_release (GtkWidget *widget, GdkEventButton *event) recompute_motion (fullday, y); gdk_pointer_ungrab (event->time); - /* FIXME: update child, notify, etc. */ + update_from_drag_info (fullday); di->child = NULL; diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c index b6a61a3a9d..067b119efa 100644 --- a/calendar/gui/gncal-full-day.c +++ b/calendar/gui/gncal-full-day.c @@ -142,7 +142,7 @@ child_unmap (GncalFullDay *fullday, Child *child) } static void -child_move_text (Child *child) +child_set_text_pos (Child *child) { GtkAllocation allocation; @@ -188,7 +188,7 @@ child_realize (GncalFullDay *fullday, Child *child) gtk_widget_set_parent_window (child->widget, child->window); - child_move_text (child); + child_set_text_pos (child); } static void @@ -241,11 +241,34 @@ child_draw (GncalFullDay *fullday, Child *child, GdkRectangle *area, int draw_ch } static void -child_set_beam_cursor (GtkWidget *widget, gpointer data) +child_realized_setup (GtkWidget *widget, gpointer data) { - GncalFullDay *fullday = data; + Child *child; + GncalFullDay *fullday; + + child = data; + fullday = GNCAL_FULL_DAY (widget->parent); gdk_window_set_cursor (widget->window, fullday->beam_cursor); + + gtk_text_insert (GTK_TEXT (widget), NULL, NULL, NULL, + child->ico->summary, + strlen (child->ico->summary)); +} + +static gint +child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data) +{ + Child *child; + + child = data; + + if (child->ico->summary) + g_free (child->ico->summary); + + child->ico->summary = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1); + + return FALSE; } static Child * @@ -274,11 +297,19 @@ child_new (GncalFullDay *fullday, iCalObject *ico) child->lower_row = lower_row - f_lower_row; child->rows_used = rows_used; - /* Finish setup */ + /* We set the i-beam cursor and the initial summary text upon realization */ gtk_signal_connect (GTK_OBJECT (child->widget), "realize", - (GtkSignalFunc) child_set_beam_cursor, - fullday); + (GtkSignalFunc) child_realized_setup, + child); + + /* Update the iCalObject summary when the text widget loses focus */ + + gtk_signal_connect (GTK_OBJECT (child->widget), "focus_out_event", + (GtkSignalFunc) child_focus_out, + child); + + /* Finish setup */ gtk_text_set_editable (GTK_TEXT (child->widget), TRUE); gtk_text_set_word_wrap (GTK_TEXT (child->widget), TRUE); @@ -306,7 +337,7 @@ child_set_pos (GncalFullDay *fullday, Child *child, int x, int y, int width, int if (!GTK_WIDGET_REALIZED (fullday)) return; - child_move_text (child); + child_set_text_pos (child); gdk_window_move_resize (child->window, x, y, width, height); } @@ -763,7 +794,7 @@ draw_xor_rect (GncalFullDay *fullday) di->child->x + i, di->new_y + i, di->child->width - 2 * i - 1, - di->new_height - 2 * i - 1); + di->new_height - 2 * i - 2); gdk_gc_set_function (widget->style->white_gc, GDK_COPY); gdk_gc_set_subwindow (widget->style->white_gc, GDK_CLIP_BY_CHILDREN); @@ -867,6 +898,40 @@ recompute_motion (GncalFullDay *fullday, int y) } } +static void +update_from_drag_info (GncalFullDay *fullday) +{ + struct drag_info *di; + GtkWidget *widget; + struct tm tm; + int f_rows; + int row_height; + int start_row, used_rows; + + di = fullday->drag_info; + + widget = GTK_WIDGET (fullday); + + get_tm_range (fullday, fullday->lower, fullday->upper, &tm, NULL, NULL, &f_rows); + + row_height = (widget->allocation.height - 2 * widget->style->klass->ythickness) / f_rows; + + start_row = (di->new_y - widget->style->klass->ythickness) / row_height; + used_rows = di->new_height / row_height; + + tm.tm_min += fullday->interval * start_row; + di->child->ico->dtstart = mktime (&tm); + + tm.tm_min += fullday->interval * used_rows; + di->child->ico->dtend = mktime (&tm); + + /* FIXME: notify calendar of change */ + + /* FIXME: re-layout or let notification do it? */ + + layout_children (fullday); +} + static gint gncal_full_day_button_release (GtkWidget *widget, GdkEventButton *event) { @@ -891,7 +956,7 @@ gncal_full_day_button_release (GtkWidget *widget, GdkEventButton *event) recompute_motion (fullday, y); gdk_pointer_ungrab (event->time); - /* FIXME: update child, notify, etc. */ + update_from_drag_info (fullday); di->child = NULL; diff --git a/calendar/gui/test.vcf b/calendar/gui/test.vcf index e44ccf683f..7cd47a9cbf 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:19980407T003000 -DTEND:19980407T010000 +DTSTART:19980408T003000 +DTEND:19980408T010000 SUMMARY:asdfasdfasfasdfasdf STATUS:NEEDS ACTION CLASS:PUBLIC @@ -25,8 +25,8 @@ DCREATED:19980402T023558 UID:KOrganizer - 846930886 SEQUENCE:1 LAST-MODIFIED:19980402T023558 -DTSTART:19980407T140000 -DTEND:19980407T160000 +DTSTART:19980408T140000 +DTEND:19980408T160000 SUMMARY:asdfasfdasfasdfasfd STATUS:NEEDS ACTION CLASS:PUBLIC diff --git a/calendar/test.vcf b/calendar/test.vcf index e44ccf683f..7cd47a9cbf 100644 --- a/calendar/test.vcf +++ b/calendar/test.vcf @@ -8,8 +8,8 @@ DCREATED:19980402T023552 UID:KOrganizer - 1804289383 SEQUENCE:1 LAST-MODIFIED:19980330T225948 -DTSTART:19980407T003000 -DTEND:19980407T010000 +DTSTART:19980408T003000 +DTEND:19980408T010000 SUMMARY:asdfasdfasfasdfasdf STATUS:NEEDS ACTION CLASS:PUBLIC @@ -25,8 +25,8 @@ DCREATED:19980402T023558 UID:KOrganizer - 846930886 SEQUENCE:1 LAST-MODIFIED:19980402T023558 -DTSTART:19980407T140000 -DTEND:19980407T160000 +DTSTART:19980408T140000 +DTEND:19980408T160000 SUMMARY:asdfasfdasfasdfasfd STATUS:NEEDS ACTION CLASS:PUBLIC |