summaryrefslogtreecommitdiff
path: root/glib/src/optioncontext.ccg
diff options
context:
space:
mode:
authorJonathon Jongsma <jjongsma@gnome.org>2007-07-09 13:35:31 +0000
committerJonathon Jongsma <jjongsma@src.gnome.org>2007-07-09 13:35:31 +0000
commitd0205f9d7cce43680f9067cf8b971d4ef562a64a (patch)
tree68eb2bdcb13f2c16a762107b9cf0402988cbfde3 /glib/src/optioncontext.ccg
parenta7fe4a836d3406ab8f1eeebbf7173529da0dd55c (diff)
downloadglibmm-d0205f9d7cce43680f9067cf8b971d4ef562a64a.tar.gz
add some new API that was added in glib 2.12, including get/set_summary(),
2007-07-07 Jonathon Jongsma <jjongsma@gnome.org> * glib/src/optioncontext.ccg: * glib/src/optioncontext.hg: add some new API that was added in glib 2.12, including get/set_summary(), get/set_description(), set_translation_domain(), and set_translate_fun(). * glib/src/glib_docs.xml: Regenerated with docextract_to_xml.py * glib/src/glib_docs_override.xml: override docs for the new functions so that they say that they were introduced in glibmm 2.14 instead of 2.12 svn path=/trunk/; revision=424
Diffstat (limited to 'glib/src/optioncontext.ccg')
-rw-r--r--glib/src/optioncontext.ccg44
1 files changed, 41 insertions, 3 deletions
diff --git a/glib/src/optioncontext.ccg b/glib/src/optioncontext.ccg
index 3d77dce6..494e4f39 100644
--- a/glib/src/optioncontext.ccg
+++ b/glib/src/optioncontext.ccg
@@ -1,5 +1,5 @@
// -*- c++ -*-
-/* $Id$ */
+/* $Id: optioncontext.ccg,v 1.4 2004/10/30 14:25:45 murrayc Exp $ */
/* Copyright (C) 2002 The gtkmm Development Team
*
@@ -19,11 +19,41 @@
*/
#include <glibmm/utility.h>
+#include <glibmm/exceptionhandler.h>
#include <glib/goption.h>
namespace Glib
{
+ namespace Private
+ {
+ static const gchar* SignalProxy_translate_gtk_callback (const gchar* str, gpointer data)
+ {
+ Glib::ustring translated_str;
+ Glib::OptionContext::SlotTranslate* the_slot =
+ static_cast<Glib::OptionContext::SlotTranslate*>(data);
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try
+ {
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+ translated_str = (*the_slot)(str);
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ }
+ catch(...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+ return translated_str.c_str ();
+ }
+
+ static void SignalProxy_translate_gtk_callback_destroy (gpointer data)
+ {
+ delete static_cast<Glib::OptionContext::SlotTranslate*>(data);
+ }
+
+ } //namespace Private
OptionContext::OptionContext(const Glib::ustring& parameter_string)
: gobject_( g_option_context_new(parameter_string.c_str()) ),
@@ -68,7 +98,15 @@ OptionGroup OptionContext::get_main_group() const
*/
-
+void OptionContext::set_translate_func (const SlotTranslate& slot)
+{
+ //Create a copy of the slot. A pointer to this will be passed through the callback's data parameter.
+ //It will be deleted when SignalProxy_translate_gtk_callback_destroy() is called.
+ SlotTranslate* slot_copy = new SlotTranslate(slot);
-} // namespace Glib
+ g_option_context_set_translate_func(
+ gobj(), &Private::SignalProxy_translate_gtk_callback, slot_copy,
+ &Private::SignalProxy_translate_gtk_callback_destroy);
+}
+} // namespace Glib