Class instantiation fixes.
[ruby-esmart.git] / src / esmart_file_dialog / rb_esmart_file_dialog.c
index a45d3a49e245cb87e1b3bc280aa8f5b650aa51be..4c60feccdbf2b1d1e4cf6bfd5f7ca0bbf66ab390 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_esmart_file_dialog.c 337 2005-05-02 17:48:20Z tilman $
+ * $Id: rb_esmart_file_dialog.c 356 2006-02-10 18:27:31Z tilman $
  *
  * Copyright (C) 2005 Tilman Sauerbeck (tilman at code-monkey de)
  *
@@ -52,11 +52,15 @@ static void c_free (RbFileDialog *e)
        free (e);
 }
 
-static VALUE c_new (VALUE klass, VALUE evas, VALUE edj)
+static VALUE c_alloc (VALUE klass)
 {
-       VALUE self, argv[1];
        RbFileDialog *fd = NULL;
 
+       return Data_Make_Struct (klass, RbFileDialog, c_mark, c_free, fd);
+}
+
+static VALUE c_init (VALUE self, VALUE evas, VALUE edj)
+{
        if (!rb_block_given_p ()) {
                rb_raise (rb_eStandardError, "no block given");
                return Qnil;
@@ -65,16 +69,15 @@ static VALUE c_new (VALUE klass, VALUE evas, VALUE edj)
        CHECK_CLASS (evas, cEvas);
        StringValue (edj);
        GET_OBJ (evas, RbEvas, e);
+       GET_OBJ (self, RbFileDialog, fd);
 
-       self = Data_Make_Struct (klass, RbFileDialog, c_mark, c_free, fd);
        fd->real.real = esmart_file_dialog_new (e->real,
                                                StringValuePtr (edj));
 
        if (!fd->real.real)
                rb_raise (rb_eStandardError, "failed");
 
-       argv[0] = evas;
-       rb_obj_call_init (self, 1, argv);
+       rb_call_super (1, &evas);
 
        fd->callback = rb_block_proc ();
        fd->edje = Qnil;
@@ -179,7 +182,8 @@ void Init_esmart_file_dialog (void)
 
        c = rb_define_class_under (mEsmart, "FileDialog", cEvasObject);
 
-       rb_define_singleton_method (c, "new", c_new, 2);
+       rb_define_alloc_func (c, c_alloc);
+       rb_define_method (c, "initialize", c_init, 2);
        rb_define_method (c, "edje", c_edje_get, 0);
        rb_define_method (c, "selections", c_selections_get, 0);
        rb_define_method (c, "current_directory", c_current_directory_get, 0);