PHP-GTK2 - please test build - Instructions to help out.
| From: | Alan Knowles | Date: | Sat, 27 Sep 2003 10:57:30 +0000 |
| Subject: | PHP-GTK2 - please test build - Instructions to help out. | ||
| Groups: | php.gtk.dev | ||
| Request: | Send a blank email to php-gtk-dev+get-540@lists.php.net to get a copy of this message | ||
GTK2 Full Status - And Instructions for helping out...
At present, PHP-GTK for Gtk2 is a working extension to some degree.... On the +ve side:
- It should build against current CVS of PHP5 (eg. php-src HEAD)
- It has 1400 functions/methods auto generated from the defs file.
(gtk1 has 1000)
- It runs a slightly modified hello.php & fires up gtk.php from tests.
I have just added the base code for callbacks aka $obj->connect($signal...)
Next on the TODO list:
- argumemnt parsing: - when the connect callsback, it sends argments via g_closure_marshal. - these need converting into php variables.. - this is one of the biger changes in gtk1/gt2 - and alot of the code in main/gtk_object.c needs modifying to fix this..
- more testing.. - and understaning of marshalling .. - at present it appears to work.. - although it definatly needs more attention (eg. making sure it's not leaking memory somewhere..)
- GObject.. - more support for GObject in the base code.. - all Gdk & Gtk objects are based off of GObject now.. - so It should be alot simpler to wrap some of the simpler objects that used to be structs..
---------- BIG JOB - that anyone can help out with --------------
As you can guess Gtk has a huge number of widgets and methods.
The php-Gtk build process is based around automatically building the bindings from the C header files. - however, you can see in the gtk1 bindings that the gtk.overrides file modifies the default behaviour for a large number of widgets..
A simple example of this is GtkButton.. - the standard C code to create button is
gtk_button_new();
- this is the default constructor for the widget (NOTE THAT THERE ARE NO ARGUMENTS), and is autogenerated as
-----------------------------
PHP_FUNCTION(gtk_button_new)
{
GtkObject *wrapped_obj;
NOT_STATIC_METHOD();
if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "")) {
php_gtk_invalidate(this_ptr);
return;
}
wrapped_obj = (GtkObject *)gtk_button_new();
if (!wrapped_obj) {
php_error(E_WARNING, "%s(): could not create GtkButton object",
get_active_function_name(TSRMLS_C));
php_gtk_invalidate(this_ptr);
return;
}
php_gtk_object_init(wrapped_obj, this_ptr);} ----------------------------- However in gtk1 - you are able to send a parameter like $x = new GtkButton('the label'); so the gtk_button_new code is defined in gtk.overrides as: ------------------------------------- PHP_FUNCTION(gtk_button_new) {
GtkObject *wrapped_obj;
gchar *text = NULL;
#ifdef PHP_WIN32
gchar *utf8_text = NULL;#endif
NOT_STATIC_METHOD();
if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "|s", &text)) {
php_gtk_invalidate(this_ptr);
return;
}
if (text) {
#ifdef PHP_WIN32
utf8_text = g_convert(text, strlen(text), "UTF-8", GTK_G(codepage), NULL, NULL, NULL);
wrapped_obj = (GtkObject *)gtk_button_new_with_label(utf8_text);
if (utf8_text) g_free(utf8_text);
#else
wrapped_obj = (GtkObject *)gtk_button_new_with_label(text);#endif
}
else
wrapped_obj = (GtkObject *)gtk_button_new();
if (!wrapped_obj) {
php_error(E_WARNING, "%s(): could not create GtkButton object",
get_active_function_name(TSRMLS_C));
php_gtk_invalidate(this_ptr);
return;
}
php_gtk_object_init(wrapped_obj, this_ptr);} ------------------------------------- Notice (apart from the windows #ifdefs - there is very little different abou the two.. - the key difference being the reading of arguments.. ------------------------------------- if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "|s", &text)) { ------------------------------------- and wheather or not it calls the method.. ------------------------------------- gtk_button_new_with_label(text) or gtk_button_new() ------------------------------------- WHAT TO DO.... If anyone wants to help out.. all they need to do is pick an Object look in gtk.overrides from current CVS, for all the methods that have been overridden for that object..- add the code to the end of the gtk.overrides in the new gtk2 version. and see if it builds.. -- if you can get any or all of the methods for an object to build.. - let me know and I will add it to the new overrides file. The current working code is at.. http://devel.akbkhome.com/php-gtk2-0.4.tgz Let me know if you interested in helping out. Regards Alan -- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com