From bf844f9fa82ee8540f99df6bd1bb533e99a70562 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Tue, 25 Aug 1998 02:19:20 +0000 Subject: Today: Beautification of the Preferences dialog. Made the menus more Today: Beautification of the Preferences dialog. Made the menus more consistent with the rest of GNOME. Started work on the meat of the month view. Minor fixups on some of the other views. 1998-08-24 Federico Mena Quintero * prop.c (build_two_radio_group): Doh. Set the state of the radio buttons properly. * month-view.c (month_view_time_format_changed): New public function that notifies the month view of a time format change. * gnome-cal.c (gnome_calendar_time_format_changed): New public function that notifies the calendar of a time format change. * main.c (time_format_changed): Use gnome_calendar_time_format_changed(). * month-view.c (month_view_update): New public function to update the month view when an event changes. This is still unfinished. (month_view_set): New public function to set the month in the month view. * gnome-cal.c (gnome_calendar_direction): Add case for month view. (gnome_calendar_set_view): Likewise. (gnome_calendar_update_all): Likewise. * timeutil.c (time_add_week): Implemented the time_add_week() function, which was on the header file. (time_add_month): Added public month-adding routine. * gnome-cal.c (gnome_calendar_get_current_view_name): Add case for month view. (gnome_calendar_goto): Likewise, and set the time on the month view. * month-view.c (month_view_new): Now it takes the calendar plus the time_t representing the month. * gnome-month-item.h: Added documentation on the object arguments for the month item. * month-view.c (month_view_init): Added a month/year heading to the month view. * TODO: Updated the TODO list a bit. * main.c (gnome_cal_file_menu): The preferences menu option should go in the File menu. (gnome_cal_edit_menu): Added stock pixmaps to the menu items. (gnome_cal_menu): Renamed the Calendar menu to Edit. (gnome_cal_help_menu): Use "About Gnomecal", not just "About". * prop.c (hour_activated): Notify the property box that it has changed. svn path=/trunk/; revision=337 --- calendar/ChangeLog | 47 +++++++++++++++++++++ calendar/TODO | 37 +++++++++-------- calendar/gnome-cal.c | 29 +++++++++++-- calendar/gnome-cal.h | 4 ++ calendar/gnome-month-item.h | 21 ++++++++++ calendar/gui/gnome-cal.c | 29 +++++++++++-- calendar/gui/gnome-cal.h | 4 ++ calendar/gui/gnome-month-item.h | 21 ++++++++++ calendar/gui/main.c | 66 +++++++++++------------------- calendar/gui/month-view.c | 91 +++++++++++++++++++++++++++++++++++++++-- calendar/gui/month-view.h | 12 +++++- calendar/gui/prop.c | 3 ++ calendar/main.c | 66 +++++++++++------------------- calendar/month-view.c | 91 +++++++++++++++++++++++++++++++++++++++-- calendar/month-view.h | 12 +++++- calendar/prop.c | 3 ++ calendar/timeutil.c | 31 ++++++++++++-- calendar/timeutil.h | 1 + 18 files changed, 448 insertions(+), 120 deletions(-) (limited to 'calendar') diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 17ff9c0115..8854d69ab8 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,5 +1,52 @@ 1998-08-24 Federico Mena Quintero + * prop.c (build_two_radio_group): Doh. Set the state of the radio + buttons properly. + + * month-view.c (month_view_time_format_changed): New public + function that notifies the month view of a time format change. + + * gnome-cal.c (gnome_calendar_time_format_changed): New public + function that notifies the calendar of a time format change. + + * main.c (time_format_changed): Use gnome_calendar_time_format_changed(). + + * month-view.c (month_view_update): New public function to update + the month view when an event changes. This is still unfinished. + (month_view_set): New public function to set the month in the + month view. + + * gnome-cal.c (gnome_calendar_direction): Add case for month view. + (gnome_calendar_set_view): Likewise. + (gnome_calendar_update_all): Likewise. + + * timeutil.c (time_add_week): Implemented the time_add_week() + function, which was on the header file. + (time_add_month): Added public month-adding routine. + + * gnome-cal.c (gnome_calendar_get_current_view_name): Add case for + month view. + (gnome_calendar_goto): Likewise, and set the time on the month view. + + * month-view.c (month_view_new): Now it takes the calendar plus + the time_t representing the month. + + * gnome-month-item.h: Added documentation on the object arguments + for the month item. + + * month-view.c (month_view_init): Added a month/year heading to + the month view. + + * TODO: Updated the TODO list a bit. + + * main.c (gnome_cal_file_menu): The preferences menu option should + go in the File menu. + (gnome_cal_edit_menu): Added stock pixmaps to the menu items. + (gnome_cal_menu): Renamed the Calendar menu to Edit. + (gnome_cal_help_menu): Use "About Gnomecal", not just "About". + + * prop.c (hour_activated): Notify the property box that it has changed. + * main.c: Changed the Properties menu item to Preferences. These are global application preferences, not a single calendar's properties. diff --git a/calendar/TODO b/calendar/TODO index f7898ed7ca..eca41ce244 100644 --- a/calendar/TODO +++ b/calendar/TODO @@ -1,6 +1,24 @@ -Preferences: +Month view: + +- Display little boxes for the appointments of each day. + +- Double click on a day takes you to the day view. + +- DnD of appointments to move them around. + +Year view: + +- Make it use GnomeMonthItem to make it have a reasonable size. + +Week view: + +- Nice display as in the Palm Pilot. + +Day view: -- Add possibility to start weeks also on monday (European calendar mode) +- Rewrite in terms of the canvas and make it pretty. + +Preferences: - BUG: 12/24 hours stuff is not consistent - I remember that on editing new appointment you get the time-selectors always on 12-hr format @@ -15,21 +33,6 @@ Gnome date selection widget: - Make the displayed date be localized properly -- use strftime(). -Full day widget: - -- Display alarm/whatever flags somewhere. - -- Layout the children nicely like M$ Schedule or Netscape Calendar do - (i.e. make them not overlap each other). - -Month view: - -- Write a month view widget. - -Week view: - -- Replace the calendar by a `task density' widget like in Solaris cm. - General: - Write online help. Nice help. Lots of help. diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c index e3f1250687..c9c62101b9 100644 --- a/calendar/gnome-cal.c +++ b/calendar/gnome-cal.c @@ -51,7 +51,7 @@ setup_widgets (GnomeCalendar *gcal) gcal->notebook = gtk_notebook_new (); gcal->day_view = gncal_day_panel_new (gcal, now); gcal->week_view = gncal_week_view_new (gcal, now); - gcal->month_view = month_view_new (gcal); + gcal->month_view = month_view_new (gcal, now); gcal->year_view = gncal_year_view_new (gcal, now); gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->day_view, gtk_label_new (_("Day View"))); @@ -80,6 +80,8 @@ gnome_calendar_get_current_view_name (GnomeCalendar *gcal) return "dayview"; else if (page == gcal->week_view) return "weekview"; + else if (page == gcal->month_view) + return "monthview"; else if (page == gcal->year_view) return "yearview"; else @@ -99,6 +101,8 @@ gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time) gncal_day_panel_set (GNCAL_DAY_PANEL (gcal->day_view), new_time); else if (current == gcal->week_view) gncal_week_view_set (GNCAL_WEEK_VIEW (gcal->week_view), new_time); + else if (current == gcal->month_view) + month_view_set (MONTH_VIEW (gcal->month_view), new_time); else if (current == gcal->year_view) gncal_year_view_set (GNCAL_YEAR_VIEW (gcal->year_view), new_time); else { @@ -118,7 +122,9 @@ gnome_calendar_direction (GnomeCalendar *gcal, int direction) if (cp == gcal->day_view) new_time = time_add_day (gcal->current_display, 1 * direction); else if (cp == gcal->week_view) - new_time = time_add_day (gcal->current_display, 7 * direction); + new_time = time_add_week (gcal->current_display, 1 * direction); + else if (cp == gcal->month_view) + new_time = time_add_month (gcal->current_display, 1 * direction); else if (cp == gcal->year_view) new_time = time_add_year (gcal->current_display, 1 * direction); else { @@ -164,8 +170,10 @@ gnome_calendar_set_view (GnomeCalendar *gcal, char *page_name) page = 0; else if (strcmp (page_name, "weekview") == 0) page = 1; - else if (strcmp (page_name, "yearview") == 0) + else if (strcmp (page_name, "monthview") == 0) page = 2; + else if (strcmp (page_name, "yearview") == 0) + page = 3; gtk_notebook_set_page (GTK_NOTEBOOK (gcal->notebook), page); } @@ -196,6 +204,7 @@ gnome_calendar_update_all (GnomeCalendar *cal, iCalObject *object, int flags) { gncal_day_panel_update (GNCAL_DAY_PANEL (cal->day_view), object, flags); gncal_week_view_update (GNCAL_WEEK_VIEW (cal->week_view), object, flags); + month_view_update (MONTH_VIEW (cal->month_view), object, flags); gncal_year_view_update (GNCAL_YEAR_VIEW (cal->year_view), object, flags); } @@ -417,3 +426,17 @@ gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal) calendar_iterate (cal->cal, month_begin, month_end, mark_gtk_calendar_day, gtk_cal); gtk_calendar_thaw (gtk_cal); } + +void +gnome_calendar_time_format_changed (GnomeCalendar *gcal) +{ + g_return_if_fail (gcal != NULL); + g_return_if_fail (GNOME_IS_CALENDAR (gcal)); + + /* FIXME: the queue resizes will do until we rewrite those views... */ + + gtk_widget_queue_resize (gcal->day_view); + gtk_widget_queue_resize (gcal->week_view); + month_view_time_format_changed (MONTH_VIEW (gcal->month_view)); + gtk_widget_queue_resize (gcal->year_view); +} diff --git a/calendar/gnome-cal.h b/calendar/gnome-cal.h index 0d6c9525d9..186e90bc83 100644 --- a/calendar/gnome-cal.h +++ b/calendar/gnome-cal.h @@ -64,6 +64,10 @@ void gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags); +/* Notifies the calendar that the time format has changed and it must update all its views */ +void gnome_calendar_time_format_changed (GnomeCalendar *gcal); + + END_GNOME_DECLS #endif diff --git a/calendar/gnome-month-item.h b/calendar/gnome-month-item.h index b1b11f9d01..03ba0c84a7 100644 --- a/calendar/gnome-month-item.h +++ b/calendar/gnome-month-item.h @@ -46,6 +46,27 @@ typedef enum { GNOME_MONTH_ITEM_LAST = 147 /* total number of items */ } GnomeMonthItemChild; +/* The MonthItem canvas item defines a simple monthly calendar. It is made out of a number of + * canvas items, which can be accessed using the functions provided. The monthly calendar is + * anchored with respect to a point. The following arguments are available: + * + * name type read/write description + * ------------------------------------------------------------------------------------------ + * year uint RW Full year (1-9999) + * month uint RW Number of month (0-11) + * x double RW X position of anchor point + * y double RW Y position of anchor point + * width double RW Width of calendar in canvas units + * height double RW Height of calendar in canvas units + * anchor GtkAnchorType RW Anchor side for calendar + * head_padding double RW Padding inside heading boxes + * day_padding double RW Padding inside day boxes + * day_names char ** R Array of strings corresponding to the day names (sun-sat) + * heading_height double RW Height of headings bar in canvas units + * heading_anchor GtkAnchorType RW Anchor side for headings inside heading boxes + * day_anchor GtkAnchorType RW Anchor side for day numbers inside day boxes + * start_on_monday boolean RW Specifies whether the week starts on Monday or Sunday + */ #define GNOME_TYPE_MONTH_ITEM (gnome_month_item_get_type ()) #define GNOME_MONTH_ITEM(obj) (GTK_CHECK_CAST ((obj), GNOME_TYPE_MONTH_ITEM, GnomeMonthItem)) diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index e3f1250687..c9c62101b9 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -51,7 +51,7 @@ setup_widgets (GnomeCalendar *gcal) gcal->notebook = gtk_notebook_new (); gcal->day_view = gncal_day_panel_new (gcal, now); gcal->week_view = gncal_week_view_new (gcal, now); - gcal->month_view = month_view_new (gcal); + gcal->month_view = month_view_new (gcal, now); gcal->year_view = gncal_year_view_new (gcal, now); gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->day_view, gtk_label_new (_("Day View"))); @@ -80,6 +80,8 @@ gnome_calendar_get_current_view_name (GnomeCalendar *gcal) return "dayview"; else if (page == gcal->week_view) return "weekview"; + else if (page == gcal->month_view) + return "monthview"; else if (page == gcal->year_view) return "yearview"; else @@ -99,6 +101,8 @@ gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time) gncal_day_panel_set (GNCAL_DAY_PANEL (gcal->day_view), new_time); else if (current == gcal->week_view) gncal_week_view_set (GNCAL_WEEK_VIEW (gcal->week_view), new_time); + else if (current == gcal->month_view) + month_view_set (MONTH_VIEW (gcal->month_view), new_time); else if (current == gcal->year_view) gncal_year_view_set (GNCAL_YEAR_VIEW (gcal->year_view), new_time); else { @@ -118,7 +122,9 @@ gnome_calendar_direction (GnomeCalendar *gcal, int direction) if (cp == gcal->day_view) new_time = time_add_day (gcal->current_display, 1 * direction); else if (cp == gcal->week_view) - new_time = time_add_day (gcal->current_display, 7 * direction); + new_time = time_add_week (gcal->current_display, 1 * direction); + else if (cp == gcal->month_view) + new_time = time_add_month (gcal->current_display, 1 * direction); else if (cp == gcal->year_view) new_time = time_add_year (gcal->current_display, 1 * direction); else { @@ -164,8 +170,10 @@ gnome_calendar_set_view (GnomeCalendar *gcal, char *page_name) page = 0; else if (strcmp (page_name, "weekview") == 0) page = 1; - else if (strcmp (page_name, "yearview") == 0) + else if (strcmp (page_name, "monthview") == 0) page = 2; + else if (strcmp (page_name, "yearview") == 0) + page = 3; gtk_notebook_set_page (GTK_NOTEBOOK (gcal->notebook), page); } @@ -196,6 +204,7 @@ gnome_calendar_update_all (GnomeCalendar *cal, iCalObject *object, int flags) { gncal_day_panel_update (GNCAL_DAY_PANEL (cal->day_view), object, flags); gncal_week_view_update (GNCAL_WEEK_VIEW (cal->week_view), object, flags); + month_view_update (MONTH_VIEW (cal->month_view), object, flags); gncal_year_view_update (GNCAL_YEAR_VIEW (cal->year_view), object, flags); } @@ -417,3 +426,17 @@ gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal) calendar_iterate (cal->cal, month_begin, month_end, mark_gtk_calendar_day, gtk_cal); gtk_calendar_thaw (gtk_cal); } + +void +gnome_calendar_time_format_changed (GnomeCalendar *gcal) +{ + g_return_if_fail (gcal != NULL); + g_return_if_fail (GNOME_IS_CALENDAR (gcal)); + + /* FIXME: the queue resizes will do until we rewrite those views... */ + + gtk_widget_queue_resize (gcal->day_view); + gtk_widget_queue_resize (gcal->week_view); + month_view_time_format_changed (MONTH_VIEW (gcal->month_view)); + gtk_widget_queue_resize (gcal->year_view); +} diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 0d6c9525d9..186e90bc83 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -64,6 +64,10 @@ void gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags); +/* Notifies the calendar that the time format has changed and it must update all its views */ +void gnome_calendar_time_format_changed (GnomeCalendar *gcal); + + END_GNOME_DECLS #endif diff --git a/calendar/gui/gnome-month-item.h b/calendar/gui/gnome-month-item.h index b1b11f9d01..03ba0c84a7 100644 --- a/calendar/gui/gnome-month-item.h +++ b/calendar/gui/gnome-month-item.h @@ -46,6 +46,27 @@ typedef enum { GNOME_MONTH_ITEM_LAST = 147 /* total number of items */ } GnomeMonthItemChild; +/* The MonthItem canvas item defines a simple monthly calendar. It is made out of a number of + * canvas items, which can be accessed using the functions provided. The monthly calendar is + * anchored with respect to a point. The following arguments are available: + * + * name type read/write description + * ------------------------------------------------------------------------------------------ + * year uint RW Full year (1-9999) + * month uint RW Number of month (0-11) + * x double RW X position of anchor point + * y double RW Y position of anchor point + * width double RW Width of calendar in canvas units + * height double RW Height of calendar in canvas units + * anchor GtkAnchorType RW Anchor side for calendar + * head_padding double RW Padding inside heading boxes + * day_padding double RW Padding inside day boxes + * day_names char ** R Array of strings corresponding to the day names (sun-sat) + * heading_height double RW Height of headings bar in canvas units + * heading_anchor GtkAnchorType RW Anchor side for headings inside heading boxes + * day_anchor GtkAnchorType RW Anchor side for day numbers inside day boxes + * start_on_monday boolean RW Specifies whether the week starts on Monday or Sunday + */ #define GNOME_TYPE_MONTH_ITEM (gnome_month_item_get_type ()) #define GNOME_MONTH_ITEM(obj) (GTK_CHECK_CAST ((obj), GNOME_TYPE_MONTH_ITEM, GnomeMonthItem)) diff --git a/calendar/gui/main.c b/calendar/gui/main.c index 55aa861e0c..9f8bcae2dd 100644 --- a/calendar/gui/main.c +++ b/calendar/gui/main.c @@ -4,7 +4,7 @@ * * Authors: * Miguel de Icaza (miguel@kernel.org) - * Federico Mena (quartic@gimp.org) + * Federico Mena (federico@nuclecu.unam.mx) */ #include @@ -193,13 +193,8 @@ time_format_changed (void) { GList *l; - /* FIXME: update all the calendars and stuff */ - - for (l = all_calendars; l; l = l->next){ - GnomeCalendar *cal = GNOME_CALENDAR (l->data); - - gtk_widget_queue_resize (cal->notebook); - } + for (l = all_calendars; l; l = l->next) + gnome_calendar_time_format_changed (GNOME_CALENDAR (l->data)); } static void @@ -327,66 +322,51 @@ save_calendar_cmd (GtkWidget *widget, void *data) } static GnomeUIInfo gnome_cal_file_menu [] = { - { GNOME_APP_UI_ITEM, N_("New calendar"), NULL, new_calendar_cmd, NULL, NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_NEW }, + GNOMEUIINFO_ITEM_STOCK (N_("New calendar"), NULL, new_calendar_cmd, GNOME_STOCK_MENU_NEW), + GNOMEUIINFO_ITEM_STOCK (N_("Open calendar..."), NULL, open_calendar_cmd, GNOME_STOCK_MENU_OPEN), + GNOMEUIINFO_ITEM_STOCK (N_("Save calendar"), NULL, save_calendar_cmd, GNOME_STOCK_MENU_SAVE), + GNOMEUIINFO_ITEM_STOCK (N_("Save calendar as..."), NULL, save_as_calendar_cmd, GNOME_STOCK_MENU_SAVE), - { GNOME_APP_UI_ITEM, N_("Open calendar..."), NULL, open_calendar_cmd, NULL, NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_OPEN }, - - { GNOME_APP_UI_ITEM, N_("Save calendar"), NULL, save_calendar_cmd, NULL, NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE }, + GNOMEUIINFO_SEPARATOR, - { GNOME_APP_UI_ITEM, N_("Save calendar as..."), NULL, save_as_calendar_cmd, NULL, NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE }, + GNOMEUIINFO_ITEM_STOCK (N_("Preferences..."), NULL, properties, GNOME_STOCK_MENU_PREF), - { GNOME_APP_UI_SEPARATOR }, - { GNOME_APP_UI_ITEM, N_("Close this calendar"), NULL, close_cmd, NULL, NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT }, + GNOMEUIINFO_SEPARATOR, - { GNOME_APP_UI_ITEM, N_("Exit"), NULL, quit_cmd, NULL, NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT }, + GNOMEUIINFO_ITEM_STOCK (N_("Close this calendar"), NULL, close_cmd, GNOME_STOCK_MENU_EXIT), + GNOMEUIINFO_ITEM_STOCK (N_("Exit"), NULL, quit_cmd, GNOME_STOCK_MENU_EXIT), GNOMEUIINFO_END }; -static GnomeUIInfo gnome_cal_about_menu [] = { - { GNOME_APP_UI_ITEM, N_("About..."), NULL, about_calendar_cmd, NULL, NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_ABOUT }, +static GnomeUIInfo gnome_cal_help_menu [] = { + GNOMEUIINFO_ITEM_STOCK (N_("About Gnomecal..."), NULL, about_calendar_cmd, GNOME_STOCK_MENU_ABOUT), GNOMEUIINFO_SEPARATOR, GNOMEUIINFO_HELP ("cal"), GNOMEUIINFO_END }; static GnomeUIInfo gnome_cal_edit_menu [] = { - { GNOME_APP_UI_ITEM, N_("New appointment..."), NULL, display_objedit }, - { GNOME_APP_UI_ITEM, N_("New appointment for today..."), NULL, display_objedit_today }, - GNOMEUIINFO_SEPARATOR, - { GNOME_APP_UI_ITEM, N_("Preferences..."), NULL, properties, NULL, NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PREF }, + GNOMEUIINFO_ITEM_STOCK (N_("New appointment..."), NULL, display_objedit, GNOME_STOCK_MENU_NEW), + GNOMEUIINFO_ITEM_STOCK (N_("New appointment for today..."), NULL, display_objedit_today, GNOME_STOCK_MENU_NEW), GNOMEUIINFO_END }; static GnomeUIInfo gnome_cal_menu [] = { - { GNOME_APP_UI_SUBTREE, N_("File"), NULL, &gnome_cal_file_menu }, - { GNOME_APP_UI_SUBTREE, N_("Calendar"), NULL, &gnome_cal_edit_menu }, - { GNOME_APP_UI_SUBTREE, N_("Help"), NULL, &gnome_cal_about_menu }, + GNOMEUIINFO_SUBTREE (N_("File"), &gnome_cal_file_menu), + GNOMEUIINFO_SUBTREE (N_("Edit"), &gnome_cal_edit_menu), + GNOMEUIINFO_SUBTREE (N_("Help"), &gnome_cal_help_menu), GNOMEUIINFO_END }; static GnomeUIInfo gnome_toolbar [] = { - { GNOME_APP_UI_ITEM, N_("New"), N_("Create a new appointment"), display_objedit, 0, 0, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_NEW }, + GNOMEUIINFO_ITEM_STOCK (N_("New"), N_("Create a new appointment"), display_objedit, GNOME_STOCK_PIXMAP_NEW), GNOMEUIINFO_SEPARATOR, - { GNOME_APP_UI_ITEM, N_("Prev"), N_("Go back in time"), previous_clicked, 0, 0, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_BACK }, - - { GNOME_APP_UI_ITEM, N_("Today"), N_("Go to present time"), today_clicked, 0, 0, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_HOME }, - - { GNOME_APP_UI_ITEM, N_("Next"), N_("Go forward in time"), next_clicked, 0, 0, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_FORWARD }, + GNOMEUIINFO_ITEM_STOCK (N_("Prev"), N_("Go back in time"), previous_clicked, GNOME_STOCK_MENU_BACK), + GNOMEUIINFO_ITEM_STOCK (N_("Today"), N_("Go to present time"), today_clicked, GNOME_STOCK_PIXMAP_HOME), + GNOMEUIINFO_ITEM_STOCK (N_("Next"), N_("Go forward in time"), next_clicked, GNOME_STOCK_MENU_FORWARD), GNOMEUIINFO_SEPARATOR, diff --git a/calendar/gui/month-view.c b/calendar/gui/month-view.c index de6b89db2b..0abc717366 100644 --- a/calendar/gui/month-view.c +++ b/calendar/gui/month-view.c @@ -6,10 +6,14 @@ */ #include +#include #include "month-view.h" #include "main.h" +#define SPACING 4 /* Spacing between title and calendar */ + + static void month_view_class_init (MonthViewClass *class); static void month_view_init (MonthView *mv); static void month_view_size_request (GtkWidget *widget, @@ -60,6 +64,17 @@ month_view_class_init (MonthViewClass *class) static void month_view_init (MonthView *mv) { + /* Title */ + + mv->title = gnome_canvas_item_new (GNOME_CANVAS_GROUP (mv->canvas.root), + gnome_canvas_text_get_type (), + "anchor", GTK_ANCHOR_N, + "font", "-*-helvetica-bold-r-normal--18-*-*-*-p-*-iso8859-1", + "fill_color", "black", + NULL); + + /* Month item */ + mv->mitem = gnome_month_item_new (GNOME_CANVAS_GROUP (mv->canvas.root)); gnome_canvas_item_set (mv->mitem, "x", 0.0, @@ -71,16 +86,17 @@ month_view_init (MonthView *mv) } GtkWidget * -month_view_new (GnomeCalendar *calendar) +month_view_new (GnomeCalendar *calendar, time_t month) { MonthView *mv; g_return_val_if_fail (calendar != NULL, NULL); mv = gtk_type_new (month_view_get_type ()); - mv->calendar = calendar; + month_view_set (mv, month); + return GTK_WIDGET (mv); } @@ -102,6 +118,9 @@ static void month_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { MonthView *mv; + GdkFont *font; + GtkArg arg; + int y; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); @@ -113,8 +132,74 @@ month_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation) (* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation); gnome_canvas_set_scroll_region (GNOME_CANVAS (mv), 0, 0, allocation->width, allocation->height); + + /* Adjust items to new size */ + + arg.name = "font_gdk"; + gtk_object_getv (GTK_OBJECT (mv->title), 1, &arg); + font = GTK_VALUE_BOXED (arg); + + gnome_canvas_item_set (mv->title, + "x", (double) allocation->width / 2.0, + "y", (double) SPACING, + NULL); + + y = font->ascent + font->descent + 2 * SPACING; gnome_canvas_item_set (mv->mitem, + "y", (double) y, "width", (double) (allocation->width - 1), - "height", (double) (allocation->height - 1), + "height", (double) (allocation->height - y - 1), + NULL); + + /* FIXME: adjust events */ +} + +void +month_view_update (MonthView *mv, iCalObject *object, int flags) +{ + g_return_if_fail (mv != NULL); + g_return_if_fail (IS_MONTH_VIEW (mv)); + + /* FIXME */ +} + +void +month_view_set (MonthView *mv, time_t month) +{ + struct tm *tm; + char buf[100]; + + g_return_if_fail (mv != NULL); + g_return_if_fail (IS_MONTH_VIEW (mv)); + + /* Title */ + + tm = localtime (&month); + strftime (buf, 100, "%B %Y", tm); + + gnome_canvas_item_set (mv->title, + "text", buf, + NULL); + + /* Month item */ + + gnome_canvas_item_set (mv->mitem, + "year", tm->tm_year + 1900, + "month", tm->tm_mon, NULL); + + /* FIXME: update events */ +} + +void +month_view_time_format_changed (MonthView *mv) +{ + g_return_if_fail (mv != NULL); + g_return_if_fail (IS_MONTH_VIEW (mv)); + + gnome_canvas_item_set (mv->mitem, + "start_on_monday", week_starts_on_monday, + NULL); + + /* FIXME: update events */ } diff --git a/calendar/gui/month-view.h b/calendar/gui/month-view.h index 0f35817d78..a164332f98 100644 --- a/calendar/gui/month-view.h +++ b/calendar/gui/month-view.h @@ -31,6 +31,7 @@ struct _MonthView { GnomeCalendar *calendar; /* The calendar we are associated to */ + GnomeCanvasItem *title; /* The title heading with the month/year */ GnomeCanvasItem *mitem; /* The canvas month item used by this month view */ }; @@ -43,7 +44,16 @@ struct _MonthViewClass { GtkType month_view_get_type (void); /* Creates a new month view widget associated to the specified calendar */ -GtkWidget *month_view_new (GnomeCalendar *calendar); +GtkWidget *month_view_new (GnomeCalendar *calendar, time_t month); + +/* Notifies the month view that a calendar object has changed */ +void month_view_update (MonthView *mv, iCalObject *ico, int flags); + +/* Notifies the month view about a change of date */ +void month_view_set (MonthView *mv, time_t month); + +/* Notifies the month view that the time format has changed */ +void month_view_time_format_changed (MonthView *mv); END_GNOME_DECLS diff --git a/calendar/gui/prop.c b/calendar/gui/prop.c index c339230a1a..709d321229 100644 --- a/calendar/gui/prop.c +++ b/calendar/gui/prop.c @@ -101,6 +101,7 @@ build_two_radio_group (char *title, gtk_box_pack_start (GTK_BOX (vbox), *radio_2_widget, FALSE, FALSE, 0); gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (*radio_1_widget), radio_1_value); + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (*radio_2_widget), !radio_1_value); gtk_signal_connect (GTK_OBJECT (*radio_1_widget), "toggled", (GtkSignalFunc) toggled, @@ -135,6 +136,8 @@ hour_activated (GtkWidget *widget, gpointer data) gtk_option_menu_set_history (GTK_OPTION_MENU (start_omenu), end); } else g_assert_not_reached (); + + gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win)); } /* Builds an option menu of 24 hours */ diff --git a/calendar/main.c b/calendar/main.c index 55aa861e0c..9f8bcae2dd 100644 --- a/calendar/main.c +++ b/calendar/main.c @@ -4,7 +4,7 @@ * * Authors: * Miguel de Icaza (miguel@kernel.org) - * Federico Mena (quartic@gimp.org) + * Federico Mena (federico@nuclecu.unam.mx) */ #include @@ -193,13 +193,8 @@ time_format_changed (void) { GList *l; - /* FIXME: update all the calendars and stuff */ - - for (l = all_calendars; l; l = l->next){ - GnomeCalendar *cal = GNOME_CALENDAR (l->data); - - gtk_widget_queue_resize (cal->notebook); - } + for (l = all_calendars; l; l = l->next) + gnome_calendar_time_format_changed (GNOME_CALENDAR (l->data)); } static void @@ -327,66 +322,51 @@ save_calendar_cmd (GtkWidget *widget, void *data) } static GnomeUIInfo gnome_cal_file_menu [] = { - { GNOME_APP_UI_ITEM, N_("New calendar"), NULL, new_calendar_cmd, NULL, NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_NEW }, + GNOMEUIINFO_ITEM_STOCK (N_("New calendar"), NULL, new_calendar_cmd, GNOME_STOCK_MENU_NEW), + GNOMEUIINFO_ITEM_STOCK (N_("Open calendar..."), NULL, open_calendar_cmd, GNOME_STOCK_MENU_OPEN), + GNOMEUIINFO_ITEM_STOCK (N_("Save calendar"), NULL, save_calendar_cmd, GNOME_STOCK_MENU_SAVE), + GNOMEUIINFO_ITEM_STOCK (N_("Save calendar as..."), NULL, save_as_calendar_cmd, GNOME_STOCK_MENU_SAVE), - { GNOME_APP_UI_ITEM, N_("Open calendar..."), NULL, open_calendar_cmd, NULL, NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_OPEN }, - - { GNOME_APP_UI_ITEM, N_("Save calendar"), NULL, save_calendar_cmd, NULL, NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE }, + GNOMEUIINFO_SEPARATOR, - { GNOME_APP_UI_ITEM, N_("Save calendar as..."), NULL, save_as_calendar_cmd, NULL, NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE }, + GNOMEUIINFO_ITEM_STOCK (N_("Preferences..."), NULL, properties, GNOME_STOCK_MENU_PREF), - { GNOME_APP_UI_SEPARATOR }, - { GNOME_APP_UI_ITEM, N_("Close this calendar"), NULL, close_cmd, NULL, NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT }, + GNOMEUIINFO_SEPARATOR, - { GNOME_APP_UI_ITEM, N_("Exit"), NULL, quit_cmd, NULL, NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT }, + GNOMEUIINFO_ITEM_STOCK (N_("Close this calendar"), NULL, close_cmd, GNOME_STOCK_MENU_EXIT), + GNOMEUIINFO_ITEM_STOCK (N_("Exit"), NULL, quit_cmd, GNOME_STOCK_MENU_EXIT), GNOMEUIINFO_END }; -static GnomeUIInfo gnome_cal_about_menu [] = { - { GNOME_APP_UI_ITEM, N_("About..."), NULL, about_calendar_cmd, NULL, NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_ABOUT }, +static GnomeUIInfo gnome_cal_help_menu [] = { + GNOMEUIINFO_ITEM_STOCK (N_("About Gnomecal..."), NULL, about_calendar_cmd, GNOME_STOCK_MENU_ABOUT), GNOMEUIINFO_SEPARATOR, GNOMEUIINFO_HELP ("cal"), GNOMEUIINFO_END }; static GnomeUIInfo gnome_cal_edit_menu [] = { - { GNOME_APP_UI_ITEM, N_("New appointment..."), NULL, display_objedit }, - { GNOME_APP_UI_ITEM, N_("New appointment for today..."), NULL, display_objedit_today }, - GNOMEUIINFO_SEPARATOR, - { GNOME_APP_UI_ITEM, N_("Preferences..."), NULL, properties, NULL, NULL, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_PREF }, + GNOMEUIINFO_ITEM_STOCK (N_("New appointment..."), NULL, display_objedit, GNOME_STOCK_MENU_NEW), + GNOMEUIINFO_ITEM_STOCK (N_("New appointment for today..."), NULL, display_objedit_today, GNOME_STOCK_MENU_NEW), GNOMEUIINFO_END }; static GnomeUIInfo gnome_cal_menu [] = { - { GNOME_APP_UI_SUBTREE, N_("File"), NULL, &gnome_cal_file_menu }, - { GNOME_APP_UI_SUBTREE, N_("Calendar"), NULL, &gnome_cal_edit_menu }, - { GNOME_APP_UI_SUBTREE, N_("Help"), NULL, &gnome_cal_about_menu }, + GNOMEUIINFO_SUBTREE (N_("File"), &gnome_cal_file_menu), + GNOMEUIINFO_SUBTREE (N_("Edit"), &gnome_cal_edit_menu), + GNOMEUIINFO_SUBTREE (N_("Help"), &gnome_cal_help_menu), GNOMEUIINFO_END }; static GnomeUIInfo gnome_toolbar [] = { - { GNOME_APP_UI_ITEM, N_("New"), N_("Create a new appointment"), display_objedit, 0, 0, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_NEW }, + GNOMEUIINFO_ITEM_STOCK (N_("New"), N_("Create a new appointment"), display_objedit, GNOME_STOCK_PIXMAP_NEW), GNOMEUIINFO_SEPARATOR, - { GNOME_APP_UI_ITEM, N_("Prev"), N_("Go back in time"), previous_clicked, 0, 0, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_BACK }, - - { GNOME_APP_UI_ITEM, N_("Today"), N_("Go to present time"), today_clicked, 0, 0, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_HOME }, - - { GNOME_APP_UI_ITEM, N_("Next"), N_("Go forward in time"), next_clicked, 0, 0, - GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_FORWARD }, + GNOMEUIINFO_ITEM_STOCK (N_("Prev"), N_("Go back in time"), previous_clicked, GNOME_STOCK_MENU_BACK), + GNOMEUIINFO_ITEM_STOCK (N_("Today"), N_("Go to present time"), today_clicked, GNOME_STOCK_PIXMAP_HOME), + GNOMEUIINFO_ITEM_STOCK (N_("Next"), N_("Go forward in time"), next_clicked, GNOME_STOCK_MENU_FORWARD), GNOMEUIINFO_SEPARATOR, diff --git a/calendar/month-view.c b/calendar/month-view.c index de6b89db2b..0abc717366 100644 --- a/calendar/month-view.c +++ b/calendar/month-view.c @@ -6,10 +6,14 @@ */ #include +#include #include "month-view.h" #include "main.h" +#define SPACING 4 /* Spacing between title and calendar */ + + static void month_view_class_init (MonthViewClass *class); static void month_view_init (MonthView *mv); static void month_view_size_request (GtkWidget *widget, @@ -60,6 +64,17 @@ month_view_class_init (MonthViewClass *class) static void month_view_init (MonthView *mv) { + /* Title */ + + mv->title = gnome_canvas_item_new (GNOME_CANVAS_GROUP (mv->canvas.root), + gnome_canvas_text_get_type (), + "anchor", GTK_ANCHOR_N, + "font", "-*-helvetica-bold-r-normal--18-*-*-*-p-*-iso8859-1", + "fill_color", "black", + NULL); + + /* Month item */ + mv->mitem = gnome_month_item_new (GNOME_CANVAS_GROUP (mv->canvas.root)); gnome_canvas_item_set (mv->mitem, "x", 0.0, @@ -71,16 +86,17 @@ month_view_init (MonthView *mv) } GtkWidget * -month_view_new (GnomeCalendar *calendar) +month_view_new (GnomeCalendar *calendar, time_t month) { MonthView *mv; g_return_val_if_fail (calendar != NULL, NULL); mv = gtk_type_new (month_view_get_type ()); - mv->calendar = calendar; + month_view_set (mv, month); + return GTK_WIDGET (mv); } @@ -102,6 +118,9 @@ static void month_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { MonthView *mv; + GdkFont *font; + GtkArg arg; + int y; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); @@ -113,8 +132,74 @@ month_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation) (* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation); gnome_canvas_set_scroll_region (GNOME_CANVAS (mv), 0, 0, allocation->width, allocation->height); + + /* Adjust items to new size */ + + arg.name = "font_gdk"; + gtk_object_getv (GTK_OBJECT (mv->title), 1, &arg); + font = GTK_VALUE_BOXED (arg); + + gnome_canvas_item_set (mv->title, + "x", (double) allocation->width / 2.0, + "y", (double) SPACING, + NULL); + + y = font->ascent + font->descent + 2 * SPACING; gnome_canvas_item_set (mv->mitem, + "y", (double) y, "width", (double) (allocation->width - 1), - "height", (double) (allocation->height - 1), + "height", (double) (allocation->height - y - 1), + NULL); + + /* FIXME: adjust events */ +} + +void +month_view_update (MonthView *mv, iCalObject *object, int flags) +{ + g_return_if_fail (mv != NULL); + g_return_if_fail (IS_MONTH_VIEW (mv)); + + /* FIXME */ +} + +void +month_view_set (MonthView *mv, time_t month) +{ + struct tm *tm; + char buf[100]; + + g_return_if_fail (mv != NULL); + g_return_if_fail (IS_MONTH_VIEW (mv)); + + /* Title */ + + tm = localtime (&month); + strftime (buf, 100, "%B %Y", tm); + + gnome_canvas_item_set (mv->title, + "text", buf, + NULL); + + /* Month item */ + + gnome_canvas_item_set (mv->mitem, + "year", tm->tm_year + 1900, + "month", tm->tm_mon, NULL); + + /* FIXME: update events */ +} + +void +month_view_time_format_changed (MonthView *mv) +{ + g_return_if_fail (mv != NULL); + g_return_if_fail (IS_MONTH_VIEW (mv)); + + gnome_canvas_item_set (mv->mitem, + "start_on_monday", week_starts_on_monday, + NULL); + + /* FIXME: update events */ } diff --git a/calendar/month-view.h b/calendar/month-view.h index 0f35817d78..a164332f98 100644 --- a/calendar/month-view.h +++ b/calendar/month-view.h @@ -31,6 +31,7 @@ struct _MonthView { GnomeCalendar *calendar; /* The calendar we are associated to */ + GnomeCanvasItem *title; /* The title heading with the month/year */ GnomeCanvasItem *mitem; /* The canvas month item used by this month view */ }; @@ -43,7 +44,16 @@ struct _MonthViewClass { GtkType month_view_get_type (void); /* Creates a new month view widget associated to the specified calendar */ -GtkWidget *month_view_new (GnomeCalendar *calendar); +GtkWidget *month_view_new (GnomeCalendar *calendar, time_t month); + +/* Notifies the month view that a calendar object has changed */ +void month_view_update (MonthView *mv, iCalObject *ico, int flags); + +/* Notifies the month view about a change of date */ +void month_view_set (MonthView *mv, time_t month); + +/* Notifies the month view that the time format has changed */ +void month_view_time_format_changed (MonthView *mv); END_GNOME_DECLS diff --git a/calendar/prop.c b/calendar/prop.c index c339230a1a..709d321229 100644 --- a/calendar/prop.c +++ b/calendar/prop.c @@ -101,6 +101,7 @@ build_two_radio_group (char *title, gtk_box_pack_start (GTK_BOX (vbox), *radio_2_widget, FALSE, FALSE, 0); gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (*radio_1_widget), radio_1_value); + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (*radio_2_widget), !radio_1_value); gtk_signal_connect (GTK_OBJECT (*radio_1_widget), "toggled", (GtkSignalFunc) toggled, @@ -135,6 +136,8 @@ hour_activated (GtkWidget *widget, gpointer data) gtk_option_menu_set_history (GTK_OPTION_MENU (start_omenu), end); } else g_assert_not_reached (); + + gnome_property_box_changed (GNOME_PROPERTY_BOX (prop_win)); } /* Builds an option menu of 24 hours */ diff --git a/calendar/timeutil.c b/calendar/timeutil.c index c27a8dbd45..03d9465daa 100644 --- a/calendar/timeutil.c +++ b/calendar/timeutil.c @@ -88,6 +88,21 @@ format_simple_hour (int hour, int use_am_pm) } +time_t +time_add_minutes (time_t time, int minutes) +{ + struct tm *tm = localtime (&time); + time_t new_time; + + tm->tm_min += minutes; + if ((new_time = mktime (tm)) == -1){ + g_warning ("mktime could not handling adding a day with\n"); + print_time_t (time); + return time; + } + return new_time; +} + time_t time_add_day (time_t time, int days) { @@ -104,14 +119,24 @@ time_add_day (time_t time, int days) } time_t -time_add_minutes (time_t time, int minutes) +time_add_week (time_t time, int weeks) +{ + return time_add_day (time, weeks * 7); +} + +time_t +time_add_month (time_t time, int months) { struct tm *tm = localtime (&time); time_t new_time; - tm->tm_min += minutes; + /* FIXME: this will not work correctly when switching, say, from a 31-day month to a 30-day + * month. Figure out the number of days in the month and go to the nearest "limit" day. + */ + + tm->tm_mon += months; if ((new_time = mktime (tm)) == -1){ - g_warning ("mktime could not handling adding a day with\n"); + g_warning ("mktime could not handling adding a month with\n"); print_time_t (time); return time; } diff --git a/calendar/timeutil.h b/calendar/timeutil.h index dc0aa522bf..73b521cc20 100644 --- a/calendar/timeutil.h +++ b/calendar/timeutil.h @@ -23,6 +23,7 @@ char *isodiff_from_secs (int secs); time_t time_add_minutes (time_t time, int minutes); time_t time_add_day (time_t time, int days); time_t time_add_week (time_t time, int weeks); +time_t time_add_month (time_t time, int months); time_t time_add_year (time_t time, int years); -- cgit v1.2.3