Julien Danjou wrote:
> At 1252427007 time_t, Uli Schlachter wrote:
>> Julien, would you mind if we made awful.wibox() error out or at least warn on
>> invalid positions? (invalid being "none of left, right, top, bottom")
>> I saw the same thing in obvious today. :(
> 
> Please, go ahead. :)

Went ahead. :)

(Alternatively we could use print() to print a warning, but... dunno)
-- 
"Do you know that books smell like nutmeg or some spice from a foreign land?"
                                                  -- Faber in Fahrenheit 451
>From fa0eb17e31836b944adf6caf11e0c20e6a1c254f Mon Sep 17 00:00:00 2001
From: Uli Schlachter <[email protected]>
Date: Wed, 9 Sep 2009 10:39:08 +0200
Subject: [PATCH] awful.wibox: Error out on invalid positions

Signed-off-by: Uli Schlachter <[email protected]>
---
 lib/awful/wibox.lua.in |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/lib/awful/wibox.lua.in b/lib/awful/wibox.lua.in
index c5ef802..1bae18b 100644
--- a/lib/awful/wibox.lua.in
+++ b/lib/awful/wibox.lua.in
@@ -17,6 +17,7 @@ local ipairs = ipairs
 local table = table
 local type = type
 local image = image
+local error = error
 
 --- Wibox module for awful.
 -- This module allows you to easily create wibox and attach them to the edge of
@@ -213,6 +214,12 @@ function new(arg)
     -- Empty position and align in arg so we are passing deprecation warning
     arg.position = nil
 
+    if position ~= "top" and position ~="bottom"
+            and position ~= "left" and position ~= "right" then
+        error("Invalid position in awful.wibox(), you may only use"
+            .. " 'top', 'bottom', 'left' and 'right'")
+    end
+
     -- Set default size
     if position == "left" or position == "right" then
         arg.width = arg.width or capi.awesome.font_height * 1.5
-- 
1.6.3.3

Reply via email to