Method: CmdDirWidget#chdir

Defined in:
lib/unixcmd/dirview.rb

#chdir(path) ⇒ Object



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/unixcmd/dirview.rb', line 132

def chdir(path)
    old_path = @path == nil ? Pathname.new('') : @path 
    @path = path

    set_label @path.to_s

    reload

    if path == old_path.parent
        dirname = old_path.basename

        @view.model.each do |model, path, iter|
            if iter.get_value(0) == dirname.to_s
                @view.selection.select_path path
                @view.set_cursor path, nil, false
                break
            end
        end

    end

    if @view.selection.count_selected_rows == 0
        @view.selection.select_iter @view.model.iter_first
        @view.set_cursor @view.model.iter_first.path, nil, false
    end

    grab_focus

    signal_emit 'dir-changed'
end