1 // Generated by gmmproc 2.64.2 -- DO NOT MODIFY!
2 #ifndef _GIOMM_ACTIONGROUP_H
3 #define _GIOMM_ACTIONGROUP_H
4
5 #include <giommconfig.h>
6
7
8 #include <glibmm/ustring.h>
9 #include <sigc++/sigc++.h>
10
11 /* Copyright (C) 2010 The giomm Development Team
12 *
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
25 */
26
27
28 #include <glibmm/interface.h>
29 #include <glibmm/varianttype.h>
30 #include <gio/gio.h> //To declare g_action_group_get_action_state_type().
31
32
33 #ifndef DOXYGEN_SHOULD_SKIP_THIS
34 typedef struct _GActionGroupInterface GActionGroupInterface;
35 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
36
37 #ifndef DOXYGEN_SHOULD_SKIP_THIS
38 using GActionGroup = struct _GActionGroup;
39 using GActionGroupClass = struct _GActionGroupClass;
40 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
41
42
43 #ifndef DOXYGEN_SHOULD_SKIP_THIS
44 namespace Gio
45 { class GIOMM_API ActionGroup_Class; } // namespace Gio
46 #endif // DOXYGEN_SHOULD_SKIP_THIS
47
48 namespace Glib
49 {
50
51 class GIOMM_API VariantBase;
52 class GIOMM_API VariantContainerBase;
53 class GIOMM_API VariantType;
54
55 }
56
57 namespace Gio
58 {
59
60 /** ActionGroup - a group of actions.
61 * ActionGroup represents a group of actions.
62 *
63 * Each action in the group has a unique name (which is a string). All method
64 * calls, except list_actions() take the name of an action as an argument.
65 *
66 * The GActionGroup API is meant to be the 'public' API to the action group.
67 * The calls here are exactly the interaction that 'external forces' (eg: UI,
68 * incoming D-Bus messages, etc.) are supposed to have with actions.
69 * 'Internal' APIs (ie: ones meant only to be accessed by the action group
70 * implementation) are found on subclasses. This is why you will find -- for
71 * example -- get_action_enabled() but not an equivalent @c set() call.
72 *
73 * Signals are emitted on the action group in response to state changes on
74 * individual actions.
75 */
76
77 class GIOMM_API ActionGroup : public Glib::Interface
78 {
79
80 #ifndef DOXYGEN_SHOULD_SKIP_THIS
81
82 public:
83 using CppObjectType = ActionGroup;
84 using CppClassType = ActionGroup_Class;
85 using BaseObjectType = GActionGroup;
86 using BaseClassType = GActionGroupInterface;
87
88 // noncopyable
89 ActionGroup(const ActionGroup&) = delete;
90 ActionGroup& operator=(const ActionGroup&) = delete;
91
92 private:
93 friend class ActionGroup_Class;
94 static CppClassType actiongroup_class_;
95
96 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
97 protected:
98 /**
99 * You should derive from this class to use it.
100 */
101 ActionGroup();
102
103 #ifndef DOXYGEN_SHOULD_SKIP_THIS
104 /** Called by constructors of derived classes. Provide the result of
105 * the Class init() function to ensure that it is properly
106 * initialized.
107 *
108 * @param interface_class The Class object for the derived type.
109 */
110 explicit ActionGroup(const Glib::Interface_Class& interface_class);
111
112 public:
113 // This is public so that C++ wrapper instances can be
114 // created for C instances of unwrapped types.
115 // For instance, if an unexpected C type implements the C interface.
116 explicit ActionGroup(GActionGroup* castitem);
117
118 protected:
119 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
120
121 public:
122
123 ActionGroup(ActionGroup&& src) noexcept;
124 ActionGroup& operator=(ActionGroup&& src) noexcept;
125
126 ~ActionGroup() noexcept override;
127
128 static void add_interface(GType gtype_implementer);
129
130 /** Get the GType for this class, for use with the underlying GObject type system.
131 */
132 static GType get_type() G_GNUC_CONST;
133
134 #ifndef DOXYGEN_SHOULD_SKIP_THIS
135 static GType get_base_type() G_GNUC_CONST;
136 #endif
137
138 ///Provides access to the underlying C GObject.
gobj()139 GActionGroup* gobj() { return reinterpret_cast<GActionGroup*>(gobject_); }
140
141 ///Provides access to the underlying C GObject.
gobj()142 const GActionGroup* gobj() const { return reinterpret_cast<GActionGroup*>(gobject_); }
143
144 private:
145
146
147 public:
148
149 /** Checks if the named action exists within @a action_group.
150 *
151 * @newin{2,28}
152 *
153 * @param action_name The name of the action to check for.
154 * @return Whether the named action exists.
155 */
156 bool has_action(const Glib::ustring& action_name) const;
157
158
159 /** Lists the actions contained within @a action_group.
160 *
161 * @newin{2,28}
162 *
163 * @return A <tt>nullptr</tt>-terminated array of the names of the
164 * actions in the group.
165 */
166 std::vector<Glib::ustring> list_actions() const;
167
168 //TODO: Add templated method, renaming this to query_action_variant).
169
170 /** Queries all aspects of the named action within an @a action_group.
171 *
172 * This function acquires the information available from
173 * g_action_group_has_action(), g_action_group_get_action_enabled(),
174 * g_action_group_get_action_parameter_type(),
175 * g_action_group_get_action_state_type(),
176 * g_action_group_get_action_state_hint() and
177 * g_action_group_get_action_state() with a single function call.
178 *
179 * This provides two main benefits.
180 *
181 * The first is the improvement in efficiency that comes with not having
182 * to perform repeated lookups of the action in order to discover
183 * different things about it. The second is that implementing
184 * ActionGroup can now be done by only overriding this one virtual
185 * function.
186 *
187 * The interface provides a default implementation of this function that
188 * calls the individual functions, as required, to fetch the
189 * information. The interface also provides default implementations of
190 * those functions that call this function. All implementations,
191 * therefore, must override either this function or all of the others.
192 *
193 * If the action exists, <tt>true</tt> is returned and any of the requested
194 * fields (as indicated by having a non-<tt>nullptr</tt> reference passed in) are
195 * filled. If the action doesn't exist, <tt>false</tt> is returned and the
196 * fields may or may not have been modified.
197 *
198 * @newin{2,32}
199 *
200 * @param action_name The name of an action in the group.
201 * @param enabled If the action is presently enabled.
202 * @param parameter_type The parameter type, or <tt>nullptr</tt> if none needed.
203 * @param state_type The state type, or <tt>nullptr</tt> if stateless.
204 * @param state_hint The state hint, or <tt>nullptr</tt> if none.
205 * @param state The current state, or <tt>nullptr</tt> if stateless.
206 * @return <tt>true</tt> if the action exists, else <tt>false</tt>.
207 */
208 bool query_action(const Glib::ustring& action_name, bool& enabled, Glib::VariantType& parameter_type, Glib::VariantBase& state_hint, Glib::VariantType& state_type, Glib::VariantBase& state);
209
210 /// A query_action() convenience overload.
211 bool query_action(const Glib::ustring& action_name, bool& enabled, Glib::VariantType& parameter_type, Glib::VariantBase& state_hint, Glib::VariantType& state_type);
212
213 /// A query_action() convenience overload.
214 bool query_action(const Glib::ustring& action_name, bool& enabled, Glib::VariantType& parameter_type, Glib::VariantBase& state_hint, Glib::VariantBase& state);
215
216 /// A query_action() convenience overload.
217 bool query_action(const Glib::ustring& action_name, bool& enabled, Glib::VariantType& parameter_type, Glib::VariantBase& state_hint);
218
219 /// A query_action() convenience overload.
220 bool query_action(const Glib::ustring& action_name, bool& enabled, Glib::VariantBase& state_hint, Glib::VariantType& state_type, Glib::VariantBase& state);
221
222 /// A query_action() convenience overload.
223 bool query_action(const Glib::ustring& action_name, bool& enabled, Glib::VariantBase& state_hint, Glib::VariantType& state_type);
224
225 /// A query_action() convenience overload.
226 bool query_action(const Glib::ustring& action_name, bool& enabled, Glib::VariantBase& state_hint, Glib::VariantBase& state);
227
228 /// A query_action() convenience overload.
229 bool query_action(const Glib::ustring& action_name, bool& enabled, Glib::VariantBase& state_hint);
230
231
232 /** Checks if the named action within @a action_group is currently enabled.
233 *
234 * An action must be enabled in order to be activated or in order to
235 * have its state changed from outside callers.
236 *
237 * @newin{2,28}
238 *
239 * @param action_name The name of the action to query.
240 * @return Whether or not the action is currently enabled.
241 */
242 bool get_action_enabled(const Glib::ustring& action_name) const;
243
244
245 /** Queries the type of the parameter that must be given when activating
246 * the named action within @a action_group.
247 *
248 * When activating the action using g_action_group_activate_action(),
249 * the Variant given to that function must be of the type returned
250 * by this function.
251 *
252 * In the case that this function returns <tt>nullptr</tt>, you must not give any
253 * Variant, but <tt>nullptr</tt> instead.
254 *
255 * The parameter type of a particular action will never change but it is
256 * possible for an action to be removed and for a new action to be added
257 * with the same name but a different parameter type.
258 *
259 * @newin{2,28}
260 *
261 * @param action_name The name of the action to query.
262 * @return The parameter type.
263 */
264 Glib::VariantType get_action_parameter_type(const Glib::ustring& action_name) const;
265
266 /** Queries the type of the state of the named action within
267 * @a action_group.
268 *
269 * If the action is stateful then this function returns the
270 * VariantType of the state. All calls to
271 * g_action_group_change_action_state() must give a Variant of this
272 * type and g_action_group_get_action_state() will return a Variant
273 * of the same type.
274 *
275 * If the action is not stateful then this function will return <tt>nullptr</tt>.
276 * In that case, g_action_group_get_action_state() will return <tt>nullptr</tt>
277 * and you must not call g_action_group_change_action_state().
278 *
279 * The state type of a particular action will never change but it is
280 * possible for an action to be removed and for a new action to be added
281 * with the same name but a different state type.
282 *
283 * @newin{2,28}
284 *
285 * @param action_name The name of the action to query.
286 * @return The state type, if the action is stateful.
287 */
288 Glib::VariantType get_action_state_type(const Glib::ustring& action_name) const;
289
290
291 #ifndef GIOMM_DISABLE_DEPRECATED
292
293 /** Requests a hint about the valid range of values for the state of the
294 * named action within @a action_group.
295 *
296 * If <tt>nullptr</tt> is returned it either means that the action is not stateful
297 * or that there is no hint about the valid range of values for the
298 * state of the action.
299 *
300 * If a Variant array is returned then each item in the array is a
301 * possible value for the state. If a Variant pair (ie: two-tuple) is
302 * returned then the tuple specifies the inclusive lower and upper bound
303 * of valid values for the state.
304 *
305 * In any case, the information is merely a hint. It may be possible to
306 * have a state value outside of the hinted range and setting a value
307 * within the range may fail.
308 *
309 * The return value (if non-<tt>nullptr</tt>) should be freed with
310 * Glib::variant_unref() when it is no longer required.
311 *
312 * @newin{2,28}
313 *
314 * @deprecated Use the get_action_state() method that takes an output parameter instead.
315 *
316 * @param action_name The name of the action to query.
317 * @return The state range hint.
318 */
319 Glib::VariantContainerBase get_action_state_hint(const Glib::ustring& action_name) const;
320 #endif // GIOMM_DISABLE_DEPRECATED
321
322
323 //TODO: How do we check for a nullptr Variant?
324 /**
325 * Requests a hint about the valid range of values for the state of the
326 * named action within the action group
327 *
328 * If a null Variant is returned it either means that the action is not stateful
329 * or that there is no hint about the valid range of values for the
330 * state of the action.
331 *
332 * If a ariant array is returned then each item in the array is a
333 * possible value for the state. If Variant pair (ie: two-tuple) is
334 * returned then the tuple specifies the inclusive lower and upper bound
335 * of valid values for the state.
336 *
337 * In any case, the information is merely a hint. It may be possible to
338 * have a state value outside of the hinted range and setting a value
339 * within the range may fail.
340 *
341 * @param action_name The name of the action to query.
342 * @param value This will be set to the state range hint.
343 */
344 template <typename T_Value>
345 void get_action_state_hint(const Glib::ustring& action_name, T_Value& value) const;
346
347
348 /** Requests a hint about the valid range of values for the state of the
349 * named action within @a action_group.
350 *
351 * If <tt>nullptr</tt> is returned it either means that the action is not stateful
352 * or that there is no hint about the valid range of values for the
353 * state of the action.
354 *
355 * If a Variant array is returned then each item in the array is a
356 * possible value for the state. If a Variant pair (ie: two-tuple) is
357 * returned then the tuple specifies the inclusive lower and upper bound
358 * of valid values for the state.
359 *
360 * In any case, the information is merely a hint. It may be possible to
361 * have a state value outside of the hinted range and setting a value
362 * within the range may fail.
363 *
364 * The return value (if non-<tt>nullptr</tt>) should be freed with
365 * Glib::variant_unref() when it is no longer required.
366 *
367 * @newin{2,28}
368 *
369 * @param action_name The name of the action to query.
370 * @return The state range hint.
371 */
372 Glib::VariantContainerBase get_action_state_hint_variant(const Glib::ustring& action_name) const;
373
374
375 #ifndef GIOMM_DISABLE_DEPRECATED
376
377 /** Queries the current state of the named action within @a action_group.
378 *
379 * If the action is not stateful then <tt>nullptr</tt> will be returned. If the
380 * action is stateful then the type of the return value is the type
381 * given by g_action_group_get_action_state_type().
382 *
383 * The return value (if non-<tt>nullptr</tt>) should be freed with
384 * Glib::variant_unref() when it is no longer required.
385 *
386 * @newin{2,28}
387 *
388 * @deprecated Use the get_action_state() method that takes an output parameter instead.
389 *
390 * @param action_name The name of the action to query.
391 * @return The current state of the action.
392 */
393 Glib::VariantBase get_action_state(const Glib::ustring& action_name) const;
394 #endif // GIOMM_DISABLE_DEPRECATED
395
396
397 //TODO: How do we check for a nullptr Variant?
398 /** Queries the current state of the named action within the action group.
399 *
400 * If the action is not stateful then a null Variant will be returned. If the
401 * action is stateful then the type of the return value is the type
402 * given by get_action_state_type().
403 *
404 * @param action_name The name of the action to query.
405 * @param value This will be set to the current state of the action.
406 */
407 template <typename T_Value>
408 void get_action_state(const Glib::ustring& action_name, T_Value& value) const;
409
410
411 /** Queries the current state of the named action within @a action_group.
412 *
413 * If the action is not stateful then <tt>nullptr</tt> will be returned. If the
414 * action is stateful then the type of the return value is the type
415 * given by g_action_group_get_action_state_type().
416 *
417 * The return value (if non-<tt>nullptr</tt>) should be freed with
418 * Glib::variant_unref() when it is no longer required.
419 *
420 * @newin{2,28}
421 *
422 * @param action_name The name of the action to query.
423 * @return The current state of the action.
424 */
425 Glib::VariantBase get_action_state_variant(const Glib::ustring& action_name) const;
426
427 //TODO: Add templated method, renaming this to change_action_state_variant().
428
429 /** Request for the state of the named action within @a action_group to be
430 * changed to @a value.
431 *
432 * The action must be stateful and @a value must be of the correct type.
433 * See g_action_group_get_action_state_type().
434 *
435 * This call merely requests a change. The action may refuse to change
436 * its state or may change its state to something other than @a value.
437 * See g_action_group_get_action_state_hint().
438 *
439 * If the @a value GVariant is floating, it is consumed.
440 *
441 * @newin{2,28}
442 *
443 * @param action_name The name of the action to request the change on.
444 * @param value The new state.
445 */
446 void change_action_state(const Glib::ustring& action_name, const Glib::VariantBase& value);
447
448 //TODO: Add templated method, renaming this to activate_action_variant().
449
450 /** Activate the named action within @a action_group.
451 *
452 * If the action is expecting a parameter, then the correct type of
453 * parameter must be given as @a parameter. If the action is expecting no
454 * parameters then @a parameter must be <tt>nullptr</tt>. See
455 * g_action_group_get_action_parameter_type().
456 *
457 * @newin{2,28}
458 *
459 * @param action_name The name of the action to activate.
460 * @param parameter Parameters to the activation.
461 */
462 void activate_action(const Glib::ustring& action_name, const Glib::VariantBase& parameter);
463
464 /// A activate_action() convenience overload.
465 void activate_action(const Glib::ustring& action_name);
466
467
468 /** Emits the ActionGroup::signal_action_added() signal on @a action_group.
469 *
470 * This function should only be called by ActionGroup implementations.
471 *
472 * @newin{2,28}
473 *
474 * @param action_name The name of an action in the group.
475 */
476 void action_added(const Glib::ustring& action_name);
477
478 /** Emits the ActionGroup::signal_action_removed() signal on @a action_group.
479 *
480 * This function should only be called by ActionGroup implementations.
481 *
482 * @newin{2,28}
483 *
484 * @param action_name The name of an action in the group.
485 */
486 void action_removed(const Glib::ustring& action_name);
487
488 /** Emits the ActionGroup::signal_action_enabled_changed() signal on @a action_group.
489 *
490 * This function should only be called by ActionGroup implementations.
491 *
492 * @newin{2,28}
493 *
494 * @param action_name The name of an action in the group.
495 * @param enabled Whether or not the action is now enabled.
496 */
497 void action_enabled_changed(const Glib::ustring& action_name, bool enabled);
498
499 //TODO: Add templated method, renaming this to action_state_changed_variant).
500
501 /** Emits the ActionGroup::signal_action_state_changed() signal on @a action_group.
502 *
503 * This function should only be called by ActionGroup implementations.
504 *
505 * @newin{2,28}
506 *
507 * @param action_name The name of an action in the group.
508 * @param state The new state of the named action.
509 */
510 void action_state_changed(const Glib::ustring& action_name, const Glib::VariantBase& state);
511
512 //TODO: Remove two_signal_methods when we can break ABI.
513
514 /**
515 * @par Slot Prototype:
516 * <tt>void on_my_%action_added(const Glib::ustring& action_name)</tt>
517 *
518 * Flags: Run Last
519 *
520 * Signals that a new action was just added to the group.
521 * This signal is emitted after the action has been added
522 * and is now visible.
523 *
524 * @newin{2,28}
525 *
526 * @param action_name The name of the action in @a action_group.
527 */
528
529 Glib::SignalProxy< void,const Glib::ustring& > signal_action_added();
530
531 /**
532 * @par Slot Prototype:
533 * <tt>void on_my_%action_added(const Glib::ustring& action_name)</tt>
534 *
535 * Flags: Run Last
536 *
537 * Signals that a new action was just added to the group.
538 * This signal is emitted after the action has been added
539 * and is now visible.
540 *
541 * @newin{2,28}
542 *
543 * @param action_name The name of the action in @a action_group.
544 */
545
546 Glib::SignalProxyDetailedAnyType< void,const Glib::ustring& > signal_action_added(const Glib::ustring& action_name);
547
548
549 /**
550 * @par Slot Prototype:
551 * <tt>void on_my_%action_enabled_changed(const Glib::ustring& action_name, bool enabled)</tt>
552 *
553 * Flags: Run Last
554 *
555 * Signals that the enabled status of the named action has changed.
556 *
557 * @newin{2,28}
558 *
559 * @param action_name The name of the action in @a action_group.
560 * @param enabled Whether the action is enabled or not.
561 */
562
563 Glib::SignalProxy< void,const Glib::ustring&,bool > signal_action_enabled_changed();
564
565 /**
566 * @par Slot Prototype:
567 * <tt>void on_my_%action_enabled_changed(const Glib::ustring& action_name, bool enabled)</tt>
568 *
569 * Flags: Run Last
570 *
571 * Signals that the enabled status of the named action has changed.
572 *
573 * @newin{2,28}
574 *
575 * @param action_name The name of the action in @a action_group.
576 * @param enabled Whether the action is enabled or not.
577 */
578
579 Glib::SignalProxyDetailedAnyType< void,const Glib::ustring&,bool > signal_action_enabled_changed(const Glib::ustring& action_name);
580
581
582 /**
583 * @par Slot Prototype:
584 * <tt>void on_my_%action_removed(const Glib::ustring& action_name)</tt>
585 *
586 * Flags: Run Last
587 *
588 * Signals that an action is just about to be removed from the group.
589 * This signal is emitted before the action is removed, so the action
590 * is still visible and can be queried from the signal handler.
591 *
592 * @newin{2,28}
593 *
594 * @param action_name The name of the action in @a action_group.
595 */
596
597 Glib::SignalProxy< void,const Glib::ustring& > signal_action_removed();
598
599 /**
600 * @par Slot Prototype:
601 * <tt>void on_my_%action_removed(const Glib::ustring& action_name)</tt>
602 *
603 * Flags: Run Last
604 *
605 * Signals that an action is just about to be removed from the group.
606 * This signal is emitted before the action is removed, so the action
607 * is still visible and can be queried from the signal handler.
608 *
609 * @newin{2,28}
610 *
611 * @param action_name The name of the action in @a action_group.
612 */
613
614 Glib::SignalProxyDetailedAnyType< void,const Glib::ustring& > signal_action_removed(const Glib::ustring& action_name);
615
616
617 /**
618 * @par Slot Prototype:
619 * <tt>void on_my_%action_state_changed(const Glib::ustring& action_name, const Glib::VariantBase& value)</tt>
620 *
621 * Flags: Run Last, Must Collect
622 *
623 * Signals that the state of the named action has changed.
624 *
625 * @newin{2,28}
626 *
627 * @param action_name The name of the action in @a action_group.
628 * @param value The new value of the state.
629 */
630
631 Glib::SignalProxy< void,const Glib::ustring&,const Glib::VariantBase& > signal_action_state_changed();
632
633 /**
634 * @par Slot Prototype:
635 * <tt>void on_my_%action_state_changed(const Glib::ustring& action_name, const Glib::VariantBase& value)</tt>
636 *
637 * Flags: Run Last, Must Collect
638 *
639 * Signals that the state of the named action has changed.
640 *
641 * @newin{2,28}
642 *
643 * @param action_name The name of the action in @a action_group.
644 * @param value The new value of the state.
645 */
646
647 Glib::SignalProxyDetailedAnyType< void,const Glib::ustring&,const Glib::VariantBase& > signal_action_state_changed(const Glib::ustring& action_name);
648
649
650 virtual bool has_action_vfunc(const Glib::ustring& name) const;
651
652
653 virtual std::vector<Glib::ustring> list_actions_vfunc() const;
654
655
656 virtual bool get_action_enabled_vfunc(const Glib::ustring& name) const;
657
658
659 virtual Glib::VariantType get_action_parameter_type_vfunc(const Glib::ustring& name) const;
660
661 virtual Glib::VariantType get_action_state_type_vfunc(const Glib::ustring& name) const;
662
663
664 virtual Glib::VariantBase get_action_state_hint_vfunc(const Glib::ustring& name) const;
665
666 virtual Glib::VariantBase get_action_state_vfunc(const Glib::ustring& name) const;
667
668
669 virtual void change_action_state_vfunc(const Glib::ustring& name, const Glib::VariantBase& value);
670
671 virtual void activate_action_vfunc(const Glib::ustring& name, const Glib::VariantBase& parameter);
672
673
674 public:
675
676 public:
677 //C++ methods used to invoke GTK+ virtual functions:
678
679 protected:
680 //GTK+ Virtual Functions (override these to change behaviour):
681
682 //Default Signal Handlers::
683 /// This is a default handler for the signal signal_action_added().
684 virtual void on_action_added(const Glib::ustring& action_name);
685 /// This is a default handler for the signal signal_action_enabled_changed().
686 virtual void on_action_enabled_changed(const Glib::ustring& action_name, bool enabled);
687 /// This is a default handler for the signal signal_action_removed().
688 virtual void on_action_removed(const Glib::ustring& action_name);
689 /// This is a default handler for the signal signal_action_state_changed().
690 virtual void on_action_state_changed(const Glib::ustring& action_name, const Glib::VariantBase& value);
691
692
693 };
694
695 template <typename T_Value>
get_action_state(const Glib::ustring & action_name,T_Value & value)696 void ActionGroup::get_action_state(const Glib::ustring& action_name, T_Value& value) const
697 {
698 value = T_Value(); //Make sure that it is initialized.
699
700 using type_glib_variant = Glib::Variant<T_Value>;
701
702 g_return_if_fail(
703 g_variant_type_equal(g_action_group_get_action_state_type(const_cast<GActionGroup*>(gobj()), action_name.c_str()), type_glib_variant::variant_type().gobj()));
704
705 const auto variantBase = get_action_state_variant(action_name);
706
707 //TODO: Add a bool return instead of letting a std::bad_cast from the cast_dynamic() be thrown up to the caller?
708 const auto variantDerived = variantBase.cast_dynamic<type_glib_variant>(variantBase);
709 value = variantDerived.get();
710 }
711
712 template <typename T_Value>
get_action_state_hint(const Glib::ustring & action_name,T_Value & value)713 void ActionGroup::get_action_state_hint(const Glib::ustring& action_name, T_Value& value) const
714 {
715 value = T_Value(); //Make sure that it is initialized.
716
717 using type_glib_variant = Glib::Variant<T_Value>;
718
719 const auto variantBase = get_action_state_hint_variant(action_name);
720
721 // We can't check the type (a range) that will be returned before getting the range hint.
722 g_return_if_fail(
723 variantBase.is_of_type(type_glib_variant::variant_type()) );
724
725 const auto variantDerived = variantBase.cast_dynamic<type_glib_variant>(variantBase);
726 value = variantDerived.get();
727 }
728
729 } // namespace Gio
730
731
732 namespace Glib
733 {
734 /** A Glib::wrap() method for this object.
735 *
736 * @param object The C instance.
737 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
738 * @result A C++ instance that wraps this C instance.
739 *
740 * @relates Gio::ActionGroup
741 */
742 GIOMM_API
743 Glib::RefPtr<Gio::ActionGroup> wrap(GActionGroup* object, bool take_copy = false);
744
745 } // namespace Glib
746
747
748 #endif /* _GIOMM_ACTIONGROUP_H */
749
750