Debian Codegraph @

gtk/src/toggleaction.hg

raw
1 /* Copyright (C) 2003 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 // To exclude this file from the documentation when build-deprecated-api=false.
18 _CONFIGINCLUDE(gtkmmconfig.h)
19
20 #include <gtkmm/action.h>
21
22 _DEFS(gtkmm,gtk)
23 _PINCLUDE(gtkmm/private/action_p.h)
24
25 #m4 _PUSH(SECTION_CC_PRE_INCLUDES)
26 #undef GTK_DISABLE_DEPRECATED
27 #define GDK_DISABLE_DEPRECATION_WARNINGS 1
28 #m4 _POP()
29
30 _IS_DEPRECATED // This whole file is deprecated.
31
32 namespace Gtk
33 {
34
35 /** A deprecated action which can be toggled between two states.
36 *
37 * A Gtk::ToggleAction corresponds roughly to a Gtk::CheckMenuItem.
38 * It has an "active" state specifying whether the action has been checked or not.
39 *
40 * @deprecated Use Gio::Action and Gio::SimpleAction instead, and associate actions
41 * with Gtk::Actionable widgets. Use Gio::MenuModel for creating menus with
42 * Gtk::Menu(const Glib::RefPtr<Gio::MenuModel>& model).
43 * See the Gtk::Action base class for more information about the deprecation.
44 */
45 class GTKMM_API ToggleAction : public Gtk::Action
46 {
47 _CLASS_GOBJECT(ToggleAction, GtkToggleAction, GTK_TOGGLE_ACTION, Gtk::Action, GtkAction, , , GTKMM_API)
48
49 protected:
50 /** Creates an empty toggle action. */
51 _CTOR_DEFAULT
52
53 _DEPRECATE_IFDEF_START
54 /** Creates a toggle action.
55 *
56 * @param name A unique name for the action.
57 * @param stock_id The stock icon to display in widgets representing the
58 * action.
59 * @param label The label displayed in menu items and on buttons.
60 * @param tooltip A tooltip for the action.
61 * @param is_active The default checked state of the action.
62 *
63 * @deprecated There is no corresponding replacement when using Gio::Action.
64 */
65 explicit ToggleAction(const Glib::ustring& name, const StockID& stock_id = StockID(), const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring(), bool is_active = false);
66
67 /** Creates a toggle action with an icon name.
68 * The toggle action's icon will reflect the specified icon name in the
69 * user's icon theme.
70 *
71 * @param name A unique name for the action.
72 * @param icon_name An IconTheme icon name used for widgets representing the
73 * action.
74 * @param label The label displayed in menu items and on buttons.
75 * @param tooltip A tooltip for the action.
76 * @param is_active The default checked state of the action.
77 * @deprecated Use Gio::Action, which can be created by Gio::ActionMap::add_action_bool().<br>
78 * Use Gio::MenuItem::set_icon() to set an icon on a Gio::MenuItem associated with a Gio::Action,
79 * or Gtk::Container::add() to add a Gtk::Image to a Gtk::ToggleButton.<br>
80 * Set a label on a menu item with Gio::MenuItem::set_label().
81 * For Gtk::Actionable widgets, use the widget-specific API to set a label.<br>
82 * Set tooltips on associated Gtk::Actionable widgets with Gtk::Widget::set_tooltip_text().
83 */
84 explicit ToggleAction(const Glib::ustring& name, const Glib::ustring& icon_name, const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring(), bool is_active = false);
85 _DEPRECATE_IFDEF_END
86
87 public:
88 //Note that gtk_toggle_action_new() does not allow name to be NULL, which suggests that we should not have a default constructor,
89 //but it's OK to set the name later:
90 _WRAP_CREATE()
91
92 _DEPRECATE_IFDEF_START
93 /** Creates a toggle action.
94 *
95 * @param name A unique name for the action.
96 * @param label The label displayed in menu items and on buttons.
97 * @param tooltip A tooltip for the action.
98 * @param is_active The default checked state of the action.
99 *
100 * @return A new ToggleAction.
101 * @deprecated Use Gio::Action, which can be created by Gio::ActionMap::add_action_bool().<br>
102 * Set a label on a menu item with Gio::MenuItem::set_label().
103 * For Gtk::Actionable widgets, use the widget-specific API to set a label.<br>
104 * Set tooltips on associated Gtk::Actionable widgets with Gtk::Widget::set_tooltip_text().
105 */
106 static Glib::RefPtr<ToggleAction> create(const Glib::ustring& name, const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring(), bool is_active = false);
107
108 /** Creates a toggle action with a stock ID.
109 * The tock ID is used to set a default icon, text and accelerator for
110 * the toggle action.
111 *
112 * @param name A unique name for the action.
113 * @param stock_id The stock icon to display in widgets representing the
114 * action.
115 * @param label The label displayed in menu items and on buttons.
116 * @param tooltip A tooltip for the action.
117 * @param is_active The default checked state of the action.
118 *
119 * @return A new ToggleAction.
120 * @deprecated There is no corresponding replacement when using Gio::Action.
121 */
122 static Glib::RefPtr<ToggleAction> create(const Glib::ustring& name, const Gtk::StockID& stock_id, const Glib::ustring& label = Glib::ustring(), const Glib::ustring& tooltip = Glib::ustring(), bool is_active = false);
123
124 /** Creates a toggle action with an icon name.
125 * The toggle action's icon will reflect the specified icon name in the
126 * user's icon theme.
127 *
128 * @param name A unique name for the action.
129 * @param icon_name An IconTheme icon name used for widgets representing the
130 * action.
131 * @param label The label displayed in menu items and on buttons.
132 * @param tooltip A tooltip for the action.
133 * @param is_active The default checked state of the action.
134 *
135 * @return A new ToggleAction.
136 * @deprecated Use Gio::Action, which can be created by Gio::ActionMap::add_action_bool().<br>
137 * Use Gio::MenuItem::set_icon() to set an icon on a Gio::MenuItem associated with a Gio::Action,
138 * or Gtk::Container::add() to add a Gtk::Image to a Gtk::ToggleButton.<br>
139 * Set a label on a menu item with Gio::MenuItem::set_label().
140 * For Gtk::Actionable widgets, use the widget-specific API to set a label.<br>
141 * Set tooltips on associated Gtk::Actionable widgets with Gtk::Widget::set_tooltip_text().
142 */
143 static Glib::RefPtr<ToggleAction> create_with_icon_name(const Glib::ustring& name, const Glib::ustring& icon_name, const Glib::ustring& label, const Glib::ustring& tooltip, bool is_active = false);
144 _DEPRECATE_IFDEF_END
145
146 _WRAP_METHOD(void toggled(), gtk_toggle_action_toggled, deprecated "Use Gio::Action::activate() on a Gio::Action instead.")
147 _WRAP_METHOD(void set_active(bool is_active = true), gtk_toggle_action_set_active, deprecated "Use Gio::Action::change_state() on a Gio::Action instead.")
148 _WRAP_METHOD(bool get_active() const, gtk_toggle_action_get_active, deprecated "Use Gio::Action::get_state() on a Gio::Action instead.")
149 _WRAP_METHOD(void set_draw_as_radio(bool draw_as_radio = true), gtk_toggle_action_set_draw_as_radio,
150 deprecated "Use Gtk::CheckMenuItem::set_draw_as_radio() on a Gtk::CheckMenuItem instead.")
151 _WRAP_METHOD(bool get_draw_as_radio() const, gtk_toggle_action_get_draw_as_radio,
152 deprecated "Use Gtk::CheckMenuItem::get_draw_as_radio() on a Gtk::CheckMenuItem instead.")
153
154 _WRAP_SIGNAL(void toggled(), "toggled", deprecated "Use Gio::SimpleAction::signal_activate() or Gio::SimpleAction::signal_change_state() instead.")
155
156 _WRAP_PROPERTY("draw_as_radio", bool, deprecated "Use Gtk::CheckMenuItem::property_draw_as_radio() on a Gtk::CheckMenuItem instead.")
157 _WRAP_PROPERTY("active", bool, deprecated "Use Gio::Action::property_state() and Gio::SimpleAction::property_state() instead.")
158 };
159
160 } // namespace Gtk