~ubuntu-branches/ubuntu/intrepid/ruby1.9/intrepid-updates

« back to all changes in this revision

Viewing changes to lib/json/editor.rb

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-09-04 16:01:17 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20070904160117-i15zckg2nhxe9fyw
Tags: 1.9.0+20070830-2ubuntu1
* Sync from Debian; remaining changes:
  - Add -g to CFLAGS.
* Fixes build failure on ia64.
* Fixes build failure with gcc-4.2 on lpia.
* Robustify check for target_os, fixing build failure on lpia.
* Set Ubuntu maintainer address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
        MessageDialog::ERROR, 
53
53
        MessageDialog::BUTTONS_CLOSE, text)
54
54
      dialog.show_all
55
 
      window.focus = dialog
56
55
      dialog.run
57
56
    rescue TypeError
58
57
      dialog = MessageDialog.new(Editor.window, Dialog::MODAL, 
59
58
        MessageDialog::ERROR, 
60
59
        MessageDialog::BUTTONS_CLOSE, text)
61
60
      dialog.show_all
62
 
      window.focus = dialog
63
61
      dialog.run
64
62
    ensure
65
63
      dialog.destroy if dialog
73
71
        MessageDialog::QUESTION, 
74
72
        MessageDialog::BUTTONS_YES_NO, text)
75
73
      dialog.show_all
76
 
      window.focus = dialog
77
74
      dialog.run do |response|
78
75
        return Gtk::Dialog::RESPONSE_YES === response
79
76
      end
1102
1099
      # Quit this editor, that is, leave this editor's main loop.
1103
1100
      def quit
1104
1101
        ask_save if @changed
1105
 
        destroy
1106
 
        Gtk.main_quit
1107
 
        true
 
1102
        if Gtk.main_level > 0
 
1103
          destroy
 
1104
          Gtk.main_quit
 
1105
        end
 
1106
        nil
1108
1107
      end
1109
1108
 
1110
1109
      # Display the new title according to the editor's current state.
1185
1184
        if filename
1186
1185
          if File.directory?(filename)
1187
1186
            Editor.error_dialog(self, "Try to select a JSON file!")
1188
 
            return
 
1187
            nil
1189
1188
          else
1190
 
            data = read_data(filename)
1191
1189
            @filename = filename
1192
 
            toplevel.display_status("Loaded data from '#@filename'.")
 
1190
            if data = read_data(filename)
 
1191
              toplevel.display_status("Loaded data from '#@filename'.")
 
1192
            end
1193
1193
            display_title
1194
 
            return data
 
1194
            data
1195
1195
          end
1196
1196
        end
1197
1197
      end
1198
1198
 
1199
1199
      # Load the data at location _uri_ into the editor as a JSON document.
1200
1200
      def load_location(uri)
1201
 
        data = read_data(uri)
 
1201
        data = read_data(uri) or return
1202
1202
        @filename = nil
1203
1203
        toplevel.display_status("Loaded data from '#{uri}'.")
1204
1204
        display_title
1217
1217
          end
1218
1218
          return JSON::parse(json, :max_nesting => false)
1219
1219
        end
1220
 
      rescue JSON::JSONError => e
 
1220
      rescue => e
1221
1221
        Editor.error_dialog(self, "Failed to parse JSON file: #{e}!")
1222
1222
        return
1223
 
      rescue SystemCallError => e
1224
 
        quit
1225
1223
      end
1226
1224
 
1227
1225
      # Open a file selecton dialog, displaying _message_, and return the