-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi list,

This change enables stuff like the following:

 awful.widget.graph({}):set_color("red"):set_width(40):add_value(0.5)

Additionally, one can use the above directly in th widgets table.

This most likely doesn't break any existing configs and it adds a quite nice
syntax which can be used for in-place configuration of new widgets.

Plus I need this to make my Great New Obvious Stuff (tm) (GNOS) work. ;)

Uli
- --
"Do you know that books smell like nutmeg or some spice from a foreign land?"
                                                  -- Faber in Fahrenheit 451
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iQEcBAEBCAAGBQJKfYLsAAoJECLkKOvLj8sGCi8H/14VwwUyJv0CwePnpef0KeaH
XMsghB8vluZj7a4A1jXQo2TYPBrzf0F+Ttr2nhPS9f4o+p5fkUwUGoTZg+3YeAv3
1Tb03HNkg7ihXeZsqH07v8EtLJqCYeNr2abm18R1/IPxWRuKUnXVFe1+N+wA2IfH
KA7hSOEauAgXVrkfblVRK5yCFAb57B6NCz3ccO/xpAQEj77JaTMBwCAgdT0VPhDe
jwLRDrLJZqRsL9r1gQS0FEPwXGs0T2Qco4dfKKrYohmQLQjEuBuT8vlhcJ5sBQV+
HjEdwENPXe7hHYodlBLZPmN18V2SNjHB8iwciDaN6yrW6B/DLcUiGQmtESEm9Sk=
=S5bK
-----END PGP SIGNATURE-----
>From dba6afb751a821d2d40643fed21b1539f2a043e9 Mon Sep 17 00:00:00 2001
From: Uli Schlachter <psyc...@znc.in>
Date: Sat, 8 Aug 2009 15:47:00 +0200
Subject: [PATCH] lib.awful.widget: Return obj in set_* methods

This change enables stuff like the following:

 awful.widget.graph({}):set_color("red"):set_width(40):add_value(0.5)

Additionally, one can use the above directly in th widgets table.

This most likely doesn't break any existing configs and it adds a quite nice
syntax which can be used for in-place configuration of new widgets.

Signed-off-by: Uli Schlachter <psyc...@znc.in>
---
 lib/awful/widget/graph.lua.in       |    4 ++++
 lib/awful/widget/progressbar.lua.in |    4 ++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/lib/awful/widget/graph.lua.in b/lib/awful/widget/graph.lua.in
index 4802a0d..7ef756b 100644
--- a/lib/awful/widget/graph.lua.in
+++ b/lib/awful/widget/graph.lua.in
@@ -164,6 +164,7 @@ local function add_value(graph, value)
     end
 
     update(graph)
+    return graph
 end
 
 
@@ -175,6 +176,7 @@ local function set_height(graph, height)
         data[graph].height = height
         update(graph)
     end
+    return graph
 end
 
 --- Set the graph width.
@@ -185,6 +187,7 @@ local function set_width(graph, width)
         data[graph].width = width
         update(graph)
     end
+    return graph
 end
 
 -- Build properties function
@@ -193,6 +196,7 @@ for _, prop in ipairs(properties) do
         _M["set_" .. prop] = function(graph, value)
             data[graph][prop] = value
             update(graph)
+            return graph
         end
     end
 end
diff --git a/lib/awful/widget/progressbar.lua.in b/lib/awful/widget/progressbar.lua.in
index 652a949..2b30a3a 100644
--- a/lib/awful/widget/progressbar.lua.in
+++ b/lib/awful/widget/progressbar.lua.in
@@ -116,6 +116,7 @@ end
 local function set_value(pbar, value)
     local value = value or 0
     data[pbar].value = math.min(1, math.max(0, value))
+    return pb
 end
 
 --- Set the progressbar height.
@@ -126,6 +127,7 @@ local function set_height(progressbar, height)
         data[progressbar].height = height
         update(progressbar)
     end
+    return progressbar
 end
 
 --- Set the progressbar width.
@@ -136,6 +138,7 @@ local function set_width(progressbar, width)
         data[progressbar].width = width
         update(progressbar)
     end
+    return progressbar
 end
 
 -- Build properties function
@@ -144,6 +147,7 @@ for _, prop in ipairs(properties) do
         _M["set_" .. prop] = function(pbar, value)
             data[pbar][prop] = value
             update(pbar)
+            return pbar
         end
     end
 end
-- 
1.6.3.3

Reply via email to