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