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