class Subtlext::Sublet

  1. ../../../../../tmp/subtlext.c
Superclass: Object

Class for interaction with sublets

Methods

Public Class

  1. find
  2. first
  3. list
  4. new

Public Instance

  1. <=>
  2. ==
  3. eql?
  4. geometry
  5. hash
  6. hide
  7. id
  8. kill
  9. name
  10. send_data
  11. show
  12. style=
  13. to_str
  14. update

Public Instance Aliases

to_s -> to_str

Aliases

Attributes

geometry [R]

Geometry

id [R]

Sublet id

name [R]

Name of the sublet

Public Class methods

find(value) -> Array

Find Sublet by a given value which can be of following type:

Fixnum

Array index of the SUBTLE_SUBLET_LIST property list.

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>]
[show source]
VALUE
subextSubletSingFind(VALUE self,
  VALUE value)
{
  return SubletFind(value, False);
}
first(value) -> Subtlext::Sublet or nil

Find first Sublet by a given value which can be of following type:

Fixnum

Array index of the SUBTLE_SUBLET_LIST property list.

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>
[show source]
VALUE
subextSubletSingFirst(VALUE self,
  VALUE value)
{
  return SubletFind(value, True);
}
list -> Array

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
=> []
[show source]
VALUE
subextSubletSingList(VALUE self)
{
  return subextSubtlextFindObjectsGeometry("SUBTLE_SUBLET_LIST",
    "Sublet", NULL, 0, False);
}
new(name) -> Subtlext::Sublet

Create new Sublet object locally without calling save automatically.

sublet = Subtlext::Sublet.new("subtle")
=> #<Subtlext::Sublet:xxx>
[show source]
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

<=>(other) -> -1, 0 or 1

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
[show source]
static VALUE
SubtlextEqualSpaceId(VALUE self,
  VALUE other)
{
  return SubtlextSpaceship(self, other, "@id");
}
==(other) -> True or False

Whether both objects have the same values (based on id)

object1 == object2
=> true
[show source]
static VALUE
SubtlextEqualId(VALUE self,
  VALUE other)
{
  return SubtlextEqual(self, other, "@id", False);
}
eql?(other) -> True or False

Whether both objects have the same values and types (based on id)

object1.eql? object2
=> true
[show source]
static VALUE
SubtlextEqualTypedId(VALUE self,
  VALUE other)
{
  return SubtlextEqual(self, other, "@id", True);
}
hash -> Hash

Convert this object to hash.

puts object.hash
=> 1746246187916025425
[show source]
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 -> Subtlext::Sublet

Hide sublet from the panels.

sublet.hide
=> #<Subtlext::Sublet:xxx>
[show source]
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;
}
kill -> nil

Remove this Sublet from subtle and freeze this object.

sublet.kill
=> nil
[show source]
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_data(string) -> Subtlext::Sublet

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>
[show source]
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 -> Subtlext::Sublet

Show sublet in the panels.

sublet.show
=> #<Subtlext::Sublet:xxx>
[show source]
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;
}
style=(string) -> nil
style=(symbol) -> nil
style=(nil) -> nil

Set style state of this Object, use nil to reset state.

object.style = :blue
=> nil
[show source]
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;
}
to_str -> String

Convert Sublet object to string.

puts sublet
=> sublet
[show source]
VALUE
subextSubletToString(VALUE self)
{
  VALUE name = Qnil;

  /* Check ruby object */
  GET_ATTR(self, "@name", name);

  return name;
}
update -> Subtlext::Sublet

Force subtle to update the data of this Sublet.

sublet.update
=> #<Subtlext::Sublet:xxx>
[show source]
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;
}