[vte] widget: Add API to get features as flags



commit e28f1d50c07605bb0deaec70a46f520b621a9bff
Author: Christian Persch <chpe src gnome org>
Date:   Sat Aug 8 21:55:09 2020 +0200

    widget: Add API to get features as flags
    
    This will be used in gnome-terminal to hide UI that's not functional
    due to VTE being compiled without that feature.

 doc/reference/vte-sections.txt |  2 ++
 src/vte/vteenums.h             | 21 ++++++++++++++++++++-
 src/vte/vteglobals.h           |  4 ++++
 src/vtegtk.cc                  | 30 ++++++++++++++++++++++++++++++
 4 files changed, 56 insertions(+), 1 deletion(-)
---
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
index c402b447..28c1c958 100644
--- a/doc/reference/vte-sections.txt
+++ b/doc/reference/vte-sections.txt
@@ -95,8 +95,10 @@ vte_terminal_event_check_regex_array
 vte_terminal_event_check_regex_simple
 
 <SUBSECTION>
+VteFeatureFlags
 vte_get_user_shell
 vte_get_features
+vte_get_feature_flags
 vte_get_encodings
 vte_get_encoding_supported
 
diff --git a/src/vte/vteenums.h b/src/vte/vteenums.h
index 84d07a0d..fac22520 100644
--- a/src/vte/vteenums.h
+++ b/src/vte/vteenums.h
@@ -167,7 +167,7 @@ typedef enum {
  * @VTE_FORMAT_TEXT: Export as plain text
  * @VTE_FORMAT_HTML: Export as HTML formatted text
  *
- * An enumeratio type that can be used to specify the format the selection
+ * An enumeration type that can be used to specify the format the selection
  * should be copied to the clipboard in.
  *
  * Since: 0.50
@@ -177,6 +177,25 @@ typedef enum {
         VTE_FORMAT_HTML = 2
 } VteFormat;
 
+/**
+ * VteFeatureFlags:
+ * @VTE_FEATURE_FLAG_BIDI: whether VTE was built with bidirectional text support
+ * @VTE_FEATURE_FLAG_ICU: whether VTE was built with ICU support
+ * @VTE_FEATURE_FLAG_SYSTEMD: whether VTE was built with systemd support
+ * @VTE_FEATURE_FLAG_SIXEL: whether VTE was built with SIXEL support
+ *
+ * An enumeration type for features.
+ *
+ * Since: 0.62
+ */
+typedef enum /*< skip >*/ {
+        VTE_FEATURE_FLAG_BIDI    = 1ULL << 0,
+        VTE_FEATURE_FLAG_ICU     = 1ULL << 1,
+        VTE_FEATURE_FLAG_SYSTEMD = 1ULL << 2,
+        VTE_FEATURE_FLAG_SIXEL   = 1ULL << 3,
+        VTE_FEATURE_FLAGS_MASK   = 0xFFFFFFFFFFFFFFFFULL, /* force enum to 64 bit */
+} VteFeatureFlags;
+
 G_END_DECLS
 
 #endif /* __VTE_VTE_ENUMS_H__ */
diff --git a/src/vte/vteglobals.h b/src/vte/vteglobals.h
index 34b44bfb..cf7957b5 100644
--- a/src/vte/vteglobals.h
+++ b/src/vte/vteglobals.h
@@ -22,6 +22,7 @@
 #include <glib.h>
 
 #include "vtemacros.h"
+#include "vteenums.h"
 
 G_BEGIN_DECLS
 
@@ -31,6 +32,9 @@ char *vte_get_user_shell(void) _VTE_CXX_NOEXCEPT;
 _VTE_PUBLIC
 const char *vte_get_features (void) _VTE_CXX_NOEXCEPT;
 
+_VTE_PUBLIC
+VteFeatureFlags vte_get_feature_flags(void) _VTE_CXX_NOEXCEPT;
+
 #define VTE_TEST_FLAGS_NONE (G_GUINT64_CONSTANT(0))
 #define VTE_TEST_FLAGS_ALL (~G_GUINT64_CONSTANT(0))
 
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index 2ce55a26..5fcae132 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -2083,6 +2083,36 @@ vte_get_features (void) noexcept
                 ;
 }
 
+/**
+ * vte_get_feature_flags:
+ *
+ * Gets features VTE was compiled with.
+ *
+ * Returns: (transfer none): flags from #VteFeatureFlags
+ *
+ * Since: 0.62
+ */
+VteFeatureFlags
+vte_get_feature_flags(void) noexcept
+{
+        return VteFeatureFlags(0ULL |
+#ifdef WITH_FRIBIDI
+                               VTE_FEATURE_FLAG_BIDI |
+#endif
+#ifdef WITH_ICU
+                               VTE_FEATURE_FLAG_ICU |
+#endif
+#ifdef WITH_SIXEL
+                               VTE_FEATURE_FLAG_SIXEL |
+#endif
+#ifdef __linux__
+#ifdef WITH_SYSTEMD
+                               VTE_FEATURE_FLAG_SYSTEMD |
+#endif
+#endif // __linux__
+                               0ULL);
+}
+
 /**
  * vte_get_major_version:
  *


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