Hi,
this is my first patch made for awesome and I wish it is well written
and formatted and etc. If not, I am happy to hear and fix my mistakes.
So what basically I did was to add function to set widget buttons for
awful.widget.proggressbar:
* New function created (set_buttons)
* Updated properties table (added "button_table" field)
* Modified update() function to work with newly created property
I tested this and it works as expected.
Cheers,
Ignas Anikevicius
>From bed00c8a8ed1b2bd56fe7e99120f09e5e2927eab Mon Sep 17 00:00:00 2001
From: Ignas Anikevicius (gns_ank) <[email protected]>
Date: Sat, 31 Jul 2010 12:42:18 +0200
Subject: [PATCH] Added a new ability to set button table to the progressbar
widget
Signed-off-by: Ignas Anikevicius (gns_ank) <[email protected]>
---
lib/awful/widget/progressbar.lua.in | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/lib/awful/widget/progressbar.lua.in
b/lib/awful/widget/progressbar.lua.in
index c4e6a94..078509e 100644
--- a/lib/awful/widget/progressbar.lua.in
+++ b/lib/awful/widget/progressbar.lua.in
@@ -76,13 +76,15 @@ local data = setmetatable({}, { __mode = "k" })
local properties = { "width", "height", "border_color",
"gradient_colors", "color", "background_color",
"vertical", "value", "max_value",
- "ticks", "ticks_gap", "ticks_size" }
+ "ticks", "ticks_gap", "ticks_size",
+ "button_table" }
local function update(pbar)
local width = data[pbar].width or 100
local height = data[pbar].height or 20
local ticks_gap = data[pbar].ticks_gap or 1
local ticks_size = data[pbar].ticks_size or 4
+ local button_table = data[pbar].button_table or false
-- Create new empty image
local img = capi.image.argb32(width, height, nil)
@@ -168,6 +170,11 @@ local function update(pbar)
-- Update the image
pbar.widget.image = img
+
+ -- Create the button bindings
+ if button_table then
+ pbar.widget:buttons(button_table)
+ end
end
--- Set the progressbar value.
@@ -199,6 +206,15 @@ function set_width(progressbar, width)
return progressbar
end
+--- Set the progressbar button table.
+-- @param progressbar The progressbar.
+-- @param width The button table to set.
+function set_buttons(progressbar, button_table)
+ data[progressbar].button_table = button_table
+ update(progressbar)
+ return progressbar
+end
+
-- Build properties function
for _, prop in ipairs(properties) do
if not _M["set_" .. prop] then
--
1.7.2