comp.lang.ada
 help / color / mirror / Atom feed
From: ldries46 <bertus.dries@planet.nl>
Subject: Gtk in ada using radiobuttons
Date: Sat, 15 Oct 2022 16:28:47 +0200	[thread overview]
Message-ID: <nnd$0c6be124$11646b54@413dc7685a372cde> (raw)

[-- Attachment #1: Type: text/plain, Size: 419 bytes --]

I realized a set of two radiobuttons that should operate in a group, 
either one or the other but I cannot find the correct way to combine 
these two radio buttons although I can see the dialog in which they are 
used. only both buttons are on and clicking on them cannot set either of 
the off. I tried to find an example how to do this on internet.  I just 
send the used files along. Can anybody help me.



[-- Attachment #2: CPP2Ada_Dialog_Type_Init.ads --]
[-- Type: text/plain, Size: 3285 bytes --]

------------------------------------------------------------------------------
--                                                                          --
--      Copyright (C) 2019 L. Dries                                         --
--                                                                          --
-- This library is free software;  you can redistribute it and/or modify it --
-- under terms of the  GNU General Public License  as published by the Free --
-- Software  Foundation;  either version 3,  or (at your  option) any later --
-- version. This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            --
--                                                                          --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception,   --
-- version 3.1, as published by the Free Software Foundation.               --
--                                                                          --
-- You should have received a copy of the GNU General Public License and    --
-- a copy of the GCC Runtime Library Exception along with this program;     --
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
-- <http://www.gnu.org/licenses/>.                                          --
--                                                                          --
------------------------------------------------------------------------------
-- Version 1.00 dd. 19-07-2016 created by L. Dries                          --
------------------------------------------------------------------------------
-- Created from Template V1.00 by L. Dries on  23- 10- 2018                 --
------------------------------------------------------------------------------

pragma License(Unrestricted);

with Glib;                  use Glib;
with Gtk.Widget;            use Gtk.Widget;
with Gtk.Dialog;            use Gtk.Dialog;
with Gtk.Window;            use Gtk.Window;
with Gtk.Box;               use Gtk.Box;
with Gtk.Button;            use Gtk.Button;
with Gtk.Frame;             use Gtk.Frame;
with Gtk.Radio_Button;      use Gtk.Radio_Button;

package CPP2Ada_Dialog_Type_Init is

   type Type_Dialog_Record is new Gtk_Dialog_Record with record
      Dialog_Box   : Gtk_Box;
      Button_Box   : Gtk_Box;
      Frame_Box    : Gtk_Box;
      Frame        : Gtk_Frame;
      Radio_Frame  : Gtk_Window_Group;
      Radio_Header : Gtk_Radio_Button;
      Radio_CPP    : Gtk_Radio_Button;
      OK           : Gtk_Button;
      Wrong_File   : Gtk_Button;
   end record;

   type Type_Dialog_Access is access all Type_Dialog_Record'Class;

   Dialogsize_H     : Gint := 150;  -- Width of the dialog window
   Dialogsize_V     : Gint := 80;   -- Height of the dialog window
   Type_Dialog      : Type_Dialog_Access;
   Type_Dialog_Open : Boolean := false;

   procedure Type_New(TypeDialog : out Type_Dialog_Access);
   procedure Type_Init(TypeDialog : access Type_Dialog_Record'Class);

end CPP2Ada_Dialog_Type_Init;

[-- Attachment #3: CPP2Ada_Dialog_Type_Init.adb --]
[-- Type: text/plain, Size: 5933 bytes --]

------------------------------------------------------------------------------
--                                                                          --
--      Copyright (C) 2019 L. Dries                                         --
--                                                                          --
-- This library is free software;  you can redistribute it and/or modify it --
-- under terms of the  GNU General Public License  as published by the Free --
-- Software  Foundation;  either version 3,  or (at your  option) any later --
-- version. This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            --
--                                                                          --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception,   --
-- version 3.1, as published by the Free Software Foundation.               --
--                                                                          --
-- You should have received a copy of the GNU General Public License and    --
-- a copy of the GCC Runtime Library Exception along with this program;     --
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
-- <http://www.gnu.org/licenses/>.                                          --
--                                                                          --
------------------------------------------------------------------------------
-- Version 1.00 dd. 19-07-2016 created by L. Dries                          --
------------------------------------------------------------------------------
-- Created from Template V1.00 by L. Dries on  23- 10- 2018                 --
------------------------------------------------------------------------------

pragma License(Unrestricted);

with Gtk.Enums;               use Gtk.Enums;
with Gtk.Handlers;            use Gtk.Handlers;
with Gtk.Combo_Box_Text;      use Gtk.Combo_Box_Text;
with Glib.Gslist;             use Glib.Gslist;
with Ada.Strings.Unbounded;   use Ada.Strings.Unbounded;
with CPP2Ada_Dialog_Type_CB; use CPP2Ada_Dialog_Type_CB;
with CPP2Ada_General;         use CPP2Ada_General;
with CPP2Ada_Main_Init;       use CPP2Ada_Main_Init;
with CPP2Ada_Languages;       use CPP2Ada_Languages;

package body CPP2Ada_Dialog_Type_Init is

   package Dialog_CBR is new
     Gtk.Handlers.Return_Callback (Gtk_Dialog_Record, Boolean);
   package Button is new
     Gtk.Handlers.Callback (Gtk_Button_Record);

   procedure Type_New(TypeDialog : out Type_Dialog_Access) is
   begin
      TypeDialog := new Type_Dialog_Record;
      CPP2Ada_Dialog_Type_Init.Type_Init (TypeDialog);
   end Type_New;

   procedure Type_Init(TypeDialog : access Type_Dialog_Record'Class) is
      pragma Suppress (All_Checks);
      Pixmaps_Dir : constant String := "pixmaps/";
      Items : String_List.Glist;
   begin
      Gtk.Dialog.Initialize (TypeDialog);
      TypeDialog.Set_Title (To_String(Type_Dialog_Title(Lan)));
      Set_Position (TypeDialog, Win_Pos_Center);
      Set_Modal (TypeDialog, true);
      Set_Resizable (TypeDialog, false);
      Set_Default_Size (TypeDialog, Dialogsize_H, Dialogsize_V);
      if Set_Icon_From_File(TypeDialog, Icon_Name) then
         On_Type_End(null);
      end if;
      Type_Dialog_Open := true;
      TypeDialog.Dialog_Box := Get_Content_Area(TypeDialog);
      Gtk_New(TypeDialog.Button_Box, Orientation_Horizontal, 0);
      Gtk_New(TypeDialog.Frame_Box, Orientation_Vertical, 0);
      Gtk_New(TypeDialog.Frame, To_String(Type_Frame_Title(lan)));
      Gtk_New (TypeDialog.Radio_Header);
      Gtk_New (TypeDialog.Radio_CPP);
      Pack_Start
        (TypeDialog.Frame_Box,
         TypeDialog.Frame,
         Expand  => True,
         Fill    => True,
         Padding => 0);
      Set_Label(TypeDialog.Radio_Header, To_String(Type_Header_Title(lan)));
      Pack_Start
        (TypeDialog.Frame_Box,
         TypeDialog.Radio_Header,
         Expand  => True,
         Fill    => True,
         Padding => 0);
      Set_Label(TypeDialog.Radio_CPP, To_String(Type_CPP_Title(lan)));
      Pack_Start
        (TypeDialog.Frame_Box,
         TypeDialog.Radio_CPP,
         Expand  => True,
         Fill    => True,
         Padding => 1);
      Gtk_New (TypeDialog.Wrong_File, To_String(Lan_Wrong_File(Lan)));
      Pack_Start
        (TypeDialog.Button_Box,
         TypeDialog.Wrong_File,
         Expand  => True,
         Fill    => True,
         Padding => 0);
      Gtk_New (TypeDialog.OK, To_String(Lan_OK(Lan)));
      Pack_Start
        (TypeDialog.Button_Box,
         TypeDialog.OK,
         Expand  => True,
         Fill    => True,
         Padding => 0);
        Pack_Start
        (TypeDialog.Dialog_Box,
         TypeDialog.Frame_Box,
         Expand  => True,
         Fill    => True,
         Padding => 0);
    Pack_Start
        (TypeDialog.Dialog_Box,
         TypeDialog.Button_Box,
         Expand  => True,
         Fill    => True,
         Padding => 0);
      TypeDialog.Radio_Frame := Get_Group(TypeDialog.Radio_Header'record);
      Set_Group(TypeDialog.Radio_CPP, TypeDialog.Radio_Frame);
      Set_Size_Request(TypeDialog, Dialogsize_H, Dialogsize_V);
      Dialog_CBR.Connect(TypeDialog, "delete_event",
                         Dialog_CBR.To_Marshaller(On_Type_Delete_Event'Access));
      Button.Connect(TypeDialog.OK, "clicked",
                     Button.To_Marshaller(On_Type_OK'Access));
      Button.Connect(TypeDialog.Wrong_File, "clicked",
                     Button.To_Marshaller(On_Type_End'Access));
   end Type_Init;

end CPP2Ada_Dialog_Type_Init;

             reply	other threads:[~2022-10-15 14:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-15 14:28 ldries46 [this message]
2022-10-15 15:58 ` Gtk in ada using radiobuttons Ludovic Brenta
2022-10-16 20:09   ` Jeffrey R.Carter
2022-10-16 22:14     ` Ludovic Brenta
2022-10-17  7:27       ` ldries46
2022-10-17 11:18         ` Ludovic Brenta
2022-10-17 11:22         ` Ludovic Brenta
2022-10-17  8:18       ` Jeffrey R.Carter
2022-10-16 16:43 ` ldries46
2022-10-16 20:12   ` Jeffrey R.Carter
2022-10-17  6:56     ` ldries46
2022-10-17 11:17       ` Ludovic Brenta
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox