Class: OneInputAction
- Inherits:
-
Object
- Object
- OneInputAction
- Defined in:
- lib/vimamsa/search_replace.rb
Instance Method Summary collapse
-
#initialize(main_window, title, field_label, button_title, callback, opt = {}) ⇒ OneInputAction
constructor
A new instance of OneInputAction.
- #run ⇒ Object
Constructor Details
#initialize(main_window, title, field_label, button_title, callback, opt = {}) ⇒ OneInputAction
Returns a new instance of OneInputAction.
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/vimamsa/search_replace.rb', line 216 def initialize(main_window, title, field_label, , callback, opt = {}) @window = Gtk::Window.new() # @window.screen = main_window.screen # @window.title = title @window.title = "" frame = Gtk::Frame.new() # frame.margin = 20 @window.set_child(frame) infolabel = Gtk::Label.new infolabel.markup = title vbox = Gtk::Box.new(:vertical, 8) vbox.margin = 10 frame.set_child(vbox) hbox = Gtk::Box.new(:horizontal, 8) # @window.add(hbox) vbox.pack_end(infolabel, :expand => false, :fill => false, :padding => 0) vbox.pack_end(hbox, :expand => false, :fill => false, :padding => 0) = Gtk::Button.new(:label => ) = Gtk::Button.new(:label => "Cancel") label = Gtk::Label.new(field_label) @entry1 = Gtk::Entry.new if opt[:hide] @entry1.visibility = false end .signal_connect "clicked" do callback.call(@entry1.text) @window.destroy end .signal_connect "clicked" do @window.destroy end press = Gtk::EventControllerKey.new press.set_propagation_phase(Gtk::PropagationPhase::CAPTURE) @window.add_controller(press) press.signal_connect "key-pressed" do |gesture, keyval, keycode, y| if keyval == Gdk::Keyval::KEY_Return callback.call(@entry1.text) @window.destroy true elsif keyval == Gdk::Keyval::KEY_Escape @window.destroy true else false end end hbox.pack_end(label, :expand => false, :fill => false, :padding => 0) hbox.pack_end(@entry1, :expand => false, :fill => false, :padding => 0) hbox.pack_end(, :expand => false, :fill => false, :padding => 0) hbox.pack_end(, :expand => false, :fill => false, :padding => 0) return end |
Instance Method Details
#run ⇒ Object
281 282 283 284 285 286 287 288 |
# File 'lib/vimamsa/search_replace.rb', line 281 def run if !@window.visible? @window.show else @window.destroy end @window end |