1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  A Gtk.Menu.Gtk_Menu is a Gtk.Menu_Shell.Gtk_Menu_Shell that implements a 
  26. --  drop down menu consisting of a list of Gtk.Menu_Item.Gtk_Menu_Item objects 
  27. --  which can be navigated and activated by the user to perform application 
  28. --  functions. 
  29. -- 
  30. --  A Gtk.Menu.Gtk_Menu is most commonly dropped down by activating a 
  31. --  Gtk.Menu_Item.Gtk_Menu_Item in a Gtk.Menu_Bar.Gtk_Menu_Bar or popped up by 
  32. --  activating a Gtk.Menu_Item.Gtk_Menu_Item in another Gtk.Menu.Gtk_Menu. 
  33. -- 
  34. --  A Gtk.Menu.Gtk_Menu can also be popped up by activating a 
  35. --  Gtk.Combo_Box.Gtk_Combo_Box. Other composite widgets such as the 
  36. --  Gtk.Notebook.Gtk_Notebook can pop up a Gtk.Menu.Gtk_Menu as well. 
  37. -- 
  38. --  Applications can display a Gtk.Menu.Gtk_Menu as a popup menu by calling 
  39. --  the Gtk.Menu.Popup function. The example below shows how an application can 
  40. --  pop up a menu when the 3rd mouse button is pressed. 
  41. -- 
  42. --  == Connecting the popup signal handler. == 
  43. -- 
  44. --    /<!---->* connect our handler which will popup the menu *<!---->/ 
  45. --    g_signal_connect_swapped (window, "button_press_event", 
  46. --       G_CALLBACK (my_popup_handler), menu); 
  47. -- 
  48. --  == Signal handler which displays a popup menu. == 
  49. -- 
  50. --    static gint 
  51. --    my_popup_handler (GtkWidget *widget, GdkEvent *event) 
  52. --    { 
  53. --       GtkMenu *menu; 
  54. --       GdkEventButton *event_button; 
  55. --       g_return_val_if_fail (widget != NULL, FALSE); 
  56. --       g_return_val_if_fail (GTK_IS_MENU (widget), FALSE); 
  57. --       g_return_val_if_fail (event != NULL, FALSE); 
  58. --       /<!---->* The "widget" is the menu that was supplied when 
  59. --       * g_signal_connect_swapped was called. 
  60. --       *<!---->/ 
  61. --       menu = GTK_MENU (widget); 
  62. --       if (event->type == GDK_BUTTON_PRESS) 
  63. --       { 
  64. --          event_button = (GdkEventButton *) event; 
  65. --          if (event_button->button == GDK_BUTTON_SECONDARY) 
  66. --          { 
  67. --             gtk_menu_popup (menu, NULL, NULL, NULL, NULL, 
  68. --                event_button->button, event_button->time); 
  69. --             return TRUE; 
  70. --          } 
  71. --       } 
  72. --       return FALSE; 
  73. --    } 
  74. -- 
  75. -- 
  76. --  </description> 
  77. pragma Ada_2005; 
  78.  
  79. pragma Warnings (Off, "*is already use-visible*"); 
  80. with Gdk.Device;      use Gdk.Device; 
  81. with Gdk.Screen;      use Gdk.Screen; 
  82. with Glib;            use Glib; 
  83. with Glib.Menu_Model; use Glib.Menu_Model; 
  84. with Glib.Object;     use Glib.Object; 
  85. with Glib.Properties; use Glib.Properties; 
  86. with Glib.Types;      use Glib.Types; 
  87. with Gtk.Accel_Group; use Gtk.Accel_Group; 
  88. with Gtk.Buildable;   use Gtk.Buildable; 
  89. with Gtk.Enums;       use Gtk.Enums; 
  90. with Gtk.Menu_Item;   use Gtk.Menu_Item; 
  91. with Gtk.Menu_Shell;  use Gtk.Menu_Shell; 
  92. with Gtk.Widget;      use Gtk.Widget; 
  93.  
  94. package Gtk.Menu is 
  95.  
  96.    type Gtk_Menu_Record is new Gtk_Menu_Shell_Record with null record; 
  97.    type Gtk_Menu is access all Gtk_Menu_Record'Class; 
  98.  
  99.    --------------- 
  100.    -- Callbacks -- 
  101.    --------------- 
  102.  
  103.    type Gtk_Menu_Detach_Func is access procedure (Attach_Widget : System.Address; Menu : System.Address); 
  104.    --  A user function supplied when calling Gtk.Menu.Attach_To_Widget which 
  105.    --  will be called when the menu is later detached from the widget. 
  106.    --  "attach_widget": the Gtk.Widget.Gtk_Widget that the menu is being 
  107.    --  detached from. 
  108.    --  "menu": the Gtk.Menu.Gtk_Menu being detached. 
  109.  
  110.    pragma Convention (C, Gtk_Menu_Detach_Func); 
  111.  
  112.    type Gtk_Menu_Position_Func is access procedure 
  113.      (Menu    : not null access Gtk_Menu_Record'Class; 
  114.       X       : in out Gint; 
  115.       Y       : in out Gint; 
  116.       Push_In : out Boolean); 
  117.    --  A user function supplied when calling Gtk.Menu.Popup which controls the 
  118.    --  positioning of the menu when it is displayed. The function sets the X 
  119.    --  and Y parameters to the coordinates where the menu is to be drawn. To 
  120.    --  make the menu appear on a different monitor than the mouse pointer, 
  121.    --  gtk_menu_set_monitor must be called. 
  122.    --  "menu": a Gtk.Menu.Gtk_Menu. 
  123.    --  "x": address of the Gint representing the horizontal position where the 
  124.    --  menu shall be drawn. 
  125.    --  "y": address of the Gint representing the vertical position where the 
  126.    --  menu shall be drawn. This is an output parameter. 
  127.    --  "push_in": This parameter controls how menus placed outside the monitor 
  128.    --  are handled. If this is set to True and part of the menu is outside the 
  129.    --  monitor then GTK+ pushes the window into the visible area, effectively 
  130.    --  modifying the popup position. Note that moving and possibly resizing the 
  131.    --  menu around will alter the scroll position to keep the menu items "in 
  132.    --  place", i.e. at the same monitor position they would have been without 
  133.    --  resizing. In practice, this behavior is only useful for combobox popups 
  134.    --  or option menus and cannot be used to simply confine a menu to monitor 
  135.    --  boundaries. In that case, changing the scroll offset is not desirable. 
  136.  
  137.    ------------------ 
  138.    -- Constructors -- 
  139.    ------------------ 
  140.  
  141.    procedure Gtk_New (Menu : out Gtk_Menu); 
  142.    procedure Initialize (Menu : not null access Gtk_Menu_Record'Class); 
  143.    --  Creates a new Gtk.Menu.Gtk_Menu 
  144.  
  145.    function Gtk_Menu_New return Gtk_Menu; 
  146.    --  Creates a new Gtk.Menu.Gtk_Menu 
  147.  
  148.    procedure Gtk_New_From_Model 
  149.       (Menu  : out Gtk_Menu; 
  150.        Model : not null access Glib.Menu_Model.Gmenu_Model_Record'Class); 
  151.    procedure Initialize_From_Model 
  152.       (Menu  : not null access Gtk_Menu_Record'Class; 
  153.        Model : not null access Glib.Menu_Model.Gmenu_Model_Record'Class); 
  154.    --  Creates a Gtk.Menu.Gtk_Menu and populates it with menu items and 
  155.    --  submenus according to Model. 
  156.    --  The created menu items are connected to actions found in the 
  157.    --  Gtk.Application_Window.Gtk_Application_Window to which the menu belongs 
  158.    --  - typically by means of being attached to a widget (see 
  159.    --  Gtk.Menu.Attach_To_Widget) that is contained within the 
  160.    --  Gtk_Application_Windows widget hierarchy. 
  161.    --  Since: gtk+ 3.4 
  162.    --  "model": a Glib.Menu_Model.Gmenu_Model 
  163.  
  164.    function Gtk_Menu_New_From_Model 
  165.       (Model : not null access Glib.Menu_Model.Gmenu_Model_Record'Class) 
  166.        return Gtk_Menu; 
  167.    --  Creates a Gtk.Menu.Gtk_Menu and populates it with menu items and 
  168.    --  submenus according to Model. 
  169.    --  The created menu items are connected to actions found in the 
  170.    --  Gtk.Application_Window.Gtk_Application_Window to which the menu belongs 
  171.    --  - typically by means of being attached to a widget (see 
  172.    --  Gtk.Menu.Attach_To_Widget) that is contained within the 
  173.    --  Gtk_Application_Windows widget hierarchy. 
  174.    --  Since: gtk+ 3.4 
  175.    --  "model": a Glib.Menu_Model.Gmenu_Model 
  176.  
  177.    function Get_Type return Glib.GType; 
  178.    pragma Import (C, Get_Type, "gtk_menu_get_type"); 
  179.  
  180.    ------------- 
  181.    -- Methods -- 
  182.    ------------- 
  183.  
  184.    procedure Attach 
  185.       (Menu          : not null access Gtk_Menu_Record; 
  186.        Child         : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  187.        Left_Attach   : Guint; 
  188.        Right_Attach  : Guint; 
  189.        Top_Attach    : Guint; 
  190.        Bottom_Attach : Guint); 
  191.    --  Adds a new Gtk.Menu_Item.Gtk_Menu_Item to a (table) menu. The number of 
  192.    --  'cells' that an item will occupy is specified by Left_Attach, 
  193.    --  Right_Attach, Top_Attach and Bottom_Attach. These each represent the 
  194.    --  leftmost, rightmost, uppermost and lower column and row numbers of the 
  195.    --  table. (Columns and rows are indexed from zero). 
  196.    --  Note that this function is not related to Gtk.Menu.Detach. 
  197.    --  Since: gtk+ 2.4 
  198.    --  "child": a Gtk.Menu_Item.Gtk_Menu_Item 
  199.    --  "left_attach": The column number to attach the left side of the item to 
  200.    --  "right_attach": The column number to attach the right side of the item 
  201.    --  to 
  202.    --  "top_attach": The row number to attach the top of the item to 
  203.    --  "bottom_attach": The row number to attach the bottom of the item to 
  204.  
  205.    procedure Attach_To_Widget 
  206.       (Menu          : not null access Gtk_Menu_Record; 
  207.        Attach_Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  208.        Detacher      : Gtk_Menu_Detach_Func); 
  209.    --  Attaches the menu to the widget and provides a callback function that 
  210.    --  will be invoked when the menu calls Gtk.Menu.Detach during its 
  211.    --  destruction. 
  212.    --  "attach_widget": the Gtk.Widget.Gtk_Widget that the menu will be 
  213.    --  attached to 
  214.    --  "detacher": the user supplied callback function that will be called 
  215.    --  when the menu calls Gtk.Menu.Detach 
  216.  
  217.    procedure Detach (Menu : not null access Gtk_Menu_Record); 
  218.    --  Detaches the menu from the widget to which it had been attached. This 
  219.    --  function will call the callback function, Detacher, provided when the 
  220.    --  Gtk.Menu.Attach_To_Widget function was called. 
  221.  
  222.    function Get_Accel_Group 
  223.       (Menu : not null access Gtk_Menu_Record) 
  224.        return Gtk.Accel_Group.Gtk_Accel_Group; 
  225.    --  Gets the Gtk.Accel_Group.Gtk_Accel_Group which holds global 
  226.    --  accelerators for the menu. See Gtk.Menu.Set_Accel_Group. 
  227.  
  228.    procedure Set_Accel_Group 
  229.       (Menu        : not null access Gtk_Menu_Record; 
  230.        Accel_Group : access Gtk.Accel_Group.Gtk_Accel_Group_Record'Class); 
  231.    --  Set the Gtk.Accel_Group.Gtk_Accel_Group which holds global accelerators 
  232.    --  for the menu. This accelerator group needs to also be added to all 
  233.    --  windows that this menu is being used in with Gtk.Window.Add_Accel_Group, 
  234.    --  in order for those windows to support all the accelerators contained in 
  235.    --  this group. 
  236.    --  "accel_group": the Gtk.Accel_Group.Gtk_Accel_Group to be associated 
  237.    --  with the menu. 
  238.  
  239.    function Get_Accel_Path 
  240.       (Menu : not null access Gtk_Menu_Record) return UTF8_String; 
  241.    --  Retrieves the accelerator path set on the menu. 
  242.    --  Since: gtk+ 2.14 
  243.  
  244.    procedure Set_Accel_Path 
  245.       (Menu       : not null access Gtk_Menu_Record; 
  246.        Accel_Path : UTF8_String := ""); 
  247.    --  Sets an accelerator path for this menu from which accelerator paths for 
  248.    --  its immediate children, its menu items, can be constructed. The main 
  249.    --  purpose of this function is to spare the programmer the inconvenience of 
  250.    --  having to call Gtk.Menu_Item.Set_Accel_Path on each menu item that 
  251.    --  should support runtime user changable accelerators. Instead, by just 
  252.    --  calling Gtk.Menu.Set_Accel_Path on their parent, each menu item of this 
  253.    --  menu, that contains a label describing its purpose, automatically gets 
  254.    --  an accel path assigned. 
  255.    --  For example, a menu containing menu items "New" and "Exit", will, after 
  256.    --  'gtk_menu_set_accel_path (menu, "<Gnumeric-Sheet>/File");' has been 
  257.    --  called, assign its items the accel paths: '"<Gnumeric-Sheet>/File/New"' 
  258.    --  and '"<Gnumeric-Sheet>/File/Exit"'. 
  259.    --  Assigning accel paths to menu items then enables the user to change 
  260.    --  their accelerators at runtime. More details about accelerator paths and 
  261.    --  their default setups can be found at Gtk.Accel_Map.Add_Entry. 
  262.    --  Note that Accel_Path string will be stored in a Glib.GQuark. Therefore, 
  263.    --  if you pass a static string, you can save some memory by interning it 
  264.    --  first with g_intern_static_string. 
  265.    --  "accel_path": a valid accelerator path 
  266.  
  267.    function Get_Active 
  268.       (Menu : not null access Gtk_Menu_Record) 
  269.        return Gtk.Menu_Item.Gtk_Menu_Item; 
  270.    --  Returns the selected menu item from the menu. This is used by the 
  271.    --  Gtk.Combo_Box.Gtk_Combo_Box. 
  272.  
  273.    procedure Set_Active 
  274.       (Menu  : not null access Gtk_Menu_Record; 
  275.        Index : Guint); 
  276.    --  Selects the specified menu item within the menu. This is used by the 
  277.    --  Gtk.Combo_Box.Gtk_Combo_Box and should not be used by anyone else. 
  278.    --  "index": the index of the menu item to select. Iindex values are from 0 
  279.    --  to n-1 
  280.  
  281.    function Get_Attach_Widget 
  282.       (Menu : not null access Gtk_Menu_Record) return Gtk.Widget.Gtk_Widget; 
  283.    --  Returns the Gtk.Widget.Gtk_Widget that the menu is attached to. 
  284.  
  285.    function Get_Monitor (Menu : not null access Gtk_Menu_Record) return Gint; 
  286.    --  Retrieves the number of the monitor on which to show the menu. 
  287.    --  Since: gtk+ 2.14 
  288.  
  289.    procedure Set_Monitor 
  290.       (Menu        : not null access Gtk_Menu_Record; 
  291.        Monitor_Num : Gint); 
  292.    --  Informs GTK+ on which monitor a menu should be popped up. See 
  293.    --  Gdk.Screen.Get_Monitor_Geometry. 
  294.    --  This function should be called from a Gtk_Menu_Position_Func if the 
  295.    --  menu should not appear on the same monitor as the pointer. This 
  296.    --  information can't be reliably inferred from the coordinates returned by 
  297.    --  a Gtk_Menu_Position_Func, since, for very long menus, these coordinates 
  298.    --  may extend beyond the monitor boundaries or even the screen boundaries. 
  299.    --  Since: gtk+ 2.4 
  300.    --  "monitor_num": the number of the monitor on which the menu should be 
  301.    --  popped up 
  302.  
  303.    function Get_Reserve_Toggle_Size 
  304.       (Menu : not null access Gtk_Menu_Record) return Boolean; 
  305.    --  Returns whether the menu reserves space for toggles and icons, 
  306.    --  regardless of their actual presence. 
  307.    --  Since: gtk+ 2.18 
  308.  
  309.    procedure Set_Reserve_Toggle_Size 
  310.       (Menu                : not null access Gtk_Menu_Record; 
  311.        Reserve_Toggle_Size : Boolean); 
  312.    --  Sets whether the menu should reserve space for drawing toggles or 
  313.    --  icons, regardless of their actual presence. 
  314.    --  Since: gtk+ 2.18 
  315.    --  "reserve_toggle_size": whether to reserve size for toggles 
  316.  
  317.    function Get_Tearoff_State 
  318.       (Menu : not null access Gtk_Menu_Record) return Boolean; 
  319.    --  Returns whether the menu is torn off. See Gtk.Menu.Set_Tearoff_State. 
  320.  
  321.    procedure Set_Tearoff_State 
  322.       (Menu     : not null access Gtk_Menu_Record; 
  323.        Torn_Off : Boolean); 
  324.    --  Changes the tearoff state of the menu. A menu is normally displayed as 
  325.    --  drop down menu which persists as long as the menu is active. It can also 
  326.    --  be displayed as a tearoff menu which persists until it is closed or 
  327.    --  reattached. 
  328.    --  "torn_off": If True, menu is displayed as a tearoff menu. 
  329.  
  330.    function Get_Title 
  331.       (Menu : not null access Gtk_Menu_Record) return UTF8_String; 
  332.    --  Returns the title of the menu. See Gtk.Menu.Set_Title. 
  333.  
  334.    procedure Set_Title 
  335.       (Menu  : not null access Gtk_Menu_Record; 
  336.        Title : UTF8_String); 
  337.    --  Sets the title string for the menu. 
  338.    --  The title is displayed when the menu is shown as a tearoff menu. If 
  339.    --  Title is null, the menu will see if it is attached to a parent menu 
  340.    --  item, and if so it will try to use the same text as that menu item's 
  341.    --  label. 
  342.    --  "title": a string containing the title for the menu 
  343.  
  344.    procedure Popdown (Menu : not null access Gtk_Menu_Record); 
  345.    --  Removes the menu from the screen. 
  346.  
  347.    procedure Popup 
  348.       (Menu              : not null access Gtk_Menu_Record; 
  349.        Parent_Menu_Shell : Gtk.Menu_Shell.Gtk_Menu_Shell := null; 
  350.        Parent_Menu_Item  : Gtk.Menu_Item.Gtk_Menu_Item := null; 
  351.        Func              : Gtk_Menu_Position_Func := null; 
  352.        Button            : Guint := 1; 
  353.        Activate_Time     : Guint32 := 0); 
  354.    --  Displays a menu and makes it available for selection. 
  355.    --  Applications can use this function to display context-sensitive menus, 
  356.    --  and will typically supply null for the Parent_Menu_Shell, 
  357.    --  Parent_Menu_Item, Func and Data parameters. The default menu positioning 
  358.    --  function will position the menu at the current mouse cursor position. 
  359.    --  The Button parameter should be the mouse button pressed to initiate the 
  360.    --  menu popup. If the menu popup was initiated by something other than a 
  361.    --  mouse button press, such as a mouse button release or a keypress, Button 
  362.    --  should be 0. 
  363.    --  The Activate_Time parameter is used to conflict-resolve initiation of 
  364.    --  concurrent requests for mouse/keyboard grab requests. To function 
  365.    --  properly, this needs to be the timestamp of the user event (such as a 
  366.    --  mouse click or key press) that caused the initiation of the popup. Only 
  367.    --  if no such event is available, Gtk.Main.Get_Current_Event_Time can be 
  368.    --  used instead. 
  369.    --  "parent_menu_shell": the menu shell containing the triggering menu 
  370.    --  item, or null 
  371.    --  "parent_menu_item": the menu item whose activation triggered the popup, 
  372.    --  or null 
  373.    --  "func": a user supplied function used to position the menu, or null 
  374.    --  "button": the mouse button which was pressed to initiate the event. 
  375.    --  "activate_time": the time at which the activation event occurred. 
  376.  
  377.    generic 
  378.       type User_Data_Type (<>) is private; 
  379.       with procedure Destroy (Data : in out User_Data_Type) is null; 
  380.    package Popup_User_Data is 
  381.  
  382.       type Gtk_Menu_Position_Func is access procedure 
  383.         (Menu      : not null access Gtk.Menu.Gtk_Menu_Record'Class; 
  384.          X         : in out Gint; 
  385.          Y         : in out Gint; 
  386.          Push_In   : out Boolean; 
  387.          User_Data : User_Data_Type); 
  388.       --  A user function supplied when calling Gtk.Menu.Popup which controls the 
  389.       --  positioning of the menu when it is displayed. The function sets the X 
  390.       --  and Y parameters to the coordinates where the menu is to be drawn. To 
  391.       --  make the menu appear on a different monitor than the mouse pointer, 
  392.       --  gtk_menu_set_monitor must be called. 
  393.       --  "menu": a Gtk.Menu.Gtk_Menu. 
  394.       --  "x": address of the Gint representing the horizontal position where the 
  395.       --  menu shall be drawn. 
  396.       --  "y": address of the Gint representing the vertical position where the 
  397.       --  menu shall be drawn. This is an output parameter. 
  398.       --  "push_in": This parameter controls how menus placed outside the monitor 
  399.       --  are handled. If this is set to True and part of the menu is outside the 
  400.       --  monitor then GTK+ pushes the window into the visible area, effectively 
  401.       --  modifying the popup position. Note that moving and possibly resizing the 
  402.       --  menu around will alter the scroll position to keep the menu items "in 
  403.       --  place", i.e. at the same monitor position they would have been without 
  404.       --  resizing. In practice, this behavior is only useful for combobox popups 
  405.       --  or option menus and cannot be used to simply confine a menu to monitor 
  406.       --  boundaries. In that case, changing the scroll offset is not desirable. 
  407.       --  "user_data": the data supplied by the user in the Gtk.Menu.Popup Data 
  408.       --  parameter. 
  409.  
  410.       procedure Popup 
  411.          (Menu              : not null access Gtk.Menu.Gtk_Menu_Record'Class; 
  412.           Parent_Menu_Shell : Gtk.Menu_Shell.Gtk_Menu_Shell := null; 
  413.           Parent_Menu_Item  : Gtk.Menu_Item.Gtk_Menu_Item := null; 
  414.           Func              : Gtk_Menu_Position_Func := null; 
  415.           Data              : User_Data_Type; 
  416.           Button            : Guint := 1; 
  417.           Activate_Time     : Guint32 := 0); 
  418.       --  Displays a menu and makes it available for selection. 
  419.       --  Applications can use this function to display context-sensitive 
  420.       --  menus, and will typically supply null for the Parent_Menu_Shell, 
  421.       --  Parent_Menu_Item, Func and Data parameters. The default menu 
  422.       --  positioning function will position the menu at the current mouse 
  423.       --  cursor position. 
  424.       --  The Button parameter should be the mouse button pressed to initiate 
  425.       --  the menu popup. If the menu popup was initiated by something other 
  426.       --  than a mouse button press, such as a mouse button release or a 
  427.       --  keypress, Button should be 0. 
  428.       --  The Activate_Time parameter is used to conflict-resolve initiation 
  429.       --  of concurrent requests for mouse/keyboard grab requests. To function 
  430.       --  properly, this needs to be the timestamp of the user event (such as a 
  431.       --  mouse click or key press) that caused the initiation of the popup. 
  432.       --  Only if no such event is available, Gtk.Main.Get_Current_Event_Time 
  433.       --  can be used instead. 
  434.       --  "parent_menu_shell": the menu shell containing the triggering menu 
  435.       --  item, or null 
  436.       --  "parent_menu_item": the menu item whose activation triggered the 
  437.       --  popup, or null 
  438.       --  "func": a user supplied function used to position the menu, or null 
  439.       --  "data": user supplied data to be passed to Func. 
  440.       --  "button": the mouse button which was pressed to initiate the event. 
  441.       --  "activate_time": the time at which the activation event occurred. 
  442.  
  443.    end Popup_User_Data; 
  444.  
  445.    procedure Popup_For_Device 
  446.       (Menu              : not null access Gtk_Menu_Record; 
  447.        Device            : access Gdk.Device.Gdk_Device_Record'Class; 
  448.        Parent_Menu_Shell : access Gtk.Widget.Gtk_Widget_Record'Class; 
  449.        Parent_Menu_Item  : access Gtk.Widget.Gtk_Widget_Record'Class; 
  450.        Func              : Gtk_Menu_Position_Func; 
  451.        Button            : Guint; 
  452.        Activate_Time     : Guint32); 
  453.    --  Displays a menu and makes it available for selection. 
  454.    --  Applications can use this function to display context-sensitive menus, 
  455.    --  and will typically supply null for the Parent_Menu_Shell, 
  456.    --  Parent_Menu_Item, Func, Data and Destroy parameters. The default menu 
  457.    --  positioning function will position the menu at the current position of 
  458.    --  Device (or its corresponding pointer). 
  459.    --  The Button parameter should be the mouse button pressed to initiate the 
  460.    --  menu popup. If the menu popup was initiated by something other than a 
  461.    --  mouse button press, such as a mouse button release or a keypress, Button 
  462.    --  should be 0. 
  463.    --  The Activate_Time parameter is used to conflict-resolve initiation of 
  464.    --  concurrent requests for mouse/keyboard grab requests. To function 
  465.    --  properly, this needs to be the time stamp of the user event (such as a 
  466.    --  mouse click or key press) that caused the initiation of the popup. Only 
  467.    --  if no such event is available, Gtk.Main.Get_Current_Event_Time can be 
  468.    --  used instead. 
  469.    --  Since: gtk+ 3.0 
  470.    --  "device": a Gdk.Device.Gdk_Device 
  471.    --  "parent_menu_shell": the menu shell containing the triggering menu 
  472.    --  item, or null 
  473.    --  "parent_menu_item": the menu item whose activation triggered the popup, 
  474.    --  or null 
  475.    --  "func": a user supplied function used to position the menu, or null 
  476.    --  "button": the mouse button which was pressed to initiate the event 
  477.    --  "activate_time": the time at which the activation event occurred 
  478.  
  479.    generic 
  480.       type User_Data_Type (<>) is private; 
  481.       with procedure Destroy (Data : in out User_Data_Type) is null; 
  482.    package Popup_For_Device_User_Data is 
  483.  
  484.       type Gtk_Menu_Position_Func is access procedure 
  485.         (Menu      : not null access Gtk.Menu.Gtk_Menu_Record'Class; 
  486.          X         : out Gint; 
  487.          Y         : out Gint; 
  488.          Push_In   : out Boolean; 
  489.          User_Data : User_Data_Type); 
  490.       --  A user function supplied when calling Gtk.Menu.Popup which controls the 
  491.       --  positioning of the menu when it is displayed. The function sets the X 
  492.       --  and Y parameters to the coordinates where the menu is to be drawn. To 
  493.       --  make the menu appear on a different monitor than the mouse pointer, 
  494.       --  gtk_menu_set_monitor must be called. 
  495.       --  "menu": a Gtk.Menu.Gtk_Menu. 
  496.       --  "x": address of the Gint representing the horizontal position where the 
  497.       --  menu shall be drawn. 
  498.       --  "y": address of the Gint representing the vertical position where the 
  499.       --  menu shall be drawn. This is an output parameter. 
  500.       --  "push_in": This parameter controls how menus placed outside the monitor 
  501.       --  are handled. If this is set to True and part of the menu is outside the 
  502.       --  monitor then GTK+ pushes the window into the visible area, effectively 
  503.       --  modifying the popup position. Note that moving and possibly resizing the 
  504.       --  menu around will alter the scroll position to keep the menu items "in 
  505.       --  place", i.e. at the same monitor position they would have been without 
  506.       --  resizing. In practice, this behavior is only useful for combobox popups 
  507.       --  or option menus and cannot be used to simply confine a menu to monitor 
  508.       --  boundaries. In that case, changing the scroll offset is not desirable. 
  509.       --  "user_data": the data supplied by the user in the Gtk.Menu.Popup Data 
  510.       --  parameter. 
  511.  
  512.       procedure Popup_For_Device 
  513.          (Menu              : not null access Gtk.Menu.Gtk_Menu_Record'Class; 
  514.           Device            : access Gdk.Device.Gdk_Device_Record'Class; 
  515.           Parent_Menu_Shell : access Gtk.Widget.Gtk_Widget_Record'Class; 
  516.           Parent_Menu_Item  : access Gtk.Widget.Gtk_Widget_Record'Class; 
  517.           Func              : Gtk_Menu_Position_Func; 
  518.           Data              : User_Data_Type; 
  519.           Button            : Guint; 
  520.           Activate_Time     : Guint32); 
  521.       --  Displays a menu and makes it available for selection. 
  522.       --  Applications can use this function to display context-sensitive 
  523.       --  menus, and will typically supply null for the Parent_Menu_Shell, 
  524.       --  Parent_Menu_Item, Func, Data and Destroy parameters. The default menu 
  525.       --  positioning function will position the menu at the current position 
  526.       --  of Device (or its corresponding pointer). 
  527.       --  The Button parameter should be the mouse button pressed to initiate 
  528.       --  the menu popup. If the menu popup was initiated by something other 
  529.       --  than a mouse button press, such as a mouse button release or a 
  530.       --  keypress, Button should be 0. 
  531.       --  The Activate_Time parameter is used to conflict-resolve initiation 
  532.       --  of concurrent requests for mouse/keyboard grab requests. To function 
  533.       --  properly, this needs to be the time stamp of the user event (such as 
  534.       --  a mouse click or key press) that caused the initiation of the popup. 
  535.       --  Only if no such event is available, Gtk.Main.Get_Current_Event_Time 
  536.       --  can be used instead. 
  537.       --  Since: gtk+ 3.0 
  538.       --  "device": a Gdk.Device.Gdk_Device 
  539.       --  "parent_menu_shell": the menu shell containing the triggering menu 
  540.       --  item, or null 
  541.       --  "parent_menu_item": the menu item whose activation triggered the 
  542.       --  popup, or null 
  543.       --  "func": a user supplied function used to position the menu, or null 
  544.       --  "data": user supplied data to be passed to Func 
  545.       --  "button": the mouse button which was pressed to initiate the event 
  546.       --  "activate_time": the time at which the activation event occurred 
  547.  
  548.    end Popup_For_Device_User_Data; 
  549.  
  550.    procedure Reorder_Child 
  551.       (Menu     : not null access Gtk_Menu_Record; 
  552.        Child    : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  553.        Position : Gint); 
  554.    --  Moves Child to a new Position in the list of Menu children. 
  555.    --  "child": the Gtk.Menu_Item.Gtk_Menu_Item to move 
  556.    --  "position": the new position to place Child. Positions are numbered 
  557.    --  from 0 to n - 1 
  558.  
  559.    procedure Reposition (Menu : not null access Gtk_Menu_Record); 
  560.    --  Repositions the menu according to its position function. 
  561.  
  562.    procedure Set_Screen 
  563.       (Menu   : not null access Gtk_Menu_Record; 
  564.        Screen : access Gdk.Screen.Gdk_Screen_Record'Class); 
  565.    --  Sets the Gdk.Screen.Gdk_Screen on which the menu will be displayed. 
  566.    --  Since: gtk+ 2.2 
  567.    --  "screen": a Gdk.Screen.Gdk_Screen, or null if the screen should be 
  568.    --  determined by the widget the menu is attached to 
  569.  
  570.    --------------- 
  571.    -- Functions -- 
  572.    --------------- 
  573.  
  574.    function Get_For_Attach_Widget 
  575.       (Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class) 
  576.        return Gtk.Widget.Widget_List.Glist; 
  577.    --  Returns a list of the menus which are attached to this widget. This 
  578.    --  list is owned by GTK+ and must not be modified. 
  579.    --  Since: gtk+ 2.6 
  580.    --  "widget": a Gtk.Widget.Gtk_Widget 
  581.  
  582.    ---------------- 
  583.    -- Properties -- 
  584.    ---------------- 
  585.    --  The following properties are defined for this widget. See 
  586.    --  Glib.Properties for more information on properties) 
  587.  
  588.    Accel_Group_Property : constant Glib.Properties.Property_Object; 
  589.    --  Type: Gtk.Accel_Group.Gtk_Accel_Group 
  590.    --  The accel group holding accelerators for the menu. 
  591.  
  592.    Accel_Path_Property : constant Glib.Properties.Property_String; 
  593.    --  An accel path used to conveniently construct accel paths of child 
  594.    --  items. 
  595.  
  596.    Active_Property : constant Glib.Properties.Property_Int; 
  597.    --  The index of the currently selected menu item, or -1 if no menu item is 
  598.    --  selected. 
  599.  
  600.    Attach_Widget_Property : constant Glib.Properties.Property_Object; 
  601.    --  Type: Gtk.Widget.Gtk_Widget 
  602.    --  The widget the menu is attached to. Setting this property attaches the 
  603.    --  menu without a Gtk_Menu_Detach_Func. If you need to use a detacher, use 
  604.    --  Gtk.Menu.Attach_To_Widget directly. 
  605.  
  606.    Monitor_Property : constant Glib.Properties.Property_Int; 
  607.    --  The monitor the menu will be popped up on. 
  608.  
  609.    Reserve_Toggle_Size_Property : constant Glib.Properties.Property_Boolean; 
  610.    --  A boolean that indicates whether the menu reserves space for toggles 
  611.    --  and icons, regardless of their actual presence. 
  612.    -- 
  613.    --  This property should only be changed from its default value for 
  614.    --  special-purposes such as tabular menus. Regular menus that are connected 
  615.    --  to a menu bar or context menus should reserve toggle space for 
  616.    --  consistency. 
  617.  
  618.    Tearoff_State_Property : constant Glib.Properties.Property_Boolean; 
  619.    --  A boolean that indicates whether the menu is torn-off. 
  620.  
  621.    Tearoff_Title_Property : constant Glib.Properties.Property_String; 
  622.  
  623.    ------------- 
  624.    -- Signals -- 
  625.    ------------- 
  626.  
  627.    type Cb_Gtk_Menu_Gtk_Scroll_Type_Void is not null access procedure 
  628.      (Self        : access Gtk_Menu_Record'Class; 
  629.       Scroll_Type : Gtk.Enums.Gtk_Scroll_Type); 
  630.  
  631.    type Cb_GObject_Gtk_Scroll_Type_Void is not null access procedure 
  632.      (Self        : access Glib.Object.GObject_Record'Class; 
  633.       Scroll_Type : Gtk.Enums.Gtk_Scroll_Type); 
  634.  
  635.    Signal_Move_Scroll : constant Glib.Signal_Name := "move-scroll"; 
  636.    procedure On_Move_Scroll 
  637.       (Self  : not null access Gtk_Menu_Record; 
  638.        Call  : Cb_Gtk_Menu_Gtk_Scroll_Type_Void; 
  639.        After : Boolean := False); 
  640.    procedure On_Move_Scroll 
  641.       (Self  : not null access Gtk_Menu_Record; 
  642.        Call  : Cb_GObject_Gtk_Scroll_Type_Void; 
  643.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  644.        After : Boolean := False); 
  645.  
  646.    ---------------- 
  647.    -- Interfaces -- 
  648.    ---------------- 
  649.    --  This class implements several interfaces. See Glib.Types 
  650.    -- 
  651.    --  - "Buildable" 
  652.  
  653.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  654.      (Gtk.Buildable.Gtk_Buildable, Gtk_Menu_Record, Gtk_Menu); 
  655.    function "+" 
  656.      (Widget : access Gtk_Menu_Record'Class) 
  657.    return Gtk.Buildable.Gtk_Buildable 
  658.    renames Implements_Gtk_Buildable.To_Interface; 
  659.    function "-" 
  660.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  661.    return Gtk_Menu 
  662.    renames Implements_Gtk_Buildable.To_Object; 
  663.  
  664. private 
  665.    Tearoff_Title_Property : constant Glib.Properties.Property_String := 
  666.      Glib.Properties.Build ("tearoff-title"); 
  667.    Tearoff_State_Property : constant Glib.Properties.Property_Boolean := 
  668.      Glib.Properties.Build ("tearoff-state"); 
  669.    Reserve_Toggle_Size_Property : constant Glib.Properties.Property_Boolean := 
  670.      Glib.Properties.Build ("reserve-toggle-size"); 
  671.    Monitor_Property : constant Glib.Properties.Property_Int := 
  672.      Glib.Properties.Build ("monitor"); 
  673.    Attach_Widget_Property : constant Glib.Properties.Property_Object := 
  674.      Glib.Properties.Build ("attach-widget"); 
  675.    Active_Property : constant Glib.Properties.Property_Int := 
  676.      Glib.Properties.Build ("active"); 
  677.    Accel_Path_Property : constant Glib.Properties.Property_String := 
  678.      Glib.Properties.Build ("accel-path"); 
  679.    Accel_Group_Property : constant Glib.Properties.Property_Object := 
  680.      Glib.Properties.Build ("accel-group"); 
  681. end Gtk.Menu;