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 GtkImageMenuItem is a menu item which has an icon next to the text 
  26. --  label. 
  27. -- 
  28. --  Note that the user can disable display of menu icons, so make sure to 
  29. --  still fill in the text label. 
  30. -- 
  31. --  </description> 
  32. pragma Ada_2005; 
  33.  
  34. pragma Warnings (Off, "*is already use-visible*"); 
  35. with Glib;            use Glib; 
  36. with Glib.Properties; use Glib.Properties; 
  37. with Glib.Types;      use Glib.Types; 
  38. with Glib.Variant;    use Glib.Variant; 
  39. with Gtk.Accel_Group; use Gtk.Accel_Group; 
  40. with Gtk.Action;      use Gtk.Action; 
  41. with Gtk.Actionable;  use Gtk.Actionable; 
  42. with Gtk.Activatable; use Gtk.Activatable; 
  43. with Gtk.Buildable;   use Gtk.Buildable; 
  44. with Gtk.Menu_Item;   use Gtk.Menu_Item; 
  45. with Gtk.Widget;      use Gtk.Widget; 
  46.  
  47. package Gtk.Image_Menu_Item is 
  48.  
  49.    type Gtk_Image_Menu_Item_Record is new Gtk_Menu_Item_Record with null record; 
  50.    type Gtk_Image_Menu_Item is access all Gtk_Image_Menu_Item_Record'Class; 
  51.  
  52.    ------------------ 
  53.    -- Constructors -- 
  54.    ------------------ 
  55.  
  56.    procedure Gtk_New (Self : out Gtk_Image_Menu_Item); 
  57.    procedure Initialize 
  58.       (Self : not null access Gtk_Image_Menu_Item_Record'Class); 
  59.    --  Creates a new Gtk.Image_Menu_Item.Gtk_Image_Menu_Item with an empty 
  60.    --  label. 
  61.  
  62.    function Gtk_Image_Menu_Item_New return Gtk_Image_Menu_Item; 
  63.    --  Creates a new Gtk.Image_Menu_Item.Gtk_Image_Menu_Item with an empty 
  64.    --  label. 
  65.  
  66.    procedure Gtk_New_From_Stock 
  67.       (Self        : out Gtk_Image_Menu_Item; 
  68.        Stock_Id    : UTF8_String; 
  69.        Accel_Group : access Gtk.Accel_Group.Gtk_Accel_Group_Record'Class); 
  70.    procedure Initialize_From_Stock 
  71.       (Self        : not null access Gtk_Image_Menu_Item_Record'Class; 
  72.        Stock_Id    : UTF8_String; 
  73.        Accel_Group : access Gtk.Accel_Group.Gtk_Accel_Group_Record'Class); 
  74.    --  Creates a new Gtk.Image_Menu_Item.Gtk_Image_Menu_Item containing the 
  75.    --  image and text from a stock item. Some stock ids have preprocessor 
  76.    --  macros like GTK_STOCK_OK and GTK_STOCK_APPLY. 
  77.    --  If you want this menu item to have changeable accelerators, then pass 
  78.    --  in null for accel_group. Next call Gtk.Menu_Item.Set_Accel_Path with an 
  79.    --  appropriate path for the menu item, use Gtk.Stock.Lookup to look up the 
  80.    --  standard accelerator for the stock item, and if one is found, call 
  81.    --  Gtk.Accel_Map.Add_Entry to register it. 
  82.    --  "stock_id": the name of the stock item. 
  83.    --  "accel_group": the Gtk.Accel_Group.Gtk_Accel_Group to add the menu 
  84.    --  items accelerator to, or null. 
  85.  
  86.    function Gtk_Image_Menu_Item_New_From_Stock 
  87.       (Stock_Id    : UTF8_String; 
  88.        Accel_Group : access Gtk.Accel_Group.Gtk_Accel_Group_Record'Class) 
  89.        return Gtk_Image_Menu_Item; 
  90.    --  Creates a new Gtk.Image_Menu_Item.Gtk_Image_Menu_Item containing the 
  91.    --  image and text from a stock item. Some stock ids have preprocessor 
  92.    --  macros like GTK_STOCK_OK and GTK_STOCK_APPLY. 
  93.    --  If you want this menu item to have changeable accelerators, then pass 
  94.    --  in null for accel_group. Next call Gtk.Menu_Item.Set_Accel_Path with an 
  95.    --  appropriate path for the menu item, use Gtk.Stock.Lookup to look up the 
  96.    --  standard accelerator for the stock item, and if one is found, call 
  97.    --  Gtk.Accel_Map.Add_Entry to register it. 
  98.    --  "stock_id": the name of the stock item. 
  99.    --  "accel_group": the Gtk.Accel_Group.Gtk_Accel_Group to add the menu 
  100.    --  items accelerator to, or null. 
  101.  
  102.    procedure Gtk_New (Self : out Gtk_Image_Menu_Item; Label : UTF8_String); 
  103.    procedure Initialize 
  104.       (Self  : not null access Gtk_Image_Menu_Item_Record'Class; 
  105.        Label : UTF8_String); 
  106.    --  Creates a new Gtk.Image_Menu_Item.Gtk_Image_Menu_Item containing a 
  107.    --  label. 
  108.    --  "label": the text of the menu item. 
  109.  
  110.    function Gtk_Image_Menu_Item_New_With_Label 
  111.       (Label : UTF8_String) return Gtk_Image_Menu_Item; 
  112.    --  Creates a new Gtk.Image_Menu_Item.Gtk_Image_Menu_Item containing a 
  113.    --  label. 
  114.    --  "label": the text of the menu item. 
  115.  
  116.    procedure Gtk_New_With_Mnemonic 
  117.       (Self  : out Gtk_Image_Menu_Item; 
  118.        Label : UTF8_String); 
  119.    procedure Initialize_With_Mnemonic 
  120.       (Self  : not null access Gtk_Image_Menu_Item_Record'Class; 
  121.        Label : UTF8_String); 
  122.    --  Creates a new Gtk.Image_Menu_Item.Gtk_Image_Menu_Item containing a 
  123.    --  label. The label will be created using Gtk.Label.Gtk_New_With_Mnemonic, 
  124.    --  so underscores in Label indicate the mnemonic for the menu item. 
  125.    --  "label": the text of the menu item, with an underscore in front of the 
  126.    --  mnemonic character 
  127.  
  128.    function Gtk_Image_Menu_Item_New_With_Mnemonic 
  129.       (Label : UTF8_String) return Gtk_Image_Menu_Item; 
  130.    --  Creates a new Gtk.Image_Menu_Item.Gtk_Image_Menu_Item containing a 
  131.    --  label. The label will be created using Gtk.Label.Gtk_New_With_Mnemonic, 
  132.    --  so underscores in Label indicate the mnemonic for the menu item. 
  133.    --  "label": the text of the menu item, with an underscore in front of the 
  134.    --  mnemonic character 
  135.  
  136.    function Get_Type return Glib.GType; 
  137.    pragma Import (C, Get_Type, "gtk_image_menu_item_get_type"); 
  138.  
  139.    ------------- 
  140.    -- Methods -- 
  141.    ------------- 
  142.  
  143.    function Get_Always_Show_Image 
  144.       (Self : not null access Gtk_Image_Menu_Item_Record) return Boolean; 
  145.    --  Returns whether the menu item will ignore the 
  146.    --  Gtk.Settings.Gtk_Settings:gtk-menu-images setting and always show the 
  147.    --  image, if available. 
  148.    --  Since: gtk+ 2.16 
  149.  
  150.    procedure Set_Always_Show_Image 
  151.       (Self        : not null access Gtk_Image_Menu_Item_Record; 
  152.        Always_Show : Boolean); 
  153.    --  If True, the menu item will ignore the 
  154.    --  Gtk.Settings.Gtk_Settings:gtk-menu-images setting and always show the 
  155.    --  image, if available. 
  156.    --  Use this property if the menuitem would be useless or hard to use 
  157.    --  without the image. 
  158.    --  Since: gtk+ 2.16 
  159.    --  "always_show": True if the menuitem should always show the image 
  160.  
  161.    function Get_Image 
  162.       (Self : not null access Gtk_Image_Menu_Item_Record) 
  163.        return Gtk.Widget.Gtk_Widget; 
  164.    --  Gets the widget that is currently set as the image of Image_Menu_Item. 
  165.    --  See Gtk.Image_Menu_Item.Set_Image. 
  166.  
  167.    procedure Set_Image 
  168.       (Self  : not null access Gtk_Image_Menu_Item_Record; 
  169.        Image : access Gtk.Widget.Gtk_Widget_Record'Class); 
  170.    --  Sets the image of Image_Menu_Item to the given widget. Note that it 
  171.    --  depends on the show-menu-images setting whether the image will be 
  172.    --  displayed or not. 
  173.    --  "image": a widget to set as the image for the menu item. 
  174.  
  175.    function Get_Use_Stock 
  176.       (Self : not null access Gtk_Image_Menu_Item_Record) return Boolean; 
  177.    --  Checks whether the label set in the menuitem is used as a stock id to 
  178.    --  select the stock item for the item. 
  179.    --  Since: gtk+ 2.16 
  180.  
  181.    procedure Set_Use_Stock 
  182.       (Self      : not null access Gtk_Image_Menu_Item_Record; 
  183.        Use_Stock : Boolean); 
  184.    --  If True, the label set in the menuitem is used as a stock id to select 
  185.    --  the stock item for the item. 
  186.    --  Since: gtk+ 2.16 
  187.    --  "use_stock": True if the menuitem should use a stock item 
  188.  
  189.    procedure Set_Accel_Group 
  190.       (Self        : not null access Gtk_Image_Menu_Item_Record; 
  191.        Accel_Group : not null access Gtk.Accel_Group.Gtk_Accel_Group_Record'Class); 
  192.    --  Specifies an Accel_Group to add the menu items accelerator to (this 
  193.    --  only applies to stock items so a stock item must already be set, make 
  194.    --  sure to call Gtk.Image_Menu_Item.Set_Use_Stock and 
  195.    --  Gtk.Menu_Item.Set_Label with a valid stock item first). 
  196.    --  If you want this menu item to have changeable accelerators then you 
  197.    --  shouldnt need this (see Gtk.Image_Menu_Item.Gtk_New_From_Stock). 
  198.    --  Since: gtk+ 2.16 
  199.    --  "accel_group": the Gtk.Accel_Group.Gtk_Accel_Group 
  200.  
  201.    --------------------------------------------- 
  202.    -- Inherited subprograms (from interfaces) -- 
  203.    --------------------------------------------- 
  204.    --  Methods inherited from the Buildable interface are not duplicated here 
  205.    --  since they are meant to be used by tools, mostly. If you need to call 
  206.    --  them, use an explicit cast through the "-" operator below. 
  207.  
  208.    function Get_Action_Name 
  209.       (Self : not null access Gtk_Image_Menu_Item_Record) return UTF8_String; 
  210.  
  211.    procedure Set_Action_Name 
  212.       (Self        : not null access Gtk_Image_Menu_Item_Record; 
  213.        Action_Name : UTF8_String); 
  214.  
  215.    function Get_Action_Target_Value 
  216.       (Self : not null access Gtk_Image_Menu_Item_Record) 
  217.        return Glib.Variant.Gvariant; 
  218.  
  219.    procedure Set_Action_Target_Value 
  220.       (Self         : not null access Gtk_Image_Menu_Item_Record; 
  221.        Target_Value : Glib.Variant.Gvariant); 
  222.  
  223.    procedure Set_Detailed_Action_Name 
  224.       (Self                 : not null access Gtk_Image_Menu_Item_Record; 
  225.        Detailed_Action_Name : UTF8_String); 
  226.  
  227.    procedure Do_Set_Related_Action 
  228.       (Self   : not null access Gtk_Image_Menu_Item_Record; 
  229.        Action : not null access Gtk.Action.Gtk_Action_Record'Class); 
  230.  
  231.    function Get_Related_Action 
  232.       (Self : not null access Gtk_Image_Menu_Item_Record) 
  233.        return Gtk.Action.Gtk_Action; 
  234.  
  235.    procedure Set_Related_Action 
  236.       (Self   : not null access Gtk_Image_Menu_Item_Record; 
  237.        Action : not null access Gtk.Action.Gtk_Action_Record'Class); 
  238.  
  239.    function Get_Use_Action_Appearance 
  240.       (Self : not null access Gtk_Image_Menu_Item_Record) return Boolean; 
  241.  
  242.    procedure Set_Use_Action_Appearance 
  243.       (Self           : not null access Gtk_Image_Menu_Item_Record; 
  244.        Use_Appearance : Boolean); 
  245.  
  246.    procedure Sync_Action_Properties 
  247.       (Self   : not null access Gtk_Image_Menu_Item_Record; 
  248.        Action : access Gtk.Action.Gtk_Action_Record'Class); 
  249.  
  250.    ---------------- 
  251.    -- Properties -- 
  252.    ---------------- 
  253.    --  The following properties are defined for this widget. See 
  254.    --  Glib.Properties for more information on properties) 
  255.  
  256.    Accel_Group_Property : constant Glib.Properties.Property_Object; 
  257.    --  Type: Gtk.Accel_Group.Gtk_Accel_Group 
  258.    --  Flags: write 
  259.    --  The Accel Group to use for stock accelerator keys 
  260.  
  261.    Always_Show_Image_Property : constant Glib.Properties.Property_Boolean; 
  262.    --  If True, the menu item will ignore the 
  263.    --  Gtk.Settings.Gtk_Settings:gtk-menu-images setting and always show the 
  264.    --  image, if available. 
  265.    -- 
  266.    --  Use this property if the menuitem would be useless or hard to use 
  267.    --  without the image. 
  268.  
  269.    Image_Property : constant Glib.Properties.Property_Object; 
  270.    --  Type: Gtk.Widget.Gtk_Widget 
  271.  
  272.    Use_Stock_Property : constant Glib.Properties.Property_Boolean; 
  273.    --  If True, the label set in the menuitem is used as a stock id to select 
  274.    --  the stock item for the item. 
  275.  
  276.    ---------------- 
  277.    -- Interfaces -- 
  278.    ---------------- 
  279.    --  This class implements several interfaces. See Glib.Types 
  280.    -- 
  281.    --  - "Actionable" 
  282.    -- 
  283.    --  - "Activatable" 
  284.    -- 
  285.    --  - "Buildable" 
  286.  
  287.    package Implements_Gtk_Actionable is new Glib.Types.Implements 
  288.      (Gtk.Actionable.Gtk_Actionable, Gtk_Image_Menu_Item_Record, Gtk_Image_Menu_Item); 
  289.    function "+" 
  290.      (Widget : access Gtk_Image_Menu_Item_Record'Class) 
  291.    return Gtk.Actionable.Gtk_Actionable 
  292.    renames Implements_Gtk_Actionable.To_Interface; 
  293.    function "-" 
  294.      (Interf : Gtk.Actionable.Gtk_Actionable) 
  295.    return Gtk_Image_Menu_Item 
  296.    renames Implements_Gtk_Actionable.To_Object; 
  297.  
  298.    package Implements_Gtk_Activatable is new Glib.Types.Implements 
  299.      (Gtk.Activatable.Gtk_Activatable, Gtk_Image_Menu_Item_Record, Gtk_Image_Menu_Item); 
  300.    function "+" 
  301.      (Widget : access Gtk_Image_Menu_Item_Record'Class) 
  302.    return Gtk.Activatable.Gtk_Activatable 
  303.    renames Implements_Gtk_Activatable.To_Interface; 
  304.    function "-" 
  305.      (Interf : Gtk.Activatable.Gtk_Activatable) 
  306.    return Gtk_Image_Menu_Item 
  307.    renames Implements_Gtk_Activatable.To_Object; 
  308.  
  309.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  310.      (Gtk.Buildable.Gtk_Buildable, Gtk_Image_Menu_Item_Record, Gtk_Image_Menu_Item); 
  311.    function "+" 
  312.      (Widget : access Gtk_Image_Menu_Item_Record'Class) 
  313.    return Gtk.Buildable.Gtk_Buildable 
  314.    renames Implements_Gtk_Buildable.To_Interface; 
  315.    function "-" 
  316.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  317.    return Gtk_Image_Menu_Item 
  318.    renames Implements_Gtk_Buildable.To_Object; 
  319.  
  320. private 
  321.    Use_Stock_Property : constant Glib.Properties.Property_Boolean := 
  322.      Glib.Properties.Build ("use-stock"); 
  323.    Image_Property : constant Glib.Properties.Property_Object := 
  324.      Glib.Properties.Build ("image"); 
  325.    Always_Show_Image_Property : constant Glib.Properties.Property_Boolean := 
  326.      Glib.Properties.Build ("always-show-image"); 
  327.    Accel_Group_Property : constant Glib.Properties.Property_Object := 
  328.      Glib.Properties.Build ("accel-group"); 
  329. end Gtk.Image_Menu_Item;