Class: CmdPanelWidget

Inherits:
Gtk::VBox
  • Object
show all
Defined in:
lib/unixcmd/panel.rb

Instance Method Summary collapse

Constructor Details

#initializeCmdPanelWidget

Returns a new instance of CmdPanelWidget.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/unixcmd/panel.rb', line 101

def initialize
    super

    @caption = CmdPanelCaptionWidget.new

    @dir = CmdDirWidget.new

    pack_start @caption, false
    pack_end @dir

    @dir.signal_connect('dir-changed') { update_caption; signal_emit 'dir-changed' }
    @caption.signal_connect('go-root') { @dir.chdir Pathname.new '/' }
    @caption.signal_connect('go-home') { @dir.chdir Pathname.new '~' }
    @caption.signal_connect('go-back') { @dir.back }
    @caption.signal_connect('go-mountpoint') { |widget, point| @dir.chdir Pathname.new point if point != nil }

    self.focus_chain = [ @dir ]

    @dir.chdir Pathname.new '~'
end

Instance Method Details

#pathObject



136
137
138
# File 'lib/unixcmd/panel.rb', line 136

def path
    @dir.path
end

#reloadObject



156
157
158
# File 'lib/unixcmd/panel.rb', line 156

def reload
    @dir.reload
end

#selectionObject



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/unixcmd/panel.rb', line 140

def selection
    res = Array.new

    @dir.view().model.each { |model, path, iter|
        res << Pathname.new(iter[0]) if(iter[7] != 0)
    }

    if res.empty? then
        @dir.view.selection.selected_each do |model, path, iter|
            res << Pathname.new(model.get_value(iter, 0))
        end
    end

    res.count > 0 ? res : nil
end

#signal_do_dir_changedObject



164
# File 'lib/unixcmd/panel.rb', line 164

def signal_do_dir_changed() nil end

#update_captionObject



122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/unixcmd/panel.rb', line 122

def update_caption
    path = @dir.path.expand_path.to_s
    mount_point = Sys::Filesystem.mount_point path

    stat = Sys::Filesystem.stat mount_point

    capacity = stat.blocks*stat.block_size
    free = stat.blocks_free*stat.block_size

    @caption.set_text(sprintf("%s of %s free", free.to_i.to_szstr, capacity.to_i.to_szstr))
    @caption.reload_mounts
    @caption.update_mount_point mount_point
end