diff options
author | Federico Mena Quintero <federico@nuclecu.unam.mx> | 1998-04-13 05:38:59 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1998-04-13 05:38:59 +0800 |
commit | 75c96db2e105085d12295990d44b8427eb8230c2 (patch) | |
tree | fabe5ec93cc297324cfdc056d39e35fea3cb69d9 /calendar/gui | |
parent | fbc607b0edbdc39297d17c0ecc75b45e4bfbb0c8 (diff) | |
download | gsoc2013-evolution-75c96db2e105085d12295990d44b8427eb8230c2.tar gsoc2013-evolution-75c96db2e105085d12295990d44b8427eb8230c2.tar.gz gsoc2013-evolution-75c96db2e105085d12295990d44b8427eb8230c2.tar.bz2 gsoc2013-evolution-75c96db2e105085d12295990d44b8427eb8230c2.tar.lz gsoc2013-evolution-75c96db2e105085d12295990d44b8427eb8230c2.tar.xz gsoc2013-evolution-75c96db2e105085d12295990d44b8427eb8230c2.tar.zst gsoc2013-evolution-75c96db2e105085d12295990d44b8427eb8230c2.zip |
We now connect to the range_activated signal of the fullday widget instead
1998-04-12 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gnome-cal.c (setup_day_view): We now connect to the
range_activated signal of the fullday widget instead of catching
key presses ourselves.
(day_view_range_activated): New function that creates a new
iCalObject and inserts it into the calendar, not finished yet.
1998-04-11 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gncal-full-day.c (get_time_from_rows): New function, calculates
a pair of time_t values from the specified start and number of rows.
* gncal-full-day.h (GncalFullDayClass): New signal
"range_activated". It is emitted when a range is selected and the
user hits Return.
(gncal_full_day_selection_range): New function, returns the
selected range.
* gncal-full-day.c (struct drag_info): Moved selection information
to their own fields instead of sharing the child's drag fields.
This allows us to keep the selection when a child is moved.
(recompute_motion): Made the case when (row < di->sel_click_row)
work correctly.
svn path=/trunk/; revision=128
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/gncal-full-day.c | 157 | ||||
-rw-r--r-- | calendar/gui/gncal-full-day.h | 15 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 24 | ||||
-rw-r--r-- | calendar/gui/test.vcf | 8 |
4 files changed, 150 insertions, 54 deletions
diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c index 9a14230f92..398472a576 100644 --- a/calendar/gui/gncal-full-day.c +++ b/calendar/gui/gncal-full-day.c @@ -6,6 +6,7 @@ */ #include <string.h> +#include <gdk/gdkkeysyms.h> #include <gtk/gtkdrawingarea.h> #include <gtk/gtktext.h> #include "gncal-full-day.h" @@ -47,10 +48,20 @@ struct drag_info { Child *child; int start_row; int rows_used; + + int sel_click_row; + int sel_start_row; + int sel_rows_used; guint32 click_time; }; +enum { + RANGE_ACTIVATED, + LAST_SIGNAL +}; + + static void gncal_full_day_class_init (GncalFullDayClass *class); static void gncal_full_day_init (GncalFullDay *fullday); static void gncal_full_day_destroy (GtkObject *object); @@ -73,6 +84,8 @@ static gint gncal_full_day_motion (GtkWidget *widget, GdkEventMotion *event); static gint gncal_full_day_expose (GtkWidget *widget, GdkEventExpose *event); +static gint gncal_full_day_key_press (GtkWidget *widget, + GdkEventKey *event); static gint gncal_full_day_focus_in (GtkWidget *widget, GdkEventFocus *event); static gint gncal_full_day_focus_out (GtkWidget *widget, @@ -81,9 +94,13 @@ static void gncal_full_day_foreach (GtkContainer *container, GtkCallback callback, gpointer callback_data); +static void range_activated (GncalFullDay *fullday); + static GtkContainerClass *parent_class; +static fullday_signals[LAST_SIGNAL] = { 0 }; + static void get_tm_range (GncalFullDay *fullday, @@ -186,7 +203,8 @@ child_realize (GncalFullDay *fullday, Child *child) | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_MOTION_MASK - | GDK_POINTER_MOTION_HINT_MASK); + | GDK_POINTER_MOTION_HINT_MASK + | GDK_KEY_PRESS_MASK); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_CURSOR; @@ -559,6 +577,16 @@ gncal_full_day_class_init (GncalFullDayClass *class) parent_class = gtk_type_class (gtk_container_get_type ()); + fullday_signals[RANGE_ACTIVATED] = + gtk_signal_new ("range_activated", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (GncalFullDayClass, range_activated), + gtk_signal_default_marshaller, + GTK_TYPE_NONE, 0); + + gtk_object_class_add_signals (object_class, fullday_signals, LAST_SIGNAL); + object_class->destroy = gncal_full_day_destroy; widget_class->map = gncal_full_day_map; @@ -573,10 +601,13 @@ gncal_full_day_class_init (GncalFullDayClass *class) widget_class->button_release_event = gncal_full_day_button_release; widget_class->motion_notify_event = gncal_full_day_motion; widget_class->expose_event = gncal_full_day_expose; + widget_class->key_press_event = gncal_full_day_key_press; widget_class->focus_in_event = gncal_full_day_focus_in; widget_class->focus_out_event = gncal_full_day_focus_out; container_class->foreach = gncal_full_day_foreach; + + class->range_activated = range_activated; } static void @@ -807,11 +838,11 @@ paint_back (GncalFullDay *fullday, GdkRectangle *area) row_height = calc_row_height (fullday); - if (di->rows_used != 0) { + if (di->sel_rows_used != 0) { rect.x = x1; - rect.y = y1 + row_height * di->start_row; + rect.y = y1 + row_height * di->sel_start_row; rect.width = width; - rect.height = row_height * di->rows_used; + rect.height = row_height * di->sel_rows_used; if (gdk_rectangle_intersect (&rect, area, &dest)) gdk_draw_rectangle (widget->window, @@ -1093,8 +1124,9 @@ gncal_full_day_button_press (GtkWidget *widget, GdkEventButton *event) di->drag_mode = DRAG_SELECT; - di->start_row = get_row_from_y (fullday, event->y, FALSE); - di->rows_used = 1; + di->sel_click_row = get_row_from_y (fullday, event->y, FALSE); + di->sel_start_row = di->sel_click_row; + di->sel_rows_used = 1; di->click_time = event->time; @@ -1165,11 +1197,13 @@ recompute_motion (GncalFullDay *fullday, int y) if (row >= f_rows) row = f_rows - 1; - if (row < di->start_row) { - di->rows_used = di->start_row - row + 1; - di->start_row = row; - } else - di->rows_used = row - di->start_row + 1; + if (row < di->sel_click_row) { + di->sel_start_row = row; + di->sel_rows_used = di->sel_click_row - row + 1; + } else { + di->sel_start_row = di->sel_click_row; + di->sel_rows_used = row - di->sel_start_row + 1; + } break; @@ -1201,26 +1235,35 @@ recompute_motion (GncalFullDay *fullday, int y) } static void -update_from_drag_info (GncalFullDay *fullday) +get_time_from_rows (GncalFullDay *fullday, int start_row, int rows_used, time_t *t_lower, time_t *t_upper) { - struct drag_info *di; - GtkWidget *widget; struct tm tm; int row_height; - di = fullday->drag_info; - - widget = GTK_WIDGET (fullday); - get_tm_range (fullday, fullday->lower, fullday->upper, &tm, NULL, NULL, NULL); row_height = calc_row_height (fullday); - tm.tm_min += fullday->interval * di->start_row; - di->child->ico->dtstart = mktime (&tm); + tm.tm_min += fullday->interval * start_row; + *t_lower = mktime (&tm); - tm.tm_min += fullday->interval * di->rows_used; - di->child->ico->dtend = mktime (&tm); + tm.tm_min += fullday->interval * rows_used; + *t_upper = mktime (&tm); +} + +static void +update_from_drag_info (GncalFullDay *fullday) +{ + struct drag_info *di; + GtkWidget *widget; + + di = fullday->drag_info; + + widget = GTK_WIDGET (fullday); + + get_time_from_rows (fullday, di->start_row, di->rows_used, + &di->child->ico->dtstart, + &di->child->ico->dtend); child_range_changed (fullday, di->child); @@ -1252,7 +1295,7 @@ gncal_full_day_button_release (GtkWidget *widget, GdkEventButton *event) case DRAG_SELECT: if ((event->time - di->click_time) < UNSELECT_TIMEOUT) - di->rows_used = 0; + di->sel_rows_used = 0; else recompute_motion (fullday, y); @@ -1278,9 +1321,6 @@ gncal_full_day_button_release (GtkWidget *widget, GdkEventButton *event) g_assert_not_reached (); } - if (!di->child || (event->window != di->child->window)) - return FALSE; - di->drag_mode = DRAG_NONE; di->child = NULL; @@ -1360,6 +1400,31 @@ gncal_full_day_expose (GtkWidget *widget, GdkEventExpose *event) } static gint +gncal_full_day_key_press (GtkWidget *widget, GdkEventKey *event) +{ + GncalFullDay *fullday; + struct drag_info *di; + + g_return_val_if_fail (widget != NULL, FALSE); + g_return_val_if_fail (GNCAL_IS_FULL_DAY (widget), FALSE); + g_return_val_if_fail (event != NULL, FALSE); + + fullday = GNCAL_FULL_DAY (widget); + + di = fullday->drag_info; + + if (di->sel_rows_used == 0) + return FALSE; + + if (event->keyval == GDK_Return) { + gtk_signal_emit (GTK_OBJECT (fullday), fullday_signals [RANGE_ACTIVATED]); + return TRUE; + } + + return FALSE; +} + +static gint gncal_full_day_focus_in (GtkWidget *widget, GdkEventFocus *event) { g_return_val_if_fail (widget != NULL, FALSE); @@ -1470,20 +1535,44 @@ gncal_full_day_set_bounds (GncalFullDay *fullday, time_t lower, time_t upper) } } -/* - * Returns the selected range - */ int gncal_full_day_selection_range (GncalFullDay *fullday, time_t *lower, time_t *upper) { struct drag_info *di; + time_t alower, aupper; + + g_return_val_if_fail (fullday != NULL, FALSE); + g_return_val_if_fail (GNCAL_IS_FULL_DAY (fullday), FALSE); + + di = fullday->drag_info; + + if (di->sel_rows_used == 0) + return FALSE; + + get_time_from_rows (fullday, di->sel_start_row, di->sel_rows_used, &alower, &aupper); + + if (lower) + *lower = alower; + + if (upper) + *upper= aupper; + + return TRUE; +} + +static void +range_activated (GncalFullDay *fullday) +{ + struct drag_info *di; - g_return_val_if_fail (fullday != NULL, 0); - g_return_val_if_fail (GNCAL_IS_FULL_DAY (fullday), 0); - g_return_val_if_fail (lower != NULL, 0); - g_return_val_if_fail (upper != NULL, 0); + g_return_if_fail (fullday != NULL); + g_return_if_fail (GNCAL_IS_FULL_DAY (fullday)); di = fullday->drag_info; - return 1; + /* Remove selection; at this point someone should already have added an appointment */ + + di->sel_rows_used = 0; + + paint_back (fullday, NULL); } diff --git a/calendar/gui/gncal-full-day.h b/calendar/gui/gncal-full-day.h index 27e60c9326..309924bc2e 100644 --- a/calendar/gui/gncal-full-day.h +++ b/calendar/gui/gncal-full-day.h @@ -44,14 +44,21 @@ struct _GncalFullDay { struct _GncalFullDayClass { GtkContainerClass parent_class; + + void (* range_activated) (GncalFullDay *fullday); }; -guint gncal_full_day_get_type (void); -GtkWidget *gncal_full_day_new (GnomeCalendar *calendar, time_t lower, time_t upper); +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_set_bounds (GncalFullDay *fullday, time_t lower, time_t upper); -void gncal_full_day_update (GncalFullDay *fullday); -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 + * selected, return value is FALSE, otherwise it is TRUE. + */ +int gncal_full_day_selection_range (GncalFullDay *fullday, time_t *lower, time_t *upper); END_GNOME_DECLS diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 00344a79f0..9fa59a22d8 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -6,7 +6,6 @@ */ #include <gnome.h> -#include <gdk/gdkkeysyms.h> #include "calendar.h" #include "gnome-cal.h" #include "gncal-full-day.h" @@ -40,19 +39,21 @@ gnome_calendar_get_type (void) } static void -day_view_key_press (GncalFullDay *fday, GdkEventKey *kevent, GnomeCalendar *gcal) +day_view_range_activated (GncalFullDay *fullday, GnomeCalendar *gcal) { iCalObject *ical; time_t start, end; - - if (kevent->keyval != GDK_Return) - return; - /* Create a new event on the selected range */ ical = ical_new ("", user_name, ""); ical->new = 1; -/* gncal_full_day_selection_range (gcal->day_view, &ical->dtstart, &ical->dtend); */ - event_editor_new (gcal, ical); + + gncal_full_day_selection_range (fullday, &start, &end); + + /* FIXME: this should insert the ical object into the calendar and somehow ask + * the fullday to update itself and focus the new child. + */ + +/* event_editor_new (gcal, ical); */ } static void @@ -65,16 +66,15 @@ setup_day_view (GnomeCalendar *gcal) b = time_end_of_day (now); gcal->day_view = gncal_full_day_new (gcal, a, b); - gtk_widget_set_events (gcal->day_view, - gtk_widget_get_events (gcal->day_view) | GDK_KEY_PRESS_MASK); + gtk_signal_connect (GTK_OBJECT (gcal->day_view), "range_activated", + (GtkSignalFunc) day_view_range_activated, + gcal); gcal->day_view_container = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (gcal->day_view_container), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (gcal->day_view_container), gcal->day_view); gtk_widget_show (gcal->day_view); - gtk_signal_connect (GTK_OBJECT (gcal->day_view), "key_press_event", - GTK_SIGNAL_FUNC (day_view_key_press), gcal); } static void diff --git a/calendar/gui/test.vcf b/calendar/gui/test.vcf index 2217537486..c90cc189d0 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:19980411T003000 -DTEND:19980411T010000 +DTSTART:19980412T003000 +DTEND:19980412T010000 SUMMARY:asdfasdfasfasdfasdf STATUS:NEEDS ACTION CLASS:PUBLIC @@ -25,8 +25,8 @@ DCREATED:19980402T023558 UID:KOrganizer - 846930886 SEQUENCE:1 LAST-MODIFIED:19980402T023558 -DTSTART:19980411T140000 -DTEND:19980411T160000 +DTSTART:19980412T140000 +DTEND:19980412T160000 SUMMARY:asdfasfdasfasdfasfd STATUS:NEEDS ACTION CLASS:PUBLIC |