static VALUE gobj_s_gobject_new(int argc, VALUE *argv, VALUE self) { const RGObjClassInfo* cinfo = rbgobj_lookup_class(self); VALUE params_hash; GObject* gobj; VALUE result; rb_scan_args(argc, argv, "01", ¶ms_hash); if (!NIL_P(params_hash)) Check_Type(params_hash, T_HASH); if (cinfo->klass != self) rb_raise(rb_eTypeError, "%s isn't registered class", rb_class2name(self)); gobj = rbgobj_gobject_new(cinfo->gtype, params_hash); result = GOBJ2RVAL(gobj); // XXX: Ughhhhh if (is_gtkobject(gobj)){ // We can't call gtk_object_sink() here. // But hopefully someone will call it in the future. //gtk_object_sink(gobj); } else { g_object_unref(gobj); } return result; }
static VALUE gobj_initialize(int argc, VALUE *argv, VALUE self) { VALUE params_hash; GObject* gobj; rb_scan_args(argc, argv, "01", ¶ms_hash); if (!NIL_P(params_hash)) Check_Type(params_hash, T_HASH); gobj = rbgobj_gobject_new(RVAL2GTYPE(self), params_hash); if (is_gtkobject(gobj)){ gobj = g_object_ref(gobj); // We can't call gtk_object_sink() here. // But hopefully someone will call it in the future. //gtk_object_sink(gobj); } G_INITIALIZE(self, gobj); return Qnil; }
static VALUE rg_s_new_bang(int argc, VALUE *argv, VALUE self) { const RGObjClassInfo* cinfo = rbgobj_lookup_class(self); VALUE params_hash; GObject* gobj; VALUE result; rb_scan_args(argc, argv, "01", ¶ms_hash); if (!NIL_P(params_hash)) Check_Type(params_hash, RUBY_T_HASH); if (cinfo->klass != self) rb_raise(rb_eTypeError, "%s isn't registered class", rb_class2name(self)); gobj = rbgobj_gobject_new(cinfo->gtype, params_hash); result = GOBJ2RVAL(gobj); g_object_unref(gobj); return result; }
static VALUE rg_initialize(int argc, VALUE *argv, VALUE self) { GType gtype; VALUE params_hash; GObject* gobj; gtype = CLASS2GTYPE(CLASS_OF(self)); if (G_TYPE_IS_ABSTRACT(gtype)) { rb_raise(rb_eTypeError, "initializing abstract class: %s", RBG_INSPECT(CLASS_OF(self))); } rb_scan_args(argc, argv, "01", ¶ms_hash); if (!NIL_P(params_hash)) Check_Type(params_hash, RUBY_T_HASH); gobj = rbgobj_gobject_new(RVAL2GTYPE(self), params_hash); G_INITIALIZE(self, gobj); return Qnil; }