Class: MySourceView

Inherits:
Gtk::ScrolledWindow
  • Object
show all
Includes:
ManqodCommon
Defined in:
lib/FormHolder/Form/InputHolder/SourceView.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) ⇒ MySourceView

Returns a new instance of MySourceView.



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
37
38
39
40
41
42
43
44
45
# File 'lib/FormHolder/Form/InputHolder/SourceView.rb', line 7

def initialize(pc)
	@pc=pc
	super(nil,nil)
	set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC)
	@tv=Gtk::SourceView.new()
	
	add(@tv)
	@tv.buffer.set_highlight_matching_brackets(true)
	@tv.set_auto_indent(true).
		set_highlight_current_line(true).
		set_indent_on_tab(true).
		set_indent_on_tab(true).
		set_indent_width(4)
	@tv.editable=item['editable']=="true"
	@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.



48
49
50
# File 'lib/FormHolder/Form/InputHolder/SourceView.rb', line 48

def pc
  @pc
end

#tvObject

Returns the value of attribute tv.



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

def tv
  @tv
end

Instance Method Details

#editableObject



53
54
55
# File 'lib/FormHolder/Form/InputHolder/SourceView.rb', line 53

def editable
	pc.editable
end

#inspectObject



91
92
93
# File 'lib/FormHolder/Form/InputHolder/SourceView.rb', line 91

def inspect
	"SourceView #{item['description']}(#{pc.gtk_attribute("language")})"
end

#itemObject



50
51
52
# File 'lib/FormHolder/Form/InputHolder/SourceView.rb', line 50

def item
	@pc.item
end

#parentMObject



87
88
89
# File 'lib/FormHolder/Form/InputHolder/SourceView.rb', line 87

def parentM
	@pc.parentM
end

#parentselectedObject



83
84
85
# File 'lib/FormHolder/Form/InputHolder/SourceView.rb', line 83

def parentselected
@pc.parentselected
end

#run_search(form_holder) ⇒ Object



79
80
81
# File 'lib/FormHolder/Form/InputHolder/SourceView.rb', line 79

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

#test_contentObject



75
76
77
# File 'lib/FormHolder/Form/InputHolder/SourceView.rb', line 75

def test_content
	client_query(eeval("\"#{text}\""))
end

#textObject



57
58
59
# File 'lib/FormHolder/Form/InputHolder/SourceView.rb', line 57

def text
	@tv.buffer.text
end

#to_sObject



95
96
97
# File 'lib/FormHolder/Form/InputHolder/SourceView.rb', line 95

def to_s
	inspect
end

#update(new_value = item['default']) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/FormHolder/Form/InputHolder/SourceView.rb', line 61

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

@tv.buffer.delete(*@tv.buffer.bounds)
@tv.buffer.set_language(Gtk::SourceLanguageManager.new.get_language(pc.gtk_attribute("language") || "sql"))
@tv.buffer.non_undoable_action {
	@tv.buffer.insert(@tv.buffer.get_iter_at_offset(0),item['default']) if item['default']
}
#		@tv.set_sensitive(item['editable']=="true")
run_events(item['id'],'form_item-AfterUpdate')
end