Class: TreeViewerWindow
- Inherits:
-
Object
- Object
- TreeViewerWindow
- Defined in:
- lib/hilfer/tree_viewer_window.rb
Overview
Layout of the Tree Viewer Window.
Constant Summary collapse
- @@window_count =
0
Instance Method Summary collapse
- #find_icon_path ⇒ Object
-
#initialize(root_fs_path, editor) ⇒ TreeViewerWindow
constructor
A new instance of TreeViewerWindow.
Constructor Details
#initialize(root_fs_path, editor) ⇒ TreeViewerWindow
Returns a new instance of TreeViewerWindow.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/hilfer/tree_viewer_window.rb', line 10 def initialize( root_fs_path, editor ) @window = Gtk::Window.new # initialize viewer with a path @editor = editor # location bar @location = Gtk::Entry.new @tv = TreeViewer.new( root_fs_path, editor, @window, @location ) # add scrollbars @scroll = Gtk::ScrolledWindow.new( nil, nil ) @scroll.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC ) @scroll.add( @tv.view ) # expand and fill @vbox = Gtk::VBox.new( false ) @vbox.pack_start( @location, false, false ) @vbox.pack_start( @scroll, true, true ) @vbox.focus_chain = [@scroll, @location] icon_path = find_icon_path if icon_path != nil @window.icon = Gdk::Pixbuf.new( icon_path ) end @window.title = 'Hilfer ' + @tv.root_item.path @window.add( @vbox ) # read config. OK, the last parameter is a hack # but we need it so that new windows aren't show in # exactly the same position and it looks like nothing # has happened @@window_count += 1 @hc = HilferConfig.new( CONFIG_FILE, @window, @@window_count ) # set first line selected @tv.select_first # The program will directly end upon 'delete_event', ie window close @window.signal_connect( 'delete_event' ) do # unregister view from editor @editor.unregister_view( @tv ) # finish @@window_count -= 1 if @@window_count == 0 @hc.save # this MUST come before cleanup, otherwise # there will be no pipes to write the command to @editor.quit if $options[:quit_editor] # delete command pipe files @editor.cleanup Gtk.main_quit false end end # to allow the sd command to find the correct editor instance @window.signal_connect 'focus-in-event' do |,event| @editor.write_pipe_name false end # to allow the sd command to find the correct editor instance @window.signal_connect 'focus-out-event' do |,event| @editor.write_pipe_name false end end |
Instance Method Details
#find_icon_path ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/hilfer/tree_viewer_window.rb', line 80 def find_icon_path $LOAD_PATH.each do |path| png_file = Pathname.new( path ) + 'hilfer/hilfer-icon.png' return png_file.to_s if png_file.exist? end nil end |