Class: KeepYourHead::DialogEditText

Inherits:
Object
  • Object
show all
Defined in:
lib/Keepyourhead/gui/DialogEditText.rb

Constant Summary collapse

Widgets =
["viewport_edit", "labelName" ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ DialogEditText

Returns a new instance of DialogEditText.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/Keepyourhead/gui/DialogEditText.rb', line 25

def initialize( name )
	@glade = GladeXML.new(Resources::system("glade/DialogEditText.glade")) { |handler| method(handler) }

	@window = @glade.get_widget("dialog_edit_text")

	Widgets.each { |name|
		widget = @glade.get_widget(name)
		assert widget
		eval("@#{name} = widget")
	}
	
	self.name = name

	@window.title = "editieren"
	
	language = Gtk::SourceLanguagesManager.new.get_language("text/x-tex")
	
	@edit_buffer = Gtk::SourceBuffer.new language
	@edit_buffer.set_property( "check-brackets", true )
	@edit_buffer.set_property( "highlight", true )
#		@edit_buffer.set_property( "max-undo-levels", 20 )
	@textview_latex = Gtk::SourceView.new @edit_buffer
	@textview_latex.set_property( "auto-indent", true)
	@textview_latex.set_property( "insert-spaces-instead-of-tabs", false)
#		@textview_latex.set_property( "margin", 10)
	@textview_latex.set_property( "show-line-markers", true)
	@textview_latex.set_property( "show-line-numbers", true)
	@textview_latex.set_property( "show-margin", true)
	@textview_latex.set_property( "smart-home-end", true)
	@textview_latex.set_property( "tabs-width", 4)

	@viewport_edit.add @textview_latex
	@textview_latex.show

	@window.add_button Gtk::Stock::APPLY, Gtk::Dialog::RESPONSE_APPLY
	@window.add_button Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL
end

Instance Attribute Details

#changeProcObject

Returns the value of attribute changeProc.



21
22
23
# File 'lib/Keepyourhead/gui/DialogEditText.rb', line 21

def changeProc
  @changeProc
end

Instance Method Details

#destroyObject



98
99
100
# File 'lib/Keepyourhead/gui/DialogEditText.rb', line 98

def destroy
	@window.destroy
end

#nameObject



63
64
65
# File 'lib/Keepyourhead/gui/DialogEditText.rb', line 63

def name
	@labelName.text
end

#name=(o) ⇒ Object



66
67
68
# File 'lib/Keepyourhead/gui/DialogEditText.rb', line 66

def name=(o)
	@labelName.text=o
end

#runObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/Keepyourhead/gui/DialogEditText.rb', line 79

def run
	@window.show

	ret = nil

	while ret == nil do
		response = @window.run

		case response
		when Gtk::Dialog::RESPONSE_APPLY
			ret = true
		when Gtk::Dialog::RESPONSE_CANCEL
			ret = false
		end
	end

	ret
end

#textObject



70
71
72
# File 'lib/Keepyourhead/gui/DialogEditText.rb', line 70

def text
	@edit_buffer.text
end

#text=(t) ⇒ Object



74
75
76
# File 'lib/Keepyourhead/gui/DialogEditText.rb', line 74

def text=(t)
	@edit_buffer.text = t
end