class Alexandria::UI::NewSmartLibraryDialog
Public Class Methods
new(parent)
click to toggle source
Calls superclass method
# File lib/alexandria/ui/new_smart_library_dialog.rb, line 13 def initialize(parent) super(parent) dialog.add_buttons([Gtk::Stock::CANCEL, :cancel], [Gtk::Stock::NEW, :ok]) dialog.title = _("New Smart Library") # FIXME: Should accept just :cancel dialog.default_response = Gtk::ResponseType::CANCEL insert_new_rule end
Public Instance Methods
acquire()
click to toggle source
# File lib/alexandria/ui/new_smart_library_dialog.rb, line 25 def acquire dialog.show_all result = nil while ((response = dialog.run) != Gtk::ResponseType::CANCEL) && (response != Gtk::ResponseType::DELETE_EVENT) case response when Gtk::ResponseType::HELP handle_help_response when Gtk::ResponseType::OK result = handle_ok_response break if result end end dialog.destroy result end
Private Instance Methods
handle_help_response()
click to toggle source
# File lib/alexandria/ui/new_smart_library_dialog.rb, line 47 def handle_help_response Alexandria::UI.display_help(self, "new-smart-library") end
handle_ok_response()
click to toggle source
# File lib/alexandria/ui/new_smart_library_dialog.rb, line 51 def handle_ok_response user_confirms_possible_weirdnesses_before_saving? or return rules = smart_library_rules basename = smart_library_base_name(rules) || _("Smart Library") name = Library.generate_new_name( LibraryCollection.instance.all_libraries, basename) library_store = LibraryCollection.instance.library_store SmartLibrary.new(name, rules, predicate_operator_rule, library_store) end
smart_library_base_name(rules)
click to toggle source
# File lib/alexandria/ui/new_smart_library_dialog.rb, line 66 def smart_library_base_name(rules) return unless rules.length == 1 value = rules.first.value value if value.is_a?(String) && !value.strip.empty? end