Class: MyRendererMultiline

Inherits:
Gtk::ScrolledWindow
  • Object
show all
Includes:
ManqodCommon
Defined in:
lib/FormHolder/Form/InputHolder/MultiLine.rb

Overview

this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint([email protected])

Constant Summary

Constants included from ManqodCommon

ManqodCommon::CRITICAL, ManqodCommon::DEBUG, ManqodCommon::ERROR, ManqodCommon::INFO, ManqodCommon::NORMAL, ManqodCommon::WARNING

Constants included from Eprint

Eprint::DOMAIN, Eprint::LEVEL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ManqodCommon

#add_where, #admin, #admin_cache, #admin_qrow, #admin_rows, #backtrace_to_debug, #cache, #changed_ids_of_base, #client, #client_fields, #client_image_of_id, #client_qrow, #client_query, #client_rows, #eeval, #escape_string, #getBinding, #guess_base, #guess_table, #image_of_id, #lzero, #manqod_db, #measure, #myexec, #nick, #nick_id, #number_format, #qrow, #query, #reconnect_manqod_db, #rows, #run_events, #send_message, #sendmail, #set_manqod_db_uri, #set_nick

Methods included from Eprint

#ecode, #edebug, #eerror, #einfo, #enormal, #eprint, #ewarn, #gtk_set_edebug, #set_edebug, #tell_exception

Constructor Details

#initialize(pc) ⇒ MyRendererMultiline

Returns a new instance of MyRendererMultiline.



7
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
36
# File 'lib/FormHolder/Form/InputHolder/MultiLine.rb', line 7

def initialize(pc)
	@pc=pc
	super(nil,nil)
	set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC)
	@tv=Gtk::TextView.new(@source_buffer = Gtk::TextBuffer.new)
	add(@tv)
	@tv.modify_font(Pango::FontDescription.new('Monospace 10'))
	@found_tag=@tv.buffer.create_tag('found',{'background' => 'yellow'})
	@search_window=Gtk::Window.new(Gtk::Window::POPUP).set_destroy_with_parent(true).set_modal(true).set_window_position(Gtk::Window::POS_CENTER_ON_PARENT).set_decorated(false)
	@search_window.add(Gtk::VBox.new.
		pack_start(Gtk::Label.new("filter: #{item['description']}")).
		pack_start(@entry=Gtk::Entry.new.set_can_focus(true).set_can_default(true))
	)

	@entry.signal_connect("key-release-event"){|me,ev|
		@tv.buffer.remove_tag(@found_tag,@tv.buffer.start_iter,@tv.buffer.end_iter)
		if ev.keyval == Gdk::Keyval::GDK_KEY_Escape
			@search_window.hide
			else
			start_iter=@tv.buffer.start_iter
			while bounds=start_iter.forward_search(me.text,Gtk::TextIter::SEARCH_TEXT_ONLY,nil)
				@tv.buffer.apply_tag(@found_tag,bounds[0],bounds[1])
				start_iter=bounds[1]
			end
		end
	}
	@entry.signal_connect("activate"){|me|
		@search_window.hide
	}
end

Instance Attribute Details

#pcObject

Returns the value of attribute pc.



38
39
40
# File 'lib/FormHolder/Form/InputHolder/MultiLine.rb', line 38

def pc
  @pc
end

#tvObject

Returns the value of attribute tv.



37
38
39
# File 'lib/FormHolder/Form/InputHolder/MultiLine.rb', line 37

def tv
  @tv
end

Instance Method Details

#editableObject



43
44
45
# File 'lib/FormHolder/Form/InputHolder/MultiLine.rb', line 43

def editable
	@tv.editable
end

#inspectObject



81
82
83
# File 'lib/FormHolder/Form/InputHolder/MultiLine.rb', line 81

def inspect
	"Multiline(#{item['description']})"
end

#itemObject



40
41
42
# File 'lib/FormHolder/Form/InputHolder/MultiLine.rb', line 40

def item
	@pc.item
end

#modify_font(f) ⇒ Object



47
48
49
# File 'lib/FormHolder/Form/InputHolder/MultiLine.rb', line 47

def modify_font(f)
	@tv.modify_font(f)
end

#parentMObject



78
79
80
# File 'lib/FormHolder/Form/InputHolder/MultiLine.rb', line 78

def parentM
	@pc.parentM
end

#parentselectedObject



74
75
76
# File 'lib/FormHolder/Form/InputHolder/MultiLine.rb', line 74

def parentselected
	@pc.parentselected
end

#run_search(form_holder) ⇒ Object



70
71
72
# File 'lib/FormHolder/Form/InputHolder/MultiLine.rb', line 70

def run_search(form_holder)
	@search_window.set_transient_for(form_holder.get_ancestor(Gtk::Window)).show_all
end

#set_sensitive(sens) ⇒ Object



55
56
57
# File 'lib/FormHolder/Form/InputHolder/MultiLine.rb', line 55

def set_sensitive(sens)
	@tv.set_sensitive(sens)
end

#textObject



51
52
53
# File 'lib/FormHolder/Form/InputHolder/MultiLine.rb', line 51

def text
	@tv.buffer.text
end

#to_sObject



84
85
86
# File 'lib/FormHolder/Form/InputHolder/MultiLine.rb', line 84

def to_s
	inspect
end

#update(new_value) ⇒ Object



59
60
61
62
63
64
65
66
67
68
# File 'lib/FormHolder/Form/InputHolder/MultiLine.rb', line 59

def update(new_value)
	run_events(item['id'],'form_item-BeforeUpdate')
	pc.run_query

	@source_buffer.delete(*@source_buffer.bounds)
	@source_buffer.insert(@source_buffer.get_iter_at_offset(0),"#{item['default']}")
	@tv.set_buffer(@source_buffer)
	edebug("#{self} updated to #{item['default']}","form","info")
	run_events(item['id'],'form_item-AfterUpdate')
end