com gtk/php-gtk: GtkTreeSelection::set_select_function : ext/gtk+/gtktreeview.overrides
[email protected] (David Soria Parra)
| Newsgroups | php.gtk.cvs |
|---|---|
| Message-ID | <[email protected]> |
Commit: dedc8764a46ff50a47b2506f74995b3af6769136 Author: Christian Weiske <[email protected]> Thu, 15 Jun 2006 06:30:51 +0000 Parents: 21403874bde3c429990b714b75382561b2e2b33a Branches: master Link: http://git.php.net/?p=gtk/php-gtk.git;a=commitdiff;h=dedc8764a46ff50a47b2506f74995b3af6769136 Log: GtkTreeSelection::set_select_function Changed paths: M ext/gtk+/gtktreeview.overrides Diff: dedc8764a46ff50a47b2506f74995b3af6769136 diff --git a/ext/gtk+/gtktreeview.overrides b/ext/gtk+/gtktreeview.overrides index c200258..a9d8cba 100644 --- a/ext/gtk+/gtktreeview.overrides +++ b/ext/gtk+/gtktreeview.overrides @@ -16,6 +16,7 @@ static gboolean phpg_tree_model_filter_visible_func_marshal(GtkTreeModel *model, static gboolean phpg_tree_view_row_separator_func_marshal (GtkTreeModel *model, GtkTreeIter *iter, gpointer data); static gboolean phpg_tree_view_column_drop_func_marshal (GtkTreeView *tree_view, GtkTreeViewColumn *column, GtkTreeViewColumn *prev_column, GtkTreeViewColumn *next_column, gpointer data); static void phpg_tree_selection_foreach_func_marshal (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data); +static gboolean phpg_tree_selection_func_marshal (GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, gpointer data); %% post-registration GtkListStore @@ -1594,6 +1595,97 @@ PHP_METHOD phpg_cb_data_destroy(cb_data); } +%% +add-arginfo GtkTreeSelection set_select_function +static +ZEND_BEGIN_ARG_INFO(ARGINFO_NAME, 0) + ZEND_ARG_INFO(0, callback) +ZEND_END_ARG_INFO(); + +%% +override gtk_tree_selection_set_select_function +static gboolean phpg_tree_selection_func_marshal(GtkTreeSelection *selection, + GtkTreeModel *model, + GtkTreePath *path, + gboolean path_currently_selected, + gpointer data) +{ + phpg_cb_data_t *cbd = (phpg_cb_data_t *) data; + zval *retval = NULL; + zval ***args = NULL; + int n_args = 0; + char *callback_name; + zval *php_selection = NULL, *php_model = NULL, *php_path = NULL, *php_path_currently_selected; + gboolean allow_toggle = TRUE; + TSRMLS_FETCH(); + + if (!zend_is_callable(cbd->callback, 0, &callback_name)) { + php_error(E_WARNING, "Unable to invoke callback '%s' specified in %s on line %ld", callback_name, cbd->src_filename, cbd->src_lineno); + efree(callback_name); + return 0; + } + + phpg_gobject_new(&php_selection, (GObject*)selection TSRMLS_CC); + phpg_gobject_new(&php_model, (GObject*)model TSRMLS_CC); + phpg_tree_path_to_zval(path, &php_path TSRMLS_CC); + MAKE_STD_ZVAL(php_path_currently_selected); + ZVAL_BOOL(php_path_currently_selected, path_currently_selected); + + args = php_gtk_hash_as_array_offset(cbd->user_args, 4, &n_args); + args[0] = &php_selection; + args[1] = &php_model; + args[2] = &php_path; + args[3] = &php_path_currently_selected; + + call_user_function_ex(EG(function_table), NULL, cbd->callback, &retval, n_args, args, 0, NULL TSRMLS_CC); + + zval_ptr_dtor(&php_selection); + zval_ptr_dtor(&php_model); + zval_ptr_dtor(&php_path); + zval_ptr_dtor(&php_path_currently_selected); + + if (retval) { + allow_toggle = zend_is_true(retval); + zval_ptr_dtor(&retval); + } else { + allow_toggle = TRUE; + } + + phpg_handle_marshaller_exception(TSRMLS_C); + + efree(callback_name); + efree(args); + + return allow_toggle; +} + +PHP_METHOD +{ + zval *php_callback, *extra; + phpg_cb_data_t *cb_data; + GtkTreeSelectionFunc callback; + + NOT_STATIC_METHOD(); + + if (!php_gtk_parse_varargs(ZEND_NUM_ARGS(), 1, &extra, "V", &php_callback)) + return; + + if (php_callback) { + if (Z_TYPE_P(php_callback) == IS_NULL) { + cb_data = NULL; + callback = NULL; + } else { + zval_add_ref(&php_callback); + cb_data = phpg_cb_data_new(php_callback, extra TSRMLS_CC); + callback = (GtkTreeSelectionFunc)phpg_tree_selection_func_marshal; + } + } + + gtk_tree_selection_set_select_function(GTK_TREE_SELECTION(PHPG_GOBJECT(this_ptr)), + callback, + cb_data, phpg_cb_data_destroy); +} + %% }}} %% {{{ GtkTreeSortable