diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-06-06 22:38:42 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-06-06 22:38:42 +0000 |
commit | b60d64b001c8819e6626b00efbeae96560368a08 (patch) | |
tree | 5f4596a1a68c41d917a4aacb43b9804c2121158b /lib/json/editor.rb | |
parent | 6d2dee14f3d5d4224effd0ec2d8fbc07dc54cbac (diff) | |
download | ruby-b60d64b001c8819e6626b00efbeae96560368a08.tar.gz |
* lib/json/common.rb: Ponder offering parse\! method.
* lib/json/editor.rb: be a bit more robust while loading data.
* ext/json/ext/{generator,parser}/extconf.rb:
add a have_header directive for st.h
* test/json: fix some tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12456 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/json/editor.rb')
-rw-r--r-- | lib/json/editor.rb | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/lib/json/editor.rb b/lib/json/editor.rb index 063df69533..3dbcce5536 100644 --- a/lib/json/editor.rb +++ b/lib/json/editor.rb @@ -52,14 +52,12 @@ module JSON MessageDialog::ERROR, MessageDialog::BUTTONS_CLOSE, text) dialog.show_all - window.focus = dialog dialog.run rescue TypeError dialog = MessageDialog.new(Editor.window, Dialog::MODAL, MessageDialog::ERROR, MessageDialog::BUTTONS_CLOSE, text) dialog.show_all - window.focus = dialog dialog.run ensure dialog.destroy if dialog @@ -73,7 +71,6 @@ module JSON MessageDialog::QUESTION, MessageDialog::BUTTONS_YES_NO, text) dialog.show_all - window.focus = dialog dialog.run do |response| return Gtk::Dialog::RESPONSE_YES === response end @@ -1102,9 +1099,11 @@ module JSON # Quit this editor, that is, leave this editor's main loop. def quit ask_save if @changed - destroy - Gtk.main_quit - true + if Gtk.main_level > 0 + destroy + Gtk.main_quit + end + nil end # Display the new title according to the editor's current state. @@ -1185,20 +1184,21 @@ module JSON if filename if File.directory?(filename) Editor.error_dialog(self, "Try to select a JSON file!") - return + nil else - data = read_data(filename) @filename = filename - toplevel.display_status("Loaded data from '#@filename'.") + if data = read_data(filename) + toplevel.display_status("Loaded data from '#@filename'.") + end display_title - return data + data end end end # Load the data at location _uri_ into the editor as a JSON document. def load_location(uri) - data = read_data(uri) + data = read_data(uri) or return @filename = nil toplevel.display_status("Loaded data from '#{uri}'.") display_title @@ -1217,11 +1217,9 @@ module JSON end return JSON::parse(json, :max_nesting => false) end - rescue JSON::JSONError => e + rescue => e Editor.error_dialog(self, "Failed to parse JSON file: #{e}!") return - rescue SystemCallError => e - quit end # Open a file selecton dialog, displaying _message_, and return the |