summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
commitcca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch)
tree146f39ded1c938019e1ed42d30923c2ac9e86789 /src/include
parentInitial commit. (diff)
downloadinkscape-upstream/1.2.2.tar.xz
inkscape-upstream/1.2.2.zip
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/CMakeLists.txt8
-rw-r--r--src/include/README3
-rw-r--r--src/include/glibmm_version.h45
-rw-r--r--src/include/gtkmm_version.h45
-rw-r--r--src/include/macros.h52
-rw-r--r--src/include/source_date_epoch.h68
6 files changed, 221 insertions, 0 deletions
diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt
new file mode 100644
index 0000000..5e08ebd
--- /dev/null
+++ b/src/include/CMakeLists.txt
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+set(include_SRC
+ glibmm_version.h
+ gtkmm_version.h
+ macros.h
+)
+
+add_inkscape_source("${io_SRC}")
diff --git a/src/include/README b/src/include/README
new file mode 100644
index 0000000..336b3e2
--- /dev/null
+++ b/src/include/README
@@ -0,0 +1,3 @@
+Configuration, defines, macros and similar that do not fit anywhere else.
+
+Try to keep this to a minimum and move to more suitable locations whenever possible.
diff --git a/src/include/glibmm_version.h b/src/include/glibmm_version.h
new file mode 100644
index 0000000..39bf2c6
--- /dev/null
+++ b/src/include/glibmm_version.h
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/** @file
+ * macro for checking glibmm version
+ *//*
+ * Authors:
+ * Patrick Storz <eduard.braun2@gmx.de>
+ *
+ * Copyright (C) 2020 Authors
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information.
+ */
+
+#ifndef SEEN_GLIBMM_VERSION
+#define SEEN_GLIBMM_VERSION
+
+#include <glibmm.h>
+
+#ifndef GLIBMM_CHECK_VERSION
+
+#if !defined(GLIBMM_MAJOR_VERSION) || !defined(GLIBMM_MINOR_VERSION) || !defined(GLIBMM_MICRO_VERSION)
+ #error "Missing defines for glibmm version (GLIBMM_MAJOR_VERSION / GLIBMM_MINOR_VERSION / GLIBMM_MICRO_VERSION)"
+#endif
+
+/**
+ * Check glibmm version
+ *
+ * This is adapted from the upstream gtk macro for use with glibmm
+ *
+ * @major: major version (e.g. 1 for version 1.2.5)
+ * @minor: minor version (e.g. 2 for version 1.2.5)
+ * @micro: micro version (e.g. 5 for version 1.2.5)
+ *
+ * Returns %TRUE if the version of the glibmm header files
+ * is the same as or newer than the passed-in version.
+ *
+ * Returns: %TRUE if glibmm headers are new enough
+ */
+#define GLIBMM_CHECK_VERSION(major,minor,micro) \
+ (GLIBMM_MAJOR_VERSION > (major) || \
+ (GLIBMM_MAJOR_VERSION == (major) && GLIBMM_MINOR_VERSION > (minor)) || \
+ (GLIBMM_MAJOR_VERSION == (major) && GLIBMM_MINOR_VERSION == (minor) && \
+ GLIBMM_MICRO_VERSION >= (micro)))
+
+#endif // #ifndef GLIBMM_CHECK_VERSION
+
+#endif // SEEN_GLIBMM_VERSION
diff --git a/src/include/gtkmm_version.h b/src/include/gtkmm_version.h
new file mode 100644
index 0000000..a23223c
--- /dev/null
+++ b/src/include/gtkmm_version.h
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/** @file
+ * macro for checking gtkmm version
+ *//*
+ * Authors:
+ * Patrick Storz <eduard.braun2@gmx.de>
+ *
+ * Copyright (C) 2018 Authors
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information.
+ */
+
+#ifndef SEEN_GTKMM_VERSION
+#define SEEN_GTKMM_VERSION
+
+#include <gtkmm.h>
+
+#ifndef GTKMM_CHECK_VERSION
+
+#if !defined(GTKMM_MAJOR_VERSION) || !defined(GTKMM_MINOR_VERSION) || !defined(GTKMM_MICRO_VERSION)
+ #error "Missing defines for gtkmm version (GTKMM_MAJOR_VERSION / GTKMM_MINOR_VERSION / GTKMM_MICRO_VERSION)"
+#endif
+
+/**
+ * Check GtkMM version
+ *
+ * This is adapted from the upstream Gtk+ macro for use with GtkMM
+ *
+ * @major: major version (e.g. 1 for version 1.2.5)
+ * @minor: minor version (e.g. 2 for version 1.2.5)
+ * @micro: micro version (e.g. 5 for version 1.2.5)
+ *
+ * Returns %TRUE if the version of the GTK+ header files
+ * is the same as or newer than the passed-in version.
+ *
+ * Returns: %TRUE if GTK+ 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)))
+
+#endif // #ifndef GTKMM_CHECK_VERSION
+
+#endif // SEEN_GTKMM_VERSION
diff --git a/src/include/macros.h b/src/include/macros.h
new file mode 100644
index 0000000..aa1719d
--- /dev/null
+++ b/src/include/macros.h
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#ifndef SEEN_MACROS_H
+#define SEEN_MACROS_H
+
+/**
+ * Useful macros for inkscape
+ *
+ * Author:
+ * Lauris Kaplinski <lauris@kaplinski.com>
+ *
+ * Copyright (C) 2002 Lauris Kaplinski
+ *
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information.
+ */
+
+// I'm of the opinion that this file should be removed, so I will in the future take the necessary steps to wipe it out.
+// Macros are not in general bad, but these particular ones are rather ugly. --Liam
+
+#define sp_signal_disconnect_by_data(o,d) g_signal_handlers_disconnect_matched(o, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, d)
+
+// "primary" modifier: Ctrl on Linux/Windows and Cmd on macOS.
+// note: Could query this at runtime with
+// `gdk_keymap_get_modifier_mask(..., GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR)`
+#ifdef GDK_WINDOWING_QUARTZ
+#define INK_GDK_PRIMARY_MASK GDK_MOD2_MASK
+#else
+#define INK_GDK_PRIMARY_MASK GDK_CONTROL_MASK
+#endif
+
+// all modifiers used by Inkscape
+#define INK_GDK_MODIFIER_MASK (GDK_SHIFT_MASK | INK_GDK_PRIMARY_MASK | GDK_MOD1_MASK)
+
+// keyboard modifiers in an event
+#define MOD__SHIFT(event) ((event)->key.state & GDK_SHIFT_MASK)
+#define MOD__CTRL(event) ((event)->key.state & INK_GDK_PRIMARY_MASK)
+#define MOD__ALT(event) ((event)->key.state & GDK_MOD1_MASK)
+#define MOD__SHIFT_ONLY(event) (((event)->key.state & INK_GDK_MODIFIER_MASK) == GDK_SHIFT_MASK)
+#define MOD__CTRL_ONLY(event) (((event)->key.state & INK_GDK_MODIFIER_MASK) == INK_GDK_PRIMARY_MASK)
+#define MOD__ALT_ONLY(event) (((event)->key.state & INK_GDK_MODIFIER_MASK) == GDK_MOD1_MASK)
+
+#endif // SEEN_MACROS_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :
diff --git a/src/include/source_date_epoch.h b/src/include/source_date_epoch.h
new file mode 100644
index 0000000..9080526
--- /dev/null
+++ b/src/include/source_date_epoch.h
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/** @file
+ * Functions to parse the "SOURCE_DATE_EPOCH" environment variable for reproducible build hacks, see
+ * https://reproducible-builds.org/docs/source-date-epoch/
+ *//*
+ * Authors:
+ * Patrick Storz <eduard.braun2@gmx.de>
+ *
+ * Copyright (C) 2019 Authors
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information.
+ */
+
+#ifndef SEEN_SOURCE_DATE_EPOCH
+#define SEEN_SOURCE_DATE_EPOCH
+
+#include <sstream>
+#include <iostream>
+#include <cstdlib>
+#include <ctime>
+
+namespace ReproducibleBuilds {
+
+/** parse current time from SOURCE_DATE_EPOCH environment variable
+ *
+ * \return current time (or zero if SOURCE_DATE_EPOCH unset)
+ */
+time_t now()
+{
+ time_t now = 0;
+
+ char *source_date_epoch = std::getenv("SOURCE_DATE_EPOCH");
+ if (source_date_epoch) {
+ std::istringstream iss(source_date_epoch);
+ iss >> now;
+ if (iss.fail() || !iss.eof()) {
+ std::cerr << "Error: Cannot parse SOURCE_DATE_EPOCH as integer\n";
+ exit(27);
+ }
+ }
+
+ return now;
+}
+
+/** like ReproducibleBuilds::now() but returns a ISO 8601 formatted string
+ *
+ * \return current time as ISO 8601 formatted string (or empty string if SOURCE_DATE_EPOCH unset)
+ */
+Glib::ustring now_iso_8601()
+{
+ Glib::ustring now_formatted;
+
+ time_t now = ReproducibleBuilds::now();
+ if (now) {
+ const tm *now_struct;
+ char buffer[25];
+
+ now_struct = gmtime(&now);
+ if (strftime(buffer, 25, "%Y-%m-%dT%H:%M:%S", now_struct)) {
+ now_formatted = buffer;
+ }
+ }
+
+ return now_formatted;
+}
+
+} // namespace ReproducibleBuilds
+
+#endif // SEEN_SOURCE_DATE_EPOCH