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