Class: MyRendererModel::Filterer

Inherits:
Gtk::Window
  • Object
show all
Defined in:
lib/FormHolder/Form/InputHolder/Common/Model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ Filterer

Returns a new instance of Filterer.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/FormHolder/Form/InputHolder/Common/Model.rb', line 8

def initialize(model)
	@model=model
	super(Gtk::Window::POPUP)
	add(Gtk::VBox.new)
	child.pack_start(Gtk::Label.new("filter: #{model.pc.item['description']}"))
	child.pack_start(@entry=Gtk::Entry.new.set_can_focus(true).set_can_default(true))
	set_destroy_with_parent(true)
	set_modal(true)
	set_decorated(false)
	set_window_position(Gtk::Window::POS_CENTER_ON_PARENT)
	entry.signal_connect('activate'){|me|
		@old_text=@entry.text
		hide
	}
	entry.signal_connect("key-release-event",self){|me,ev,filterer|
		if ev.keyval == Gdk::Keyval::GDK_KEY_Escape
			#set the old filter back
			model.typed=@old_text
			@entry.set_text(@old_text)
			model.refilter
			filterer.hide
			else
			#filter
			model.typed=me.text
			model.refilter
		end
	}
end

Instance Attribute Details

#entryObject

Returns the value of attribute entry.



36
37
38
# File 'lib/FormHolder/Form/InputHolder/Common/Model.rb', line 36

def entry
  @entry
end

#modelObject

Returns the value of attribute model.



36
37
38
# File 'lib/FormHolder/Form/InputHolder/Common/Model.rb', line 36

def model
  @model
end

Instance Method Details

#run(parent_window) ⇒ Object



38
39
40
41
42
# File 'lib/FormHolder/Form/InputHolder/Common/Model.rb', line 38

def run(parent_window)
	@old_text=@entry.text
	set_transient_for(parent_window.get_ancestor(Gtk::Window))
	show_all
end