[glibmm/glibmm-2-52] Gio::ActionMap: Improve declaration order/spacing



commit 5d6ef7483543be850e9f790aaf0e1d92c809a579
Author: Daniel Boles <dboles src gnome org>
Date:   Sat Dec 24 15:06:54 2016 +0000

    Gio::ActionMap: Improve declaration order/spacing
    
    This puts several things in more logical places and adds a couple of
    line breaks that make it easier to see the key sections in the header.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=774444

 gio/src/actionmap.ccg |   14 +++++++-------
 gio/src/actionmap.hg  |   43 +++++++++++++++++++++++--------------------
 2 files changed, 30 insertions(+), 27 deletions(-)
---
diff --git a/gio/src/actionmap.ccg b/gio/src/actionmap.ccg
index 054eee3..5598642 100644
--- a/gio/src/actionmap.ccg
+++ b/gio/src/actionmap.ccg
@@ -32,19 +32,19 @@ ActionMap::add_action(const Glib::ustring& name)
 }
 
 Glib::RefPtr<SimpleAction>
-ActionMap::add_action_with_parameter(
-  const Glib::ustring& name, const ActivateWithParameterSlot& slot, const Glib::VariantType& parameter_type)
+ActionMap::add_action(const Glib::ustring& name, const ActivateSlot& slot)
 {
-  auto action = SimpleAction::create(name, parameter_type);
-  action->signal_activate().connect(slot);
+  auto action = add_action(name);
+  action->signal_activate().connect(sigc::hide(slot));
   return action;
 }
 
 Glib::RefPtr<SimpleAction>
-ActionMap::add_action(const Glib::ustring& name, const ActivateSlot& slot)
+ActionMap::add_action_with_parameter(
+  const Glib::ustring& name, const ActivateWithParameterSlot& slot, const Glib::VariantType& parameter_type)
 {
-  auto action = add_action(name);
-  action->signal_activate().connect(sigc::hide(slot));
+  auto action = SimpleAction::create(name, parameter_type);
+  action->signal_activate().connect(slot);
   return action;
 }
 
diff --git a/gio/src/actionmap.hg b/gio/src/actionmap.hg
index e42d592..5222a0d 100644
--- a/gio/src/actionmap.hg
+++ b/gio/src/actionmap.hg
@@ -50,19 +50,16 @@ class ActionMap : public Glib::Interface
   _CLASS_INTERFACE(ActionMap, GActionMap, G_ACTION_MAP, GActionMapInterface)
 
 public:
+  _WRAP_METHOD(void add_action(const Glib::RefPtr<Action>& action), g_action_map_add_action)
+  _WRAP_METHOD(void remove_action(const Glib::ustring& action_name), g_action_map_remove_action)
+
   _WRAP_METHOD(Glib::RefPtr<Action> lookup_action(const Glib::ustring& action_name), 
g_action_map_lookup_action, refreturn)
   _WRAP_METHOD(Glib::RefPtr<const Action> lookup_action(const Glib::ustring& action_name) const, 
g_action_map_lookup_action, constversion, refreturn)
 
-  /** A Slot to be called when an action has been activated,
-   * passing a parameter of a specified type.
-   * See add_action_with_parameter().
-   *
-   * For instance,
-   * void on_slot_activated(const Glib::VariantBase& parameter);
-   */
-  using ActivateWithParameterSlot = sigc::slot<void, const Glib::VariantBase&>;
+  // The various add_action() methods are our equivalent for g_action_map_add_action_entries().
+  _IGNORE(g_action_map_add_action_entries)
+
 
-  //This is an equivalent for g_action_map_add_action_entries().
   /** A convenience method for creating a SimpleAction instance
    * and adding it to the ActionMap.
    *
@@ -71,7 +68,15 @@ public:
    */
   Glib::RefPtr<SimpleAction> add_action(const Glib::ustring& name);
 
-  //This is an equivalent for g_action_map_add_action_entries().
+  /** A Slot to be called when an action has been activated,
+   * without passing a parameter to the slot.
+   * See add_action() and add_action_bool().
+   *
+   * For instance,
+   * void on_slot_activated();
+   */
+  using ActivateSlot = sigc::slot<void()>;
+
   /** A convenience method for creating a SimpleAction instance
    * and adding it to the ActionMap.
    *
@@ -79,17 +84,17 @@ public:
    * @param slot The callback method to be called when the action is activated.
    * @return The Action.
    */
-  Glib::RefPtr<SimpleAction> add_action_with_parameter(const Glib::ustring& name, const 
ActivateWithParameterSlot& slot, const Glib::VariantType& parameter_type);
-  _IGNORE(g_action_map_add_action_entries)
+  Glib::RefPtr<SimpleAction> add_action(const Glib::ustring& name, const ActivateSlot& slot);
+
 
   /** A Slot to be called when an action has been activated,
-   * without passing a parameter to the slot.
-   * See add_action() and add_action_bool().
+   * passing a parameter of a specified type.
+   * See add_action_with_parameter().
    *
    * For instance,
-   * void on_slot_activated();
+   * void on_slot_activated(const Glib::VariantBase& parameter);
    */
-  using ActivateSlot = sigc::slot<void>;
+  using ActivateWithParameterSlot = sigc::slot<void(const Glib::VariantBase&)>;
 
   /** A convenience method for creating a SimpleAction instance
    * and adding it to the ActionMap.
@@ -99,7 +104,7 @@ public:
    * @parameter_type The type of parameter to be passed to the slot.
    * @return The Action.
    */
-  Glib::RefPtr<SimpleAction> add_action(const Glib::ustring& name, const ActivateSlot& slot);
+  Glib::RefPtr<SimpleAction> add_action_with_parameter(const Glib::ustring& name, const 
ActivateWithParameterSlot& slot, const Glib::VariantType& parameter_type);
 
 
   /** A convenience method for creating a boolean-stateful SimpleAction instance
@@ -151,6 +156,7 @@ public:
    */
   Glib::RefPtr<SimpleAction> add_action_radio_string(const Glib::ustring& name, const 
ActivateWithStringParameterSlot& slot, const Glib::ustring& state);
 
+
 //TODO: Docs: Add hints about how to specify the various possible states in the GtkBuilder XML.
   /** A convenience method for creating an integer-based radio SimpleAction instance
    * and adding it to the ActionMap.
@@ -181,9 +187,6 @@ public:
   Glib::RefPtr<SimpleAction> add_action_radio_integer(const Glib::ustring& name, const 
ActivateWithIntParameterSlot& slot, gint32 state);
 
 
-  _WRAP_METHOD(void add_action(const Glib::RefPtr<Action>& action), g_action_map_add_action)
-  _WRAP_METHOD(void remove_action(const Glib::ustring& action_name), g_action_map_remove_action)
-
 #m4 _CONVERSION(`Glib::RefPtr<Action>', `GAction*', `Glib::unwrap($3)')
   _WRAP_VFUNC(Glib::RefPtr<Action> lookup_action(const Glib::ustring& name) const, "lookup_action", 
refreturn)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]