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-2006 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. --  The Gtk_Accel_Label widget is a child of Gtk_Label that also displays an 
  32. --  accelerator key on the right of the label text, e.g. 'Ctl+S'. It is 
  33. --  commonly used in menus to show the keyboard short-cuts for commands. 
  34. -- 
  35. --  The accelerator key to display is not set explicitly. Instead, the 
  36. --  Gtk_Accel_Label displays the accelerators which have been added to a 
  37. --  particular widget. This widget is set by calling Set_Accel_Widget. 
  38. -- 
  39. --  For example, a Gtk_Menu_Item widget may have an accelerator added to emit 
  40. --  the "activate" signal when the 'Ctl+S' key combination is pressed. 
  41. --  A Gtk_Accel_Label is created and added to the Gtk_Menu_Item, and 
  42. --  Set_Accel_Widget is called with the Gtk_Menu_Item as the second argument. 
  43. --  The Gtk_Accel_Label will now display 'Ctl+S' after its label. 
  44. -- 
  45. --  Note that creating a Gtk_Menu_Item with Gtk_New and a non null "label" 
  46. --  parameter (ditto for Gtk_Check_Menu_Item and Gtk_Radio_Menu_Item) 
  47. --  automatically adds a Gtk_Accel_Label to the Gtk_Menu_Item and calls 
  48. --  Set_Accel_Widget to set it up for you. 
  49. -- 
  50. --  A Gtk_Accel_Label will only display accelerators which have the 
  51. --  Accel_Visible (see Gtk.Accel_Group) flag set. A Gtk_Accel_Label can display 
  52. --  multiple accelerators and even signal names, though it is almost always 
  53. --  used to display just one accelerator key. 
  54. --  </description> 
  55. --  <c_version>2.8.17</c_version> 
  56. --  <group>Display widgets</group> 
  57. --  <screenshot>gtk-accel_label</screenshot> 
  58.  
  59. with Glib.Properties; 
  60. with Gtk.Label; 
  61. with Gtk.Widget; 
  62.  
  63. package Gtk.Accel_Label is 
  64.  
  65.    type Gtk_Accel_Label_Record is new Gtk.Label.Gtk_Label_Record with private; 
  66.    type Gtk_Accel_Label is access all Gtk_Accel_Label_Record; 
  67.  
  68.    procedure Gtk_New (Accel_Label : out Gtk_Accel_Label; Str : UTF8_String); 
  69.    --  Create a new Gtk_Accel_Label. 
  70.    --  Str is the label string. 
  71.  
  72.    procedure Initialize 
  73.      (Accel_Label : access Gtk_Accel_Label_Record'Class; Str : UTF8_String); 
  74.    --  Internal initialization function. 
  75.    --  See the section "Creating your own widgets" in the documentation. 
  76.  
  77.    function Get_Type return Gtk.Gtk_Type; 
  78.    --  Return the internal value associated with a Gtk_Accel_Label. 
  79.  
  80.    procedure Set_Accel_Widget 
  81.      (Accel_Label  : access Gtk_Accel_Label_Record; 
  82.       Accel_Widget : access Gtk.Widget.Gtk_Widget_Record'Class); 
  83.    --  Add an accelerator to a particular widget. 
  84.  
  85.    function Get_Accel_Widget 
  86.      (Accel_Label : access Gtk_Accel_Label_Record) 
  87.       return Gtk.Widget.Gtk_Widget; 
  88.    --  Return the widget monitored by Accel_Label. 
  89.  
  90.    function Get_Accel_Width 
  91.      (Accel_Label : access Gtk_Accel_Label_Record) return Guint; 
  92.    --  Return the width needed to display the accelerator key(s). 
  93.    --  This is used by menus to align all of the Gtk_Menu_Item widgets, and 
  94.    --  shouldn't be needed by applications. 
  95.  
  96.    function Refetch 
  97.      (Accel_Label : access Gtk_Accel_Label_Record) return Boolean; 
  98.    --  Recreate the string representing the accelerator keys. 
  99.    --  This should not be needed since the string is automatically updated 
  100.    --  whenever accelerators are added or removed from the associated widget. 
  101.    --  Always return False. 
  102.  
  103.    ---------------- 
  104.    -- Properties -- 
  105.    ---------------- 
  106.  
  107.    --  <properties> 
  108.    --  The following properties are defined for this widget. See 
  109.    --  Glib.Properties for more information on properties. 
  110.    --  </properties> 
  111.  
  112.    ------------- 
  113.    -- Signals -- 
  114.    ------------- 
  115.  
  116.    --  <signals> 
  117.    --  The following new signals are defined for this widget: 
  118.    -- 
  119.    --  Name:  Accel_Closure_Property 
  120.    --  Type:  Boxed 
  121.    --  Descr: The closure to be monitored for accelerator changes 
  122.    -- 
  123.    --  Name:  Accel_Widget_Property 
  124.    --  Type:  Object 
  125.    --  Descr: The widget to be monitored for accelerator changes 
  126.    -- 
  127.    --  </signals> 
  128.  
  129.    --  Accel_Closure_Property : constant Glib.Properties.Property_Boxed; 
  130.    Accel_Widget_Property  : constant Glib.Properties.Property_Object; 
  131.  
  132.  
  133. private 
  134.    type Gtk_Accel_Label_Record is new Gtk.Label.Gtk_Label_Record 
  135.    with null record; 
  136.  
  137.    --  Accel_Closure_Property : constant Glib.Properties.Property_Boxed := 
  138.    --   Glib.Properties.Build ("accel-closure"); 
  139.    Accel_Widget_Property : constant Glib.Properties.Property_Object := 
  140.      Glib.Properties.Build ("accel-widget"); 
  141.  
  142.    pragma Import (C, Get_Type, "gtk_accel_label_get_type"); 
  143.  
  144. end Gtk.Accel_Label; 
  145.  
  146. --  <example> 
  147. --  Creating a simple menu item with an accelerator key. 
  148. -- 
  149. --  Save_Item   : Gtk_Menu_Item; 
  150. --  Accel_Group : Gtk_Accel_Group; 
  151. -- 
  152. --  --  Create a Gtk_Accel_Group and add it to the window. 
  153. --  Gtk_New (Accel_Group); 
  154. --  Add_Accel_Group (Window, Accel_Group); 
  155. -- 
  156. --  --  Create the menu item using the convenience function. 
  157. --  Gtk_New (Save_Item, "Save"); 
  158. --  Show (Save_Item); 
  159. --  Add (Menu, Save_Item); 
  160. -- 
  161. --  --  Now add the accelerator to the Gtk_Menu_Item. Note that since we called 
  162. --  --  Gtk_New with a label to create the Gtk_Menu_Item the 
  163. --  --  Gtk_Accel_Label is automatically set up to display the Gtk_Menu_Item 
  164. --  --  accelerators. We just need to make sure we use Accel_Visible here. 
  165. -- 
  166. --  Add_Accelerator 
  167. --    (Save_Item, "activate", Accel_Group, 
  168. --     GDK_S, Control_Mask, Accel_Visible); 
  169. --  </example> 
  170.  
  171. --  No binding: gtk_accel_label_set_accel_closure