[gnome-calendar/calendar-management] source-manager: confirm the removal before actually removing
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/calendar-management] source-manager: confirm the removal before actually removing
- Date: Thu, 5 Feb 2015 20:45:25 +0000 (UTC)
commit e0b6c4af2e39a3fca5634a9a283852df6d291f05
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Feb 5 18:44:58 2015 -0200
source-manager: confirm the removal before actually removing
This will avoid complaints in the future.
src/gcal-source-manager-dialog.c | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/src/gcal-source-manager-dialog.c b/src/gcal-source-manager-dialog.c
index 7efd5f4..0e197af 100644
--- a/src/gcal-source-manager-dialog.c
+++ b/src/gcal-source-manager-dialog.c
@@ -465,10 +465,43 @@ remove_action_activated (GSimpleAction *menu_item,
gpointer user_data)
{
GcalSourceManagerDialogPrivate *priv;
+ GtkWidget *dialog, *cancel_button, *remove_button;
+ gint response;
+
priv = gcal_source_manager_dialog_get_instance_private (GCAL_SOURCE_MANAGER_DIALOG (user_data));
- if (priv->selected_source != NULL)
+ if (priv->selected_source == NULL)
+ return;
+
+ /* Prepare the dialog */
+ dialog = gtk_message_dialog_new (GTK_WINDOW (user_data), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
+ _("Do you really want to remove the calendar '%s'?"),
+ e_source_get_display_name (priv->selected_source));
+
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _("This will remove all data associated with this calendar."));
+
+ /* Dialog buttons */
+ cancel_button = gtk_button_new_with_label (_("Cancel"));
+ remove_button = gtk_button_new_with_label (_("Remove"));
+
+ gtk_style_context_add_class (gtk_widget_get_style_context (remove_button), "destructive-action");
+
+ gtk_widget_show (cancel_button);
+ gtk_widget_show (remove_button);
+
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog), cancel_button, GTK_RESPONSE_CANCEL);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog), remove_button, GTK_RESPONSE_OK);
+
+
+ /* Run the dialog and wait for the response */
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ /* Remove the source */
+ if (response == GTK_RESPONSE_OK)
gcal_manager_remove_source (priv->manager, priv->selected_source);
+
+ gtk_widget_destroy (dialog);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]