From 6685e8b62f8539353617e4537c7409da5b5f417d Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Mon, 2 May 2005 17:48:20 +0000 Subject: [PATCH] Tweaked the API. --- .../rb_esmart_file_dialog.c | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/esmart_file_dialog/rb_esmart_file_dialog.c b/src/esmart_file_dialog/rb_esmart_file_dialog.c index ad61a52..a45d3a4 100644 --- a/src/esmart_file_dialog/rb_esmart_file_dialog.c +++ b/src/esmart_file_dialog/rb_esmart_file_dialog.c @@ -1,5 +1,5 @@ /* - * $Id: rb_esmart_file_dialog.c 336 2005-05-02 17:29:52Z tilman $ + * $Id: rb_esmart_file_dialog.c 337 2005-05-02 17:48:20Z tilman $ * * Copyright (C) 2005 Tilman Sauerbeck (tilman at code-monkey de) * @@ -32,6 +32,9 @@ typedef struct { VALUE edje; } RbFileDialog; +static void on_action (void *data, Evas_Object *edje, + Esmart_File_Dialog_Op op); + static void c_mark (RbFileDialog *e) { c_evas_object_mark (&e->real); @@ -54,6 +57,11 @@ static VALUE c_new (VALUE klass, VALUE evas, VALUE edj) VALUE self, argv[1]; RbFileDialog *fd = NULL; + if (!rb_block_given_p ()) { + rb_raise (rb_eStandardError, "no block given"); + return Qnil; + } + CHECK_CLASS (evas, cEvas); StringValue (edj); GET_OBJ (evas, RbEvas, e); @@ -68,9 +76,12 @@ static VALUE c_new (VALUE klass, VALUE evas, VALUE edj) argv[0] = evas; rb_obj_call_init (self, 1, argv); - fd->callback = Qnil; + fd->callback = rb_block_proc (); fd->edje = Qnil; + esmart_file_dialog_callback_add (fd->real.real, on_action, + (void *) fd->callback); + return self; } @@ -105,21 +116,6 @@ static void on_action (void *data, Evas_Object *edje, rb_funcall ((VALUE) data, rb_intern ("call"), 1, ID2SYM (sym)); } -static VALUE c_on_action (VALUE self) -{ - GET_OBJ (self, RbFileDialog, fd); - - if (!rb_block_given_p ()) - return Qnil; - - fd->callback = rb_block_proc (); - - esmart_file_dialog_callback_add (fd->real.real, on_action, - (void *) fd->callback); - - return Qnil; -} - static VALUE c_edje_get (VALUE self) { Evas_Object *e; @@ -184,7 +180,6 @@ 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_method (c, "on_action", c_on_action, 0); 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); -- 2.30.2