Debian Codegraph @

gtk/src/radiotoolbutton.ccg

raw
1 /* Copyright (C) 1998-2002 The gtkmm Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
15 */
16
17 #include <gtk/gtk.h>
18
19 typedef Gtk::RadioToolButton::Group Group; //So that the generate get_group return type is parsed.
20
21 namespace Gtk
22 {
23
24 RadioToolButton::RadioToolButton(const Glib::ustring& label)
25 :
26 _CONSTRUCT("label", label.c_str())
27 {
28 }
29
30 RadioToolButton::RadioToolButton(Group& group, const Glib::ustring& label)
31 :
32 Glib::ObjectBase(nullptr), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
33 Gtk::ToggleToolButton(Glib::ConstructParams(radiotoolbutton_class_.init(), "label", label.c_str(), nullptr))
34 {
35 set_group(group);
36 }
37
38 #ifndef GTKMM_DISABLE_DEPRECATED
39 RadioToolButton::RadioToolButton(Group& group, const Gtk::StockID& stock_id)
40 :
41 Glib::ObjectBase(nullptr), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
42 Gtk::ToggleToolButton(Glib::ConstructParams(radiotoolbutton_class_.init(), "stock_id", (stock_id).get_c_str(), nullptr))
43 {
44 //Based on the source of gtk_radio_tool_button_new_from_stock():
45 set_group(group);
46 }
47 #endif // GTKMM_DISABLE_DEPRECATED
48
49 /* This would look too much like a copy constructor:
50 RadioToolButton::RadioToolButton(RadioToolButton& group, const Gtk::StockID& stock_id)
51 :
52 Glib::ObjectBase(nullptr), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
53 Gtk::ToggleToolButton(Glib::ConstructParams(radiotoolbutton_class_.init(), "stock_id", (stock_id).get_c_str(), nullptr))
54 {
55 //Based on the source of gtk_radio_tool_button_new_with_stock_from_widget():
56 auto radiogroup = group.get_group();
57 set_group(radiogroup);
58 }
59 */
60
61 RadioToolButton::RadioToolButton(Widget& icon_widget, const Glib::ustring& label)
62 :
63 Glib::ObjectBase(nullptr), //Mark this class as gtkmmproc-generated, rather than a custom class, to allow vfunc optimisations.
64 Gtk::ToggleToolButton(Glib::ConstructParams(radiotoolbutton_class_.init(), "icon_widget", (icon_widget).gobj(), "label", label.c_str(), nullptr))
65 {
66 }
67
68 void RadioToolButton::set_group(Group& group)
69 {
70 gtk_radio_tool_button_set_group(gobj(), group.group_);
71
72 //The group will be updated, ready for use with the next radio tool button:
73 group = get_group();
74 }
75
76 void RadioToolButton::reset_group()
77 {
78 gtk_radio_tool_button_set_group(gobj(), nullptr);
79 }
80
81 void RadioToolButton::join_group(RadioToolButton& group_source)
82 {
83 gtk_radio_tool_button_set_group(gobj(), gtk_radio_tool_button_get_group(group_source.gobj()));
84 }
85
86 } // namespace Gtk