]> git.decadent.org.uk Git - ion3.git/blobdiff - ioncore/names.c
Imported Upstream version 20090110
[ion3.git] / ioncore / names.c
index 70855042e7e6fd288ad718f037f66325835c5ef1..14bde2c53100d5203fa401cf4b21c9cbd433178e 100644 (file)
@@ -1,12 +1,9 @@
 /*
  * ion/ioncore/names.c
  *
- * Copyright (c) Tuomo Valkonen 1999-2006
+ * Copyright (c) Tuomo Valkonen 1999-2009
  *
- * Ion is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
+ * See the included file LICENSE for details.
  */
 
 
@@ -19,6 +16,7 @@
 #include <libextl/extl.h>
 
 #include "common.h"
+#include "global.h"
 #include "region.h"
 #include "clientwin.h"
 #include "names.h"
@@ -416,7 +414,7 @@ static bool do_set_name(bool (*fn)(WRegion *reg, WNamespace *ns, const char *p),
     if(nm!=NULL)
         free(nm);
 
-    region_notify_change(reg, "name");
+    region_notify_change(reg, ioncore_g.notifies.name);
     
     return ret;
 }
@@ -448,7 +446,7 @@ bool clientwin_register(WClientWin *cwin)
 
 /*EXTL_DOC
  * Set the name of \var{reg} to \var{p}. If the name is already in use,
- * an instance number suffix \code{<n>} will be attempted. If \var{p} has
+ * an instance number suffix \codestr{<n>} will be attempted. If \var{p} has
  * such a suffix, it will be modified, otherwise such a suffix will be
  * added. Setting \var{p} to nil will cause current name to be removed.
  */
@@ -465,7 +463,7 @@ bool region_set_name(WRegion *reg, const char *p)
 /*EXTL_DOC
  * Similar to \fnref{WRegion.set_name} except if the name is already in use,
  * other instance numbers will not be attempted. The string \var{p} should
- * not contain a \code{<n>} suffix or this function will fail.
+ * not contain a \codestr{<n>} suffix or this function will fail.
  */
 EXTL_EXPORT_MEMBER
 bool region_set_name_exact(WRegion *reg, const char *p)
@@ -537,16 +535,13 @@ WClientWin *ioncore_lookup_clientwin(const char *name)
 }
 
 
-static ExtlTab do_list(WNamespace *ns, const char *typenam)
+static bool do_list(ExtlFn fn, WNamespace *ns, const char *typenam)
 {
-    ExtlTab tab;
     Rb_node node;
     int n=0;
     
     if(!ns->initialised)
-        return extl_table_none();
-    
-    tab=extl_create_table();
+        return FALSE;
     
     rb_traverse(node, ns->rb){
         WRegion *reg=(WRegion*)node->v.val;
@@ -556,33 +551,40 @@ static ExtlTab do_list(WNamespace *ns, const char *typenam)
         if(typenam!=NULL && !obj_is_str((Obj*)reg, typenam))
             continue;
 
-        if(extl_table_seti_o(tab, n+1, (Obj*)reg))
-            n++;
+        if(!extl_iter_obj(fn, (Obj*)reg))
+            return FALSE;
     }
     
-    return tab;
+    return TRUE;
 }
 
 
 /*EXTL_DOC
- * Find all non-client window regions inheriting \var{typenam}.
+ * Iterate over all non-client window regions with (inherited) class
+ * \var{typenam} until \var{iterfn} returns \code{false}.
+ * The function is called in protected mode.
+ * This routine returns \code{true} if it reaches the end of list
+ * without this happening.
  */
 EXTL_SAFE
 EXTL_EXPORT
-ExtlTab ioncore_region_list(const char *typenam)
+bool ioncore_region_i(ExtlFn fn, const char *typenam)
 {
-    return do_list(&ioncore_internal_ns, typenam);
+    return do_list(fn, &ioncore_internal_ns, typenam);
 }
 
 
 /*EXTL_DOC
- * Return a list of all client windows.
+ * Iterate over client windows until \var{iterfn} returns \code{false}.
+ * The function is called in protected mode.
+ * This routine returns \code{true} if it reaches the end of list
+ * without this happening.
  */
 EXTL_SAFE
 EXTL_EXPORT
-ExtlTab ioncore_clientwin_list()
+bool ioncore_clientwin_i(ExtlFn fn)
 {
-    return do_list(&ioncore_clientwin_ns, NULL);
+    return do_list(fn, &ioncore_clientwin_ns, NULL);
 }