Book Annotation - Pro PHP-GTK - Listing 5-8 - Gdk-WARNING **: gdkwindow-win32.c:1089: SetWindowLong failed
I have been learning PHP-GTK. I was reading ‘Pro PHP-GTK’ a book by Scott Mattocks, published by Apress (2006) and was trying out the last code example of Chapter 5, Listing 5-8.
It was very exciting to seeĀ my first splash screen come up (i used my own logo and it looked sparkly). On the face of it, the application worked exactly as expected. However, I noticed a Gdk warning appear in my command line. It said:
(php.exe:3220): Gdk-WARNING **: gdkwindow-win32.c:1089: SetWindowLong failed: Not enough storage is available to process this command.
I am PHP version 5.2.9 and GTK Version 2.12.9 which i installed using the piGii installer
I was unsure if I had written a typo as I copied the source code from the book. So, I decided to run the official book source code that I had downloaded from the Apress site. (booksourcecode\Chapter05\listing5-9.php)
After a couple of tweaks to alter the, deprecated, ‘connect_object’ methods into ‘connect_simple’ methods, I ran the code.
Again, the application ran OK from the user’s perspective. However, the warning (see above) also appeared in the command line. So, it was not a typo of mine causing it.
I do not know enough about php-gtk to be able to understand why it occurs. But, after some tweaking of the code and experimentation, I found that I could prevent that warning from showing.
There are two ways to stop that warning:
- In the constructor of the class Crisscott_SplashScreen, change the argument of the set_decorated() method from false to true, OR
- Leave it being set as false and move that set_decorated() method further down the code, into the Crisscott_SplashScreen::start() method so that it is called after the show_all() method.
The second option is the only one I found that makes the sample application behave as we’d like it to.
<?php
//booksourcecode\Chapter05\listing5-9.php
class Crisscott_SplashScreen extends GtkWindow {
public $status;
public function __construct()
{
parent::__construct();
//commented out ‘cos moved down
//$this->set_decorated(false);
$this->set_size_request(300, 100);
//…
$this->connect_simple_after(’show’, array($this, ’startMainWindow’));
}
private function _populate()
{
//…left as is
}
public function start()
{
$this->show_all();
$this->set_decorated(false); //it works here
Gtk::main();
}
…
}
As I say, both these techniques stop the warning but i have no idea why. All I know is that set_decorated() and show_all() are having a little argument between themselves and there is some other mystery factor that is triggering the dispute between them (making this example throw a warning where other examples did not).
