diff options
author | Arturo Espinosa Aldama <arturo@nuclecu.unam.mx> | 1998-04-15 10:40:24 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 1998-04-15 10:40:24 +0800 |
commit | 0e5cfe78a5161e1c98e69f4670552e0d381b3d30 (patch) | |
tree | 058ef3f23121fbd5c87361a951c02b611c384529 /calendar | |
parent | 3161696e57f03b5ebc859907725f6836f4220667 (diff) | |
download | gsoc2013-evolution-0e5cfe78a5161e1c98e69f4670552e0d381b3d30.tar gsoc2013-evolution-0e5cfe78a5161e1c98e69f4670552e0d381b3d30.tar.gz gsoc2013-evolution-0e5cfe78a5161e1c98e69f4670552e0d381b3d30.tar.bz2 gsoc2013-evolution-0e5cfe78a5161e1c98e69f4670552e0d381b3d30.tar.lz gsoc2013-evolution-0e5cfe78a5161e1c98e69f4670552e0d381b3d30.tar.xz gsoc2013-evolution-0e5cfe78a5161e1c98e69f4670552e0d381b3d30.tar.zst gsoc2013-evolution-0e5cfe78a5161e1c98e69f4670552e0d381b3d30.zip |
New widget for the year view. added required compilation of the new files.
1998-04-14 Arturo Espinosa Aldama <arturo@nuclecu.unam.mx>
* gncal-year-view.[hc]: New widget for the year view.
* Makefile.am: added required compilation of the new files.
svn path=/trunk/; revision=134
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 28 | ||||
-rw-r--r-- | calendar/Makefile.am | 2 | ||||
-rw-r--r-- | calendar/TODO | 13 | ||||
-rw-r--r-- | calendar/cal-util/calobj.c | 26 | ||||
-rw-r--r-- | calendar/calobj.c | 26 | ||||
-rw-r--r-- | calendar/eventedit.c | 15 | ||||
-rw-r--r-- | calendar/gncal-full-day.c | 22 | ||||
-rw-r--r-- | calendar/gnome-cal.h | 2 | ||||
-rw-r--r-- | calendar/gui/Makefile.am | 2 | ||||
-rw-r--r-- | calendar/gui/eventedit.c | 15 | ||||
-rw-r--r-- | calendar/gui/gncal-full-day.c | 22 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.h | 2 | ||||
-rw-r--r-- | calendar/gui/main.c | 2 | ||||
-rw-r--r-- | calendar/gui/test.vcf | 8 | ||||
-rw-r--r-- | calendar/gui/year-view.c | 135 | ||||
-rw-r--r-- | calendar/gui/year-view.h | 52 | ||||
-rw-r--r-- | calendar/main.c | 2 | ||||
-rw-r--r-- | calendar/pcs/calobj.c | 26 | ||||
-rw-r--r-- | calendar/test.vcf | 8 | ||||
-rw-r--r-- | calendar/year-view.c | 135 | ||||
-rw-r--r-- | calendar/year-view.h | 52 |
21 files changed, 513 insertions, 82 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index c986771afc..f6ad8b1a78 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,5 +1,33 @@ +1998-04-14 Arturo Espinosa Aldama <arturo@nuclecu.unam.mx> + + * gncal-year-view.[hc]: New widget for the year view. + * Makefile.am: added required compilation of the new files. + +1998-04-14 Federico Mena Quintero <federico@nuclecu.unam.mx> + + * eventedit.c (event_editor_setup_time_frame): Fixed some table + expansions to make the dialog look nicer when resized. + + * calobj.c (ignore_space): Fixed compiler warning about unused + computed value. + (ocurrencelist): Replace str by p confusion. Removed unused + variables value and q. + (daynumber): Fixed a couple of warnings about unused values. + (load_recurrence): Removed unused variable c. Added a default + clause to the switch(type). + + * eventedit.c (ee_rp_init_frequency): Removed unused variable content. + Fixed a compiler warning by adding a missing cast. + + * calobj.c (ical_object_create_from_vobject): Make the + load_recurrence() part work correctly. Eliminated use of + syntax_error variable. + 1998-04-13 Federico Mena Quintero <federico@nuclecu.unam.mx> + * gncal-full-day.c (child_key_press): Unfocus the child and focus + the parent fullday widget when the user presses Esc. + * gncal-week-view.c (gncal_week_view_update): Now takes object and flags parameters. * gncal-day-view.c (gncal_day_view_update): Likewise. diff --git a/calendar/Makefile.am b/calendar/Makefile.am index 283e46e1c2..b762dae475 100644 --- a/calendar/Makefile.am +++ b/calendar/Makefile.am @@ -19,6 +19,8 @@ gnomecal_SOURCES = \ gncal-full-day.h \ gncal-week-view.c \ gncal-week-view.h \ + gncal-year-view.c \ + gncal-year-view.h \ gnome-cal.c \ gnome-cal.h \ main.c \ diff --git a/calendar/TODO b/calendar/TODO index 1ab5522faa..8cb3a2d68b 100644 --- a/calendar/TODO +++ b/calendar/TODO @@ -1,10 +1,5 @@ Gnome date selection widget: -- Fix the signals. - -- The date selected in the popup calendar does not match the displayed - date in the entry. - - Make the calendar a `real' popup window like in GtkCombo. - Make the displayed date be localized properly -- use strftime(). @@ -15,9 +10,11 @@ Event editor dialog: Full day view widget: -- Check notification to calendar when an object changes. Maybe we - need some flags to tell gnome_calendar_object_changed() whether - summary/dates/etc. changed. Maybe not. +- Right-click on background should pop up a menu with "New + appointment" item. + +- Right-click on child should pop up a menu with "Properties" and + "Remove appointment" items. - Layout the children nicely like M$ Schedule or Netscape Calendar do (i.e. make them not overlap each other). diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c index 5d997dec5d..237017a6f9 100644 --- a/calendar/cal-util/calobj.c +++ b/calendar/cal-util/calobj.c @@ -134,7 +134,7 @@ static void ignore_space(char **str) { while (**str && isspace (**str)) - *str++; + str++; } static void @@ -182,12 +182,11 @@ weekdaylist (iCalObject *o, char **str) static void ocurrencelist (iCalObject *o, char **str) { - char *p, *q; - int value = 0; + char *p; ignore_space (str); p = *str; - if (!isdigit (*str)) + if (!isdigit (*p)) return; if (!(*p >= '1' && *p <= '5')) @@ -218,11 +217,11 @@ daynumber (iCalObject *o, char **str) while (**str && isdigit (**str)){ val = val * 10 + (**str - '0'); - *str++; + str++; } if (**str == '+') - *str++; + str++; if (**str == '-') val *= -1; @@ -314,7 +313,6 @@ enddate (iCalObject *o, char **str) static int load_recurrence (iCalObject *o, char *str) { - char c; enum RecurType type; int interval = 0; @@ -374,6 +372,9 @@ load_recurrence (iCalObject *o, char *str) case RECUR_YEARLY_BY_DAY: load_recur_yearly_day (o, &str); break; + default: + g_warning ("Unimplemented recurrence type %d", (int) type); + break; } duration (o, &str); enddate (o, &str); @@ -393,7 +394,6 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) iCalObject *ical; VObject *vo; VObjectIterator i; - int syntax_error; ical = g_new0 (iCalObject, 1); @@ -515,12 +515,10 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) /* FIXME: rrule */ if (has (o, VCRRuleProp)) - syntax_error = load_recurrence (ical, str_val (vo)) == 0; - - if (syntax_error){ - ical_object_destroy (ical); - return NULL; - } + if (!load_recurrence (ical, str_val (vo))) { + ical_object_destroy (ical); + return NULL; + } return ical; } diff --git a/calendar/calobj.c b/calendar/calobj.c index 5d997dec5d..237017a6f9 100644 --- a/calendar/calobj.c +++ b/calendar/calobj.c @@ -134,7 +134,7 @@ static void ignore_space(char **str) { while (**str && isspace (**str)) - *str++; + str++; } static void @@ -182,12 +182,11 @@ weekdaylist (iCalObject *o, char **str) static void ocurrencelist (iCalObject *o, char **str) { - char *p, *q; - int value = 0; + char *p; ignore_space (str); p = *str; - if (!isdigit (*str)) + if (!isdigit (*p)) return; if (!(*p >= '1' && *p <= '5')) @@ -218,11 +217,11 @@ daynumber (iCalObject *o, char **str) while (**str && isdigit (**str)){ val = val * 10 + (**str - '0'); - *str++; + str++; } if (**str == '+') - *str++; + str++; if (**str == '-') val *= -1; @@ -314,7 +313,6 @@ enddate (iCalObject *o, char **str) static int load_recurrence (iCalObject *o, char *str) { - char c; enum RecurType type; int interval = 0; @@ -374,6 +372,9 @@ load_recurrence (iCalObject *o, char *str) case RECUR_YEARLY_BY_DAY: load_recur_yearly_day (o, &str); break; + default: + g_warning ("Unimplemented recurrence type %d", (int) type); + break; } duration (o, &str); enddate (o, &str); @@ -393,7 +394,6 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) iCalObject *ical; VObject *vo; VObjectIterator i; - int syntax_error; ical = g_new0 (iCalObject, 1); @@ -515,12 +515,10 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) /* FIXME: rrule */ if (has (o, VCRRuleProp)) - syntax_error = load_recurrence (ical, str_val (vo)) == 0; - - if (syntax_error){ - ical_object_destroy (ical); - return NULL; - } + if (!load_recurrence (ical, str_val (vo))) { + ical_object_destroy (ical); + return NULL; + } return ical; } diff --git a/calendar/eventedit.c b/calendar/eventedit.c index 8230c70429..74ad9570ff 100644 --- a/calendar/eventedit.c +++ b/calendar/eventedit.c @@ -140,7 +140,7 @@ event_editor_setup_time_frame (EventEditor *ee) GTK_FILL | GTK_SHRINK, 0, 0); gtk_table_attach (t, start_time, 2, 3, 1, 2, - GTK_FILL | GTK_SHRINK, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 0, 0); @@ -154,7 +154,7 @@ event_editor_setup_time_frame (EventEditor *ee) GTK_FILL | GTK_SHRINK, 0, 0); gtk_table_attach (t, end_time, 2, 3, 2, 3, - GTK_FILL | GTK_SHRINK, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 0, 0); @@ -659,7 +659,7 @@ static void ee_rp_init_frequency (EventEditor *ee) { char *day_names [] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; - GtkWidget *r, *re, *r1, *f, *vbox, *hbox, *content, *week_hbox, *week_day, *w; + GtkWidget *r, *re, *r1, *f, *vbox, *hbox, *week_hbox, *week_day, *w; GtkWidget *daily, *weekly, *monthly, *yearly; GtkNotebook *notebook; GSList *group; @@ -805,13 +805,12 @@ ee_rp_init_frequency (EventEditor *ee) 4, 5, 0, 2, 0, 0, 5, 0); gtk_table_attach (GTK_TABLE (monthly), gtk_label_new (_("month(s)")), 5, 6, 0, 2, 0, 0, 0, 0); - if (ee->ical->recur){ + if (ee->ical->recur) { if (ee->ical->recur->type == RECUR_MONTHLY_BY_POS) gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (r1), 1); - } else { - recur_month_enable_date ((re), ee); - } - + } else + recur_month_enable_date (GTK_TOGGLE_BUTTON (re), ee); + /* 4. The yearly recurrence */ yearly = gtk_hbox_new (0, 0); ee->recur_year_period = small_entry (year_period); diff --git a/calendar/gncal-full-day.c b/calendar/gncal-full-day.c index ce64db9173..8c3bf31db2 100644 --- a/calendar/gncal-full-day.c +++ b/calendar/gncal-full-day.c @@ -331,13 +331,27 @@ child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data) /* Notify calendar of change */ - fullday = gtk_object_get_user_data (GTK_OBJECT (widget)); + fullday = GNCAL_FULL_DAY (widget->parent); gnome_calendar_object_changed (fullday->calendar, child->ico, CHANGE_SUMMARY); return FALSE; } +static gint +child_key_press (GtkWidget *widget, GdkEventKey *event, gpointer data) +{ + if (event->keyval != GDK_Escape) + return FALSE; + + /* If user pressed Esc, un-focus the child by focusing the fullday widget */ + + gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event"); + gtk_widget_grab_focus (widget->parent); + + return FALSE; +} + static Child * child_new (GncalFullDay *fullday, iCalObject *ico) { @@ -353,8 +367,6 @@ child_new (GncalFullDay *fullday, iCalObject *ico) child->width = 0; child->height = 0; - gtk_object_set_user_data (GTK_OBJECT (child->widget), fullday); - child_range_changed (fullday, child); /* We set the i-beam cursor and the initial summary text upon realization */ @@ -371,6 +383,10 @@ child_new (GncalFullDay *fullday, iCalObject *ico) (GtkSignalFunc) child_focus_out, child); + gtk_signal_connect (GTK_OBJECT (child->widget), "key_press_event", + (GtkSignalFunc) child_key_press, + child); + /* Finish setup */ gtk_text_set_editable (GTK_TEXT (child->widget), TRUE); diff --git a/calendar/gnome-cal.h b/calendar/gnome-cal.h index 8e765bda15..96567ab722 100644 --- a/calendar/gnome-cal.h +++ b/calendar/gnome-cal.h @@ -11,6 +11,8 @@ #include <libgnome/gnome-defs.h> #include <libgnomeui/gnome-app.h> +#include "calendar.h" + BEGIN_GNOME_DECLS #define GNOME_CALENDAR(obj) GTK_CHECK_CAST(obj, gnome_calendar_get_type(), GnomeCalendar) diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 283e46e1c2..b762dae475 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -19,6 +19,8 @@ gnomecal_SOURCES = \ gncal-full-day.h \ gncal-week-view.c \ gncal-week-view.h \ + gncal-year-view.c \ + gncal-year-view.h \ gnome-cal.c \ gnome-cal.h \ main.c \ diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c index 8230c70429..74ad9570ff 100644 --- a/calendar/gui/eventedit.c +++ b/calendar/gui/eventedit.c @@ -140,7 +140,7 @@ event_editor_setup_time_frame (EventEditor *ee) GTK_FILL | GTK_SHRINK, 0, 0); gtk_table_attach (t, start_time, 2, 3, 1, 2, - GTK_FILL | GTK_SHRINK, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 0, 0); @@ -154,7 +154,7 @@ event_editor_setup_time_frame (EventEditor *ee) GTK_FILL | GTK_SHRINK, 0, 0); gtk_table_attach (t, end_time, 2, 3, 2, 3, - GTK_FILL | GTK_SHRINK, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 0, 0); @@ -659,7 +659,7 @@ static void ee_rp_init_frequency (EventEditor *ee) { char *day_names [] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" }; - GtkWidget *r, *re, *r1, *f, *vbox, *hbox, *content, *week_hbox, *week_day, *w; + GtkWidget *r, *re, *r1, *f, *vbox, *hbox, *week_hbox, *week_day, *w; GtkWidget *daily, *weekly, *monthly, *yearly; GtkNotebook *notebook; GSList *group; @@ -805,13 +805,12 @@ ee_rp_init_frequency (EventEditor *ee) 4, 5, 0, 2, 0, 0, 5, 0); gtk_table_attach (GTK_TABLE (monthly), gtk_label_new (_("month(s)")), 5, 6, 0, 2, 0, 0, 0, 0); - if (ee->ical->recur){ + if (ee->ical->recur) { if (ee->ical->recur->type == RECUR_MONTHLY_BY_POS) gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (r1), 1); - } else { - recur_month_enable_date ((re), ee); - } - + } else + recur_month_enable_date (GTK_TOGGLE_BUTTON (re), ee); + /* 4. The yearly recurrence */ yearly = gtk_hbox_new (0, 0); ee->recur_year_period = small_entry (year_period); diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c index ce64db9173..8c3bf31db2 100644 --- a/calendar/gui/gncal-full-day.c +++ b/calendar/gui/gncal-full-day.c @@ -331,13 +331,27 @@ child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data) /* Notify calendar of change */ - fullday = gtk_object_get_user_data (GTK_OBJECT (widget)); + fullday = GNCAL_FULL_DAY (widget->parent); gnome_calendar_object_changed (fullday->calendar, child->ico, CHANGE_SUMMARY); return FALSE; } +static gint +child_key_press (GtkWidget *widget, GdkEventKey *event, gpointer data) +{ + if (event->keyval != GDK_Escape) + return FALSE; + + /* If user pressed Esc, un-focus the child by focusing the fullday widget */ + + gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event"); + gtk_widget_grab_focus (widget->parent); + + return FALSE; +} + static Child * child_new (GncalFullDay *fullday, iCalObject *ico) { @@ -353,8 +367,6 @@ child_new (GncalFullDay *fullday, iCalObject *ico) child->width = 0; child->height = 0; - gtk_object_set_user_data (GTK_OBJECT (child->widget), fullday); - child_range_changed (fullday, child); /* We set the i-beam cursor and the initial summary text upon realization */ @@ -371,6 +383,10 @@ child_new (GncalFullDay *fullday, iCalObject *ico) (GtkSignalFunc) child_focus_out, child); + gtk_signal_connect (GTK_OBJECT (child->widget), "key_press_event", + (GtkSignalFunc) child_key_press, + child); + /* Finish setup */ gtk_text_set_editable (GTK_TEXT (child->widget), TRUE); diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 8e765bda15..96567ab722 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -11,6 +11,8 @@ #include <libgnome/gnome-defs.h> #include <libgnomeui/gnome-app.h> +#include "calendar.h" + BEGIN_GNOME_DECLS #define GNOME_CALENDAR(obj) GTK_CHECK_CAST(obj, gnome_calendar_get_type(), GnomeCalendar) diff --git a/calendar/gui/main.c b/calendar/gui/main.c index cd4d107421..f55a3e65ca 100644 --- a/calendar/gui/main.c +++ b/calendar/gui/main.c @@ -244,7 +244,7 @@ new_calendar (char *full_name, char *calendar_file) printf ("Trying to load %s\n", calendar_file); gnome_calendar_load (GNOME_CALENDAR (toplevel), calendar_file); } else { - printf ("tring: ./test.vcf\n"); + printf ("Trying to load ./test.vcf\n"); gnome_calendar_load (GNOME_CALENDAR (toplevel), "./test.vcf"); } active_calendars++; diff --git a/calendar/gui/test.vcf b/calendar/gui/test.vcf index a5d9ad9db6..fc99526bd3 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:19980413T003000 -DTEND:19980413T010000 +DTSTART:19980414T003000 +DTEND:19980414T010000 SUMMARY:asdfasdfasfasdfasdf STATUS:NEEDS ACTION CLASS:PUBLIC @@ -25,8 +25,8 @@ DCREATED:19980402T023558 UID:KOrganizer - 846930886 SEQUENCE:1 LAST-MODIFIED:19980402T023558 -DTSTART:19980413T140000 -DTEND:19980413T160000 +DTSTART:19980414T140000 +DTEND:19980414T160000 SUMMARY:asdfasfdasfasdfasfd STATUS:NEEDS ACTION CLASS:PUBLIC diff --git a/calendar/gui/year-view.c b/calendar/gui/year-view.c new file mode 100644 index 0000000000..d4c2d218df --- /dev/null +++ b/calendar/gui/year-view.c @@ -0,0 +1,135 @@ +/* Week view composite widget for gncal + * + * Copyright (C) 1998 The Free Software Foundation + * + * Author: Arturo Espinosa <arturo@nuclecu.unam.mx> + * + * Heavily based on Federico Mena's week view. + * + */ + +#include <time.h> + +#include "gncal-year-view.h" + +static void gncal_year_view_init (GncalYearView *yview); + +static void +select_day(GtkWidget *widget, gpointer data) +{ + int i; + + GncalYearView *yview; + + yview = GNCAL_YEAR_VIEW(data); + + for (i = 0; i < 12; i++) + gtk_signal_handler_block(GTK_OBJECT(yview->calendar[i]), + yview->handler[i]); + + for (i = 0; i < 12; i++) + if (GTK_CALENDAR(yview->calendar[i]) != GTK_CALENDAR(widget)) + gtk_calendar_select_day(GTK_CALENDAR(yview->calendar[i]), 0); + + for (i = 0; i < 12; i++) + gtk_signal_handler_unblock(GTK_OBJECT(yview->calendar[i]), + yview->handler[i]); +} + +guint +gncal_year_view_get_type (void) +{ + static guint year_view_type = 0; + + if (!year_view_type) { + GtkTypeInfo year_view_info = { + "GncalYearView", + sizeof (GncalYearView), + sizeof (GncalYearViewClass), + (GtkClassInitFunc) NULL, + (GtkObjectInitFunc) gncal_year_view_init, + (GtkArgSetFunc) NULL, + (GtkArgGetFunc) NULL + }; + + year_view_type = gtk_type_unique (gtk_table_get_type (), + &year_view_info); + } + + return year_view_type; +} + +static void +gncal_year_view_init (GncalYearView *yview) +{ + int i; + + for (i = 0; i < 12; i++) { + yview->calendar[i] = NULL; + yview->handler [i] = 0; + } +} + +GtkWidget * +gncal_year_view_new (int year) +{ + struct tm my_tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + char monthbuff[40]; + GncalYearView *yview; + GtkWidget *frame, *vbox, *label; + int i, x, y; + + yview = gtk_type_new (gncal_year_view_get_type ()); + + gtk_table_set_homogeneous (GTK_TABLE (yview), TRUE); + + yview->year = year; + + for (x = 0; x < 3; x++) + for (y = 0; y < 4; y++) { + + i = y * 3 + x; + + yview->calendar[i] = gtk_calendar_new(); + frame = gtk_frame_new(NULL); + vbox = gtk_vbox_new(0,0); + + yview->handler[i] = + gtk_signal_connect(GTK_OBJECT(yview->calendar[i]), + "day_selected", + GTK_SIGNAL_FUNC(select_day), + (gpointer *) yview); + + my_tm.tm_mon = i; + strftime(monthbuff, 40, "%B", &my_tm); + label = gtk_label_new(monthbuff); + + gtk_container_add(GTK_CONTAINER(frame), vbox); + gtk_box_pack_start(GTK_BOX(vbox), label, 0, 0, 0); + gtk_box_pack_start(GTK_BOX(vbox), yview->calendar[i], 0, 0, 0); + + gtk_table_attach (GTK_TABLE (yview), + GTK_WIDGET (vbox), + x, x + 1, + y, y + 1, + 0, 0, 0, 0); + + gtk_widget_show (frame); + gtk_widget_show (vbox); + gtk_widget_show (GTK_WIDGET (yview->calendar[i])); + } + + gncal_year_view_set (yview, year); + + return GTK_WIDGET (yview); +} + +void gncal_year_view_set (GncalYearView *yview, int year) +{ + int i; + + for (i = 0; i < 12; i++) { + yview->year = year; + gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i + 1, year); + } +} diff --git a/calendar/gui/year-view.h b/calendar/gui/year-view.h new file mode 100644 index 0000000000..1aedf41299 --- /dev/null +++ b/calendar/gui/year-view.h @@ -0,0 +1,52 @@ +/* Week view composite widget for gncal + * + * Copyright (C) 1998 The Free Software Foundation + * + * Author: Arturo Espinosa <arturo@nuclecu.unam.mx> + * + * Heavily based on Federico Mena's week view. + * + */ + +#ifndef YEAR_VIEW_H +#define YEAR_VIEW_H + + +#include <gtk/gtktable.h> +#include <libgnome/gnome-defs.h> +#include <libgnomeui/gtkcalendar.h> +#include "gnome-cal.h" + +BEGIN_GNOME_DECLS + + +#define GNCAL_YEAR_VIEW(obj) GTK_CHECK_CAST (obj, gncal_year_view_get_type (), GncalYearView) +#define GNCAL_YEAR_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_year_view_get_type (), GncalYearViewClass) +#define GNCAL_IS_YEAR_VIEW(obj) GTK_CHECK_TYPE (obj, gncal_year_view_get_type ()) + + +typedef struct _GncalYearView GncalYearView; +typedef struct _GncalYearViewClass GncalYearViewClass; + +struct _GncalYearView { + GtkTable table; + + GtkWidget *calendar[12]; /* one calendar per month */ + guint handler[12]; /* for (un)blocking the calendars */ + gint year; +}; + +struct _GncalYearViewClass { + GtkTableClass parent_class; +}; + + +guint gncal_year_view_get_type (void); +GtkWidget *gncal_year_view_new (int year); + +void gncal_year_view_set (GncalYearView *yview, int year); + + +END_GNOME_DECLS + +#endif diff --git a/calendar/main.c b/calendar/main.c index cd4d107421..f55a3e65ca 100644 --- a/calendar/main.c +++ b/calendar/main.c @@ -244,7 +244,7 @@ new_calendar (char *full_name, char *calendar_file) printf ("Trying to load %s\n", calendar_file); gnome_calendar_load (GNOME_CALENDAR (toplevel), calendar_file); } else { - printf ("tring: ./test.vcf\n"); + printf ("Trying to load ./test.vcf\n"); gnome_calendar_load (GNOME_CALENDAR (toplevel), "./test.vcf"); } active_calendars++; diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c index 5d997dec5d..237017a6f9 100644 --- a/calendar/pcs/calobj.c +++ b/calendar/pcs/calobj.c @@ -134,7 +134,7 @@ static void ignore_space(char **str) { while (**str && isspace (**str)) - *str++; + str++; } static void @@ -182,12 +182,11 @@ weekdaylist (iCalObject *o, char **str) static void ocurrencelist (iCalObject *o, char **str) { - char *p, *q; - int value = 0; + char *p; ignore_space (str); p = *str; - if (!isdigit (*str)) + if (!isdigit (*p)) return; if (!(*p >= '1' && *p <= '5')) @@ -218,11 +217,11 @@ daynumber (iCalObject *o, char **str) while (**str && isdigit (**str)){ val = val * 10 + (**str - '0'); - *str++; + str++; } if (**str == '+') - *str++; + str++; if (**str == '-') val *= -1; @@ -314,7 +313,6 @@ enddate (iCalObject *o, char **str) static int load_recurrence (iCalObject *o, char *str) { - char c; enum RecurType type; int interval = 0; @@ -374,6 +372,9 @@ load_recurrence (iCalObject *o, char *str) case RECUR_YEARLY_BY_DAY: load_recur_yearly_day (o, &str); break; + default: + g_warning ("Unimplemented recurrence type %d", (int) type); + break; } duration (o, &str); enddate (o, &str); @@ -393,7 +394,6 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) iCalObject *ical; VObject *vo; VObjectIterator i; - int syntax_error; ical = g_new0 (iCalObject, 1); @@ -515,12 +515,10 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) /* FIXME: rrule */ if (has (o, VCRRuleProp)) - syntax_error = load_recurrence (ical, str_val (vo)) == 0; - - if (syntax_error){ - ical_object_destroy (ical); - return NULL; - } + if (!load_recurrence (ical, str_val (vo))) { + ical_object_destroy (ical); + return NULL; + } return ical; } diff --git a/calendar/test.vcf b/calendar/test.vcf index a5d9ad9db6..fc99526bd3 100644 --- a/calendar/test.vcf +++ b/calendar/test.vcf @@ -8,8 +8,8 @@ DCREATED:19980402T023552 UID:KOrganizer - 1804289383 SEQUENCE:1 LAST-MODIFIED:19980330T225948 -DTSTART:19980413T003000 -DTEND:19980413T010000 +DTSTART:19980414T003000 +DTEND:19980414T010000 SUMMARY:asdfasdfasfasdfasdf STATUS:NEEDS ACTION CLASS:PUBLIC @@ -25,8 +25,8 @@ DCREATED:19980402T023558 UID:KOrganizer - 846930886 SEQUENCE:1 LAST-MODIFIED:19980402T023558 -DTSTART:19980413T140000 -DTEND:19980413T160000 +DTSTART:19980414T140000 +DTEND:19980414T160000 SUMMARY:asdfasfdasfasdfasfd STATUS:NEEDS ACTION CLASS:PUBLIC diff --git a/calendar/year-view.c b/calendar/year-view.c new file mode 100644 index 0000000000..d4c2d218df --- /dev/null +++ b/calendar/year-view.c @@ -0,0 +1,135 @@ +/* Week view composite widget for gncal + * + * Copyright (C) 1998 The Free Software Foundation + * + * Author: Arturo Espinosa <arturo@nuclecu.unam.mx> + * + * Heavily based on Federico Mena's week view. + * + */ + +#include <time.h> + +#include "gncal-year-view.h" + +static void gncal_year_view_init (GncalYearView *yview); + +static void +select_day(GtkWidget *widget, gpointer data) +{ + int i; + + GncalYearView *yview; + + yview = GNCAL_YEAR_VIEW(data); + + for (i = 0; i < 12; i++) + gtk_signal_handler_block(GTK_OBJECT(yview->calendar[i]), + yview->handler[i]); + + for (i = 0; i < 12; i++) + if (GTK_CALENDAR(yview->calendar[i]) != GTK_CALENDAR(widget)) + gtk_calendar_select_day(GTK_CALENDAR(yview->calendar[i]), 0); + + for (i = 0; i < 12; i++) + gtk_signal_handler_unblock(GTK_OBJECT(yview->calendar[i]), + yview->handler[i]); +} + +guint +gncal_year_view_get_type (void) +{ + static guint year_view_type = 0; + + if (!year_view_type) { + GtkTypeInfo year_view_info = { + "GncalYearView", + sizeof (GncalYearView), + sizeof (GncalYearViewClass), + (GtkClassInitFunc) NULL, + (GtkObjectInitFunc) gncal_year_view_init, + (GtkArgSetFunc) NULL, + (GtkArgGetFunc) NULL + }; + + year_view_type = gtk_type_unique (gtk_table_get_type (), + &year_view_info); + } + + return year_view_type; +} + +static void +gncal_year_view_init (GncalYearView *yview) +{ + int i; + + for (i = 0; i < 12; i++) { + yview->calendar[i] = NULL; + yview->handler [i] = 0; + } +} + +GtkWidget * +gncal_year_view_new (int year) +{ + struct tm my_tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + char monthbuff[40]; + GncalYearView *yview; + GtkWidget *frame, *vbox, *label; + int i, x, y; + + yview = gtk_type_new (gncal_year_view_get_type ()); + + gtk_table_set_homogeneous (GTK_TABLE (yview), TRUE); + + yview->year = year; + + for (x = 0; x < 3; x++) + for (y = 0; y < 4; y++) { + + i = y * 3 + x; + + yview->calendar[i] = gtk_calendar_new(); + frame = gtk_frame_new(NULL); + vbox = gtk_vbox_new(0,0); + + yview->handler[i] = + gtk_signal_connect(GTK_OBJECT(yview->calendar[i]), + "day_selected", + GTK_SIGNAL_FUNC(select_day), + (gpointer *) yview); + + my_tm.tm_mon = i; + strftime(monthbuff, 40, "%B", &my_tm); + label = gtk_label_new(monthbuff); + + gtk_container_add(GTK_CONTAINER(frame), vbox); + gtk_box_pack_start(GTK_BOX(vbox), label, 0, 0, 0); + gtk_box_pack_start(GTK_BOX(vbox), yview->calendar[i], 0, 0, 0); + + gtk_table_attach (GTK_TABLE (yview), + GTK_WIDGET (vbox), + x, x + 1, + y, y + 1, + 0, 0, 0, 0); + + gtk_widget_show (frame); + gtk_widget_show (vbox); + gtk_widget_show (GTK_WIDGET (yview->calendar[i])); + } + + gncal_year_view_set (yview, year); + + return GTK_WIDGET (yview); +} + +void gncal_year_view_set (GncalYearView *yview, int year) +{ + int i; + + for (i = 0; i < 12; i++) { + yview->year = year; + gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i + 1, year); + } +} diff --git a/calendar/year-view.h b/calendar/year-view.h new file mode 100644 index 0000000000..1aedf41299 --- /dev/null +++ b/calendar/year-view.h @@ -0,0 +1,52 @@ +/* Week view composite widget for gncal + * + * Copyright (C) 1998 The Free Software Foundation + * + * Author: Arturo Espinosa <arturo@nuclecu.unam.mx> + * + * Heavily based on Federico Mena's week view. + * + */ + +#ifndef YEAR_VIEW_H +#define YEAR_VIEW_H + + +#include <gtk/gtktable.h> +#include <libgnome/gnome-defs.h> +#include <libgnomeui/gtkcalendar.h> +#include "gnome-cal.h" + +BEGIN_GNOME_DECLS + + +#define GNCAL_YEAR_VIEW(obj) GTK_CHECK_CAST (obj, gncal_year_view_get_type (), GncalYearView) +#define GNCAL_YEAR_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gncal_year_view_get_type (), GncalYearViewClass) +#define GNCAL_IS_YEAR_VIEW(obj) GTK_CHECK_TYPE (obj, gncal_year_view_get_type ()) + + +typedef struct _GncalYearView GncalYearView; +typedef struct _GncalYearViewClass GncalYearViewClass; + +struct _GncalYearView { + GtkTable table; + + GtkWidget *calendar[12]; /* one calendar per month */ + guint handler[12]; /* for (un)blocking the calendars */ + gint year; +}; + +struct _GncalYearViewClass { + GtkTableClass parent_class; +}; + + +guint gncal_year_view_get_type (void); +GtkWidget *gncal_year_view_new (int year); + +void gncal_year_view_set (GncalYearView *yview, int year); + + +END_GNOME_DECLS + +#endif |