PHP-GTK.eu End of Life and GDPR

If you're reading the PHP-GTK.eu community site these days, you certainly noticed that not a single piece of significant content was created since 2015, and not much since 2013.

Whatever this may mean for PHP-GTK itself is another issue, but for the site itself, it means it ceased to be relevant about 5 years ago, and it's time to move on for the site members. Since the site contains non-anonymous user, it will fall under the new EU GDPR regulations entering into force on 2018-05-25, and there is no point for me to spend time on evolving the site towards compliance when no one is actually using it.

So here is the EOL announcement: the site will be shutting down on 2018-05-24 and its data will taken offline.

A static version of the articles may be published again at some point here or elsewhere, but I wouldn't hold my breath on it. So if you have even some interest in the site content, be sure to copy/paste the pages of interest before it goes dark on 2018-05-24. Or contact me if you want a copy of the files and content, or check my blog for newer content.

Thanks all for participating, it's been a pleasure while it lasted.

FGM

Getting (x,y) coordinates when clicking on images

I wrote an application where the user clicks on a GtkImage, and I want to know *where* the user clicked. Here's a simple object extending GtkAlignment.

I'm extending GtkAlignment, because you have to place the image in 0,0 to get the correct coordinates. Also, keep in mind that (0,0) is the top left corner of the image.

<?php
class xyGtkImage extends GtkAlignment {
    var
$eventbox;
    var
$image;  

   
    function
__construct($imagefile=NULL)
    {
       
GtkAlignment::__construct(0,0,0,0);
       
       
// create a new eventbox
       
$this->eventbox = &new GtkEventBox;
       
$this->add($this->eventbox);
       
$this->eventbox->set_events(Gdk::BUTTON_PRESS_MASK);
       
$this->eventbox->connect ('button-press-event', array($this, "print_coordinates"));
       
       
// creating the gtkimage
       
$this->image = &new GtkImage();
       
       
// if you set $imagefile then image will be automatically loaded
       
if ($imagefile !== NULL ) $this->image->set_from_file($imagefile);
       
$this->eventbox->add ($this->image);
    }
   
    function
print_coordinates($widget, $event)
    {
        echo
"You have just clicked on (" . $event->x . "," . $event->y .")\n";
    }
       
   
}
?>

Using the class is pretty simple :D

<?php

$window
= &new GtkWindow();
$window->set_position(Gtk::WIN_POS_CENTER);
$window->set_default_size (640, 480);
$window->set_title("xyGtkImage Example");
$window->connect('destroy', 'close_win');

$img = new xyGtkImage('/path/to/yourimage.png');
$window->add($img);


$window->show_all();
gtk::main();
function
close_win ()
{
   
gtk::main_quit();
}
?>