1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --                 Copyright (C) 2000-2009, AdaCore                  -- 
  5. --                                                                   -- 
  6. -- This library is free software; you can redistribute it and/or     -- 
  7. -- modify it under the terms of the GNU General Public               -- 
  8. -- License as published by the Free Software Foundation; either      -- 
  9. -- version 2 of the License, or (at your option) any later version.  -- 
  10. --                                                                   -- 
  11. -- This library is distributed in the hope that it will be useful,   -- 
  12. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  13. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  14. -- General Public License for more details.                          -- 
  15. --                                                                   -- 
  16. -- You should have received a copy of the GNU General Public         -- 
  17. -- License along with this library; if not, write to the             -- 
  18. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  19. -- Boston, MA 02111-1307, USA.                                       -- 
  20. --                                                                   -- 
  21. -- -- -- -- -- -- -- -- -- -- -- --
  22. ----------------------------------------------------------------------- 
  23.  
  24. --  <description> 
  25. --  This package implements support for the selection mechanism (ie a way to 
  26. --  get a currently active selection anywhere on your Xserver or on your 
  27. --  Windows machine). 
  28. -- 
  29. --  This also acts as the low-level support for drag-and-drop, as described 
  30. --  in Gtk.Dnd. 
  31. -- 
  32. --  A lot of subprograms in this package work on Gdk_Atom types, instead of 
  33. --  strings. Converting from one to the other can easily be done through 
  34. --  calls to the subprograms in Gdk.Property (Atom_Intern and Atom_Name). 
  35. --  The reason we use Gdk_Atom is for efficiency, since comparing two integers 
  36. --  is of course faster than comparing two strings. 
  37. -- 
  38. --  The selection mechanism is the primary mechanism by which applications 
  39. --  can transfer data to each other on a given system. Even though both 
  40. --  applications must be visible on the same screen, this does not mean that 
  41. --  they can access the same files or ressources, since they might in fact 
  42. --  be running on different machines. You should always keep this in mind 
  43. --  when setting the data to be transfered. 
  44.  
  45. --  A selection is a essentially a named clipboard, identified by a string 
  46. --  interned as a Gdk_Atom. By claiming ownership of a selection, an 
  47. --  application indicates that it will be responsible for supplying its 
  48. --  contents. 
  49.  
  50. --  The contents of a selection can be represented in a number of formats, 
  51. --  called targets. Each target is identified by an atom. A list of all 
  52. --  possible targets supported by the selection owner can be retrieved by 
  53. --  requesting the special target TARGETS. When a selection is retrieved, the 
  54. --  data is accompanied by a type (an atom), and a format (an integer, 
  55. --  representing the number of bits per item). 
  56. -- 
  57. --  See also http://standards.freedesktop.org/clipboards-spec/ for 
  58. --  more information on the way selection works on X-Window systems. 
  59. -- 
  60. --  </description> 
  61. --  <c_version>2.8.17</c_version> 
  62. --  <group>Inter-Process communication</group> 
  63. --  <testgtk>create_selection.adb</testgtk> 
  64.  
  65. with Gdk.Types; 
  66. with Gdk.Pixbuf; 
  67. with Gtk.Widget; 
  68. with Gtkada.Types; 
  69. with GNAT.Strings; 
  70.  
  71. package Gtk.Selection is 
  72.  
  73.    type Selection_Data is new Gdk.C_Proxy; 
  74.    --  Contents of a selection or a drag-and-drop operation. 
  75.    --  This structure can only be created internally by GtkAda. However, you 
  76.    --  need to be able to access it to get the selection. 
  77.    --   - Selection and Target identify the request. 
  78.    --   - Type specifies the type of the return. 
  79.    --   - if Length is negative, the Data should be ignored. Otherwise, it 
  80.    --     contains the data itself. 
  81.    --   - Time gives the timestamp at which the data was sent. 
  82.  
  83.    --------------- 
  84.    -- Selection -- 
  85.    --------------- 
  86.  
  87.    subtype Gdk_Selection is Gdk.Types.Gdk_Atom; 
  88.    --  These are predefined atom values for several common selections. 
  89.    --  You are of course free to create new ones, but most of the time you 
  90.    --  should simply use Selection_Primary unless you foresee the need for 
  91.    --  multiple simultaneous selections. 
  92.    --  To access the clipboard on windows machines, you might need to create 
  93.    --  a new selection with Gdk.Property.Atom_Intern ("CLIPBOARD"); 
  94.  
  95.    Selection_Primary   : constant Gdk_Selection; 
  96.    Selection_Secondary : constant Gdk_Selection; 
  97.  
  98.    -------------------- 
  99.    -- Selection_Type -- 
  100.    -------------------- 
  101.  
  102.    subtype Gdk_Selection_Type is Gdk.Types.Gdk_Atom; 
  103.    --  Predefined atom values for selection types. 
  104.    --  Although the preferred way in GtkAda to indicate the type of a selection 
  105.    --  is to use mime types, these values are provided for compatibility with 
  106.    --  older X11 applications. 
  107.  
  108.    Selection_Type_Atom     : constant Gdk_Selection_Type; 
  109.    --  A Gdk_Atom (format=32 bits) 
  110.  
  111.    Selection_Type_Bitmap   : constant Gdk_Selection_Type; 
  112.    --  A Gdk_Bitmap Id (format=32 bits) 
  113.  
  114.    Selection_Type_Colormap : constant Gdk_Selection_Type; 
  115.    --  A colormap Id (format=32 bits) 
  116.  
  117.    Selection_Type_Drawable : constant Gdk_Selection_Type; 
  118.    --  A drawable Id (format=32 bits), ie the result of Gdk.Window.Get_Window. 
  119.  
  120.    Selection_Type_Integer  : constant Gdk_Selection_Type; 
  121.    --  An integer (format=32 bits) 
  122.  
  123.    Selection_Type_Pixmap   : constant Gdk_Selection_Type; 
  124.    --  A Gdk_Pixmap ID (format=32 bits) 
  125.  
  126.    Selection_Type_Window   : constant Gdk_Selection_Type; 
  127.    --  A Gdk_Window ID (format=32 bits) 
  128.  
  129.    Selection_Type_String   : constant Gdk_Selection_Type; 
  130.    --  A string encoded in Iso-latin1 format (format=8 bits per character) 
  131.  
  132.    ---------------- 
  133.    -- Gdk_Target -- 
  134.    ---------------- 
  135.  
  136.    subtype Gdk_Target is Gdk.Types.Gdk_Atom; 
  137.    --  Predefined atom values which are used to describe possible targets for 
  138.    --  a selection. Other atoms can be used, and the recommended practice for 
  139.    --  GtkAda is to to use mime types for this purpose. However, supporting 
  140.    --  these types may be useful for compatibility with older programs. 
  141.  
  142.    Target_Bitmap   : constant Gdk_Target; 
  143.    Target_Colormap : constant Gdk_Target; 
  144.    Target_Drawable : constant Gdk_Target; 
  145.    Target_Pixmap   : constant Gdk_Target; 
  146.    Target_String   : constant Gdk_Target; 
  147.  
  148.    ------------------ 
  149.    -- Target_Flags -- 
  150.    ------------------ 
  151.  
  152.    type Target_Flags is new Integer; 
  153.    --  Used to specify constraints on an entry 
  154.  
  155.    Target_No_Constraint : constant Target_Flags; 
  156.    --  No constraint is specified. 
  157.  
  158.    Target_Same_App      : constant Target_Flags; 
  159.    --  If this is set, the target will only be selected for drags within a 
  160.    --  single application. 
  161.  
  162.    Target_Same_Widget   : constant Target_Flags; 
  163.    --  If this is set, the target will only be selected for drags within a 
  164.    --  single widget. 
  165.  
  166.    ------------------ 
  167.    -- Target_Entry -- 
  168.    ------------------ 
  169.  
  170.    type Target_Entry is record 
  171.       Target : Gtkada.Types.Chars_Ptr; 
  172.       Flags  : Target_Flags; 
  173.       Info   : Guint; 
  174.    end record; 
  175.    --  A single type of data that can be supplied or received during a 
  176.    --  drag-and-drop or a selection. 
  177.    -- 
  178.    --  Target is a string that represents the drag type. This can be any 
  179.    --  string if you want to implement drag-and-drop inside your application. 
  180.    --  However, if you want to communicate with other external application, 
  181.    --  you should use MIME types, ie "text/plain", "text/uri-list", ... 
  182.    --  See the RFCs 2045, 2046, 2047, 2048, 2049 for more information on 
  183.    --  MIME types. 
  184.    -- 
  185.    --  For more information, see 
  186.    --  ftp://ftp.isi.edu/in-notes/iana/assignments/media-types/ 
  187.    -- 
  188.    --  Another set of supported names are the ones associated with the X 
  189.    --  Inter-Client Communications Conventions Manual (ICCCM). 
  190.    --  Here some of the default names and their meaning. See the ICCCM manual 
  191.    --  online for a complete list (for instance at 
  192.    --  http://www.tronche.com/gui/x/icccm/). 
  193.    -- 
  194.    --   - "TIMESTAMP"   (type Integer)  Timestamp used to acquire the selection 
  195.    --   - "TEXT"        (type Text)     Text in owner's encoding 
  196.    --   - "STRING"      (type String)   Iso Latin1 text 
  197.    --   - "PIXMAP"      (type Drawable) Pixmap Id 
  198.    --   - "BITMAP"      (type Bitmap)   Bitmap Id 
  199.    --   - "FOREGROUND"  (type Pixel)    Pixel Value 
  200.    --   - "BACKGROUND"  (type Pixel)    Pixel Value 
  201.    -- 
  202.    --  Info is an application-assigned integer (i.e. that you choose), that 
  203.    --  will be passed as a signal parameter for all the dnd-related signals, 
  204.    --  like "selection_get". This saves a lot of expensive string compares, 
  205.    --  and in fact replaced Target everywhere in your application expect in 
  206.    --  Source_Set and Dest_Set. 
  207.  
  208.    type Target_Entry_Array is array (Natural range <>) of Target_Entry; 
  209.  
  210.    Any_Target_Entry : Target_Entry_Array (1 .. 0); 
  211.    --  To be used for drop sites that accept any kind of data. 
  212.  
  213.    ----------------- 
  214.    -- Target_List -- 
  215.    ----------------- 
  216.  
  217.    type Target_List is new Gdk.C_Proxy; 
  218.    --  A list of targets. 
  219.    --  You can only manipulate this list through the functions below. 
  220.  
  221.    function Target_List_New (Targets : Target_Entry_Array) return Target_List; 
  222.    --  Create a new list of target, starting from an array. 
  223.  
  224.    procedure Target_List_Ref (List : Target_List); 
  225.    --  Increment the reference count for the list. 
  226.    --  You should almost never have to use this function, this is done 
  227.    --  transparently by GtkAda. 
  228.  
  229.    procedure Target_List_Unref (List : Target_List); 
  230.    --  Decrement the reference count for the list. 
  231.    --  You should almost never have to use this function, since everything is 
  232.    --  done transparently by GtkAda. 
  233.    --  As usual, the list is freed when the reference count reaches 0. 
  234.  
  235.    procedure Target_List_Add 
  236.      (List   : Target_List; 
  237.       Target : Gdk.Types.Gdk_Atom; 
  238.       Flags  : Guint; 
  239.       Info   : Guint); 
  240.    --  Add a new target to the list. 
  241.    --  You can for instance use the result of Get_Targets (Drag_Context) for 
  242.    --  the value of Target. 
  243.  
  244.    procedure Target_List_Add_Table 
  245.      (List    : Target_List; 
  246.       Targets : Target_Entry_Array); 
  247.    --  Add a new set of targets to the list. 
  248.  
  249.    procedure Target_List_Add_Text_Targets 
  250.      (List      : Target_List; 
  251.       Info      : Guint); 
  252.    --  Appends the text targets supported internally by gtk+ to List. 
  253.    --  All targets are added with the same info. 
  254.    --  Info will be passed back to the application. 
  255.  
  256.    procedure Target_List_Add_URI_Targets 
  257.      (List      : Target_List; 
  258.       Info      : Guint); 
  259.    --  Appends the URI targets supported internally by gtk+ to List. 
  260.    --  All targets are added with the same info. 
  261.  
  262.    procedure Target_List_Add_Image_Targets 
  263.      (List      : Target_List; 
  264.       Info      : Guint; 
  265.       Writable  : Boolean); 
  266.    --  Appends the image targets supported internally by gtk+ to List. 
  267.    --  All targets are added with the same info. 
  268.    --  If Writable is True, then only those targets for which gtk+ knows how to 
  269.    --  convert a Gdk_Pixbuf into the format are added. 
  270.  
  271.    procedure Target_List_Remove 
  272.      (List   : Target_List; 
  273.       Target : Gdk.Types.Gdk_Atom); 
  274.    --  Remove a specific target from the list. 
  275.  
  276.    procedure Target_List_Find 
  277.      (List   : Target_List; 
  278.       Target : Gdk.Types.Gdk_Atom; 
  279.       Info   : out Guint; 
  280.       Found  : out Boolean); 
  281.    --  Search for a specific target in the list. 
  282.    --  If the target was found, Found is set to True and Info contains the 
  283.    --  integer that was associated with the target when it was created. 
  284.  
  285.    -------------------- 
  286.    -- Selection_Data -- 
  287.    -------------------- 
  288.  
  289.    function Selection_Get_Type return Glib.GType; 
  290.    --  Return the internal type used for a selection 
  291.  
  292.    function Get_Selection (Selection : Selection_Data) return Gdk_Selection; 
  293.    --  Return the selection used (primary, clipboard, ...) 
  294.  
  295.    function Get_Target (Selection : Selection_Data) return Gdk.Types.Gdk_Atom; 
  296.    --  Return the target of the selection (ie a MIME string that identifies 
  297.    --  the selection). 
  298.  
  299.    function Get_Type (Selection : Selection_Data) return Gdk.Types.Gdk_Atom; 
  300.    --  Return the type of the selection, as defined in Gdk_Selection_Type, 
  301.    --  ie for compatibility with older X11 applications. 
  302.  
  303.    function Get_Format (Selection : Selection_Data) return Gint; 
  304.    --  Return the format of the data. 
  305.    --  The semantics depends on the type of data. For instance, for strings 
  306.    --  this is the number of bits per character. 
  307.  
  308.    function Get_Data (Selection : Selection_Data) return System.Address; 
  309.    --  Return the data of the selection. 
  310.    --  This should be ignored if Get_Length returns a value < 0. 
  311.  
  312.    function Get_Data_As_String (Selection : Selection_Data) return String; 
  313.    --  Return the data as a string. 
  314.    --  This is only a convenience function, since it simply creates a string 
  315.    --  from the return of Get_Data. 
  316.  
  317.    function Get_Length (Selection : Selection_Data) return Gint; 
  318.    --  Return the length of the data. 
  319.  
  320.    ---------------------------------- 
  321.    -- Setting and getting contents -- 
  322.    ---------------------------------- 
  323.  
  324.    function Set_Pixbuf 
  325.      (Selection : Selection_Data; 
  326.       Pixbuf    : Gdk.Pixbuf.Gdk_Pixbuf) return Boolean; 
  327.    --  Sets the contents of the selection from a pixbuf 
  328.    --  The pixbuf is converted to the form determined by 
  329.    --  Get_Target (Selection_Data). 
  330.    --  Returns True if the selection was successfully set. 
  331.  
  332.    function Get_Pixbuf 
  333.      (Selection : Selection_Data) return Gdk.Pixbuf.Gdk_Pixbuf; 
  334.    --  Gets the contents of the selection data as a pixbuf. 
  335.    --  Return value: if the selection data contained a recognized 
  336.    --  image type and it could be converted to a pixbuf, a 
  337.    --  newly allocated pixbuf is returned, otherwise null. 
  338.    --  If the result is non-null it must be freed with Unref. 
  339.  
  340.    function Targets_Include_Image 
  341.      (Selection : Selection_Data; Writable : Boolean := True) return Boolean; 
  342.    --  Given a Selection object holding a list of targets, determines if any of 
  343.    --  the targets in these targets can be used to provide a Gdk.Pixbuf. 
  344.    --  Writable: whether to accept only targets for which gtk+ knows how to 
  345.    --  convert a pixbuf into the format. 
  346.    --  Returns True if Selection holds a list of targets and a suitable 
  347.    --  target for images is included 
  348.  
  349.    function Set_Text 
  350.      (Selection : Selection_Data; 
  351.       Str       : UTF8_String) return Boolean; 
  352.    --  Sets the contents of the selection from a UTF-8 encoded string. 
  353.    --  The string is converted to the form determined by 
  354.    --  Get_Target (Selection_Data). 
  355.  
  356.    function Get_Text (Selection : Selection_Data) return UTF8_String; 
  357.    --  Gets the contents of the selection data as a UTF-8 string. 
  358.    --  Return value: if the selection data contained a recognized 
  359.    --  text type and it could be converted to UTF-8, the string is returned. 
  360.  
  361.    function Targets_Include_Text (Selection : Selection_Data) return Boolean; 
  362.    --  Given a Selection object holding a list of targets, determines if any of 
  363.    --  the targets can be used to provide text. 
  364.  
  365.    function Set_Uris 
  366.      (Selection : Selection_Data; 
  367.       URIs      : GNAT.Strings.String_List) 
  368.       return Boolean; 
  369.    --  Sets the contents of the selection from a list of URIs. 
  370.    --  The string is converted to the form determined by 
  371.    --  Get_Target (Selection). 
  372.    --  Return True if the selection was successfully set. 
  373.  
  374.    function Get_Uris 
  375.      (Selection : Selection_Data) 
  376.       return GNAT.Strings.String_List; 
  377.    --  Gets the contents of the selection data as array of URIs. 
  378.    --  The returned value must be freed by the caller. 
  379.  
  380.    function Get_Targets 
  381.      (Selection : Selection_Data) return Gdk.Types.Gdk_Atom_Array; 
  382.    --  Gets the contents of Selection_Data as an array of targets. 
  383.    --  This can be used to interpret the results of getting 
  384.    --  the standard TARGETS target that is always supplied for 
  385.    --  any selection. 
  386.    --  This is different from Get_Target, which indicate the current format 
  387.    --  that the selection contains. Get_Targets only applies when Get_Target 
  388.    --  is "TARGETS". 
  389.  
  390.    procedure Selection_Data_Set 
  391.      (Selection : Selection_Data; 
  392.       The_Type  : Gdk.Types.Gdk_Atom; 
  393.       Format    : Gint; 
  394.       Data      : System.Address; 
  395.       Length    : Gint); 
  396.    --  General form of Selection_Data_Set. 
  397.    --  Any data can be transmitted. Length is the number of bytes in Data. 
  398.  
  399.    pragma Import (C, Selection_Data_Set, "gtk_selection_data_set"); 
  400.  
  401.    procedure Selection_Data_Set 
  402.      (Selection : Selection_Data; 
  403.       The_Type  : Gdk.Types.Gdk_Atom; 
  404.       Format    : Gint; 
  405.       Data      : String); 
  406.    --  Set the data for a selection (special case for strings) 
  407.    --  This function is generally called when a drag-and-drop operation 
  408.    --  ask the source widget for the data to be transmitted. In that case, 
  409.    --  a Selection_Data was already transmitted and is given as a handler 
  410.    --  parameter for the signal "drag_data_get". The_Type can simply be 
  411.    --  extracted from the Selection_Data. 
  412.  
  413.    function Selection_Data_Copy 
  414.      (Selection : Selection_Data) return Selection_Data; 
  415.    --  Make a copy of a selection data. 
  416.  
  417.    procedure Selection_Data_Free (Selection : Selection_Data); 
  418.    --  Free a Selection_Data structure returned from Selection_Data_Copy. 
  419.  
  420.    -------------------------------- 
  421.    -- Manipulating the selection -- 
  422.    -------------------------------- 
  423.  
  424.    function Owner_Set 
  425.      (Widget    : Gtk.Widget.Gtk_Widget; 
  426.       Selection : Gdk_Selection := Selection_Primary; 
  427.       Time      : Guint32 := 0) return Boolean; 
  428.    --  Claim ownership of a given selection for a particular widget, 
  429.    --  or, if widget is null, release ownership of the selection. 
  430.    -- 
  431.    --  Once a Widget has claimed selection, it is responsible for delivering 
  432.    --  the data whenever it is needed. 
  433.    -- 
  434.    --  Time is the timestamp for claiming the selection (default is the current 
  435.    --  time). 
  436.    --  This function returns True if the operation succeeded. 
  437.  
  438.    procedure Add_Target 
  439.      (Widget    : access Gtk.Widget.Gtk_Widget_Record'Class; 
  440.       Selection : Gdk_Selection; 
  441.       Target    : Gdk.Types.Gdk_Atom; 
  442.       Info      : Guint); 
  443.    --  Add specified target to the list of supported targets for a given 
  444.    --  widget and selection. 
  445.    --  Info is an integer which will be passed back to the application instead 
  446.    --  of a string when the target is used. 
  447.  
  448.    procedure Add_Targets 
  449.      (Widget    : access Gtk.Widget.Gtk_Widget_Record'Class; 
  450.       Selection : Gdk_Selection; 
  451.       Targets   : Target_Entry_Array); 
  452.    --  Add a set of targets to the list of supported targets for a given widget 
  453.    --  and selection. 
  454.  
  455.    procedure Clear_Targets 
  456.      (Widget    : access Gtk.Widget.Gtk_Widget_Record'Class; 
  457.       Selection : Gdk_Selection); 
  458.    --  Clear the list of supported targets for a given widget and selection. 
  459.  
  460.    function Convert 
  461.      (Widget    : access Gtk.Widget.Gtk_Widget_Record'Class; 
  462.       Selection : Gdk_Selection := Selection_Primary; 
  463.       Target    : Gdk.Types.Gdk_Atom; 
  464.       Time      : Guint32 := 0) return Boolean; 
  465.    --  Request the contents of a selection. 
  466.    --  When received, a "selection_received" signal will be generated, and the 
  467.    --  widget needs to have a handler for it. 
  468.    -- 
  469.    --  Target is the form of information desired, for instance an intern 
  470.    --  Gdk_Atom whose name is "text/plain", or one of the Gdk_Target values. 
  471.    -- 
  472.    --  This function returns True if the request succeeded, False if the 
  473.    --  request could not be processed, for instance if there was already a 
  474.    --  request in process for this widget or this target is not known by the 
  475.    --  owner of the selection. 
  476.    -- 
  477.    --  Widget is the widget which acts as a requestor. 
  478.  
  479.    procedure Remove_All (Widget : access Gtk.Widget.Gtk_Widget_Record'Class); 
  480.    --  Remove all handlers and unsets ownership of all selections for a widget. 
  481.    --  Called when widget is being destroyed. This function will not generally 
  482.    --  be called by applications. 
  483.  
  484.    ------------- 
  485.    -- Signals -- 
  486.    ------------- 
  487.  
  488.    --  <signals> 
  489.    --  The following new signals are defined for the class 
  490.    --  Gtk.Widget.Gtk_Widget to support drag-and-drop. 
  491.    --  Please note that no default marshaller is provided in GtkAda for these 
  492.    --  handlers, and that you will have to use the general form of callbacks 
  493.    --  instead, getting the value of the parameters directly from the 
  494.    --  Gtk_Args structure. 
  495.    -- 
  496.    --  - "selection_get"  (source side) 
  497.    --    procedure Handler (Widget : access Gtk_Widget_Record'Class; 
  498.    --                       Data   : Selection_Data; 
  499.    --                       Info   : Guint; 
  500.    --                       Time   : Guint); 
  501.    -- 
  502.    --    This signal is sent to the owner of a selection whenever some other 
  503.    --    widget wants to get data from that selection. The type of the data 
  504.    --    is indicated in Info, and is the third field that was set in the 
  505.    --    Target_Entrys for that specific widget and selection. 
  506.    -- 
  507.    --    The handler should modify the Data in the selection. 
  508.    -- 
  509.    --  - "selection_received"  (client side) 
  510.    --    procedure Handler (Widget : access Gtk_Widget_Record'Class; 
  511.    --                       Data   : Selection_Data; 
  512.    --                       Time   : Guint); 
  513.    -- 
  514.    --    This signal is sent to the receiver end of a selection, when the data 
  515.    --    has been sent by the owner. The receiver should call Convert, which 
  516.    --    will emit the signal selection_get to ask for the contents of the 
  517.    --    selection, and then selection_received will be emitted to warn the 
  518.    --    receiver. 
  519.    -- 
  520.    --    Note: you can not connect this signal to a widget that does not have 
  521.    --    an associated Gdk_Window (i.e the flag Gtk.Widget.No_Window must not 
  522.    --    be set for this widget), since it needs to be able to receive 
  523.    --    Property_Notify events from the server. It will not work with a 
  524.    --    Gtk_Label for instance. 
  525.    -- 
  526.    --  </signals> 
  527.  
  528. private 
  529.  
  530.    pragma Import (C, Target_List_Ref, "gtk_target_list_ref"); 
  531.    pragma Import (C, Target_List_Unref, "gtk_target_list_unref"); 
  532.    pragma Import (C, Target_List_Add, "gtk_target_list_add"); 
  533.    pragma Import (C, Target_List_Remove, "gtk_target_list_remove"); 
  534.  
  535.    pragma Import (C, Get_Selection, "ada_gtk_dnd_get_selection"); 
  536.    pragma Import (C, Get_Target,    "ada_gtk_dnd_get_target"); 
  537.    pragma Import (C, Get_Type,      "ada_gtk_dnd_get_type"); 
  538.    pragma Import (C, Get_Format,    "ada_gtk_dnd_get_format"); 
  539.    pragma Import (C, Get_Data,      "ada_gtk_dnd_get_data"); 
  540.    pragma Import (C, Get_Length,    "ada_gtk_dnd_get_length"); 
  541.  
  542.    pragma Import (C, Selection_Data_Copy, "gtk_selection_data_copy"); 
  543.    pragma Import (C, Selection_Data_Free, "gtk_selection_data_free"); 
  544.    pragma Import (C, Selection_Get_Type, "gtk_selection_data_get_type"); 
  545.    pragma Import (C, Target_List_Add_Text_Targets, 
  546.                   "gtk_target_list_add_text_targets"); 
  547.    pragma Import (C, Target_List_Add_URI_Targets, 
  548.                   "gtk_target_list_add_uri_targets"); 
  549.  
  550.    function Make_Atom (Num : Gulong) return Gdk.Types.Gdk_Atom; 
  551.    pragma Import (C, Make_Atom, "ada_make_atom"); 
  552.  
  553.    Selection_Primary   : constant Gdk_Selection := Make_Atom (1); 
  554.    Selection_Secondary : constant Gdk_Selection := Make_Atom (2); 
  555.  
  556.    Selection_Type_Atom     : constant Gdk_Selection_Type := Make_Atom (4); 
  557.    Selection_Type_Bitmap   : constant Gdk_Selection_Type := Make_Atom (5); 
  558.    Selection_Type_Colormap : constant Gdk_Selection_Type := Make_Atom (7); 
  559.    Selection_Type_Drawable : constant Gdk_Selection_Type := Make_Atom (17); 
  560.    Selection_Type_Integer  : constant Gdk_Selection_Type := Make_Atom (19); 
  561.    Selection_Type_Pixmap   : constant Gdk_Selection_Type := Make_Atom (20); 
  562.    Selection_Type_Window   : constant Gdk_Selection_Type := Make_Atom (33); 
  563.    Selection_Type_String   : constant Gdk_Selection_Type := Make_Atom (31); 
  564.  
  565.    Target_No_Constraint : constant Target_Flags := 0; 
  566.    Target_Same_App      : constant Target_Flags := 1; 
  567.    Target_Same_Widget   : constant Target_Flags := 2; 
  568.  
  569.    Target_Bitmap   : constant Gdk_Target := Make_Atom (5); 
  570.    Target_Colormap : constant Gdk_Target := Make_Atom (7); 
  571.    Target_Drawable : constant Gdk_Target := Make_Atom (17); 
  572.    Target_Pixmap   : constant Gdk_Target := Make_Atom (20); 
  573.    Target_String   : constant Gdk_Target := Make_Atom (31); 
  574. end Gtk.Selection; 
  575.  
  576. --  This function is indicated as obsolescent by gtk+ developers: 
  577. --  No binding: gtk_selection_clear 
  578.  
  579. --  No binding: gtk_selection_owner_set_for_display