diff options
author | Federico Mena Quintero <federico@nuclecu.unam.mx> | 1998-10-17 06:19:12 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1998-10-17 06:19:12 +0800 |
commit | 66701930a9995d48335f8cc28796bd36680d0e89 (patch) | |
tree | 3bbfd5b619c65e1360bdeb9e4b9e7144e516068b /calendar | |
parent | 4627acaf00c285354a823d612ca1c365f8c8e79d (diff) | |
download | gsoc2013-evolution-66701930a9995d48335f8cc28796bd36680d0e89.tar gsoc2013-evolution-66701930a9995d48335f8cc28796bd36680d0e89.tar.gz gsoc2013-evolution-66701930a9995d48335f8cc28796bd36680d0e89.tar.bz2 gsoc2013-evolution-66701930a9995d48335f8cc28796bd36680d0e89.tar.lz gsoc2013-evolution-66701930a9995d48335f8cc28796bd36680d0e89.tar.xz gsoc2013-evolution-66701930a9995d48335f8cc28796bd36680d0e89.tar.zst gsoc2013-evolution-66701930a9995d48335f8cc28796bd36680d0e89.zip |
Changed a lot of stuff not to use the layout code -- the month view's days
1998-10-16 Federico Mena Quintero <federico@nuclecu.unam.mx>
* month-view.c: Changed a lot of stuff not to use the layout code
-- the month view's days are too small to display layout
usefully. Now they display a little list of the events in each
day. We also have a popup menu for the days in the month view.
* calendar.c (calendar_get_objects_in_range): Reverse the list so
that it is returned in increasing order.
* eventedit.c (event_editor_new_whole_day): New public function to
create an event for the complete span of day_begin to day_end.
* year-view.c (new_appointment): Use event_editor_new_whole_day().
* year-view.c (yv_popup_menu): Mark strings for i18n.
svn path=/trunk/; revision=452
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 17 | ||||
-rw-r--r-- | calendar/TODO | 8 | ||||
-rw-r--r-- | calendar/calendar.c | 5 | ||||
-rw-r--r-- | calendar/eventedit.c | 33 | ||||
-rw-r--r-- | calendar/eventedit.h | 6 | ||||
-rw-r--r-- | calendar/gui/calendar.c | 5 | ||||
-rw-r--r-- | calendar/gui/eventedit.c | 33 | ||||
-rw-r--r-- | calendar/gui/eventedit.h | 6 | ||||
-rw-r--r-- | calendar/gui/month-view.c | 189 | ||||
-rw-r--r-- | calendar/gui/year-view.c | 35 | ||||
-rw-r--r-- | calendar/month-view.c | 189 | ||||
-rw-r--r-- | calendar/year-view.c | 35 |
12 files changed, 496 insertions, 65 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index bfc17a4a39..9bcf73a445 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,20 @@ +1998-10-16 Federico Mena Quintero <federico@nuclecu.unam.mx> + + * month-view.c: Changed a lot of stuff not to use the layout code + -- the month view's days are too small to display layout + usefully. Now they display a little list of the events in each + day. We also have a popup menu for the days in the month view. + + * calendar.c (calendar_get_objects_in_range): Reverse the list so + that it is returned in increasing order. + + * eventedit.c (event_editor_new_whole_day): New public function to + create an event for the complete span of day_begin to day_end. + + * year-view.c (new_appointment): Use event_editor_new_whole_day(). + + * year-view.c (yv_popup_menu): Mark strings for i18n. + 1998-10-12 Ji Lee <g@ucsd.edu> * eventedit.c (ee_store_recur_rule_to_ical): The interval was diff --git a/calendar/TODO b/calendar/TODO index 81a657d658..6d10b689da 100644 --- a/calendar/TODO +++ b/calendar/TODO @@ -1,7 +1,11 @@ BUGS: - Recurrence end date is wrong. An event that repeats daily will not - be included in the ending date of the recurrence (off-by-one error?). + be included in the ending date of the recurrence (off-by-one + error?). + +- X-fields (extensions) are stripped from a vCal file when it is + saved. They should be preserved. Year view: @@ -10,8 +14,6 @@ Year view: Month view: -- Display little boxes for the appointments of each day. - - Popup menu like in the year view. - Double click on a day takes you to the day view. diff --git a/calendar/calendar.c b/calendar/calendar.c index bacd7c9291..963f91be06 100644 --- a/calendar/calendar.c +++ b/calendar/calendar.c @@ -201,6 +201,11 @@ calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompar } } + /* Put the list in increasing order if no sort function was specified */ + + if (!sort_func) + new_events = g_list_reverse (new_events); + return new_events; } diff --git a/calendar/eventedit.c b/calendar/eventedit.c index c46da47c1f..a8a972158f 100644 --- a/calendar/eventedit.c +++ b/calendar/eventedit.c @@ -1482,3 +1482,36 @@ event_editor_new (GnomeCalendar *gcal, iCalObject *ical) return retval; } + +void +event_editor_new_whole_day (GnomeCalendar *owner, time_t day) +{ + struct tm tm; + iCalObject *ico; + GtkWidget *ee; + + g_return_if_fail (owner != NULL); + g_return_if_fail (GNOME_IS_CALENDAR (owner)); + + ico = ical_new ("", user_name, ""); + ico->new = TRUE; + + tm = *localtime (&day); + + /* Set the start time of the event to the beginning of the day */ + + tm.tm_hour = day_begin; + tm.tm_min = 0; + tm.tm_sec = 0; + ico->dtstart = mktime (&tm); + + /* Set the end time of the event to the end of the day */ + + tm.tm_hour = day_end; + ico->dtend = mktime (&tm); + + /* Launch the event editor */ + + ee = event_editor_new (owner, ico); + gtk_widget_show (ee); +} diff --git a/calendar/eventedit.h b/calendar/eventedit.h index 9cb80e3912..15ef540333 100644 --- a/calendar/eventedit.h +++ b/calendar/eventedit.h @@ -71,6 +71,12 @@ typedef struct { guint event_editor_get_type (void); GtkWidget *event_editor_new (GnomeCalendar *owner, iCalObject *); +/* Convenience function to create and show a new event editor for an event that goes from day_begin + * to day_end of the specified day. + */ +void event_editor_new_whole_day (GnomeCalendar *owner, time_t day); + + END_GNOME_DECLS diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c index bacd7c9291..963f91be06 100644 --- a/calendar/gui/calendar.c +++ b/calendar/gui/calendar.c @@ -201,6 +201,11 @@ calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompar } } + /* Put the list in increasing order if no sort function was specified */ + + if (!sort_func) + new_events = g_list_reverse (new_events); + return new_events; } diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c index c46da47c1f..a8a972158f 100644 --- a/calendar/gui/eventedit.c +++ b/calendar/gui/eventedit.c @@ -1482,3 +1482,36 @@ event_editor_new (GnomeCalendar *gcal, iCalObject *ical) return retval; } + +void +event_editor_new_whole_day (GnomeCalendar *owner, time_t day) +{ + struct tm tm; + iCalObject *ico; + GtkWidget *ee; + + g_return_if_fail (owner != NULL); + g_return_if_fail (GNOME_IS_CALENDAR (owner)); + + ico = ical_new ("", user_name, ""); + ico->new = TRUE; + + tm = *localtime (&day); + + /* Set the start time of the event to the beginning of the day */ + + tm.tm_hour = day_begin; + tm.tm_min = 0; + tm.tm_sec = 0; + ico->dtstart = mktime (&tm); + + /* Set the end time of the event to the end of the day */ + + tm.tm_hour = day_end; + ico->dtend = mktime (&tm); + + /* Launch the event editor */ + + ee = event_editor_new (owner, ico); + gtk_widget_show (ee); +} diff --git a/calendar/gui/eventedit.h b/calendar/gui/eventedit.h index 9cb80e3912..15ef540333 100644 --- a/calendar/gui/eventedit.h +++ b/calendar/gui/eventedit.h @@ -71,6 +71,12 @@ typedef struct { guint event_editor_get_type (void); GtkWidget *event_editor_new (GnomeCalendar *owner, iCalObject *); +/* Convenience function to create and show a new event editor for an event that goes from day_begin + * to day_end of the specified day. + */ +void event_editor_new_whole_day (GnomeCalendar *owner, time_t day); + + END_GNOME_DECLS diff --git a/calendar/gui/month-view.c b/calendar/gui/month-view.c index 7cce9b359e..07a92578dd 100644 --- a/calendar/gui/month-view.c +++ b/calendar/gui/month-view.c @@ -7,10 +7,12 @@ #include <config.h> #include <libgnomeui/gnome-canvas-text.h> +#include "eventedit.h" #include "layout.h" #include "month-view.h" #include "main.h" #include "mark.h" +#include "quick-view.h" #include "timeutil.h" @@ -71,6 +73,184 @@ month_view_class_init (MonthViewClass *class) widget_class->size_allocate = month_view_size_allocate; } +/* Creates the quick view when a day is clicked in the month view */ +static void +do_quick_view_popup (MonthView *mv, GdkEventButton *event, int day) +{ + time_t day_begin_time, day_end_time; + GList *list; + GtkWidget *qv; + char date_str[256]; + + day_begin_time = time_from_day (mv->year, mv->month, day); + day_end_time = time_day_end (day_begin_time); + + list = calendar_get_events_in_range (mv->calendar->cal, day_begin_time, day_end_time); + + strftime (date_str, sizeof (date_str), "%a %b %d %Y", localtime (&day_begin_time)); + qv = quick_view_new (mv->calendar, date_str, list); + + quick_view_do_popup (QUICK_VIEW (qv), event); + + gtk_widget_destroy (qv); + calendar_destroy_event_list (list); +} + +/* Callback used to destroy the popup menu when the month view is destroyed */ +static void +destroy_menu (GtkWidget *widget, gpointer data) +{ + gtk_widget_destroy (GTK_WIDGET (data)); +} + +/* Creates a new appointment in the current day */ +static void +new_appointment (GtkWidget *widget, gpointer data) +{ + MonthView *mv; + time_t *t; + + mv = MONTH_VIEW (data); + t = gtk_object_get_data (GTK_OBJECT (widget), "time_data"); + + event_editor_new_whole_day (mv->calendar, *t); +} + +/* Convenience functions to jump to a view and set the time */ +static void +do_jump (GtkWidget *widget, gpointer data, char *view_name) +{ + MonthView *mv; + time_t *t; + + mv = MONTH_VIEW (data); + + /* Get the time data from the menu item */ + + t = gtk_object_get_data (GTK_OBJECT (widget), "time_data"); + + /* Set the view and time */ + + gnome_calendar_set_view (mv->calendar, view_name); + gnome_calendar_goto (mv->calendar, *t); +} + +/* The following three callbacks set the view in the calendar and change the time */ + +static void +jump_to_day (GtkWidget *widget, gpointer data) +{ + do_jump (widget, data, "dayview"); +} + +static void +jump_to_week (GtkWidget *widget, gpointer data) +{ + do_jump (widget, data, "weekview"); +} + +static void +jump_to_year (GtkWidget *widget, gpointer data) +{ + do_jump (widget, data, "yearview"); +} + +static GnomeUIInfo mv_popup_menu[] = { + GNOMEUIINFO_ITEM_STOCK (N_("_New appointment in this day..."), NULL, new_appointment, GNOME_STOCK_MENU_NEW), + + GNOMEUIINFO_SEPARATOR, + + GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _day"), NULL, jump_to_day, GNOME_STOCK_MENU_JUMP_TO), + GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _week"), NULL, jump_to_week, GNOME_STOCK_MENU_JUMP_TO), + GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _year"), NULL, jump_to_year, GNOME_STOCK_MENU_JUMP_TO), + GNOMEUIINFO_END +}; + +/* Creates the popup menu for the month view if it does not yet exist, and attaches it to the month + * view object so that it can be destroyed when appropriate. + */ +static GtkWidget * +get_popup_menu (MonthView *mv) +{ + GtkWidget *menu; + + menu = gtk_object_get_data (GTK_OBJECT (mv), "popup_menu"); + + if (!menu) { + menu = gnome_popup_menu_new (mv_popup_menu); + gtk_object_set_data (GTK_OBJECT (mv), "popup_menu", menu); + gtk_signal_connect (GTK_OBJECT (mv), "destroy", + (GtkSignalFunc) destroy_menu, + menu); + } + + return menu; +} + +/* Pops up the menu for the month view. */ +static void +do_popup_menu (MonthView *mv, GdkEventButton *event, int day) +{ + GtkWidget *menu; + static time_t t; + + menu = get_popup_menu (mv); + + /* Enable or disable items as appropriate */ + + gtk_widget_set_sensitive (mv_popup_menu[0].widget, day != 0); + gtk_widget_set_sensitive (mv_popup_menu[2].widget, day != 0); + gtk_widget_set_sensitive (mv_popup_menu[3].widget, day != 0); + + if (day == 0) + day = 1; + + /* Store the time for the menu item callbacks to use */ + + t = time_from_day (mv->year, mv->month, day); + + gtk_object_set_data (GTK_OBJECT (mv_popup_menu[0].widget), "time_data", &t); + gtk_object_set_data (GTK_OBJECT (mv_popup_menu[2].widget), "time_data", &t); + gtk_object_set_data (GTK_OBJECT (mv_popup_menu[3].widget), "time_data", &t); + gtk_object_set_data (GTK_OBJECT (mv_popup_menu[4].widget), "time_data", &t); + + gnome_popup_menu_do_popup (menu, NULL, NULL, event, mv); +} + +/* Event handler for day groups. When mouse button 1 is pressed, it will pop up a quick view with + * the events in that day. When mouse button 3 is pressed, it will pop up a menu. + */ +static gint +day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data) +{ + MonthView *mv; + int child_num; + int day; + + mv = MONTH_VIEW (data); + + child_num = gnome_month_item_child2num (GNOME_MONTH_ITEM (mv->mitem), item); + day = gnome_month_item_num2day (GNOME_MONTH_ITEM (mv->mitem), child_num); + + switch (event->type) { + case GDK_BUTTON_PRESS: + if ((event->button.button == 1) && (day != 0)) { + do_quick_view_popup (mv, (GdkEventButton *) event, day); + return TRUE; + } else if (event->button.button == 3) { + do_popup_menu (mv, (GdkEventButton *) event, day); + return TRUE; + } + + break; + + default: + break; + } + + return FALSE; +} + /* Returns the index of the specified arrow in the array of arrows */ static int get_arrow_index (MonthView *mv, GnomeCanvasItem *arrow) @@ -188,6 +368,9 @@ arrow_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data) return TRUE; case GDK_BUTTON_PRESS: + if (event->button.button != 1) + break; + do_arrow_click (mv, item); return TRUE; @@ -251,7 +434,8 @@ month_view_init (MonthView *mv) NULL); /* Arrows and text items. The arrows start hidden by default; they will be shown as - * appropriate by the item adjustment code. + * appropriate by the item adjustment code. Also, connect to the event signal of the + * day groups so that we can pop up the quick view when appropriate. */ points = gnome_canvas_points_new (3); @@ -259,6 +443,9 @@ month_view_init (MonthView *mv) for (i = 0; i < 42; i++) { day_group = gnome_month_item_num2child (GNOME_MONTH_ITEM (mv->mitem), i + GNOME_MONTH_ITEM_DAY_GROUP); + gtk_signal_connect (GTK_OBJECT (day_group), "event", + (GtkSignalFunc) day_event, + mv); /* Up arrow */ diff --git a/calendar/gui/year-view.c b/calendar/gui/year-view.c index 5746d61803..113b842714 100644 --- a/calendar/gui/year-view.c +++ b/calendar/gui/year-view.c @@ -178,37 +178,12 @@ static void new_appointment (GtkWidget *widget, gpointer data) { YearView *yv; - GtkWidget *ee; time_t *t; - struct tm tm; - iCalObject *ico; yv = YEAR_VIEW (data); - - /* Get the time data from the menu item */ - t = gtk_object_get_data (GTK_OBJECT (widget), "time_data"); - tm = *localtime (t); - - ico = ical_new ("", user_name, ""); - ico->new = TRUE; - - /* Set the start time of the event to the beginning of the day */ - - tm.tm_hour = day_begin; - tm.tm_min = 0; - tm.tm_sec = 0; - ico->dtstart = mktime (&tm); - - /* Set the end time of the event to the end of the day */ - - tm.tm_hour = day_end; - ico->dtend = mktime (&tm); - - /* Launch the event editor */ - ee = event_editor_new (yv->calendar, ico); - gtk_widget_show (ee); + event_editor_new_whole_day (yv->calendar, *t); } /* Convenience functions to jump to a view and set the time */ @@ -252,13 +227,13 @@ jump_to_month (GtkWidget *widget, gpointer data) /* Information for the year view's popup menu */ static GnomeUIInfo yv_popup_menu[] = { - GNOMEUIINFO_ITEM_STOCK ("_New appointment in this day...", NULL, new_appointment, GNOME_STOCK_MENU_NEW), + GNOMEUIINFO_ITEM_STOCK (N_("_New appointment in this day..."), NULL, new_appointment, GNOME_STOCK_MENU_NEW), GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_STOCK ("Jump to this _day", NULL, jump_to_day, GNOME_STOCK_MENU_JUMP_TO), - GNOMEUIINFO_ITEM_STOCK ("Jump to this _week", NULL, jump_to_week, GNOME_STOCK_MENU_JUMP_TO), - GNOMEUIINFO_ITEM_STOCK ("Jump to this _month", NULL, jump_to_month, GNOME_STOCK_MENU_JUMP_TO), + GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _day"), NULL, jump_to_day, GNOME_STOCK_MENU_JUMP_TO), + GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _week"), NULL, jump_to_week, GNOME_STOCK_MENU_JUMP_TO), + GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _month"), NULL, jump_to_month, GNOME_STOCK_MENU_JUMP_TO), GNOMEUIINFO_END }; diff --git a/calendar/month-view.c b/calendar/month-view.c index 7cce9b359e..07a92578dd 100644 --- a/calendar/month-view.c +++ b/calendar/month-view.c @@ -7,10 +7,12 @@ #include <config.h> #include <libgnomeui/gnome-canvas-text.h> +#include "eventedit.h" #include "layout.h" #include "month-view.h" #include "main.h" #include "mark.h" +#include "quick-view.h" #include "timeutil.h" @@ -71,6 +73,184 @@ month_view_class_init (MonthViewClass *class) widget_class->size_allocate = month_view_size_allocate; } +/* Creates the quick view when a day is clicked in the month view */ +static void +do_quick_view_popup (MonthView *mv, GdkEventButton *event, int day) +{ + time_t day_begin_time, day_end_time; + GList *list; + GtkWidget *qv; + char date_str[256]; + + day_begin_time = time_from_day (mv->year, mv->month, day); + day_end_time = time_day_end (day_begin_time); + + list = calendar_get_events_in_range (mv->calendar->cal, day_begin_time, day_end_time); + + strftime (date_str, sizeof (date_str), "%a %b %d %Y", localtime (&day_begin_time)); + qv = quick_view_new (mv->calendar, date_str, list); + + quick_view_do_popup (QUICK_VIEW (qv), event); + + gtk_widget_destroy (qv); + calendar_destroy_event_list (list); +} + +/* Callback used to destroy the popup menu when the month view is destroyed */ +static void +destroy_menu (GtkWidget *widget, gpointer data) +{ + gtk_widget_destroy (GTK_WIDGET (data)); +} + +/* Creates a new appointment in the current day */ +static void +new_appointment (GtkWidget *widget, gpointer data) +{ + MonthView *mv; + time_t *t; + + mv = MONTH_VIEW (data); + t = gtk_object_get_data (GTK_OBJECT (widget), "time_data"); + + event_editor_new_whole_day (mv->calendar, *t); +} + +/* Convenience functions to jump to a view and set the time */ +static void +do_jump (GtkWidget *widget, gpointer data, char *view_name) +{ + MonthView *mv; + time_t *t; + + mv = MONTH_VIEW (data); + + /* Get the time data from the menu item */ + + t = gtk_object_get_data (GTK_OBJECT (widget), "time_data"); + + /* Set the view and time */ + + gnome_calendar_set_view (mv->calendar, view_name); + gnome_calendar_goto (mv->calendar, *t); +} + +/* The following three callbacks set the view in the calendar and change the time */ + +static void +jump_to_day (GtkWidget *widget, gpointer data) +{ + do_jump (widget, data, "dayview"); +} + +static void +jump_to_week (GtkWidget *widget, gpointer data) +{ + do_jump (widget, data, "weekview"); +} + +static void +jump_to_year (GtkWidget *widget, gpointer data) +{ + do_jump (widget, data, "yearview"); +} + +static GnomeUIInfo mv_popup_menu[] = { + GNOMEUIINFO_ITEM_STOCK (N_("_New appointment in this day..."), NULL, new_appointment, GNOME_STOCK_MENU_NEW), + + GNOMEUIINFO_SEPARATOR, + + GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _day"), NULL, jump_to_day, GNOME_STOCK_MENU_JUMP_TO), + GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _week"), NULL, jump_to_week, GNOME_STOCK_MENU_JUMP_TO), + GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _year"), NULL, jump_to_year, GNOME_STOCK_MENU_JUMP_TO), + GNOMEUIINFO_END +}; + +/* Creates the popup menu for the month view if it does not yet exist, and attaches it to the month + * view object so that it can be destroyed when appropriate. + */ +static GtkWidget * +get_popup_menu (MonthView *mv) +{ + GtkWidget *menu; + + menu = gtk_object_get_data (GTK_OBJECT (mv), "popup_menu"); + + if (!menu) { + menu = gnome_popup_menu_new (mv_popup_menu); + gtk_object_set_data (GTK_OBJECT (mv), "popup_menu", menu); + gtk_signal_connect (GTK_OBJECT (mv), "destroy", + (GtkSignalFunc) destroy_menu, + menu); + } + + return menu; +} + +/* Pops up the menu for the month view. */ +static void +do_popup_menu (MonthView *mv, GdkEventButton *event, int day) +{ + GtkWidget *menu; + static time_t t; + + menu = get_popup_menu (mv); + + /* Enable or disable items as appropriate */ + + gtk_widget_set_sensitive (mv_popup_menu[0].widget, day != 0); + gtk_widget_set_sensitive (mv_popup_menu[2].widget, day != 0); + gtk_widget_set_sensitive (mv_popup_menu[3].widget, day != 0); + + if (day == 0) + day = 1; + + /* Store the time for the menu item callbacks to use */ + + t = time_from_day (mv->year, mv->month, day); + + gtk_object_set_data (GTK_OBJECT (mv_popup_menu[0].widget), "time_data", &t); + gtk_object_set_data (GTK_OBJECT (mv_popup_menu[2].widget), "time_data", &t); + gtk_object_set_data (GTK_OBJECT (mv_popup_menu[3].widget), "time_data", &t); + gtk_object_set_data (GTK_OBJECT (mv_popup_menu[4].widget), "time_data", &t); + + gnome_popup_menu_do_popup (menu, NULL, NULL, event, mv); +} + +/* Event handler for day groups. When mouse button 1 is pressed, it will pop up a quick view with + * the events in that day. When mouse button 3 is pressed, it will pop up a menu. + */ +static gint +day_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data) +{ + MonthView *mv; + int child_num; + int day; + + mv = MONTH_VIEW (data); + + child_num = gnome_month_item_child2num (GNOME_MONTH_ITEM (mv->mitem), item); + day = gnome_month_item_num2day (GNOME_MONTH_ITEM (mv->mitem), child_num); + + switch (event->type) { + case GDK_BUTTON_PRESS: + if ((event->button.button == 1) && (day != 0)) { + do_quick_view_popup (mv, (GdkEventButton *) event, day); + return TRUE; + } else if (event->button.button == 3) { + do_popup_menu (mv, (GdkEventButton *) event, day); + return TRUE; + } + + break; + + default: + break; + } + + return FALSE; +} + /* Returns the index of the specified arrow in the array of arrows */ static int get_arrow_index (MonthView *mv, GnomeCanvasItem *arrow) @@ -188,6 +368,9 @@ arrow_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data) return TRUE; case GDK_BUTTON_PRESS: + if (event->button.button != 1) + break; + do_arrow_click (mv, item); return TRUE; @@ -251,7 +434,8 @@ month_view_init (MonthView *mv) NULL); /* Arrows and text items. The arrows start hidden by default; they will be shown as - * appropriate by the item adjustment code. + * appropriate by the item adjustment code. Also, connect to the event signal of the + * day groups so that we can pop up the quick view when appropriate. */ points = gnome_canvas_points_new (3); @@ -259,6 +443,9 @@ month_view_init (MonthView *mv) for (i = 0; i < 42; i++) { day_group = gnome_month_item_num2child (GNOME_MONTH_ITEM (mv->mitem), i + GNOME_MONTH_ITEM_DAY_GROUP); + gtk_signal_connect (GTK_OBJECT (day_group), "event", + (GtkSignalFunc) day_event, + mv); /* Up arrow */ diff --git a/calendar/year-view.c b/calendar/year-view.c index 5746d61803..113b842714 100644 --- a/calendar/year-view.c +++ b/calendar/year-view.c @@ -178,37 +178,12 @@ static void new_appointment (GtkWidget *widget, gpointer data) { YearView *yv; - GtkWidget *ee; time_t *t; - struct tm tm; - iCalObject *ico; yv = YEAR_VIEW (data); - - /* Get the time data from the menu item */ - t = gtk_object_get_data (GTK_OBJECT (widget), "time_data"); - tm = *localtime (t); - - ico = ical_new ("", user_name, ""); - ico->new = TRUE; - - /* Set the start time of the event to the beginning of the day */ - - tm.tm_hour = day_begin; - tm.tm_min = 0; - tm.tm_sec = 0; - ico->dtstart = mktime (&tm); - - /* Set the end time of the event to the end of the day */ - - tm.tm_hour = day_end; - ico->dtend = mktime (&tm); - - /* Launch the event editor */ - ee = event_editor_new (yv->calendar, ico); - gtk_widget_show (ee); + event_editor_new_whole_day (yv->calendar, *t); } /* Convenience functions to jump to a view and set the time */ @@ -252,13 +227,13 @@ jump_to_month (GtkWidget *widget, gpointer data) /* Information for the year view's popup menu */ static GnomeUIInfo yv_popup_menu[] = { - GNOMEUIINFO_ITEM_STOCK ("_New appointment in this day...", NULL, new_appointment, GNOME_STOCK_MENU_NEW), + GNOMEUIINFO_ITEM_STOCK (N_("_New appointment in this day..."), NULL, new_appointment, GNOME_STOCK_MENU_NEW), GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_STOCK ("Jump to this _day", NULL, jump_to_day, GNOME_STOCK_MENU_JUMP_TO), - GNOMEUIINFO_ITEM_STOCK ("Jump to this _week", NULL, jump_to_week, GNOME_STOCK_MENU_JUMP_TO), - GNOMEUIINFO_ITEM_STOCK ("Jump to this _month", NULL, jump_to_month, GNOME_STOCK_MENU_JUMP_TO), + GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _day"), NULL, jump_to_day, GNOME_STOCK_MENU_JUMP_TO), + GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _week"), NULL, jump_to_week, GNOME_STOCK_MENU_JUMP_TO), + GNOMEUIINFO_ITEM_STOCK (N_("Jump to this _month"), NULL, jump_to_month, GNOME_STOCK_MENU_JUMP_TO), GNOMEUIINFO_END }; |