"Fossies" - the Fresh Open Source Software Archive

Member "glibmm-2.74.0/untracked/gio/giomm/actionmap.h" (19 Sep 2022, 11187 Bytes) of package /linux/misc/glibmm-2.74.0.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "actionmap.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes reports: 2.73.2_vs_2.74.0 or 2.72.1_vs_2.74.0.

    1 // Generated by gmmproc 2.74.0 -- DO NOT MODIFY!
    2 #ifndef _GIOMM_ACTIONMAP_H
    3 #define _GIOMM_ACTIONMAP_H
    4 
    5 
    6 #include <glibmm/ustring.h>
    7 #include <sigc++/sigc++.h>
    8 
    9 /* Copyright (C) 2012 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/interface.h>
   26 #include <giomm/simpleaction.h>
   27 
   28 
   29 #ifndef DOXYGEN_SHOULD_SKIP_THIS
   30 typedef struct _GActionMapInterface GActionMapInterface;
   31 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
   32 
   33 #ifndef DOXYGEN_SHOULD_SKIP_THIS
   34 using GActionMap = struct _GActionMap;
   35 using GActionMapClass = struct _GActionMapClass;
   36 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
   37 
   38 
   39 #ifndef DOXYGEN_SHOULD_SKIP_THIS
   40 namespace Gio
   41 { class GIOMM_API ActionMap_Class; } // namespace Gio
   42 #endif // DOXYGEN_SHOULD_SKIP_THIS
   43 
   44 namespace Gio
   45 {
   46 
   47 class GIOMM_API Action;
   48 
   49 /** ActionMap - Interface for action containers.
   50  * The ActionMap interface is implemented by ActionGroup implementations that
   51  * operate by containing a number of named Action instances, such as
   52  * SimpleActionGroup.
   53  *
   54  * One useful application of this interface is to map the names of actions from
   55  * various action groups to unique, prefixed names (e.g. by prepending "app."
   56  * or "win."). This is the motivation for the 'Map' part of the interface name.
   57  * @newin{2,32}
   58  */
   59 
   60 class GIOMM_API ActionMap : public Glib::Interface
   61 {
   62   
   63 #ifndef DOXYGEN_SHOULD_SKIP_THIS
   64 
   65 public:
   66   using CppObjectType = ActionMap;
   67   using CppClassType = ActionMap_Class;
   68   using BaseObjectType = GActionMap;
   69   using BaseClassType = GActionMapInterface;
   70 
   71   // noncopyable
   72   ActionMap(const ActionMap&) = delete;
   73   ActionMap& operator=(const ActionMap&) = delete;
   74 
   75 private:
   76   friend class ActionMap_Class;
   77   static CppClassType actionmap_class_;
   78 
   79 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
   80 protected:
   81   /**
   82    * You should derive from this class to use it.
   83    */
   84   ActionMap();
   85 
   86 #ifndef DOXYGEN_SHOULD_SKIP_THIS
   87   /** Called by constructors of derived classes. Provide the result of
   88    * the Class init() function to ensure that it is properly
   89    * initialized.
   90    *
   91    * @param interface_class The Class object for the derived type.
   92    */
   93   explicit ActionMap(const Glib::Interface_Class& interface_class);
   94 
   95 public:
   96   // This is public so that C++ wrapper instances can be
   97   // created for C instances of unwrapped types.
   98   // For instance, if an unexpected C type implements the C interface.
   99   explicit ActionMap(GActionMap* castitem);
  100 
  101 protected:
  102 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
  103 
  104 public:
  105 
  106   ActionMap(ActionMap&& src) noexcept;
  107   ActionMap& operator=(ActionMap&& src) noexcept;
  108 
  109   ~ActionMap() noexcept override;
  110 
  111   static void add_interface(GType gtype_implementer);
  112 
  113   /** Get the GType for this class, for use with the underlying GObject type system.
  114    */
  115   static GType get_type()      G_GNUC_CONST;
  116 
  117 #ifndef DOXYGEN_SHOULD_SKIP_THIS
  118   static GType get_base_type() G_GNUC_CONST;
  119 #endif
  120 
  121   ///Provides access to the underlying C GObject.
  122   GActionMap*       gobj()       { return reinterpret_cast<GActionMap*>(gobject_); }
  123 
  124   ///Provides access to the underlying C GObject.
  125   const GActionMap* gobj() const { return reinterpret_cast<GActionMap*>(gobject_); }
  126 
  127 private:
  128 
  129 
  130   // The various add_action...() methods are our equivalent for g_action_map_add_action_entries().
  131   
  132 
  133 public:
  134   
  135   /** Adds an action to the @a action_map.
  136    * 
  137    * If the action map already contains an action with the same name
  138    * as @a action then the old action is dropped from the action map.
  139    * 
  140    * The action map takes its own reference on @a action.
  141    * 
  142    * @newin{2,32}
  143    * 
  144    * @param action A Action.
  145    */
  146   void add_action(const Glib::RefPtr<Action>& action);
  147   
  148   /** Removes the named action from the action map.
  149    * 
  150    * If no action of this name is in the map then nothing happens.
  151    * 
  152    * @newin{2,32}
  153    * 
  154    * @param action_name The name of the action.
  155    */
  156   void remove_action(const Glib::ustring& action_name);
  157 
  158   
  159   /** Looks up the action with the name @a action_name in @a action_map.
  160    * 
  161    * If no such action exists, returns <tt>nullptr</tt>.
  162    * 
  163    * @newin{2,32}
  164    * 
  165    * @param action_name The name of an action.
  166    * @return A Action, or <tt>nullptr</tt>.
  167    */
  168   Glib::RefPtr<Action> lookup_action(const Glib::ustring& action_name);
  169   
  170   /** Looks up the action with the name @a action_name in @a action_map.
  171    * 
  172    * If no such action exists, returns <tt>nullptr</tt>.
  173    * 
  174    * @newin{2,32}
  175    * 
  176    * @param action_name The name of an action.
  177    * @return A Action, or <tt>nullptr</tt>.
  178    */
  179   Glib::RefPtr<const Action> lookup_action(const Glib::ustring& action_name) const;
  180 
  181 
  182   /** A convenience method for creating a SimpleAction instance
  183    * and adding it to the ActionMap.
  184    *
  185    * @param name The name of the Action.
  186    * @return The Action.
  187    */
  188   Glib::RefPtr<SimpleAction> add_action(const Glib::ustring& name);
  189 
  190   /** A Slot to be called when an action has been activated,
  191    * without passing a parameter to the slot.
  192    * See add_action() and add_action_bool().
  193    *
  194    * For instance,
  195    * void on_slot_activated();
  196    */
  197   using ActivateSlot = sigc::slot<void()>;
  198 
  199   /** A convenience method for creating a SimpleAction instance
  200    * and adding it to the ActionMap.
  201    *
  202    * @param name The name of the Action.
  203    * @param slot The callback method to be called when the action is activated.
  204    * @return The Action.
  205    */
  206   Glib::RefPtr<SimpleAction> add_action(const Glib::ustring& name, const ActivateSlot& slot);
  207 
  208 
  209   /** A Slot to be called when an action has been activated,
  210    * passing a parameter of a specified type.
  211    * See add_action_with_parameter().
  212    *
  213    * For instance,
  214    * void on_slot_activated(const Glib::VariantBase& parameter);
  215    */
  216   using ActivateWithParameterSlot = sigc::slot<void(const Glib::VariantBase&)>;
  217 
  218   /** A convenience method for creating a SimpleAction instance, which when
  219    * activated will call a slot receiving a given type of parameter, and adding
  220    * that SimpleAction to the ActionMap.
  221    *
  222    * @param name The name of the Action.
  223    * @param parameter_type The type of parameter to be passed to the slot.
  224    * @param slot The callback method to be called when the action is activated.
  225    * @return The Action.
  226    */
  227   Glib::RefPtr<SimpleAction> add_action_with_parameter(const Glib::ustring& name, const Glib::VariantType& parameter_type, const ActivateWithParameterSlot& slot);
  228 
  229 
  230   /** A convenience method for creating a boolean-stateful SimpleAction instance
  231    * and adding it to the ActionMap.
  232    *
  233    * @param name The name of the Action.
  234    * @param state The initial state.
  235    * @return The Action.
  236    */
  237   Glib::RefPtr<SimpleAction> add_action_bool(const Glib::ustring& name, bool state = false);
  238 
  239   /** A convenience method for creating a boolean-stateful (toggle) SimpleAction instance
  240    * and adding it to the ActionMap.
  241    *
  242    * @param name The name of the Action.
  243    * @param slot The callback method to be called when the action is activated.
  244    * @param state The initial state.
  245    * @return The Action.
  246    */
  247   Glib::RefPtr<SimpleAction> add_action_bool(const Glib::ustring& name, const ActivateSlot& slot, bool state = false);
  248 
  249 
  250 //TODO: Docs: Add hints about how to specify the various possible states in the GtkBuilder XML.
  251   /** A convenience method for creating a string-based radio SimpleAction instance
  252    * and adding it to the ActionMap.
  253    *
  254    * @param name The name of the Action.
  255    * @param state The initial state.
  256    * @return The Action.
  257    */
  258   Glib::RefPtr<SimpleAction> add_action_radio_string(const Glib::ustring& name, const Glib::ustring& state);
  259 
  260   /** A Slot to be called when an action has been activated.
  261    * See add_action_radio_string().
  262    *
  263    * For instance,
  264    * void on_slot_activated(const Glib::ustring& parameter);
  265    */
  266   using ActivateWithStringParameterSlot = sigc::slot<void(const Glib::ustring&)>;
  267 
  268 //TODO: Docs: Add hints about how to specify the various possible states in the GtkBuilder XML.
  269   /** A convenience method for creating a string-based radio SimpleAction instance
  270    * and adding it to the ActionMap.
  271    *
  272    * @param name The name of the Action.
  273    * @param slot The callback method to be called when the action is activated.
  274    * @param state The initial state.
  275    * @return The Action.
  276    */
  277   Glib::RefPtr<SimpleAction> add_action_radio_string(const Glib::ustring& name, const ActivateWithStringParameterSlot& slot, const Glib::ustring& state);
  278 
  279 
  280 //TODO: Docs: Add hints about how to specify the various possible states in the GtkBuilder XML.
  281   /** A convenience method for creating an integer-based radio SimpleAction instance
  282    * and adding it to the ActionMap.
  283    *
  284    * @param name The name of the Action.
  285    * @param state The initial state.
  286    * @return The Action.
  287    */
  288   Glib::RefPtr<SimpleAction> add_action_radio_integer(const Glib::ustring& name, gint32 state);
  289 
  290   /** A Slot to be called when an action has been activated.
  291    * See add_action_radio_integer().
  292    *
  293    * For instance,
  294    * void on_slot_activated(int parameter);
  295    */
  296   using ActivateWithIntParameterSlot = sigc::slot<void(int)>;
  297   
  298 //TODO: Docs: Add hints about how to specify the various possible states in the GtkBuilder XML.
  299   /** A convenience method for creating an integer-based radio SimpleAction instance
  300    * and adding it to the ActionMap.
  301    *
  302    * @param name The name of the Action.
  303    * @param slot The callback method to be called when the action is activated.
  304    * @param state The initial state.
  305    * @return The Action.
  306    */
  307   Glib::RefPtr<SimpleAction> add_action_radio_integer(const Glib::ustring& name, const ActivateWithIntParameterSlot& slot, gint32 state);
  308 
  309 protected:
  310  
  311 
  312     virtual Glib::RefPtr<Action> lookup_action_vfunc(const Glib::ustring& name) const;
  313 
  314 
  315     virtual void add_action_vfunc(const Glib::RefPtr<Action>& action) const;
  316 
  317 
  318     virtual void remove_action_vfunc(const Glib::ustring& name);
  319 
  320 
  321 public:
  322 
  323 public:
  324   //C++ methods used to invoke GTK+ virtual functions:
  325 
  326 protected:
  327   //GTK+ Virtual Functions (override these to change behaviour):
  328 
  329   //Default Signal Handlers::
  330 
  331 
  332 };
  333 
  334 } // namespace Gio
  335 
  336 
  337 namespace Glib
  338 {
  339   /** A Glib::wrap() method for this object.
  340    *
  341    * @param object The C instance.
  342    * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
  343    * @result A C++ instance that wraps this C instance.
  344    *
  345    * @relates Gio::ActionMap
  346    */
  347   GIOMM_API
  348   Glib::RefPtr<Gio::ActionMap> wrap(GActionMap* object, bool take_copy = false);
  349 
  350 } // namespace Glib
  351 
  352 
  353 #endif /* _GIOMM_ACTIONMAP_H */
  354