2 * ion/ioncore/extlconv.c
4 * Copyright (c) Tuomo Valkonen 1999-2005.
6 * Ion is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
13 #include <libextl/extl.h>
15 #include "region-iter.h"
21 ExtlTab
managed_list_to_table(WRegion
*list
, bool (*filter
)(WRegion
*r
))
23 ExtlTab tab
=extl_create_table();
27 FOR_ALL_MANAGED_ON_LIST(list
, r
){
28 if(filter
==NULL
|| filter(r
)){
29 extl_table_seti_o(tab
, i
, (Obj
*)r
);
44 bool extl_table_is_bool_set(ExtlTab tab
, const char *entry
)
48 if(extl_table_gets_b(tab
, entry
, &b
))
60 bool extl_table_to_rectangle(ExtlTab tab
, WRectangle
*rectret
)
62 if(!extl_table_gets_i(tab
, "x", &(rectret
->x
)) ||
63 !extl_table_gets_i(tab
, "y", &(rectret
->y
)) ||
64 !extl_table_gets_i(tab
, "w", &(rectret
->w
)) ||
65 !extl_table_gets_i(tab
, "h", &(rectret
->h
)))
72 ExtlTab
extl_table_from_rectangle(const WRectangle
*rect
)
74 ExtlTab tab
=extl_create_table();
76 extl_table_sets_i(tab
, "x", rect
->x
);
77 extl_table_sets_i(tab
, "y", rect
->y
);
78 extl_table_sets_i(tab
, "w", rect
->w
);
79 extl_table_sets_i(tab
, "h", rect
->h
);
85 void extl_table_sets_rectangle(ExtlTab tab
, const char *nam
,
86 const WRectangle
*rect
)
88 ExtlTab g
=extl_table_from_rectangle(rect
);
89 extl_table_sets_t(tab
, nam
, g
);
94 bool extl_table_gets_rectangle(ExtlTab tab
, const char *nam
,
100 if(!extl_table_gets_t(tab
, nam
, &g
))
103 ok
=extl_table_to_rectangle(g
, rect
);