Method: Gtk::TextView#__populate_popup
- Defined in:
- lib/gtk_app/ext/text_view.rb
#__populate_popup(menu) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
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 |
# File 'lib/gtk_app/ext/text_view.rb', line 28 def __populate_popup() iter = buffer.get_iter_at_mark(buffer.text_marks[:click]) s_iter, e_iter = iter.clone, iter.clone s_iter.backward_word_start unless s_iter.starts_word? e_iter.forward_word_end if e_iter.inside_word? word = buffer.get_text(s_iter, e_iter) = Gtk::MenuItem.new("Spelling Suggestions") = Gtk::Menu.new buffer.spell_check.send(:suggestions, word).each_with_index do |wurd, ndx| = Gtk::MenuItem.new(wurd) .signal_connect('activate') do |mi| buffer.begin_user_action buffer.delete(s_iter, e_iter) buffer.insert(s_iter, mi.label) buffer.end_user_action end .append() end . = .prepend() .show_all end |