Class: Alexandria::UI::ReallyDeleteDialog

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ReallyDeleteDialog.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/alexandria/ui/dialogs/misc_dialogs.rb', line 49

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, :cancel],
         [Gtk::Stock::DELETE, :ok]],
        description)

  self.default_response = Gtk::ResponseType::CANCEL
  show_all && (@response = run)
  destroy
end

Instance Method Details

#ok?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/alexandria/ui/dialogs/misc_dialogs.rb', line 82

def ok?
  @response == :ok
end