class Alexandria::UI::ReallyDeleteDialog

Public Class Methods

new(parent, library, books = nil) click to toggle source
Calls superclass method Alexandria::UI::AlertDialog::new
# File lib/alexandria/ui/really_delete_dialog.rb, line 15
def initialize(parent, library, books = nil)
  # Deleting a library.
  if books.nil?
    message = _("Are you sure you want to delete '%s'?") % library.name
    description = if library.is_a?(SmartLibrary) || library.empty?
                    nil
                  else
                    n_("If you continue, %d book will be deleted.",
                       "If you continue, %d books will be deleted.",
                       library.size) % library.size
                  end
    # Deleting books.
  else
    message = if books.length == 1
                format(_("Are you sure you want to delete '%s' " \
                         "from '%s'?"), books.first.title, library.name)
              else
                _("Are you sure you want to delete the " \
                  "selected books from '%s'?") % library.name
              end
    description = nil
  end

  super(parent, message, Gtk::Stock::DIALOG_QUESTION,
        [[Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL],
         [Gtk::Stock::DELETE, Gtk::ResponseType::OK]],
        description)

  dialog.default_response = Gtk::ResponseType::CANCEL
end

Public Instance Methods

ok?() click to toggle source
# File lib/alexandria/ui/really_delete_dialog.rb, line 46
def ok?
  show_all && (@response = run)
  destroy
  @response == Gtk::ResponseType::OK
end