diff options
Diffstat (limited to 'calendar/gui/tasks-control.c')
-rw-r--r-- | calendar/gui/tasks-control.c | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/calendar/gui/tasks-control.c b/calendar/gui/tasks-control.c index 57d3623090..504342fa88 100644 --- a/calendar/gui/tasks-control.c +++ b/calendar/gui/tasks-control.c @@ -26,8 +26,13 @@ #include <libgnome/gnome-defs.h> #include <libgnome/gnome-i18n.h> #include <libgnome/gnome-util.h> +#include <libgnomeui/gnome-dialog.h> +#include <libgnomeui/gnome-dialog-util.h> +#include <libgnomeui/gnome-stock.h> #include <bonobo/bonobo-control.h> #include <bonobo/bonobo-ui-util.h> +#include <gal/widgets/e-gui-utils.h> +#include <e-util/e-dialog-utils.h> #include "dialogs/cal-prefs-dialog.h" #include "calendar-config.h" #include "calendar-commands.h" @@ -74,6 +79,9 @@ static void tasks_control_paste_cmd (BonoboUIComponent *uic, static void tasks_control_delete_cmd (BonoboUIComponent *uic, gpointer data, const char *path); +static void tasks_control_expunge_cmd (BonoboUIComponent *uic, + gpointer data, + const char *path); static void tasks_control_settings_cmd (BonoboUIComponent *uic, gpointer data, const char *path); @@ -238,6 +246,7 @@ static BonoboUIVerb verbs [] = { BONOBO_UI_VERB ("TasksCopy", tasks_control_copy_cmd), BONOBO_UI_VERB ("TasksPaste", tasks_control_paste_cmd), BONOBO_UI_VERB ("TasksDelete", tasks_control_delete_cmd), + BONOBO_UI_VERB ("TasksExpunge", tasks_control_expunge_cmd), BONOBO_UI_VERB ("TasksSettings", tasks_control_settings_cmd), BONOBO_UI_VERB_END @@ -387,6 +396,91 @@ tasks_control_delete_cmd (BonoboUIComponent *uic, e_tasks_delete_selected (tasks); } +static gboolean +confirm_expunge (ETasks *tasks) +{ + GtkWidget *dialog, *label, *checkbox; + int button, val; + char *text = NULL; + + if (!calendar_config_get_confirm_expunge ()) + return TRUE; + + dialog = gnome_dialog_new (_("Warning"), + GNOME_STOCK_BUTTON_YES, + GNOME_STOCK_BUTTON_NO, + NULL); + e_gnome_dialog_set_parent (GNOME_DIALOG (dialog), + GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (tasks), + GTK_TYPE_WINDOW))); + + val = calendar_config_get_hide_completed_tasks_value (); + if (val == 0) { + text = g_strdup (_("This operation will permanently erase all tasks marked as completed. If you continue, you will not be able to recover these tasks.\n\nReally erase these tasks?")); + } else { + int units; + + units = calendar_config_get_hide_completed_tasks_units (); + switch (units) { + case CAL_DAYS: + if (val == 1) + text = g_strdup (_("This operation will permanently erase all tasks marked as completed on or before 1 day ago. If you continue, you will not be able to recover these tasks.\n\nReally erase these tasks?")); + else + text = g_strdup_printf (_("This operation will permanently erase all tasks marked as completed on or before %d days ago. If you continue, you will not be able to recover these tasks.\n\nReally erase these tasks?"), val); + break; + case CAL_HOURS: + if (val == 1) + text = g_strdup (_("This operation will permanently erase all tasks marked as completed on or before 1 hour ago. If you continue, you will not be able to recover these tasks.\n\nReally erase these tasks?")); + else + text = g_strdup_printf (_("This operation will permanently erase all tasks marked as completed on or before %d hours ago. If you continue, you will not be able to recover these tasks.\n\nReally erase these tasks?"), val); + break; + case CAL_MINUTES: + if (val == 1) + text = g_strdup (_("This operation will permanently erase all tasks marked as completed on or before 1 minute ago. If you continue, you will not be able to recover these tasks.\n\nReally erase these tasks?")); + else + text = g_strdup_printf (_("This operation will permanently erase all tasks marked as completed on or before %d minutes ago. If you continue, you will not be able to recover these tasks.\n\nReally erase these tasks?"), val); + break; + } + } + label = gtk_label_new (text); + g_free (text); + + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); + gtk_widget_show (label); + gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), label, TRUE, TRUE, 4); + + checkbox = gtk_check_button_new_with_label (_("Do not ask me again.")); + gtk_widget_show (checkbox); + gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), checkbox, TRUE, TRUE, 4); + + button = gnome_dialog_run (GNOME_DIALOG (dialog)); + + if (button == 0 && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox))) + calendar_config_set_confirm_expunge (FALSE); + + gnome_dialog_close (GNOME_DIALOG (dialog)); + + if (button == 0) + return TRUE; + else + return FALSE; +} + +static void +tasks_control_expunge_cmd (BonoboUIComponent *uic, + gpointer data, + const char *path) +{ + ETasks *tasks; + + tasks = E_TASKS (data); + + if (confirm_expunge (tasks)) + e_tasks_delete_completed (tasks); +} + + /* Callback used for the tasks settings command */ static void tasks_control_settings_cmd (BonoboUIComponent *uic, gpointer data, const char *path) |