Class: Alexandria::UI::SmartLibraryPropertiesDialog

Inherits:
SmartLibraryPropertiesDialogBase show all
Includes:
GetText
Defined in:
lib/alexandria/ui/dialogs/smart_library_properties_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, smart_library) ⇒ SmartLibraryPropertiesDialog

Returns a new instance of SmartLibraryPropertiesDialog.



26
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
# File 'lib/alexandria/ui/dialogs/smart_library_properties_dialog.rb', line 26

def initialize(parent, smart_library)
  super(parent)

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

  self.title = _("Properties for '%s'") % smart_library.name
  # FIXME: Should accept just :cancel
  self.default_response = Gtk::ResponseType::CANCEL

  show_all
  smart_library.rules.each { |x| insert_new_rule(x) }
  update_rules_header_box(smart_library.predicate_operator_rule)

  while (response = run) != :cancel
    if response == :help
      Alexandria::UI.display_help(self, 'edit-smart-library')
    elsif response == :ok
      if user_confirms_possible_weirdnesses_before_saving?
        smart_library.rules = smart_library_rules
        smart_library.predicate_operator_rule =
          predicate_operator_rule
        smart_library.save
        yield(smart_library)
        break
      end
    end
  end

  destroy
end