1
+ {-# LANGUAGE CPP #-}
2
+
3
+ -- | This module contains two things:
4
+ --
5
+ -- 1. Extension functions to libraries like GTK. These functions wrap up some
6
+ -- generic GTK functionality. They are not Termonad-specific.
7
+ --
8
+ -- 2. Wrappers around functionality that is only specific to certain versions
9
+ -- of libraries like GTK or VTE.
10
+ --
11
+ -- For instance, 'terminalSetEnableSixelIfExists' is
12
+ -- a wrapper around 'terminalSetEnableSixel'. Sixel support is only availble in
13
+ -- vte >= 0.63, so if a user tries to compile Termonad with a version of vte
14
+ -- less than 0.63, this function won't do anything.
15
+
1
16
module Termonad.Gtk where
2
17
3
18
import Termonad.Prelude
@@ -12,6 +27,12 @@ import GI.Gdk
12
27
import GI.Gio (ApplicationFlags )
13
28
import GI.Gtk (Application , IsWidget , Widget (Widget ), applicationNew , builderGetObject , toWidget )
14
29
import qualified GI.Gtk as Gtk
30
+ import GI.Vte
31
+ ( IsTerminal
32
+ #ifdef VTE_VERSION_GEQ_0_63
33
+ , terminalSetEnableSixel
34
+ #endif
35
+ )
15
36
16
37
17
38
objFromBuildUnsafe ::
@@ -58,3 +79,17 @@ widgetEq a b = do
58
79
withManagedPtr managedPtrA $ \ ptrA ->
59
80
withManagedPtr managedPtrB $ \ ptrB ->
60
81
pure (ptrA == ptrB)
82
+
83
+ -- | Wrapper around 'terminalSetEnableSixel'. The 'terminalSetEnableSixel' function
84
+ -- is only available starting with vte-0.63. This function has no effect when
85
+ -- compiling against previous versions of vte.
86
+ terminalSetEnableSixelIfExists
87
+ :: (HasCallStack , MonadIO m , IsTerminal t )
88
+ => t -- ^ a Terminal
89
+ -> Bool -- ^ whether to enable SIXEL images
90
+ -> m ()
91
+ terminalSetEnableSixelIfExists t b = do
92
+ #ifdef VTE_VERSION_GEQ_0_63
93
+ terminalSetEnableSixel t b
94
+ #endif
95
+ pure ()
0 commit comments