[glibmm] Gio::Action: print_detailed_name() Make this templated.



commit 31d34b516699d7e8e6b847bd684afcc035ab95f4
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Aug 6 21:04:25 2013 +0200

    Gio::Action: print_detailed_name() Make this templated.
    
    Renaming the original method to print_detaild_name_variant().
    This method is new in this development cycle, so we may still
    change it.

 gio/src/action.hg |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/gio/src/action.hg b/gio/src/action.hg
index c0e97b3..8cf8e06 100644
--- a/gio/src/action.hg
+++ b/gio/src/action.hg
@@ -115,7 +115,11 @@ public:
 
   //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)
@@ -174,4 +178,15 @@ void Action::get_state_hint(T_Value& value) const
   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));
+}
+
 } // namespace Gio


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