class Alexandria::UI::SmartLibraryPropertiesDialog

Public Class Methods

new(parent, smart_library) click to toggle source
Calls superclass method
# File lib/alexandria/ui/smart_library_properties_dialog.rb, line 13
def initialize(parent, smart_library)
  super(parent)

  @smart_library = smart_library

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

  dialog.title = _("Properties for '%s'") % @smart_library.name
  # FIXME: Should accept just :cancel
  dialog.default_response = Gtk::ResponseType::CANCEL
  @smart_library.rules.each { |x| insert_new_rule(x) }
  update_rules_header_box(@smart_library.predicate_operator_rule)
end

Public Instance Methods

acquire() click to toggle source
# File lib/alexandria/ui/smart_library_properties_dialog.rb, line 28
def acquire
  dialog.show_all

  while (response = dialog.run) != Gtk::ResponseType::CANCEL
    case response
    when Gtk::ResponseType::HELP
      handle_help_response
    when Gtk::ResponseType::OK
      break if handle_ok_response
    end
  end

  dialog.destroy
end

Private Instance Methods

handle_help_response() click to toggle source
# File lib/alexandria/ui/smart_library_properties_dialog.rb, line 55
def handle_help_response
  Alexandria::UI.display_help(self, "edit-smart-library")
end
handle_ok_response() click to toggle source
# File lib/alexandria/ui/smart_library_properties_dialog.rb, line 45
def handle_ok_response
  user_confirms_possible_weirdnesses_before_saving? or return

  @smart_library.rules = smart_library_rules
  @smart_library.predicate_operator_rule =
    predicate_operator_rule
  @smart_library.save
  true
end