w3-tools.com - Free Webmaster Tools and Resources
 
w3-tools.com - Free Webmaster Tools and Resources
 Free Webmaster Tools and Resources

 



PHP-GTK Manual

This manual is provided as a courtesy. It is not an official source. Please check gtk.php.net for updated information.

PHP-GTK Manual

PHP-GTK Manual

The good news: Unlike the drop problems, all tested programs (Konqueror, Kate, Firefox, Opera, Nautilus) seem to be able to handle correct URIs dragged to them in the right way. Even Firefox accepts text/uri-list data.

The first step is again to tell the widget that it has the ability to act as a source for drag data. Furthermore, we need to provide the data we want to drag, which can be done by connecting the widget to the "drag-data-get" signal.

We told the widget the following:

Next is to provide the data for the drop target in the dragDataGet function:

The data are passed by overwriting the selection data via the set() method of the selection_data. As we want to follow the standards, the file name has to be converted to a full-flagged url-encoded URI, with the terminating \r\n at the end of the line. When nothing is selected in the tree, we don't change the selection data.

When trying to drag a file to your favorite application, you will note that nothing happens. Why? The URI passed to the program looks like that: file%3A%2F%2Flocalhost%2Fdata%2Fphp-gtk. Yes, urlencode doesn't take care of the character's meaning in the URI. Now it would cost some effort to make a function which does a correct encoding while taking care of special characters, as http URIs can contain slashes in a parameter which would have to be encoded, but slashes in the filename not. For that reason, only a simple back-translation of some chars is done after urlencoding the string:

With that, we can change our dragDataGet function:

$selection_data->set($selection_data->target, 8, $this->pathurlencode($this->getUriFromFile($file)) . "\r\n");

Newsletter

Join to our newsletter and receive news and updates about our site.
Your name: 
E-mail address: 
Action: 
 

Hosted by

Search

Google
Web w3-tools.com

Links

  What is my IP? Find your IP address!     Valid XHTML 1.0 Transitional  
Copyright © 2006. by w3-tools.com. All rights reserved