Class: CmdPanelCaptionWidget
- Defined in:
- lib/unixcmd/panel.rb
Instance Method Summary collapse
-
#initialize ⇒ CmdPanelCaptionWidget
constructor
A new instance of CmdPanelCaptionWidget.
- #reload_mounts ⇒ Object
- #set_text(text) ⇒ Object
- #signal_do_go_back ⇒ Object
- #signal_do_go_home ⇒ Object
- #signal_do_go_mountpoint(point) ⇒ Object
- #signal_do_go_root ⇒ Object
- #update_mount_point(point) ⇒ Object
Constructor Details
#initialize ⇒ CmdPanelCaptionWidget
Returns a new instance of CmdPanelCaptionWidget.
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 |
# File 'lib/unixcmd/panel.rb', line 21 def initialize super @text = Gtk::Label.new 'Caption' @mounts = Gtk::ComboBox.new btn_root = Gtk::Button.new '/' btn_home = Gtk::Button.new '~' btn_back = Gtk::Button.new '..' btn_root.relief = Gtk::RELIEF_NONE btn_home.relief = Gtk::RELIEF_NONE btn_back.relief = Gtk::RELIEF_NONE btn_root.signal_connect('clicked') { signal_emit 'go-root' } btn_home.signal_connect('clicked') { signal_emit 'go-home' } btn_back.signal_connect('clicked') { signal_emit 'go-back' } @mounts_handler = @mounts.signal_connect('changed') { signal_emit 'go-mountpoint', @mounts.active_text } @mounts.focus_on_click = false self.focus_chain = [] reload_mounts pack_start @mounts, false pack_start @text, true pack_start Gtk::VSeparator.new, false pack_start btn_root, false pack_start Gtk::VSeparator.new, false pack_start btn_home, false pack_start Gtk::VSeparator.new, false pack_start btn_back, false end |
Instance Method Details
#reload_mounts ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/unixcmd/panel.rb', line 57 def reload_mounts cur_mounts = Array.new new_mounts = Array.new Sys::Filesystem.mounts do |mount| # TODO: make correct mounts filter next if mount.mount_type != 'vfat' && mount.mount_type != 'ntfs' && mount.mount_type != 'ext3' && mount.mount_type != 'ext2' && mount.mount_type != 'ext4' new_mounts << Pathname.new(mount.mount_point).to_s end @mounts.model.each do |model, path, iter| cur_mounts << model.get_value(iter, 0) end if new_mounts != cur_mounts @mounts.signal_handler_block @mounts_handler @mounts.model.clear @mounts.active = -1 new_mounts.each { |point| @mounts.append_text point } @mounts.signal_handler_unblock @mounts_handler end end |
#set_text(text) ⇒ Object
92 93 94 |
# File 'lib/unixcmd/panel.rb', line 92 def set_text(text) @text.text = text end |
#signal_do_go_back ⇒ Object
18 |
# File 'lib/unixcmd/panel.rb', line 18 def signal_do_go_back() nil end |
#signal_do_go_home ⇒ Object
17 |
# File 'lib/unixcmd/panel.rb', line 17 def signal_do_go_home() nil end |
#signal_do_go_mountpoint(point) ⇒ Object
19 |
# File 'lib/unixcmd/panel.rb', line 19 def signal_do_go_mountpoint(point) nil end |
#signal_do_go_root ⇒ Object
16 |
# File 'lib/unixcmd/panel.rb', line 16 def signal_do_go_root() nil end |
#update_mount_point(point) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/unixcmd/panel.rb', line 80 def update_mount_point(point) new_active = nil @mounts.model.each do |model, path, iter| new_active = model.get_iter(path) if point == model.get_iter(path).get_value(0) end @mounts.signal_handler_block @mounts_handler @mounts.active_iter = new_active if @mounts.active_iter != new_active @mounts.signal_handler_unblock @mounts_handler end |