diff --git a/awesomerc.lua.in b/awesomerc.lua.in
index d1d05eff7..4c4994fdd 100644
--- a/awesomerc.lua.in
+++ b/awesomerc.lua.in
@@ -120,8 +120,7 @@ mytextbox.text = " awesome " .. AWESOME_VERSION .. " "
mypromptbox = widget({ type = "textbox", name = "mypromptbox", align = "left" })
-- Create an iconbox widget
-myiconbox = widget({ type = "textbox", name = "myiconbox", align = "left" })
-myiconbox.text = ""
+myiconbox = awful.widget.button({ name = "myiconbox", image = "@AWESOME_ICON_PATH@/awesome16.png" })
-- Create a systray
mysystray = widget({ type = "systray", name = "mysystray", align = "right" })
diff --git a/lib/awful.lua.in b/lib/awful.lua.in
index d6c8b6edd..1c17cc4ba 100644
--- a/lib/awful.lua.in
+++ b/lib/awful.lua.in
@@ -1503,11 +1503,11 @@ function titlebar.add(c, args)
capi.button({ }, 1, function (t) t.client:mouse_move() end),
capi.button({ args.modkey }, 3, function (t) t.client:mouse_resize() end)
}
- title:button_press(bts)
+ title:buttons(bts)
if theme.titlebar_close_button == "true" then
local close_button = capi.widget({ type = "textbox", name = "close", align = "right" })
- close_button:button_press({ capi.button({ }, 1, function (t) t.client:kill() end) })
+ close_button:buttons({ capi.button({ }, 1, function (t) t.client:kill() end) })
tb:widgets({
capi.widget({ type = "appicon", name = "appicon", align = "left" }),
@@ -1589,6 +1589,21 @@ function beautiful.register(btheme)
end
end
+--- Create a button widget. When clicked, the image is deplaced to make it like
+-- a real button.
+-- @param args Standard widget table arguments, plus image for the image path.
+-- @return A textbox widget configured as a button.
+function widget.button(args)
+ if not args then return end
+ args.type = "textbox"
+ local w = capi.widget(args)
+ local img_release = ""
+ local img_press = ""
+ w.text = img_release
+ w:buttons({ capi.button({}, 1, function () w.text = img_press end, function () w.text = img_release end) })
+ return w
+end
+
-- Register standards hooks
hooks.arrange.register(tag.history.update)