Class: FormatJustificationWidget

Inherits:
Gtk::HBox
  • Object
show all
Defined in:
lib/ManqodHelp/FormatEditor/FormatJustificationWidget.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])

Instance Method Summary collapse

Constructor Details

#initialize(fe) ⇒ FormatJustificationWidget

Returns a new instance of FormatJustificationWidget.



6
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ManqodHelp/FormatEditor/FormatJustificationWidget.rb', line 6

def initialize(fe)
	@fe=fe
	super()
	pack_start(@fill=Gtk::ToggleButton.new(Gtk::Stock::JUSTIFY_FILL))
	pack_start(@left=Gtk::ToggleButton.new(Gtk::Stock::JUSTIFY_LEFT))
	pack_start(@center=Gtk::ToggleButton.new(Gtk::Stock::JUSTIFY_CENTER))
	pack_start(@right=Gtk::ToggleButton.new(Gtk::Stock::JUSTIFY_RIGHT))
	
	@fill.signal_connect('toggled'){|me|
		if me.active?
			@left.set_active(false)
			@center.set_active(false)
			@right.set_active(false)
			if tag=@fe.current_tag
				tag.set_justification(Gtk::Justification::FILL).set_justification_set(true)
				@fe.help.browser.save_current_item
			end
		end
	}
	@left.signal_connect('toggled'){|me|
		if me.active?
			@fill.set_active(false)
			@center.set_active(false)
			@right.set_active(false)
			if tag=@fe.current_tag
				tag.set_justification(Gtk::Justification::LEFT).set_justification_set(true)
				@fe.help.browser.save_current_item
			end
		end
	}
	@center.signal_connect('toggled'){|me|
		if me.active?
			@left.set_active(false)
			@fill.set_active(false)
			@right.set_active(false)
			if tag=@fe.current_tag
				tag.set_justification(Gtk::Justification::CENTER).set_justification_set(true)
				@fe.help.browser.save_current_item
			end
		end
	}
	@right.signal_connect('toggled'){|me|
		if me.active?
			@left.set_active(false)
			@center.set_active(false)
			@fill.set_active(false)
			if tag=@fe.current_tag
				tag.set_justification(Gtk::Justification::RIGHT).set_justification_set(true)
				@fe.help.browser.save_current_item
			end
		end
	}
	add_events(Gdk::Event::Mask::ALL_EVENTS_MASK)
end

Instance Method Details

#set_value(val) ⇒ Object



60
61
62
63
64
65
66
67
# File 'lib/ManqodHelp/FormatEditor/FormatJustificationWidget.rb', line 60

def set_value(val)
	case val
		when Gtk::Justification::FILL then @fill.set_active(true)
		when Gtk::Justification::LEFT then @left.set_active(true)
		when Gtk::Justification::CENTER then @center.set_active(true)
		when Gtk::Justification::RIGHT then @right.set_active(true)
	end
end

#valueObject



68
69
70
71
72
73
74
# File 'lib/ManqodHelp/FormatEditor/FormatJustificationWidget.rb', line 68

def value
	val=nil
	val=Gtk::Justification::FILL if @fill.active?
	val=Gtk::Justification::LEFT if @left.active?
	val=Gtk::Justification::CENTER if @center.active?
	val=Gtk::Justification::RIGHT if @right.active?
end