class Smartdict::Gui::WordList
Public Class Methods
new(controller)
click to toggle source
Calls superclass method
# File lib/smartdict/gui/word_list.rb, line 24 def initialize(controller) @controller = controller @list_model = Gtk::ListStore.new(String, String, String) super(@list_model) self.append_column(ListColumn.new("History")) self.selection.signal_connect("changed"){ item = self.selection.selected word, from_lang, to_lang = item[0], item[1], item[2] @controller.translate_selected_word(word, from_lang, to_lang) } end
Public Instance Methods
first_item_matches?(word, from_lang, to_lang)
click to toggle source
# File lib/smartdict/gui/word_list.rb, line 47 def first_item_matches?(word, from_lang, to_lang) iter = @list_model.iter_first return false unless iter word == @list_model.get_value(iter, 0) && from_lang == @list_model.get_value(iter, 1) && to_lang == @list_model.get_value(iter, 2) end
prepend_word(translation)
click to toggle source
# File lib/smartdict/gui/word_list.rb, line 39 def prepend_word(translation) item = @list_model.prepend item[0] = translation.word item[1] = translation.from_lang item[2] = translation.to_lang selection.select_iter(item) end
scroll_up()
click to toggle source
# File lib/smartdict/gui/word_list.rb, line 55 def scroll_up # TODO: It's a dirty hack! # We need just resize WordList and set vadjustment.value = 0. # But WordList is resized after, so I do this hack to make sure # that it's already resized. Thread.new do # Expected to parent be Gtk::ScrolledWindow vad = self.parent.vadjustment vad.value = vad.lower vad.value_changed end end