[libadwaita/wip/exalm/demo: 2/17] version: Add runtime version functions




commit 5b6f744defdaf60448bee4938e33fd8f3aa16fc1
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Wed Oct 13 15:25:05 2021 +0500

    version: Add runtime version functions
    
    This will allow to show the current version in the demo about dialog.

 src/adw-version.c    | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/adw-version.h.in | 13 ++++++++++
 src/meson.build      |  1 +
 3 files changed, 85 insertions(+)
---
diff --git a/src/adw-version.c b/src/adw-version.c
new file mode 100644
index 00000000..24ea008f
--- /dev/null
+++ b/src/adw-version.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2021 Purism SPC
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * Author: Alexander Mikhaylenko <alexander mikhaylenko puri sm>
+ */
+
+#include "config.h"
+
+#include "adw-version.h"
+
+/**
+ * adw_get_major_version:
+ *
+ * Returns the major version number of the Adwaita library.
+ *
+ * For example, in libadwaita version 1.2.3 this is 1.
+ *
+ * This function is in the library, so it represents the libadwaita library
+ * your code is running against. Contrast with the %ADW_MAJOR_VERSION macro,
+ * which represents the major version of the libadwaita headers you have
+ * included when compiling your code.
+ *
+ * Returns: the major version number of the Adwaita library
+ */
+guint
+adw_get_major_version (void)
+{
+  return ADW_MAJOR_VERSION;
+}
+
+/**
+ * adw_get_minor_version:
+ *
+ * Returns the minor version number of the Adwaita library.
+ *
+ * For example, in libadwaita version 1.2.3 this is 2.
+ *
+ * This function is in the library, so it represents the libadwaita library
+ * your code is running against. Contrast with the %ADW_MAJOR_VERSION macro,
+ * which represents the minor version of the libadwaita headers you have
+ * included when compiling your code.
+ *
+ * Returns: the minor version number of the Adwaita library
+ */
+guint
+adw_get_minor_version (void)
+{
+  return ADW_MINOR_VERSION;
+}
+
+/**
+ * adw_get_micro_version:
+ *
+ * Returns the micro version number of the Adwaita library.
+ *
+ * For example, in libadwaita version 1.2.3 this is 2.
+ *
+ * This function is in the library, so it represents the libadwaita library
+ * your code is running against. Contrast with the %ADW_MAJOR_VERSION macro,
+ * which represents the micro version of the libadwaita headers you have
+ * included when compiling your code.
+ *
+ * Returns: the micro version number of the Adwaita library
+ */
+guint
+adw_get_micro_version (void)
+{
+  return ADW_MICRO_VERSION;
+}
diff --git a/src/adw-version.h.in b/src/adw-version.h.in
index 54a70c24..a0a445d6 100644
--- a/src/adw-version.h.in
+++ b/src/adw-version.h.in
@@ -10,6 +10,10 @@
 #error "Only <adwaita.h> can be included directly."
 #endif
 
+#include <glib.h>
+
+G_BEGIN_DECLS
+
 /**
  * ADW_MAJOR_VERSION:
  *
@@ -84,3 +88,12 @@
 #define ADW_UNAVAILABLE(major, minor) G_UNAVAILABLE(major, minor) _ADW_EXTERN
 
 #define ADW_AVAILABLE_IN_ALL _ADW_EXTERN
+
+ADW_AVAILABLE_IN_ALL
+guint adw_get_major_version (void) G_GNUC_CONST;
+ADW_AVAILABLE_IN_ALL
+guint adw_get_minor_version (void) G_GNUC_CONST;
+ADW_AVAILABLE_IN_ALL
+guint adw_get_micro_version (void) G_GNUC_CONST;
+
+G_END_DECLS
diff --git a/src/meson.build b/src/meson.build
index fd4e2784..9a3be48e 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -168,6 +168,7 @@ src_sources = [
   'adw-tab-bar.c',
   'adw-tab-box.c',
   'adw-tab-view.c',
+  'adw-version.c',
   'adw-view-stack.c',
   'adw-view-switcher.c',
   'adw-view-switcher-bar.c',


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