• Re: Gtk in ada using radiobuttons

    From Ludovic Brenta@21:1/5 to All on Sat Oct 15 17:58:00 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From ldries46@21:1/5 to All on Sun Oct 16 18:43:17 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jeffrey R.Carter@21:1/5 to All on Sun Oct 16 22:12:17 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jeffrey R.Carter@21:1/5 to Ludovic Brenta on Sun Oct 16 22:09:03 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ludovic Brenta@21:1/5 to Jeffrey R.Carter on Mon Oct 17 00:14:27 2022
    "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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From ldries46@21:1/5 to All on Mon Oct 17 08:56:09 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From ldries46@21:1/5 to All on Mon Oct 17 09:27:11 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jeffrey R.Carter@21:1/5 to Ludovic Brenta on Mon Oct 17 10:18:13 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ludovic Brenta@21:1/5 to bertus.dries@planet.nl on Mon Oct 17 13:22:56 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ludovic Brenta@21:1/5 to bertus.dries@planet.nl on Mon Oct 17 13:17:05 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ludovic Brenta@21:1/5 to bertus.dries@planet.nl on Mon Oct 17 13:18:08 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)