Skip to content

Commit b8dd569

Browse files
author
Anton Lobov
committed
Added backwards compatibility fixes
1 parent dbbf7d6 commit b8dd569

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

bashets.lua

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
-- @author Anton Lobov <[email protected]>
55
-- @copyright 2010 Anton Lobov
66
-- @license GPLv3
7-
-- @release 0.6 for Awesome-git
8-
-----------------------------------------------------------------------
7+
-- @release 0.6.1 (meant to be backwards compatible with older versions)
8+
------------------------------------------------------------------------
99

1010
-- Grab only needed enviroment
1111
local awful = require("awful")
1212
local string = string
1313
local io = io
1414
local table = table
1515
local pairs = pairs
16-
--local timer = timer
16+
local timer = timer
1717
local type = type
18-
--local image = image
18+
local image = image
1919
local capi = {oocairo = oocairo, timer = timer, dbus = dbus}
2020
local tonumber = tonumber
2121
local print = print
@@ -181,29 +181,39 @@ function util.create_timers_table()
181181
-- Parse table with timer data
182182
for _,tmr in pairs(timerdata) do
183183
-- Create timer for the period
184-
local t = capi.timer {timeout = tmr[1]}
184+
local t
185+
if capi.timer ~= nil then
186+
t = capi.timer {timeout = tmr[1]}
187+
else
188+
t = timer {timeout = tmr[1]}
189+
end
185190
-- Function to call all dispatched functions
186191
local f = function()
187192
for _, func in pairs(tmr[2]) do
188193
func()
189194
end
190195
end
191-
t:connect_signal("timeout", f)
196+
197+
if t.add_signal ~= nil then
198+
t:add_signal("timeout", f)
199+
else
200+
t:connect_signal("timeout", f)
201+
end
192202
table.insert(timers, t)
193203
end
194204
end
195205

196206
function util.update_widget_field(widget, valuess)
197207
-- print(widget.type)
198-
--if widget.type == "imagebox" then --imagebox
199-
if widget.set_image ~= nil then --imagebox
200-
--widget["image"] = image(valuess) moved to oocairo
208+
if widget.type == "imagebox" then --imagebox (old API)
209+
widget["image"] = image(valuess)
210+
elseif widget.set_image ~= nil then --imagebox (new API)
201211
--widget["image"] = capi.oocairo.image_surface_create_from_png(valuess)
202212
--widget:set_image(capi.oocairo.image_surface_create_from_png(valuess))
203213
widget:set_image(valuess)
204-
--elseif widget.type == "textbox" then --textbox
205-
elseif widget.set_markup ~= nil then --textbox
206-
--widget["text"] = valuess
214+
elseif widget.type == "textbox" then --textbox (old API)
215+
widget["text"] = valuess
216+
elseif widget.set_markup ~= nil then --textbox (new API)
207217
widget:set_markup(valuess)
208218
--elseif widget["widget"] ~= nil then
209219
elseif widget.set_value ~= nil then --progressbar

0 commit comments

Comments
 (0)