Re: php source q's
| From: | Andrei Zmievski | Date: | Mon, 25 Jul 2005 16:58:33 +0000 |
| Subject: | Re: php source q's | ||
| References: | 1 2 | Groups: | php.gtk.dev |
| Request: | Send a blank email to php-gtk-dev+get-1468@lists.php.net to get a copy of this message | ||
You have to accept a parameter of type "a" in php_gtk_parse_args() and then iterate through it and add elements to gchar** array. Something like:
override gtk_combo_set_popdown_strings
PHP_FUNCTION(gtk_combo_set_popdown_strings)
{
zval *php_list, **item;
GList *list = NULL;
#ifdef PHP_WIN32
gchar *utf8_text = NULL;#endif
NOT_STATIC_METHOD();
if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "a/", &php_list))
return;
zend_hash_internal_pointer_reset(Z_ARRVAL_P(php_list));
while (zend_hash_get_current_data(Z_ARRVAL_P(php_list), (void **)&item) == SUCCESS) {
convert_to_string_ex(item);
#ifdef PHP_WIN32
utf8_text = g_convert(Z_STRVAL_PP(item), Z_STRLEN_PP(item), "UTF-8", GTK_G(codepage), NULL, NULL, NULL);
list = g_list_append(list, utf8_text);
#else
list = g_list_append(list, Z_STRVAL_PP(item));#endif
zend_hash_move_forward(Z_ARRVAL_P(php_list));
}
gtk_combo_set_popdown_strings(GTK_COMBO(PHP_GTK_GET(this_ptr)), list);
g_list_free(list);
RETURN_TRUE;
}
But this code is from PHP-GTK 1 so it might need to be adjusted.
-Andrei
On Jul 24, 2005, at 4:39 AM, Simon wrote:
how to grab an array passed as an argument ,& convert it to the correct type ? Yes I did look at the php documentation but totally confused .. there are a few Dialog functions that could be cleaned up if only I had a clue what I was doing ;) ... e.g. I want to learn /*********************************************************/ static PHP_METHOD(GtkAboutDialog, set_documenters) {gchar *doccers[] = { "Andrei", "Steph", "Christian", "Scott...etc", NULL }; zend_bool free_doccers;gtk_about_dialog_set_documenters(GTK_ABOUT_DIALOG(PHPG_GOBJECT(this_ptr)), doccers);if (free_doccers) g_free(doccers);} /*****************************************************/ The above works in as much that the doccers array is successfully passed to the dialog (and the credits button appears) , I think I have ints worked out ~ but what is the process for grabbing an array argument & then converting to the expected type ?gchar**? Regards, Simon. --PHP-GTK Development Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php