1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --   Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet   -- 
  5. --                Copyright (C) 2000-2009, AdaCore                   -- 
  6. --                                                                   -- 
  7. -- This library is free software; you can redistribute it and/or     -- 
  8. -- modify it under the terms of the GNU General Public               -- 
  9. -- License as published by the Free Software Foundation; either      -- 
  10. -- version 2 of the License, or (at your option) any later version.  -- 
  11. --                                                                   -- 
  12. -- This library is distributed in the hope that it will be useful,   -- 
  13. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  14. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  15. -- General Public License for more details.                          -- 
  16. --                                                                   -- 
  17. -- You should have received a copy of the GNU General Public         -- 
  18. -- License along with this library; if not, write to the             -- 
  19. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  20. -- Boston, MA 02111-1307, USA.                                       -- 
  21. --                                                                   -- 
  22. -- -- -- -- -- -- -- -- -- -- -- --
  23. ----------------------------------------------------------------------- 
  24.  
  25. --  <description> 
  26. --  An accel group represents a group of keyboard accelerators, generally 
  27. --  attached to a toplevel window. 
  28. --  Accelerators are different from mnemonics. Accelerators are shortcuts for 
  29. --  activating a menu item. They appear alongside the menu item they are a 
  30. --  shortcut for. Mnemonics are shortcuts for GUI elements, such as buttons. 
  31. --  They appear as underline characters. Menu items can have both. 
  32. --  </description> 
  33. --  <c_version>2.16</c_version> 
  34.  
  35. with Gdk.Types; 
  36. with Gtk.Object; 
  37.  
  38. package Gtk.Accel_Group is 
  39.  
  40.    type Gtk_Accel_Group_Record is new Glib.Object.GObject_Record with private; 
  41.    type Gtk_Accel_Group is access all Gtk_Accel_Group_Record'Class; 
  42.    type Gtk_Accel_Group_Entry is new Gdk.C_Proxy; 
  43.  
  44.    type Gtk_Accel_Flags is new Guint; 
  45.    Accel_Visible : constant Gtk_Accel_Flags; 
  46.    Accel_Locked  : constant Gtk_Accel_Flags; 
  47.    Accel_Mask    : constant Gtk_Accel_Flags; 
  48.  
  49.    type Gtk_Accel_Key is record 
  50.       Accel_Key  : Gdk.Types.Gdk_Key_Type; 
  51.       Accel_Mods : Gdk.Types.Gdk_Modifier_Type; 
  52.       Flags      : Gtk_Accel_Flags; 
  53.    end record; 
  54.    pragma Convention (C, Gtk_Accel_Key); 
  55.  
  56.    type Gtk_Accel_Group_Activate is access function 
  57.      (Accel_Group   : access Gtk_Accel_Group_Record'Class; 
  58.       Acceleratable : Glib.Object.GObject; 
  59.       Keyval        : Gdk.Types.Gdk_Key_Type; 
  60.       Modifier      : Gdk.Types.Gdk_Modifier_Type) return Boolean; 
  61.  
  62.    procedure Gtk_New (Accel_Group : out Gtk_Accel_Group); 
  63.    procedure Initialize (Accel_Group : access Gtk_Accel_Group_Record'Class); 
  64.    --  Remember to call Gtk.Window.Add_Accel_Group to active the group. 
  65.  
  66.    function Get_Type return Glib.GType; 
  67.    --  Return the internal value associated with a Gtk_Accel_Group. 
  68.  
  69.    procedure Lock (Accel_Group : access Gtk_Accel_Group_Record); 
  70.    procedure Unlock (Accel_Group : access Gtk_Accel_Group_Record); 
  71.    function Get_Is_Locked 
  72.      (Accel_Group : access Gtk_Accel_Group_Record) return Boolean; 
  73.    --  Locks or unlocks the group.  When a group is locked, the accelerators 
  74.    --  contained in it cannot be changed at runtime by the user. See 
  75.    --  Gtk_Accel_Map.Change_Entry about runtime accelerator changes. 
  76.    --  Unlock must be called the same number of time that Lock was called. 
  77.  
  78.    ------------ 
  79.    -- Groups -- 
  80.    ------------ 
  81.  
  82.    function Accel_Groups_Activate 
  83.      (Object     : access Gtk.Object.Gtk_Object_Record'Class; 
  84.       Accel_Key  : Gdk.Types.Gdk_Key_Type; 
  85.       Accel_Mods : Gdk.Types.Gdk_Modifier_Type) return Boolean; 
  86.    --  Find the first accelerator in any group, attached to Object that matches 
  87.    --  the given key and modifier, and activate that accelerator. 
  88.    --  Returns True if an accelerator was activated. 
  89.  
  90.    function From_Object 
  91.      (Object : access Gtk.Object.Gtk_Object_Record'Class) 
  92.       return Object_List.GSlist; 
  93.    --  Gets a list of all accel groups which are attached to Object. 
  94.  
  95.    ------------------ 
  96.    -- Accelerators -- 
  97.    ------------------ 
  98.  
  99.    function Accelerator_Valid 
  100.      (Keyval    : Gdk.Types.Gdk_Key_Type; 
  101.       Modifiers : Gdk.Types.Gdk_Modifier_Type) return Boolean; 
  102.    --  Determines whether a given keyval and modifier constitute a valid 
  103.    --  accelerator. For instance, GDK_Control_L is not a valid accelerator, 
  104.    --  whereas Gdk_L associated with Control_Mask is valid. 
  105.  
  106.    procedure Accelerator_Parse 
  107.      (Accelerator      : String; 
  108.       Accelerator_Key  : out Gdk.Types.Gdk_Key_Type; 
  109.       Accelerator_Mods : out Gdk.Types.Gdk_Modifier_Type); 
  110.    --  Parse a string representing an accelerator. The format looks like 
  111.    --  "<Control>a", "<Shift><Alt>a" or "<Release>z" (the last one applies to 
  112.    --  a key release. Abbreviations such as "Ctrl" are allowed. 
  113.  
  114.    function Accelerator_Name 
  115.      (Accelerator_Key  : Gdk.Types.Gdk_Key_Type; 
  116.       Accelerator_Mods : Gdk.Types.Gdk_Modifier_Type) return String; 
  117.    --  Converts an accelerator keyval and modifier mask into a string parseable 
  118.    --  by Accelerator_Parse. For example, if you pass in GDK_q and 
  119.    --  GDK_CONTROL_MASK, this function returns "<Control>q". 
  120.    --  If you need to display accelerators in the user interface, see 
  121.    --  Accelerator_Get_Label. 
  122.  
  123.    function Accelerator_Get_Label 
  124.      (Accelerator_Key  : Gdk.Types.Gdk_Key_Type; 
  125.       Accelerator_Mods : Gdk.Types.Gdk_Modifier_Type) return String; 
  126.    --  Converts an accelerator keyval and modifier mask into a string 
  127.    --  which can be used to represent the accelerator to the user. 
  128.  
  129.    procedure Set_Default_Mod_Mask 
  130.      (Default_Mod_Mask : Gdk.Types.Gdk_Modifier_Type); 
  131.    function Get_Default_Mod_Mask return Gdk.Types.Gdk_Modifier_Type; 
  132.    --  Sets the modifiers that will be considered significant for keyboard 
  133.    --  accelerators. The default mod mask is GDK_CONTROL_MASK | GDK_SHIFT_MASK 
  134.    --  | GDK_MOD1_MASK, that is, Control, Shift, and Alt. Other modifiers will 
  135.    --  by default be ignored by GtkAccelGroup. You must include at least the 
  136.    --  three default modifiers in any value you pass to this function. 
  137.    -- 
  138.    --  The default mod mask should be changed on application startup, before 
  139.    --  using any accelerator groups. 
  140.  
  141.    function Get_Modifier_Mask 
  142.      (Accel_Group : access Gtk_Accel_Group_Record) 
  143.       return Gdk.Types.Gdk_Modifier_Type; 
  144.    --  Gets a modifier type representing the mask for this 
  145.    --  Accel_Group. For example, GDK_CONTROL_MASK, GDK_SHIFT_MASK, etc. 
  146.  
  147.    ------------- 
  148.    -- Signals -- 
  149.    ------------- 
  150.  
  151.    --  <signals> 
  152.    --  The following new signals are defined for this widget: 
  153.    -- 
  154.    --  - "accel_activate" 
  155.    --    procedure Handler 
  156.    --      (Group         : access Gtk_Accel_Group_Record'Class; 
  157.    --       Acceleratable : access GObject_Record'Class; 
  158.    --       Keyval        : Gdk_Key_Type; 
  159.    --       Modifier      : Gdk_Modifier_Type); 
  160.    --    This is an implementation detail, not meant to be used by applications 
  161.    -- 
  162.    --  - "accel_changed" 
  163.    --    procedure Handler 
  164.    --      (Group         : access Gtk_Accel_Group_Record'Class; 
  165.    --       Keyval        : Gdk_Key_Type; 
  166.    --       Modifier      : Gdk_Modifier_Type; 
  167.    --       Closure       : GClosure); 
  168.    --    Emitted when a Gtk_Accel_Group_Entry is added to or removed from the 
  169.    --    accel group. 
  170.    --    Widgets like Gtk_Accel_Label which display an associated accelerator 
  171.    --    should connect to this signal, and rebuild their visual representation 
  172.    --    if the accel_closure is theirs. 
  173.    --  </signals> 
  174.  
  175.    Signal_Accel_Activate : constant Glib.Signal_Name := "accel_activate"; 
  176.    Signal_Accel_Changed  : constant Glib.Signal_Name := "accel_changed"; 
  177.  
  178. private 
  179.  
  180.    type Gtk_Accel_Group_Record is new Glib.Object.GObject_Record with 
  181.      null record; 
  182.  
  183.    Accel_Visible : constant Gtk_Accel_Flags := 2 ** 0; 
  184.    Accel_Locked  : constant Gtk_Accel_Flags := 2 ** 1; 
  185.    Accel_Mask    : constant Gtk_Accel_Flags := 16#07#; 
  186.  
  187.    pragma Import (C, Get_Type, "gtk_accel_group_get_type"); 
  188.  
  189.    pragma Import 
  190.      (C, Set_Default_Mod_Mask, "gtk_accelerator_set_default_mod_mask"); 
  191.    pragma Import 
  192.      (C, Get_Default_Mod_Mask, "gtk_accelerator_get_default_mod_mask"); 
  193. end Gtk.Accel_Group; 
  194.  
  195. --  This function is mostly internal, better used through 
  196. --  gtk_accel_groups_activate 
  197. --  No binding: gtk_accel_group_activate 
  198.  
  199. --  We are missing a binding of GClosure for the following functions 
  200. --  No binding: gtk_accel_group_connect 
  201. --  No binding: gtk_accel_group_connect_by_path 
  202. --  No binding: gtk_accel_group_disconnect 
  203. --  No binding: gtk_accel_group_disconnect_key 
  204. --  No binding: gtk_accel_group_find 
  205. --  No binding: gtk_accel_group_from_accel_closure 
  206. --  No binding: gtk_accel_group_query