1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --                    Copyright (C) 2010, 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. --  A Gtk_Assistant is a widget used to represent a generally complex 
  31. --  operation split into several steps, guiding the user through its 
  32. --  pages and controlling the page flow to collect the necessary data. 
  33. --  </description> 
  34. --  <c_version>2.16.6</c_version> 
  35. --  <group>Windows</group> 
  36. --  <testgtk>create_assistant.adb</testgtk> 
  37.  
  38. with Glib; 
  39. with Glib.Properties; 
  40. with Gdk.Pixbuf;      use Gdk.Pixbuf; 
  41. with Gtk.Widget;      use Gtk.Widget; 
  42. with Gtk.Window; 
  43.  
  44. package Gtk.Assistant is 
  45.  
  46.    type Gtk_Assistant_Record is new Gtk.Window.Gtk_Window_Record with private; 
  47.    type Gtk_Assistant is access all Gtk_Assistant_Record'Class; 
  48.  
  49.    procedure Gtk_New (Widget : out Gtk_Assistant); 
  50.    procedure Initialize (Widget : access Gtk_Assistant_Record'Class); 
  51.    --  Creates a new Gtk_Assistant. 
  52.  
  53.    type Gtk_Assistant_Page_Type is 
  54.      (Gtk_Assistant_Page_Content, 
  55.       Gtk_Assistant_Page_Intro, 
  56.       Gtk_Assistant_Page_Confirm, 
  57.       Gtk_Assistant_Page_Summary, 
  58.       Gtk_Assistant_Page_Progress); 
  59.    --  Definition of various page types.  See Get_Page_Type/Set_Page_Type 
  60.    --  for more info. 
  61.  
  62.    procedure Add_Action_Widget 
  63.      (Assistant : access Gtk_Assistant_Record; 
  64.       Child     : access Gtk_Widget_Record'Class); 
  65.    --  Adds a widget to the action area of a Gtk_Assistant. 
  66.  
  67.    function Append_Page 
  68.      (Assistant : access Gtk_Assistant_Record; 
  69.       Page      : access Gtk_Widget_Record'Class) 
  70.       return Gint; 
  71.    --  Appends a page to the Assistant. 
  72.    -- 
  73.    --  Return value: the index (starting at 0) of the inserted page 
  74.  
  75.    function Get_Current_Page (Assistant : access Gtk_Assistant_Record) 
  76.       return Gint; 
  77.    --  Returns the index (starting from 0) of the current page in the 
  78.    --  Assistant.  If the Assistant has no pages, -1 will be returned 
  79.  
  80.    function Get_N_Pages (Assistant : access Gtk_Assistant_Record) return Gint; 
  81.    --  Returns the number of pages in the Assistant 
  82.  
  83.    function Get_Nth_Page 
  84.      (Assistant : access Gtk_Assistant_Record; 
  85.       Page_Num  : Gint) 
  86.       return Gtk_Widget; 
  87.    --  Assistant: a Gtk_Assistant 
  88.    --  Page_Num: The index of a page in the Assistant, or -1 to get the 
  89.    --  last page 
  90.    -- 
  91.    --  Returns the child widget contained in page number Page_Num, or null 
  92.    --  if Page_Num is out of bounds. 
  93.  
  94.    function Get_Page_Complete 
  95.      (Assistant : access Gtk_Assistant_Record; 
  96.       Page      : access Gtk_Widget_Record'Class) 
  97.       return Boolean; 
  98.    --  Returns whether Page is complete. 
  99.  
  100.    function Get_Page_Header_Image 
  101.      (Assistant : access Gtk_Assistant_Record; 
  102.       Page      : access Gtk_Widget_Record'Class) 
  103.       return Gdk_Pixbuf; 
  104.    --  Gets the header image for Page.  Returns null if there's no header 
  105.    --  image for the page. 
  106.  
  107.    function Get_Page_Side_Image 
  108.      (Assistant : access Gtk_Assistant_Record; 
  109.       Page      : access Gtk_Widget_Record'Class) 
  110.       return Gdk_Pixbuf; 
  111.    --  Gets the side image for Page.  Returns null if there's no side 
  112.    --  image for the page. 
  113.  
  114.    function Get_Page_Title 
  115.      (Assistant : access Gtk_Assistant_Record; 
  116.       Page      : access Gtk_Widget_Record'Class) 
  117.       return String; 
  118.    --  Gets the title for Page. 
  119.  
  120.    function Get_Page_Type 
  121.      (Assistant : access Gtk_Assistant_Record; 
  122.       Page      : access Gtk_Widget_Record'Class) 
  123.       return Gtk_Assistant_Page_Type; 
  124.    --  Gets the page type of Page. 
  125.  
  126.    function Get_Type return GType; 
  127.    --  Return the internal value associated with a Gtk_Assistant. 
  128.  
  129.    function Insert_Page 
  130.      (Assistant : access Gtk_Assistant_Record; 
  131.       Page      : access Gtk_Widget_Record'Class; 
  132.       Position  : Gint) 
  133.       return Gint; 
  134.    --  Assistant: a Gtk_Assistant 
  135.    --  Page: a Gtk_Widget 
  136.    --  Position: the index (starting at 0) at which to insert the page, 
  137.    --  or -1 to append the page to the Assistant 
  138.    -- 
  139.    --  Inserts a page in the Assistant at a given position. 
  140.    -- 
  141.    --  Return value: the index (starting from 0) of the inserted page 
  142.  
  143.    function Prepend_Page 
  144.      (Assistant : access Gtk_Assistant_Record; 
  145.       Page      : access Gtk_Widget_Record'Class) 
  146.       return Gint; 
  147.    --  Prepends a page to the Assistant. 
  148.    -- 
  149.    --  Return value: the index (starting at 0) of the inserted page 
  150.  
  151.    procedure Remove_Action_Widget 
  152.      (Assistant : access Gtk_Assistant_Record; 
  153.       Child     : access Gtk_Widget_Record'Class); 
  154.    --  Removes a widget from the action area of a Gtk_Assistant. 
  155.  
  156.    procedure Set_Current_Page 
  157.      (Assistant : access Gtk_Assistant_Record; 
  158.       Page_Num  : Gint); 
  159.    --  Assistant: a Gtk_Assistant 
  160.    --  Page_Num: index of the page to switch to, starting from 0. 
  161.    --  If negative, the last page will be used. If greater 
  162.    --  than the number of pages in the Assistant, nothing 
  163.    --  will be done. 
  164.    -- 
  165.    --  Switches the page to Page_Num. Note that this will only be necessary 
  166.    --  in custom buttons, as the Assistant flow can be set with 
  167.    --  Set_Forward_Page_Func. 
  168.  
  169.    generic 
  170.       type Data_Type (<>) is private; 
  171.    package Generic_Assistant_Functions is 
  172.       type Page_Func is access function 
  173.         (Current_Page : Gint; 
  174.          User_Data    : Data_Type) 
  175.          return Gint; 
  176.       --  Spec for page forwarding function. 
  177.  
  178.       type Destroy_Notify is access procedure (User_Data : in out Data_Type); 
  179.       --  Destroy_Notify is called just prior to the destruction of 
  180.       --  User_Data. 
  181.  
  182.       procedure Set_Forward_Page_Func 
  183.         (Assistant : Gtk_Assistant; 
  184.          Func      : Page_Func; 
  185.          User_Data : Data_Type; 
  186.          Destroy   : Destroy_Notify := null); 
  187.       --  Sets the Assistant's page forwarding function to be Func.  This 
  188.       --  function will be used to determine what will be the next page when 
  189.       --  the user presses the forward button. Setting Func to null will make 
  190.       --  the assistant use the default forward function, which just goes 
  191.       --  to the next visible page. 
  192.    end Generic_Assistant_Functions; 
  193.  
  194.    procedure Set_Page_Complete 
  195.      (Assistant : access Gtk_Assistant_Record; 
  196.       Page      : access Gtk_Widget_Record'Class; 
  197.       Complete  : Boolean); 
  198.    --  Sets whether Page contents are complete. This will make 
  199.    --  Assistant update the buttons' state to be able to continue the task. 
  200.  
  201.    procedure Set_Page_Header_Image 
  202.      (Assistant : access Gtk_Assistant_Record; 
  203.       Page      : access Gtk_Widget_Record'Class; 
  204.       Pixbuf    : Gdk_Pixbuf); 
  205.    --  Sets a header image for Page. This image is displayed in the header 
  206.    --  area of the assistant when Page is the current page. 
  207.  
  208.    procedure Set_Page_Side_Image 
  209.      (Assistant : access Gtk_Assistant_Record; 
  210.       Page      : access Gtk_Widget_Record'Class; 
  211.       Pixbuf    : Gdk_Pixbuf); 
  212.    --  Sets a side image for Page. This image is displayed in the side 
  213.    --  area of the assistant when Page is the current page. 
  214.  
  215.    procedure Set_Page_Title 
  216.      (Assistant : access Gtk_Assistant_Record; 
  217.       Page      : access Gtk_Widget_Record'Class; 
  218.       Title     : String); 
  219.    --  Sets a title for Page. The title is displayed in the header 
  220.    --  area of the assistant when Page is the current page. 
  221.  
  222.    procedure Set_Page_Type 
  223.      (Assistant : access Gtk_Assistant_Record; 
  224.       Page      : access Gtk_Widget_Record'Class; 
  225.       Page_Type : Gtk_Assistant_Page_Type); 
  226.    --  Sets the page type for Page. The page type determines the page 
  227.    --  behavior in the Assistant. 
  228.  
  229.    procedure Update_Buttons_State (Assistant : access Gtk_Assistant_Record); 
  230.    --  Forces Assistant to recompute the state of the buttons. 
  231.    -- 
  232.    --  GTK+ automatically takes care of this in most situations, 
  233.    --  e.g. when the user goes to a different page, or when the 
  234.    --  visibility or completeness of a page changes. 
  235.    -- 
  236.    --  One situation where it can be necessary to call this 
  237.    --  function is when changing a value on the current page 
  238.    --  affects the future page flow of the assistant. 
  239.  
  240.    ---------------------- 
  241.    -- Child Properties -- 
  242.    ---------------------- 
  243.    --  The following properties can be set on children of this widget. See 
  244.    --  in particular Gtk.Containers.Child_Set_Property. 
  245.  
  246.    --  <child_properties> 
  247.    --  Name:  Complete_Property 
  248.    --  Type:  Boolean 
  249.    --  Descr: Whether all required fields on the page have been filled out 
  250.    -- 
  251.    --  Name:  Header_Image_Property 
  252.    --  Type:  Object 
  253.    --  Descr: Header image for the assistant page 
  254.    -- 
  255.    --  Name:  Page_Type_Property 
  256.    --  Type:  Enum 
  257.    --  Descr: The type of the assistant page 
  258.    -- 
  259.    --  Name:  Sidebar_Image_Property 
  260.    --  Type:  Object 
  261.    --  Descr: Sidebar image for the assistant page 
  262.    -- 
  263.    --  Name:  Title_Property 
  264.    --  Type:  String 
  265.    --  Descr: The title of the assistant page 
  266.    --  </child_properties> 
  267.  
  268.    Complete_Property      : constant Glib.Properties.Property_Boolean; 
  269.    Header_Image_Property  : constant Glib.Properties.Property_Object; 
  270.    Page_Type_Property     : constant Glib.Properties.Property_Enum; 
  271.    Sidebar_Image_Property : constant Glib.Properties.Property_Object; 
  272.    Title_Property         : constant Glib.Properties.Property_String; 
  273.  
  274.    ---------------------- 
  275.    -- Style Properties -- 
  276.    ---------------------- 
  277.    --  The following properties can be changed through the gtk theme and 
  278.    --  configuration files, and retrieved through Gtk.Widget.Style_Get_Property 
  279.  
  280.    --  <style_properties> 
  281.    --  Name:  Content_Padding_Property 
  282.    --  Type:  Int 
  283.    --  Descr: Number of pixels around the content pages. 
  284.    -- 
  285.    --  Name:  Header_Padding_Property 
  286.    --  Type:  Int 
  287.    --  Descr: Number of pixels around the header. 
  288.    --  </style_properties> 
  289.  
  290.    Content_Padding_Property : constant Glib.Properties.Property_Int; 
  291.    Header_Padding_Property  : constant Glib.Properties.Property_Int; 
  292.  
  293. private 
  294.  
  295.    type Gtk_Assistant_Record is 
  296.      new Gtk.Window.Gtk_Window_Record with null record; 
  297.  
  298.    pragma Import (C, Get_Type, "gtk_assistant_get_type"); 
  299.  
  300.    Complete_Property : constant Glib.Properties.Property_Boolean := 
  301.      Glib.Properties.Build ("complete"); 
  302.    Header_Image_Property : constant Glib.Properties.Property_Object := 
  303.      Glib.Properties.Build ("header-image"); 
  304.    Page_Type_Property : constant Glib.Properties.Property_Enum := 
  305.      Glib.Properties.Build ("page-type"); 
  306.    Sidebar_Image_Property : constant Glib.Properties.Property_Object := 
  307.      Glib.Properties.Build ("sidebar-image"); 
  308.    Title_Property : constant Glib.Properties.Property_String := 
  309.      Glib.Properties.Build ("title"); 
  310.  
  311.    Content_Padding_Property : constant Glib.Properties.Property_Int := 
  312.      Glib.Properties.Build ("content-padding"); 
  313.    Header_Padding_Property : constant Glib.Properties.Property_Int := 
  314.      Glib.Properties.Build ("header-padding"); 
  315.  
  316. end Gtk.Assistant;