01 May 2013 - After the site upgrade, all passwords were reset and you will need to ask the site for a login reset on your first connection.

Extending widgets with PHP

primitive widget

  • you need to extend GtkWidget
  • you need to write many methods
  • your constructor MUST NOT call parent::__construct, or you will have an error (Fatal error: Cannot instantiate abstract class) for primitive widgets (abstract ?) (GtkWidget),
<?php
# simple code fragment (need to be completed)
class PrimitiveWidget extends GtkWidget {
  function
__construct() {
   
# Fatal error: Cannot instantiate abstract class
    # PrimitiveWidget in line ... (__construct() line call)
    # parent::__construct();
 
}
}

$w = new PrimitiveWidget();
?>

composite widget

  • you can extend from GtkVbox for example
  • constructor will have to create all needed objects,
  • no need to write many methods,
  • here is a working sample code :
<?php
class CompositeWidget extends GtkVbox {
  function
__construct() {
   
parent::__construct();
   
$this->label = new GtkLabel('test composite widget');
   
$this->add($this->label);
   
$this->add(new GtkLabel('an other label'));
   
$this->add(new GtkButton('Test me'));
   
$this->set_border_width(10);
  }
}

$win = new GtkWindow();
$win->set_title('Composite Widget extension example');
$win->connect_simple('destroy', array('gtk', 'main_quit'));

$composite_widget = new CompositeWidget();

$vbox = new GtkVBox();
$win->add($vbox);

$vbox->pack_start($composite_widget, true);

$win->show_all();
Gtk::main();
?>

links