diff options
-rw-r--r-- | calendar/ChangeLog | 17 | ||||
-rw-r--r-- | calendar/cal-util/calobj.c | 4 | ||||
-rw-r--r-- | calendar/calendar.h | 1 | ||||
-rw-r--r-- | calendar/calobj.c | 4 | ||||
-rw-r--r-- | calendar/eventedit.c | 72 | ||||
-rw-r--r-- | calendar/gncal-full-day.c | 5 | ||||
-rw-r--r-- | calendar/gnome-cal.h | 1 | ||||
-rw-r--r-- | calendar/gui/calendar.h | 1 | ||||
-rw-r--r-- | calendar/gui/eventedit.c | 72 | ||||
-rw-r--r-- | calendar/gui/gncal-full-day.c | 5 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.h | 1 | ||||
-rw-r--r-- | calendar/gui/main.c | 117 | ||||
-rw-r--r-- | calendar/main.c | 117 | ||||
-rw-r--r-- | calendar/pcs/calobj.c | 4 |
14 files changed, 290 insertions, 131 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 58a01b187f..962c9a5026 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,20 @@ +1998-04-17 Federico Mena Quintero <federico@nuclecu.unam.mx> + + * calobj.c (ical_new): Added mandatory status property. + (ical_object_to_vobject): Only store "related" list if it exists. + + * main.c (save_calendar_cmd): Implemented calendar saving. + (open_calendar_cmd): Implemented calendar loading. + (new_calendar_cmd): Implemented calendar creation. + (new_calendar): Don't load our test calendar by default. + + * gncal-full-day.c (delete_appointment): Delete appointment implemented. + + * eventedit.c (ee_store_recur_values_to_ical): Free/create + ical's recurrence appropriately. + (ee_rp_init_rule): Initialize all missing parameters from ical. + (ee_rp_init_ending_date): Initialize missing fields from ical. + 1998-04-17 Miguel de Icaza <miguel@nuclecu.unam.mx> * gnome-cal.c (gnome_calendar_remove_object): Add support for diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c index 7878df7aa8..641c3fbf8b 100644 --- a/calendar/cal-util/calobj.c +++ b/calendar/cal-util/calobj.c @@ -56,6 +56,7 @@ ical_new (char *comment, char *organizer, char *summary) ico->organizer = g_strdup (organizer); ico->summary = g_strdup (summary); ico->class = g_strdup ("PUBLIC"); + ico->status = g_strdup ("NEEDS ACTION"); default_alarm (ico, &ico->dalarm, organizer, ALARM_DISPLAY); default_alarm (ico, &ico->palarm, organizer, ALARM_PROGRAM); @@ -790,7 +791,8 @@ ical_object_to_vobject (iCalObject *ical) addPropValue (o, VCTranspProp, to_str (ical->transp)); /* related */ - store_list (o, VCRelatedToProp, ical->related, ';'); + if (ical->related) + store_list (o, VCRelatedToProp, ical->related, ';'); /* attach */ for (l = ical->attach; l; l = l->next) diff --git a/calendar/calendar.h b/calendar/calendar.h index 94b471d3da..52cd2c90f6 100644 --- a/calendar/calendar.h +++ b/calendar/calendar.h @@ -36,6 +36,7 @@ typedef struct { Calendar *calendar_new (char *title); char *calendar_load (Calendar *cal, char *fname); +void calendar_save (Calendar *cal, char *fname); void calendar_add_object (Calendar *cal, iCalObject *obj); void calendar_remove_object (Calendar *cal, iCalObject *obj); void calendar_destroy (Calendar *cal); diff --git a/calendar/calobj.c b/calendar/calobj.c index 7878df7aa8..641c3fbf8b 100644 --- a/calendar/calobj.c +++ b/calendar/calobj.c @@ -56,6 +56,7 @@ ical_new (char *comment, char *organizer, char *summary) ico->organizer = g_strdup (organizer); ico->summary = g_strdup (summary); ico->class = g_strdup ("PUBLIC"); + ico->status = g_strdup ("NEEDS ACTION"); default_alarm (ico, &ico->dalarm, organizer, ALARM_DISPLAY); default_alarm (ico, &ico->palarm, organizer, ALARM_PROGRAM); @@ -790,7 +791,8 @@ ical_object_to_vobject (iCalObject *ical) addPropValue (o, VCTranspProp, to_str (ical->transp)); /* related */ - store_list (o, VCRelatedToProp, ical->related, ';'); + if (ical->related) + store_list (o, VCRelatedToProp, ical->related, ';'); /* attach */ for (l = ical->attach; l; l = l->next) diff --git a/calendar/eventedit.c b/calendar/eventedit.c index 7a1a582729..3ea0f674ec 100644 --- a/calendar/eventedit.c +++ b/calendar/eventedit.c @@ -329,6 +329,8 @@ alarm_toggle (GtkToggleButton *toggle, CalendarAlarm *alarm) static void ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType type, int y) { + GtkWidget *entry; + alarm->w_enabled = gtk_check_button_new_with_label (str); gtk_signal_connect (GTK_OBJECT (alarm->w_enabled), "toggled", GTK_SIGNAL_FUNC (alarm_toggle), alarm); @@ -350,7 +352,7 @@ ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType t gtk_table_attach (table, alarm->w_label, 3, 4, y, y+1, FS, FS, 0, 0); alarm->w_entry = gtk_entry_new (); gtk_table_attach (table, alarm->w_entry, 4, 5, y, y+1, FXS, FS, 0, 0); - gtk_entry_set_text (GTK_ENTRY (alarm->w_entry), alarm->data); + gtk_entry_set_text (GTK_ENTRY (alarm->w_entry), alarm->data ? alarm->data : ""); break; case ALARM_PROGRAM: @@ -358,6 +360,8 @@ ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType t gtk_misc_set_alignment (GTK_MISC (alarm->w_label), 1.0, 0.5); gtk_table_attach (table, alarm->w_label, 3, 4, y, y+1, FS, FS, 0, 0); alarm->w_entry = gnome_file_entry_new ("alarm-program", _("Select program to run at alarm time")); + entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (alarm->w_entry)); + gtk_entry_set_text (GTK_ENTRY (entry), alarm->data ? alarm->data : ""); gtk_table_attach (table, alarm->w_entry, 4, 5, y, y+1, FXS, FS, 0, 0); break; @@ -392,16 +396,10 @@ ee_alarm_widgets (EventEditor *ee) return l; } -static void -connect_and_pack (EventEditor *ee, GtkWidget *hbox, GtkWidget *toggle, char *value) -{ - gtk_box_pack_start_defaults (GTK_BOX (hbox), toggle); -} - static GtkWidget * ee_classification_widgets (EventEditor *ee) { - GtkWidget *rpub, *rpriv, *conf; + GtkWidget *rpub, *rpriv, *rconf; GtkWidget *frame, *hbox; frame = gtk_frame_new (_("Classification")); @@ -412,13 +410,21 @@ ee_classification_widgets (EventEditor *ee) rpub = gtk_radio_button_new_with_label (NULL, _("Public")); rpriv = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rpub), _("Private")); - conf = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rpub), _("Confidential")); + rconf = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rpub), _("Confidential")); + + gtk_box_pack_start (GTK_BOX (hbox), rpub, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), rpriv, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), rconf, FALSE, FALSE, 0); + + if (strcmp (ee->ical->class, class_names[0])) + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (rpub), TRUE); + else if (strcmp (ee->ical->class, class_names[1])) + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (rpriv), TRUE); + else if (strcmp (ee->ical->class, class_names[2])) + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (rconf), TRUE); - connect_and_pack (ee, hbox, rpub, class_names [0]); - connect_and_pack (ee, hbox, rpriv, class_names [1]); - connect_and_pack (ee, hbox, conf, class_names [2]); ee->general_radios = rpub; - + return frame; } @@ -484,7 +490,7 @@ ee_store_general_values_to_ical (EventEditor *ee) ee_store_alarm (&ical->palarm, ALARM_PROGRAM); ee_store_alarm (&ical->malarm, ALARM_MAIL); - for (idx = 0; list; list = list->next){ + for (idx = 0; list; list = list->next) { if (GTK_TOGGLE_BUTTON (list->data)->active) break; idx++; @@ -662,12 +668,17 @@ ee_store_recur_exceptions_to_ical (EventEditor *ee) static void ee_store_recur_values_to_ical (EventEditor *ee) { - if (!ee->ical->recur) - ee->ical->recur = g_new0 (Recurrence, 1); - - ee_store_recur_rule_to_ical (ee); - ee_store_recur_end_to_ical (ee); - ee_store_recur_exceptions_to_ical (ee); + if (GTK_TOGGLE_BUTTON (ee->general_recur)->active) { + if (!ee->ical->recur) + ee->ical->recur = g_new0 (Recurrence, 1); + + ee_store_recur_rule_to_ical (ee); + ee_store_recur_end_to_ical (ee); + ee_store_recur_exceptions_to_ical (ee); + } else if (ee->ical->recur) { + g_free (ee->ical->recur); + ee->ical->recur = NULL; + } } /* @@ -783,7 +794,7 @@ ee_init_general_page (EventEditor *ee) gtk_misc_set_alignment (GTK_MISC (ee->general_owner), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (hbox), ee->general_owner, TRUE, TRUE, 4); - l = gtk_label_new (_("Description:")); + l = gtk_label_new (_("Summary:")); gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); gtk_table_attach (GTK_TABLE (ee->general_table), l, 0, 1, DESC_LINE, DESC_LINE + 1, @@ -982,6 +993,7 @@ ee_rp_init_rule (EventEditor *ee) page = 2; month_period = interval; def_pos = ee->ical->recur->u.month_pos; + default_day = ee->ical->recur->u.month_day; break; case RECUR_MONTHLY_BY_DAY: @@ -1051,18 +1063,18 @@ ee_rp_init_rule (EventEditor *ee) ee->recur_rr_week_days [i] = gtk_check_button_new_with_label (_(day_names [i])); gtk_box_pack_start (GTK_BOX (week_day), ee->recur_rr_week_days [i], FALSE, FALSE, 0); - if (week_vector & (1 << i)) + if (week_vector & (1 << ((i + 1) % 7))) /* on the spec, Sunday is 0 */ gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (ee->recur_rr_week_days [i]), TRUE); } /* 3. The monthly recurrence */ - monthly = gtk_table_new (0, 0, 0); + monthly = gtk_table_new (0, 0, FALSE); gtk_table_set_row_spacings (GTK_TABLE (monthly), 4); gtk_table_set_col_spacings (GTK_TABLE (monthly), 4); re = gtk_radio_button_new_with_label (NULL, _("Recur on the")); - ee->recur_rr_month_date = make_spin_button (1, 1, 31); /* FIXME: set the day */ + ee->recur_rr_month_date = make_spin_button (default_day, 1, 31); ee->recur_rr_month_date_label = w = gtk_label_new (_("th day of the month")); gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5); gtk_table_attach (GTK_TABLE (monthly), re, @@ -1074,8 +1086,8 @@ ee_rp_init_rule (EventEditor *ee) gtk_signal_connect (GTK_OBJECT (re), "toggled", GTK_SIGNAL_FUNC (recur_month_enable_date), ee); r1 = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (re)), _("Recur on the")); - ee->recur_rr_month_day = make_numbered_menu (weekday_positions, 0); - ee->recur_rr_month_weekday = make_numbered_menu (weekday_names, def_pos); + ee->recur_rr_month_day = make_numbered_menu (weekday_positions, def_pos); + ee->recur_rr_month_weekday = make_numbered_menu (weekday_names, default_day); gtk_table_attach (GTK_TABLE (monthly), r1, 0, 1, 1, 2, FS, FS, 0, 0); gtk_table_attach (GTK_TABLE (monthly), ee->recur_rr_month_day, @@ -1146,6 +1158,7 @@ ee_rp_init_ending_date (EventEditor *ee) GtkWidget *ihbox; GtkWidget *widget; time_t enddate; + int repeat; frame = gtk_frame_new (_("Ending date")); @@ -1202,7 +1215,12 @@ ee_rp_init_ending_date (EventEditor *ee) ihbox = gtk_hbox_new (FALSE, 4); gtk_box_pack_start (GTK_BOX (hbox), ihbox, FALSE, FALSE, 0); - ee->recur_ed_end_after = widget = make_spin_button (2, 1, 10000); + if (ee->ical->recur && ee->ical->recur->duration) + repeat = ee->ical->recur->duration; + else + repeat = 2; + + ee->recur_ed_end_after = widget = make_spin_button (repeat, 1, 10000); gtk_box_pack_start (GTK_BOX (ihbox), widget, FALSE, FALSE, 0); widget = gtk_label_new (_("occurrence(s)")); diff --git a/calendar/gncal-full-day.c b/calendar/gncal-full-day.c index 7a20b3789d..1af9daa65f 100644 --- a/calendar/gncal-full-day.c +++ b/calendar/gncal-full-day.c @@ -370,12 +370,13 @@ static void delete_appointment (GtkWidget *widget, gpointer data) { Child *child; + GncalFullDay *fullday; child = data; - /* FIXME */ + fullday = GNCAL_FULL_DAY (child->widget->parent); - printf ("Yay! delete_appointment() not yet implemented\n"); + gnome_calendar_remove_object (fullday->calendar, child->ico); } static void diff --git a/calendar/gnome-cal.h b/calendar/gnome-cal.h index 71c5c386c8..e526d219d7 100644 --- a/calendar/gnome-cal.h +++ b/calendar/gnome-cal.h @@ -41,6 +41,7 @@ guint gnome_calendar_get_type (void); GtkWidget *gnome_calendar_new (char *title); void gnome_calendar_load (GnomeCalendar *gcal, char *file); void gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj); +void gnome_calendar_remove_object (GnomeCalendar *gcal, iCalObject *obj); void gnome_calendar_next (GnomeCalendar *gcal); void gnome_calendar_previous (GnomeCalendar *gcal); void gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time); diff --git a/calendar/gui/calendar.h b/calendar/gui/calendar.h index 94b471d3da..52cd2c90f6 100644 --- a/calendar/gui/calendar.h +++ b/calendar/gui/calendar.h @@ -36,6 +36,7 @@ typedef struct { Calendar *calendar_new (char *title); char *calendar_load (Calendar *cal, char *fname); +void calendar_save (Calendar *cal, char *fname); void calendar_add_object (Calendar *cal, iCalObject *obj); void calendar_remove_object (Calendar *cal, iCalObject *obj); void calendar_destroy (Calendar *cal); diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c index 7a1a582729..3ea0f674ec 100644 --- a/calendar/gui/eventedit.c +++ b/calendar/gui/eventedit.c @@ -329,6 +329,8 @@ alarm_toggle (GtkToggleButton *toggle, CalendarAlarm *alarm) static void ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType type, int y) { + GtkWidget *entry; + alarm->w_enabled = gtk_check_button_new_with_label (str); gtk_signal_connect (GTK_OBJECT (alarm->w_enabled), "toggled", GTK_SIGNAL_FUNC (alarm_toggle), alarm); @@ -350,7 +352,7 @@ ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType t gtk_table_attach (table, alarm->w_label, 3, 4, y, y+1, FS, FS, 0, 0); alarm->w_entry = gtk_entry_new (); gtk_table_attach (table, alarm->w_entry, 4, 5, y, y+1, FXS, FS, 0, 0); - gtk_entry_set_text (GTK_ENTRY (alarm->w_entry), alarm->data); + gtk_entry_set_text (GTK_ENTRY (alarm->w_entry), alarm->data ? alarm->data : ""); break; case ALARM_PROGRAM: @@ -358,6 +360,8 @@ ee_create_ae (GtkTable *table, char *str, CalendarAlarm *alarm, enum AlarmType t gtk_misc_set_alignment (GTK_MISC (alarm->w_label), 1.0, 0.5); gtk_table_attach (table, alarm->w_label, 3, 4, y, y+1, FS, FS, 0, 0); alarm->w_entry = gnome_file_entry_new ("alarm-program", _("Select program to run at alarm time")); + entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (alarm->w_entry)); + gtk_entry_set_text (GTK_ENTRY (entry), alarm->data ? alarm->data : ""); gtk_table_attach (table, alarm->w_entry, 4, 5, y, y+1, FXS, FS, 0, 0); break; @@ -392,16 +396,10 @@ ee_alarm_widgets (EventEditor *ee) return l; } -static void -connect_and_pack (EventEditor *ee, GtkWidget *hbox, GtkWidget *toggle, char *value) -{ - gtk_box_pack_start_defaults (GTK_BOX (hbox), toggle); -} - static GtkWidget * ee_classification_widgets (EventEditor *ee) { - GtkWidget *rpub, *rpriv, *conf; + GtkWidget *rpub, *rpriv, *rconf; GtkWidget *frame, *hbox; frame = gtk_frame_new (_("Classification")); @@ -412,13 +410,21 @@ ee_classification_widgets (EventEditor *ee) rpub = gtk_radio_button_new_with_label (NULL, _("Public")); rpriv = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rpub), _("Private")); - conf = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rpub), _("Confidential")); + rconf = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (rpub), _("Confidential")); + + gtk_box_pack_start (GTK_BOX (hbox), rpub, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), rpriv, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (hbox), rconf, FALSE, FALSE, 0); + + if (strcmp (ee->ical->class, class_names[0])) + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (rpub), TRUE); + else if (strcmp (ee->ical->class, class_names[1])) + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (rpriv), TRUE); + else if (strcmp (ee->ical->class, class_names[2])) + gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (rconf), TRUE); - connect_and_pack (ee, hbox, rpub, class_names [0]); - connect_and_pack (ee, hbox, rpriv, class_names [1]); - connect_and_pack (ee, hbox, conf, class_names [2]); ee->general_radios = rpub; - + return frame; } @@ -484,7 +490,7 @@ ee_store_general_values_to_ical (EventEditor *ee) ee_store_alarm (&ical->palarm, ALARM_PROGRAM); ee_store_alarm (&ical->malarm, ALARM_MAIL); - for (idx = 0; list; list = list->next){ + for (idx = 0; list; list = list->next) { if (GTK_TOGGLE_BUTTON (list->data)->active) break; idx++; @@ -662,12 +668,17 @@ ee_store_recur_exceptions_to_ical (EventEditor *ee) static void ee_store_recur_values_to_ical (EventEditor *ee) { - if (!ee->ical->recur) - ee->ical->recur = g_new0 (Recurrence, 1); - - ee_store_recur_rule_to_ical (ee); - ee_store_recur_end_to_ical (ee); - ee_store_recur_exceptions_to_ical (ee); + if (GTK_TOGGLE_BUTTON (ee->general_recur)->active) { + if (!ee->ical->recur) + ee->ical->recur = g_new0 (Recurrence, 1); + + ee_store_recur_rule_to_ical (ee); + ee_store_recur_end_to_ical (ee); + ee_store_recur_exceptions_to_ical (ee); + } else if (ee->ical->recur) { + g_free (ee->ical->recur); + ee->ical->recur = NULL; + } } /* @@ -783,7 +794,7 @@ ee_init_general_page (EventEditor *ee) gtk_misc_set_alignment (GTK_MISC (ee->general_owner), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (hbox), ee->general_owner, TRUE, TRUE, 4); - l = gtk_label_new (_("Description:")); + l = gtk_label_new (_("Summary:")); gtk_misc_set_alignment (GTK_MISC (l), 0.0, 0.5); gtk_table_attach (GTK_TABLE (ee->general_table), l, 0, 1, DESC_LINE, DESC_LINE + 1, @@ -982,6 +993,7 @@ ee_rp_init_rule (EventEditor *ee) page = 2; month_period = interval; def_pos = ee->ical->recur->u.month_pos; + default_day = ee->ical->recur->u.month_day; break; case RECUR_MONTHLY_BY_DAY: @@ -1051,18 +1063,18 @@ ee_rp_init_rule (EventEditor *ee) ee->recur_rr_week_days [i] = gtk_check_button_new_with_label (_(day_names [i])); gtk_box_pack_start (GTK_BOX (week_day), ee->recur_rr_week_days [i], FALSE, FALSE, 0); - if (week_vector & (1 << i)) + if (week_vector & (1 << ((i + 1) % 7))) /* on the spec, Sunday is 0 */ gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (ee->recur_rr_week_days [i]), TRUE); } /* 3. The monthly recurrence */ - monthly = gtk_table_new (0, 0, 0); + monthly = gtk_table_new (0, 0, FALSE); gtk_table_set_row_spacings (GTK_TABLE (monthly), 4); gtk_table_set_col_spacings (GTK_TABLE (monthly), 4); re = gtk_radio_button_new_with_label (NULL, _("Recur on the")); - ee->recur_rr_month_date = make_spin_button (1, 1, 31); /* FIXME: set the day */ + ee->recur_rr_month_date = make_spin_button (default_day, 1, 31); ee->recur_rr_month_date_label = w = gtk_label_new (_("th day of the month")); gtk_misc_set_alignment (GTK_MISC (w), 0.0, 0.5); gtk_table_attach (GTK_TABLE (monthly), re, @@ -1074,8 +1086,8 @@ ee_rp_init_rule (EventEditor *ee) gtk_signal_connect (GTK_OBJECT (re), "toggled", GTK_SIGNAL_FUNC (recur_month_enable_date), ee); r1 = gtk_radio_button_new_with_label (gtk_radio_button_group (GTK_RADIO_BUTTON (re)), _("Recur on the")); - ee->recur_rr_month_day = make_numbered_menu (weekday_positions, 0); - ee->recur_rr_month_weekday = make_numbered_menu (weekday_names, def_pos); + ee->recur_rr_month_day = make_numbered_menu (weekday_positions, def_pos); + ee->recur_rr_month_weekday = make_numbered_menu (weekday_names, default_day); gtk_table_attach (GTK_TABLE (monthly), r1, 0, 1, 1, 2, FS, FS, 0, 0); gtk_table_attach (GTK_TABLE (monthly), ee->recur_rr_month_day, @@ -1146,6 +1158,7 @@ ee_rp_init_ending_date (EventEditor *ee) GtkWidget *ihbox; GtkWidget *widget; time_t enddate; + int repeat; frame = gtk_frame_new (_("Ending date")); @@ -1202,7 +1215,12 @@ ee_rp_init_ending_date (EventEditor *ee) ihbox = gtk_hbox_new (FALSE, 4); gtk_box_pack_start (GTK_BOX (hbox), ihbox, FALSE, FALSE, 0); - ee->recur_ed_end_after = widget = make_spin_button (2, 1, 10000); + if (ee->ical->recur && ee->ical->recur->duration) + repeat = ee->ical->recur->duration; + else + repeat = 2; + + ee->recur_ed_end_after = widget = make_spin_button (repeat, 1, 10000); gtk_box_pack_start (GTK_BOX (ihbox), widget, FALSE, FALSE, 0); widget = gtk_label_new (_("occurrence(s)")); diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c index 7a20b3789d..1af9daa65f 100644 --- a/calendar/gui/gncal-full-day.c +++ b/calendar/gui/gncal-full-day.c @@ -370,12 +370,13 @@ static void delete_appointment (GtkWidget *widget, gpointer data) { Child *child; + GncalFullDay *fullday; child = data; - /* FIXME */ + fullday = GNCAL_FULL_DAY (child->widget->parent); - printf ("Yay! delete_appointment() not yet implemented\n"); + gnome_calendar_remove_object (fullday->calendar, child->ico); } static void diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 71c5c386c8..e526d219d7 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -41,6 +41,7 @@ guint gnome_calendar_get_type (void); GtkWidget *gnome_calendar_new (char *title); void gnome_calendar_load (GnomeCalendar *gcal, char *file); void gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj); +void gnome_calendar_remove_object (GnomeCalendar *gcal, iCalObject *obj); void gnome_calendar_next (GnomeCalendar *gcal); void gnome_calendar_previous (GnomeCalendar *gcal); void gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time); diff --git a/calendar/gui/main.c b/calendar/gui/main.c index 089b544ebc..8249763ff0 100644 --- a/calendar/gui/main.c +++ b/calendar/gui/main.c @@ -2,9 +2,11 @@ * GnomeCalendar widget * Copyright (C) 1998 the Free Software Foundation * - * Authors: + * Authors: * Miguel de Icaza (miguel@kernel.org) + * Federico Mena (quartic@gimp.org) */ + #include <config.h> #include <gnome.h> #include <pwd.h> @@ -35,18 +37,21 @@ int active_calendars = 0; /* A list of all of the calendars started */ GList *all_calendars = NULL; +static void new_calendar (char *full_name, char *calendar_file); + + void init_username (void) { char *p; struct passwd *passwd; - + passwd = getpwuid (getuid ()); - if ((p = passwd->pw_name)){ + if ((p = passwd->pw_name)) { user_name = g_strdup (p); full_name = g_strdup (passwd->pw_gecos); } else { - if ((p = getenv ("USER"))){ + if ((p = getenv ("USER"))) { user_name = g_strdup (p); full_name = g_strdup (p); return; @@ -61,11 +66,9 @@ init_username (void) int range_check_hour (int hour) { - struct tm tm; - if (hour < 0) hour = 0; - if (hour > 24) + else if (hour >= 24) hour = 23; return hour; @@ -89,6 +92,7 @@ init_calendar (void) day_begin = 8; day_end = 17; } + gnome_config_pop_prefix (); } @@ -124,7 +128,7 @@ void quit_cmd (GtkWidget *widget, GnomeCalendar *gcal) { /* FIXME: check all of the calendars for their state (modified) */ - + gtk_main_quit (); } @@ -136,6 +140,7 @@ close_cmd (GtkWidget *widget, GnomeCalendar *gcal) GNOME_MESSAGE_BOX_WARNING, "Yes", "No"); } + gtk_widget_destroy (widget); active_calendars--; @@ -164,39 +169,86 @@ today_clicked (GtkWidget *widget, GnomeCalendar *gcal) void new_calendar_cmd (GtkWidget *widget, void *data) { + new_calendar (full_name, NULL); +} + +static void +open_ok (GtkWidget *widget, GtkFileSelection *fs) +{ + /* FIXME: find out who owns this calendar and use that name */ + new_calendar ("Somebody", gtk_file_selection_get_filename (fs)); + + gtk_widget_destroy (GTK_WIDGET (fs)); } void open_calendar_cmd (GtkWidget *widget, void *data) { - GtkWidget *filesel; + GtkFileSelection *fs; + + fs = GTK_FILE_SELECTION (gtk_file_selection_new (_("Open calendar"))); - filesel = gtk_file_selection_new (_("Open Calendar")); - gtk_widget_show (filesel); - + gtk_signal_connect (GTK_OBJECT (fs->ok_button), "clicked", + (GtkSignalFunc) open_ok, + fs); + gtk_signal_connect_object (GTK_OBJECT (fs->cancel_button), "clicked", + (GtkSignalFunc) gtk_widget_destroy, + GTK_OBJECT (fs)); + + gtk_widget_show (GTK_WIDGET (fs)); + gtk_grab_add (GTK_WIDGET (fs)); /* Yes, it is modal, so sue me */ +} + +static void +save_ok (GtkWidget *widget, GtkFileSelection *fs) +{ + GnomeCalendar *gcal; + + gcal = GNOME_CALENDAR (gtk_object_get_user_data (GTK_OBJECT (fs))); + + if (gcal->cal->filename) + g_free (gcal->cal->filename); + + gcal->cal->filename = g_strdup (gtk_file_selection_get_filename (fs)); + calendar_save (gcal->cal, gcal->cal->filename); + gtk_widget_destroy (GTK_WIDGET (fs)); } void save_calendar_cmd (GtkWidget *widget, void *data) { + GtkFileSelection *fs; + + fs = GTK_FILE_SELECTION (gtk_file_selection_new (_("Save calendar"))); + gtk_object_set_user_data (GTK_OBJECT (fs), data); + + gtk_signal_connect (GTK_OBJECT (fs->ok_button), "clicked", + (GtkSignalFunc) save_ok, + fs); + gtk_signal_connect_object (GTK_OBJECT (fs->cancel_button), "clicked", + (GtkSignalFunc) gtk_widget_destroy, + GTK_OBJECT (fs)); + + gtk_widget_show (GTK_WIDGET (fs)); + gtk_grab_add (GTK_WIDGET (fs)); /* Yes, it is modal, so sue me even more */ } GnomeUIInfo gnome_cal_file_menu [] = { { GNOME_APP_UI_ITEM, N_("New calendar"), NULL, new_calendar_cmd }, - { GNOME_APP_UI_ITEM, N_("Open calendar"), NULL, open_calendar_cmd, NULL, NULL, + { 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_UI_ITEM, N_("Save calendar..."), NULL, save_calendar_cmd, NULL, NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE }, - - { GNOME_APP_UI_SEPARATOR }, - { GNOME_APP_UI_ITEM, N_("Close"), NULL, close_cmd, NULL, NULL, + + { 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 }, - + { GNOME_APP_UI_ITEM, N_("Exit"), NULL, quit_cmd, NULL, NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT }, - + GNOMEUIINFO_END }; @@ -213,19 +265,19 @@ GnomeUIInfo gnome_cal_edit_menu [] = { }; GnomeUIInfo gnome_cal_menu [] = { - { GNOME_APP_UI_SUBTREE, N_("File"), NULL, &gnome_cal_file_menu }, - { GNOME_APP_UI_SUBTREE, N_("Edit"), NULL, &gnome_cal_edit_menu }, - { GNOME_APP_UI_SUBTREE, N_("Help"), NULL, &gnome_cal_about_menu }, + { GNOME_APP_UI_SUBTREE, N_("File"), NULL, &gnome_cal_file_menu }, + { GNOME_APP_UI_SUBTREE, N_("Edit"), NULL, &gnome_cal_edit_menu }, + { GNOME_APP_UI_SUBTREE, N_("Help"), NULL, &gnome_cal_about_menu }, GNOMEUIINFO_END }; GnomeUIInfo gnome_toolbar [] = { { GNOME_APP_UI_ITEM, N_("Prev"), NULL, previous_clicked, 0, 0, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_BACK }, - + { GNOME_APP_UI_ITEM, N_("Today"), NULL, today_clicked, 0, 0, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_BACK }, - + { GNOME_APP_UI_ITEM, N_("Next"), NULL, next_clicked, 0, 0, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_FORWARD }, @@ -237,7 +289,6 @@ setup_menu (GtkWidget *gcal) { gnome_app_create_menus_with_data (GNOME_APP (gcal), gnome_cal_menu, gcal); gnome_app_create_toolbar_with_data (GNOME_APP (gcal), gnome_toolbar, gcal); - } static void @@ -245,30 +296,28 @@ new_calendar (char *full_name, char *calendar_file) { GtkWidget *toplevel; char *title; - + title = g_copy_strings (full_name, "'s calendar", NULL); - + toplevel = gnome_calendar_new (title); g_free (title); setup_menu (toplevel); - if (g_file_exists (calendar_file)){ + if (calendar_file && g_file_exists (calendar_file)) { printf ("Trying to load %s\n", calendar_file); gnome_calendar_load (GNOME_CALENDAR (toplevel), calendar_file); - } else { - printf ("Trying to load ./test.vcf\n"); - gnome_calendar_load (GNOME_CALENDAR (toplevel), "./test.vcf"); } + active_calendars++; all_calendars = g_list_prepend (all_calendars, toplevel); gtk_widget_show (toplevel); } - + int main(int argc, char *argv[]) { GnomeClient *client; - + argp_program_version = VERSION; /* Initialise the i18n stuff */ @@ -283,5 +332,3 @@ main(int argc, char *argv[]) gtk_main (); return 0; } - - diff --git a/calendar/main.c b/calendar/main.c index 089b544ebc..8249763ff0 100644 --- a/calendar/main.c +++ b/calendar/main.c @@ -2,9 +2,11 @@ * GnomeCalendar widget * Copyright (C) 1998 the Free Software Foundation * - * Authors: + * Authors: * Miguel de Icaza (miguel@kernel.org) + * Federico Mena (quartic@gimp.org) */ + #include <config.h> #include <gnome.h> #include <pwd.h> @@ -35,18 +37,21 @@ int active_calendars = 0; /* A list of all of the calendars started */ GList *all_calendars = NULL; +static void new_calendar (char *full_name, char *calendar_file); + + void init_username (void) { char *p; struct passwd *passwd; - + passwd = getpwuid (getuid ()); - if ((p = passwd->pw_name)){ + if ((p = passwd->pw_name)) { user_name = g_strdup (p); full_name = g_strdup (passwd->pw_gecos); } else { - if ((p = getenv ("USER"))){ + if ((p = getenv ("USER"))) { user_name = g_strdup (p); full_name = g_strdup (p); return; @@ -61,11 +66,9 @@ init_username (void) int range_check_hour (int hour) { - struct tm tm; - if (hour < 0) hour = 0; - if (hour > 24) + else if (hour >= 24) hour = 23; return hour; @@ -89,6 +92,7 @@ init_calendar (void) day_begin = 8; day_end = 17; } + gnome_config_pop_prefix (); } @@ -124,7 +128,7 @@ void quit_cmd (GtkWidget *widget, GnomeCalendar *gcal) { /* FIXME: check all of the calendars for their state (modified) */ - + gtk_main_quit (); } @@ -136,6 +140,7 @@ close_cmd (GtkWidget *widget, GnomeCalendar *gcal) GNOME_MESSAGE_BOX_WARNING, "Yes", "No"); } + gtk_widget_destroy (widget); active_calendars--; @@ -164,39 +169,86 @@ today_clicked (GtkWidget *widget, GnomeCalendar *gcal) void new_calendar_cmd (GtkWidget *widget, void *data) { + new_calendar (full_name, NULL); +} + +static void +open_ok (GtkWidget *widget, GtkFileSelection *fs) +{ + /* FIXME: find out who owns this calendar and use that name */ + new_calendar ("Somebody", gtk_file_selection_get_filename (fs)); + + gtk_widget_destroy (GTK_WIDGET (fs)); } void open_calendar_cmd (GtkWidget *widget, void *data) { - GtkWidget *filesel; + GtkFileSelection *fs; + + fs = GTK_FILE_SELECTION (gtk_file_selection_new (_("Open calendar"))); - filesel = gtk_file_selection_new (_("Open Calendar")); - gtk_widget_show (filesel); - + gtk_signal_connect (GTK_OBJECT (fs->ok_button), "clicked", + (GtkSignalFunc) open_ok, + fs); + gtk_signal_connect_object (GTK_OBJECT (fs->cancel_button), "clicked", + (GtkSignalFunc) gtk_widget_destroy, + GTK_OBJECT (fs)); + + gtk_widget_show (GTK_WIDGET (fs)); + gtk_grab_add (GTK_WIDGET (fs)); /* Yes, it is modal, so sue me */ +} + +static void +save_ok (GtkWidget *widget, GtkFileSelection *fs) +{ + GnomeCalendar *gcal; + + gcal = GNOME_CALENDAR (gtk_object_get_user_data (GTK_OBJECT (fs))); + + if (gcal->cal->filename) + g_free (gcal->cal->filename); + + gcal->cal->filename = g_strdup (gtk_file_selection_get_filename (fs)); + calendar_save (gcal->cal, gcal->cal->filename); + gtk_widget_destroy (GTK_WIDGET (fs)); } void save_calendar_cmd (GtkWidget *widget, void *data) { + GtkFileSelection *fs; + + fs = GTK_FILE_SELECTION (gtk_file_selection_new (_("Save calendar"))); + gtk_object_set_user_data (GTK_OBJECT (fs), data); + + gtk_signal_connect (GTK_OBJECT (fs->ok_button), "clicked", + (GtkSignalFunc) save_ok, + fs); + gtk_signal_connect_object (GTK_OBJECT (fs->cancel_button), "clicked", + (GtkSignalFunc) gtk_widget_destroy, + GTK_OBJECT (fs)); + + gtk_widget_show (GTK_WIDGET (fs)); + gtk_grab_add (GTK_WIDGET (fs)); /* Yes, it is modal, so sue me even more */ } GnomeUIInfo gnome_cal_file_menu [] = { { GNOME_APP_UI_ITEM, N_("New calendar"), NULL, new_calendar_cmd }, - { GNOME_APP_UI_ITEM, N_("Open calendar"), NULL, open_calendar_cmd, NULL, NULL, + { 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_UI_ITEM, N_("Save calendar..."), NULL, save_calendar_cmd, NULL, NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE }, - - { GNOME_APP_UI_SEPARATOR }, - { GNOME_APP_UI_ITEM, N_("Close"), NULL, close_cmd, NULL, NULL, + + { 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 }, - + { GNOME_APP_UI_ITEM, N_("Exit"), NULL, quit_cmd, NULL, NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT }, - + GNOMEUIINFO_END }; @@ -213,19 +265,19 @@ GnomeUIInfo gnome_cal_edit_menu [] = { }; GnomeUIInfo gnome_cal_menu [] = { - { GNOME_APP_UI_SUBTREE, N_("File"), NULL, &gnome_cal_file_menu }, - { GNOME_APP_UI_SUBTREE, N_("Edit"), NULL, &gnome_cal_edit_menu }, - { GNOME_APP_UI_SUBTREE, N_("Help"), NULL, &gnome_cal_about_menu }, + { GNOME_APP_UI_SUBTREE, N_("File"), NULL, &gnome_cal_file_menu }, + { GNOME_APP_UI_SUBTREE, N_("Edit"), NULL, &gnome_cal_edit_menu }, + { GNOME_APP_UI_SUBTREE, N_("Help"), NULL, &gnome_cal_about_menu }, GNOMEUIINFO_END }; GnomeUIInfo gnome_toolbar [] = { { GNOME_APP_UI_ITEM, N_("Prev"), NULL, previous_clicked, 0, 0, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_BACK }, - + { GNOME_APP_UI_ITEM, N_("Today"), NULL, today_clicked, 0, 0, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_BACK }, - + { GNOME_APP_UI_ITEM, N_("Next"), NULL, next_clicked, 0, 0, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_FORWARD }, @@ -237,7 +289,6 @@ setup_menu (GtkWidget *gcal) { gnome_app_create_menus_with_data (GNOME_APP (gcal), gnome_cal_menu, gcal); gnome_app_create_toolbar_with_data (GNOME_APP (gcal), gnome_toolbar, gcal); - } static void @@ -245,30 +296,28 @@ new_calendar (char *full_name, char *calendar_file) { GtkWidget *toplevel; char *title; - + title = g_copy_strings (full_name, "'s calendar", NULL); - + toplevel = gnome_calendar_new (title); g_free (title); setup_menu (toplevel); - if (g_file_exists (calendar_file)){ + if (calendar_file && g_file_exists (calendar_file)) { printf ("Trying to load %s\n", calendar_file); gnome_calendar_load (GNOME_CALENDAR (toplevel), calendar_file); - } else { - printf ("Trying to load ./test.vcf\n"); - gnome_calendar_load (GNOME_CALENDAR (toplevel), "./test.vcf"); } + active_calendars++; all_calendars = g_list_prepend (all_calendars, toplevel); gtk_widget_show (toplevel); } - + int main(int argc, char *argv[]) { GnomeClient *client; - + argp_program_version = VERSION; /* Initialise the i18n stuff */ @@ -283,5 +332,3 @@ main(int argc, char *argv[]) gtk_main (); return 0; } - - diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c index 7878df7aa8..641c3fbf8b 100644 --- a/calendar/pcs/calobj.c +++ b/calendar/pcs/calobj.c @@ -56,6 +56,7 @@ ical_new (char *comment, char *organizer, char *summary) ico->organizer = g_strdup (organizer); ico->summary = g_strdup (summary); ico->class = g_strdup ("PUBLIC"); + ico->status = g_strdup ("NEEDS ACTION"); default_alarm (ico, &ico->dalarm, organizer, ALARM_DISPLAY); default_alarm (ico, &ico->palarm, organizer, ALARM_PROGRAM); @@ -790,7 +791,8 @@ ical_object_to_vobject (iCalObject *ical) addPropValue (o, VCTranspProp, to_str (ical->transp)); /* related */ - store_list (o, VCRelatedToProp, ical->related, ';'); + if (ical->related) + store_list (o, VCRelatedToProp, ical->related, ';'); /* attach */ for (l = ical->attach; l; l = l->next) |