ADG Lua 

ADG Lua Commit Details

Date:2013-03-20 00:20:56 (6 years 8 months ago)
Author:Nicola Fontana
Branch:master
Commit:2de1a6fd8257afbc388d8afba021b5751469cf5b
Parents: 4d124e5650e50861399f1df57e5bb0af15768d8c
Message:adg-demo: handling bool and string also for setter

Changes:
Madg-demo.lua.in (3 diffs)

File differences

adg-demo.lua.in
113113
114114
115115
116
116
117117
118118
119
119
120120
121121
122
122
123123
124124
125125
......
137137
138138
139139
140
141
140
141
142142
143143
144144
145
145
146146
147147
148148
......
186186
187187
188188
189
190
189
190
191
191192
192193
193194
local function entry_info(widget)
if Gtk.ToggleButton:is_type_of(widget) then
-- Boolean value
return 'get_active', 'on_toggled'
return 'get_active', 'set_active', 'on_toggled'
elseif Gtk.Entry:is_type_of(widget) then
-- String value
return 'get_text', 'on_changed'
return 'get_text', 'set_text', 'on_changed'
elseif Gtk.SpinButton:is_type_of(widget) then
-- Number value
return 'get_value', 'on_changed'
return 'get_value', 'set_value', 'on_changed'
else
-- Unhandled type
return
end
-- Unlock the UI on every widget change
local get_value, on_change = entry_info(widget)
widget[on_change] = function ()
local getter, _, notification = entry_info(widget)
widget[notification] = function ()
ui.btnApply:set_sensitive(true)
ui.btnReset:set_sensitive(true)
end
piston[name] = widget[get_value](widget)
piston[name] = widget[getter](widget)
end
end
-- Update the widgets using the piston data
for _, name in pairs(widgets) do
local widget = ui['edit' .. name]
if widget then
widget:set_value(piston[name])
local _, setter = entry_info(widget)
if setter then
widget[setter](widget, piston[name])
end
end

Archive Download the corresponding diff file

Branches

Tags