Class FileMenu
In: lib/json/editor.rb
Parent: Object
OptionsMenu EditMenu PopUpMenu FileMenu MainWindow JSONTreeView Enumerable TreeIter JSONError GeneratorError ParserError MissingUnicodeSupport CircularDatastructure NestingError StandardError StringScanner Parser State Gtk::Window Gtk::TreeView MenuExtension Editor lib/json/editor.rb Gtk lib/json/common.rb Ext Editor lib/json/pure/parser.rb lib/json/pure/generator.rb Object Integer FalseClass Array Hash Float NilClass TrueClass Extend String GeneratorMethods Generator Pure JSON dot/f_1.png

This class creates the File pulldown menu.

Methods

create   new   open   open_location   quit   revert   save   save_as  

Included Modules

MenuExtension

Public Instance methods

Create the menu.

[Source]

     # File lib/json/editor.rb, line 527
527:       def create
528:         title = MenuItem.new('File')
529:         title.submenu = menu
530:         add_item('New', &method(:new))
531:         add_item('Open', ?o, &method(:open))
532:         add_item('Open location', ?l, &method(:open_location))
533:         add_item('Revert', &method(:revert))
534:         add_separator
535:         add_item('Save', ?s, &method(:save))
536:         add_item('Save As', ?S, &method(:save_as))
537:         add_separator
538:         add_item('Quit', ?q, &method(:quit))
539:         title
540:       end

Clear the model and filename, but ask to save the JSON document, if unsaved changes have occured.

[Source]

     # File lib/json/editor.rb, line 490
490:       def new(item)
491:         window.clear
492:       end

Open a file and load it into the editor. Ask to save the JSON document first, if unsaved changes have occured.

[Source]

     # File lib/json/editor.rb, line 496
496:       def open(item)
497:         window.file_open
498:       end

[Source]

     # File lib/json/editor.rb, line 500
500:       def open_location(item)
501:         window.location_open
502:       end

Quit the editor, after asking to save any unsaved changes first.

[Source]

     # File lib/json/editor.rb, line 522
522:       def quit(item)
523:         window.quit
524:       end

Revert the current JSON document in the editor to the saved version.

[Source]

     # File lib/json/editor.rb, line 505
505:       def revert(item)
506:         window.instance_eval do
507:           @filename and file_open(@filename) 
508:         end
509:       end

Save the current JSON document.

[Source]

     # File lib/json/editor.rb, line 512
512:       def save(item)
513:         window.file_save
514:       end

Save the current JSON document under the given filename.

[Source]

     # File lib/json/editor.rb, line 517
517:       def save_as(item)
518:         window.file_save_as
519:       end

[Validate]