Class: Ig3tool::GladeHelper
- Inherits:
-
Object
- Object
- Ig3tool::GladeHelper
show all
- Defined in:
- lib/ui/gladehelper.rb
Constant Summary
collapse
- GLADE_DIR =
Pathname.new(__FILE__).parent.parent + "glade"
Instance Method Summary
collapse
Constructor Details
#initialize(gladefile, toplevel = "window") ⇒ GladeHelper
Returns a new instance of GladeHelper.
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/ui/gladehelper.rb', line 8
def initialize (gladefile, toplevel = "window")
filename = GLADE_DIR + gladefile
@glade = GladeXML.new(filename.to_s, toplevel) {|h| method(h) }
@window = @glade.get_widget(toplevel)
@window.title += " - Ig3tool"
@window.move(169,0) @window.signal_connect("delete-event") do
@window.hide
true
end
end
|
Instance Method Details
28
29
30
|
# File 'lib/ui/gladehelper.rb', line 28
def _get_widget(widget)
@glade.get_widget(widget)
end
|
#add_window_colorer(combo, window) ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/ui/gladehelper.rb', line 83
def add_window_colorer(combo, window)
combo.signal_connect("changed") do
saldo = 0
if combo.active_iter
debugger = combo.active_iter[1]
if debugger != "kas"
begin
saldo = $client.interne(debugger).saldo.to_i
rescue Exception => e
puts e.to_s + " - " + e.message
end
end
end
if saldo < 0
shade = [65535, 0, 0]
ratio = (saldo < -7500) ? 1 : Rational(saldo,(-75 * 100)) else
shade = [0, 65535, 0]
ratio = (saldo > 20000) ? 1 : Rational(saldo,(200 * 100))
end
ratio1 = 1 - ratio
base = Gtk::Widget.default_style.bg(Gtk::STATE_NORMAL)
window.modify_bg(Gtk::STATE_NORMAL,
Gdk::Color.new(
(base.red * ratio1 + shade[0] * ratio).to_i,
(base.green * ratio1 + shade[1] * ratio).to_i,
(base.blue * ratio1 + shade[2] * ratio).to_i))
end
end
|
#make_debugger_combo(combo, window = nil) ⇒ Object
Debugger combobox invullen
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
|
# File 'lib/ui/gladehelper.rb', line 33
def make_debugger_combo (combo, window = nil)
debuggers = $client.person_debuggers
debuggers.sort! {|a,b| a.username <=> b.username }
debugger_model = Gtk::ListStore.new(Object, String)
debuggers.each do |d|
row = debugger_model.append
row[0] = d
row[1] = d.username
end
combo.model = debugger_model
combo.clear
renderer = Gtk::CellRendererText.new
combo.pack_start(renderer, true)
combo.set_attributes(renderer, :text => 1)
add_window_colorer(combo, window) if window
username = $client.username
debugger_model.each do |m, p, i|
if i[1] == username
combo.active_iter = i
break
end
end
end
|
115
116
117
118
119
120
|
# File 'lib/ui/gladehelper.rb', line 115
def make_eval_widget(widget)
widget.signal_connect "focus-out-event" do
Ig3tool::number_eval_widget widget
false
end
end
|
#make_status_combo(combo, statussen = nil) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/ui/gladehelper.rb', line 63
def make_status_combo (combo,statussen = nil)
begin
statussen = $client.person_statussen unless statussen
statussen_model = Gtk::ListStore.new(Object, String)
statussen.each do |key, value|
row = statussen_model.append
row[0] = key
row[1] = value
end
combo.model = statussen_model
combo.active = 0
combo.clear
renderer = Gtk::CellRendererText.new
combo.pack_start(renderer, true)
combo.set_attributes(renderer, :text => 1)
rescue Exception => e
puts "Fout: Make_status_combo: #{$!}"
end
end
|
#present ⇒ Object
24
25
26
|
# File 'lib/ui/gladehelper.rb', line 24
def present
@window.present
end
|
#show ⇒ Object
20
21
22
|
# File 'lib/ui/gladehelper.rb', line 20
def show
@window.show
end
|