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 radio menu item is a check menu item that belongs to a group. At each 
  26. --  instant exactly one of the radio menu items from a group is selected. 
  27. -- 
  28. --  The group list does not need to be freed, as each 
  29. --  Gtk.Radio_Menu_Item.Gtk_Radio_Menu_Item will remove itself and its list 
  30. --  item when it is destroyed. 
  31. -- 
  32. --  The correct way to create a group of radio menu items is approximatively 
  33. --  this: 
  34. -- 
  35. --  == How to create a group of radio menu items. == 
  36. -- 
  37. --    GSList *group = NULL; 
  38. --    GtkWidget *item; 
  39. --    gint i; 
  40. --    for (i = 0; i < 5; i++) 
  41. --    { 
  42. --       item = gtk_radio_menu_item_new_with_label (group, "This is an example"); 
  43. --       group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (item)); 
  44. --       if (i == 1) 
  45. --       gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); 
  46. --    } 
  47. -- 
  48. -- 
  49. --  </description> 
  50. pragma Ada_2005; 
  51.  
  52. pragma Warnings (Off, "*is already use-visible*"); 
  53. with Glib;                use Glib; 
  54. with Glib.Object;         use Glib.Object; 
  55. with Glib.Properties;     use Glib.Properties; 
  56. with Glib.Types;          use Glib.Types; 
  57. with Glib.Variant;        use Glib.Variant; 
  58. with Gtk.Action;          use Gtk.Action; 
  59. with Gtk.Actionable;      use Gtk.Actionable; 
  60. with Gtk.Activatable;     use Gtk.Activatable; 
  61. with Gtk.Buildable;       use Gtk.Buildable; 
  62. with Gtk.Check_Menu_Item; use Gtk.Check_Menu_Item; 
  63. with Gtk.Widget;          use Gtk.Widget; 
  64.  
  65. package Gtk.Radio_Menu_Item is 
  66.  
  67.    type Gtk_Radio_Menu_Item_Record is new Gtk_Check_Menu_Item_Record with null record; 
  68.    type Gtk_Radio_Menu_Item is access all Gtk_Radio_Menu_Item_Record'Class; 
  69.  
  70.    ------------------ 
  71.    -- Constructors -- 
  72.    ------------------ 
  73.  
  74.    procedure Gtk_New 
  75.       (Radio_Menu_Item : out Gtk_Radio_Menu_Item; 
  76.        Group           : Gtk.Widget.Widget_SList.GSlist; 
  77.        Label           : UTF8_String := ""); 
  78.    procedure Initialize 
  79.       (Radio_Menu_Item : not null access Gtk_Radio_Menu_Item_Record'Class; 
  80.        Group           : Gtk.Widget.Widget_SList.GSlist; 
  81.        Label           : UTF8_String := ""); 
  82.    --  Creates a new Gtk.Radio_Menu_Item.Gtk_Radio_Menu_Item whose child is a 
  83.    --  simple Gtk.Label.Gtk_Label. 
  84.    --  "label": the text for the label 
  85.  
  86.    function Gtk_Radio_Menu_Item_New_With_Label 
  87.       (Group : Gtk.Widget.Widget_SList.GSlist; 
  88.        Label : UTF8_String := "") return Gtk_Radio_Menu_Item; 
  89.    --  Creates a new Gtk.Radio_Menu_Item.Gtk_Radio_Menu_Item whose child is a 
  90.    --  simple Gtk.Label.Gtk_Label. 
  91.    --  "label": the text for the label 
  92.  
  93.    procedure Gtk_New_With_Mnemonic 
  94.       (Radio_Menu_Item : out Gtk_Radio_Menu_Item; 
  95.        Group           : Gtk.Widget.Widget_SList.GSlist; 
  96.        Label           : UTF8_String); 
  97.    procedure Initialize_With_Mnemonic 
  98.       (Radio_Menu_Item : not null access Gtk_Radio_Menu_Item_Record'Class; 
  99.        Group           : Gtk.Widget.Widget_SList.GSlist; 
  100.        Label           : UTF8_String); 
  101.    --  Creates a new Gtk.Radio_Menu_Item.Gtk_Radio_Menu_Item containing a 
  102.    --  label. The label will be created using Gtk.Label.Gtk_New_With_Mnemonic, 
  103.    --  so underscores in Label indicate the mnemonic for the menu item. 
  104.    --  "group": group the radio menu item is inside 
  105.    --  "label": the text of the button, with an underscore in front of the 
  106.    --  mnemonic character 
  107.  
  108.    function Gtk_Radio_Menu_Item_New_With_Mnemonic 
  109.       (Group : Gtk.Widget.Widget_SList.GSlist; 
  110.        Label : UTF8_String) return Gtk_Radio_Menu_Item; 
  111.    --  Creates a new Gtk.Radio_Menu_Item.Gtk_Radio_Menu_Item containing a 
  112.    --  label. The label will be created using Gtk.Label.Gtk_New_With_Mnemonic, 
  113.    --  so underscores in Label indicate the mnemonic for the menu item. 
  114.    --  "group": group the radio menu item is inside 
  115.    --  "label": the text of the button, with an underscore in front of the 
  116.    --  mnemonic character 
  117.  
  118.    function Get_Type return Glib.GType; 
  119.    pragma Import (C, Get_Type, "gtk_radio_menu_item_get_type"); 
  120.  
  121.    ------------- 
  122.    -- Methods -- 
  123.    ------------- 
  124.  
  125.    function Get_Group 
  126.       (Radio_Menu_Item : not null access Gtk_Radio_Menu_Item_Record) 
  127.        return Gtk.Widget.Widget_SList.GSlist; 
  128.    --  Returns the group to which the radio menu item belongs, as a GList of 
  129.    --  Gtk.Radio_Menu_Item.Gtk_Radio_Menu_Item. The list belongs to GTK+ and 
  130.    --  should not be freed. 
  131.  
  132.    procedure Set_Group 
  133.       (Radio_Menu_Item : not null access Gtk_Radio_Menu_Item_Record; 
  134.        Group           : Gtk.Widget.Widget_SList.GSlist); 
  135.    --  Sets the group of a radio menu item, or changes it. 
  136.    --  "group": the new group. 
  137.  
  138.    ---------------------- 
  139.    -- GtkAda additions -- 
  140.    ---------------------- 
  141.  
  142.    function Selected_Button (In_Group : Widget_SList.GSlist) return Natural; 
  143.    --  Return the button number of the selected button in the group. 
  144.    --  Note: This function is not part of Gtk+ itself, but is provided as a 
  145.    --  convenient function 
  146.  
  147.    --------------------------------------------- 
  148.    -- Inherited subprograms (from interfaces) -- 
  149.    --------------------------------------------- 
  150.    --  Methods inherited from the Buildable interface are not duplicated here 
  151.    --  since they are meant to be used by tools, mostly. If you need to call 
  152.    --  them, use an explicit cast through the "-" operator below. 
  153.  
  154.    function Get_Action_Name 
  155.       (Self : not null access Gtk_Radio_Menu_Item_Record) return UTF8_String; 
  156.  
  157.    procedure Set_Action_Name 
  158.       (Self        : not null access Gtk_Radio_Menu_Item_Record; 
  159.        Action_Name : UTF8_String); 
  160.  
  161.    function Get_Action_Target_Value 
  162.       (Self : not null access Gtk_Radio_Menu_Item_Record) 
  163.        return Glib.Variant.Gvariant; 
  164.  
  165.    procedure Set_Action_Target_Value 
  166.       (Self         : not null access Gtk_Radio_Menu_Item_Record; 
  167.        Target_Value : Glib.Variant.Gvariant); 
  168.  
  169.    procedure Set_Detailed_Action_Name 
  170.       (Self                 : not null access Gtk_Radio_Menu_Item_Record; 
  171.        Detailed_Action_Name : UTF8_String); 
  172.  
  173.    procedure Do_Set_Related_Action 
  174.       (Self   : not null access Gtk_Radio_Menu_Item_Record; 
  175.        Action : not null access Gtk.Action.Gtk_Action_Record'Class); 
  176.  
  177.    function Get_Related_Action 
  178.       (Self : not null access Gtk_Radio_Menu_Item_Record) 
  179.        return Gtk.Action.Gtk_Action; 
  180.  
  181.    procedure Set_Related_Action 
  182.       (Self   : not null access Gtk_Radio_Menu_Item_Record; 
  183.        Action : not null access Gtk.Action.Gtk_Action_Record'Class); 
  184.  
  185.    function Get_Use_Action_Appearance 
  186.       (Self : not null access Gtk_Radio_Menu_Item_Record) return Boolean; 
  187.  
  188.    procedure Set_Use_Action_Appearance 
  189.       (Self           : not null access Gtk_Radio_Menu_Item_Record; 
  190.        Use_Appearance : Boolean); 
  191.  
  192.    procedure Sync_Action_Properties 
  193.       (Self   : not null access Gtk_Radio_Menu_Item_Record; 
  194.        Action : access Gtk.Action.Gtk_Action_Record'Class); 
  195.  
  196.    ---------------- 
  197.    -- Properties -- 
  198.    ---------------- 
  199.    --  The following properties are defined for this widget. See 
  200.    --  Glib.Properties for more information on properties) 
  201.  
  202.    Group_Property : constant Glib.Properties.Property_Object; 
  203.    --  Type: Gtk_Radio_Menu_Item 
  204.    --  Flags: write 
  205.    --  The radio menu item whose group this widget belongs to. 
  206.  
  207.    ------------- 
  208.    -- Signals -- 
  209.    ------------- 
  210.  
  211.    type Cb_Gtk_Radio_Menu_Item_Void is not null access procedure 
  212.      (Self : access Gtk_Radio_Menu_Item_Record'Class); 
  213.  
  214.    type Cb_GObject_Void is not null access procedure 
  215.      (Self : access Glib.Object.GObject_Record'Class); 
  216.  
  217.    Signal_Group_Changed : constant Glib.Signal_Name := "group-changed"; 
  218.    procedure On_Group_Changed 
  219.       (Self  : not null access Gtk_Radio_Menu_Item_Record; 
  220.        Call  : Cb_Gtk_Radio_Menu_Item_Void; 
  221.        After : Boolean := False); 
  222.    procedure On_Group_Changed 
  223.       (Self  : not null access Gtk_Radio_Menu_Item_Record; 
  224.        Call  : Cb_GObject_Void; 
  225.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  226.        After : Boolean := False); 
  227.  
  228.    ---------------- 
  229.    -- Interfaces -- 
  230.    ---------------- 
  231.    --  This class implements several interfaces. See Glib.Types 
  232.    -- 
  233.    --  - "Actionable" 
  234.    -- 
  235.    --  - "Activatable" 
  236.    -- 
  237.    --  - "Buildable" 
  238.  
  239.    package Implements_Gtk_Actionable is new Glib.Types.Implements 
  240.      (Gtk.Actionable.Gtk_Actionable, Gtk_Radio_Menu_Item_Record, Gtk_Radio_Menu_Item); 
  241.    function "+" 
  242.      (Widget : access Gtk_Radio_Menu_Item_Record'Class) 
  243.    return Gtk.Actionable.Gtk_Actionable 
  244.    renames Implements_Gtk_Actionable.To_Interface; 
  245.    function "-" 
  246.      (Interf : Gtk.Actionable.Gtk_Actionable) 
  247.    return Gtk_Radio_Menu_Item 
  248.    renames Implements_Gtk_Actionable.To_Object; 
  249.  
  250.    package Implements_Gtk_Activatable is new Glib.Types.Implements 
  251.      (Gtk.Activatable.Gtk_Activatable, Gtk_Radio_Menu_Item_Record, Gtk_Radio_Menu_Item); 
  252.    function "+" 
  253.      (Widget : access Gtk_Radio_Menu_Item_Record'Class) 
  254.    return Gtk.Activatable.Gtk_Activatable 
  255.    renames Implements_Gtk_Activatable.To_Interface; 
  256.    function "-" 
  257.      (Interf : Gtk.Activatable.Gtk_Activatable) 
  258.    return Gtk_Radio_Menu_Item 
  259.    renames Implements_Gtk_Activatable.To_Object; 
  260.  
  261.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  262.      (Gtk.Buildable.Gtk_Buildable, Gtk_Radio_Menu_Item_Record, Gtk_Radio_Menu_Item); 
  263.    function "+" 
  264.      (Widget : access Gtk_Radio_Menu_Item_Record'Class) 
  265.    return Gtk.Buildable.Gtk_Buildable 
  266.    renames Implements_Gtk_Buildable.To_Interface; 
  267.    function "-" 
  268.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  269.    return Gtk_Radio_Menu_Item 
  270.    renames Implements_Gtk_Buildable.To_Object; 
  271.  
  272. private 
  273.    Group_Property : constant Glib.Properties.Property_Object := 
  274.      Glib.Properties.Build ("group"); 
  275. end Gtk.Radio_Menu_Item;