4 * Copyright (c) Tuomo Valkonen 1999-2006.
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.
12 #include <libtu/objlist.h>
13 #include <libtu/setparam.h>
18 static ObjList *taglist=NULL;
21 /*{{{ Adding/removing tags */
24 bool region_set_tagged(WRegion *reg, int sp)
26 bool set=(reg->flags®ION_TAGGED);
27 bool nset=libtu_do_setparam(sp, set);
30 if(reg->flags®ION_TAGGED){
31 reg->flags&=~REGION_TAGGED;
32 objlist_remove(&taglist, (Obj*)reg);
34 reg->flags|=REGION_TAGGED;
35 objlist_insert_last(&taglist, (Obj*)reg);
37 region_notify_change(reg, "tag");
45 * Change tagging state of \var{reg} as defined by \var{how}
46 * (set/unset/toggle). Resulting state is returned.
48 EXTL_EXPORT_AS(WRegion, set_tagged)
49 bool region_set_tagged_extl(WRegion *reg, const char *how)
51 return region_set_tagged(reg, libtu_string_to_setparam(how));
56 * Is \var{reg} tagged?
60 bool region_is_tagged(WRegion *reg)
62 return ((reg->flags®ION_TAGGED)!=0);
70 void ioncore_clear_tags()
72 while(ioncore_tags_take_first()!=NULL)
84 * Returns first tagged object.
88 WRegion *ioncore_tags_first()
90 return (WRegion*)OBJLIST_FIRST(WRegion*, taglist);
94 WRegion *ioncore_tags_take_first()
96 WRegion *reg=(WRegion*)objlist_take_first(&taglist);
99 reg->flags&=~REGION_TAGGED;
100 region_notify_change(reg, "tag");
107 * Returns a list of tagged regions.
111 ExtlTab ioncore_tagged_list()
118 region=ioncore_tags_first();
120 return extl_table_none();
122 tab=extl_create_table();
124 FOR_ALL_ON_OBJLIST(WRegion*, region, taglist, tmp){
125 if(extl_table_seti_o(tab, n+1, (Obj*)region))