On Sun, Sep 13, 2009 at 2:46 PM, Julien Danjou <jul...@danjou.info> wrote:
> At 1252789547 time_t, Cedric GESTES wrote:
>> Geometry can be set using percent.
>> Placement can be called
>
> Well 2 things, 2 patches would have been better. :)
>
>> +--- Apply a gemetry property on a client
>> +-- @param c The client
>> +-- @param property The property name
>> +-- @param value The value to set
>> +-- @return true is the property match
>> +function properties.setgeometry(c, property, value)
>
> set_geometry() please.
> (might not be yet documented in STYLES)
>
>> +    if  property == "height" or
>> +        property == "width"  or
>> +        property == "x"      or
>> +        property == "y" then
>> +
>> +        local geo = c:geometry();
>> +        repeat
>> +            if type(value) == "string" then
>> +                v,percent = value:match("(%d*)(%%*)")
>> +                if v and percent == "%" then
>> +                    local screen_geometry = capi.screen[c.screen].workarea
>> +                    screen_geometry.x = screen_geometry.width
>> +                    screen_geometry.y = screen_geometry.height
>> +                    geo[property] = screen_geometry[property] * v / 100
>> +                    break
>> +                elseif v then
>> +                    geo[property] = v
>> +                    break
>> +                end
>> +            else
>> +                geo[property] = value
>> +            end
>> +        until true
>> +        c:geometry(geo);
>> +    end
>> +    return false
>> +end
>
> At first sight, this seems totally not related to rules. This can be
> useful for anything, even for wiboxes. This should go somewhere else. :)
Would a awful.util.get_abs_or_percent(value, min, max) be nice?

>
>> +--- Apply a placement property on a client
>> +-- @param c The client
>> +-- @param property The property name
>> +-- @param value The value to set
>> +-- @return true is the property match
>> +function properties.setplacement(c, property, value)
>> +    if property == "placement" then
>> +        if type(aplacement[value]) == "function" then
>> +            aplacement[value](c)
>> +        end
>> +    end
>> +    return false
>> +end
>
> Seems totally overkill. But I get why you wrote that. :)
>
>> +--- Apply a set of properties on a client
>> +-- @param c The client
>> +-- @param props a dictionary of properties
>> +function properties.set(c, props)
>> +    if props == nil then
>> +        return
>> +    end
>> +    for property, value in pairs(props) do
>> +        repeat
>> +            if property == "floating" then
>> +                aclient.floating.set(c, value)
>> +            elseif property == "tag" then
>> +                aclient.movetotag(value, c)
>> +            elseif property == "switchtotag" then
>> +                if props.tag then atag.viewonly(props.tag) end
>> +            elseif properties.setgeometry(c, property, value) then
>> +                break --this is continue
>> +            elseif properties.setplacement(c, property, value) then
>> +                break --this is continue
>
> Really, this module is going to explode its size if we continue to add
> so much option. I think we should just add a simple callback system, so
> that if the user wants to do more stuff than setting things it can write
> a little function doing placement or whatever.
>
I will split and cleanup my patch and add a callback system.

>> +            elseif type(c[property]) == "function" then
>> +                c[property](c, value)
>> +            elseif property ~= "switchtotag" and property ~= "focus" then
>> +                c[property] = value
>> +            end
>> +        until true
>> +    end
>> +
>> +    -- Do this at last so we do not erase things done by the focus
>> +    -- signal.
>> +    if props.focus then
>> +        client.focus = c
>> +    end
>> +end
>
> Splitting your patch when you go over so much changes would be nice btw. :-)
>
> Cheers,
> --
> Julien Danjou
> // ᐰ <jul...@danjou.info>   http://julien.danjou.info
> // 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
> // When I get sad, I stop being sad and be awesome instead. True story.
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iEYEARECAAYFAkqs6ZcACgkQpGK1HsL+5c3d6gCeNb/UyllULOqLQ5Gemj1n2qFV
> s0kAnAxGQZcxW641gYgQRc/4Uzo89HNO
> =qIge
> -----END PGP SIGNATURE-----
>
>

--
To unsubscribe, send mail to awesome-devel-unsubscr...@naquadah.org.

Reply via email to