4 * Copyright (c) Tuomo Valkonen 1999-2007.
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>
21 static ObjList *taglist=NULL;
24 /*{{{ Adding/removing tags */
27 bool region_set_tagged(WRegion *reg, int sp)
29 bool set=(reg->flags®ION_TAGGED);
30 bool nset=libtu_do_setparam(sp, set);
33 if(reg->flags®ION_TAGGED){
34 reg->flags&=~REGION_TAGGED;
35 objlist_remove(&taglist, (Obj*)reg);
37 reg->flags|=REGION_TAGGED;
38 objlist_insert_last(&taglist, (Obj*)reg);
40 region_notify_change(reg, ioncore_g.notifies.tag);
48 * Change tagging state of \var{reg} as defined by \var{how}
49 * (set/unset/toggle). Resulting state is returned.
51 EXTL_EXPORT_AS(WRegion, set_tagged)
52 bool region_set_tagged_extl(WRegion *reg, const char *how)
54 return region_set_tagged(reg, libtu_string_to_setparam(how));
59 * Is \var{reg} tagged?
63 bool region_is_tagged(WRegion *reg)
65 return ((reg->flags®ION_TAGGED)!=0);
73 void ioncore_tagged_clear()
75 while(ioncore_tagged_first(TRUE)!=NULL)
87 * Returns first tagged object, untagging it as well if \var{untag}is set.
91 WRegion *ioncore_tagged_first(bool untag)
96 reg=(WRegion*)OBJLIST_FIRST(WRegion*, taglist);
98 reg=(WRegion*)objlist_take_first(&taglist);
101 reg->flags&=~REGION_TAGGED;
102 region_notify_change(reg, ioncore_g.notifies.tag);
111 * Iterate over tagged regions until \var{iterfn} returns \code{false}.
112 * The function itself returns \code{true} if it reaches the end of list
113 * without this happening.
117 bool ioncore_tagged_i(ExtlFn iterfn)
119 return extl_iter_objlist(iterfn, taglist);