1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --                   Copyright (C) 2002-2007 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. --  An accel_map provides support for loading and saving accelerators (see 
  31. --  also Gtk.Accel_Group). 
  32. --  </description> 
  33. --  <c_version>2.8.17</c_version> 
  34.  
  35. with Glib; 
  36. with Gdk.Types; 
  37. with Gtk.Accel_Group; 
  38.  
  39. package Gtk.Accel_Map is 
  40.  
  41.    type Gtk_Accel_Map_Record is 
  42.      new Glib.Object.GObject_Record with null record; 
  43.    type Gtk_Accel_Map is access all Gtk_Accel_Map_Record'Class; 
  44.  
  45.    function Get return Gtk_Accel_Map; 
  46.    --  Gets the singleton global Gtk_Accel_Map object. This object 
  47.    --  is useful only for notification of changes to the accelerator 
  48.    --  map via the ::changed signal; it isn't a parameter to the 
  49.    --  other accelerator map functions. 
  50.  
  51.    function Get_Type return Glib.GType; 
  52.    --  Return the internal type used for a Gtk_Accel_Map 
  53.  
  54.    procedure Save (File_Name : String); 
  55.    --  Save the key shortcuts to a file. These are the shortcuts that might 
  56.    --  have been changed dynamically by the user, if the RC file (see Gtk.RC) 
  57.    --  contained the line "gtk-can-change-accels=1" 
  58.  
  59.    procedure Load (File_Name : String); 
  60.    --  Load the key shortcuts from a file 
  61.  
  62.    procedure Add_Entry 
  63.      (Accel_Path : String; 
  64.       Accel_Key  : Gdk.Types.Gdk_Key_Type; 
  65.       Accel_Mods : Gdk.Types.Gdk_Modifier_Type); 
  66.    --  Register a new accelerator for a given menu item, within the global 
  67.    --  accelerator map. 
  68.    --  This function should only be called once per Accel_Path. To change it 
  69.    --  programmatically during runtime, use Change_Entry. 
  70.    --  Accel_Path is of the form: 
  71.    --     <app>/Category1/Category2/.../Action", 
  72.    --  where "app" is a unique, application-specific identifier (for examples 
  73.    --  of valid Accel_Path, check the file created by Save above). 
  74.    -- 
  75.    --  For instance, the path in the testgtk application for the menu 
  76.    --  File->Open would be 
  77.    --     <testgtk>/file/open 
  78.    -- 
  79.    --  Generally, the path need to be set explicitely for an item, through a 
  80.    --  call to Gtk.Menu_Item.Set_Accel_Path or 
  81.    --  Gtk.Widget.Set_Accel_Path. However, if the widget is created 
  82.    --  automatically through a Gtk.Item_Factory, this is done automatically. 
  83.    -- 
  84.    --  It is better to use this function instead of Add_Accelerator, since when 
  85.    --  the accelerators are changed interactively by the user, the new value 
  86.    --  will be shown properly in the menu, which wouldn't happen if they had 
  87.    --  been forced by Add_Accelerator. 
  88.  
  89.    procedure Lookup_Entry 
  90.      (Accel_Path : String; 
  91.       Key        : out Gtk.Accel_Group.Gtk_Accel_Key; 
  92.       Found      : out Boolean); 
  93.    --  Look up the accelerator for Accel_Path, and set Key appropriately. If no 
  94.    --  accelerator was set, Found is set to False, and the value of Key is 
  95.    --  meaningless. 
  96.  
  97.    function Change_Entry 
  98.      (Accel_Path : String; 
  99.       Accel_Key  : Gdk.Types.Gdk_Key_Type; 
  100.       Accel_Mods : Gdk.Types.Gdk_Modifier_Type; 
  101.       Replace    : Boolean) return Boolean; 
  102.    --  Change the accelerator currently associated wtih Accel_Path. 
  103.    --  A change may not always be possible due to conflicts with other 
  104.    --  accelerators. Replace should be set to True if other accelerators may be 
  105.    --  deleted to resolve such conflicts. 
  106.    --  Returns True if the entry could be changed 
  107.  
  108.    procedure Lock_Path   (Accel_Path : String); 
  109.    procedure Unlock_Path (Accel_Path : String); 
  110.    --  Locks the given accelerator path. If the accelerator map doesn't yet 
  111.    --  contain an entry for Accel_Path, a new one is created. 
  112.    -- 
  113.    --  Locking an accelerator path prevents its accelerator from being changed 
  114.    --  during runtime. A locked accelerator path can be unlocked by 
  115.    --  Unlock_Path. Refer to Change_Entry for information about runtime 
  116.    --  accelerator changes. 
  117.    -- 
  118.    --  If called more than once, Accel_Path remains locked until Unlock_Path 
  119.    --  has been called an equivalent number of times. 
  120.    -- 
  121.    --  Note that locking of individual accelerator paths is independent from 
  122.    --  locking the Gtk_Accel_Group containing them. For runtime accelerator 
  123.    --  changes to be possible both the accelerator path and its accel group 
  124.    --  have to be unlocked. 
  125.  
  126.    ------------- 
  127.    -- Foreach -- 
  128.    ------------- 
  129.  
  130.    procedure Add_Filter (Filter_Pattern : String); 
  131.    --  Adds a filter to the global list of accel path filters. 
  132.    --  Accel map entries whose accel path matches one of the filters 
  133.    --  are skipped by Foreach. 
  134.    --  This function is intended for GTK+ modules that create their own 
  135.    --  menus, but don't want them to be saved into the applications accelerator 
  136.    --  map dump. 
  137.  
  138.    type Gtk_Accel_Map_Foreach is access procedure 
  139.      (Data       : System.Address; 
  140.       Accel_Path : String; 
  141.       Accel_Key  : Gdk.Types.Gdk_Key_Type; 
  142.       Accel_Mods : Gdk.Types.Gdk_Modifier_Type; 
  143.       Changed    : Boolean); 
  144.    --  Changed is set to true if the keybinding was changed manually by the 
  145.    --  user, and thus would need saving during an accelerator map dump. 
  146.  
  147.    procedure Foreach 
  148.      (Data : System.Address; Func : Gtk_Accel_Map_Foreach); 
  149.    --  Calls Func for each of the currently defined key shortcuts. 
  150.    --  Data is passed as is to Func 
  151.  
  152.    procedure Foreach_Unfiltered 
  153.      (Data : System.Address; Func : Gtk_Accel_Map_Foreach); 
  154.    --  Loops over all entries in the accelerator map, and execute 
  155.    --  Func on each. 
  156.  
  157.    ------------- 
  158.    -- Signals -- 
  159.    ------------- 
  160.  
  161.    --  <signals> 
  162.    --  The following new signals are defined for this widget: 
  163.    -- 
  164.    --  - "changed" 
  165.    --    procedure Handler 
  166.    --      (Map : Gtk_Accel_Map; 
  167.    --       Accel_Path : String; 
  168.    --       Accel_Key  : Gdk_Key_Type; 
  169.    --       Accel_Mods : Gdk_Modifier_Type); 
  170.    --    Notifies of a change in the global accelerator map. The path is also 
  171.    --    used as the detail for the signal, so it is possible to connect to 
  172.    --    changed::accel_path. 
  173.    -- 
  174.    --  </signals> 
  175.  
  176.    Signal_Changed : constant Glib.Signal_Name := "changed"; 
  177.  
  178. private 
  179.    pragma Import (C, Get_Type, "gtk_accel_map_get_type"); 
  180. end Gtk.Accel_Map; 
  181.  
  182. --  No binding: gtk_accel_map_load_fd 
  183. --  No binding: gtk_accel_map_save_fd 
  184. --  No binding: gtk_accel_map_load_scanner 
  185.  
  186.