{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}

module GI.GtkSource.Objects.Tag
    ( 

-- * Exported types
    Tag(..)                                 ,
    IsTag                                   ,
    toTag                                   ,
    noTag                                   ,


 -- * Methods
-- ** new #method:new#
    tagNew                                  ,




 -- * Properties
-- ** drawSpaces #attr:drawSpaces#
    TagDrawSpacesPropertyInfo               ,
    constructTagDrawSpaces                  ,
    getTagDrawSpaces                        ,
    setTagDrawSpaces                        ,
    tagDrawSpaces                           ,


-- ** drawSpacesSet #attr:drawSpacesSet#
    TagDrawSpacesSetPropertyInfo            ,
    constructTagDrawSpacesSet               ,
    getTagDrawSpacesSet                     ,
    setTagDrawSpacesSet                     ,
    tagDrawSpacesSet                        ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gtk.Objects.TextTag as Gtk.TextTag

newtype Tag = Tag (ManagedPtr Tag)
foreign import ccall "gtk_source_tag_get_type"
    c_gtk_source_tag_get_type :: IO GType

instance GObject Tag where
    gobjectType _ = c_gtk_source_tag_get_type
    

class GObject o => IsTag o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Tag a) =>
    IsTag a
#endif
instance IsTag Tag
instance Gtk.TextTag.IsTextTag Tag
instance GObject.Object.IsObject Tag

toTag :: IsTag o => o -> IO Tag
toTag = unsafeCastTo Tag

noTag :: Maybe Tag
noTag = Nothing

type family ResolveTagMethod (t :: Symbol) (o :: *) :: * where
    ResolveTagMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveTagMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveTagMethod "changed" o = Gtk.TextTag.TextTagChangedMethodInfo
    ResolveTagMethod "event" o = Gtk.TextTag.TextTagEventMethodInfo
    ResolveTagMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveTagMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveTagMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveTagMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveTagMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveTagMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveTagMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveTagMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveTagMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveTagMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveTagMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveTagMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveTagMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveTagMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveTagMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveTagMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveTagMethod "getPriority" o = Gtk.TextTag.TextTagGetPriorityMethodInfo
    ResolveTagMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveTagMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveTagMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveTagMethod "setPriority" o = Gtk.TextTag.TextTagSetPriorityMethodInfo
    ResolveTagMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveTagMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveTagMethod t Tag, O.MethodInfo info Tag p) => O.IsLabelProxy t (Tag -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveTagMethod t Tag, O.MethodInfo info Tag p) => O.IsLabel t (Tag -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- VVV Prop "draw-spaces"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Nothing,Nothing)

getTagDrawSpaces :: (MonadIO m, IsTag o) => o -> m Bool
getTagDrawSpaces obj = liftIO $ getObjectPropertyBool obj "draw-spaces"

setTagDrawSpaces :: (MonadIO m, IsTag o) => o -> Bool -> m ()
setTagDrawSpaces obj val = liftIO $ setObjectPropertyBool obj "draw-spaces" val

constructTagDrawSpaces :: (IsTag o) => Bool -> IO (GValueConstruct o)
constructTagDrawSpaces val = constructObjectPropertyBool "draw-spaces" val

data TagDrawSpacesPropertyInfo
instance AttrInfo TagDrawSpacesPropertyInfo where
    type AttrAllowedOps TagDrawSpacesPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint TagDrawSpacesPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint TagDrawSpacesPropertyInfo = IsTag
    type AttrGetType TagDrawSpacesPropertyInfo = Bool
    type AttrLabel TagDrawSpacesPropertyInfo = "draw-spaces"
    type AttrOrigin TagDrawSpacesPropertyInfo = Tag
    attrGet _ = getTagDrawSpaces
    attrSet _ = setTagDrawSpaces
    attrConstruct _ = constructTagDrawSpaces
    attrClear _ = undefined

-- VVV Prop "draw-spaces-set"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Nothing,Nothing)

getTagDrawSpacesSet :: (MonadIO m, IsTag o) => o -> m Bool
getTagDrawSpacesSet obj = liftIO $ getObjectPropertyBool obj "draw-spaces-set"

setTagDrawSpacesSet :: (MonadIO m, IsTag o) => o -> Bool -> m ()
setTagDrawSpacesSet obj val = liftIO $ setObjectPropertyBool obj "draw-spaces-set" val

constructTagDrawSpacesSet :: (IsTag o) => Bool -> IO (GValueConstruct o)
constructTagDrawSpacesSet val = constructObjectPropertyBool "draw-spaces-set" val

