* Gtk in ada using radiobuttons
@ 2022-10-15 14:28 ldries46
2022-10-15 15:58 ` Ludovic Brenta
2022-10-16 16:43 ` ldries46
0 siblings, 2 replies; 12+ messages in thread
From: ldries46 @ 2022-10-15 14:28 UTC (permalink / 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;
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Gtk in ada using radiobuttons
2022-10-15 14:28 Gtk in ada using radiobuttons ldries46
@ 2022-10-15 15:58 ` Ludovic Brenta
2022-10-16 20:09 ` Jeffrey R.Carter
2022-10-16 16:43 ` ldries46
1 sibling, 1 reply; 12+ messages in thread
From: Ludovic Brenta @ 2022-10-15 15:58 UTC (permalink / raw)
Read the comments at the top of gtk-radio_button.ads; it explains how to
retrieve the group from the first radio button and then assign all other
buttons to that group. See Get_Group, Set_Group.
--
Ludovic Brenta.
Talent retention and emotional impact technically interact with scalabilities.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Gtk in ada using radiobuttons
2022-10-15 14:28 Gtk in ada using radiobuttons ldries46
2022-10-15 15:58 ` Ludovic Brenta
@ 2022-10-16 16:43 ` ldries46
2022-10-16 20:12 ` Jeffrey R.Carter
1 sibling, 1 reply; 12+ messages in thread
From: ldries46 @ 2022-10-16 16:43 UTC (permalink / raw)
Op 15-10-2022 om 16:28 schreef ldries46:
> 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.
>
>
As far as I can read in gtk-radio_button.ads the followinf dtatements
should do the trick:
TypeDialog.Radio_Frame := Widget_SList.Null_List;
TypeDialog.Radio_Header :=
Gtk_Radio_Button_New_With_Label(TypeDialog.Radio_Frame,To_String(Ext_C_Header(lan)));
TypeDialog.Radio_CPP :=
Gtk_Radio_Button_New_With_Label(TypeDialog.Radio_Frame,
To_String(Ext_CPP_Header(lan)));
Pack_Start
(TypeDialog.Radio_Button_Box,
TypeDialog.Radio_Header,
Expand => True,
Fill => True,
Padding => 0);
Pack_Start
(TypeDialog.Radio_Button_Box,
TypeDialog.Radio_CPP,
Expand => True,
Fill => True,
Padding => 1);
But the dialog looks good with the exception that both buttons are
activated and cannot be deactivated. I still do want the choice between
the two I cannot find that in the When running in debugging mode I can
see that the group still is null
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Gtk in ada using radiobuttons
2022-10-15 15:58 ` Ludovic Brenta
@ 2022-10-16 20:09 ` Jeffrey R.Carter
2022-10-16 22:14 ` Ludovic Brenta
0 siblings, 1 reply; 12+ messages in thread
From: Jeffrey R.Carter @ 2022-10-16 20:09 UTC (permalink / raw)
On 2022-10-15 17:58, Ludovic Brenta wrote:
> Read the comments at the top of gtk-radio_button.ads; it explains how to
> retrieve the group from the first radio button and then assign all other
> buttons to that group. See Get_Group, Set_Group.
I know of no reason why the client of a GUI library would ever create a single,
independent radio button. A single radio button is useless. One always wants to
create a set of linked buttuns. A GUI library that makes the client do extra
work to achieve this is poorly designed.
--
Jeff Carter
"No one is to stone anyone until I blow this whistle,
do you understand? Even--and I want to make this
absolutely clear--even if they do say, 'Jehovah.'"
Monty Python's Life of Brian
74
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Gtk in ada using radiobuttons
2022-10-16 16:43 ` ldries46
@ 2022-10-16 20:12 ` Jeffrey R.Carter
2022-10-17 6:56 ` ldries46
0 siblings, 1 reply; 12+ messages in thread
From: Jeffrey R.Carter @ 2022-10-16 20:12 UTC (permalink / raw)
On 2022-10-16 18:43, ldries46 wrote:
>
> But the dialog looks good with the exception that both buttons are activated and
> cannot be deactivated. I still do want the choice between the two I cannot find
> that in the When running in debugging mode I can see that the group still is null
A set of 2 radio buttons is usually equivalent to a check box, which is visually
simpler as well.
--
Jeff Carter
"No one is to stone anyone until I blow this whistle,
do you understand? Even--and I want to make this
absolutely clear--even if they do say, 'Jehovah.'"
Monty Python's Life of Brian
74
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Gtk in ada using radiobuttons
2022-10-16 20:09 ` Jeffrey R.Carter
@ 2022-10-16 22:14 ` Ludovic Brenta
2022-10-17 7:27 ` ldries46
2022-10-17 8:18 ` Jeffrey R.Carter
0 siblings, 2 replies; 12+ messages in thread
From: Ludovic Brenta @ 2022-10-16 22:14 UTC (permalink / raw)
"Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not> writes:
> On 2022-10-15 17:58, Ludovic Brenta wrote:
>> Read the comments at the top of gtk-radio_button.ads; it explains how to
>> retrieve the group from the first radio button and then assign all other
>> buttons to that group. See Get_Group, Set_Group.
>
> I know of no reason why the client of a GUI library would ever create
> a single, independent radio button. A single radio button is useless.
> One always wants to create a set of linked buttuns.
Yes but you create the radio buttons one at a time, so one of the
buttons must be the first you create.
> A GUI library that makes the client do extra work to achieve this is
> poorly designed.
Agreed but since you've read the documentation by now, you know about
Gtk_Radio_Button_New_With_Label_From_Widget.
--
Ludovic Brenta.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Gtk in ada using radiobuttons
2022-10-16 20:12 ` Jeffrey R.Carter
@ 2022-10-17 6:56 ` ldries46
2022-10-17 11:17 ` Ludovic Brenta
0 siblings, 1 reply; 12+ messages in thread
From: ldries46 @ 2022-10-17 6:56 UTC (permalink / raw)
Op 16-10-2022 om 22:12 schreef Jeffrey R.Carter:
> On 2022-10-16 18:43, ldries46 wrote:
>>
>> But the dialog looks good with the exception that both buttons are
>> activated and cannot be deactivated. I still do want the choice
>> between the two I cannot find that in the When running in debugging
>> mode I can see that the group still is null
>
> A set of 2 radio buttons is usually equivalent to a check box, which
> is visually simpler as well.
>
Building a program is sometimes a step by step process. It may be
possible that I need a third or even a fourth possibility in the choice,
so in my opinion it is good to anticipate
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Gtk in ada using radiobuttons
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
1 sibling, 2 replies; 12+ messages in thread
From: ldries46 @ 2022-10-17 7:27 UTC (permalink / raw)
Op 17-10-2022 om 0:14 schreef Ludovic Brenta:
> "Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not> writes:
>> On 2022-10-15 17:58, Ludovic Brenta wrote:
>>> Read the comments at the top of gtk-radio_button.ads; it explains how to
>>> retrieve the group from the first radio button and then assign all other
>>> buttons to that group. See Get_Group, Set_Group.
>> I know of no reason why the client of a GUI library would ever create
>> a single, independent radio button. A single radio button is useless.
>> One always wants to create a set of linked buttuns.
> Yes but you create the radio buttons one at a time, so one of the
> buttons must be the first you create.
>
>> A GUI library that makes the client do extra work to achieve this is
>> poorly designed.
> Agreed but since you've read the documentation by now, you know about
> Gtk_Radio_Button_New_With_Label_From_Widget.
>
Finally I had the correct view and working of my dialogue.
But the very first remark I made stays true for someone trying to use
Gtk is stays a problem without good example code.
Examples are almost always a better way to learn something while the
description in the ads files are always technically correct descriptions
of the function and not how the function interacts with all other functions.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Gtk in ada using radiobuttons
2022-10-16 22:14 ` Ludovic Brenta
2022-10-17 7:27 ` ldries46
@ 2022-10-17 8:18 ` Jeffrey R.Carter
1 sibling, 0 replies; 12+ messages in thread
From: Jeffrey R.Carter @ 2022-10-17 8:18 UTC (permalink / raw)
On 2022-10-17 00:14, Ludovic Brenta wrote:
> "Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not> writes:
>>
>> I know of no reason why the client of a GUI library would ever create
>> a single, independent radio button. A single radio button is useless.
>> One always wants to create a set of linked buttons.
>
> Yes but you create the radio buttons one at a time, so one of the
> buttons must be the first you create.
This may be necessary at a low level in the GUI, but there's no reason why the
client-interface pkg of a library can't provide a higher-level interface.
Consider the equivalent from Ada GUI
(https://github.com/jrcarter/Ada_GUI/blob/master/ada_gui.ads):
type Text_List is array (Positive range <>) of
Ada.Strings.Unbounded.Unbounded_String
with
Dynamic_Predicate => Text_List'First = 1;
type Orientation_ID is (Horizontal, Vertical);
function New_Radio_Buttons (Row : Positive := 1;
Column : Positive := 1;
Label : Text_List;
Break_Before : Boolean := False;
Orientation : Orientation_ID := Vertical)
return Widget_ID with Pre => Set_Up and Label'Length > 1;
-- Creates Label'Length radio buttons; Label contains the labels for the
-- buttons
-- Orientation = Horizontal results in a row of buttons
-- = Vertical has each button after the 1st below the preceding
buttons
-- The button for Label'First will be active
-- The operations Set_Active and Active for radio buttons take an Index;
-- Index will refer to the button for Label (Index)
An implementation based on, say, GTK, will have to create the buttons
individually as the GUI requires, but the client doesn't have to deal with that.
--
Jeff Carter
"The men get one hot meal a day: a bowl of steam."
Take the Money and Run
145
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Gtk in ada using radiobuttons
2022-10-17 6:56 ` ldries46
@ 2022-10-17 11:17 ` Ludovic Brenta
0 siblings, 0 replies; 12+ messages in thread
From: Ludovic Brenta @ 2022-10-17 11:17 UTC (permalink / raw)
ldries46 <bertus.dries@planet.nl> writes:
> Op 16-10-2022 om 22:12 schreef Jeffrey R.Carter:
>> On 2022-10-16 18:43, ldries46 wrote:
>>>
>>> But the dialog looks good with the exception that both buttons are
>>> activated and cannot be deactivated. I still do want the choice
>>> between the two I cannot find that in the When running in debugging
>>> mode I can see that the group still is null
>>
>> A set of 2 radio buttons is usually equivalent to a check box, which
>> is visually simpler as well.
>>
> Building a program is sometimes a step by step process. It may be
> possible that I need a third or even a fourth possibility in the
> choice, so in my opinion it is good to anticipate
That's what I assumed. Have you considered a Gtk_Combo_Box as an alternative?
--
Ludovic Brenta.
The attackers re-invent our correlations. As a result, co-innovations swiftly revolutionise our projections.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Gtk in ada using radiobuttons
2022-10-17 7:27 ` ldries46
@ 2022-10-17 11:18 ` Ludovic Brenta
2022-10-17 11:22 ` Ludovic Brenta
1 sibling, 0 replies; 12+ messages in thread
From: Ludovic Brenta @ 2022-10-17 11:18 UTC (permalink / raw)
ldries46 <bertus.dries@planet.nl> writes:
> Finally I had the correct view and working of my dialogue.
> But the very first remark I made stays true for someone trying to use
> Gtk is stays a problem without good example code.
There is example code in the doc but written in C; trivial to translate
to Ada.
https://docs.gtk.org/gtk3/class.RadioButton.html
--
Ludovic Brenta.
Going forward, a leadership effectiveness strengthens the enablers.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Gtk in ada using radiobuttons
2022-10-17 7:27 ` ldries46
2022-10-17 11:18 ` Ludovic Brenta
@ 2022-10-17 11:22 ` Ludovic Brenta
1 sibling, 0 replies; 12+ messages in thread
From: Ludovic Brenta @ 2022-10-17 11:22 UTC (permalink / raw)
ldries46 <bertus.dries@planet.nl> writes:
> Finally I had the correct view and working of my dialogue.
> But the very first remark I made stays true for someone trying to use
> Gtk is stays a problem without good example code.
Also, GtkAda comes with a complete example code called testgtk, which
shows how to use every type of widget. In the case of radio buttons,
look at the file create_radio_buttons.adb. On Debian and derivatives,
this is installed as part of package libgtkada-doc, as
/usr/share/doc/libgtkada-doc/examples/testgtk.tgz.
--
Ludovic Brenta.
The Chief Risk Appetite Officer reaches out our systems.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2022-10-17 11:22 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-15 14:28 Gtk in ada using radiobuttons ldries46
2022-10-15 15:58 ` 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox