[Lazarus] GTK2: Drag files to other applications (to the file manager, Thunar, Nautilus, etc)

Graeme Geldenhuys graemeg.lists at gmail.com
Thu Aug 23 17:32:52 CEST 2012


Hi,

On 22 August 2012 14:20, Hans-Peter Diettrich <DrDiettrich1 at aol.com> wrote:
>
>
> How do you intend to communicate your type to the world outside?
>
> Mime types are nice, but useful only when the receiver understands them -
> not very likely on Windows :-(

fpGUI and Qt code are open source, you are welcome to browse them to
see how we accomplish that magic. And by the way, more and more
Windows apps are starting to use mime types for DND because they
understand how well it works in emails and on platforms like X11.
After all, mime types are a well know standard.

But fpGUI (and Qt) doesn't drop those programs that don't understand
mime types. We simply map (behind the scenes) well know mime type to
well know Windows Clipboard/DND types too, then offer all types to the
receiving end of the DND action. So even though you drag 'txt/plain'
data, that will also map to Windows TEXT etc. The mapping works in
both directions, but fpGUI developers only need to use mime types in
their applications.

For example, here is a snippet of code showing Windows clipboard types
being mapped to mime types.

  { replace known clipboard formats with mime types }
  if CFFormat = 'CF_TEXT' then
    Result := 'text/plain'
  else if CFFormat = 'CF_UNICODETEXT' then
    Result := 'text/plain'
  else if CFFormat = 'CF_OEMTEXT' then
    Result := 'text/plain'
  else if CFFormat = 'CF_HDROP' then
    Result := 'text/uri-list'
  else if CFFormat = 'CF_RICHTEXT' then
    Result := 'text/html'
  else
    Result := CFFormat;



Next time, feel free to browse the fpGUI source code for more answers.

-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net




More information about the Lazarus mailing list