| ユーザフォーラムで議論/質問 | マニュアル検索 | ハイライト | ハイライトオフ | ポータル | php spot |
It seems that Gtk 1.x on windows allows you to receive drops from other windows programs, but not to drag outside the application. This means you can use DnD inside your PHP-Gtk application, but use drop only when communicating with other programs. 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. 例 4.7. Setting up the drag source
We told the widget the following: Next is to provide the data for the drop target in the dragDataGet function: 例 4.8. Setting the data to drag
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:
|
各種マニュアル:
PHPマニュアル |
PEARマニュアル |
Smarty(英語)マニュアル |
PHP-GTKマニュアル |
「Dragging files to other applications」をGoogle検索
|