Class: Newt::Form::ExitStruct

Inherits:
Object
  • Object
show all
Defined in:
ext/ruby_newt/ruby_newt.c

Instance Method Summary collapse

Instance Method Details

#==(obj) ⇒ Object



813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
# File 'ext/ruby_newt/ruby_newt.c', line 813

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;
}

#componentObject



801
802
803
804
805
806
807
808
809
810
811
# File 'ext/ruby_newt/ruby_newt.c', line 801

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;
  }
}

#inspectObject



833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
# File 'ext/ruby_newt/ruby_newt.c', line 833

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);
  }
}

#keyObject



790
791
792
793
794
795
796
797
798
799
# File 'ext/ruby_newt/ruby_newt.c', line 790

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;
}

#reasonObject



771
772
773
774
775
776
777
# File 'ext/ruby_newt/ruby_newt.c', line 771

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);
}

#watchObject



779
780
781
782
783
784
785
786
787
788
# File 'ext/ruby_newt/ruby_newt.c', line 779

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;
}