[gtkmm] Add the GTKMM_CHECK_VERSION() preprocessor macro



commit 277edfd75c097579e5c02b343b885d756f8cd3be
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Sun Mar 24 12:16:18 2019 +0100

    Add the GTKMM_CHECK_VERSION() preprocessor macro
    
    and remove macros that check the GTK version. Fixes #5

 gdk/src/types.hg      | 18 ------------
 gtk/gtkmm.h           |  2 +-
 gtk/gtkmm/base.h      | 47 -------------------------------
 gtk/gtkmm/filelist.am |  2 +-
 gtk/gtkmm/object.h    |  1 -
 gtk/gtkmm/version.h   | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 80 insertions(+), 68 deletions(-)
---
diff --git a/gdk/src/types.hg b/gdk/src/types.hg
index f4a859b7..db48a842 100644
--- a/gdk/src/types.hg
+++ b/gdk/src/types.hg
@@ -31,24 +31,6 @@ enum { ERROR = GTKMM_MACRO_DEFINITION_ERROR };
 #define GTKMM_MACRO_SHADOW_ERROR 1
 #endif
 
-/*********************************************************************
-***** Version macros
-*********************************************************************/
-
-/* macro for controlling version numbers */
-#ifndef _GDK_VERSION
-
-#define GDK_VERSION_GT(major,minor) 
((GTK_MAJOR_VERSION>major)||(GTK_MAJOR_VERSION==major)&&(GTK_MINOR_VERSION>minor))
-#define GDK_VERSION_GE(major,minor) 
((GTK_MAJOR_VERSION>major)||(GTK_MAJOR_VERSION==major)&&(GTK_MINOR_VERSION>=minor))
-#define GDK_VERSION_EQ(major,minor) ((GTK_MAJOR_VERSION==major)&&(GTK_MINOR_VERSION==minor))
-#define GDK_VERSION_NE(major,minor) ((GTK_MAJOR_VERSION!=major)||(GTK_MINOR_VERSION!=minor))
-#define GDK_VERSION_LE(major,minor) 
((GTK_MAJOR_VERSION<major)||(GTK_MAJOR_VERSION==major)&&(GTK_MINOR_VERSION<=minor))
-#define GDK_VERSION_LT(major,minor) 
((GTK_MAJOR_VERSION<major)||(GTK_MAJOR_VERSION==major)&&(GTK_MINOR_VERSION<minor))
-
-//Note: Use GTK_CHECK_VERSION to check that a version is equal or more than (the micro version).
-
-#endif /* _GDK_VERSION */
-
 namespace Gdk
 {
 
diff --git a/gtk/gtkmm.h b/gtk/gtkmm.h
index b8464fb8..b39535a0 100644
--- a/gtk/gtkmm.h
+++ b/gtk/gtkmm.h
@@ -104,7 +104,6 @@ extern const int gtkmm_micro_version;
 #include <gtkmm/applicationwindow.h>
 #include <gtkmm/aspectframe.h>
 #include <gtkmm/assistant.h>
-#include <gtkmm/base.h>
 #include <gtkmm/bin.h>
 #include <gtkmm/border.h>
 #include <gtkmm/box.h>
@@ -277,6 +276,7 @@ extern const int gtkmm_micro_version;
 #include <gtkmm/treestore.h>
 #include <gtkmm/treeview.h>
 #include <gtkmm/treeviewcolumn.h>
+#include <gtkmm/version.h>
 #include <gtkmm/video.h>
 #include <gtkmm/viewport.h>
 #include <gtkmm/volumebutton.h>
diff --git a/gtk/gtkmm/filelist.am b/gtk/gtkmm/filelist.am
index 1a647f18..0906e4f6 100644
--- a/gtk/gtkmm/filelist.am
+++ b/gtk/gtkmm/filelist.am
@@ -22,7 +22,6 @@ gtkmm_files_extra_deprecated_cc =
 gtkmm_files_extra_any_h =                      \
        accelkey.h                      \
        accelmap.h                      \
-       base.h                          \
        border.h                        \
        cellrenderer_generation.h       \
        childpropertyproxy.h \
@@ -34,6 +33,7 @@ gtkmm_files_extra_any_h =                     \
        selectiondata_private.h         \
        treemodelcolumn.h               \
        treeview_private.h              \
+       version.h \
        wrap_init.h
 
 gtkmm_files_extra_deprecated_h =
diff --git a/gtk/gtkmm/object.h b/gtk/gtkmm/object.h
index 8ef4788f..b7653dd3 100644
--- a/gtk/gtkmm/object.h
+++ b/gtk/gtkmm/object.h
@@ -19,7 +19,6 @@
 #define _GTKMM_OBJECT_H
 
 #include <glibmm/object.h>
-#include <gtkmm/base.h>
 #include <gtkmmconfig.h>
 
 #include <utility>
diff --git a/gtk/gtkmm/version.h b/gtk/gtkmm/version.h
new file mode 100644
index 00000000..a95f719d
--- /dev/null
+++ b/gtk/gtkmm/version.h
@@ -0,0 +1,78 @@
+#ifndef _GTKMM_VERSION_H
+#define _GTKMM_VERSION_H
+
+/* Copyright (C) 2019 The gtkmm Development Team
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtkmmconfig.h>
+
+// GTKMM_M*_VERSION are defined in gtkmmconfig.h.
+// They are described here because Doxygen does not document gtkmmconfig.h.
+
+#ifdef DOXYGEN_SHOULD_SKIP_THIS
+// Only Doxygen sees this.
+#define GTKMM_MAJOR_VERSION
+#define GTKMM_MINOR_VERSION
+#define GTKMM_MICRO_VERSION
+#endif
+
+/** @defgroup Version Version
+ * Gtkmm version
+ * @{
+ */
+
+/** @def GTKMM_MAJOR_VERSION
+ * The major version number of the GTKMM library.
+ *
+ * From the headers used at application compile time.
+ * E.g. in GTKMM version 4.2.1 this is 4.
+ */
+
+/** @def GTKMM_MINOR_VERSION
+ * The minor version number of the GTKMM library.
+ *
+ * From the headers used at application compile time.
+ * E.g. in GTKMM version 4.2.1 this is 2.
+ */
+
+/** @def GTKMM_MICRO_VERSION
+ * The micro version number of the GTKMM library.
+ *
+ * From the headers used at application compile time.
+ * E.g. in GTKMM version 4.2.1 this is 1.
+ */
+
+/** Checks the version of the GTKMM header files at compile time.
+ *
+ * Returns <tt>true</tt> if the version of the GTKMM header files
+ * is the same as or newer than the passed-in version.
+ *
+ * @newin{3,96}
+ *
+ * @param major Major version (e.g. 4 for version 4.2.1)
+ * @param minor Minor version (e.g. 2 for version 4.2.1)
+ * @param micro Micro version (e.g. 1 for version 4.2.1)
+ * @returns <tt>true</tt> if GTKMM headers are new enough.
+ */
+#define GTKMM_CHECK_VERSION(major, minor, micro) \
+  (GTKMM_MAJOR_VERSION > (major) || \
+  (GTKMM_MAJOR_VERSION == (major) && GTKMM_MINOR_VERSION > (minor)) || \
+  (GTKMM_MAJOR_VERSION == (major) && GTKMM_MINOR_VERSION == (minor) && \
+   GTKMM_MICRO_VERSION >= (micro)))
+
+/** @} */ // end of group Version
+
+#endif // _GTKMM_VERSION_H


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