From ed13d53db95e4657bb5f673238b8632e8c039b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sun, 3 Aug 2025 15:18:44 +0200 Subject: [PATCH] clapper-gtk: Add runtime version information Allows apps to check the library version app is run against, contrary to compiled against --- src/lib/clapper-gtk/clapper-gtk-version.c | 95 ++++++++++++++++++++ src/lib/clapper-gtk/clapper-gtk-version.h.in | 14 +++ src/lib/clapper-gtk/meson.build | 1 + 3 files changed, 110 insertions(+) create mode 100644 src/lib/clapper-gtk/clapper-gtk-version.c diff --git a/src/lib/clapper-gtk/clapper-gtk-version.c b/src/lib/clapper-gtk/clapper-gtk-version.c new file mode 100644 index 00000000..b70757a1 --- /dev/null +++ b/src/lib/clapper-gtk/clapper-gtk-version.c @@ -0,0 +1,95 @@ +/* Clapper GTK Integration Library + * Copyright (C) 2025 Rafał Dzięgiel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + * . + */ + +#include "clapper-gtk-version.h" + +/** + * clapper_gtk_get_major_version: + * + * ClapperGtk runtime major version component + * + * This returns the ClapperGtk library version your code is + * running against unlike [const@ClapperGtk.MAJOR_VERSION] + * which represents compile time version. + * + * Returns: the major version number of the ClapperGtk library + * + * Since: 0.10 + */ +guint +clapper_gtk_get_major_version (void) +{ + return CLAPPER_GTK_MAJOR_VERSION; +} + +/** + * clapper_gtk_get_minor_version: + * + * ClapperGtk runtime minor version component + * + * This returns the ClapperGtk library version your code is + * running against unlike [const@ClapperGtk.MINOR_VERSION] + * which represents compile time version. + * + * Returns: the minor version number of the ClapperGtk library + * + * Since: 0.10 + */ +guint +clapper_gtk_get_minor_version (void) +{ + return CLAPPER_GTK_MINOR_VERSION; +} + +/** + * clapper_gtk_get_micro_version: + * + * ClapperGtk runtime micro version component + * + * This returns the ClapperGtk library version your code is + * running against unlike [const@ClapperGtk.MICRO_VERSION] + * which represents compile time version. + * + * Returns: the micro version number of the ClapperGtk library + * + * Since: 0.10 + */ +guint +clapper_gtk_get_micro_version (void) +{ + return CLAPPER_GTK_MICRO_VERSION; +} + +/** + * clapper_gtk_get_version_s: + * + * ClapperGtk runtime version as string + * + * This returns the ClapperGtk library version your code is + * running against unlike [const@ClapperGtk.VERSION_S] + * which represents compile time version. + * + * Returns: the version of the ClapperGtk library as string + * + * Since: 0.10 + */ +const gchar * +clapper_gtk_get_version_s (void) +{ + return CLAPPER_GTK_VERSION_S; +} diff --git a/src/lib/clapper-gtk/clapper-gtk-version.h.in b/src/lib/clapper-gtk/clapper-gtk-version.h.in index cfec457c..de9668a5 100644 --- a/src/lib/clapper-gtk/clapper-gtk-version.h.in +++ b/src/lib/clapper-gtk/clapper-gtk-version.h.in @@ -22,6 +22,8 @@ #error "Only can be included directly." #endif +#include + /** * CLAPPER_GTK_MAJOR_VERSION: * @@ -73,3 +75,15 @@ (CLAPPER_GTK_MAJOR_VERSION == (major) && CLAPPER_GTK_MINOR_VERSION > (minor)) || \ (CLAPPER_GTK_MAJOR_VERSION == (major) && CLAPPER_GTK_MINOR_VERSION == (minor) && \ CLAPPER_GTK_MICRO_VERSION >= (micro))) + +G_BEGIN_DECLS + +guint clapper_gtk_get_major_version (void); + +guint clapper_gtk_get_minor_version (void); + +guint clapper_gtk_get_micro_version (void); + +const gchar * clapper_gtk_get_version_s (void); + +G_END_DECLS diff --git a/src/lib/clapper-gtk/meson.build b/src/lib/clapper-gtk/meson.build index 1cc234c9..9a4e5863 100644 --- a/src/lib/clapper-gtk/meson.build +++ b/src/lib/clapper-gtk/meson.build @@ -131,6 +131,7 @@ clappergtk_sources = [ 'clapper-gtk-toggle-fullscreen-button.c', 'clapper-gtk-toggle-play-button.c', 'clapper-gtk-utils.c', + 'clapper-gtk-version.c', 'clapper-gtk-video.c', 'clapper-gtk-video-placeholder.c', clappergtk_resources,