com gtk/php-gtk: - Add set_column_types() method fo r GtkListStore and GtkTreeStore. - Allow construc tors of those classes to take 0 arguments.: ext/gtk+/gtktreeview.overrides
[email protected] (David Soria Parra) Fri, 07 Apr 2006 05:18:57 +0000
| Newsgroups | php.gtk.cvs |
|---|---|
| Message-ID | <[email protected]> |
Commit: 63e6877616411a3fa82118c0fdabf8e36209ed05 Author: Andrei Zmievski <[email protected]> Fri, 7 Apr 2006 05:18:57 +0000 Parents: 3527207aeeb0976f35e3c64dd40e375cf1f64a2d Branches: master Link: http://git.php.net/?p=gtk/php-gtk.git;a=commitdiff;h=63e6877616411a3fa82118c0fdabf8e36209ed05 Log: - Add set_column_types() method for GtkListStore and GtkTreeStore. - Allow constructors of those classes to take 0 arguments. Changed paths: M ext/gtk+/gtktreeview.overrides Diff: 63e6877616411a3fa82118c0fdabf8e36209ed05 diff --git a/ext/gtk+/gtktreeview.overrides b/ext/gtk+/gtktreeview.overrides index 8f92644..3f10b51 100644 --- a/ext/gtk+/gtktreeview.overrides +++ b/ext/gtk+/gtktreeview.overrides @@ -203,15 +203,11 @@ PHP_METHOD GObject *wrapped_obj; int i, argc = ZEND_NUM_ARGS(); - if (argc == 0) { - php_error(E_WARNING, "%s::%s() requires at least 1 argument", - get_active_class_name(NULL TSRMLS_CC), get_active_function_name(TSRMLS_C)); - PHPG_THROW_CONSTRUCT_EXCEPTION(GtkListStore); + if (argc > 0) { + args = php_gtk_func_args(argc); + column_types = emalloc(argc * sizeof(GType)); } - args = php_gtk_func_args(argc); - - column_types = emalloc(argc * sizeof(GType)); for (i = 0; i < argc; i++) { column_types[i] = phpg_gtype_from_zval(*args[i]); if (column_types[i] == 0) { @@ -222,8 +218,12 @@ PHP_METHOD wrapped_obj = g_object_newv(phpg_gtype_from_zval(this_ptr), 0, NULL); gtk_list_store_set_column_types(GTK_LIST_STORE(wrapped_obj), argc, column_types); - efree(column_types); - efree(args); + + if (argc > 0) { + efree(column_types); + efree(args); + } + if (!wrapped_obj) { PHPG_THROW_CONSTRUCT_EXCEPTION(GtkListStore); } @@ -232,6 +232,39 @@ PHP_METHOD } %% +override gtk_list_store_set_column_types +PHP_METHOD +{ + zval *php_types, **item; + GType *column_types; + int i, n; + + NOT_STATIC_METHOD(); + + if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "a", &php_types)) { + return; + } + + n = zend_hash_num_elements(Z_ARRVAL_P(php_types)); + column_types = safe_emalloc(n, sizeof(GType), 0); + for (i = 0, zend_hash_internal_pointer_reset(Z_ARRVAL_P(php_types)); + zend_hash_get_current_data(Z_ARRVAL_P(php_types), (void**)&item) == SUCCESS; + zend_hash_move_forward(Z_ARRVAL_P(php_types)), i++) { + + column_types[i] = phpg_gtype_from_zval(*item); + if (column_types[i] == 0) { + efree(column_types); + php_error(E_WARNING, "could not set column types for GtkListStore"); + return; + } + } + + gtk_list_store_set_column_types(GTK_LIST_STORE(PHPG_GOBJECT(this_ptr)), i, column_types); + + efree(column_types); +} + +%% add-arginfo GtkListStore append static ZEND_BEGIN_ARG_INFO_EX(ARGINFO_NAME, 0, 0, 0) @@ -511,15 +544,11 @@ PHP_METHOD GObject *wrapped_obj; int i, argc = ZEND_NUM_ARGS(); - if (argc == 0) { - php_error(E_WARNING, "%s::%s() requires at least 1 argument", - get_active_class_name(NULL TSRMLS_CC), get_active_function_name(TSRMLS_C)); - PHPG_THROW_CONSTRUCT_EXCEPTION(GtkTreeStore); + if (argc > 0) { + args = php_gtk_func_args(argc); + column_types = emalloc(argc * sizeof(GType)); } - args = php_gtk_func_args(argc); - - column_types = emalloc(argc * sizeof(GType)); for (i = 0; i < argc; i++) { column_types[i] = phpg_gtype_from_zval(*args[i]); if (column_types[i] == 0) { @@ -530,8 +559,12 @@ PHP_METHOD wrapped_obj = g_object_newv(phpg_gtype_from_zval(this_ptr), 0, NULL); gtk_tree_store_set_column_types(GTK_TREE_STORE(wrapped_obj), argc, column_types); - efree(column_types); - efree(args); + + if (argc > 0) { + efree(column_types); + efree(args); + } + if (!wrapped_obj) { PHPG_THROW_CONSTRUCT_EXCEPTION(GtkTreeStore); } @@ -540,6 +573,39 @@ PHP_METHOD } %% +override gtk_tree_store_set_column_types +PHP_METHOD +{ + zval *php_types, **item; + GType *column_types; + int i, n; + + NOT_STATIC_METHOD(); + + if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "a", &php_types)) { + return; + } + + n = zend_hash_num_elements(Z_ARRVAL_P(php_types)); + column_types = safe_emalloc(n, sizeof(GType), 0); + for (i = 0, zend_hash_internal_pointer_reset(Z_ARRVAL_P(php_types)); + zend_hash_get_current_data(Z_ARRVAL_P(php_types), (void**)&item) == SUCCESS; + zend_hash_move_forward(Z_ARRVAL_P(php_types)), i++) { + + column_types[i] = phpg_gtype_from_zval(*item); + if (column_types[i] == 0) { + efree(column_types); + php_error(E_WARNING, "could not set column types for GtkTreeStore"); + return; + } + } + + gtk_tree_store_set_column_types(GTK_TREE_STORE(PHPG_GOBJECT(this_ptr)), i, column_types); + + efree(column_types); +} + +%% add-arginfo GtkTreeStore append static ZEND_BEGIN_ARG_INFO_EX(ARGINFO_NAME, 0, 0, 0)