+2.37.6 (unstable):
+
+
+Gio:
+* Action:
+ - Make get_state() templated.
+ (Murray Cumming)
+ - get_state_hint(): Correct a check.
+ (Murray Cumming)
+ - Add templated change_state() and activate().
+ (Murray Cumming)
+ - print_detailed_name() Make this templated.
+ (Murray Cumming)
+* ActionGroup: Add templated getters.
+ (Murray Cumming)
+* ActionMap: add_action_radio_*(): Use better Slot types.
+ (Murray Cumming)
+* SimpleAction:
+ - Make set_state() protected.
+ (Murray Cumming)
+ - add_action() now takes a slot with no parameter.
+ Added add_action_with_parameter().
+ (Murray Cumming)
+* SimpleActionGroup:
+ - lookup(): Add a const version and use refreturn.
+ (Murray Cumming)
+ - Deprecate all methods, because they just call methods in
+ the base ActionMap. The C functions are now deprecated too.
+ See glib bug #705600 .
+ (Murray Cumming)
+
+gmmproc:
+* Fix _WRAP_SIGNAL with 'ifdef' and 'deprecated'.
+ (Kjell Ahlstedt)
+
+
2.37.5 (unstable):
Glib
## You should have received a copy of the GNU Lesser General Public License
## along with this library. If not, see <http://www.gnu.org/licenses/>.
-AC_INIT([glibmm], [2.37.5],
+AC_INIT([glibmm], [2.37.6],
[http://bugzilla.gnome.org/enter_bug.cgi?product=glibmm],
[glibmm], [http://www.gtkmm.org/])
AC_PREREQ([2.59])
namespace Gio
{
-bool Action::get_state_bool() const
-{
- g_return_val_if_fail(
- g_variant_type_equal(g_action_get_state_type(const_cast<GAction*>(gobj())), G_VARIANT_TYPE_BOOLEAN),
- false);
-
- GVariant* state = g_action_get_state(const_cast<GAction*>(gobj()));
- g_return_val_if_fail(state, false);
- const bool result = g_variant_get_boolean(state);
- g_variant_unref(state);
- return result;
-}
-
-void Action::change_state(bool value)
-{
- g_return_if_fail(
- g_variant_type_equal(g_action_get_state_type(const_cast<GAction*>(gobj())), G_VARIANT_TYPE_BOOLEAN));
- change_state(Glib::Variant<bool>::create(value));
-}
-
} // namespace Gio
#include <glibmm/interface.h>
#include <glibmm/varianttype.h>
+#include <gio/gio.h>
_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/interface_p.h)
_WRAP_METHOD(Glib::ustring get_name() const, g_action_get_name)
_WRAP_METHOD(Glib::VariantType get_parameter_type() const, g_action_get_parameter_type)
_WRAP_METHOD(Glib::VariantType get_state_type() const, g_action_get_state_type)
- _WRAP_METHOD(Glib::VariantBase get_state_hint() const, g_action_get_state_hint)
- _WRAP_METHOD(bool get_enabled() const, g_action_get_enabled)
- _WRAP_METHOD(Glib::VariantBase get_state() const, g_action_get_state)
//TODO: Docs
- bool get_state_bool() const;
+ //TODO: Is there any specific type that can really be used with this? A std::list<>. We must test this.
+ // See also ActionGroup:::get_action_state_hint().
+ template <typename T_Value>
+ void get_state_hint(T_Value& value) const;
+
+ //TODO: When we can break ABI, Return a Glib::VariantContainerBase,
+ // as we already do for ActionGroup::get_action_state_hint(),
+ // because that is what this returns (to specify a range).
+ _WRAP_METHOD(Glib::VariantBase get_state_hint_variant() const, g_action_get_state_hint)
- _WRAP_METHOD(void change_state(const Glib::VariantBase& value), g_action_change_state)
+ _WRAP_METHOD(bool get_enabled() const, g_action_get_enabled)
/** Request for the state of @a action to be changed to @a value,
- * assuming that the state is boolean.
+ * assuming that the action has the expected state type.
*
- * See g_action_get_state_type().
+ * See get_state_type().
*
* This call merely requests a change. The action may refuse to change
* its state or may change its state to something other than @a value.
- * See g_action_get_state_hint().
+ * See get_state_hint().
*
* @newin{2,38}
* @param value The new state.
*/
- void change_state(bool value);
+ template <typename T_Value>
+ void change_state(const T_Value& value);
+
+ //This is just here to maintain API compatibility,
+ //by stopping the compiler from calling the
+ //regular change_state() with a Variant,
+ //if the application code previously called change_state(VariantBase).
+ template <typename T_Value>
+ void change_state(const Glib::Variant<T_Value>& value);
+
+ _WRAP_METHOD(void change_state_variant(const Glib::VariantBase& value), g_action_change_state)
+
+ _WRAP_METHOD(void change_state(const Glib::VariantBase& value), g_action_change_state, deprecated "Use the templated method instead, passing a normal C++ type.")
+
+ //TODO: Docs
+ template <typename T_Value>
+ void get_state(T_Value& value) const;
+
+ _WRAP_METHOD(Glib::VariantBase get_state_variant() const, g_action_get_state)
+
+ //TODO: Docs
+ template <typename T_Value>
+ void activate(const T_Value& parameter);
+
+ //This is just here to maintain API compatibility,
+ //by stopping the compiler from calling the
+ //regular change_state() with a Variant,
+ //if the application code previously called activate(VariantBase).
+ template <typename T_Value>
+ void activate(const Glib::Variant<T_Value>& parameter);
+
+ _WRAP_METHOD(void activate_variant(const Glib::VariantBase& parameter), g_action_activate)
- _WRAP_METHOD(void activate(const Glib::VariantBase& parameter), g_action_activate)
+ _WRAP_METHOD(void activate(const Glib::VariantBase& parameter), g_action_activate, deprecated "Use the templated method instead, passing a normal C++ type.")
_WRAP_METHOD(static bool name_is_valid(const Glib::ustring& action_name), g_action_name_is_valid )
//TODO: _WRAP_METHOD(static bool parse_detailed_name(const Glib::ustring& detailed_name, gchar** action_name, GVariant** target_value), g_action_parse_detailed_name, errthrow)
- _WRAP_METHOD(static Glib::ustring print_detailed_name(const Glib::ustring& action_name, const Glib::VariantBase& parameter), g_action_print_detailed_name)
+ //TODO: Docs.
+ template <typename T_Value>
+ Glib::ustring print_detailed_name(const Glib::ustring& action_name, const T_Value& value);
+
+ _WRAP_METHOD(static Glib::ustring print_detailed_name_variant(const Glib::ustring& action_name, const Glib::VariantBase& parameter), g_action_print_detailed_name)
_WRAP_PROPERTY("enabled", bool)
_WRAP_PROPERTY("name", Glib::ustring)
_WRAP_VFUNC(void activate(const Glib::VariantBase& parameter), "activate")
};
+template <typename T_Value>
+void Action::get_state(T_Value& value) const
+{
+ value = T_Value(); //Make sure that it is initialized.
+
+ typedef Glib::Variant<T_Value> type_glib_variant;
+
+ g_return_if_fail(
+ g_variant_type_equal(g_action_get_state_type(const_cast<GAction*>(gobj())), type_glib_variant::variant_type().gobj()));
+
+ const Glib::VariantBase variantBase = get_state_variant();
+ const type_glib_variant variantDerived = variantBase.cast_dynamic<type_glib_variant>(variantBase);
+ value = variantDerived.get();
+}
+
+template <typename T_Value>
+void Action::get_state_hint(T_Value& value) const
+{
+ value = T_Value(); //Make sure that it is initialized.
+
+ typedef Glib::Variant<T_Value> type_glib_variant;
+
+ const Glib::VariantBase variantBase = get_state_hint_variant();
+
+ // We can't check the type (a range) that will be returned before getting the range hint.
+ g_return_if_fail(
+ variantBase.is_of_type(type_glib_variant::variant_type()) );
+
+ const type_glib_variant variantDerived = variantBase.cast_dynamic<type_glib_variant>(variantBase);
+ value = variantDerived.get();
+}
+
+template <typename T_Value>
+Glib::ustring Action::print_detailed_name(const Glib::ustring& action_name, const T_Value& parameter)
+{
+ typedef Glib::Variant<T_Value> type_glib_variant;
+
+ g_return_val_if_fail(
+ g_variant_type_equal(g_action_get_parameter_type(const_cast<GAction*>(gobj())), type_glib_variant::variant_type().gobj()),
+ Glib::ustring());
+ return print_detailed_name_variant(type_glib_variant::create(parameter));
+}
+
+template <typename T_Value>
+void Action::change_state(const T_Value& value)
+{
+ typedef Glib::Variant<T_Value> type_glib_variant;
+
+ g_return_if_fail(
+ g_variant_type_equal(g_action_get_state_type(const_cast<GAction*>(gobj())), type_glib_variant::variant_type().gobj()));
+
+ change_state_variant(type_glib_variant::create(value));
+}
+
+template <typename T_Value>
+void Action::change_state(const Glib::Variant<T_Value>& value)
+{
+ change_state_variant(value);
+}
+
+template <typename T_Value>
+void Action::activate(const T_Value& parameter)
+{
+ typedef Glib::Variant<T_Value> type_glib_variant;
+
+ g_return_if_fail(
+ g_variant_type_equal(g_action_get_parameter_type(const_cast<GAction*>(gobj())), type_glib_variant::variant_type().gobj()));
+
+ activate_variant(type_glib_variant::create(parameter));
+}
+
+
+template <typename T_Value>
+void Action::activate(const Glib::Variant<T_Value>& value)
+{
+ activate(value);
+}
+
+
} // namespace Gio
#include <glibmm/interface.h>
#include <glibmm/varianttype.h>
+#include <gio/gio.h> //To declare g_action_group_get_action_state_type().
_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/interface_p.h)
#m4 _CONVERSION(`gchar**',`std::vector<Glib::ustring>',`Glib::ArrayHandler<Glib::ustring>::array_to_vector($3, Glib::OWNERSHIP_DEEP)')
_WRAP_METHOD(std::vector<Glib::ustring> list_actions() const, g_action_group_list_actions)
+ //TODO: Add templated method, renaming this to query_action_variant).
_WRAP_METHOD(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{.>>?}), g_action_group_query_action)
_WRAP_METHOD(bool get_action_enabled(const Glib::ustring& action_name) const, g_action_group_get_action_enabled)
_WRAP_METHOD(Glib::VariantType get_action_parameter_type(const Glib::ustring& action_name) const, g_action_group_get_action_parameter_type)
_WRAP_METHOD(Glib::VariantType get_action_state_type(const Glib::ustring& action_name) const, g_action_group_get_action_state_type)
- _WRAP_METHOD(Glib::VariantContainerBase get_action_state_hint(const Glib::ustring& action_name) const, g_action_group_get_action_state_hint)
- _WRAP_METHOD(Glib::VariantBase get_action_state(const Glib::ustring& action_name) const, g_action_group_get_action_state)
+ _WRAP_METHOD(Glib::VariantContainerBase get_action_state_hint(const Glib::ustring& action_name) const, g_action_group_get_action_state_hint, deprecated "Use the get_action_state() method that takes an output parameter instead.")
+
+ //TODO: Docs
+ template <typename T_Value>
+ void get_action_state_hint(const Glib::ustring& action_name, T_Value& value) const;
+
+ _WRAP_METHOD(Glib::VariantContainerBase get_action_state_hint_variant(const Glib::ustring& action_name) const, g_action_group_get_action_state_hint)
+
+
+ _WRAP_METHOD(Glib::VariantBase get_action_state(const Glib::ustring& action_name) const, g_action_group_get_action_state, deprecated "Use the get_action_state() method that takes an output parameter instead.")
+
+ //TODO: Docs
+ template <typename T_Value>
+ void get_action_state(const Glib::ustring& action_name, T_Value& value) const;
+
+ _WRAP_METHOD(Glib::VariantBase get_action_state_variant(const Glib::ustring& action_name) const, g_action_group_get_action_state)
+
+ //TODO: Add templated method, renaming this to change_action_state_variant().
_WRAP_METHOD(void change_action_state(const Glib::ustring& action_name, const Glib::VariantBase& value), g_action_group_change_action_state)
+
+ //TODO: Add templated method, renaming this to activate_action_variant().
_WRAP_METHOD(void activate_action(const Glib::ustring& action_name, const Glib::VariantBase& parameter), g_action_group_activate_action)
+
_WRAP_METHOD(void action_added(const Glib::ustring& action_name), g_action_group_action_added)
_WRAP_METHOD(void action_removed(const Glib::ustring& action_name), g_action_group_action_removed)
_WRAP_METHOD(void action_enabled_changed(const Glib::ustring& action_name, bool enabled), g_action_group_action_enabled_changed)
+
+ //TODO: Add templated method, renaming this to action_state_changed_variant).
_WRAP_METHOD(void action_state_changed (const Glib::ustring& action_name, const Glib::VariantBase& state), g_action_group_action_state_changed)
_WRAP_SIGNAL(void action_added(const Glib::ustring& action_name), "action-added")
_WRAP_VFUNC(void activate_action(const Glib::ustring& name, const Glib::VariantBase& parameter), "activate_action")
};
+template <typename T_Value>
+void ActionGroup::get_action_state(const Glib::ustring& action_name, T_Value& value) const
+{
+ value = T_Value(); //Make sure that it is initialized.
+
+ typedef Glib::Variant<T_Value> type_glib_variant;
+
+ g_return_if_fail(
+ 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()));
+
+ const Glib::VariantBase variantBase = get_action_state_variant(action_name);
+ const type_glib_variant variantDerived = variantBase.cast_dynamic<type_glib_variant>(variantBase);
+ value = variantDerived.get();
+}
+
+template <typename T_Value>
+void ActionGroup::get_action_state_hint(const Glib::ustring& action_name, T_Value& value) const
+{
+ value = T_Value(); //Make sure that it is initialized.
+
+ typedef Glib::Variant<T_Value> type_glib_variant;
+
+ g_return_if_fail(
+ g_variant_type_equal(g_action_get_state_type(const_cast<GAction*>(gobj())), type_glib_variant::variant_type().gobj()));
+
+ const Glib::VariantBase variantBase = get_action_state_hint_variant(action_name);
+
+ // We can't check the type (a range) that will be returned before getting the range hint.
+ g_return_if_fail(
+ variantBase.is_of_type(type_glib_variant::variant_type()) );
+
+ const type_glib_variant variantDerived = variantBase.cast_dynamic<type_glib_variant>(variantBase);
+ value = variantDerived.get();
+}
+
} // namespace Gio
return action;
}
-Glib::RefPtr<SimpleAction> ActionMap::add_action(const Glib::ustring& name, const ActivateSlot& slot)
+Glib::RefPtr<SimpleAction> ActionMap::add_action_with_parameter(const Glib::ustring& name, const ActivateWithParameterSlot& slot)
{
Glib::RefPtr<SimpleAction> action = add_action(name);
action->signal_activate().connect(slot);
return action;
}
+Glib::RefPtr<SimpleAction> ActionMap::add_action(const Glib::ustring& name, const ActivateSlot& slot)
+{
+ Glib::RefPtr<SimpleAction> action = add_action(name);
+ action->signal_activate().connect(
+ sigc::hide(slot));
+ return action;
+}
+
+
Glib::RefPtr<SimpleAction> ActionMap::add_action_bool(const Glib::ustring& name, bool state)
{
Glib::RefPtr<SimpleAction> action = SimpleAction::create_bool(name, state);
return action;
}
+//TODO: Use a slot that takes a bool?
Glib::RefPtr<SimpleAction> ActionMap::add_action_bool(const Glib::ustring& name, const ActivateSlot& slot, bool state)
{
Glib::RefPtr<SimpleAction> action = add_action_bool(name, state);
- action->signal_activate().connect(slot);
+ action->signal_activate().connect(
+ sigc::hide(slot));
return action;
}
+//TODO: Use a slot that takes a string?
Glib::RefPtr<SimpleAction> ActionMap::add_action_radio_string(const Glib::ustring& name, const Glib::ustring& state)
{
Glib::RefPtr<SimpleAction> action = SimpleAction::create_radio_string(name, state);
return action;
}
-Glib::RefPtr<SimpleAction> ActionMap::add_action_radio_string(const Glib::ustring& name, const ActivateSlot& slot, const Glib::ustring& state)
+
+namespace {
+
+//Handle the normal activate signal, calling instead a slot that takes the specific type:
+static void on_action_radio_string(const Glib::VariantBase& parameter, const Gio::ActionMap::ActivateWithStringParameterSlot& slot)
+{
+ //TODO: This syntax is odd:
+ const Glib::Variant<Glib::ustring> variantDerived =
+ parameter.cast_dynamic< Glib::Variant<Glib::ustring> >(parameter);
+ const Glib::ustring str = variantDerived.get();
+ slot(str);
+}
+
+} //anonymous namespace
+
+Glib::RefPtr<SimpleAction> ActionMap::add_action_radio_string(const Glib::ustring& name, const ActivateWithStringParameterSlot& slot, const Glib::ustring& state)
{
Glib::RefPtr<SimpleAction> action = add_action_radio_string(name, state);
- action->signal_activate().connect(slot);
+ action->signal_activate().connect(
+ sigc::bind(sigc::ptr_fun(&on_action_radio_string), slot));
return action;
}
+namespace {
+
+//Handle the normal activate signal, calling instead a slot that takes the specific type:
+static void on_action_radio_int(const Glib::VariantBase& parameter, const Gio::ActionMap::ActivateWithIntParameterSlot& slot)
+{
+ //TODO: This syntax is odd:
+ const Glib::Variant<int> variantDerived =
+ parameter.cast_dynamic< Glib::Variant<int> >(parameter);
+ const int str = variantDerived.get();
+ slot(str);
+}
+
+} //anonymous namespace
+
+//TODO: Use a slot that takes an integer?
Glib::RefPtr<SimpleAction> ActionMap::add_action_radio_integer(const Glib::ustring& name, gint32 state)
{
Glib::RefPtr<SimpleAction> action = SimpleAction::create_radio_integer(name, state);
return action;
}
-Glib::RefPtr<SimpleAction> ActionMap::add_action_radio_integer(const Glib::ustring& name, const ActivateSlot& slot, gint32 state)
+Glib::RefPtr<SimpleAction> ActionMap::add_action_radio_integer(const Glib::ustring& name, const ActivateWithIntParameterSlot& slot, gint32 state)
{
Glib::RefPtr<SimpleAction> action = add_action_radio_integer(name, state);
- action->signal_activate().connect(slot);
+ action->signal_activate().connect(
+ sigc::bind(sigc::ptr_fun(&on_action_radio_int), slot));
return action;
}
_WRAP_METHOD(Glib::RefPtr<const Action> lookup_action(const Glib::ustring& action_name) const, g_action_map_lookup_action, constversion)
/** A Slot to be called when an action has been activated.
- * See add_action().
+ * See add_action_with_parameter().
*
* For instance,
* void on_slot_activated(const Glib::VariantBase& parameter);
*/
- typedef sigc::slot< void,const Glib::VariantBase& > ActivateSlot;
+ typedef sigc::slot< void, const Glib::VariantBase& > ActivateWithParameterSlot;
//This is an equivalent for g_action_map_add_action_entries().
/** A convenience method for creating a SimpleAction instance
* @param slot The callback method to be called when the action is activated.
* @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);
_IGNORE(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().
+ *
+ * For instance,
+ * void on_slot_activated();
+ */
+ typedef sigc::slot<void> ActivateSlot;
+
+ /** A convenience method for creating a SimpleAction instance
+ * and adding it to the ActionMap.
+ *
+ * @param name The name of the Action.
+ * @param slot The callback method to be called when the action is activated.
+ * @return The Action.
+ */
+ Glib::RefPtr<SimpleAction> add_action(const Glib::ustring& name, const ActivateSlot& slot);
+
+
/** A convenience method for creating a boolean-stateful SimpleAction instance
* and adding it to the ActionMap.
*
*/
Glib::RefPtr<SimpleAction> add_action_bool(const Glib::ustring& name, const ActivateSlot& slot, bool state = false);
+
//TODO: Docs: Add hints about how to specify the various possible states in the GtkBuilder XML.
/** A convenience method for creating a string-based radio SimpleAction instance
* and adding it to the ActionMap.
*/
Glib::RefPtr<SimpleAction> add_action_radio_string(const Glib::ustring& name, const Glib::ustring& state);
+ /** A Slot to be called when an action has been activated.
+ * See add_action_radio_string().
+ *
+ * For instance,
+ * void on_slot_activated(const Glib::VariantBase& parameter);
+ */
+ typedef sigc::slot< void, const Glib::ustring& > ActivateWithStringParameterSlot;
+
//TODO: Docs: Add hints about how to specify the various possible states in the GtkBuilder XML.
/** A convenience method for creating a string-based radio SimpleAction instance
* and adding it to the ActionMap.
* @param state The initial state.
* @return The Action.
*/
- Glib::RefPtr<SimpleAction> add_action_radio_string(const Glib::ustring& name, const ActivateSlot& slot, const Glib::ustring& state);
+ 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
*/
Glib::RefPtr<SimpleAction> add_action_radio_integer(const Glib::ustring& name, gint32 state);
+ /** A Slot to be called when an action has been activated.
+ * See add_action_radio_int().
+ *
+ * For instance,
+ * void on_slot_activated(const Glib::VariantBase& parameter);
+ */
+ typedef sigc::slot< void, int > ActivateWithIntParameterSlot;
+
//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.
* @param state The initial state.
* @return The Action.
*/
- Glib::RefPtr<SimpleAction> add_action_radio_integer(const Glib::ustring& name, const ActivateSlot& slot, gint32 state);
+ 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)
static Glib::RefPtr<SimpleAction> create_radio_integer(const Glib::ustring& name, gint32 inital_state);
_WRAP_METHOD(void set_enabled(bool enabled = true), g_simple_action_set_enabled)
- _WRAP_METHOD(void set_state(const Glib::VariantBase& value), g_simple_action_set_state)
_WRAP_PROPERTY("enabled", bool)
_WRAP_PROPERTY("name", Glib::ustring)
_WRAP_SIGNAL(void activate(const Glib::VariantBase& parameter), "activate", no_default_handler)
_WRAP_SIGNAL(void change_state(const Glib::VariantBase& value), "change-state", no_default_handler)
+
+protected:
+
+ //TODO: Add templated version of this, renaming this to set_state_variant(), like Action::change_state()?
+ //This is protected because the C docs say "This should only be called by the implementor of the action."
+ // though that is not entirely clear. We can make this public if somebody needs it.
+ _WRAP_METHOD(void set_state(const Glib::VariantBase& value), g_simple_action_set_state)
};
} // namespace Gio
_WRAP_METHOD_DOCS_ONLY(g_simple_action_group_new)
_WRAP_CREATE()
- _WRAP_METHOD(Glib::RefPtr<Action> lookup(const Glib::ustring& action_name), g_simple_action_group_lookup)
- _WRAP_METHOD(void insert(const Glib::RefPtr<Action>& action), g_simple_action_group_insert)
- _WRAP_METHOD(void remove(const Glib::ustring& action_name), g_simple_action_group_remove)
+ _WRAP_METHOD(Glib::RefPtr<Action> lookup(const Glib::ustring& action_name), g_simple_action_group_lookup, refreturn, deprecated "Use ActionMap::lookup_action() instead")
+ _WRAP_METHOD(Glib::RefPtr<const Action> lookup(const Glib::ustring& action_name) const, g_simple_action_group_lookup, refreturn, constversion, deprecated "Use ActionMap::lookup_action() instead")
- //TODO?: _WRAP_METHOD(void add_entries(const GActionEntry* entries, int n_entries, gpointer user_data), g_simple_action_group_add_entries)
+ _WRAP_METHOD(void insert(const Glib::RefPtr<Action>& action), g_simple_action_group_insert, deprecated "Use ActionMap::add_action() instead")
+ _WRAP_METHOD(void remove(const Glib::ustring& action_name), g_simple_action_group_remove, deprecated "Use ActionMap::remove_action() instead")
+
+ //We ignore g_simple_action_group_add_entries() because it does nothing but call g_action_map_add_action_entries(),
+ //which is already in the base class.
+ _IGNORE(g_simple_action_group_add_entries)
};
} // namespace Gio
* in C++11, std::bind() or a C++11 lambda expression instead of sigc::mem_fun().
*
* The @a name can be useful for discriminating threads in a debugger.
+ * It is not used for other purposes and does not have to be unique.
* Some systems restrict the length of @a name to 16 bytes.
*
* @param slot A slot to execute in the new thread.
my $refreturn = "";
$refreturn = "refreturn" if($bRefreturn eq 1);
+ my ($conversions, $declarations, $initializations) =
+ convert_args_cpp_to_c($objCppfunc, $objDefsSignal, 0, $line_num);
+
# The default signal handler is a virtual function.
# It's not hidden by deprecation, since that would break ABI.
my $str = sprintf("_SIGNAL_CC(%s,%s,%s,%s,\`%s\',\`%s\',%s,%s,%s)dnl\n",
$$objCppfunc{rettype},
$$objDefsSignal{rettype},
$objCppfunc->args_types_and_names(),
- convert_args_cpp_to_c($objCppfunc, $objDefsSignal, 0, $line_num), #$objCppfunc->args_names_only(),
+ $conversions,
$$objCppfunc{const},
$refreturn,
$ifdef);
if($bCustomCCallback ne 1)
{
+ my $conversions =
+ convert_args_c_to_cpp($objDefsSignal, $objCppfunc, $line_num);
+
#This is hidden by deprecation.
my $str = sprintf("_SIGNAL_PCC(%s,%s,%s,%s,\`%s\',\`%s\',\`%s\',\`%s\',%s,%s)dnl\n",
$$objCppfunc{name},
$$objDefsSignal{rettype},
$objDefsSignal->args_types_and_names(),
$objDefsSignal->args_names_only(),
- convert_args_c_to_cpp($objDefsSignal, $objCppfunc, $line_num),
+ $conversions,
${$objDefsSignal->get_param_names()}[0],
$ifdef,
$deprecated);
}
}
-# void output_wrap_sig_decl($filename, $line_num, $objCSignal, $objCppfunc, $signal_name, $bCustomCCallback, $ifdef, $merge_doxycomment_with_previous, $deprecated, $deprecation_docs)
+# void output_wrap_sig_decl($filename, $line_num, $objCSignal, $objCppfunc, $signal_name, $bCustomCCallback, $ifdef, $commentblock, $deprecated, $deprecation_docs)
# custom_signalproxy_name is "" when no type conversion is required - a normal templates SignalProxy will be used instead.
sub output_wrap_sig_decl($$$$$$$$$$)
{
- my ($self, $filename, $line_num, $objCSignal, $objCppfunc, $signal_name, $bCustomCCallback, $ifdef, $merge_doxycomment_with_previous, $deprecated, $deprecation_docs) = @_;
+ my ($self, $filename, $line_num, $objCSignal, $objCppfunc, $signal_name, $bCustomCCallback, $ifdef, $commentblock, $deprecated, $deprecation_docs) = @_;
# _SIGNAL_PROXY(c_signal_name, c_return_type, `<c_arg_types_and_names>',
# cpp_signal_name, cpp_return_type, `<cpp_arg_types>',`<c_args_to_cpp>',
my $doxycomment = $objCppfunc->get_refdoc_comment($documentation);
# If there was already a previous doxygen comment, we want to merge this
- # one with the previous so it is one big comment. If it were two separate
- # comments, doxygen would ignore the first one. If
- # $merge_doxycomment_with_previous is nonzero, the first comment is
- # already open but not yet closed.
- if($merge_doxycomment_with_previous)
+ # one with the previous so it is one big comment. If
+ # $commentblock is not emtpy, it contains the previous doxygen comment without
+ # opening and closing tokens (/** and */).
+ if($commentblock ne "")
{
# Strip leading whitespace
$doxycomment =~ s/^\s+//;
- # We don't have something to add, so just close the comment.
+ # We don't have something to add, so just use $commentblock with
+ # opening and closing tokens added.
if($doxycomment eq "")
{
- $doxycomment = " */";
+ $doxycomment = ' /**' . $commentblock . "\n */";
}
else
{
- # Append the new comment, but remove the first three leading characters
- # (which are /**) that mark the beginning of the comment.
+ # Merge the two comments, but remove the first three characters from the
+ # second comment (/**) that mark the beginning of the comment.
$doxycomment = substr($doxycomment, 3);
$doxycomment =~ s/^\s+//;
- $doxycomment = " " . $doxycomment;
+ $doxycomment = ' /**' . $commentblock . "\n *\n " . $doxycomment;
}
}
- my $str = sprintf("_SIGNAL_PROXY(%s,%s,\`%s\',%s,%s,\`%s\',\`%s\',\`%s\',\`%s\',%s)dnl\n",
+ my $conversions =
+ convert_args_c_to_cpp($objCSignal, $objCppfunc, $line_num);
+
+ my $str = sprintf("_SIGNAL_PROXY(%s,%s,\`%s\',%s,%s,\`%s\',\`%s\',\`%s\',%s,\`%s\',%s)dnl\n",
$signal_name,
$$objCSignal{rettype},
$objCSignal->args_types_and_names_without_object(),
$$objCppfunc{name},
$$objCppfunc{rettype},
$objCppfunc->args_types_only(),
- convert_args_c_to_cpp($objCSignal, $objCppfunc, $line_num),
+ $conversions,
$bCustomCCallback, #When this is true, it will not write the *_callback implementation for you.
$deprecated,
$doxycomment,
if ($token eq "_WRAP_METHOD") { $self->on_wrap_method(); next;}
if ($token eq "_WRAP_METHOD_DOCS_ONLY") { $self->on_wrap_method_docs_only(); next;}
if ($token eq "_WRAP_CORBA_METHOD") { $self->on_wrap_corba_method(); next;} #Used in libbonobo*mm.
- if ($token eq "_WRAP_SIGNAL") { $self->on_wrap_signal(0); next;}
+ if ($token eq "_WRAP_SIGNAL") { $self->on_wrap_signal(); next;}
if ($token eq "_WRAP_PROPERTY") { $self->on_wrap_property(); next;}
if ($token eq "_WRAP_VFUNC") { $self->on_wrap_vfunc(); next;}
if ($token eq "_WRAP_CTOR") { $self->on_wrap_ctor(); next;}
if ($_ eq "*/")
{
- push (@out,"\'*");
+ push (@out,"\'*/");
$objOutputter->append(join("", @out));
- # Find next non-whitespace token, but remember whitespace so that we
- # can print it if the next real token is not _WRAP_SIGNAL
+ # Extract all following whitespace tokens.
my @whitespace;
my $next_token = $self->peek_token();
while ($next_token !~ /\S/)
{
push(@whitespace, $self->extract_token());
- $next_token = $self->peek_token();
- }
-
- # If the next token is a signal, do not close this comment, to merge
- # this doxygen comment with the one from the signal.
- if($next_token eq '_WRAP_SIGNAL')
- {
- # Extract token and process
- $self->extract_token();
- # Tell wrap_signal to merge automatically generated comment with
- # already existing comment. This is why we do not close the comment
- # here.
- $self->on_wrap_signal(1);
- }
- else
- {
- # Something other than signal follows, so close comment normally
- $objOutputter->append("/");
- # And append whitespace we ignored so far
- $objOutputter->append(join("", @whitespace));
- # Do not extract the token so that parse_and_build_output() will
- # process it.
+ $next_token = $self->peek_token();
}
-
+ # Do not extract the following non-whitespace token so that
+ # parse_and_build_output() will process it.
+
+ # Append whitespace.
+ # extract_preceding_documentation() expects to find a preceding
+ # doxygen comment, if any, as two array elements, one with the whole
+ # comment, the following (possibly empty) with the following
+ # whitespace.
+ $objOutputter->append(join("", @whitespace));
last;
}
my $comment = '';
- if ($#$out >= 2)
+ if ($#$out >= 1)
{
- # steal the last three tokens
- my @back = splice(@$out, -3);
+ # steal the last two tokens
+ my @back = splice(@$out, -2);
local $_ = join('', @back);
# Check for /*[*!] ... */ or //[/!] comments. The closing */ _must_
sub on_wrap_signal($$)
{
- my ($self, $merge_doxycomment_with_previous) = @_;
+ my ($self) = @_;
if( !($self->check_for_eof()) )
{
return;
}
+ my $commentblock = $self->extract_preceding_documentation();
+ # Remove leading and trailing m4 quotes, if any.
+ # M4 quotes will be added around the whole comment, after $commentblock has
+ # possibly been merged with a second comment block.
+ $commentblock =~ s/^`//;
+ $commentblock =~ s/'$//;
+
my $str = $self->extract_bracketed_text();
my @args = string_split_commas($str);
$self->output_wrap_signal($argCppDecl, $argCName, $$self{filename}, $$self{line_num},
$bCustomDefaultHandler, $bNoDefaultHandler, $bCustomCCallback,
- $bRefreturn, $ifdef, $merge_doxycomment_with_previous, $argDeprecated, $deprecation_docs);
+ $bRefreturn, $ifdef, $commentblock, $argDeprecated, $deprecation_docs);
}
# void on_wrap_vfunc()
# void output_wrap($CppDecl, $signal_name, $filename, $line_num, $bCustomDefaultHandler,
# $bNoDefaultHandler, $bCustomCCallback, $bRefreturn, $ifdef,
-# $merge_doxycomment_with_previous, $deprecated, $deprecation_docs)
+# $commentblock, $deprecated, $deprecation_docs)
sub output_wrap_signal($$$$$$$$$$$)
{
my ($self, $CppDecl, $signal_name, $filename, $line_num, $bCustomDefaultHandler,
$bNoDefaultHandler, $bCustomCCallback, $bRefreturn, $ifdef,
- $merge_doxycomment_with_previous, $deprecated, $deprecation_docs) = @_;
+ $commentblock, $deprecated, $deprecation_docs) = @_;
#Some checks:
return if ($self->output_wrap_check($CppDecl, $signal_name,
}
$objOutputter->output_wrap_sig_decl($filename, $line_num, $objCSignal, $objCppSignal,
- $signal_name, $bCustomCCallback, $ifdef, $merge_doxycomment_with_previous,
+ $signal_name, $bCustomCCallback, $ifdef, $commentblock,
$deprecated, $deprecation_docs);
if($bNoDefaultHandler eq 0)