Re: GtkPlug for Windows

From: Date: Wed, 31 Jan 2007 17:30:21 +0000
Subject: Re: GtkPlug for Windows
References: 1 2 3  Groups: php.gtk.dev 
Request: Send a blank email to php-gtk-dev+get-3653@lists.php.net to get a copy of this message
Hi, There is a reason that we do:
     wrapped_obj = g_object_new(phpg_gtype_from_zval(this_ptr), NULL);
Instead of:
     wrapped_obj = gtk_plug_new(socket_id);
Either one creates GtkPlug object under normal circumstances. The difference appears when you try to subclass GtkPlug class in PHP-land and register it as a Gtk+ type. Now, since you have to call parent's constructor, the first call would properly get the gtype from your custom class and create your custom Gtk+ object. The second call would erroneously create GtkPlug. I think that we do not need the gtk_plug_construct() override. Just incorporate that call into the GtkPlug constructor. -Andrei On Jan 30, 2007, at 10:26 AM, Elizabeth Smith wrote:
Here's a fixed version of the override for gtkplug constructor (the current override doesn't work at all - go ahead try it, you get "internal object not found") - thanks to anant for the help I added a construct method initially because ruby/gnome has it. Pygtk doesn't - it doesn't really matter I was simply checking parity with other language wrappers. If you don't think it's needed then it doesn't need to be in - whatever. Thanks, Elizabeth Smith Index: gtk.overrides =================================================================== RCS file: /repository/php-gtk/ext/gtk+/gtk.overrides,v retrieving revision 1.235 diff -u -r1.235 gtk.overrides --- gtk.overrides 23 Jan 2007 18:26:08 -0000 1.235 +++ gtk.overrides 30 Jan 2007 18:23:31 -0000 @@ -4114,28 +4114,36 @@ %% {{{ GtkPlug %% +add-arginfo GtkPlug construct +static +ZEND_BEGIN_ARG_INFO_EX(ARGINFO_NAME, 0, 0, 1)
+    ZEND_ARG_INFO(0, socket_id)
+    ZEND_ARG_OBJ_INFO(0, display, GdkDisplay, 1)
+ZEND_END_ARG_INFO(); + +%% override gtk_plug_new PHP_METHOD {
     gulong socket_id;
     zval *display = NULL;
-    GObject *wrapped_obj = NULL;
-
+    GtkWidget *wrapped_obj = NULL;
+
     if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "i|O", &socket_id, &display))
         PHPG_THROW_CONSTRUCT_EXCEPTION(GtkPlug);
-    wrapped_obj = g_object_new(phpg_gtype_from_zval(this_ptr), NULL);
-
     if (display) {
-        gtk_plug_construct_for_display(GTK_PLUG(PHPG_GOBJECT(this_ptr)),
-                                       GDK_DISPLAY(PHPG_GOBJECT(display)), socket_id);
+        wrapped_obj = gtk_plug_new_for_display(GDK_DISPLAY(PHPG_GOBJECT(display)), socket_id);
+
     } else {
-        gtk_plug_construct(GTK_PLUG(PHPG_GOBJECT(this_ptr)), socket_id);
+        wrapped_obj = gtk_plug_new(socket_id);
     }
- +
     if (!wrapped_obj) {
         PHPG_THROW_CONSTRUCT_EXCEPTION(GtkPlug);
     }
+
+    phpg_gobject_new(&this_ptr, (GObject *) wrapped_obj TSRMLS_CC);
} %% }}} -- PHP-GTK Development Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.gtk.dev (#3653) next »