Parent

Class/Module Index [+]

Quicksearch

Demo::EntryCompletion

Public Class Methods

new() click to toggle source
# File gtk2/sample/gtk-demo/entry_completion.rb, line 15
def initialize
  super('GtkEntryCompletion',
        nil, # parent
        0,
        [Gtk::Stock::CLOSE, Gtk::Dialog::RESPONSE_NONE])

  self.resizable = false

  signal_connect('response') do
    self.destroy
  end

  vbox = Gtk::VBox.new(false, 5)
  self.vbox.pack_start(vbox, true, true)
  vbox.border_width = 5

  label = Gtk::Label.new
  label.markup = 'Completion demo, try writing <b>total</b> or <b>gnome</b> for example'
  vbox.pack_start(label, false, false)

  # Create our entry
  entry = Gtk::Entry.new
  vbox.pack_start(entry, false, false)

  # Create the completion object
  completion = Gtk::EntryCompletion.new

  # Assign the completion to the entry
  entry.completion = completion

  # Create a tree model and use it as the completion model
  completion.model = create_completion_model

  # Use model column 0 as the text column
  completion.text_column = 0
end

Public Instance Methods

create_completion_model() click to toggle source
# File gtk2/sample/gtk-demo/entry_completion.rb, line 53
def create_completion_model
  store = Gtk::ListStore.new(String)
  %(GNOME total totally).each do |word|
    iter = store.append
    iter[0] = word
  end

  store
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.