lib/json/editor.rb in json_pure-1.5.3 vs lib/json/editor.rb in json_pure-1.5.4

- old
+ new

@@ -45,18 +45,18 @@ end # Opens an error dialog on top of _window_ showing the error message # _text_. def Editor.error_dialog(window, text) - dialog = MessageDialog.new(window, Dialog::MODAL, - MessageDialog::ERROR, + dialog = MessageDialog.new(window, Dialog::MODAL, + MessageDialog::ERROR, MessageDialog::BUTTONS_CLOSE, text) dialog.show_all dialog.run rescue TypeError - dialog = MessageDialog.new(Editor.window, Dialog::MODAL, - MessageDialog::ERROR, + dialog = MessageDialog.new(Editor.window, Dialog::MODAL, + MessageDialog::ERROR, MessageDialog::BUTTONS_CLOSE, text) dialog.show_all dialog.run ensure dialog.destroy if dialog @@ -64,12 +64,12 @@ # Opens a yes/no question dialog on top of _window_ showing the error # message _text_. If yes was answered _true_ is returned, otherwise # _false_. def Editor.question_dialog(window, text) - dialog = MessageDialog.new(window, Dialog::MODAL, - MessageDialog::QUESTION, + dialog = MessageDialog.new(window, Dialog::MODAL, + MessageDialog::QUESTION, MessageDialog::BUTTONS_YES_NO, text) dialog.show_all dialog.run do |response| return Gtk::Dialog::RESPONSE_YES === response end @@ -462,11 +462,11 @@ add_item("Paste node (inserting before)", ?I, &method(:paste_node_inserting_before)) add_separator add_item("Append new node", ?a, &method(:append_new_node)) add_item("Insert new node before", ?i, &method(:insert_new_node)) - add_separator + add_separator add_item("Collapse/Expand node (recursively)", ?e, &method(:collapse_expand)) menu.show_all signal_connect(:button_press_event) do |widget, event| @@ -501,11 +501,11 @@ end # Revert the current JSON document in the editor to the saved version. def revert(item) window.instance_eval do - @filename and file_open(@filename) + @filename and file_open(@filename) end end # Save the current JSON document. def save(item) @@ -663,11 +663,11 @@ if expanded self.expanded = false collapse_all else self.expanded = true - expand_all + expand_all end end # Toggle pretty saving mode on/off. def pretty_saving(item) @@ -882,11 +882,11 @@ dialog.vbox.pack_start(hbox, false) dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER) dialog.show_all self.focus = dialog - dialog.run do |response| + dialog.run do |response| if response == Dialog::RESPONSE_ACCEPT @key = key_input.text type = ALL_TYPES[@type = type_input.active] content = value_input.text return @key, type, content @@ -934,11 +934,11 @@ dialog.vbox.pack_start(hbox, false) dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER) dialog.show_all self.focus = dialog - dialog.run do |response| + dialog.run do |response| if response == Dialog::RESPONSE_ACCEPT type = types[type_input.active] @content = case type when 'Numeric' if (t = value_input.text) == 'Infinity' @@ -979,11 +979,11 @@ dialog.vbox.pack_start(hbox, false) dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER) dialog.show_all self.focus = dialog - dialog.run do |response| + dialog.run do |response| if response == Dialog::RESPONSE_ACCEPT return @order = order_input.text, reverse_checkbox.active? end end return @@ -1014,11 +1014,11 @@ dialog.vbox.pack_start(hbox, false) dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER) dialog.show_all self.focus = dialog - dialog.run do |response| + dialog.run do |response| if response == Dialog::RESPONSE_ACCEPT begin return Regexp.new(regex_input.text, icase_checkbox.active? ? Regexp::IGNORECASE : 0) rescue => e Editor.error_dialog(self, "Evaluation of regex /#{regex_input.text}/ failed: #{e}!") @@ -1213,11 +1213,11 @@ else file_save_as end end - # Save the current file as the filename + # Save the current file as the filename def file_save_as filename = select_file('Save as a JSON file') store_file(filename) end @@ -1239,11 +1239,11 @@ unchange end rescue SystemCallError => e Editor.error_dialog(self, "Failed to store JSON file: #{e}!") end - + # Load the file named _filename_ into the editor as a JSON document. def load_file(filename) if filename if File.directory?(filename) Editor.error_dialog(self, "Try to select a JSON file!") @@ -1331,10 +1331,10 @@ dialog.vbox.pack_start(hbox, false) dialog.signal_connect(:'key-press-event', &DEFAULT_DIALOG_KEY_PRESS_HANDLER) dialog.show_all - dialog.run do |response| + dialog.run do |response| if response == Dialog::RESPONSE_ACCEPT return @location = location_input.text end end return