diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index 45442a505..f62d6bd89 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -81,6 +81,10 @@ static GSList *main_loops = NULL; guint clutter_debug_flags = 0; /* global clutter debug flag */ +const guint clutter_major_version = CLUTTER_MAJOR_VERSION; +const guint clutter_minor_version = CLUTTER_MINOR_VERSION; +const guint clutter_micro_version = CLUTTER_MICRO_VERSION; + #ifdef CLUTTER_ENABLE_DEBUG static const GDebugKey clutter_debug_keys[] = { { "misc", CLUTTER_DEBUG_MISC }, @@ -2995,3 +2999,33 @@ _clutter_run_repaint_functions (void) if (reinvoke_list) context->repaint_funcs = reinvoke_list; } + +/** + * clutter_check_version: + * @major: major version, like 1 in 1.2.3 + * @minor: minor version, like 2 in 1.2.3 + * @micro: micro version, like 3 in 1.2.3 + * + * Run-time version check, to check the version the Clutter library + * that an application is currently linked against + * + * This is the run-time equivalent of the compile-time %CLUTTER_CHECK_VERSION + * pre-processor macro + * + * Return value: %TRUE if the version of the Clutter library is + * greater than (@major, @minor, @micro), and %FALSE otherwise + * + * Since: 1.2 + */ +gboolean +clutter_check_version (guint major, + guint minor, + guint micro) +{ + return (clutter_major_version > major || + (clutter_major_version == major && + clutter_minor_version > minor) || + (clutter_major_version == major && + clutter_minor_version == minor && + clutter_micro_version >= micro)); +} diff --git a/clutter/clutter-version.h.in b/clutter/clutter-version.h.in index 7c9e15656..93a83923e 100644 --- a/clutter/clutter-version.h.in +++ b/clutter/clutter-version.h.in @@ -34,6 +34,10 @@ #ifndef __CLUTTER_VERSION_H__ #define __CLUTTER_VERSION_H__ +#include + +G_BEGIN_DECLS + /** * CLUTTER_MAJOR_VERSION: * @@ -117,7 +121,7 @@ * * The default GObject type for the Clutter stage. * - * Since 0.8 + * Since: 0.8 */ #define CLUTTER_STAGE_TYPE @CLUTTER_STAGE_TYPE@ @@ -131,5 +135,14 @@ */ #define CLUTTER_NO_FPU CLUTTER_NO_FPU_MACRO_WAS_REMOVED +extern const guint clutter_major_version; +extern const guint clutter_minor_version; +extern const guint clutter_micro_version; + +gboolean clutter_check_version (guint major, + guint minor, + guint micro); + +G_END_DECLS #endif /* __CLUTTER_VERSION_H__ */ diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index b81e82de6..36b552dda 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -1125,10 +1125,17 @@ CLUTTER_MICRO_VERSION CLUTTER_VERSION CLUTTER_VERSION_S CLUTTER_VERSION_HEX + + CLUTTER_CHECK_VERSION + + CLUTTER_FLAVOUR CLUTTER_COGL CLUTTER_NO_FPU + + +clutter_check_version