Ejemplo n.º 1
0
/*
 * The code in trash_empty_show_confirmation_dialog() was taken from
 * libcaja-private/caja-file-operations.c (confirm_empty_trash)
 * by Michiel Sikkes <*****@*****.**> and adapted for the applet.
 */
static void
trash_empty_show_confirmation_dialog (GtkWidget *parent)
{
  GtkWidget *dialog;
  GtkWidget *button;
  GdkScreen *screen;

  if (!trash_empty_require_confirmation ())
    {
      trash_empty_start (parent);
      return;
    }

  screen = gtk_widget_get_screen (parent);

  dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
                                   GTK_MESSAGE_WARNING,
                                   GTK_BUTTONS_NONE,
                                   _("Empty all of the items from "
                                     "the trash?"));
  trash_empty_confirm_dialog = GTK_DIALOG (dialog);
  g_object_add_weak_pointer (G_OBJECT (dialog),
                             (gpointer *) &trash_empty_confirm_dialog);

  gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
                                            _("If you choose to empty "
                                              "the trash, all items in "
                                              "it will be permanently "
                                              "lost. Please note that "
                                              "you can also delete them "
                                              "separately."));

  gtk_window_set_screen (GTK_WINDOW (dialog), screen);
  atk_object_set_role (gtk_widget_get_accessible (dialog), ATK_ROLE_ALERT);
  gtk_window_set_wmclass (GTK_WINDOW (dialog), "empty_trash", "Caja");

  gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL,
                         GTK_RESPONSE_CANCEL);

  button = gtk_button_new_with_mnemonic (_("_Empty Trash"));
  gtk_widget_show (button);
  gtk_widget_set_can_default (button, TRUE);

  gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button,
                                GTK_RESPONSE_YES);

  gtk_dialog_set_default_response (GTK_DIALOG (dialog),
                                   GTK_RESPONSE_YES);

  gtk_widget_show (dialog);

  g_signal_connect (dialog, "response",
                    G_CALLBACK (trash_empty_confirmation_response), NULL);
}
static void
trash_empty_show_confirmation_dialog ()
{
        GtkWidget *button;

        if (!trash_empty_require_confirmation ()) {
                trash_empty_start ();
                return;
        }

        trash_empty_confirm_dialog = gtk_message_dialog_new (NULL, 0,
                                                             GTK_MESSAGE_WARNING,
                                                             GTK_BUTTONS_NONE,
                                                             _("Empty all of the items from the trash?"));

        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (trash_empty_confirm_dialog),
                                                  _("If you choose to empty the trash, all items in "
                                                  "it will be permanently lost. Please note that "
                                                  "you can also delete them separately."));

        gtk_dialog_add_button (GTK_DIALOG (trash_empty_confirm_dialog), GTK_STOCK_CANCEL,
                               GTK_RESPONSE_CANCEL);

        button = gtk_button_new_with_mnemonic (_("_Empty Trash"));
        gtk_widget_show (button);
        gtk_widget_set_can_default (button, TRUE);

        gtk_dialog_add_action_widget (GTK_DIALOG (trash_empty_confirm_dialog),
                                      button, GTK_RESPONSE_YES);

        gtk_dialog_set_default_response (GTK_DIALOG (trash_empty_confirm_dialog),
                                         GTK_RESPONSE_YES);

        gtk_window_set_icon_name (GTK_WINDOW (trash_empty_confirm_dialog),
                                  "user-trash");

        gtk_widget_show (trash_empty_confirm_dialog);

        g_signal_connect (trash_empty_confirm_dialog, "response",
                          G_CALLBACK (trash_empty_confirmation_response), NULL);
}