GtkBuilder does not call __construct() for custom widgets

View: New views
1 Messages — Rating Filter:   Alert me  

GtkBuilder does not call __construct() for custom widgets

by Pistiolis Konstantinos-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm trying to add custom php-gtk widgets to glade-3
- I've compiled a php with the embed sapi and linked it
with a library of my own which includes the php code.
- added the .so to the glade path
- added the needed catalogue files
It seems to be ok with glade but there is a major problem:

GtkBuilder creates the php-gtk Derived objects but does not
call their constructor (their __construct() method in php)

check this code:
<?php

class MyWin extends GtkWindow {
        public function __construct() {
                echo "MyWin::__construct(): constructor called\n";
                parent::__construct();
        }
}
GObject::register_type('MyWin');
$xml = '<interface><object class="MyWin"
id="window1"></object></interface>';

$builder = new GtkBuilder();
$builder->add_from_string($xml);

$win = $builder->get_object('window1');

$win->connect_simple('destroy', array('Gtk', 'main_quit'));
$win->show_all();
Gtk::main();
?>

no conctructor is called
Same thing works in pygtk:
import gtk

class MyWin(gtk.Window):
  __gtype_name__ = 'MyWin'

  def __init__(self):
    print "MyWin.__init__(): constructor called"
    super(MyWin, self).__init__()

xml = '<interface><object class="MyWin"
id="window1"></object></interface>'

builder = gtk.Builder()
builder.add_from_string(xml)

win = builder.get_object('window1')

win.connect('destroy', gtk.main_quit)
win.show_all()
gtk.main()


Isn't this a bug?
I have tried to check it from the php-gtk code but I don't know
zend so I can't do much.

Con




--
PHP-GTK Development Mailing List (http://gtk.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php