1. ----------------------------------------------------------------------- 
  2. --              GtkAda - Ada95 binding for Gtk+/Gnome                -- 
  3. --                                                                   -- 
  4. --                Copyright (C) 2006-2013, 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. --  Actions represent operations that the user can perform, along with some 
  31. --  information on how it should be presented in the interface. Each action 
  32. --  provides methods to create icons, menu items and toolbar items representing 
  33. --  itself. 
  34. -- 
  35. --  As well as the callback that is called when the action gets activated, the 
  36. --  following also gets associated with the action: 
  37. --    - a name (not translated, for path lookup) 
  38. --    - a label (translated, for display) 
  39. --    - an accelerator 
  40. --    - whether label indicates a stock id 
  41. --    - a tooltip (optional, translated) 
  42. --    - a toolbar label (optional, shorter than label) 
  43. -- 
  44. --  The action will also have some state information: 
  45. --    - visible (shown/hidden) 
  46. --    - sensitive (enabled/disabled) 
  47. -- 
  48. --  Apart from regular actions, there are toggle actions, which can be toggled 
  49. --  between two states and radio actions, of which only one in a group can be 
  50. --  in the "active" state. Other actions can be implemented as Gtk_Action 
  51. --  subclasses. 
  52. -- 
  53. --  Each action can have one or more proxy menu item, toolbar button or other 
  54. --  proxy widgets. Proxies mirror the state of the action (text label, tooltip, 
  55. --  icon, visible, sensitive, etc), and should change when the action's state 
  56. --  changes. When the proxy is activated, it should activate its action. 
  57. --  </description> 
  58. --  <c_version>2.16.6</c_version> 
  59. --  <group>Action-based menus</group> 
  60.  
  61. with Glib.G_Icon; 
  62. with Glib.Object; 
  63. with Glib.Properties; 
  64. with Gtk.Accel_Group; 
  65. with Gtk.Enums; 
  66. with Gtk.Widget; 
  67. with System; 
  68.  
  69. package Gtk.Action is 
  70.  
  71.    type Gtk_Action_Record is new Glib.Object.GObject_Record with private; 
  72.    type Gtk_Action is access all Gtk_Action_Record'Class; 
  73.  
  74.    procedure Gtk_New 
  75.      (Action   : out Gtk_Action; 
  76.       Name     : String; 
  77.       Label    : String; 
  78.       Tooltip  : String := ""; 
  79.       Stock_Id : String := ""); 
  80.    procedure Initialize 
  81.      (Action   : access Gtk_Action_Record'Class; 
  82.       Name     : String; 
  83.       Label    : String; 
  84.       Tooltip  : String := ""; 
  85.       Stock_Id : String := ""); 
  86.    --  Creates a new Gtk_Action object. To add the action to a Gtk_Action_Group 
  87.    --  and set the accelerator for the action, call 
  88.    --  Gtk.Action_Group.Add_Action_With_Accel. 
  89.    --  Name must be a unique name for the action. Label is the label displayed 
  90.    --  in menu items and on buttons. 
  91.  
  92.    function Convert (C_Object : System.Address) return Gtk_Action; 
  93.    --  Convert a C object to a Gtk_Action. The type of the C object must match, 
  94.    --  of course. 
  95.  
  96.    function Get_Type return GType; 
  97.    --  Return the internal value associated with a Gtk_Action 
  98.  
  99.    procedure Activate (Action : access Gtk_Action_Record); 
  100.    --  Emits the "activate" signal on the specified action, if it isn't 
  101.    --  insensitive. This gets called by the proxy widgets when they get 
  102.    --  activated. 
  103.    --  It can also be used to manually activate an action. 
  104.  
  105.    procedure Connect_Accelerator    (Action : access Gtk_Action_Record); 
  106.    procedure Disconnect_Accelerator (Action : access Gtk_Action_Record); 
  107.    --  Installs the accelerator for Action if Action has an accel path and 
  108.    --  group. See Set_Accel_Path and Set_Accel_Group. 
  109.    --  Since multiple proxies may independently trigger the installation 
  110.    --  of the accelerator, the Action counts the number of times this 
  111.    --  function has been called and doesn't remove the accelerator until 
  112.    --  Disconnect_Accelerator has been called as many times. 
  113.  
  114.    function Create_Icon 
  115.      (Action    : access Gtk_Action_Record; 
  116.       Icon_Size : Gtk.Enums.Gtk_Icon_Size) return Gtk.Widget.Gtk_Widget; 
  117.    --  This function is intended for use by action implementations to 
  118.    --  create icons displayed in the proxy widgets. 
  119.    --  Returns a widget that displays the icon for this action. 
  120.  
  121.    function Get_GIcon (Action : access Gtk_Action_Record) 
  122.       return Glib.G_Icon.G_Icon; 
  123.    procedure Set_GIcon 
  124.      (Action : access Gtk_Action_Record; 
  125.       Icon   : Glib.G_Icon.G_Icon); 
  126.    --  Gets/Sets the Action's G_Icon. 
  127.  
  128.    function Get_Icon_Name (Action : access Gtk_Action_Record) return String; 
  129.    procedure Set_Icon_Name 
  130.      (Action    : access Gtk_Action_Record; 
  131.       Icon_Name : String); 
  132.    --  Gets/Sets the Action's icon name. 
  133.  
  134.    function Get_Is_Important (Action : access Gtk_Action_Record) 
  135.       return Boolean; 
  136.    procedure Set_Is_Important 
  137.      (Action       : access Gtk_Action_Record; 
  138.       Is_Important : Boolean); 
  139.    --  Gets/Sets whether or not Action is important. 
  140.  
  141.    function Get_Label (Action : access Gtk_Action_Record) return String; 
  142.    procedure Set_Label 
  143.      (Action : access Gtk_Action_Record; 
  144.       Label  : String); 
  145.    --  Gets/Sets the label text associated with Action. 
  146.  
  147.    function Get_Short_Label (Action : access Gtk_Action_Record) return String; 
  148.    procedure Set_Short_Label 
  149.      (Action      : access Gtk_Action_Record; 
  150.       Short_Label : String); 
  151.    --  Gets/Sets the short label text of Action. 
  152.  
  153.    function Get_Stock_Id (Action : access Gtk_Action_Record) return String; 
  154.    procedure Set_Stock_Id 
  155.      (Action   : access Gtk_Action_Record; 
  156.       Stock_Id : String); 
  157.    --  Gets/Sets the stock id of Action. 
  158.  
  159.    function Get_Tooltip (Action : access Gtk_Action_Record) return String; 
  160.    procedure Set_Tooltip 
  161.      (Action  : access Gtk_Action_Record; 
  162.       Tooltip : String); 
  163.    --  Gets/Sets the tooltip text associated with Action. 
  164.  
  165.    function Get_Visible_Horizontal (Action : access Gtk_Action_Record) 
  166.       return Boolean; 
  167.    procedure Set_Visible_Horizontal 
  168.      (Action             : access Gtk_Action_Record; 
  169.       Visible_Horizontal : Boolean); 
  170.    --  Gets/Sets whether Action is visible when horizontal. 
  171.  
  172.    function Get_Visible_Vertical (Action : access Gtk_Action_Record) 
  173.       return Boolean; 
  174.    procedure Set_Visible_Vertical 
  175.      (Action           : access Gtk_Action_Record; 
  176.       Visible_Vertical : Boolean); 
  177.    --  Gets/Sets whether Action is visible when vertical. 
  178.  
  179.    function Create_Menu 
  180.      (Action : access Gtk_Action_Record) 
  181.       return Gtk.Widget.Gtk_Widget; 
  182.    --  If Action provides a Gtk_Menu widget as a submenu for the menu 
  183.    --  item or the toolbar item it creates, this function returns an 
  184.    --  instance of that menu. 
  185.    --  Since: 2.12 
  186.  
  187.    function Create_Menu_Item 
  188.      (Action : access Gtk_Action_Record) return Gtk.Widget.Gtk_Widget; 
  189.    --  Creates a menu item widget that proxies for the given action. 
  190.  
  191.    function Create_Tool_Item 
  192.      (Action : access Gtk_Action_Record) return Gtk.Widget.Gtk_Widget; 
  193.    --  Creates a toolbar item widget that proxies for the given action. 
  194.  
  195.    procedure Set_Accel_Group 
  196.      (Action      : access Gtk_Action_Record; 
  197.       Accel_Group : Gtk.Accel_Group.Gtk_Accel_Group := null); 
  198.    --  Sets the Gtk_Accel_Group in which the accelerator for this action 
  199.    --  will be installed. 
  200.  
  201.    procedure Set_Accel_Path 
  202.      (Action : access Gtk_Action_Record; Accel_Path : String); 
  203.    function Get_Accel_Path (Action : access Gtk_Action_Record) return String; 
  204.    --  Sets the accel path for this action.  All proxy widgets associated 
  205.    --  with the action will have this accel path, so that their 
  206.    --  accelerators are consistent. 
  207.  
  208.    function Get_Name (Action : access Gtk_Action_Record) return String; 
  209.    --  Returns the name of the action. 
  210.  
  211.    procedure Set_Sensitive 
  212.      (Action    : access Gtk_Action_Record; Sensitive : Boolean); 
  213.    function Get_Sensitive (Action : access Gtk_Action_Record) return Boolean; 
  214.    --  Returns whether the action itself is sensitive. Note that this doesn't 
  215.    --  necessarily mean effective sensitivity. See Is_Sensitive for that. 
  216.  
  217.    function Is_Sensitive (Action : access Gtk_Action_Record) return Boolean; 
  218.    --  Returns whether the action is effectively sensitive. 
  219.    --  Returns True if teh action and its associated action group are both 
  220.    --  sensitive. 
  221.  
  222.    procedure Set_Visible 
  223.      (Action : access Gtk_Action_Record; Visible : Boolean); 
  224.    function Get_Visible (Action : access Gtk_Action_Record) return Boolean; 
  225.    --  Returns whether the action itself is visible. Note that this doesn't 
  226.    --  necessarily mean effective visibility. See Is_Visible for that. 
  227.  
  228.    function Is_Visible (Action : access Gtk_Action_Record) return Boolean; 
  229.    --  Returns whether the action is effectively visible. 
  230.    --  Returns True if the action and its associated action group are both 
  231.    --  visible. 
  232.  
  233.    ------------- 
  234.    -- Proxies -- 
  235.    ------------- 
  236.  
  237.    function Get_Proxies 
  238.      (Action : access Gtk_Action_Record) return Gtk.Widget.Widget_SList.GSlist; 
  239.    --  Returns the proxy widgets for an action. The returned list must not be 
  240.    --  modified 
  241.  
  242.    function Gtk_Widget_Get_Action 
  243.      (Widget : access Gtk.Widget.Gtk_Widget_Record) return Gtk_Action; 
  244.    pragma Obsolescent (Gtk_Widget_Get_Action); 
  245.    --  Returns the action that Widget is a proxy for. 
  246.    --  See also Get_Proxies. 
  247.    --  Since: 2.10 
  248.  
  249.    procedure Connect_Proxy 
  250.      (Action : access Gtk_Action_Record; 
  251.       Proxy  : access Gtk.Widget.Gtk_Widget_Record'Class); 
  252.    pragma Obsolescent (Connect_Proxy); 
  253.    procedure Disconnect_Proxy 
  254.      (Action : access Gtk_Action_Record; 
  255.       Proxy  : access Gtk.Widget.Gtk_Widget_Record'Class); 
  256.    pragma Obsolescent (Disconnect_Proxy); 
  257.    --  Connects a widget to an action object as a proxy. Synchronises various 
  258.    --  properties of the action with the widget (such as label text, icon, 
  259.    --  tooltip, etc), and attaches a callback so that the action gets activated 
  260.    --  when the proxy widget does. 
  261.    --  If the widget is already connected to an action, it is disconnected 
  262.    --  first. 
  263.    --  Disconnect_Proxy does not destroy the widget. 
  264.  
  265.    procedure Block_Activate   (Action : access Gtk_Action_Record); 
  266.    procedure Unblock_Activate (Action : access Gtk_Action_Record); 
  267.    --  Disable or reenable activation signals from the action.  This is 
  268.    --  needed when updating the state of your proxy widget could result 
  269.    --  in calling Activate.  This is a convenience function to avoid 
  270.    --  recursing in those cases (updating toggle state for instance). 
  271.  
  272.    procedure Block_Activate_From 
  273.      (Action : access Gtk_Action_Record; 
  274.       Proxy  : access Gtk.Widget.Gtk_Widget_Record'Class); 
  275.    pragma Obsolescent (Block_Activate_From); 
  276.    procedure Unblock_Activate_From 
  277.      (Action : access Gtk_Action_Record; 
  278.       Proxy  : access Gtk.Widget.Gtk_Widget_Record'Class); 
  279.    pragma Obsolescent (Unblock_Activate_From); 
  280.    --  Disables calls to the Activate function by signals on the given proxy 
  281.    --  widget. This is used to break notification loops for things like check 
  282.    --  or radio actions. 
  283.    --  This function is intended for use by action implementations. 
  284.  
  285.    ---------------- 
  286.    -- Properties -- 
  287.    ---------------- 
  288.  
  289.    --  <properties> 
  290.    --  The following properties are defined for this widget. See 
  291.    --  Glib.Properties for more information on properties. 
  292.    -- 
  293.    --  Name:  Action_Group_Property 
  294.    --  Type:  Object 
  295.    --  Descr: The Gtk_Action_Group this Gtk_Action is associated with, or NULL 
  296.    --        (for internal use). 
  297.    -- 
  298.    --  Name:  GIcon_Property 
  299.    --  Type:  Object 
  300.    --  Descr: The GIcon being displayed 
  301.    -- 
  302.    --  Name:  Hide_If_Empty_Property 
  303.    --  Type:  Boolean 
  304.    --  Descr: When TRUE, empty menu proxies for this action are hidden. 
  305.    -- 
  306.    --  Name:  Icon_Name_Property 
  307.    --  Type:  String 
  308.    --  Descr: The name of the icon from the icon theme 
  309.    -- 
  310.    --  Name:  Is_Important_Property 
  311.    --  Type:  Boolean 
  312.    --  Descr: Whether the action is considered important. 
  313.    -- 
  314.    --  Name:  Label_Property 
  315.    --  Type:  String 
  316.    --  Descr: The label used for menu items and buttons 
  317.    -- 
  318.    --  Name:  Name_Property 
  319.    --  Type:  String 
  320.    --  Descr: A unique name for the action. 
  321.    -- 
  322.    --  Name:  Sensitive_Property 
  323.    --  Type:  Boolean 
  324.    --  Descr: Whether the action is enabled. 
  325.    -- 
  326.    --  Name:  Short_Label_Property 
  327.    --  Type:  String 
  328.    --  Descr: A shorter label that may be used on toolbar buttons. 
  329.    -- 
  330.    --  Name:  Stock_Id_Property 
  331.    --  Type:  String 
  332.    --  Descr: The stock icon displayed in widgets representing 
  333.    -- 
  334.    --  Name:  Tooltip_Property 
  335.    --  Type:  String 
  336.    --  Descr: A tooltip for this action. 
  337.    -- 
  338.    --  Name:  Visible_Property 
  339.    --  Type:  Boolean 
  340.    --  Descr: Whether the action is visible. 
  341.    -- 
  342.    --  Name:  Visible_Horizontal_Property 
  343.    --  Type:  Boolean 
  344.    --  Descr: Whether the toolbar item is visible when the toolbar 
  345.    -- 
  346.    --  Name:  Visible_Overflown_Property 
  347.    --  Type:  Boolean 
  348.    --  Descr: When TRUE, toolitem proxies for this action 
  349.    -- 
  350.    --  Name:  Visible_Vertical_Property 
  351.    --  Type:  Boolean 
  352.    --  Descr: Whether the toolbar item is visible when the toolbar 
  353.    -- 
  354.    --  </properties> 
  355.  
  356.    Action_Group_Property       : constant Glib.Properties.Property_Object; 
  357.    GIcon_Property              : constant Glib.Properties.Property_Object; 
  358.    Hide_If_Empty_Property      : constant Glib.Properties.Property_Boolean; 
  359.    Icon_Name_Property          : constant Glib.Properties.Property_String; 
  360.    Is_Important_Property       : constant Glib.Properties.Property_Boolean; 
  361.    Label_Property              : constant Glib.Properties.Property_String; 
  362.    Name_Property               : constant Glib.Properties.Property_String; 
  363.    Sensitive_Property          : constant Glib.Properties.Property_Boolean; 
  364.    Short_Label_Property        : constant Glib.Properties.Property_String; 
  365.    Stock_Id_Property           : constant Glib.Properties.Property_String; 
  366.    Tooltip_Property            : constant Glib.Properties.Property_String; 
  367.    Visible_Property            : constant Glib.Properties.Property_Boolean; 
  368.    Visible_Horizontal_Property : constant Glib.Properties.Property_Boolean; 
  369.    Visible_Overflown_Property  : constant Glib.Properties.Property_Boolean; 
  370.    Visible_Vertical_Property   : constant Glib.Properties.Property_Boolean; 
  371.  
  372.    ------------- 
  373.    -- Signals -- 
  374.    ------------- 
  375.  
  376.    --  <signals> 
  377.    --  The following new signals are defined for this widget: 
  378.    -- 
  379.    --  - "activate" 
  380.    --    procedure Handler (Action : access Gtk_Action_Record'Class); 
  381.    --    The "activate" signal is emitted when the action is activated. 
  382.    --  </signals> 
  383.  
  384.    Signal_Activate : constant Glib.Signal_Name := "activate"; 
  385.  
  386. private 
  387.    type Gtk_Action_Record is new Glib.Object.GObject_Record with null record; 
  388.  
  389.    Action_Group_Property : constant Glib.Properties.Property_Object := 
  390.      Glib.Properties.Build ("action-group"); 
  391.    GIcon_Property : constant Glib.Properties.Property_Object := 
  392.      Glib.Properties.Build ("gicon"); 
  393.    Hide_If_Empty_Property : constant Glib.Properties.Property_Boolean := 
  394.      Glib.Properties.Build ("hide-if-empty"); 
  395.    Icon_Name_Property : constant Glib.Properties.Property_String := 
  396.      Glib.Properties.Build ("icon-name"); 
  397.    Is_Important_Property : constant Glib.Properties.Property_Boolean := 
  398.      Glib.Properties.Build ("is-important"); 
  399.    Label_Property : constant Glib.Properties.Property_String := 
  400.      Glib.Properties.Build ("label"); 
  401.    Name_Property : constant Glib.Properties.Property_String := 
  402.      Glib.Properties.Build ("name"); 
  403.    Sensitive_Property : constant Glib.Properties.Property_Boolean := 
  404.      Glib.Properties.Build ("sensitive"); 
  405.    Short_Label_Property : constant Glib.Properties.Property_String := 
  406.      Glib.Properties.Build ("short-label"); 
  407.    Stock_Id_Property : constant Glib.Properties.Property_String := 
  408.      Glib.Properties.Build ("stock-id"); 
  409.    Tooltip_Property : constant Glib.Properties.Property_String := 
  410.      Glib.Properties.Build ("tooltip"); 
  411.    Visible_Property : constant Glib.Properties.Property_Boolean := 
  412.      Glib.Properties.Build ("visible"); 
  413.    Visible_Horizontal_Property : constant Glib.Properties.Property_Boolean := 
  414.      Glib.Properties.Build ("visible-horizontal"); 
  415.    Visible_Overflown_Property : constant Glib.Properties.Property_Boolean := 
  416.      Glib.Properties.Build ("visible-overflown"); 
  417.    Visible_Vertical_Property : constant Glib.Properties.Property_Boolean := 
  418.      Glib.Properties.Build ("visible-vertical"); 
  419.  
  420.    pragma Import (C, Get_Type, "gtk_action_get_type"); 
  421. end Gtk.Action; 
  422.  
  423. --  No binding: gtk_action_get_accel_closure