changeset 3122:94ff54dd6e4a

Updated #267: Removed Subtlext::Sublet#data and renamed Subtlext::Subtle#data= to Subtlext::Subtle#send_data
author unexist
date Mon, 14 Nov 2011 20:03:43 +0100
parents 42ae3bebb840
children a7dcbc8f286b
files src/subtlext/sublet.c src/subtlext/subtlext.c src/subtlext/subtlext.h
diffstat 3 files changed, 11 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/src/subtlext/sublet.c	Fri Nov 11 15:22:13 2011 +0100
+++ b/src/subtlext/sublet.c	Mon Nov 14 20:03:43 2011 +0100
@@ -183,40 +183,19 @@
   return Qnil;
 } /* }}} */
 
-/* subSubletDataReader {{{ */
+/* subSubletSend {{{ */
 /*
- * call-seq: data -> String
+ * call-seq: send_data(string) -> nil
  *
- * Get data of this Sublet.
+ * Send given string data to a :data event of a Sublet. The data is
+ * passed as second argument.
  *
- *  puts sublet.data
- *  => "subtle"
+ *  sublet.send_data("subtle")
+ *  => nil
  */
 
 VALUE
-subSubletDataReader(VALUE self)
-{
-  VALUE id = Qnil;
-
-  /* Check ruby object */
-  rb_check_frozen(self);
-  GET_ATTR(self, "@id", id);
-
-  return id;
-} /* }}} */
-
-/* subSubletDataWriter {{{ */
-/*
- * call-seq: data=(string) -> String
- *
- * Set data of this Sublet.
- *
- *  sublet.data = "subtle"
- *  => "subtle"
- */
-
-VALUE
-subSubletDataWriter(VALUE self,
+subSubletSend(VALUE self,
   VALUE value)
 {
   VALUE id = Qnil;
@@ -237,7 +216,7 @@
         XInternAtom(display, "SUBTLE_DATA", False), &list, 1);
       free(list);
 
-      data.l[0] = FIX2LONG(id);
+      data.l[0] = FIX2INT(id);
 
       subSharedMessage(display, DefaultRootWindow(display),
         "SUBTLE_SUBLET_DATA", data, 32, True);
@@ -245,7 +224,7 @@
   else rb_raise(rb_eArgError, "Unexpected value-type `%s'",
     rb_obj_classname(value));
 
-  return value;
+  return Qnil;
 } /* }}} */
 
 /* subSubletVisibilityShow {{{ */
--- a/src/subtlext/subtlext.c	Fri Nov 11 15:22:13 2011 +0100
+++ b/src/subtlext/subtlext.c	Mon Nov 14 20:03:43 2011 +0100
@@ -2169,8 +2169,7 @@
   /* Class methods */
   rb_define_method(sublet, "initialize", subSubletInit,           1);
   rb_define_method(sublet, "update",     subSubletUpdate,         0);
-  rb_define_method(sublet, "data",       subSubletDataReader,     0);
-  rb_define_method(sublet, "data=",      subSubletDataWriter,     1);
+  rb_define_method(sublet, "send_data",  subSubletSend,           1);
   rb_define_method(sublet, "show",       subSubletVisibilityShow, 0);
   rb_define_method(sublet, "hide",       subSubletVisibilityHide, 0);
   rb_define_method(sublet, "to_str",     subSubletToString,       0);
--- a/src/subtlext/subtlext.h	Fri Nov 11 15:22:13 2011 +0100
+++ b/src/subtlext/subtlext.h	Mon Nov 14 20:03:43 2011 +0100
@@ -181,8 +181,7 @@
 /* Class */
 VALUE subSubletInit(VALUE self, VALUE name);                      ///< Create sublet
 VALUE subSubletUpdate(VALUE self);                                ///< Update sublet
-VALUE subSubletDataReader(VALUE self);                            ///< Get sublet data
-VALUE subSubletDataWriter(VALUE self, VALUE value);               ///< Set sublet data
+VALUE subSubletSend(VALUE self, VALUE value);                     ///< Send data to sublet
 VALUE subSubletVisibilityShow(VALUE self);                        ///< Show sublet
 VALUE subSubletVisibilityHide(VALUE self);                        ///< Hide sublet
 VALUE subSubletGeometryReader(VALUE self);                        ///< Get sublet geometry