diff options
author | Rodrigo Moya <rodrigo@ximian.com> | 2004-01-27 08:19:53 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@src.gnome.org> | 2004-01-27 08:19:53 +0800 |
commit | 92e99db3801a472ecab7924ddaad4792fe29e36b (patch) | |
tree | 3dda9b0b088b0960df5cf0013035a244aa5a452d | |
parent | fa9ea7766217e4a35ce489b9a780a0f145a40b42 (diff) | |
download | gsoc2013-evolution-92e99db3801a472ecab7924ddaad4792fe29e36b.tar.gz gsoc2013-evolution-92e99db3801a472ecab7924ddaad4792fe29e36b.tar.zst gsoc2013-evolution-92e99db3801a472ecab7924ddaad4792fe29e36b.zip |
Fixes #53276
2004-01-27 Rodrigo Moya <rodrigo@ximian.com>
Fixes #53276
* gui/dialogs/copy-source-dialog.c (show_error): new function to
create an error message dialog.
(copy_source): check if the destination calendar is read only, and
if so, don't try to copy components over. Fixed leaks. Call show_error
to display meaningful error messages.
svn path=/trunk/; revision=24456
-rw-r--r-- | calendar/ChangeLog | 10 | ||||
-rw-r--r-- | calendar/gui/dialogs/copy-source-dialog.c | 58 |
2 files changed, 50 insertions, 18 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 3fbd851847..73fc01bcf8 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,13 @@ +2004-01-27 Rodrigo Moya <rodrigo@ximian.com> + + Fixes #53276 + + * gui/dialogs/copy-source-dialog.c (show_error): new function to + create an error message dialog. + (copy_source): check if the destination calendar is read only, and + if so, don't try to copy components over. Fixed leaks. Call show_error + to display meaningful error messages. + 2004-01-26 JP Rosevear <jpr@ximian.com> * gui/migration.c (migrate_ical_folder): add the source to the diff --git a/calendar/gui/dialogs/copy-source-dialog.c b/calendar/gui/dialogs/copy-source-dialog.c index 1bf4cae4a6..b3abd44747 100644 --- a/calendar/gui/dialogs/copy-source-dialog.c +++ b/calendar/gui/dialogs/copy-source-dialog.c @@ -21,6 +21,7 @@ #include <gtk/gtkbox.h> #include <gtk/gtkdialog.h> #include <gtk/gtklabel.h> +#include <gtk/gtkmessagedialog.h> #include <gtk/gtkstock.h> #include <bonobo/bonobo-i18n.h> #include <widgets/misc/e-source-option-menu.h> @@ -54,11 +55,22 @@ source_selected_cb (ESourceOptionMenu *menu, ESource *selected_source, gpointer gtk_dialog_set_response_sensitive (GTK_DIALOG (csdd->dialog), GTK_RESPONSE_OK, FALSE); } +static void +show_error (GtkWindow *parent, const char *msg) +{ + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (parent, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, msg); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); +} + static gboolean copy_source (CopySourceDialogData *csdd) { char *uri; ECal *source_client, *dest_client; + gboolean read_only = TRUE; GList *obj_list = NULL; gboolean result = FALSE; @@ -68,40 +80,50 @@ copy_source (CopySourceDialogData *csdd) /* open the source */ source_client = auth_new_cal_from_source (csdd->orig_source, csdd->obj_type); if (!e_cal_open (source_client, TRUE, NULL)) { + show_error (GTK_WINDOW (csdd->dialog), _("Could not open source")); g_object_unref (source_client); - g_warning (G_STRLOC ": Could not open source"); return FALSE; } /* open the destination */ dest_client = auth_new_cal_from_source (csdd->selected_source, csdd->obj_type); if (!e_cal_open (dest_client, FALSE, NULL)) { + show_error (GTK_WINDOW (csdd->dialog), _("Could not open destination")); g_object_unref (dest_client); g_object_unref (source_client); - g_warning (G_STRLOC ": Could not open destination"); return FALSE; } - if (e_cal_get_object_list (source_client, "#t", &obj_list, NULL)) { - GList *l; - const char *uid; - icalcomponent *icalcomp; - - for (l = obj_list; l != NULL; l = l->next) { - /* FIXME: process recurrences */ - /* FIXME: process errors */ - if (e_cal_get_object (dest_client, icalcomponent_get_uid (l->data), NULL, - &icalcomp, NULL)) { - e_cal_modify_object (dest_client, icalcomp, CALOBJ_MOD_ALL, NULL); - } else { - e_cal_create_object (dest_client, l->data, (char **) &uid, NULL); - g_free ((gpointer) uid); + /* check if the destination is read only */ + e_cal_is_read_only (dest_client, &read_only, NULL); + if (read_only) { + show_error (GTK_WINDOW (csdd->dialog), _("Destination is read only")); + } else { + if (e_cal_get_object_list (source_client, "#t", &obj_list, NULL)) { + GList *l; + const char *uid; + icalcomponent *icalcomp; + + for (l = obj_list; l != NULL; l = l->next) { + /* FIXME: process recurrences */ + /* FIXME: process errors */ + if (e_cal_get_object (dest_client, icalcomponent_get_uid (l->data), NULL, + &icalcomp, NULL)) { + e_cal_modify_object (dest_client, icalcomp, CALOBJ_MOD_ALL, NULL); + } else { + e_cal_create_object (dest_client, l->data, (char **) &uid, NULL); + g_free ((gpointer) uid); + } } - } - e_cal_free_object_list (obj_list); + e_cal_free_object_list (obj_list); + } } + /* free memory */ + g_object_unref (dest_client); + g_object_unref (source_client); + return result; } |