changeset 3238:6879457695b5

Fixed #309: Moved .spawn to Subtlext::Client
author unexist
date Wed, 14 Nov 2012 16:12:46 +0100
parents 3b8dbf9dea5c
children 6670ea4caf96
files src/subtlext/client.c src/subtlext/subtle.c src/subtlext/subtlext.c src/subtlext/subtlext.h
diffstat 4 files changed, 39 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/src/subtlext/client.c	Wed Nov 14 16:12:22 2012 +0100
+++ b/src/subtlext/client.c	Wed Nov 14 16:12:46 2012 +0100
@@ -486,6 +486,43 @@
   return array;
 } /* }}} */
 
+/* subextClientSingSpawn {{{ */
+/*
+ * call-seq: spawn(cmd) -> Subtlext::Client
+ *
+ * Spawn a command and returns a Client object.
+ *
+ *  spawn("xterm")
+ *  => #<Subtlext::Client:xxx>
+ */
+
+VALUE
+subextClientSingSpawn(VALUE self,
+  VALUE cmd)
+{
+  VALUE ret = Qnil;
+
+  /* Check object type */
+  if(T_STRING == rb_type(cmd))
+    {
+      pid_t pid = 0;
+
+      subextSubtlextConnect(NULL); ///< Implicit open connection
+
+      /* Create client with empty window id since we cannot
+       * know the real window id at this point (race) */
+      if(0 < (pid = subSharedSpawn(RSTRING_PTR(cmd))))
+        {
+          ret = subextClientInstantiate((Window)pid);
+          rb_iv_set(ret, "@pid", INT2FIX((int)pid));
+        }
+    }
+  else rb_raise(rb_eArgError, "Unexpected value-type `%s'",
+    rb_obj_classname(cmd));
+
+  return ret;
+} /* }}} */
+
 /* Helper */
 
 /* subextClientInstantiate {{{ */
--- a/src/subtlext/subtle.c	Wed Nov 14 16:12:22 2012 +0100
+++ b/src/subtlext/subtle.c	Wed Nov 14 16:12:46 2012 +0100
@@ -355,41 +355,4 @@
   return font;
 } /* }}} */
 
-/* subextSubtleSingSpawn {{{ */
-/*
- * call-seq: spawn(cmd) -> Subtlext::Client
- *
- * Spawn a command and returns a Client object.
- *
- *  spawn("xterm")
- *  => #<Subtlext::Client:xxx>
- */
-
-VALUE
-subextSubtleSingSpawn(VALUE self,
-  VALUE cmd)
-{
-  VALUE ret = Qnil;
-
-  /* Check object type */
-  if(T_STRING == rb_type(cmd))
-    {
-      pid_t pid = 0;
-
-      subextSubtlextConnect(NULL); ///< Implicit open connection
-
-      /* Create client with empty window id since we cannot
-       * know the real window id at this point (race) */
-      if(0 < (pid = subSharedSpawn(RSTRING_PTR(cmd))))
-        {
-          ret = subextClientInstantiate((Window)pid);
-          rb_iv_set(ret, "@pid", INT2FIX((int)pid));
-        }
-    }
-  else rb_raise(rb_eArgError, "Unexpected value-type `%s'",
-    rb_obj_classname(cmd));
-
-  return ret;
-} /* }}} */
-
 // vim:ts=2:bs=2:sw=2:et:fdm=marker
--- a/src/subtlext/subtlext.c	Wed Nov 14 16:12:22 2012 +0100
+++ b/src/subtlext/subtlext.c	Wed Nov 14 16:12:46 2012 +0100
@@ -1831,6 +1831,7 @@
   rb_define_singleton_method(client, "visible", subextClientSingVisible, 0);
   rb_define_singleton_method(client, "list",    subextClientSingList,    0);
   rb_define_singleton_method(client, "recent",  subextClientSingRecent,  0);
+  rb_define_singleton_method(client, "spawn",   subextClientSingSpawn,   1);
 
   /* General methods */
   rb_define_method(client, "has_tag?",    SubtlextTagAsk,           1);
@@ -2119,7 +2120,6 @@
   rb_define_singleton_method(subtle, "quit",          subextSubtleSingQuit,          0);
   rb_define_singleton_method(subtle, "colors",        subextSubtleSingColors,        0);
   rb_define_singleton_method(subtle, "font",          subextSubtleSingFont,          0);
-  rb_define_singleton_method(subtle, "spawn",         subextSubtleSingSpawn,         1);
 
   /* Aliases */
   rb_define_alias(rb_singleton_class(subtle), "reload_config", "reload");
--- a/src/subtlext/subtlext.h	Wed Nov 14 16:12:22 2012 +0100
+++ b/src/subtlext/subtlext.h	Wed Nov 14 16:12:46 2012 +0100
@@ -56,6 +56,7 @@
 VALUE subextClientSingVisible(VALUE self);                           ///< Get all visible clients
 VALUE subextClientSingList(VALUE self);                              ///< Get all clients
 VALUE subextClientSingRecent(VALUE self);                            ///< Get recent active clients
+VALUE subextClientSingSpawn(VALUE self, VALUE cmd);                  ///< Spawn command
 
 /* Class */
 VALUE subextClientInstantiate(Window win);                           ///< Instantiate client
@@ -201,7 +202,6 @@
 VALUE subextSubtleSingQuit(VALUE self);                              ///< Quit subtle
 VALUE subextSubtleSingColors(VALUE self);                            ///< Get colors
 VALUE subextSubtleSingFont(VALUE self);                              ///< Get font
-VALUE subextSubtleSingSpawn(VALUE self, VALUE cmd);                  ///< Spawn command
 /* }}} */
 
 /* subtlext.c {{{ */