aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/comp-util.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-10-28 06:13:20 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-10-28 06:13:20 +0800
commit54634a1357884543f64d00aa135bf8bc9a525880 (patch)
tree44d33eb65ea05b6dba7fff9877948f5967d0fa22 /calendar/gui/comp-util.c
parent18f549eefbc0922c33de0e57095229413ef951f3 (diff)
downloadgsoc2013-evolution-54634a1357884543f64d00aa135bf8bc9a525880.tar.gz
gsoc2013-evolution-54634a1357884543f64d00aa135bf8bc9a525880.tar.zst
gsoc2013-evolution-54634a1357884543f64d00aa135bf8bc9a525880.zip
Delete appointments with empty summaries. Fixes Ximian bug #780.
2001-10-27 Federico Mena Quintero <federico@ximian.com> * gui/e-day-view.c (e_day_view_on_editing_stopped): Delete appointments with empty summaries. Fixes Ximian bug #780. * gui/e-week-view.c (e_week_view_on_editing_stopped): Likewise. * gui/dialogs/delete-comp.c (delete_component_dialog): Added an argument to specify whether we unconditionally want single components to be considered as not having a summary. * gui/comp-util.c (cal_comp_confirm_delete_empty_comp): New function. * gui/misc.[ch]: New files with miscellaneous utility functions; moved string_is_empty() over from calendar-model.c. * gui/calendar-model.c: Use the string_is_empty() function from misc.c. * gui/Makefile.am (evolution_calendar_SOURCES): Added misc.[ch] to the list of sources. svn path=/trunk/; revision=14233
Diffstat (limited to 'calendar/gui/comp-util.c')
-rw-r--r--calendar/gui/comp-util.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c
index 808d9be910..71efec2573 100644
--- a/calendar/gui/comp-util.c
+++ b/calendar/gui/comp-util.c
@@ -24,6 +24,7 @@
#endif
#include "comp-util.h"
+#include "dialogs/delete-comp.h"
@@ -159,3 +160,74 @@ cal_comp_util_compare_event_timezones (CalComponent *comp,
return retval;
}
+
+/**
+ * cal_comp_confirm_delete_empty_comp:
+ * @comp: A calendar component.
+ * @client: Calendar client where the component purportedly lives.
+ * @widget: Widget to be used as the basis for UTF8 conversion.
+ *
+ * Assumming a calendar component with an empty SUMMARY property (as per
+ * string_is_empty()), asks whether the user wants to delete it based on
+ * whether the appointment is on the calendar server or not. If the
+ * component is on the server, this function will present a confirmation
+ * dialog and delete the component if the user tells it to. If the component
+ * is not on the server it will just return TRUE.
+ *
+ * Return value: A result code indicating whether the component
+ * was not on the server and is to be deleted locally, whether it
+ * was on the server and the user deleted it, or whether the
+ * user cancelled the deletion.
+ **/
+ConfirmDeleteEmptyCompResult
+cal_comp_confirm_delete_empty_comp (CalComponent *comp, CalClient *client, GtkWidget *widget)
+{
+ const char *uid;
+ CalClientGetStatus status;
+ CalComponent *server_comp;
+
+ g_return_val_if_fail (comp != NULL, EMPTY_COMP_DO_NOT_REMOVE);
+ g_return_val_if_fail (IS_CAL_COMPONENT (comp), EMPTY_COMP_DO_NOT_REMOVE);
+ g_return_val_if_fail (client != NULL, EMPTY_COMP_DO_NOT_REMOVE);
+ g_return_val_if_fail (IS_CAL_CLIENT (client), EMPTY_COMP_DO_NOT_REMOVE);
+ g_return_val_if_fail (widget != NULL, EMPTY_COMP_DO_NOT_REMOVE);
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), EMPTY_COMP_DO_NOT_REMOVE);
+
+ /* See if the component is on the server. If it is not, then it likely
+ * means that the appointment is new, only in the day view, and we
+ * haven't added it yet to the server. In that case, we don't need to
+ * confirm and we can just delete the event. Otherwise, we ask
+ * the user.
+ */
+ cal_component_get_uid (comp, &uid);
+
+ status = cal_client_get_object (client, uid, &server_comp);
+
+ switch (status) {
+ case CAL_CLIENT_GET_SUCCESS:
+ gtk_object_unref (GTK_OBJECT (server_comp));
+ /* Will handle confirmation below */
+ break;
+
+ case CAL_CLIENT_GET_SYNTAX_ERROR:
+ g_message ("confirm_delete_empty_appointment(): Syntax error when getting "
+ "object `%s'",
+ uid);
+ /* However, the object *is* in the server, so confirm */
+ break;
+
+ case CAL_CLIENT_GET_NOT_FOUND:
+ return EMPTY_COMP_REMOVE_LOCALLY;
+
+ default:
+ g_assert_not_reached ();
+ }
+
+ /* The event exists in the server, so confirm whether to delete it */
+
+ if (delete_component_dialog (comp, TRUE, 1, CAL_COMPONENT_EVENT, widget)) {
+ cal_client_remove_object (client, uid);
+ return EMPTY_COMP_REMOVED_FROM_SERVER;
+ } else
+ return EMPTY_COMP_DO_NOT_REMOVE;
+}