Class: Alexandria::UI::ReallyDeleteDialog

Inherits:
AlertDialog
  • Object
show all
Includes:
GetText
Defined in:
lib/alexandria/ui/really_delete_dialog.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent, library, books = nil) ⇒ ReallyDeleteDialog

Returns a new instance of ReallyDeleteDialog.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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)

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

Instance Method Details

#ok?Boolean

Returns:

  • (Boolean)


46
47
48
49
50
# File 'lib/alexandria/ui/really_delete_dialog.rb', line 46

def ok?
  show_all && (@response = run)
  destroy
  @response == Gtk::ResponseType::OK
end