Re: Writing a layout - where does the p parameter come from?

2009-06-03 Thread Julien Danjou
At 1243975693 time_t, Nathan Huesken wrote:
 - What is the difference between workarea and geometry?

Geometry is the screen geometry, i.e., the number of pixels available
from left to right.
Workarea is the same thing, but minus the wibox and the client that have
struts (i.e. panel like gnome-panel or gkrellm in dock mode). That's the
space you should use to put your windows, unless you want to put your
windows above the panels and wiboxes, which I don't think you want in a
layout IMHO. :-)

 - OK, I can set simple properties of a tag and a client using

Gregor answered to that. ;)

-- 
Julien Danjou
// ᐰ jul...@danjou.info   http://julien.danjou.info
// 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
// I'm no superman.


signature.asc
Description: Digital signature


Re: Writing a layout - where does the p parameter come from?

2009-06-03 Thread Nathan Huesken
Hi,

Unfortantly I have little success with this.
So I have this function in tag.lua:

--- Return the division tree of the tag
function getdivisiontree(t)
   local t = t or selected()
   local tree
   tree = getproperty(t, division_tree) or {}
   if #tree==0 then
  tree={}
  tree.division=none
  tree.ratio=0.5
  setproperty(t, division_tree, tree)
   end
   return tree
end

See Idea is, that when no decision tree exists yet, one is created.
But I get an error:
tag.lua:304: table index is nil


On Tue, Jun 02, 2009 at 11:01:23PM +0200, Gregor Best wrote:
 On Tue, Jun 02, 2009 at 10:48:13PM +0200, Nathan Huesken wrote:
  [...]
  - OK, I can set simple properties of a tag and a client using
  setproperty. But I need something more complex. I need to store a tree
  structure telling me how the area has been divided.
  So I need a root-node object, stored in the tag. And this root node
  has 2 of the same kind (until a leave node is reached).
  Can this also be archived with setproperty? I do not see how but I am
  completly new to lua!
  
  [...]
 
 You can easily store tables inside the tag properties. With some
 handling functions, tables can be modelled like trees (bintree, octree,
 k-tree, whatever you want), which should be what you want. You'd do
 something like this:
 
 local tree   = { }
 tree.left= { }
 tree.right   = { }
 tree.content = foobar
 tree.left.left= { }
 tree.left.right   = { }
 tree.left.content = gna
 awful.tag.setproperty(t, divisions, tree)
 
 -- 
 GCS/IT/M d- s+:- a--- C++ UL+++ US UB++ P+++ L+++ E--- W+ N+ o--
 K- w--- O M-- V PS+ PE- Y+ PGP+++ t+ 5 X+ R tv+ b++ DI+++ D+++ G+
 e- h! r y+
 
 Gregor Best




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


Re: Writing a layout - where does the p parameter come from?

2009-06-03 Thread Nathan Huesken
from tag.lua

function setproperty(tag, prop, value)
 if not data.tags[tag] then
data.tags[tag] = {}   -- this is line 304
 end
 data.tags[tag][prop] = value
end

The getdivisiontree is called from on_arrange.
Could it be, that it is called at a time there are not tags jet, so that
the t parameter is nil and selected also returns nil?

Does that make sense?
Thanks!
Nathan
 

On Wed, Jun 03, 2009 at 01:50:10PM +0200, Julien Danjou wrote:
 At 1244029212 time_t, Nathan Huesken wrote:
  tag.lua:304: table index is nil
 
 What's line 304 ?
 
 -- 
 Julien Danjou
 // ᐰ jul...@danjou.info   http://julien.danjou.info
 // 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
 // Tomorrow I was nothing, yesterday I'll be.




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


Re: Writing a layout - where does the p parameter come from?

2009-06-02 Thread Julien Danjou
Hi Nathan,

At 1243891357 time_t, Nathan Huesken wrote:
 So I am looking at the tile layout as reference.
 It seems, that its parameters are stored in the current tag ...
 
 No I wonder, what would I have to do to get my parameters in.
 And I also wonder how I could remember which client belongs to which
 tile. Can I store information in clients as well?

As you can see all information are passed to layouts via on_arrange()
function in awful/layout/init.lua.

Clients and tags have properties internal to awesome core, but since
some people or libs wants to store information, we usually use a
property thingie inside awful.tag and awful.client.

You have a set of awful.tag.setproperty() or something like that, which
can be used to store more properties. This properties are automatically
collected upon objects destructution so you do not have to worry about
this.

Just store what you need and retrieve it when needed.

Cheers,
-- 
Julien Danjou
// ᐰ jul...@danjou.info   http://julien.danjou.info
// 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
// Trust me.


signature.asc
Description: Digital signature


Re: Writing a layout - where does the p parameter come from?

2009-06-02 Thread Nathan Huesken
Hello,

Thanks for you answer Julien, now I feel like I am almost there.
2 Questions:

- What is the difference between workarea and geometry?

- OK, I can set simple properties of a tag and a client using
setproperty. But I need something more complex. I need to store a tree
structure telling me how the area has been divided.
So I need a root-node object, stored in the tag. And this root node
has 2 of the same kind (until a leave node is reached).
Can this also be archived with setproperty? I do not see how but I am
completly new to lua!

Thanks!
Nathan


On Tue, Jun 02, 2009 at 11:01:48AM +0200, Julien Danjou wrote:
 Hi Nathan,
 
 At 1243891357 time_t, Nathan Huesken wrote:
  So I am looking at the tile layout as reference.
  It seems, that its parameters are stored in the current tag ...
  
  No I wonder, what would I have to do to get my parameters in.
  And I also wonder how I could remember which client belongs to which
  tile. Can I store information in clients as well?
 
 As you can see all information are passed to layouts via on_arrange()
 function in awful/layout/init.lua.
 
 Clients and tags have properties internal to awesome core, but since
 some people or libs wants to store information, we usually use a
 property thingie inside awful.tag and awful.client.
 
 You have a set of awful.tag.setproperty() or something like that, which
 can be used to store more properties. This properties are automatically
 collected upon objects destructution so you do not have to worry about
 this.
 
 Just store what you need and retrieve it when needed.
 
 Cheers,
 -- 
 Julien Danjou
 // ᐰ jul...@danjou.info   http://julien.danjou.info
 // 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
 // Trust me.

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


Re: Writing a layout - where does the p parameter come from?

2009-06-02 Thread Gregor Best
On Tue, Jun 02, 2009 at 10:48:13PM +0200, Nathan Huesken wrote:
 [...]
 - OK, I can set simple properties of a tag and a client using
 setproperty. But I need something more complex. I need to store a tree
 structure telling me how the area has been divided.
 So I need a root-node object, stored in the tag. And this root node
 has 2 of the same kind (until a leave node is reached).
 Can this also be archived with setproperty? I do not see how but I am
 completly new to lua!
 
 [...]

You can easily store tables inside the tag properties. With some
handling functions, tables can be modelled like trees (bintree, octree,
k-tree, whatever you want), which should be what you want. You'd do
something like this:

local tree   = { }
tree.left= { }
tree.right   = { }
tree.content = foobar
tree.left.left= { }
tree.left.right   = { }
tree.left.content = gna
awful.tag.setproperty(t, divisions, tree)

-- 
GCS/IT/M d- s+:- a--- C++ UL+++ US UB++ P+++ L+++ E--- W+ N+ o--
K- w--- O M-- V PS+ PE- Y+ PGP+++ t+ 5 X+ R tv+ b++ DI+++ D+++ G+
e- h! r y+

Gregor Best


pgpZ9VE6Ri4nK.pgp
Description: PGP signature