Class Subtlext::Sublet < Object

Class for interaction with sublets

Methods

public class

  1. find
    [value]
  2. first
  3. list
  4. new

public instance

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

Attributes

geometry [R] Geometry
id [R] Gravity id
name [R] WM_NAME

Public class methods

find(value) → Array
[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.
 1 Subtlext::Sublet.find(1)
 2 => [#<Subtlext::Sublet:xxx>]
 3 
 4 Subtlext::Sublet.find("subtle")
 5 => [#<Subtlext::Sublet:xxx>]
 6 
 7 Subtlext::Sublet[".*"]
 8 => [#<Subtlext::Sublet:xxx>, #<Subtlext::Sublet:xxx>]
 9 
10 Subtlext::Sublet["subtle"]
11 => []
12 
13 Subtlext::Sublet[:clock]
14 => [#<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.
1 Subtlext::Sublet.first(1)
2 => #<Subtlext::Sublet:xxx>
3 
4 Subtlext::Sublet.first("subtle")
5 => #<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.

1 Subtlext::Sublet.list
2 => [#<Subtlext::Sublet:xxx>, #<Subtlext::Sublet:xxx>]
3 
4 Subtlext::Sublet.list
5 => []
[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.

1 sublet = Subtlext::Sublet.new("subtle")
2 => #<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)

1 object1 <=> object2
2 => 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)

1 object1 == object2
2 => 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)

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

Convert this object to hash.

1 puts object.hash
2 => 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.

1 sublet.hide
2 => #<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.

1 sublet.kill
2 => 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.

1 sublet.send_data("subtle")
2 => #<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.

1 sublet.show
2 => #<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.

1 object.style = :blue
2 => 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_s ()

Alias for to_str

to_str → String

Convert Sublet object to string.

1 puts sublet
2 => 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.

1 sublet.update
2 => #<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;
}