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. --  Gtk.Info_Bar.Gtk_Info_Bar is a widget that can be used to show messages to 
  26. --  the user without showing a dialog. It is often temporarily shown at the top 
  27. --  or bottom of a document. In contrast to Gtk.Dialog.Gtk_Dialog, which has a 
  28. --  horizontal action area at the bottom, Gtk.Info_Bar.Gtk_Info_Bar has a 
  29. --  vertical action area at the side. 
  30. -- 
  31. --  The API of Gtk.Info_Bar.Gtk_Info_Bar is very similar to 
  32. --  Gtk.Dialog.Gtk_Dialog, allowing you to add buttons to the action area with 
  33. --  Gtk.Info_Bar.Add_Button or gtk_info_bar_new_with_buttons. The sensitivity 
  34. --  of action widgets can be controlled with 
  35. --  Gtk.Info_Bar.Set_Response_Sensitive. To add widgets to the main content 
  36. --  area of a Gtk.Info_Bar.Gtk_Info_Bar, use Gtk.Info_Bar.Get_Content_Area and 
  37. --  add your widgets to the container. 
  38. -- 
  39. --  Similar to Gtk.Message_Dialog.Gtk_Message_Dialog, the contents of a 
  40. --  Gtk.Info_Bar.Gtk_Info_Bar can by classified as error message, warning, 
  41. --  informational message, etc, by using Gtk.Info_Bar.Set_Message_Type. GTK+ 
  42. --  uses the message type to determine the background color of the message 
  43. --  area. 
  44. -- 
  45. --  == Simple GtkInfoBar usage. == 
  46. -- 
  47. --    /* set up info bar */ 
  48. --    info_bar = gtk_info_bar_new (); 
  49. --    gtk_widget_set_no_show_all (info_bar, TRUE); 
  50. --    message_label = gtk_label_new (""); 
  51. --    gtk_widget_show (message_label); 
  52. --    content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar)); 
  53. --    gtk_container_add (GTK_CONTAINER (content_area), message_label); 
  54. --    gtk_info_bar_add_button (GTK_INFO_BAR (info_bar), 
  55. --       GTK_STOCK_OK, GTK_RESPONSE_OK); 
  56. --    g_signal_connect (info_bar, "response", 
  57. --       G_CALLBACK (gtk_widget_hide), NULL); 
  58. --    gtk_grid_attach (GTK_GRID (grid), 
  59. --       info_bar, 
  60. --       0, 2, 1, 1); 
  61. --    /* ... */ 
  62. --    /* show an error message */ 
  63. --    gtk_label_set_text (GTK_LABEL (message_label), error_message); 
  64. --    gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), 
  65. --       GTK_MESSAGE_ERROR); 
  66. --    gtk_widget_show (info_bar); 
  67. -- 
  68. --  == GtkInfoBar as GtkBuildable == 
  69. -- 
  70. --  The GtkInfoBar implementation of the GtkBuildable interface exposes the 
  71. --  content area and action area as internal children with the names 
  72. --  "content_area" and "action_area". 
  73. -- 
  74. --  GtkInfoBar supports a custom <action-widgets> element, which can contain 
  75. --  multiple <action-widget> elements. The "response" attribute specifies a 
  76. --  numeric response, and the content of the element is the id of widget (which 
  77. --  should be a child of the dialogs Action_Area). 
  78. -- 
  79. -- 
  80. --  </description> 
  81. pragma Ada_2005; 
  82.  
  83. pragma Warnings (Off, "*is already use-visible*"); 
  84. with Glib;               use Glib; 
  85. with Glib.Object;        use Glib.Object; 
  86. with Glib.Types;         use Glib.Types; 
  87. with Gtk.Box;            use Gtk.Box; 
  88. with Gtk.Buildable;      use Gtk.Buildable; 
  89. with Gtk.Enums;          use Gtk.Enums; 
  90. with Gtk.Message_Dialog; use Gtk.Message_Dialog; 
  91. with Gtk.Orientable;     use Gtk.Orientable; 
  92. with Gtk.Widget;         use Gtk.Widget; 
  93.  
  94. package Gtk.Info_Bar is 
  95.  
  96.    type Gtk_Info_Bar_Record is new Gtk_Box_Record with null record; 
  97.    type Gtk_Info_Bar is access all Gtk_Info_Bar_Record'Class; 
  98.  
  99.    ------------------ 
  100.    -- Constructors -- 
  101.    ------------------ 
  102.  
  103.    procedure Gtk_New (Self : out Gtk_Info_Bar); 
  104.    procedure Initialize (Self : not null access Gtk_Info_Bar_Record'Class); 
  105.    --  Creates a new Gtk.Info_Bar.Gtk_Info_Bar object. 
  106.    --  Since: gtk+ 2.18 
  107.  
  108.    function Gtk_Info_Bar_New return Gtk_Info_Bar; 
  109.    --  Creates a new Gtk.Info_Bar.Gtk_Info_Bar object. 
  110.    --  Since: gtk+ 2.18 
  111.  
  112.    function Get_Type return Glib.GType; 
  113.    pragma Import (C, Get_Type, "gtk_info_bar_get_type"); 
  114.  
  115.    ------------- 
  116.    -- Methods -- 
  117.    ------------- 
  118.  
  119.    procedure Add_Action_Widget 
  120.       (Self        : not null access Gtk_Info_Bar_Record; 
  121.        Child       : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  122.        Response_Id : Gint); 
  123.    --  Add an activatable widget to the action area of a 
  124.    --  Gtk.Info_Bar.Gtk_Info_Bar, connecting a signal handler that will emit 
  125.    --  the Gtk.Info_Bar.Gtk_Info_Bar::response signal on the message area when 
  126.    --  the widget is activated. The widget is appended to the end of the 
  127.    --  message areas action area. 
  128.    --  Since: gtk+ 2.18 
  129.    --  "child": an activatable widget 
  130.    --  "response_id": response ID for Child 
  131.  
  132.    function Add_Button 
  133.       (Self        : not null access Gtk_Info_Bar_Record; 
  134.        Button_Text : UTF8_String; 
  135.        Response_Id : Gint) return Gtk.Widget.Gtk_Widget; 
  136.    --  Adds a button with the given text (or a stock button, if button_text is 
  137.    --  a stock ID) and sets things up so that clicking the button will emit the 
  138.    --  "response" signal with the given response_id. The button is appended to 
  139.    --  the end of the info bars's action area. The button widget is returned, 
  140.    --  but usually you don't need it. 
  141.    --  Since: gtk+ 2.18 
  142.    --  "button_text": text of button, or stock ID 
  143.    --  "response_id": response ID for the button 
  144.  
  145.    function Get_Action_Area 
  146.       (Self : not null access Gtk_Info_Bar_Record) 
  147.        return Gtk.Widget.Gtk_Widget; 
  148.    --  Returns the action area of Info_Bar. 
  149.    --  Since: gtk+ 2.18 
  150.  
  151.    function Get_Content_Area 
  152.       (Self : not null access Gtk_Info_Bar_Record) 
  153.        return Gtk.Widget.Gtk_Widget; 
  154.    --  Returns the content area of Info_Bar. 
  155.    --  Since: gtk+ 2.18 
  156.  
  157.    function Get_Message_Type 
  158.       (Self : not null access Gtk_Info_Bar_Record) 
  159.        return Gtk.Message_Dialog.Gtk_Message_Type; 
  160.    --  Returns the message type of the message area. 
  161.    --  Since: gtk+ 2.18 
  162.  
  163.    procedure Set_Message_Type 
  164.       (Self         : not null access Gtk_Info_Bar_Record; 
  165.        Message_Type : Gtk.Message_Dialog.Gtk_Message_Type); 
  166.    --  Sets the message type of the message area. GTK+ uses this type to 
  167.    --  determine what color to use when drawing the message area. 
  168.    --  Since: gtk+ 2.18 
  169.    --  "message_type": a Gtk.Message_Dialog.Gtk_Message_Type 
  170.  
  171.    procedure Response 
  172.       (Self        : not null access Gtk_Info_Bar_Record; 
  173.        Response_Id : Gint); 
  174.    --  Emits the 'response' signal with the given Response_Id. 
  175.    --  Since: gtk+ 2.18 
  176.    --  "response_id": a response ID 
  177.  
  178.    procedure Set_Default_Response 
  179.       (Self        : not null access Gtk_Info_Bar_Record; 
  180.        Response_Id : Gint); 
  181.    --  Sets the last widget in the info bar's action area with the given 
  182.    --  response_id as the default widget for the dialog. Pressing "Enter" 
  183.    --  normally activates the default widget. 
  184.    --  Note that this function currently requires Info_Bar to be added to a 
  185.    --  widget hierarchy. 
  186.    --  Since: gtk+ 2.18 
  187.    --  "response_id": a response ID 
  188.  
  189.    procedure Set_Response_Sensitive 
  190.       (Self        : not null access Gtk_Info_Bar_Record; 
  191.        Response_Id : Gint; 
  192.        Setting     : Boolean); 
  193.    --  Calls gtk_widget_set_sensitive (widget, setting) for each widget in the 
  194.    --  info bars's action area with the given response_id. A convenient way to 
  195.    --  sensitize/desensitize dialog buttons. 
  196.    --  Since: gtk+ 2.18 
  197.    --  "response_id": a response ID 
  198.    --  "setting": TRUE for sensitive 
  199.  
  200.    --------------------------------------------- 
  201.    -- Inherited subprograms (from interfaces) -- 
  202.    --------------------------------------------- 
  203.    --  Methods inherited from the Buildable interface are not duplicated here 
  204.    --  since they are meant to be used by tools, mostly. If you need to call 
  205.    --  them, use an explicit cast through the "-" operator below. 
  206.  
  207.    function Get_Orientation 
  208.       (Self : not null access Gtk_Info_Bar_Record) 
  209.        return Gtk.Enums.Gtk_Orientation; 
  210.  
  211.    procedure Set_Orientation 
  212.       (Self        : not null access Gtk_Info_Bar_Record; 
  213.        Orientation : Gtk.Enums.Gtk_Orientation); 
  214.  
  215.    ---------------- 
  216.    -- Properties -- 
  217.    ---------------- 
  218.    --  The following properties are defined for this widget. See 
  219.    --  Glib.Properties for more information on properties) 
  220.  
  221.    Message_Type_Property : constant Gtk.Message_Dialog.Property_Gtk_Message_Type; 
  222.    --  Type: Gtk.Message_Dialog.Gtk_Message_Type 
  223.    --  The type of the message. 
  224.    -- 
  225.    --  The type is used to determine the colors to use in the info bar. The 
  226.    --  following symbolic color names can by used to customize these colors: 
  227.    --  "info_fg_color", "info_bg_color", "warning_fg_color", 
  228.    --  "warning_bg_color", "question_fg_color", "question_bg_color", 
  229.    --  "error_fg_color", "error_bg_color". "other_fg_color", "other_bg_color". 
  230.    -- 
  231.    --  If the type is GTK_MESSAGE_OTHER, no info bar is painted but the colors 
  232.    --  are still set. 
  233.  
  234.    ------------- 
  235.    -- Signals -- 
  236.    ------------- 
  237.  
  238.    type Cb_Gtk_Info_Bar_Void is not null access procedure (Self : access Gtk_Info_Bar_Record'Class); 
  239.  
  240.    type Cb_GObject_Void is not null access procedure 
  241.      (Self : access Glib.Object.GObject_Record'Class); 
  242.  
  243.    Signal_Close : constant Glib.Signal_Name := "close"; 
  244.    procedure On_Close 
  245.       (Self  : not null access Gtk_Info_Bar_Record; 
  246.        Call  : Cb_Gtk_Info_Bar_Void; 
  247.        After : Boolean := False); 
  248.    procedure On_Close 
  249.       (Self  : not null access Gtk_Info_Bar_Record; 
  250.        Call  : Cb_GObject_Void; 
  251.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  252.        After : Boolean := False); 
  253.    --  The ::close signal is a <link linkend="keybinding-signals">keybinding 
  254.    --  signal</link> which gets emitted when the user uses a keybinding to 
  255.    --  dismiss the info bar. 
  256.    -- 
  257.    --  The default binding for this signal is the Escape key. 
  258.  
  259.    type Cb_Gtk_Info_Bar_Gint_Void is not null access procedure 
  260.      (Self        : access Gtk_Info_Bar_Record'Class; 
  261.       Response_Id : Gint); 
  262.  
  263.    type Cb_GObject_Gint_Void is not null access procedure 
  264.      (Self        : access Glib.Object.GObject_Record'Class; 
  265.       Response_Id : Gint); 
  266.  
  267.    Signal_Response : constant Glib.Signal_Name := "response"; 
  268.    procedure On_Response 
  269.       (Self  : not null access Gtk_Info_Bar_Record; 
  270.        Call  : Cb_Gtk_Info_Bar_Gint_Void; 
  271.        After : Boolean := False); 
  272.    procedure On_Response 
  273.       (Self  : not null access Gtk_Info_Bar_Record; 
  274.        Call  : Cb_GObject_Gint_Void; 
  275.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  276.        After : Boolean := False); 
  277.    --  Emitted when an action widget is clicked or the application programmer 
  278.    --  calls Gtk.Dialog.Response. The Response_Id depends on which action 
  279.    --  widget was clicked. 
  280.  
  281.    ---------------- 
  282.    -- Interfaces -- 
  283.    ---------------- 
  284.    --  This class implements several interfaces. See Glib.Types 
  285.    -- 
  286.    --  - "Buildable" 
  287.    -- 
  288.    --  - "Orientable" 
  289.  
  290.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  291.      (Gtk.Buildable.Gtk_Buildable, Gtk_Info_Bar_Record, Gtk_Info_Bar); 
  292.    function "+" 
  293.      (Widget : access Gtk_Info_Bar_Record'Class) 
  294.    return Gtk.Buildable.Gtk_Buildable 
  295.    renames Implements_Gtk_Buildable.To_Interface; 
  296.    function "-" 
  297.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  298.    return Gtk_Info_Bar 
  299.    renames Implements_Gtk_Buildable.To_Object; 
  300.  
  301.    package Implements_Gtk_Orientable is new Glib.Types.Implements 
  302.      (Gtk.Orientable.Gtk_Orientable, Gtk_Info_Bar_Record, Gtk_Info_Bar); 
  303.    function "+" 
  304.      (Widget : access Gtk_Info_Bar_Record'Class) 
  305.    return Gtk.Orientable.Gtk_Orientable 
  306.    renames Implements_Gtk_Orientable.To_Interface; 
  307.    function "-" 
  308.      (Interf : Gtk.Orientable.Gtk_Orientable) 
  309.    return Gtk_Info_Bar 
  310.    renames Implements_Gtk_Orientable.To_Object; 
  311.  
  312. private 
  313.    Message_Type_Property : constant Gtk.Message_Dialog.Property_Gtk_Message_Type := 
  314.      Gtk.Message_Dialog.Build ("message-type"); 
  315. end Gtk.Info_Bar;