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