[glibmm] Gio::ActionMap: Improve declaration order/spacing
- From: Daniel Boles <dboles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Gio::ActionMap: Improve declaration order/spacing
- Date: Mon, 26 Dec 2016 16:07:48 +0000 (UTC)
commit 22b2ecabf9c2d0c1f59f05e53f0ceef053b14103
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 | 44 ++++++++++++++++++++++++--------------------
2 files changed, 31 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 e233620..9200cce 100644
--- a/gio/src/actionmap.hg
+++ b/gio/src/actionmap.hg
@@ -46,19 +46,17 @@ 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&)>;
- //This is an equivalent for g_action_map_add_action_entries().
+ // The various add_action() methods are our equivalent for g_action_map_add_action_entries().
+ _IGNORE(g_action_map_add_action_entries)
+
+
/** A convenience method for creating a SimpleAction instance
* and adding it to the ActionMap.
*
@@ -67,7 +65,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.
*
@@ -75,17 +81,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.
@@ -95,7 +101,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
@@ -147,6 +153,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.
@@ -177,9 +184,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]