diff options
author | Federico Mena Quintero <federico@helixcode.com> | 2000-06-02 13:48:02 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2000-06-02 13:48:02 +0800 |
commit | 9717e6f9efc0f5acfb0c15e576a703e02c0cd753 (patch) | |
tree | 4a265688162e8febcf3adfb8b8c2ead0c525330b /calendar/gui | |
parent | ad538c17436859d35fb80b6cfc7692b7064f7125 (diff) | |
download | gsoc2013-evolution-9717e6f9efc0f5acfb0c15e576a703e02c0cd753.tar gsoc2013-evolution-9717e6f9efc0f5acfb0c15e576a703e02c0cd753.tar.gz gsoc2013-evolution-9717e6f9efc0f5acfb0c15e576a703e02c0cd753.tar.bz2 gsoc2013-evolution-9717e6f9efc0f5acfb0c15e576a703e02c0cd753.tar.lz gsoc2013-evolution-9717e6f9efc0f5acfb0c15e576a703e02c0cd753.tar.xz gsoc2013-evolution-9717e6f9efc0f5acfb0c15e576a703e02c0cd753.tar.zst gsoc2013-evolution-9717e6f9efc0f5acfb0c15e576a703e02c0cd753.zip |
Implemented. (gnome_calendar_add_object): Removed function, since it was
2000-06-02 Federico Mena Quintero <federico@helixcode.com>
* gui/gnome-cal.c (save_ical_object_cb): Implemented.
(gnome_calendar_add_object): Removed function, since it was
identical to gnome_calendar_update_object(). Modified the rest
of the code to use only the latter.
(gnome_calendar_remove_object): Be more paranoid about the UID.
(gnome_calendar_update_object): Ditto. Also, renamed this
function from gnome_calendar_object_changed(), for consistency
with the lower-level CalClient interface.
* gui/event-editor.c (event_editor_class_init): New
"save_ical_object" signal to ask that our parent store the
calendar object to the backend.
(save_ical_object): New function to save the calendar object,
actually if just emits the signal.
(file_save_cb): Implemented.
(dialog_to_ical_object): We want priv->
alarm_program_run_program_entry (i.e. the entry inside the
GnomeFileEntry), not the file entry itself.
(dialog_to_ical_object): Only insert the recurrence ending date if
the event is recurrent!
svn path=/trunk/; revision=3380
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/e-day-view.c | 27 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 13 | ||||
-rw-r--r-- | calendar/gui/event-editor.c | 482 | ||||
-rw-r--r-- | calendar/gui/event-editor.h | 1 | ||||
-rw-r--r-- | calendar/gui/gncal-todo.c | 7 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 32 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.h | 6 |
7 files changed, 284 insertions, 284 deletions
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index f80562fb12..66fd908afd 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -2346,7 +2346,7 @@ e_day_view_on_delete_occurrence (GtkWidget *widget, gpointer data) ico = ical_object_duplicate (event->ico); ical_object_add_exdate (ico, event->start); - gnome_calendar_object_changed (day_view->calendar, ico); + gnome_calendar_update_object (day_view->calendar, ico); ical_object_unref (ico); } @@ -2401,10 +2401,10 @@ e_day_view_on_unrecur_appointment (GtkWidget *widget, gpointer data) /* Now update both iCalObjects. Note that we do this last since at present the updates happen synchronously so our event may disappear. */ - gnome_calendar_object_changed (day_view->calendar, ico); + gnome_calendar_update_object (day_view->calendar, ico); ical_object_unref (ico); - gnome_calendar_add_object (day_view->calendar, new_ico); + gnome_calendar_update_object (day_view->calendar, new_ico); ical_object_unref (new_ico); } @@ -2899,8 +2899,7 @@ e_day_view_finish_long_event_resize (EDayView *day_view) day_view->resize_drag_pos = E_DAY_VIEW_POS_NONE; - /* Notify calendar of change */ - gnome_calendar_object_changed (day_view->calendar, &ico); + gnome_calendar_update_object (day_view->calendar, &ico); } @@ -2940,8 +2939,7 @@ e_day_view_finish_resize (EDayView *day_view) day_view->resize_drag_pos = E_DAY_VIEW_POS_NONE; - /* Notify calendar of change */ - gnome_calendar_object_changed (day_view->calendar, &ico); + gnome_calendar_update_object (day_view->calendar, &ico); } @@ -3890,8 +3888,7 @@ e_day_view_key_press (GtkWidget *widget, GdkEventKey *event) g_warning ("Couldn't find event to start editing.\n"); } - gnome_calendar_add_object (day_view->calendar, ico); - + gnome_calendar_update_object (day_view->calendar, ico); ical_object_unref (ico); return TRUE; @@ -4141,9 +4138,7 @@ e_day_view_on_editing_stopped (EDayView *day_view, event->ico->summary = text; - /* Notify calendar of change. This will result in a call to update, - which will reset the event label as appropriate. */ - gnome_calendar_object_changed (day_view->calendar, event->ico); + gnome_calendar_update_object (day_view->calendar, event->ico); } @@ -5094,9 +5089,7 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, if (event->canvas_item) gnome_canvas_item_show (event->canvas_item); - /* Notify calendar of change */ - gnome_calendar_object_changed (day_view->calendar, &ico); - + gnome_calendar_update_object (day_view->calendar, &ico); return; } } @@ -5172,9 +5165,7 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, if (event->canvas_item) gnome_canvas_item_show (event->canvas_item); - /* Notify calendar of change */ - gnome_calendar_object_changed (day_view->calendar, &ico); - + gnome_calendar_update_object (day_view->calendar, &ico); return; } } diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 3dd20e4e48..d756fd7a51 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -2371,9 +2371,7 @@ e_week_view_on_editing_stopped (EWeekView *week_view, event->ico->summary = text; - /* Notify calendar of change. This will result in a call to update, - which will reset the event label as appropriate. */ - gnome_calendar_object_changed (week_view->calendar, event->ico); + gnome_calendar_update_object (week_view->calendar, event->ico); } @@ -2528,8 +2526,7 @@ e_week_view_key_press (GtkWidget *widget, GdkEventKey *event) g_warning ("Couldn't find event to start editing.\n"); } - gnome_calendar_add_object (week_view->calendar, ico); - + gnome_calendar_update_object (week_view->calendar, ico); ical_object_unref (ico); return TRUE; @@ -2662,7 +2659,7 @@ e_week_view_on_delete_occurrence (GtkWidget *widget, gpointer data) ico = ical_object_duplicate (event->ico); ical_object_add_exdate (ico, event->start); - gnome_calendar_object_changed (week_view->calendar, ico); + gnome_calendar_update_object (week_view->calendar, ico); ical_object_unref (ico); } @@ -2718,9 +2715,9 @@ e_week_view_on_unrecur_appointment (GtkWidget *widget, gpointer data) /* Now update both iCalObjects. Note that we do this last since at present the updates happen synchronously so our event may disappear. */ - gnome_calendar_object_changed (week_view->calendar, ico); + gnome_calendar_update_object (week_view->calendar, ico); ical_object_unref (ico); - gnome_calendar_add_object (week_view->calendar, new_ico); + gnome_calendar_update_object (week_view->calendar, new_ico); ical_object_unref (new_ico); } diff --git a/calendar/gui/event-editor.c b/calendar/gui/event-editor.c index 9f24fb63cd..da56a5e387 100644 --- a/calendar/gui/event-editor.c +++ b/calendar/gui/event-editor.c @@ -117,6 +117,7 @@ typedef struct { /* Signal IDs */ enum { + SAVE_ICAL_OBJECT, ICAL_OBJECT_RELEASED, EDITOR_CLOSED, LAST_SIGNAL @@ -191,6 +192,15 @@ event_editor_class_init (EventEditorClass *class) parent_class = gtk_type_class (GTK_TYPE_OBJECT); + event_editor_signals[SAVE_ICAL_OBJECT] = + gtk_signal_new ("save_ical_object", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EventEditorClass, save_ical_object), + gtk_marshal_NONE__POINTER, + GTK_TYPE_NONE, 1, + GTK_TYPE_POINTER); + event_editor_signals[ICAL_OBJECT_RELEASED] = gtk_signal_new ("ical_object_released", GTK_RUN_FIRST, @@ -821,6 +831,240 @@ fill_widgets (EventEditor *ee) append_exception (ee, *((time_t *) list->data)); } + + +/* Frees the list of exception dates in an iCalObject */ +static void +free_exdate (iCalObject *ico) +{ + GList *list; + + if (!ico->exdate) + return; + + for (list = ico->exdate; list; list = list->next) + g_free (list->data); + + g_list_free (ico->exdate); + ico->exdate = NULL; +} + +/* Decode the radio button group for classifications */ +static ClassificationType +classification_get (GtkWidget *widget) +{ + return e_dialog_radio_get (widget, classification_map); +} + +/* Get the values of the widgets in the event editor and put them in the iCalObject */ +static void +dialog_to_ical_object (EventEditor *ee) +{ + EventEditorPrivate *priv; + iCalObject *ico; + gboolean all_day_event; + int i; + time_t *t; + GtkCList *exception_list; + + priv = ee->priv; + ico = priv->ico; + + if (ico->summary) + g_free (ico->summary); + + ico->summary = e_dialog_editable_get (priv->general_summary); + + ico->dtstart = e_dialog_dateedit_get (priv->start_time); + ico->dtend = e_dialog_dateedit_get (priv->end_time); + + all_day_event = e_dialog_toggle_get (priv->all_day_event); + + ico->dalarm.enabled = e_dialog_toggle_get (priv->alarm_display); + ico->aalarm.enabled = e_dialog_toggle_get (priv->alarm_program); + ico->palarm.enabled = e_dialog_toggle_get (priv->alarm_audio); + ico->malarm.enabled = e_dialog_toggle_get (priv->alarm_mail); + + ico->dalarm.count = e_dialog_spin_get_int (priv->alarm_display_amount); + ico->aalarm.count = e_dialog_spin_get_int (priv->alarm_audio_amount); + ico->palarm.count = e_dialog_spin_get_int (priv->alarm_program_amount); + ico->malarm.count = e_dialog_spin_get_int (priv->alarm_mail_amount); + + ico->dalarm.units = alarm_unit_get (priv->alarm_display_unit); + ico->aalarm.units = alarm_unit_get (priv->alarm_audio_unit); + ico->palarm.units = alarm_unit_get (priv->alarm_program_unit); + ico->malarm.units = alarm_unit_get (priv->alarm_mail_unit); + + if (ico->palarm.data) + g_free (ico->palarm.data); + + if (ico->malarm.data) + g_free (ico->malarm.data); + + ico->palarm.data = e_dialog_editable_get (priv->alarm_program_run_program_entry); + ico->malarm.data = e_dialog_editable_get (priv->alarm_mail_mail_to); + + if (ico->class) + g_free (ico->class); + + switch (classification_get (priv->classification_radio)) { + case CLASSIFICATION_PUBLIC: + ico->class = g_strdup ("PUBLIC"); + break; + + case CLASSIFICATION_PRIVATE: + ico->class = g_strdup ("PRIVATE"); + break; + + case CLASSIFICATION_CONFIDENTIAL: + ico->class = g_strdup ("CONFIDENTIAL"); + break; + + default: + g_assert_not_reached (); + } + + /* Recurrence information */ + + if (ico->recur) { + g_free (ico->recur); + ico->recur = NULL; + } + + switch (recur_options_get (priv->recurrence_rule_none)) { + case RECUR_OPTION_NONE: + /* nothing */ + break; + + case RECUR_OPTION_DAILY: + ico->recur = g_new0 (Recurrence, 1); + ico->recur->type = RECUR_DAILY; + ico->recur->interval = e_dialog_spin_get_int (priv->recurrence_rule_daily_days); + break; + + case RECUR_OPTION_WEEKLY: + ico->recur = g_new0 (Recurrence, 1); + ico->recur->type = RECUR_WEEKLY; + ico->recur->interval = e_dialog_spin_get_int (priv->recurrence_rule_weekly_weeks); + ico->recur->weekday = 0; + + if (e_dialog_toggle_get (priv->recurrence_rule_weekly_sun)) + ico->recur->weekday |= 1 << 0; + if (e_dialog_toggle_get (priv->recurrence_rule_weekly_mon)) + ico->recur->weekday |= 1 << 1; + if (e_dialog_toggle_get (priv->recurrence_rule_weekly_tue)) + ico->recur->weekday |= 1 << 2; + if (e_dialog_toggle_get (priv->recurrence_rule_weekly_wed)) + ico->recur->weekday |= 1 << 3; + if (e_dialog_toggle_get (priv->recurrence_rule_weekly_thu)) + ico->recur->weekday |= 1 << 4; + if (e_dialog_toggle_get (priv->recurrence_rule_weekly_fri)) + ico->recur->weekday |= 1 << 5; + if (e_dialog_toggle_get (priv->recurrence_rule_weekly_sat)) + ico->recur->weekday |= 1 << 6; + + break; + + case RECUR_OPTION_MONTHLY: + ico->recur = g_new0 (Recurrence, 1); + + if (e_dialog_toggle_get (priv->recurrence_rule_monthly_on_day)) { + /* by day of in the month (ex: the 5th) */ + ico->recur->type = RECUR_MONTHLY_BY_DAY; + ico->recur->u.month_day = e_dialog_spin_get_int ( + priv->recurrence_rule_monthly_day_nth); + } else if (e_dialog_toggle_get (priv->recurrence_rule_monthly_weekday)) { + /* "recurrence-rule-monthly-weekday" is TRUE */ + /* by position on the calender (ex: 2nd monday) */ + ico->recur->type = RECUR_MONTHLY_BY_POS; + ico->recur->u.month_pos = e_dialog_option_menu_get ( + priv->recurrence_rule_monthly_week, + month_pos_map); + ico->recur->weekday = e_dialog_option_menu_get ( + priv->recurrence_rule_monthly_weekpos, + weekday_map); + + } else + g_assert_not_reached (); + + ico->recur->interval = e_dialog_spin_get_int ( + priv->recurrence_rule_monthly_every_n_months); + + break; + + case RECUR_OPTION_YEARLY: + ico->recur = g_new0 (Recurrence, 1); + ico->recur->type = RECUR_YEARLY_BY_DAY; + ico->recur->interval = e_dialog_spin_get_int ( + priv->recurrence_rule_yearly_every_n_years); + + default: + g_assert_not_reached (); + } + + /* recurrence ending date */ + + if (ico->recur) { + if (e_dialog_toggle_get (priv->recurrence_ending_date_repeat_forever)) { + ico->recur->_enddate = 0; + ico->recur->enddate = 0; + ico->recur->duration = 0; + } else if (e_dialog_toggle_get (priv->recurrence_ending_date_end_on)) { + /* Also here, to ensure that the event is used, we add 86400 + * secs to get get next day, in accordance to the RFC + */ + ico->recur->_enddate = e_dialog_dateedit_get ( + priv->recurrence_ending_date_end_on_date) + 86400; + ico->recur->enddate = ico->recur->_enddate; + ico->recur->duration = 0; + } else if (e_dialog_toggle_get (priv->recurrence_ending_date_end_after)) { + ico->recur->duration = e_dialog_spin_get_int ( + priv->recurrence_ending_date_end_after_count); + ical_object_compute_end (ico); + } else + g_assert_not_reached (); + } + + /* Get exceptions from clist into ico->exdate */ + + free_exdate (ico); + exception_list = GTK_CLIST (priv->recurrence_exceptions_list); + + for (i = 0; i < exception_list->rows; i++) { + t = gtk_clist_get_row_data (exception_list, i); + ico->exdate = g_list_prepend (ico->exdate, t); + } +} + +/* Emits the "save_ical_object" signal if the event editor is editing an object. */ +static void +save_ical_object (EventEditor *ee) +{ + EventEditorPrivate *priv; + + priv = ee->priv; + + if (!priv->ico) + return; + + dialog_to_ical_object (ee); + + gtk_signal_emit (GTK_OBJECT (ee), event_editor_signals[SAVE_ICAL_OBJECT], + priv->ico); +} + +/* File/Save callback */ +static void +file_save_cb (GtkWidget *widget, gpointer data) +{ + EventEditor *ee; + + ee = EVENT_EDITOR (data); + save_ical_object (ee); +} + + + /* Menu bar */ static GnomeUIInfo file_new_menu[] = { @@ -850,7 +1094,7 @@ static GnomeUIInfo file_menu[] = { GNOMEUIINFO_SEPARATOR, GNOMEUIINFO_ITEM_NONE (N_("FIXME: S_end"), NULL, NULL), GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_SAVE_ITEM (NULL, NULL), + GNOMEUIINFO_MENU_SAVE_ITEM (file_save_cb, NULL), GNOMEUIINFO_MENU_SAVE_AS_ITEM (NULL, NULL), GNOMEUIINFO_ITEM_NONE (N_("FIXME: Save Attac_hments..."), NULL, NULL), GNOMEUIINFO_SEPARATOR, @@ -1008,6 +1252,8 @@ create_menu (EventEditor *ee) bonobo_ui_handler_menu_add_list (priv->uih, "/", list); } + + /* Toolbar */ static GnomeUIInfo toolbar[] = { @@ -1056,6 +1302,8 @@ create_toolbar (EventEditor *ee) bonobo_ui_handler_toolbar_add_list (priv->uih, "/Toolbar", list); } + + /* Callback used when the dialog box is destroyed */ static gint app_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) @@ -1232,238 +1480,6 @@ event_editor_focus (EventEditor *ee) } static void -free_exdate (iCalObject *ico) -{ - GList *list; - - if (!ico->exdate) - return; - - for (list = ico->exdate; list; list = list->next) - g_free (list->data); - - g_list_free (ico->exdate); - ico->exdate = NULL; -} - -/* Decode the radio button group for classifications */ -static ClassificationType -classification_get (GtkWidget *widget) -{ - return e_dialog_radio_get (widget, classification_map); -} - -/* Get the values of the widgets in the event editor and put them in the iCalObject */ -static void -dialog_to_ical_object (EventEditor *ee) -{ - EventEditorPrivate *priv; - iCalObject *ico; - gboolean all_day_event; - int i; - time_t *t; - GtkCList *exception_list; - - priv = ee->priv; - ico = priv->ico; - - if (ico->summary) - g_free (ico->summary); - - ico->summary = e_dialog_editable_get (priv->general_summary); - - ico->dtstart = e_dialog_dateedit_get (priv->start_time); - ico->dtend = e_dialog_dateedit_get (priv->end_time); - - all_day_event = e_dialog_toggle_get (priv->all_day_event); - - ico->dalarm.enabled = e_dialog_toggle_get (priv->alarm_display); - ico->aalarm.enabled = e_dialog_toggle_get (priv->alarm_program); - ico->palarm.enabled = e_dialog_toggle_get (priv->alarm_audio); - ico->malarm.enabled = e_dialog_toggle_get (priv->alarm_mail); - - ico->dalarm.count = e_dialog_spin_get_int (priv->alarm_display_amount); - ico->aalarm.count = e_dialog_spin_get_int (priv->alarm_audio_amount); - ico->palarm.count = e_dialog_spin_get_int (priv->alarm_program_amount); - ico->malarm.count = e_dialog_spin_get_int (priv->alarm_mail_amount); - - ico->dalarm.units = alarm_unit_get (priv->alarm_display_unit); - ico->aalarm.units = alarm_unit_get (priv->alarm_audio_unit); - ico->palarm.units = alarm_unit_get (priv->alarm_program_unit); - ico->malarm.units = alarm_unit_get (priv->alarm_mail_unit); - - if (ico->palarm.data) - g_free (ico->palarm.data); - - if (ico->malarm.data) - g_free (ico->malarm.data); - - ico->palarm.data = e_dialog_editable_get (priv->alarm_program_run_program); - ico->malarm.data = e_dialog_editable_get (priv->alarm_mail_mail_to); - - if (ico->class) - g_free (ico->class); - - switch (classification_get (priv->classification_radio)) { - case CLASSIFICATION_PUBLIC: - ico->class = g_strdup ("PUBLIC"); - break; - - case CLASSIFICATION_PRIVATE: - ico->class = g_strdup ("PRIVATE"); - break; - - case CLASSIFICATION_CONFIDENTIAL: - ico->class = g_strdup ("CONFIDENTIAL"); - break; - - default: - g_assert_not_reached (); - } - - /* Recurrence information */ - - if (ico->recur) { - g_free (ico->recur); - ico->recur = NULL; - } - - switch (recur_options_get (priv->recurrence_rule_none)) { - case RECUR_OPTION_NONE: - /* nothing */ - break; - - case RECUR_OPTION_DAILY: - ico->recur = g_new0 (Recurrence, 1); - ico->recur->type = RECUR_DAILY; - ico->recur->interval = e_dialog_spin_get_int (priv->recurrence_rule_daily_days); - break; - - case RECUR_OPTION_WEEKLY: - ico->recur = g_new0 (Recurrence, 1); - ico->recur->type = RECUR_WEEKLY; - ico->recur->interval = e_dialog_spin_get_int (priv->recurrence_rule_weekly_weeks); - ico->recur->weekday = 0; - - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_sun)) - ico->recur->weekday |= 1 << 0; - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_mon)) - ico->recur->weekday |= 1 << 1; - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_tue)) - ico->recur->weekday |= 1 << 2; - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_wed)) - ico->recur->weekday |= 1 << 3; - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_thu)) - ico->recur->weekday |= 1 << 4; - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_fri)) - ico->recur->weekday |= 1 << 5; - if (e_dialog_toggle_get (priv->recurrence_rule_weekly_sat)) - ico->recur->weekday |= 1 << 6; - - break; - - case RECUR_OPTION_MONTHLY: - ico->recur = g_new0 (Recurrence, 1); - - if (e_dialog_toggle_get (priv->recurrence_rule_monthly_on_day)) { - /* by day of in the month (ex: the 5th) */ - ico->recur->type = RECUR_MONTHLY_BY_DAY; - ico->recur->u.month_day = e_dialog_spin_get_int ( - priv->recurrence_rule_monthly_day_nth); - } else if (e_dialog_toggle_get (priv->recurrence_rule_monthly_weekday)) { - /* "recurrence-rule-monthly-weekday" is TRUE */ - /* by position on the calender (ex: 2nd monday) */ - ico->recur->type = RECUR_MONTHLY_BY_POS; - ico->recur->u.month_pos = e_dialog_option_menu_get ( - priv->recurrence_rule_monthly_week, - month_pos_map); - ico->recur->weekday = e_dialog_option_menu_get ( - priv->recurrence_rule_monthly_weekpos, - weekday_map); - - } else - g_assert_not_reached (); - - ico->recur->interval = e_dialog_spin_get_int ( - priv->recurrence_rule_monthly_every_n_months); - - break; - - case RECUR_OPTION_YEARLY: - ico->recur = g_new0 (Recurrence, 1); - ico->recur->type = RECUR_YEARLY_BY_DAY; - ico->recur->interval = e_dialog_spin_get_int ( - priv->recurrence_rule_yearly_every_n_years); - - default: - g_assert_not_reached (); - } - - /* recurrence ending date */ - - if (e_dialog_toggle_get (priv->recurrence_ending_date_repeat_forever)) { - ico->recur->_enddate = 0; - ico->recur->enddate = 0; - ico->recur->duration = 0; - } else if (e_dialog_toggle_get (priv->recurrence_ending_date_end_on)) { - /* Also here, to ensure that the event is used, we add 86400 - * secs to get get next day, in accordance to the RFC - */ - ico->recur->_enddate = e_dialog_dateedit_get ( - priv->recurrence_ending_date_end_on_date) + 86400; - ico->recur->enddate = ico->recur->_enddate; - ico->recur->duration = 0; - } else if (e_dialog_toggle_get (priv->recurrence_ending_date_end_after)) { - ico->recur->duration = e_dialog_spin_get_int ( - priv->recurrence_ending_date_end_after_count); - ical_object_compute_end (ico); - } else - g_assert_not_reached (); - - /* Get exceptions from clist into ico->exdate */ - - free_exdate (ico); - exception_list = GTK_CLIST (priv->recurrence_exceptions_list); - - for (i = 0; i < exception_list->rows; i++) { - t = gtk_clist_get_row_data (exception_list, i); - ico->exdate = g_list_prepend (ico->exdate, t); - } -} - -#if 0 -static void -ee_ok (GtkWidget *widget, EventEditor *ee) -{ - EventEditorPrivate *priv; - - priv = ee->priv; - - dialog_to_ical_object (ee); - - if (priv->ico->new) - gnome_calendar_add_object (priv->gcal, priv->ico); - else - gnome_calendar_object_changed (priv->gcal, priv->ico); - - priv->ico->new = FALSE; -} - -static void -ee_cancel (GtkWidget *widget, EventEditor *ee) -{ - EventEditorPrivate *priv; - - priv = ee->priv; - - if (priv->ico) { - ical_object_unref (priv->ico); - priv->ico = NULL; - } -} -#endif - -static void alarm_toggle (GtkWidget *toggle, EventEditor *ee) { EventEditorPrivate *priv; diff --git a/calendar/gui/event-editor.h b/calendar/gui/event-editor.h index f5b5482e93..7f5cedf37c 100644 --- a/calendar/gui/event-editor.h +++ b/calendar/gui/event-editor.h @@ -52,6 +52,7 @@ struct _EventEditorClass { /* Notification signals */ + void (* save_ical_object) (EventEditor *ee, iCalObject *ico); void (* ical_object_released) (EventEditor *ee, const char *uid); void (* editor_closed) (EventEditor *ee); }; diff --git a/calendar/gui/gncal-todo.c b/calendar/gui/gncal-todo.c index e10840bf8d..1f7fd3bb59 100644 --- a/calendar/gui/gncal-todo.c +++ b/calendar/gui/gncal-todo.c @@ -82,12 +82,7 @@ ok_button (GtkWidget *widget, GnomeDialog *dialog) ico->comment = gtk_editable_get_chars( GTK_EDITABLE(comment), 0, -1); ico->user_data = NULL; - if (ico->new) { - gnome_calendar_add_object (todo->calendar, ico); - ico->new = FALSE; - } else - gnome_calendar_object_changed (todo->calendar, ico); - + gnome_calendar_update_object (todo->calendar, ico); ical_object_unref (ico); gtk_widget_destroy (GTK_WIDGET (dialog)); diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index e97947cbf0..e6e7082666 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -1014,14 +1014,15 @@ gnome_calendar_open (GnomeCalendar *gcal, return 1; } - void -gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj) +gnome_calendar_update_object (GnomeCalendar *gcal, iCalObject *obj) { char *obj_string; + g_return_if_fail (gcal != NULL); g_return_if_fail (GNOME_IS_CALENDAR (gcal)); g_return_if_fail (obj != NULL); + g_return_if_fail (obj->uid != NULL); obj_string = ical_object_to_string (obj); cal_client_update_object (gcal->client, obj->uid, obj_string); @@ -1036,23 +1037,11 @@ gnome_calendar_remove_object (GnomeCalendar *gcal, iCalObject *obj) g_return_if_fail (gcal != NULL); g_return_if_fail (GNOME_IS_CALENDAR (gcal)); g_return_if_fail (obj != NULL); + g_return_if_fail (obj->uid != NULL); r = cal_client_remove_object (gcal->client, obj->uid); } -void -gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj) -{ - char *obj_string; - g_return_if_fail (gcal != NULL); - g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - g_return_if_fail (obj != NULL); - - obj_string = ical_object_to_string (obj); - cal_client_update_object (gcal->client, obj->uid, obj_string); - g_free (obj_string); -} - static void stop_beeping (GtkObject* object, gpointer data) { @@ -1334,6 +1323,16 @@ editor_closed_cb (EventEditor *ee, gpointer data) gtk_object_unref (GTK_OBJECT (ee)); } +/* Callback used when an event editor requests that an object be saved */ +static void +save_ical_object_cb (EventEditor *ee, iCalObject *ico, gpointer data) +{ + GnomeCalendar *gcal; + + gcal = GNOME_CALENDAR (data); + gnome_calendar_update_object (gcal, ico); +} + void gnome_calendar_edit_object (GnomeCalendar *gcal, iCalObject *ico) { @@ -1363,6 +1362,9 @@ gnome_calendar_edit_object (GnomeCalendar *gcal, iCalObject *ico) gtk_signal_connect (GTK_OBJECT (ee), "editor_closed", GTK_SIGNAL_FUNC (editor_closed_cb), gcal); + gtk_signal_connect (GTK_OBJECT (ee), "save_ical_object", + GTK_SIGNAL_FUNC (save_ical_object_cb), gcal); + event_editor_set_ical_object (EVENT_EDITOR (ee), ico); } diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index e6d01b8567..a6f8a342ff 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -79,8 +79,8 @@ int gnome_calendar_open (GnomeCalendar *gcal, int gnome_calendar_create (GnomeCalendar *gcal, char *file); */ -void gnome_calendar_add_object (GnomeCalendar *gcal, - iCalObject *obj); +void gnome_calendar_update_object (GnomeCalendar *gcal, + iCalObject *obj); void gnome_calendar_remove_object (GnomeCalendar *gcal, iCalObject *obj); void gnome_calendar_next (GnomeCalendar *gcal); @@ -111,8 +111,6 @@ void gnome_calendar_get_current_time_range (GnomeCalendar *gcal, time_t *start_time, time_t *end_time); -void gnome_calendar_object_changed (GnomeCalendar *gcal, - iCalObject *obj); /* Notifies the calendar that the time format has changed and it must update all its views */ void gnome_calendar_time_format_changed (GnomeCalendar *gcal); |