Class: Alexandria::UI::NewSmartLibraryDialog

Inherits:
SmartLibraryPropertiesDialogBase show all
Includes:
GetText
Defined in:
lib/alexandria/ui/dialogs/new_smart_library_dialog.rb

Instance Attribute Summary

Attributes inherited from SmartLibraryPropertiesDialogBase

#predicate_operator_rule

Instance Method Summary collapse

Methods included from Logging

included, #log

Constructor Details

#initialize(parent) ⇒ NewSmartLibraryDialog

Returns a new instance of NewSmartLibraryDialog.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/alexandria/ui/dialogs/new_smart_library_dialog.rb', line 27

def initialize(parent)
  super(parent)

  add_buttons([Gtk::Stock::CANCEL, :cancel],
              [Gtk::Stock::NEW, :ok])

  self.title = _('New Smart Library')
  # FIXME: Should accept just :cancel
  self.default_response = Gtk::ResponseType::CANCEL

  show_all
  insert_new_rule

  while ((response = run) != :cancel) &&
      (response != :delete_event)

    if response == :help
      Alexandria::UI.display_help(self, 'new-smart-library')
    elsif response == :ok
      if user_confirms_possible_weirdnesses_before_saving?
        rules = smart_library_rules
        basename = smart_library_base_name(rules) || _('Smart Library')
        name = Library.generate_new_name(
          Libraries.instance.all_libraries,
          basename)
        library = SmartLibrary.new(name,
                                   rules,
                                   predicate_operator_rule)
        yield(library)
        break
      end
    end
  end

  destroy
end