Class for interaction with sublets
Methods
Public Class
Public Instance
Public Instance Aliases
| to_s | -> | to_str |
Aliases |
Public Class methods
Find Sublet by a given value which can be of following type:
| Fixnum |
Array index of the |
| String |
Regexp match against name of Sublets, returns a Sublet on single match or an Array on multiple matches. |
| Symbol |
Either :all for an array of all Sublets or any string for an exact match. |
Subtlext::Sublet.find(1)
=> [#<Subtlext::Sublet:xxx>]
Subtlext::Sublet.find("subtle")
=> [#<Subtlext::Sublet:xxx>]
Subtlext::Sublet[".*"]
=> [#<Subtlext::Sublet:xxx>, #<Subtlext::Sublet:xxx>]
Subtlext::Sublet["subtle"]
=> []
Subtlext::Sublet[:clock]
=> [#<Subtlext::Sublet:xxx>]
VALUE
subextSubletSingFind(VALUE self,
VALUE value)
{
return SubletFind(value, False);
}
Find first Sublet by a given value which can be of following type:
| Fixnum |
Array index of the |
| String |
Regexp match against name of Sublets, returns a Sublet on single match or an Array on multiple matches. |
| Symbol |
Either :all for an array of all Sublets or any string for an exact match. |
Subtlext::Sublet.first(1)
=> #<Subtlext::Sublet:xxx>
Subtlext::Sublet.first("subtle")
=> #<Subtlext::Sublet:xxx>
VALUE
subextSubletSingFirst(VALUE self,
VALUE value)
{
return SubletFind(value, True);
}
Get an array of all Sublets based on the SUBTLE_SUBLET_LIST
property list.
Subtlext::Sublet.list => [#<Subtlext::Sublet:xxx>, #<Subtlext::Sublet:xxx>] Subtlext::Sublet.list => []
VALUE
subextSubletSingList(VALUE self)
{
return subextSubtlextFindObjectsGeometry("SUBTLE_SUBLET_LIST",
"Sublet", NULL, 0, False);
}
Create new Sublet object locally without calling save automatically.
sublet = Subtlext::Sublet.new("subtle")
=> #<Subtlext::Sublet:xxx>
VALUE
subextSubletInit(VALUE self,
VALUE name)
{
if(T_STRING != rb_type(name))
rb_raise(rb_eArgError, "Unexpected value-type `%s'",
rb_obj_classname(name));
/* Init object */
rb_iv_set(self, "@id", Qnil);
rb_iv_set(self, "@name", name);
subextSubtlextConnect(NULL); ///< Implicit open connection
return self;
}
Public Instance methods
Whether both objects have the same value. Returns -1, 0 or 1 when self is less than, equal to or grater than other. (based on id)
object1 <=> object2 => 0
static VALUE
SubtlextEqualSpaceId(VALUE self,
VALUE other)
{
return SubtlextSpaceship(self, other, "@id");
}
Whether both objects have the same values (based on id)
object1 == object2 => true
static VALUE
SubtlextEqualId(VALUE self,
VALUE other)
{
return SubtlextEqual(self, other, "@id", False);
}
Whether both objects have the same values and types (based on id)
object1.eql? object2 => true
static VALUE
SubtlextEqualTypedId(VALUE self,
VALUE other)
{
return SubtlextEqual(self, other, "@id", True);
}
Convert this object to hash.
puts object.hash => 1746246187916025425
static VALUE
SubtlextHash(VALUE self)
{
VALUE str = Qnil, id = rb_intern("to_str");
/* Convert to string */
if(rb_respond_to(self, id))
str = rb_funcall(self, id, 0, Qnil);
return T_STRING == rb_type(str) ? INT2FIX(rb_str_hash(str)) : Qnil;
}
Hide sublet from the panels.
sublet.hide => #<Subtlext::Sublet:xxx>
VALUE
subextSubletVisibilityHide(VALUE self)
{
VALUE id = Qnil;
SubMessageData data = { { 0, 0, 0, 0, 0 } };
/* Check ruby object */
rb_check_frozen(self);
GET_ATTR(self, "@id", id);
data.l[0] = FIX2LONG(id);
data.l[1] = SUB_EWMH_HIDDEN;
subSharedMessage(display, DefaultRootWindow(display),
"SUBTLE_SUBLET_FLAGS", data, 32, True);
return self;
}
Remove this Sublet from subtle and freeze this object.
sublet.kill => nil
VALUE
subextSubletKill(VALUE self)
{
VALUE id = Qnil;
SubMessageData data = { { 0, 0, 0, 0, 0 } };
/* Check ruby object */
rb_check_frozen(self);
GET_ATTR(self, "@id", id);
subextSubtlextConnect(NULL); ///< Implicit open connection
/* Send message */
data.l[0] = FIX2INT(id);
subSharedMessage(display, DefaultRootWindow(display),
"SUBTLE_SUBLET_KILL", data, 32, True);
rb_obj_freeze(self); ///< Freeze object
return Qnil;
}
Send given string data to a :data event of a Sublet. The data is passed as second argument.
sublet.send_data("subtle")
=> #<Subtlext::Sublet:xxx>
VALUE
subextSubletSend(VALUE self,
VALUE value)
{
VALUE id = Qnil;
/* Check ruby object */
rb_check_frozen(self);
GET_ATTR(self, "@id", id);
/* Check object type */
if(T_STRING == rb_type(value))
{
char *list = NULL;
SubMessageData data = { { 0, 0, 0, 0, 0 } };
/* Store data */
list = strdup(RSTRING_PTR(value));
subSharedPropertySetStrings(display, DefaultRootWindow(display),
XInternAtom(display, "SUBTLE_DATA", False), &list, 1);
free(list);
data.l[0] = FIX2INT(id);
subSharedMessage(display, DefaultRootWindow(display),
"SUBTLE_SUBLET_DATA", data, 32, True);
}
else rb_raise(rb_eArgError, "Unexpected value-type `%s'",
rb_obj_classname(value));
return self;
}
Show sublet in the panels.
sublet.show => #<Subtlext::Sublet:xxx>
VALUE
subextSubletVisibilityShow(VALUE self)
{
VALUE id = Qnil;
SubMessageData data = { { 0, 0, 0, 0, 0 } };
/* Check ruby object */
rb_check_frozen(self);
GET_ATTR(self, "@id", id);
data.l[0] = FIX2LONG(id);
data.l[1] = SUB_EWMH_VISIBLE;
subSharedMessage(display, DefaultRootWindow(display),
"SUBTLE_SUBLET_FLAGS", data, 32, True);
return self;
}
Set style state of this Object, use nil to reset state.
object.style = :blue => nil
static VALUE
SubtlextStyle(VALUE self,
VALUE value)
{
char *prop = NULL;
VALUE id = Qnil, str = Qnil;
SubMessageData data = { { 0, 0, 0, 0, 0 } };
/* Check ruby object */
rb_check_frozen(self);
GET_ATTR(self, "@id", id);
/* Check object type */
if(rb_obj_is_instance_of(self, rb_const_get(mod, rb_intern("View"))))
prop = "SUBTLE_VIEW_STYLE";
else prop = "SUBTLE_SUBLET_STYLE";
/* Check value type */
switch(rb_type(value))
{
case T_SYMBOL: str = rb_sym_to_s(value);
case T_STRING:
snprintf(data.b, sizeof(data.b), "%d#%s",
(int)FIX2INT(id), RSTRING_PTR(str));
subSharedMessage(display, ROOT, prop, data, 32, True);
break;
case T_NIL:
snprintf(data.b, sizeof(data.b), "%d#", (int)FIX2INT(id));
subSharedMessage(display, ROOT, prop, data, 32, True);
break;
default: rb_raise(rb_eArgError, "Unexpected value-type `%s'",
rb_obj_classname(value));
}
return Qnil;
}
Convert Sublet object to string.
puts sublet => sublet
VALUE
subextSubletToString(VALUE self)
{
VALUE name = Qnil;
/* Check ruby object */
GET_ATTR(self, "@name", name);
return name;
}
Force subtle to update the data of this Sublet.
sublet.update => #<Subtlext::Sublet:xxx>
VALUE
subextSubletUpdate(VALUE self)
{
VALUE id = Qnil;
SubMessageData data = { { 0, 0, 0, 0, 0 } };
/* Check ruby object */
rb_check_frozen(self);
GET_ATTR(self, "@id", id);
/* Send message */
data.l[0] = FIX2INT(id);
subSharedMessage(display, DefaultRootWindow(display),
"SUBTLE_SUBLET_UPDATE", data, 32, True);
return self;
}