Class: VimMate::FilesMenu
- Inherits:
-
Object
- Object
- VimMate::FilesMenu
- Defined in:
- lib/vimmatelib/files_menu.rb
Overview
The pop-up menu used in the file tree
Instance Method Summary collapse
-
#add_open_signal(&block) ⇒ Object
Add a block that will be called when the user choose to open a file The block take two argument: the path to the file to open, and a symbol to indicate the kind: :open, :split_open, :tab_open.
-
#add_refresh_signal(&block) ⇒ Object
Add a block that will be called when the user choose to refresh the file tree.
-
#initialize(parent_window) ⇒ FilesMenu
constructor
Create a FilesMenu.
-
#open(path) ⇒ Object
Open the menu.
Constructor Details
#initialize(parent_window) ⇒ FilesMenu
Create a FilesMenu
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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/vimmatelib/files_menu.rb', line 36 def initialize(parent_window) @parent_window = parent_window @open_signals = Set.new @refresh_signals = Set.new # The last path is the path of the file that was used when # the menu was opened @last_path = nil # Build the menu items @gtk_menu = Gtk::Menu.new @gtk_menu.append(open = Gtk::ImageMenuItem.new(Gtk::Stock::OPEN)) open.signal_connect("activate") do end @gtk_menu.append(split_open = Gtk::MenuItem.new("_Split Open")) split_open.signal_connect("activate") do end @gtk_menu.append(tab_open = Gtk::MenuItem.new("_Tab Open")) tab_open.signal_connect("activate") do end @gtk_menu.append(Gtk::SeparatorMenuItem.new) @gtk_menu.append(new = Gtk::ImageMenuItem.new(Gtk::Stock::NEW)) new.signal_connect("activate") do end @gtk_menu.append(new_folder = Gtk::MenuItem.new("New _Folder")) new_folder.signal_connect("activate") do end @gtk_menu.append(Gtk::SeparatorMenuItem.new) @gtk_menu.append(rename = Gtk::MenuItem.new("R_ename")) rename.signal_connect("activate") do end @gtk_menu.append(delete = Gtk::ImageMenuItem.new(Gtk::Stock::DELETE)) delete.signal_connect("activate") do end @gtk_menu.append(Gtk::SeparatorMenuItem.new) Requirer.require_if('vimmatelib/subversion') do = Gtk::Menu.new .append(svn_add = Gtk::ImageMenuItem.new(Gtk::Stock::ADD)) svn_add.signal_connect("activate") do end .append(svn_rename = Gtk::MenuItem.new("R_ename")) svn_rename.signal_connect("activate") do end .append(svn_delete = Gtk::ImageMenuItem.new(Gtk::Stock::DELETE)) svn_delete.signal_connect("activate") do end .append(svn_revert = Gtk::ImageMenuItem.new(Gtk::Stock::REVERT_TO_SAVED)) svn_revert.signal_connect("activate") do end @gtk_menu.append(subversion = Gtk::MenuItem.new("S_ubversion")) subversion. = end @gtk_menu.append(refresh = Gtk::ImageMenuItem.new(Gtk::Stock::REFRESH)) refresh.signal_connect("activate") do end @gtk_menu.show_all end |
Instance Method Details
#add_open_signal(&block) ⇒ Object
Add a block that will be called when the user choose to open a file The block take two argument: the path to the file to open, and a symbol to indicate the kind: :open, :split_open, :tab_open
133 134 135 |
# File 'lib/vimmatelib/files_menu.rb', line 133 def add_open_signal(&block) @open_signals << block end |
#add_refresh_signal(&block) ⇒ Object
Add a block that will be called when the user choose to refresh the file tree. The block doesn’t take an argument.
139 140 141 |
# File 'lib/vimmatelib/files_menu.rb', line 139 def add_refresh_signal(&block) @refresh_signals << block end |
#open(path) ⇒ Object
Open the menu. Specify a path to show where the menu was opened.
125 126 127 128 |
# File 'lib/vimmatelib/files_menu.rb', line 125 def open(path) @last_path = path @gtk_menu.popup(nil, nil, 0, 0) end |