[gtkmm-documentation] RadioButton section: Describe Gtk::RadioButton::join_group()
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] RadioButton section: Describe Gtk::RadioButton::join_group()
- Date: Sun, 7 Aug 2016 15:04:27 +0000 (UTC)
commit 622bca45dec1a42dd8aafcb8cb93d257c84500a3
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Sun Aug 7 17:00:30 2016 +0200
RadioButton section: Describe Gtk::RadioButton::join_group()
* docs/tutorial/C/index-in.docbook: RadioButton section: Describe join_group().
* examples/book/buttons/radiobutton/radiobuttons.cc:
* examples/book/keyboard_events/simple/examplewindow.cc: Use join_group().
Bug #769374
docs/tutorial/C/index-in.docbook | 44 ++++++++-----------
examples/book/buttons/radiobutton/radiobuttons.cc | 7 +--
.../book/keyboard_events/simple/examplewindow.cc | 3 +-
3 files changed, 22 insertions(+), 32 deletions(-)
---
diff --git a/docs/tutorial/C/index-in.docbook b/docs/tutorial/C/index-in.docbook
index bd0b6f6..9488c56 100644
--- a/docs/tutorial/C/index-in.docbook
+++ b/docs/tutorial/C/index-in.docbook
@@ -907,36 +907,34 @@ put three radio buttons in it:
<programlisting>class RadioButtons : public Gtk::Window
{
public:
- RadioButtons();
+ RadioButtons();
protected:
- Gtk::RadioButton m_rb1, m_rb2, m_rb3;
+ Gtk::RadioButton m_rb1, m_rb2, m_rb3;
};
RadioButtons::RadioButtons()
- : m_rb1("button1"),
- m_rb2("button2"),
- m_rb3("button3")
+: m_rb1("button1"),
+ m_rb2("button2"),
+ m_rb3("button3")
{
- Gtk::RadioButton::Group group = m_rb1.get_group();
- m_rb2.set_group(group);
- m_rb3.set_group(group);
+ m_rb2.join_group(m_rb1);
+ m_rb3.join_group(m_rb1);
}</programlisting>
<para>
We told >kmm; to put all three <classname>RadioButton</classname>s in the
-same group by obtaining the group with <methodname>get_group()</methodname> and using
-<methodname>set_group()</methodname> to tell the other
-<classname>RadioButton</classname>s to share that group.
+same group by using <methodname>join_group()</methodname> to tell the other
+<classname>RadioButton</classname>s to share group with the first
+<classname>RadioButton</classname>.
</para>
<para>
-Note that you can't just do
+Note that you can't do
<programlisting>m_rb2.set_group(m_rb1.get_group()); //doesn't work</programlisting>
-because the group is modified by <methodname>set_group()</methodname> and therefore
-non-const.
+because <methodname>get_group()</methodname> returns a <classname>RadioButton::Group</classname>
+which is modified by <methodname>set_group()</methodname> and therefore is non-const.
</para>
-
<para>
The second way to set up radio buttons is to make a group first, and
then add radio buttons to it. Here's an example:
@@ -944,25 +942,21 @@ then add radio buttons to it. Here's an example:
<programlisting>class RadioButtons : public Gtk::Window
{
public:
- RadioButtons();
+ RadioButtons();
};
RadioButtons::RadioButtons()
{
- Gtk::RadioButton::Group group;
- Gtk::RadioButton *m_rb1 = Gtk::manage(
- new Gtk::RadioButton(group,"button1"));
- Gtk::RadioButton *m_rb2 = manage(
- new Gtk::RadioButton(group,"button2"));
- Gtk::RadioButton *m_rb3 = manage(
- new Gtk::RadioButton(group,"button3"));
+ Gtk::RadioButton::Group group;
+ Gtk::RadioButton* m_rb1 = Gtk::manage(new Gtk::RadioButton(group, "button1"));
+ Gtk::RadioButton* m_rb2 = Gtk::manage(new Gtk::RadioButton(group, "button2"));
+ Gtk::RadioButton* m_rb3 = Gtk::manage(new Gtk::RadioButton(group, "button3"));
}</programlisting>
<para>
We made a new group by simply declaring a variable, <literal>group</literal>,
of type <classname>Gtk::RadioButton::Group</classname>. Then we made three radio
-buttons, using a constructor to make each of them part of
-<literal>group</literal>.
+buttons, using a constructor to make each of them part of <literal>group</literal>.
</para>
</sect2>
diff --git a/examples/book/buttons/radiobutton/radiobuttons.cc
b/examples/book/buttons/radiobutton/radiobuttons.cc
index ed4b14b..227d998 100644
--- a/examples/book/buttons/radiobutton/radiobuttons.cc
+++ b/examples/book/buttons/radiobutton/radiobuttons.cc
@@ -1,5 +1,3 @@
-//$Id: radiobuttons.cc 836 2007-05-09 03:02:38Z jjongsma $ -*- c++ -*-
-
/* gtkmm example Copyright (C) 2002 gtkmm development team
*
* This program is free software; you can redistribute it and/or modify
@@ -33,9 +31,8 @@ RadioButtons::RadioButtons() :
set_border_width(0);
// Put radio buttons 2 and 3 in the same group as 1:
- Gtk::RadioButton::Group group = m_RadioButton1.get_group();
- m_RadioButton2.set_group(group);
- m_RadioButton3.set_group(group);
+ m_RadioButton2.join_group(m_RadioButton1);
+ m_RadioButton3.join_group(m_RadioButton1);
// Add outer box to the window (because the window
// can only contain a single widget)
diff --git a/examples/book/keyboard_events/simple/examplewindow.cc
b/examples/book/keyboard_events/simple/examplewindow.cc
index 6e0a23e..c8528ee 100644
--- a/examples/book/keyboard_events/simple/examplewindow.cc
+++ b/examples/book/keyboard_events/simple/examplewindow.cc
@@ -26,8 +26,7 @@ ExampleWindow::ExampleWindow()
m_first.set_label("First");
m_second.set_label("Second");
- Gtk::RadioButton::Group group = m_first.get_group();
- m_second.set_group(group);
+ m_second.join_group(m_first);
m_first.set_active();
// Main Container:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]