data TagDrawSpacesSetPropertyInfo
instance AttrInfo TagDrawSpacesSetPropertyInfo where
    type AttrAllowedOps TagDrawSpacesSetPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint TagDrawSpacesSetPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint TagDrawSpacesSetPropertyInfo = IsTag
    type AttrGetType TagDrawSpacesSetPropertyInfo = Bool
    type AttrLabel TagDrawSpacesSetPropertyInfo = "draw-spaces-set"
    type AttrOrigin TagDrawSpacesSetPropertyInfo = Tag
    attrGet _ = getTagDrawSpacesSet
    attrSet _ = setTagDrawSpacesSet
    attrConstruct _ = constructTagDrawSpacesSet
    attrClear _ = undefined

instance O.HasAttributeList Tag
type instance O.AttributeList Tag = TagAttributeList
type TagAttributeList = ('[ '("accumulativeMargin", Gtk.TextTag.TextTagAccumulativeMarginPropertyInfo), '("background", Gtk.TextTag.TextTagBackgroundPropertyInfo), '("backgroundFullHeight", Gtk.TextTag.TextTagBackgroundFullHeightPropertyInfo), '("backgroundFullHeightSet", Gtk.TextTag.TextTagBackgroundFullHeightSetPropertyInfo), '("backgroundGdk", Gtk.TextTag.TextTagBackgroundGdkPropertyInfo), '("backgroundRgba", Gtk.TextTag.TextTagBackgroundRgbaPropertyInfo), '("backgroundSet", Gtk.TextTag.TextTagBackgroundSetPropertyInfo), '("direction", Gtk.TextTag.TextTagDirectionPropertyInfo), '("drawSpaces", TagDrawSpacesPropertyInfo), '("drawSpacesSet", TagDrawSpacesSetPropertyInfo), '("editable", Gtk.TextTag.TextTagEditablePropertyInfo), '("editableSet", Gtk.TextTag.TextTagEditableSetPropertyInfo), '("fallback", Gtk.TextTag.TextTagFallbackPropertyInfo), '("fallbackSet", Gtk.TextTag.TextTagFallbackSetPropertyInfo), '("family", Gtk.TextTag.TextTagFamilyPropertyInfo), '("familySet", Gtk.TextTag.TextTagFamilySetPropertyInfo), '("font", Gtk.TextTag.TextTagFontPropertyInfo), '("fontDesc", Gtk.TextTag.TextTagFontDescPropertyInfo), '("fontFeatures", Gtk.TextTag.TextTagFontFeaturesPropertyInfo), '("fontFeaturesSet", Gtk.TextTag.TextTagFontFeaturesSetPropertyInfo), '("foreground", Gtk.TextTag.TextTagForegroundPropertyInfo), '("foregroundGdk", Gtk.TextTag.TextTagForegroundGdkPropertyInfo), '("foregroundRgba", Gtk.TextTag.TextTagForegroundRgbaPropertyInfo), '("foregroundSet", Gtk.TextTag.TextTagForegroundSetPropertyInfo), '("indent", Gtk.TextTag.TextTagIndentPropertyInfo), '("indentSet", Gtk.TextTag.TextTagIndentSetPropertyInfo), '("invisible", Gtk.TextTag.TextTagInvisiblePropertyInfo), '("invisibleSet", Gtk.TextTag.TextTagInvisibleSetPropertyInfo), '("justification", Gtk.TextTag.TextTagJustificationPropertyInfo), '("justificationSet", Gtk.TextTag.TextTagJustificationSetPropertyInfo), '("language", Gtk.TextTag.TextTagLanguagePropertyInfo), '("languageSet", Gtk.TextTag.TextTagLanguageSetPropertyInfo), '("leftMargin", Gtk.TextTag.TextTagLeftMarginPropertyInfo), '("leftMarginSet", Gtk.TextTag.TextTagLeftMarginSetPropertyInfo), '("letterSpacing", Gtk.TextTag.TextTagLetterSpacingPropertyInfo), '("letterSpacingSet", Gtk.TextTag.TextTagLetterSpacingSetPropertyInfo), '("name", Gtk.TextTag.TextTagNamePropertyInfo), '("paragraphBackground", Gtk.TextTag.TextTagParagraphBackgroundPropertyInfo), '("paragraphBackgroundGdk", Gtk.TextTag.TextTagParagraphBackgroundGdkPropertyInfo), '("paragraphBackgroundRgba", Gtk.TextTag.TextTagParagraphBackgroundRgbaPropertyInfo), '("paragraphBackgroundSet", Gtk.TextTag.TextTagParagraphBackgroundSetPropertyInfo), '("pixelsAboveLines", Gtk.TextTag.TextTagPixelsAboveLinesPropertyInfo), '("pixelsAboveLinesSet", Gtk.TextTag.TextTagPixelsAboveLinesSetPropertyInfo), '("pixelsBelowLines", Gtk.TextTag.TextTagPixelsBelowLinesPropertyInfo), '("pixelsBelowLinesSet", Gtk.TextTag.TextTagPixelsBelowLinesSetPropertyInfo), '("pixelsInsideWrap", Gtk.TextTag.TextTagPixelsInsideWrapPropertyInfo), '("pixelsInsideWrapSet", Gtk.TextTag.TextTagPixelsInsideWrapSetPropertyInfo), '("rightMargin", Gtk.TextTag.TextTagRightMarginPropertyInfo), '("rightMarginSet", Gtk.TextTag.TextTagRightMarginSetPropertyInfo), '("rise", Gtk.TextTag.TextTagRisePropertyInfo), '("riseSet", Gtk.TextTag.TextTagRiseSetPropertyInfo), '("scale", Gtk.TextTag.TextTagScalePropertyInfo), '("scaleSet", Gtk.TextTag.TextTagScaleSetPropertyInfo), '("size", Gtk.TextTag.TextTagSizePropertyInfo), '("sizePoints", Gtk.TextTag.TextTagSizePointsPropertyInfo), '("sizeSet", Gtk.TextTag.TextTagSizeSetPropertyInfo), '("stretch", Gtk.TextTag.TextTagStretchPropertyInfo), '("stretchSet", Gtk.TextTag.TextTagStretchSetPropertyInfo), '("strikethrough", Gtk.TextTag.TextTagStrikethroughPropertyInfo), '("strikethroughRgba", Gtk.TextTag.TextTagStrikethroughRgbaPropertyInfo), '("strikethroughRgbaSet", Gtk.TextTag.TextTagStrikethroughRgbaSetPropertyInfo), '("strikethroughSet", Gtk.TextTag.TextTagStrikethroughSetPropertyInfo), '("style", Gtk.TextTag.TextTagStylePropertyInfo), '("styleSet", Gtk.TextTag.TextTagStyleSetPropertyInfo), '("tabs", Gtk.TextTag.TextTagTabsPropertyInfo), '("tabsSet", Gtk.TextTag.TextTagTabsSetPropertyInfo), '("underline", Gtk.TextTag.TextTagUnderlinePropertyInfo), '("underlineRgba", Gtk.TextTag.TextTagUnderlineRgbaPropertyInfo), '("underlineRgbaSet", Gtk.TextTag.TextTagUnderlineRgbaSetPropertyInfo), '("underlineSet", Gtk.TextTag.TextTagUnderlineSetPropertyInfo), '("variant", Gtk.TextTag.TextTagVariantPropertyInfo), '("variantSet", Gtk.TextTag.TextTagVariantSetPropertyInfo), '("weight", Gtk.TextTag.TextTagWeightPropertyInfo), '("weightSet", Gtk.TextTag.TextTagWeightSetPropertyInfo), '("wrapMode", Gtk.TextTag.TextTagWrapModePropertyInfo), '("wrapModeSet", Gtk.TextTag.TextTagWrapModeSetPropertyInfo)] :: [(Symbol, *)])

tagDrawSpaces :: AttrLabelProxy "drawSpaces"
tagDrawSpaces = AttrLabelProxy

tagDrawSpacesSet :: AttrLabelProxy "drawSpacesSet"
tagDrawSpacesSet = AttrLabelProxy

type instance O.SignalList Tag = TagSignalList
type TagSignalList = ('[ '("event", Gtk.TextTag.TextTagEventSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method Tag::new
-- method type : Constructor
-- Args : [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "tag name, or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GtkSource", name = "Tag"}))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_source_tag_new" gtk_source_tag_new :: 
    CString ->                              -- name : TBasicType TUTF8
    IO (Ptr Tag)

{- |
Creates a 'GI.GtkSource.Objects.Tag.Tag'. Configure the tag using object arguments,
i.e. using @/g_object_set()/@.

For usual cases, @/gtk_source_buffer_create_source_tag()/@ is more convenient to
use.

@since 3.20
-}
tagNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    {- ^ /@name@/: tag name, or 'Nothing'. -}
    -> m Tag
    {- ^ __Returns:__ a new 'GI.GtkSource.Objects.Tag.Tag'. -}
tagNew name = liftIO $ do
    maybeName <- case name of
        Nothing -> return nullPtr
        Just jName -> do
            jName' <- textToCString jName
            return jName'
    result <- gtk_source_tag_new maybeName
    checkUnexpectedReturnNULL "tagNew" result
    result' <- (wrapObject Tag) result
    freeMem maybeName
    return result'