1 // Generated by gmmproc 2.64.2 -- DO NOT MODIFY!
2 #ifndef _GIOMM_SIMPLEACTION_H
3 #define _GIOMM_SIMPLEACTION_H
4 
5 
6 #include <glibmm/ustring.h>
7 #include <sigc++/sigc++.h>
8 
9 /* Copyright (C) 2011 The giomm Development Team
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
23  */
24 
25 #include <glibmm/object.h>
26 #include <giomm/action.h>
27 
28 
29 #ifndef DOXYGEN_SHOULD_SKIP_THIS
30 typedef struct _GSimpleAction GSimpleAction;
31 using GSimpleActionClass = GObjectClass;
32 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
33 
34 #ifndef DOXYGEN_SHOULD_SKIP_THIS
35 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
36 
37 
38 #ifndef DOXYGEN_SHOULD_SKIP_THIS
39 namespace Gio
40 { class GIOMM_API SimpleAction_Class; } // namespace Gio
41 #endif //DOXYGEN_SHOULD_SKIP_THIS
42 
43 namespace Gio
44 {
45 
46 /** SimpleAction - A simple Action implementation.
47  * A SimpleAction is the obvious simple implementation of the Action
48  * interface. This is the easiest way to create an action for purposes of
49  * adding it to a SimpleActionGroup.
50  *
51  * See also Gtk::Action.
52  *
53  * @newin{2,32}
54  */
55 
56 class GIOMM_API SimpleAction : public Glib::Object, public Action
57 {
58 
59 #ifndef DOXYGEN_SHOULD_SKIP_THIS
60 
61 public:
62   using CppObjectType = SimpleAction;
63   using CppClassType = SimpleAction_Class;
64   using BaseObjectType = GSimpleAction;
65   using BaseClassType = GSimpleActionClass;
66 
67   // noncopyable
68   SimpleAction(const SimpleAction&) = delete;
69   SimpleAction& operator=(const SimpleAction&) = delete;
70 
71 private:  friend class SimpleAction_Class;
72   static CppClassType simpleaction_class_;
73 
74 protected:
75   explicit SimpleAction(const Glib::ConstructParams& construct_params);
76   explicit SimpleAction(GSimpleAction* castitem);
77 
78 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
79 
80 public:
81 
82   SimpleAction(SimpleAction&& src) noexcept;
83   SimpleAction& operator=(SimpleAction&& src) noexcept;
84 
85   ~SimpleAction() noexcept override;
86 
87   /** Get the GType for this class, for use with the underlying GObject type system.
88    */
89   static GType get_type()      G_GNUC_CONST;
90 
91 #ifndef DOXYGEN_SHOULD_SKIP_THIS
92 
93 
94   static GType get_base_type() G_GNUC_CONST;
95 #endif
96 
97   ///Provides access to the underlying C GObject.
gobj()98   GSimpleAction*       gobj()       { return reinterpret_cast<GSimpleAction*>(gobject_); }
99 
100   ///Provides access to the underlying C GObject.
gobj()101   const GSimpleAction* gobj() const { return reinterpret_cast<GSimpleAction*>(gobject_); }
102 
103   ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
104   GSimpleAction* gobj_copy();
105 
106 private:
107 
108 
109 protected:
110   /** Creates a new action.
111    *
112    * The created action is stateless.
113    *
114    * @param name The name of the action.
115    */
116   explicit SimpleAction(const Glib::ustring& name);
117 
118   /** Creates a new stateful action.
119    *
120    * @a state is the initial state of the action.  All future state values
121    * must have the same VariantType as the initial state.
122    *
123    * @param name The name of the action.
124    * @param state The initial state of the action.
125    */
126   SimpleAction(const Glib::ustring& name, const Glib::VariantBase& state);
127 
128 
129     explicit SimpleAction(const Glib::ustring& name, const Glib::VariantType& parameter_type);
130 
131 
132     explicit SimpleAction(const Glib::ustring& name, const Glib::VariantType& parameter_type, const Glib::VariantBase& state);
133 
134 
135 public:
136 
137 
138   static Glib::RefPtr<SimpleAction> create(const Glib::ustring& name);
139 
140 
141   /** Creates a new action.
142    *
143    * The created action is stateless. See g_simple_action_new_stateful() to create
144    * an action that has state.
145    *
146    * @newin{2,28}
147    *
148    * @param name The name of the action.
149    * @param parameter_type The type of parameter that will be passed to
150    * handlers for the SimpleAction::signal_activate() signal, or <tt>nullptr</tt> for no parameter.
151    * @return A new SimpleAction.
152    */
153 
154 
155   static Glib::RefPtr<SimpleAction> create(const Glib::ustring& name, const Glib::VariantType& parameter_type);
156 
157 
158   //TODO: Add a templated version of this to avoid the need fo Gio::Variant by the caller.
159 
160   /** Creates a new stateful action.
161    *
162    * All future state values must have the same VariantType as the initial
163    *  @a state.
164    *
165    * If the @a state Variant is floating, it is consumed.
166    *
167    * @newin{2,28}
168    *
169    * @param name The name of the action.
170    * @param parameter_type The type of the parameter that will be passed to
171    * handlers for the SimpleAction::signal_activate() signal, or <tt>nullptr</tt> for no parameter.
172    * @param state The initial state of the action.
173    * @return A new SimpleAction.
174    */
175 
176 
177   static Glib::RefPtr<SimpleAction> create(const Glib::ustring& name, const Glib::VariantType& parameter_type, const Glib::VariantBase& state);
178 
179 
180   //TODO: Add a templated version of this to avoid the need fo Gio::Variant by the caller.
181   /** Creates a new stateful action.
182    *
183    * @a state is the initial state of the action.  All future state values
184    * must have the same VariantType as the initial state.
185    *
186    * @newin{2,38}
187    *
188    * @param name The name of the action.
189    * @param state The initial state of the action.
190    * @return A new SimpleAction.
191    */
192 
193   static Glib::RefPtr<SimpleAction> create(const Glib::ustring& name, const Glib::VariantBase& state);
194 
195 
196   //TODO: Use similar C API if they ever add it. Doing this manually is tedious. See https://bugzilla.gnome.org/show_bug.cgi?id=705655
197   //TODO: Create a derived SimpleToggleAction class for this?
198   //TODO: Document how the app must handle signal_activate() to call change_state().
199   /** Creates a new boolean stateful action.
200    *
201    * @a state is the initial state of the action.  All future state values
202    * must also be bool.
203    *
204    * @newin{2,38}
205    *
206    * @param name The name of the action.
207    * @param state The initial state of the action.
208    * @return A new SimpleAction.
209    */
210   static Glib::RefPtr<SimpleAction> create_bool(const Glib::ustring&name, bool state = false);
211 
212   //TODO: Use similar C API if they ever add it. Doing this manually is tedious. See https://bugzilla.gnome.org/show_bug.cgi?id=705655
213   //TODO: Create a derived SimpleToggleAction class for this?
214   //TODO: Create convenience API that auto-changes the state, like Gtk::TreeView's append_column_editable()?
215   //  See https://bugzilla.gnome.org/show_bug.cgi?id=705133 (it's not documented clearly at all).
216   //TODO: Check whether glib now has API to use enums for this: See https://bugzilla.gnome.org/show_bug.cgi?id=705483
217   //TODO: Suggest other API that could be used to activate or discover the currently-select radio value.
218   /** Creates a new radio action with a string-based target value.
219    *
220    * @newin{2,38}
221    *
222    * @param name The name of the action.
223    * @param initial_state The initial state of the action.
224    * @return A new SimpleAction.
225    */
226   static Glib::RefPtr<SimpleAction> create_radio_string(const Glib::ustring& name, const Glib::ustring& initial_state);
227 
228   //TODO: Use similar C API if they ever add it. Doing this manually is tedious. See https://bugzilla.gnome.org/show_bug.cgi?id=705655
229   //TODO: Create a derived SimpleToggleAction class for this?
230   //TODO: Create convenience API that auto-changes the state, like Gtk::TreeView's append_column_editable()?
231   //  See https://bugzilla.gnome.org/show_bug.cgi?id=705133 (it's not documented clearly at all).
232   //TODO: Check whether glib now has API to use enums for this: See https://bugzilla.gnome.org/show_bug.cgi?id=705483
233   //TODO: Suggest other API that could be used to activate or discover the currently-select radio value.
234   //TODO: Check that the need for type="i" in the XML is documented: See https://bugzilla.gnome.org/show_bug.cgi?id=704392#c14
235   /** Creates a new radio action with an integer-based target value.
236    *
237    * @newin{2,38}
238    *
239    * @param name The name of the action.
240    * @param initial_state The initial state of the action.
241    * @return A new SimpleAction.
242    */
243   static Glib::RefPtr<SimpleAction> create_radio_integer(const Glib::ustring& name, gint32 initial_state);
244 
245 
246   /** Sets the action as enabled or not.
247    *
248    * An action must be enabled in order to be activated or in order to
249    * have its state changed from outside callers.
250    *
251    * This should only be called by the implementor of the action.  Users
252    * of the action should not attempt to modify its enabled flag.
253    *
254    * @newin{2,28}
255    *
256    * @param enabled Whether the action is enabled.
257    */
258   void set_enabled(bool enabled =  true);
259 
260   //TODO: Add templated version of this, renaming this to set_state_variant(), like Action::change_state()?
261 
262   /** Sets the state of the action.
263    *
264    * This directly updates the 'state' property to the given value.
265    *
266    * This should only be called by the implementor of the action.  Users
267    * of the action should not attempt to directly modify the 'state'
268    * property.  Instead, they should call g_action_change_state() to
269    * request the change.
270    *
271    * If the @a value GVariant is floating, it is consumed.
272    *
273    * @newin{2,30}
274    *
275    * @param value The new Variant for the state.
276    */
277   void set_state(const Glib::VariantBase& value);
278 
279 
280   /** Sets the state hint for the action.
281    *
282    * See g_action_get_state_hint() for more information about
283    * action state hints.
284    *
285    * @newin{2,44}
286    *
287    * @param state_hint A Variant representing the state hint.
288    */
289   void set_state_hint(const Glib::VariantBase& state_hint);
290 
291   /** If @a action is currently enabled.
292    *
293    * If the action is disabled then calls to g_action_activate() and
294    * g_action_change_state() have no effect.
295    *
296    * @newin{2,28}
297    *
298    * Default value: <tt>true</tt>
299    *
300    * @return A PropertyProxy that allows you to get or set the value of the property,
301    * or receive notification when the value of the property changes.
302    */
303   Glib::PropertyProxy< bool > property_enabled() ;
304 
305 /** If @a action is currently enabled.
306    *
307    * If the action is disabled then calls to g_action_activate() and
308    * g_action_change_state() have no effect.
309    *
310    * @newin{2,28}
311    *
312    * Default value: <tt>true</tt>
313    *
314    * @return A PropertyProxy_ReadOnly that allows you to get the value of the property,
315    * or receive notification when the value of the property changes.
316    */
317   Glib::PropertyProxy_ReadOnly< bool > property_enabled() const;
318 
319   /** The name of the action. This is mostly meaningful for identifying
320    * the action once it has been added to a SimpleActionGroup.
321    *
322    * @newin{2,28}
323    *
324    * Default value: ""
325    *
326    * @return A PropertyProxy_ReadOnly that allows you to get the value of the property,
327    * or receive notification when the value of the property changes.
328    */
329   Glib::PropertyProxy_ReadOnly< Glib::ustring > property_name() const;
330 
331 
332   /** The type of the parameter that must be given when activating the
333    * action.
334    *
335    * @newin{2,28}
336    *
337    * @return A PropertyProxy_ReadOnly that allows you to get the value of the property,
338    * or receive notification when the value of the property changes.
339    */
340   Glib::PropertyProxy_ReadOnly< Glib::VariantType > property_parameter_type() const;
341 
342 
343   /** The state of the action, or <tt>nullptr</tt> if the action is stateless.
344    *
345    * @newin{2,28}
346    *
347    * @return A PropertyProxy that allows you to get or set the value of the property,
348    * or receive notification when the value of the property changes.
349    */
350   Glib::PropertyProxy< Glib::VariantBase > property_state() ;
351 
352 /** The state of the action, or <tt>nullptr</tt> if the action is stateless.
353    *
354    * @newin{2,28}
355    *
356    * @return A PropertyProxy_ReadOnly that allows you to get the value of the property,
357    * or receive notification when the value of the property changes.
358    */
359   Glib::PropertyProxy_ReadOnly< Glib::VariantBase > property_state() const;
360 
361   /** The VariantType of the state that the action has, or <tt>nullptr</tt> if the
362    * action is stateless.
363    *
364    * @newin{2,28}
365    *
366    * @return A PropertyProxy_ReadOnly that allows you to get the value of the property,
367    * or receive notification when the value of the property changes.
368    */
369   Glib::PropertyProxy_ReadOnly< Glib::VariantType > property_state_type() const;
370 
371 
372   /**
373    * @par Slot Prototype:
374    * <tt>void on_my_%activate(const Glib::VariantBase& parameter)</tt>
375    *
376    * Flags: Run Last, Must Collect
377    *
378    * Indicates that the action was just activated.
379    *
380    *  @a parameter will always be of the expected type, i.e. the parameter type
381    * specified when the action was created. If an incorrect type is given when
382    * activating the action, this signal is not emitted.
383    *
384    * Since GLib 2.40, if no handler is connected to this signal then the
385    * default behaviour for boolean-stated actions with a <tt>nullptr</tt> parameter
386    * type is to toggle them via the SimpleAction::signal_change_state() signal.
387    * For stateful actions where the state type is equal to the parameter
388    * type, the default is to forward them directly to
389    * SimpleAction::signal_change_state().  This should allow almost all users
390    * of SimpleAction to connect only one handler or the other.
391    *
392    * @newin{2,28}
393    *
394    * @param parameter The parameter to the activation, or <tt>nullptr</tt> if it has
395    * no parameter.
396    */
397 
398   Glib::SignalProxy< void,const Glib::VariantBase& > signal_activate();
399 
400 
401   /**
402    * @par Slot Prototype:
403    * <tt>void on_my_%change_state(const Glib::VariantBase& value)</tt>
404    *
405    * Flags: Run Last, Must Collect
406    *
407    * Indicates that the action just received a request to change its
408    * state.
409    *
410    *  @a value will always be of the correct state type, i.e. the type of the
411    * initial state passed to g_simple_action_new_stateful(). If an incorrect
412    * type is given when requesting to change the state, this signal is not
413    * emitted.
414    *
415    * If no handler is connected to this signal then the default
416    * behaviour is to call g_simple_action_set_state() to set the state
417    * to the requested value. If you connect a signal handler then no
418    * default action is taken. If the state should change then you must
419    * call g_simple_action_set_state() from the handler.
420    *
421    * An example of a 'change-state' handler:
422    *
423    * [C example ellipted]
424    *
425    * The handler need not set the state to the requested value.
426    * It could set it to any value at all, or take some other action.
427    *
428    * @newin{2,30}
429    *
430    * @param value The requested value for the state.
431    */
432 
433   Glib::SignalProxy< void,const Glib::VariantBase& > signal_change_state();
434 
435 
436 public:
437 
438 public:
439   //C++ methods used to invoke GTK+ virtual functions:
440 
441 protected:
442   //GTK+ Virtual Functions (override these to change behaviour):
443 
444   //Default Signal Handlers::
445 
446 
447 };
448 
449 } // namespace Gio
450 
451 
452 namespace Glib
453 {
454   /** A Glib::wrap() method for this object.
455    *
456    * @param object The C instance.
457    * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
458    * @result A C++ instance that wraps this C instance.
459    *
460    * @relates Gio::SimpleAction
461    */
462   GIOMM_API
463   Glib::RefPtr<Gio::SimpleAction> wrap(GSimpleAction* object, bool take_copy = false);
464 }
465 
466 
467 #endif /* _GIOMM_SIMPLEACTION_H */
468 
469