1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --   Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet   -- 
  5. --                Copyright (C) 2000-2011, AdaCore                   -- 
  6. --                                                                   -- 
  7. -- This library is free software; you can redistribute it and/or     -- 
  8. -- modify it under the terms of the GNU General Public               -- 
  9. -- License as published by the Free Software Foundation; either      -- 
  10. -- version 2 of the License, or (at your option) any later version.  -- 
  11. --                                                                   -- 
  12. -- This library is distributed in the hope that it will be useful,   -- 
  13. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  14. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  15. -- General Public License for more details.                          -- 
  16. --                                                                   -- 
  17. -- You should have received a copy of the GNU General Public         -- 
  18. -- License along with this library; if not, write to the             -- 
  19. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  20. -- Boston, MA 02111-1307, USA.                                       -- 
  21. --                                                                   -- 
  22. -- -- -- -- -- -- -- -- -- -- -- --
  23. ----------------------------------------------------------------------- 
  24.  
  25. --  <description> 
  26. --  The Gtk_About_Dialog offers a simple way to display information about a 
  27. --  program like its logo, name, copyright, website and license. It is also 
  28. --  possible to give credits to the authors, documenters, translators and 
  29. --  artists who have worked on the program. An about dialog is typically opened 
  30. --  when the user selects the About option from the Help menu. All parts of the 
  31. --  dialog are optional. 
  32. -- 
  33. --  About dialog often contain links and email addresses. Gtk_About_Dialog 
  34. --  supports this by offering global hooks, which are called when the user 
  35. --  clicks on a link or email address, see Set_Email_Hook and Set_Url_Hook. 
  36. --  Email addresses in the authors, documenters and artists properties are 
  37. --  recognized by looking for <user@host>, URLs are recognized by looking for 
  38. --  http://url, with url extending to the next space, tab or line break. 
  39. -- 
  40. --  To make constructing a Gtk_About_Dialog as convenient as possible, you can 
  41. --  use the function gtk_show_about_dialog which constructs and shows a dialog 
  42. --  and keeps it around so that it can be shown again. 
  43. -- 
  44. --  </description> 
  45. --  <group>Windows</group> 
  46. --  <testgtk>create_about.adb</testgtk> 
  47.  
  48. pragma Warnings (Off, "*is already use-visible*"); 
  49. with GNAT.Strings;         use GNAT.Strings; 
  50. with Gdk.Pixbuf;           use Gdk.Pixbuf; 
  51. with Glib;                 use Glib; 
  52. with Glib.Properties;      use Glib.Properties; 
  53. with Glib.Types;           use Glib.Types; 
  54. with Gtk.Buildable;        use Gtk.Buildable; 
  55. with Gtk.Dialog;           use Gtk.Dialog; 
  56. with Gtk.Widget;           use Gtk.Widget; 
  57. with Interfaces.C.Strings; use Interfaces.C.Strings; 
  58.  
  59. package Gtk.About_Dialog is 
  60.  
  61.    type Gtk_About_Dialog_Record is new Gtk_Dialog_Record with null record; 
  62.    type Gtk_About_Dialog is access all Gtk_About_Dialog_Record'Class; 
  63.  
  64.    type Activate_Link_Func is access procedure 
  65.      (About : System.Address; 
  66.       Link  : Interfaces.C.Strings.chars_ptr; 
  67.       Data  : System.Address); 
  68.    pragma Convention (C, Activate_Link_Func); 
  69.    --  A callback called when the user presses an hyper link in the about 
  70.    --  dialog. This is a low-level function, and you'll need to convert the 
  71.    --  parameters to more useful types with: 
  72.    --     Stub : Gtk_About_Dialog_Record; 
  73.    --     A    : constant Gtk_About_Dialog := 
  74.    --       Gtk_About_Dialog (Get_User_Data (About, Stub)); 
  75.    --     L    : constant String := Interfaces.C.Strings.Value (Link); 
  76.  
  77.    ------------------ 
  78.    -- Constructors -- 
  79.    ------------------ 
  80.  
  81.    procedure Gtk_New (About : out Gtk_About_Dialog); 
  82.    procedure Initialize (About : access Gtk_About_Dialog_Record'Class); 
  83.    --  Creates a new Gtk.About_Dialog.Gtk_About_Dialog. 
  84.    --  Since: gtk+ 2.6 
  85.  
  86.    function Get_Type return Glib.GType; 
  87.    pragma Import (C, Get_Type, "gtk_about_dialog_get_type"); 
  88.  
  89.    ------------- 
  90.    -- Methods -- 
  91.    ------------- 
  92.  
  93.    function Get_Artists 
  94.       (About : access Gtk_About_Dialog_Record) 
  95.        return GNAT.Strings.String_List; 
  96.    procedure Set_Artists 
  97.       (About   : access Gtk_About_Dialog_Record; 
  98.        Artists : GNAT.Strings.String_List); 
  99.    --  Sets the strings which are displayed in the artists tab of the 
  100.    --  secondary credits dialog. 
  101.    --  Since: gtk+ 2.6 
  102.    --  "artists": a null-terminated array of strings 
  103.  
  104.    function Get_Authors 
  105.       (About : access Gtk_About_Dialog_Record) 
  106.        return GNAT.Strings.String_List; 
  107.    procedure Set_Authors 
  108.       (About   : access Gtk_About_Dialog_Record; 
  109.        Authors : GNAT.Strings.String_List); 
  110.    --  Sets the strings which are displayed in the authors tab of the 
  111.    --  secondary credits dialog. 
  112.    --  Since: gtk+ 2.6 
  113.    --  "authors": a null-terminated array of strings 
  114.  
  115.    function Get_Comments 
  116.       (About : access Gtk_About_Dialog_Record) return UTF8_String; 
  117.    procedure Set_Comments 
  118.       (About    : access Gtk_About_Dialog_Record; 
  119.        Comments : UTF8_String); 
  120.    --  Sets the comments string to display in the about dialog. This should be 
  121.    --  a short string of one or two lines. 
  122.    --  Since: gtk+ 2.6 
  123.    --  "comments": a comments string 
  124.  
  125.    function Get_Copyright 
  126.       (About : access Gtk_About_Dialog_Record) return UTF8_String; 
  127.    procedure Set_Copyright 
  128.       (About     : access Gtk_About_Dialog_Record; 
  129.        Copyright : UTF8_String); 
  130.    --  Sets the copyright string to display in the about dialog. This should 
  131.    --  be a short string of one or two lines. 
  132.    --  Since: gtk+ 2.6 
  133.    --  "copyright": (allow-none) the copyright string 
  134.  
  135.    function Get_Documenters 
  136.       (About : access Gtk_About_Dialog_Record) 
  137.        return GNAT.Strings.String_List; 
  138.    procedure Set_Documenters 
  139.       (About       : access Gtk_About_Dialog_Record; 
  140.        Documenters : GNAT.Strings.String_List); 
  141.    --  Sets the strings which are displayed in the documenters tab of the 
  142.    --  secondary credits dialog. 
  143.    --  Since: gtk+ 2.6 
  144.    --  "documenters": a null-terminated array of strings 
  145.  
  146.    function Get_License 
  147.       (About : access Gtk_About_Dialog_Record) return UTF8_String; 
  148.    procedure Set_License 
  149.       (About   : access Gtk_About_Dialog_Record; 
  150.        License : UTF8_String); 
  151.    --  Sets the license information to be displayed in the secondary license 
  152.    --  dialog. If License is null, the license button is hidden. 
  153.    --  Since: gtk+ 2.6 
  154.    --  "license": the license information or null 
  155.  
  156.    function Get_Logo 
  157.       (About : access Gtk_About_Dialog_Record) return Gdk.Pixbuf.Gdk_Pixbuf; 
  158.    procedure Set_Logo 
  159.       (About : access Gtk_About_Dialog_Record; 
  160.        Logo  : access Gdk.Pixbuf.Gdk_Pixbuf_Record'Class); 
  161.    --  Sets the pixbuf to be displayed as logo in the about dialog. If it is 
  162.    --  null, the default window icon set with Gtk.Window.Set_Default_Icon will 
  163.    --  be used. 
  164.    --  Since: gtk+ 2.6 
  165.    --  "logo": a Gdk.Pixbuf.Gdk_Pixbuf, or null 
  166.  
  167.    function Get_Logo_Icon_Name 
  168.       (About : access Gtk_About_Dialog_Record) return UTF8_String; 
  169.    procedure Set_Logo_Icon_Name 
  170.       (About     : access Gtk_About_Dialog_Record; 
  171.        Icon_Name : UTF8_String); 
  172.    --  Sets the pixbuf to be displayed as logo in the about dialog. If it is 
  173.    --  null, the default window icon set with Gtk.Window.Set_Default_Icon will 
  174.    --  be used. 
  175.    --  Since: gtk+ 2.6 
  176.    --  "icon_name": an icon name, or null 
  177.  
  178.    function Get_Name 
  179.       (About : access Gtk_About_Dialog_Record) return UTF8_String; 
  180.    pragma Obsolescent (Get_Name); 
  181.    procedure Set_Name 
  182.       (About : access Gtk_About_Dialog_Record; 
  183.        Name  : UTF8_String); 
  184.    pragma Obsolescent (Set_Name); 
  185.    --  Sets the name to display in the about dialog. If this is not set, it 
  186.    --  defaults to g_get_application_name. 
  187.    --  Since: gtk+ 2.6 
  188.    --  Deprecated since 2.12, Use Gtk.About_Dialog.Set_Program_Name instead. 
  189.    --  "name": the program name 
  190.  
  191.    function Get_Program_Name 
  192.       (About : access Gtk_About_Dialog_Record) return UTF8_String; 
  193.    procedure Set_Program_Name 
  194.       (About : access Gtk_About_Dialog_Record; 
  195.        Name  : UTF8_String); 
  196.    --  Sets the name to display in the about dialog. If this is not set, it 
  197.    --  defaults to g_get_application_name. 
  198.    --  Since: gtk+ 2.12 
  199.    --  "name": the program name 
  200.  
  201.    function Get_Translator_Credits 
  202.       (About : access Gtk_About_Dialog_Record) return UTF8_String; 
  203.    procedure Set_Translator_Credits 
  204.       (About              : access Gtk_About_Dialog_Record; 
  205.        Translator_Credits : UTF8_String); 
  206.    --  Sets the translator credits string which is displayed in the 
  207.    --  translators tab of the secondary credits dialog. The intended use for 
  208.    --  this string is to display the translator of the language which is 
  209.    --  currently used in the user interface. Using gettext, a simple way to 
  210.    --  achieve that is to mark the string for translation: |[ 
  211.    --  gtk_about_dialog_set_translator_credits (about, 
  212.    --  _("translator-credits")); ]| It is a good idea to use the customary 
  213.    --  msgid "translator-credits" for this purpose, since translators will 
  214.    --  already know the purpose of that msgid, and since 
  215.    --  Gtk.About_Dialog.Gtk_About_Dialog will detect if "translator-credits" is 
  216.    --  untranslated and hide the tab. 
  217.    --  Since: gtk+ 2.6 
  218.    --  "translator_credits": the translator credits 
  219.  
  220.    function Get_Version 
  221.       (About : access Gtk_About_Dialog_Record) return UTF8_String; 
  222.    procedure Set_Version 
  223.       (About   : access Gtk_About_Dialog_Record; 
  224.        Version : UTF8_String); 
  225.    --  Sets the version string to display in the about dialog. 
  226.    --  Since: gtk+ 2.6 
  227.    --  "version": the version string 
  228.  
  229.    function Get_Website 
  230.       (About : access Gtk_About_Dialog_Record) return UTF8_String; 
  231.    procedure Set_Website 
  232.       (About   : access Gtk_About_Dialog_Record; 
  233.        Website : UTF8_String); 
  234.    --  Sets the URL to use for the website link. Note that that the hook 
  235.    --  functions need to be set up before calling this function. 
  236.    --  Since: gtk+ 2.6 
  237.    --  "website": a URL string starting with "http://" 
  238.  
  239.    function Get_Website_Label 
  240.       (About : access Gtk_About_Dialog_Record) return UTF8_String; 
  241.    procedure Set_Website_Label 
  242.       (About         : access Gtk_About_Dialog_Record; 
  243.        Website_Label : UTF8_String); 
  244.    --  Sets the label to be used for the website link. It defaults to the 
  245.    --  website URL. 
  246.    --  Since: gtk+ 2.6 
  247.    --  "website_label": the label used for the website link 
  248.  
  249.    function Get_Wrap_License 
  250.       (About : access Gtk_About_Dialog_Record) return Boolean; 
  251.    procedure Set_Wrap_License 
  252.       (About        : access Gtk_About_Dialog_Record; 
  253.        Wrap_License : Boolean); 
  254.    --  Sets whether the license text in About is automatically wrapped. 
  255.    --  Since: gtk+ 2.8 
  256.    --  "wrap_license": whether to wrap the license 
  257.  
  258.    --------------- 
  259.    -- Functions -- 
  260.    --------------- 
  261.  
  262.    function Set_Email_Hook 
  263.       (Func    : Activate_Link_Func; 
  264.        Data    : System.Address; 
  265.        Destroy : Glib.G_Destroy_Notify_Address) return Activate_Link_Func; 
  266.    pragma Obsolescent (Set_Email_Hook); 
  267.    --  Installs a global function to be called whenever the user activates an 
  268.    --  email link in an about dialog. Since 2.18 there exists a default 
  269.    --  function which uses gtk_show_uri(). To deactivate it, you can pass null 
  270.    --  for Func. 
  271.    --  Since: gtk+ 2.6 
  272.    --  Returns the previous email hook. 
  273.    --  Deprecated since 2.24, Use the 
  274.    --  Gtk.About_Dialog.Gtk_About_Dialog::activate-link signal 
  275.    --  "func": a function to call when an email link is activated. 
  276.    --  "data": data to pass to Func 
  277.    --  "destroy": Glib.G_Destroy_Notify_Address for Data 
  278.  
  279.    function Set_Url_Hook 
  280.       (Func    : Activate_Link_Func; 
  281.        Data    : System.Address; 
  282.        Destroy : Glib.G_Destroy_Notify_Address) return Activate_Link_Func; 
  283.    pragma Obsolescent (Set_Url_Hook); 
  284.    --  Installs a global function to be called whenever the user activates a 
  285.    --  URL link in an about dialog. Since 2.18 there exists a default function 
  286.    --  which uses gtk_show_uri(). To deactivate it, you can pass null for Func. 
  287.    --  Since: gtk+ 2.6 
  288.    --  Returns the previous URL hook. 
  289.    --  Deprecated since 2.24, Use the 
  290.    --  Gtk.About_Dialog.Gtk_About_Dialog::activate-link signal 
  291.    --  "func": a function to call when a URL link is activated. 
  292.    --  "data": data to pass to Func 
  293.    --  "destroy": Glib.G_Destroy_Notify_Address for Data 
  294.  
  295.    ---------------- 
  296.    -- Interfaces -- 
  297.    ---------------- 
  298.    --  This class implements several interfaces. See Glib.Types 
  299.    -- 
  300.    --  - "Buildable" 
  301.  
  302.    package Implements_Buildable is new Glib.Types.Implements 
  303.      (Gtk.Buildable.Gtk_Buildable, Gtk_About_Dialog_Record, Gtk_About_Dialog); 
  304.    function "+" 
  305.      (Widget : access Gtk_About_Dialog_Record'Class) 
  306.    return Gtk.Buildable.Gtk_Buildable 
  307.    renames Implements_Buildable.To_Interface; 
  308.    function "-" 
  309.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  310.    return Gtk_About_Dialog 
  311.    renames Implements_Buildable.To_Object; 
  312.  
  313.    ---------------- 
  314.    -- Properties -- 
  315.    ---------------- 
  316.    --  The following properties are defined for this widget. See 
  317.    --  Glib.Properties for more information on properties) 
  318.    -- 
  319.    --  Name: Comments_Property 
  320.    --  Type: UTF8_String 
  321.    --  Flags: read-write 
  322.    --  Comments about the program. This string is displayed in a label in the 
  323.    --  main dialog, thus it should be a short explanation of the main purpose 
  324.    --  of the program, not a detailed list of features. 
  325.    -- 
  326.    --  Name: Copyright_Property 
  327.    --  Type: UTF8_String 
  328.    --  Flags: read-write 
  329.    --  Copyright information for the program. 
  330.    -- 
  331.    --  Name: License_Property 
  332.    --  Type: UTF8_String 
  333.    --  Flags: read-write 
  334.    --  The license of the program. This string is displayed in a text view in 
  335.    --  a secondary dialog, therefore it is fine to use a long multi-paragraph 
  336.    --  text. Note that the text is only wrapped in the text view if the 
  337.    --  "wrap-license" property is set to True; otherwise the text itself must 
  338.    --  contain the intended linebreaks. 
  339.    -- 
  340.    --  Name: Logo_Property 
  341.    --  Type: Gdk.Pixbuf.Gdk_Pixbuf 
  342.    --  Flags: read-write 
  343.    --  A logo for the about box. If this is not set, it defaults to 
  344.    --  gtk_window_get_default_icon_list. 
  345.    -- 
  346.    --  Name: Logo_Icon_Name_Property 
  347.    --  Type: UTF8_String 
  348.    --  Flags: read-write 
  349.    --  A named icon to use as the logo for the about box. This property 
  350.    --  overrides the Gtk.About_Dialog.Gtk_About_Dialog:logo property. 
  351.    -- 
  352.    --  Name: Program_Name_Property 
  353.    --  Type: UTF8_String 
  354.    --  Flags: read-write 
  355.    --  The name of the program. If this is not set, it defaults to 
  356.    --  g_get_application_name. 
  357.    -- 
  358.    --  Name: Translator_Credits_Property 
  359.    --  Type: UTF8_String 
  360.    --  Flags: read-write 
  361.    --  Credits to the translators. This string should be marked as 
  362.    --  translatable. The string may contain email addresses and URLs, which 
  363.    --  will be displayed as links, see the introduction for more details. 
  364.    -- 
  365.    --  Name: Version_Property 
  366.    --  Type: UTF8_String 
  367.    --  Flags: read-write 
  368.    --  The version of the program. 
  369.    -- 
  370.    --  Name: Website_Property 
  371.    --  Type: UTF8_String 
  372.    --  Flags: read-write 
  373.    --  The URL for the link to the website of the program. This should be a 
  374.    --  string starting with "http://. 
  375.    -- 
  376.    --  Name: Website_Label_Property 
  377.    --  Type: UTF8_String 
  378.    --  Flags: read-write 
  379.    --  The label for the link to the website of the program. If this is not 
  380.    --  set, it defaults to the URL specified in the 
  381.    --  Gtk.About_Dialog.Gtk_About_Dialog:website property. 
  382.    -- 
  383.    --  Name: Wrap_License_Property 
  384.    --  Type: Boolean 
  385.    --  Flags: read-write 
  386.    --  Whether to wrap the text in the license dialog. 
  387.  
  388.    Comments_Property : constant Glib.Properties.Property_String; 
  389.    Copyright_Property : constant Glib.Properties.Property_String; 
  390.    License_Property : constant Glib.Properties.Property_String; 
  391.    Logo_Property : constant Glib.Properties.Property_Object; 
  392.    Logo_Icon_Name_Property : constant Glib.Properties.Property_String; 
  393.    Program_Name_Property : constant Glib.Properties.Property_String; 
  394.    Translator_Credits_Property : constant Glib.Properties.Property_String; 
  395.    Version_Property : constant Glib.Properties.Property_String; 
  396.    Website_Property : constant Glib.Properties.Property_String; 
  397.    Website_Label_Property : constant Glib.Properties.Property_String; 
  398.    Wrap_License_Property : constant Glib.Properties.Property_Boolean; 
  399.  
  400.    ------------- 
  401.    -- Signals -- 
  402.    ------------- 
  403.    --  The following new signals are defined for this widget: 
  404.    -- 
  405.    --  "activate-link" 
  406.    --     function Handler 
  407.    --       (Self : access Gtk_About_Dialog_Record'Class; 
  408.    --        Uri  : UTF8_String) return Boolean; 
  409.    --    --  "uri": the URI that is activated 
  410.    --  The signal which gets emitted to activate a URI. Applications may 
  411.    --  connect to it to override the default behaviour, which is to call 
  412.    --  gtk_show_uri(). 
  413.    --  Returns True if the link has been activated 
  414.  
  415.    Signal_Activate_Link : constant Glib.Signal_Name := "activate-link"; 
  416.  
  417. private 
  418.    Comments_Property : constant Glib.Properties.Property_String := 
  419.      Glib.Properties.Build ("comments"); 
  420.    Copyright_Property : constant Glib.Properties.Property_String := 
  421.      Glib.Properties.Build ("copyright"); 
  422.    License_Property : constant Glib.Properties.Property_String := 
  423.      Glib.Properties.Build ("license"); 
  424.    Logo_Property : constant Glib.Properties.Property_Object := 
  425.      Glib.Properties.Build ("logo"); 
  426.    Logo_Icon_Name_Property : constant Glib.Properties.Property_String := 
  427.      Glib.Properties.Build ("logo-icon-name"); 
  428.    Program_Name_Property : constant Glib.Properties.Property_String := 
  429.      Glib.Properties.Build ("program-name"); 
  430.    Translator_Credits_Property : constant Glib.Properties.Property_String := 
  431.      Glib.Properties.Build ("translator-credits"); 
  432.    Version_Property : constant Glib.Properties.Property_String := 
  433.      Glib.Properties.Build ("version"); 
  434.    Website_Property : constant Glib.Properties.Property_String := 
  435.      Glib.Properties.Build ("website"); 
  436.    Website_Label_Property : constant Glib.Properties.Property_String := 
  437.      Glib.Properties.Build ("website-label"); 
  438.    Wrap_License_Property : constant Glib.Properties.Property_Boolean := 
  439.      Glib.Properties.Build ("wrap-license"); 
  440. end Gtk.About_Dialog;