1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  A GtkLinkButton is a Gtk.Button.Gtk_Button with a hyperlink, similar to 
  26. --  the one used by web browsers, which triggers an action when clicked. It is 
  27. --  useful to show quick links to resources. 
  28. -- 
  29. --  A link button is created by calling either Gtk.Link_Button.Gtk_New or 
  30. --  Gtk.Link_Button.Gtk_New_With_Label. If using the former, the URI you pass 
  31. --  to the constructor is used as a label for the widget. 
  32. -- 
  33. --  The URI bound to a GtkLinkButton can be set specifically using 
  34. --  Gtk.Link_Button.Set_Uri, and retrieved using Gtk.Link_Button.Get_Uri. 
  35. -- 
  36. --  By default, GtkLinkButton calls gtk_show_uri() when the button is clicked. 
  37. --  This behaviour can be overridden by connecting to the 
  38. --  Gtk.Link_Button.Gtk_Link_Button::activate-link signal and returning True 
  39. --  from the signal handler. 
  40. -- 
  41. --  </description> 
  42. --  <group>Buttons and Toggles</group> 
  43. pragma Ada_2005; 
  44.  
  45. pragma Warnings (Off, "*is already use-visible*"); 
  46. with Glib;            use Glib; 
  47. with Glib.Object;     use Glib.Object; 
  48. with Glib.Properties; use Glib.Properties; 
  49. with Glib.Types;      use Glib.Types; 
  50. with Glib.Variant;    use Glib.Variant; 
  51. with Gtk.Action;      use Gtk.Action; 
  52. with Gtk.Actionable;  use Gtk.Actionable; 
  53. with Gtk.Activatable; use Gtk.Activatable; 
  54. with Gtk.Buildable;   use Gtk.Buildable; 
  55. with Gtk.Button;      use Gtk.Button; 
  56.  
  57. package Gtk.Link_Button is 
  58.  
  59.    type Gtk_Link_Button_Record is new Gtk_Button_Record with null record; 
  60.    type Gtk_Link_Button is access all Gtk_Link_Button_Record'Class; 
  61.  
  62.    ------------------ 
  63.    -- Constructors -- 
  64.    ------------------ 
  65.  
  66.    procedure Gtk_New (Widget : out Gtk_Link_Button; URI : UTF8_String); 
  67.    procedure Initialize 
  68.       (Widget : not null access Gtk_Link_Button_Record'Class; 
  69.        URI    : UTF8_String); 
  70.    --  Creates a new Gtk.Link_Button.Gtk_Link_Button with the URI as its text. 
  71.    --  Since: gtk+ 2.10 
  72.    --  "uri": a valid URI 
  73.  
  74.    function Gtk_Link_Button_New (URI : UTF8_String) return Gtk_Link_Button; 
  75.    --  Creates a new Gtk.Link_Button.Gtk_Link_Button with the URI as its text. 
  76.    --  Since: gtk+ 2.10 
  77.    --  "uri": a valid URI 
  78.  
  79.    procedure Gtk_New_With_Label 
  80.       (Widget : out Gtk_Link_Button; 
  81.        URI    : UTF8_String; 
  82.        Label  : UTF8_String := ""); 
  83.    procedure Initialize_With_Label 
  84.       (Widget : not null access Gtk_Link_Button_Record'Class; 
  85.        URI    : UTF8_String; 
  86.        Label  : UTF8_String := ""); 
  87.    --  Creates a new Gtk.Link_Button.Gtk_Link_Button containing a label. 
  88.    --  Since: gtk+ 2.10 
  89.    --  "uri": a valid URI 
  90.    --  "label": the text of the button 
  91.  
  92.    function Gtk_Link_Button_New_With_Label 
  93.       (URI   : UTF8_String; 
  94.        Label : UTF8_String := "") return Gtk_Link_Button; 
  95.    --  Creates a new Gtk.Link_Button.Gtk_Link_Button containing a label. 
  96.    --  Since: gtk+ 2.10 
  97.    --  "uri": a valid URI 
  98.    --  "label": the text of the button 
  99.  
  100.    function Get_Type return Glib.GType; 
  101.    pragma Import (C, Get_Type, "gtk_link_button_get_type"); 
  102.  
  103.    ------------- 
  104.    -- Methods -- 
  105.    ------------- 
  106.  
  107.    function Get_Uri 
  108.       (Widget : not null access Gtk_Link_Button_Record) return UTF8_String; 
  109.    --  Retrieves the URI set using Gtk.Link_Button.Set_Uri. 
  110.    --  Since: gtk+ 2.10 
  111.  
  112.    procedure Set_Uri 
  113.       (Widget : not null access Gtk_Link_Button_Record; 
  114.        URI    : UTF8_String); 
  115.    --  Sets Uri as the URI where the Gtk.Link_Button.Gtk_Link_Button points. 
  116.    --  As a side-effect this unsets the 'visited' state of the button. 
  117.    --  Since: gtk+ 2.10 
  118.    --  "uri": a valid URI 
  119.  
  120.    function Get_Visited 
  121.       (Widget : not null access Gtk_Link_Button_Record) return Boolean; 
  122.    --  Retrieves the 'visited' state of the URI where the 
  123.    --  Gtk.Link_Button.Gtk_Link_Button points. The button becomes visited when 
  124.    --  it is clicked. If the URI is changed on the button, the 'visited' state 
  125.    --  is unset again. 
  126.    --  The state may also be changed using Gtk.Link_Button.Set_Visited. 
  127.    --  Since: gtk+ 2.14 
  128.  
  129.    procedure Set_Visited 
  130.       (Widget  : not null access Gtk_Link_Button_Record; 
  131.        Visited : Boolean); 
  132.    --  Sets the 'visited' state of the URI where the 
  133.    --  Gtk.Link_Button.Gtk_Link_Button points. See Gtk.Link_Button.Get_Visited 
  134.    --  for more details. 
  135.    --  Since: gtk+ 2.14 
  136.    --  "visited": the new 'visited' state 
  137.  
  138.    --------------------------------------------- 
  139.    -- Inherited subprograms (from interfaces) -- 
  140.    --------------------------------------------- 
  141.    --  Methods inherited from the Buildable interface are not duplicated here 
  142.    --  since they are meant to be used by tools, mostly. If you need to call 
  143.    --  them, use an explicit cast through the "-" operator below. 
  144.  
  145.    function Get_Action_Name 
  146.       (Self : not null access Gtk_Link_Button_Record) return UTF8_String; 
  147.  
  148.    procedure Set_Action_Name 
  149.       (Self        : not null access Gtk_Link_Button_Record; 
  150.        Action_Name : UTF8_String); 
  151.  
  152.    function Get_Action_Target_Value 
  153.       (Self : not null access Gtk_Link_Button_Record) 
  154.        return Glib.Variant.Gvariant; 
  155.  
  156.    procedure Set_Action_Target_Value 
  157.       (Self         : not null access Gtk_Link_Button_Record; 
  158.        Target_Value : Glib.Variant.Gvariant); 
  159.  
  160.    procedure Set_Detailed_Action_Name 
  161.       (Self                 : not null access Gtk_Link_Button_Record; 
  162.        Detailed_Action_Name : UTF8_String); 
  163.  
  164.    procedure Do_Set_Related_Action 
  165.       (Self   : not null access Gtk_Link_Button_Record; 
  166.        Action : not null access Gtk.Action.Gtk_Action_Record'Class); 
  167.  
  168.    function Get_Related_Action 
  169.       (Self : not null access Gtk_Link_Button_Record) 
  170.        return Gtk.Action.Gtk_Action; 
  171.  
  172.    procedure Set_Related_Action 
  173.       (Self   : not null access Gtk_Link_Button_Record; 
  174.        Action : not null access Gtk.Action.Gtk_Action_Record'Class); 
  175.  
  176.    function Get_Use_Action_Appearance 
  177.       (Self : not null access Gtk_Link_Button_Record) return Boolean; 
  178.  
  179.    procedure Set_Use_Action_Appearance 
  180.       (Self           : not null access Gtk_Link_Button_Record; 
  181.        Use_Appearance : Boolean); 
  182.  
  183.    procedure Sync_Action_Properties 
  184.       (Self   : not null access Gtk_Link_Button_Record; 
  185.        Action : access Gtk.Action.Gtk_Action_Record'Class); 
  186.  
  187.    ---------------- 
  188.    -- Properties -- 
  189.    ---------------- 
  190.    --  The following properties are defined for this widget. See 
  191.    --  Glib.Properties for more information on properties) 
  192.  
  193.    URI_Property : constant Glib.Properties.Property_String; 
  194.    --  The URI bound to this button. 
  195.  
  196.    Visited_Property : constant Glib.Properties.Property_Boolean; 
  197.    --  The 'visited' state of this button. A visited link is drawn in a 
  198.    --  different color. 
  199.  
  200.    ------------- 
  201.    -- Signals -- 
  202.    ------------- 
  203.  
  204.    type Cb_Gtk_Link_Button_Boolean is not null access function 
  205.      (Self : access Gtk_Link_Button_Record'Class) return Boolean; 
  206.  
  207.    type Cb_GObject_Boolean is not null access function 
  208.      (Self : access Glib.Object.GObject_Record'Class) 
  209.    return Boolean; 
  210.  
  211.    Signal_Activate_Link : constant Glib.Signal_Name := "activate-link"; 
  212.    procedure On_Activate_Link 
  213.       (Self  : not null access Gtk_Link_Button_Record; 
  214.        Call  : Cb_Gtk_Link_Button_Boolean; 
  215.        After : Boolean := False); 
  216.    procedure On_Activate_Link 
  217.       (Self  : not null access Gtk_Link_Button_Record; 
  218.        Call  : Cb_GObject_Boolean; 
  219.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  220.        After : Boolean := False); 
  221.    --  The ::activate-link signal is emitted each time the 
  222.    --  Gtk.Link_Button.Gtk_Link_Button has been clicked. 
  223.    -- 
  224.    --  The default handler will call gtk_show_uri() with the URI stored inside 
  225.    --  the Gtk.Link_Button.Gtk_Link_Button:uri property. 
  226.    -- 
  227.    --  To override the default behavior, you can connect to the 
  228.    --  ::activate-link signal and stop the propagation of the signal by 
  229.    --  returning True from your handler. 
  230.  
  231.    ---------------- 
  232.    -- Interfaces -- 
  233.    ---------------- 
  234.    --  This class implements several interfaces. See Glib.Types 
  235.    -- 
  236.    --  - "Actionable" 
  237.    -- 
  238.    --  - "Activatable" 
  239.    -- 
  240.    --  - "Buildable" 
  241.  
  242.    package Implements_Gtk_Actionable is new Glib.Types.Implements 
  243.      (Gtk.Actionable.Gtk_Actionable, Gtk_Link_Button_Record, Gtk_Link_Button); 
  244.    function "+" 
  245.      (Widget : access Gtk_Link_Button_Record'Class) 
  246.    return Gtk.Actionable.Gtk_Actionable 
  247.    renames Implements_Gtk_Actionable.To_Interface; 
  248.    function "-" 
  249.      (Interf : Gtk.Actionable.Gtk_Actionable) 
  250.    return Gtk_Link_Button 
  251.    renames Implements_Gtk_Actionable.To_Object; 
  252.  
  253.    package Implements_Gtk_Activatable is new Glib.Types.Implements 
  254.      (Gtk.Activatable.Gtk_Activatable, Gtk_Link_Button_Record, Gtk_Link_Button); 
  255.    function "+" 
  256.      (Widget : access Gtk_Link_Button_Record'Class) 
  257.    return Gtk.Activatable.Gtk_Activatable 
  258.    renames Implements_Gtk_Activatable.To_Interface; 
  259.    function "-" 
  260.      (Interf : Gtk.Activatable.Gtk_Activatable) 
  261.    return Gtk_Link_Button 
  262.    renames Implements_Gtk_Activatable.To_Object; 
  263.  
  264.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  265.      (Gtk.Buildable.Gtk_Buildable, Gtk_Link_Button_Record, Gtk_Link_Button); 
  266.    function "+" 
  267.      (Widget : access Gtk_Link_Button_Record'Class) 
  268.    return Gtk.Buildable.Gtk_Buildable 
  269.    renames Implements_Gtk_Buildable.To_Interface; 
  270.    function "-" 
  271.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  272.    return Gtk_Link_Button 
  273.    renames Implements_Gtk_Buildable.To_Object; 
  274.  
  275. private 
  276.    Visited_Property : constant Glib.Properties.Property_Boolean := 
  277.      Glib.Properties.Build ("visited"); 
  278.    URI_Property : constant Glib.Properties.Property_String := 
  279.      Glib.Properties.Build ("uri"); 
  280. end Gtk.Link_Button;