class Newt::Form::ExitStruct

Public Instance Methods

==(p1) click to toggle source
static VALUE rb_ext_ExitStruct_equal(VALUE self, VALUE obj)
{
  rb_newt_ExitStruct *rb_es;
  newtComponent co;
  void *data;

  if (NIL_P(obj)) return Qfalse;
  if (self == obj) return Qtrue;

  /* Compare components for backwards compatibility with newtRunForm(). */
  if (rb_obj_is_kind_of(obj, cWidget)) {
    Data_Get_Struct(self, rb_newt_ExitStruct, rb_es);
    Get_Widget_Data(obj, data);
    co = ((Widget_data *) data)->co;
    if (rb_es->es.reason == NEWT_EXIT_COMPONENT
        && rb_es->es.u.co == co) return Qtrue;
  }
  return Qfalse;
}
component() click to toggle source
static VALUE rb_ext_ExitStruct_component(VALUE self)
{
  rb_newt_ExitStruct *rb_es;

  Data_Get_Struct(self, rb_newt_ExitStruct, rb_es);
  if (rb_es->es.reason == NEWT_EXIT_COMPONENT) {
      return rb_hash_aref(rb_es->components, PTR2NUM(rb_es->es.u.co));
  } else {
      return Qnil;
  }
}
inspect() click to toggle source
static VALUE rb_ext_ExitStruct_inspect(VALUE self)
{
  rb_newt_ExitStruct *rb_es;
  VALUE classname = rb_class_name(rb_obj_class(self));
  char *class = StringValuePtr(classname);

  Data_Get_Struct(self, rb_newt_ExitStruct, rb_es);
  switch(rb_es->es.reason) {
    case NEWT_EXIT_HOTKEY:
      return rb_sprintf("#<%s:%p reason=%d, key=%d>", class, (void *) self,
                        rb_es->es.reason, rb_es->es.u.key);
    case NEWT_EXIT_COMPONENT:
      return rb_sprintf("#<%s:%p reason=%d, component=%p>", class, (void *) self,
                        rb_es->es.reason, rb_es->es.u.co);
    case NEWT_EXIT_FDREADY:
      return rb_sprintf("#<%s:%p reason=%d, watch=%d>", class, (void *) self,
                        rb_es->es.reason, rb_es->es.u.watch);
    case NEWT_EXIT_TIMER:
    case NEWT_EXIT_ERROR:
      return rb_sprintf("#<%s:%p reason=%d>", class, (void *) self,
                        rb_es->es.reason);
    default:
      return rb_call_super(0, NULL);
  }
}
key() click to toggle source
static VALUE rb_ext_ExitStruct_key(VALUE self)
{
  rb_newt_ExitStruct *rb_es;

  Data_Get_Struct(self, rb_newt_ExitStruct, rb_es);
  if (rb_es->es.reason == NEWT_EXIT_HOTKEY)
    return INT2NUM(rb_es->es.u.key);
  else
    return Qnil;
}
reason() click to toggle source
static VALUE rb_ext_ExitStruct_reason(VALUE self)
{
  rb_newt_ExitStruct *rb_es;

  Data_Get_Struct(self, rb_newt_ExitStruct, rb_es);
  return INT2NUM(rb_es->es.reason);
}
watch() click to toggle source
static VALUE rb_ext_ExitStruct_watch(VALUE self)
{
  rb_newt_ExitStruct *rb_es;

  Data_Get_Struct(self, rb_newt_ExitStruct, rb_es);
  if (rb_es->es.reason == NEWT_EXIT_FDREADY)
    return INT2NUM(rb_es->es.u.watch);
  else
    return Qnil;
}