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