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

'GI.Gio.Objects.ApplicationCommandLine.ApplicationCommandLine' represents a command-line invocation of
an application.  It is created by 'GI.Gio.Objects.Application.Application' and emitted
in the 'GI.Gio.Objects.Application.Application'::@/command-line/@ signal and virtual function.

The class contains the list of arguments that the program was invoked
with.  It is also possible to query if the commandline invocation was
local (ie: the current process is running in direct response to the
invocation) or remote (ie: some other process forwarded the
commandline to this process).

The GApplicationCommandLine object can provide the /@argc@/ and /@argv@/
parameters for use with the 'GI.GLib.Structs.OptionContext.OptionContext' command-line parsing API,
with the 'GI.Gio.Objects.ApplicationCommandLine.applicationCommandLineGetArguments' function. See
[gapplication-example-cmdline3.c][gapplication-example-cmdline3]
for an example.

The exit status of the originally-invoked process may be set and
messages can be printed to stdout or stderr of that process.  The
lifecycle of the originally-invoked process is tied to the lifecycle
of this object (ie: the process exits when the last reference is
dropped).

The main use for 'GI.Gio.Objects.ApplicationCommandLine.ApplicationCommandLine' (and the
'GI.Gio.Objects.Application.Application'::@/command-line/@ signal) is \'Emacs server\' like use cases:
You can set the @EDITOR@ environment variable to have e.g. git use
your favourite editor to edit commit messages, and if you already
have an instance of the editor running, the editing will happen
in the running instance, instead of opening a new one. An important
aspect of this use case is that the process that gets started by git
does not return until the editing is done.

Normally, the commandline is completely handled in the
'GI.Gio.Objects.Application.Application'::@/command-line/@ handler. The launching instance exits
once the signal handler in the primary instance has returned, and
the return value of the signal handler becomes the exit status
of the launching instance.

=== /C code/
>
>static int
>command_line (GApplication            *application,
>              GApplicationCommandLine *cmdline)
>{
>  gchar **argv;
>  gint argc;
>  gint i;
>
>  argv = g_application_command_line_get_arguments (cmdline, &argc);
>
>  g_application_command_line_print (cmdline,
>                                    "This text is written back\n"
>                                    "to stdout of the caller\n");
>
>  for (i = 0; i < argc; i++)
>    g_print ("argument %d: %s\n", i, argv[i]);
>
>  g_strfreev (argv);
>
>  return 0;
>}

The complete example can be found here:
<https://git.gnome.org/browse/glib/tree/gio/tests/gapplication-example-cmdline.c gapplication-example-cmdline.c>

In more complicated cases, the handling of the comandline can be
split between the launcher and the primary instance.

=== /C code/
>
>static gboolean
> test_local_cmdline (GApplication   *application,
>                     gchar        ***arguments,
>                     gint           *exit_status)
>{
>  gint i, j;
>  gchar **argv;
>
>  argv = *arguments;
>
>  i = 1;
>  while (argv[i])
>    {
>      if (g_str_has_prefix (argv[i], "--local-"))
>        {
>          g_print ("handling argument %s locally\n", argv[i]);
>          g_free (argv[i]);
>          for (j = i; argv[j]; j++)
>            argv[j] = argv[j + 1];
>        }
>      else
>        {
>          g_print ("not handling argument %s locally\n", argv[i]);
>          i++;
>        }
>    }
>
>  *exit_status = 0;
>
>  return FALSE;
>}
>
>static void
>test_application_class_init (TestApplicationClass *class)
>{
>  G_APPLICATION_CLASS (class)->local_command_line = test_local_cmdline;
>
>  ...
>}

In this example of split commandline handling, options that start
with @--local-@ are handled locally, all other options are passed
to the 'GI.Gio.Objects.Application.Application'::@/command-line/@ handler which runs in the primary
instance.

The complete example can be found here:
<https://git.gnome.org/browse/glib/tree/gio/tests/gapplication-example-cmdline2.c gapplication-example-cmdline2.c>

If handling the commandline requires a lot of work, it may
be better to defer it.

=== /C code/
>
>static gboolean
>my_cmdline_handler (gpointer data)
>{
>  GApplicationCommandLine *cmdline = data;
>
>  // do the heavy lifting in an idle
>
>  g_application_command_line_set_exit_status (cmdline, 0);
>  g_object_unref (cmdline); // this releases the application
>
>  return G_SOURCE_REMOVE;
>}
>
>static int
>command_line (GApplication            *application,
>              GApplicationCommandLine *cmdline)
>{
>  // keep the application running until we are done with this commandline
>  g_application_hold (application);
>
>  g_object_set_data_full (G_OBJECT (cmdline),
>                          "application", application,
>                          (GDestroyNotify)g_application_release);
>
>  g_object_ref (cmdline);
>  g_idle_add (my_cmdline_handler, cmdline);
>
>  return 0;
>}

In this example the commandline is not completely handled before
the 'GI.Gio.Objects.Application.Application'::@/command-line/@ handler returns. Instead, we keep
a reference to the 'GI.Gio.Objects.ApplicationCommandLine.ApplicationCommandLine' object and handle it
later (in this example, in an idle). Note that it is necessary to
hold the application until you are done with the commandline.

The complete example can be found here:
<https://git.gnome.org/browse/glib/tree/gio/tests/gapplication-example-cmdline3.c gapplication-example-cmdline3.c>
-}

#define ENABLE_OVERLOADING \
       (!defined(__HADDOCK_VERSION__))

module GI.Gio.Objects.ApplicationCommandLine
    ( 

-- * Exported types
    ApplicationCommandLine(..)              ,
    IsApplicationCommandLine                ,
    toApplicationCommandLine                ,
    noApplicationCommandLine                ,


 -- * Methods
-- ** createFileForArg #method:createFileForArg#

#if ENABLE_OVERLOADING
    ApplicationCommandLineCreateFileForArgMethodInfo,
#endif
    applicationCommandLineCreateFileForArg  ,


-- ** getArguments #method:getArguments#

#if ENABLE_OVERLOADING
    ApplicationCommandLineGetArgumentsMethodInfo,
#endif
    applicationCommandLineGetArguments      ,


-- ** getCwd #method:getCwd#

#if ENABLE_OVERLOADING
    ApplicationCommandLineGetCwdMethodInfo  ,
#endif
    applicationCommandLineGetCwd            ,


-- ** getEnviron #method:getEnviron#

#if ENABLE_OVERLOADING
    ApplicationCommandLineGetEnvironMethodInfo,
#endif
    applicationCommandLineGetEnviron        ,


-- ** getExitStatus #method:getExitStatus#

#if ENABLE_OVERLOADING
    ApplicationCommandLineGetExitStatusMethodInfo,
#endif
    applicationCommandLineGetExitStatus     ,


-- ** getIsRemote #method:getIsRemote#

#if ENABLE_OVERLOADING
    ApplicationCommandLineGetIsRemoteMethodInfo,
#endif
    applicationCommandLineGetIsRemote       ,


-- ** getOptionsDict #method:getOptionsDict#

#if ENABLE_OVERLOADING
    ApplicationCommandLineGetOptionsDictMethodInfo,
#endif
    applicationCommandLineGetOptionsDict    ,


-- ** getPlatformData #method:getPlatformData#

#if ENABLE_OVERLOADING
    ApplicationCommandLineGetPlatformDataMethodInfo,
#endif
    applicationCommandLineGetPlatformData   ,


-- ** getStdin #method:getStdin#

#if ENABLE_OVERLOADING
    ApplicationCommandLineGetStdinMethodInfo,
#endif
    applicationCommandLineGetStdin          ,


-- ** getenv #method:getenv#

#if ENABLE_OVERLOADING
    ApplicationCommandLineGetenvMethodInfo  ,
#endif
    applicationCommandLineGetenv            ,


-- ** setExitStatus #method:setExitStatus#

#if ENABLE_OVERLOADING
    ApplicationCommandLineSetExitStatusMethodInfo,
#endif
    applicationCommandLineSetExitStatus     ,




 -- * Properties
-- ** arguments #attr:arguments#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    ApplicationCommandLineArgumentsPropertyInfo,
#endif
#if ENABLE_OVERLOADING
    applicationCommandLineArguments         ,
#endif
    constructApplicationCommandLineArguments,


-- ** isRemote #attr:isRemote#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    ApplicationCommandLineIsRemotePropertyInfo,
#endif
#if ENABLE_OVERLOADING
    applicationCommandLineIsRemote          ,
#endif
    getApplicationCommandLineIsRemote       ,


-- ** options #attr:options#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    ApplicationCommandLineOptionsPropertyInfo,
#endif
#if ENABLE_OVERLOADING
    applicationCommandLineOptions           ,
#endif
    constructApplicationCommandLineOptions  ,


-- ** platformData #attr:platformData#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    ApplicationCommandLinePlatformDataPropertyInfo,
#endif
#if ENABLE_OVERLOADING
    applicationCommandLinePlatformData      ,
#endif
    constructApplicationCommandLinePlatformData,




    ) 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.GValue as B.GValue
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.GLib.Structs.VariantDict as GLib.VariantDict
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Interfaces.File as Gio.File
import {-# SOURCE #-} qualified GI.Gio.Objects.InputStream as Gio.InputStream

-- | Memory-managed wrapper type.
newtype ApplicationCommandLine = ApplicationCommandLine (ManagedPtr ApplicationCommandLine)
foreign import ccall "g_application_command_line_get_type"
    c_g_application_command_line_get_type :: IO GType

instance GObject ApplicationCommandLine where
    gobjectType :: ApplicationCommandLine -> IO GType
gobjectType _ = IO GType
c_g_application_command_line_get_type
    

-- | Type class for types which can be safely cast to `ApplicationCommandLine`, for instance with `toApplicationCommandLine`.
class GObject o => IsApplicationCommandLine o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError ApplicationCommandLine a) =>
    IsApplicationCommandLine a
#endif
instance IsApplicationCommandLine ApplicationCommandLine
instance GObject.Object.IsObject ApplicationCommandLine

-- | Cast to `ApplicationCommandLine`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toApplicationCommandLine :: (MonadIO m, IsApplicationCommandLine o) => o -> m ApplicationCommandLine
toApplicationCommandLine :: o -> m ApplicationCommandLine
toApplicationCommandLine = IO ApplicationCommandLine -> m ApplicationCommandLine
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ApplicationCommandLine -> m ApplicationCommandLine)
-> (o -> IO ApplicationCommandLine)
-> o
-> m ApplicationCommandLine
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr ApplicationCommandLine -> ApplicationCommandLine)
-> o -> IO ApplicationCommandLine
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr ApplicationCommandLine -> ApplicationCommandLine
ApplicationCommandLine

-- | A convenience alias for `Nothing` :: `Maybe` `ApplicationCommandLine`.
noApplicationCommandLine :: Maybe ApplicationCommandLine
noApplicationCommandLine :: Maybe ApplicationCommandLine
noApplicationCommandLine = Maybe ApplicationCommandLine
forall a. Maybe a
Nothing

#if ENABLE_OVERLOADING
type family ResolveApplicationCommandLineMethod (t :: Symbol) (o :: *) :: * where
    ResolveApplicationCommandLineMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveApplicationCommandLineMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveApplicationCommandLineMethod "createFileForArg" o = ApplicationCommandLineCreateFileForArgMethodInfo
    ResolveApplicationCommandLineMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveApplicationCommandLineMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveApplicationCommandLineMethod "getenv" o = ApplicationCommandLineGetenvMethodInfo
    ResolveApplicationCommandLineMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveApplicationCommandLineMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveApplicationCommandLineMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveApplicationCommandLineMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveApplicationCommandLineMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveApplicationCommandLineMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveApplicationCommandLineMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveApplicationCommandLineMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveApplicationCommandLineMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveApplicationCommandLineMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveApplicationCommandLineMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveApplicationCommandLineMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveApplicationCommandLineMethod "getArguments" o = ApplicationCommandLineGetArgumentsMethodInfo
    ResolveApplicationCommandLineMethod "getCwd" o = ApplicationCommandLineGetCwdMethodInfo
    ResolveApplicationCommandLineMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveApplicationCommandLineMethod "getEnviron" o = ApplicationCommandLineGetEnvironMethodInfo
    ResolveApplicationCommandLineMethod "getExitStatus" o = ApplicationCommandLineGetExitStatusMethodInfo
    ResolveApplicationCommandLineMethod "getIsRemote" o = ApplicationCommandLineGetIsRemoteMethodInfo
    ResolveApplicationCommandLineMethod "getOptionsDict" o = ApplicationCommandLineGetOptionsDictMethodInfo
    ResolveApplicationCommandLineMethod "getPlatformData" o = ApplicationCommandLineGetPlatformDataMethodInfo
    ResolveApplicationCommandLineMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveApplicationCommandLineMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveApplicationCommandLineMethod "getStdin" o = ApplicationCommandLineGetStdinMethodInfo
    ResolveApplicationCommandLineMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveApplicationCommandLineMethod "setExitStatus" o = ApplicationCommandLineSetExitStatusMethodInfo
    ResolveApplicationCommandLineMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveApplicationCommandLineMethod l o = O.MethodResolutionFailed l o

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

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

#endif

-- VVV Prop "arguments"
   -- Type: TVariant
   -- Flags: [PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

{- |
Construct a `GValueConstruct` with valid value for the “@arguments@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructApplicationCommandLineArguments :: (IsApplicationCommandLine o) => GVariant -> IO (GValueConstruct o)
constructApplicationCommandLineArguments :: GVariant -> IO (GValueConstruct o)
constructApplicationCommandLineArguments val :: GVariant
val = String -> Maybe GVariant -> IO (GValueConstruct o)
forall o. String -> Maybe GVariant -> IO (GValueConstruct o)
constructObjectPropertyVariant "arguments" (GVariant -> Maybe GVariant
forall a. a -> Maybe a
Just GVariant
val)

#if ENABLE_OVERLOADING
data ApplicationCommandLineArgumentsPropertyInfo
instance AttrInfo ApplicationCommandLineArgumentsPropertyInfo where
    type AttrAllowedOps ApplicationCommandLineArgumentsPropertyInfo = '[ 'AttrConstruct, 'AttrClear]
    type AttrSetTypeConstraint ApplicationCommandLineArgumentsPropertyInfo = (~) GVariant
    type AttrBaseTypeConstraint ApplicationCommandLineArgumentsPropertyInfo = IsApplicationCommandLine
    type AttrGetType ApplicationCommandLineArgumentsPropertyInfo = ()
    type AttrLabel ApplicationCommandLineArgumentsPropertyInfo = "arguments"
    type AttrOrigin ApplicationCommandLineArgumentsPropertyInfo = ApplicationCommandLine
    attrGet _ = undefined
    attrSet _ = undefined
    attrConstruct _ = constructApplicationCommandLineArguments
    attrClear _ = undefined
#endif

-- VVV Prop "is-remote"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

{- |
Get the value of the “@is-remote@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' applicationCommandLine #isRemote
@
-}
getApplicationCommandLineIsRemote :: (MonadIO m, IsApplicationCommandLine o) => o -> m Bool
getApplicationCommandLineIsRemote :: o -> m Bool
getApplicationCommandLineIsRemote obj :: o
obj = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Bool
forall a. GObject a => a -> String -> IO Bool
getObjectPropertyBool o
obj "is-remote"

#if ENABLE_OVERLOADING
data ApplicationCommandLineIsRemotePropertyInfo
instance AttrInfo ApplicationCommandLineIsRemotePropertyInfo where
    type AttrAllowedOps ApplicationCommandLineIsRemotePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint ApplicationCommandLineIsRemotePropertyInfo = (~) ()
    type AttrBaseTypeConstraint ApplicationCommandLineIsRemotePropertyInfo = IsApplicationCommandLine
    type AttrGetType ApplicationCommandLineIsRemotePropertyInfo = Bool
    type AttrLabel ApplicationCommandLineIsRemotePropertyInfo = "is-remote"
    type AttrOrigin ApplicationCommandLineIsRemotePropertyInfo = ApplicationCommandLine
    attrGet _ = getApplicationCommandLineIsRemote
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined
#endif

-- VVV Prop "options"
   -- Type: TVariant
   -- Flags: [PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

{- |
Construct a `GValueConstruct` with valid value for the “@options@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructApplicationCommandLineOptions :: (IsApplicationCommandLine o) => GVariant -> IO (GValueConstruct o)
constructApplicationCommandLineOptions :: GVariant -> IO (GValueConstruct o)
constructApplicationCommandLineOptions val :: GVariant
val = String -> Maybe GVariant -> IO (GValueConstruct o)
forall o. String -> Maybe GVariant -> IO (GValueConstruct o)
constructObjectPropertyVariant "options" (GVariant -> Maybe GVariant
forall a. a -> Maybe a
Just GVariant
val)

#if ENABLE_OVERLOADING
data ApplicationCommandLineOptionsPropertyInfo
instance AttrInfo ApplicationCommandLineOptionsPropertyInfo where
    type AttrAllowedOps ApplicationCommandLineOptionsPropertyInfo = '[ 'AttrConstruct, 'AttrClear]
    type AttrSetTypeConstraint ApplicationCommandLineOptionsPropertyInfo = (~) GVariant
    type AttrBaseTypeConstraint ApplicationCommandLineOptionsPropertyInfo = IsApplicationCommandLine
    type AttrGetType ApplicationCommandLineOptionsPropertyInfo = ()
    type AttrLabel ApplicationCommandLineOptionsPropertyInfo = "options"
    type AttrOrigin ApplicationCommandLineOptionsPropertyInfo = ApplicationCommandLine
    attrGet _ = undefined
    attrSet _ = undefined
    attrConstruct _ = constructApplicationCommandLineOptions
    attrClear _ = undefined
#endif

-- VVV Prop "platform-data"
   -- Type: TVariant
   -- Flags: [PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

{- |
Construct a `GValueConstruct` with valid value for the “@platform-data@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructApplicationCommandLinePlatformData :: (IsApplicationCommandLine o) => GVariant -> IO (GValueConstruct o)
constructApplicationCommandLinePlatformData :: GVariant -> IO (GValueConstruct o)
constructApplicationCommandLinePlatformData val :: GVariant
val = String -> Maybe GVariant -> IO (GValueConstruct o)
forall o. String -> Maybe GVariant -> IO (GValueConstruct o)
constructObjectPropertyVariant "platform-data" (GVariant -> Maybe GVariant
forall a. a -> Maybe a
Just GVariant
val)

#if ENABLE_OVERLOADING
data ApplicationCommandLinePlatformDataPropertyInfo
instance AttrInfo ApplicationCommandLinePlatformDataPropertyInfo where
    type AttrAllowedOps ApplicationCommandLinePlatformDataPropertyInfo = '[ 'AttrConstruct, 'AttrClear]
    type AttrSetTypeConstraint ApplicationCommandLinePlatformDataPropertyInfo = (~) GVariant
    type AttrBaseTypeConstraint ApplicationCommandLinePlatformDataPropertyInfo = IsApplicationCommandLine
    type AttrGetType ApplicationCommandLinePlatformDataPropertyInfo = ()
    type AttrLabel ApplicationCommandLinePlatformDataPropertyInfo = "platform-data"
    type AttrOrigin ApplicationCommandLinePlatformDataPropertyInfo = ApplicationCommandLine
    attrGet _ = undefined
    attrSet _ = undefined
    attrConstruct _ = constructApplicationCommandLinePlatformData
    attrClear _ = undefined
#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList ApplicationCommandLine
type instance O.AttributeList ApplicationCommandLine = ApplicationCommandLineAttributeList
type ApplicationCommandLineAttributeList = ('[ '("arguments", ApplicationCommandLineArgumentsPropertyInfo), '("isRemote", ApplicationCommandLineIsRemotePropertyInfo), '("options", ApplicationCommandLineOptionsPropertyInfo), '("platformData", ApplicationCommandLinePlatformDataPropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
applicationCommandLineArguments :: AttrLabelProxy "arguments"
applicationCommandLineArguments = AttrLabelProxy

applicationCommandLineIsRemote :: AttrLabelProxy "isRemote"
applicationCommandLineIsRemote = AttrLabelProxy

applicationCommandLineOptions :: AttrLabelProxy "options"
applicationCommandLineOptions = AttrLabelProxy

applicationCommandLinePlatformData :: AttrLabelProxy "platformData"
applicationCommandLinePlatformData = AttrLabelProxy

#endif

#if ENABLE_OVERLOADING
type instance O.SignalList ApplicationCommandLine = ApplicationCommandLineSignalList
type ApplicationCommandLineSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method ApplicationCommandLine::create_file_for_arg
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "cmdline", argType = TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GApplicationCommandLine", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "arg", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "an argument from @cmdline", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "File"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_application_command_line_create_file_for_arg" g_application_command_line_create_file_for_arg :: 
    Ptr ApplicationCommandLine ->           -- cmdline : TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"})
    CString ->                              -- arg : TBasicType TFileName
    IO (Ptr Gio.File.File)

{- |
Creates a 'GI.Gio.Interfaces.File.File' corresponding to a filename that was given as part
of the invocation of /@cmdline@/.

This differs from 'GI.Gio.Functions.fileNewForCommandlineArg' in that it
resolves relative pathnames using the current working directory of
the invoking process rather than the local process.

/Since: 2.36/
-}
applicationCommandLineCreateFileForArg ::
    (B.CallStack.HasCallStack, MonadIO m, IsApplicationCommandLine a) =>
    a
    {- ^ /@cmdline@/: a 'GI.Gio.Objects.ApplicationCommandLine.ApplicationCommandLine' -}
    -> [Char]
    {- ^ /@arg@/: an argument from /@cmdline@/ -}
    -> m Gio.File.File
    {- ^ __Returns:__ a new 'GI.Gio.Interfaces.File.File' -}
applicationCommandLineCreateFileForArg :: a -> String -> m File
applicationCommandLineCreateFileForArg cmdline :: a
cmdline arg :: String
arg = IO File -> m File
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO File -> m File) -> IO File -> m File
forall a b. (a -> b) -> a -> b
$ do
    Ptr ApplicationCommandLine
cmdline' <- a -> IO (Ptr ApplicationCommandLine)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
cmdline
    CString
arg' <- String -> IO CString
stringToCString String
arg
    Ptr File
result <- Ptr ApplicationCommandLine -> CString -> IO (Ptr File)
g_application_command_line_create_file_for_arg Ptr ApplicationCommandLine
cmdline' CString
arg'
    Text -> Ptr File -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "applicationCommandLineCreateFileForArg" Ptr File
result
    File
result' <- ((ManagedPtr File -> File) -> Ptr File -> IO File
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr File -> File
Gio.File.File) Ptr File
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
cmdline
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
arg'
    File -> IO File
forall (m :: * -> *) a. Monad m => a -> m a
return File
result'

#if ENABLE_OVERLOADING
data ApplicationCommandLineCreateFileForArgMethodInfo
instance (signature ~ ([Char] -> m Gio.File.File), MonadIO m, IsApplicationCommandLine a) => O.MethodInfo ApplicationCommandLineCreateFileForArgMethodInfo a signature where
    overloadedMethod _ = applicationCommandLineCreateFileForArg

#endif

-- method ApplicationCommandLine::get_arguments
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "cmdline", argType = TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GApplicationCommandLine", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "argc", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the arguments array, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : [Arg {argCName = "argc", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the arguments array, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- returnType : Just (TCArray False (-1) 1 (TBasicType TFileName))
-- throws : False
-- Skip return : False

foreign import ccall "g_application_command_line_get_arguments" g_application_command_line_get_arguments :: 
    Ptr ApplicationCommandLine ->           -- cmdline : TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"})
    Ptr Int32 ->                            -- argc : TBasicType TInt
    IO (Ptr CString)

{- |
Gets the list of arguments that was passed on the command line.

The strings in the array may contain non-UTF-8 data on UNIX (such as
filenames or arguments given in the system locale) but are always in
UTF-8 on Windows.

If you wish to use the return value with 'GI.GLib.Structs.OptionContext.OptionContext', you must
use 'GI.GLib.Structs.OptionContext.optionContextParseStrv'.

The return value is 'Nothing'-terminated and should be freed using
'GI.GLib.Functions.strfreev'.

/Since: 2.28/
-}
applicationCommandLineGetArguments ::
    (B.CallStack.HasCallStack, MonadIO m, IsApplicationCommandLine a) =>
    a
    {- ^ /@cmdline@/: a 'GI.Gio.Objects.ApplicationCommandLine.ApplicationCommandLine' -}
    -> m [[Char]]
    {- ^ __Returns:__ 
     the string array containing the arguments (the argv) -}
applicationCommandLineGetArguments :: a -> m [String]
applicationCommandLineGetArguments cmdline :: a
cmdline = IO [String] -> m [String]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [String] -> m [String]) -> IO [String] -> m [String]
forall a b. (a -> b) -> a -> b
$ do
    Ptr ApplicationCommandLine
cmdline' <- a -> IO (Ptr ApplicationCommandLine)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
cmdline
    Ptr Int32
argc <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    Ptr CString
result <- Ptr ApplicationCommandLine -> Ptr Int32 -> IO (Ptr CString)
g_application_command_line_get_arguments Ptr ApplicationCommandLine
cmdline' Ptr Int32
argc
    Int32
argc' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
argc
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "applicationCommandLineGetArguments" Ptr CString
result
    [String]
result' <- (Int32 -> Ptr CString -> IO [String]
forall a.
(HasCallStack, Integral a) =>
a -> Ptr CString -> IO [String]
unpackFileNameArrayWithLength Int32
argc') Ptr CString
result
    (Int32 -> (CString -> IO ()) -> Ptr CString -> IO ()
forall a b c.
(Storable a, Integral b) =>
b -> (a -> IO c) -> Ptr a -> IO ()
mapCArrayWithLength Int32
argc') CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
cmdline
    Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
argc
    [String] -> IO [String]
forall (m :: * -> *) a. Monad m => a -> m a
return [String]
result'

#if ENABLE_OVERLOADING
data ApplicationCommandLineGetArgumentsMethodInfo
instance (signature ~ (m [[Char]]), MonadIO m, IsApplicationCommandLine a) => O.MethodInfo ApplicationCommandLineGetArgumentsMethodInfo a signature where
    overloadedMethod _ = applicationCommandLineGetArguments

#endif

-- method ApplicationCommandLine::get_cwd
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "cmdline", argType = TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GApplicationCommandLine", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TFileName)
-- throws : False
-- Skip return : False

foreign import ccall "g_application_command_line_get_cwd" g_application_command_line_get_cwd :: 
    Ptr ApplicationCommandLine ->           -- cmdline : TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"})
    IO CString

{- |
Gets the working directory of the command line invocation.
The string may contain non-utf8 data.

It is possible that the remote application did not send a working
directory, so this may be 'Nothing'.

The return value should not be modified or freed and is valid for as
long as /@cmdline@/ exists.

/Since: 2.28/
-}
applicationCommandLineGetCwd ::
    (B.CallStack.HasCallStack, MonadIO m, IsApplicationCommandLine a) =>
    a
    {- ^ /@cmdline@/: a 'GI.Gio.Objects.ApplicationCommandLine.ApplicationCommandLine' -}
    -> m (Maybe [Char])
    {- ^ __Returns:__ the current directory, or 'Nothing' -}
applicationCommandLineGetCwd :: a -> m (Maybe String)
applicationCommandLineGetCwd cmdline :: a
cmdline = IO (Maybe String) -> m (Maybe String)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe String) -> m (Maybe String))
-> IO (Maybe String) -> m (Maybe String)
forall a b. (a -> b) -> a -> b
$ do
    Ptr ApplicationCommandLine
cmdline' <- a -> IO (Ptr ApplicationCommandLine)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
cmdline
    CString
result <- Ptr ApplicationCommandLine -> IO CString
g_application_command_line_get_cwd Ptr ApplicationCommandLine
cmdline'
    Maybe String
maybeResult <- CString -> (CString -> IO String) -> IO (Maybe String)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO String) -> IO (Maybe String))
-> (CString -> IO String) -> IO (Maybe String)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        String
result'' <- HasCallStack => CString -> IO String
CString -> IO String
cstringToString CString
result'
        String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
cmdline
    Maybe String -> IO (Maybe String)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe String
maybeResult

#if ENABLE_OVERLOADING
data ApplicationCommandLineGetCwdMethodInfo
instance (signature ~ (m (Maybe [Char])), MonadIO m, IsApplicationCommandLine a) => O.MethodInfo ApplicationCommandLineGetCwdMethodInfo a signature where
    overloadedMethod _ = applicationCommandLineGetCwd

#endif

-- method ApplicationCommandLine::get_environ
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "cmdline", argType = TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GApplicationCommandLine", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TCArray True (-1) (-1) (TBasicType TFileName))
-- throws : False
-- Skip return : False

foreign import ccall "g_application_command_line_get_environ" g_application_command_line_get_environ :: 
    Ptr ApplicationCommandLine ->           -- cmdline : TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"})
    IO (Ptr CString)

{- |
Gets the contents of the \'environ\' variable of the command line
invocation, as would be returned by 'GI.GLib.Functions.getEnviron', ie as a
'Nothing'-terminated list of strings in the form \'NAME=VALUE\'.
The strings may contain non-utf8 data.

The remote application usually does not send an environment.  Use
'GI.Gio.Flags.ApplicationFlagsSendEnvironment' to affect that.  Even with this flag
set it is possible that the environment is still not available (due
to invocation messages from other applications).

The return value should not be modified or freed and is valid for as
long as /@cmdline@/ exists.

See 'GI.Gio.Objects.ApplicationCommandLine.applicationCommandLineGetenv' if you are only interested
in the value of a single environment variable.

/Since: 2.28/
-}
applicationCommandLineGetEnviron ::
    (B.CallStack.HasCallStack, MonadIO m, IsApplicationCommandLine a) =>
    a
    {- ^ /@cmdline@/: a 'GI.Gio.Objects.ApplicationCommandLine.ApplicationCommandLine' -}
    -> m [[Char]]
    {- ^ __Returns:__ 
    the environment strings, or 'Nothing' if they were not sent -}
applicationCommandLineGetEnviron :: a -> m [String]
applicationCommandLineGetEnviron cmdline :: a
cmdline = IO [String] -> m [String]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [String] -> m [String]) -> IO [String] -> m [String]
forall a b. (a -> b) -> a -> b
$ do
    Ptr ApplicationCommandLine
cmdline' <- a -> IO (Ptr ApplicationCommandLine)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
cmdline
    Ptr CString
result <- Ptr ApplicationCommandLine -> IO (Ptr CString)
g_application_command_line_get_environ Ptr ApplicationCommandLine
cmdline'
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "applicationCommandLineGetEnviron" Ptr CString
result
    [String]
result' <- HasCallStack => Ptr CString -> IO [String]
Ptr CString -> IO [String]
unpackZeroTerminatedFileNameArray Ptr CString
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
cmdline
    [String] -> IO [String]
forall (m :: * -> *) a. Monad m => a -> m a
return [String]
result'

#if ENABLE_OVERLOADING
data ApplicationCommandLineGetEnvironMethodInfo
instance (signature ~ (m [[Char]]), MonadIO m, IsApplicationCommandLine a) => O.MethodInfo ApplicationCommandLineGetEnvironMethodInfo a signature where
    overloadedMethod _ = applicationCommandLineGetEnviron

#endif

-- method ApplicationCommandLine::get_exit_status
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "cmdline", argType = TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GApplicationCommandLine", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_application_command_line_get_exit_status" g_application_command_line_get_exit_status :: 
    Ptr ApplicationCommandLine ->           -- cmdline : TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"})
    IO Int32

{- |
Gets the exit status of /@cmdline@/.  See
'GI.Gio.Objects.ApplicationCommandLine.applicationCommandLineSetExitStatus' for more information.

/Since: 2.28/
-}
applicationCommandLineGetExitStatus ::
    (B.CallStack.HasCallStack, MonadIO m, IsApplicationCommandLine a) =>
    a
    {- ^ /@cmdline@/: a 'GI.Gio.Objects.ApplicationCommandLine.ApplicationCommandLine' -}
    -> m Int32
    {- ^ __Returns:__ the exit status -}
applicationCommandLineGetExitStatus :: a -> m Int32
applicationCommandLineGetExitStatus cmdline :: a
cmdline = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr ApplicationCommandLine
cmdline' <- a -> IO (Ptr ApplicationCommandLine)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
cmdline
    Int32
result <- Ptr ApplicationCommandLine -> IO Int32
g_application_command_line_get_exit_status Ptr ApplicationCommandLine
cmdline'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
cmdline
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result

#if ENABLE_OVERLOADING
data ApplicationCommandLineGetExitStatusMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsApplicationCommandLine a) => O.MethodInfo ApplicationCommandLineGetExitStatusMethodInfo a signature where
    overloadedMethod _ = applicationCommandLineGetExitStatus

#endif

-- method ApplicationCommandLine::get_is_remote
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "cmdline", argType = TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GApplicationCommandLine", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_application_command_line_get_is_remote" g_application_command_line_get_is_remote :: 
    Ptr ApplicationCommandLine ->           -- cmdline : TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"})
    IO CInt

{- |
Determines if /@cmdline@/ represents a remote invocation.

/Since: 2.28/
-}
applicationCommandLineGetIsRemote ::
    (B.CallStack.HasCallStack, MonadIO m, IsApplicationCommandLine a) =>
    a
    {- ^ /@cmdline@/: a 'GI.Gio.Objects.ApplicationCommandLine.ApplicationCommandLine' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the invocation was remote -}
applicationCommandLineGetIsRemote :: a -> m Bool
applicationCommandLineGetIsRemote cmdline :: a
cmdline = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr ApplicationCommandLine
cmdline' <- a -> IO (Ptr ApplicationCommandLine)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
cmdline
    CInt
result <- Ptr ApplicationCommandLine -> IO CInt
g_application_command_line_get_is_remote Ptr ApplicationCommandLine
cmdline'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
cmdline
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data ApplicationCommandLineGetIsRemoteMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsApplicationCommandLine a) => O.MethodInfo ApplicationCommandLineGetIsRemoteMethodInfo a signature where
    overloadedMethod _ = applicationCommandLineGetIsRemote

#endif

-- method ApplicationCommandLine::get_options_dict
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "cmdline", argType = TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GApplicationCommandLine", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "VariantDict"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_application_command_line_get_options_dict" g_application_command_line_get_options_dict :: 
    Ptr ApplicationCommandLine ->           -- cmdline : TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"})
    IO (Ptr GLib.VariantDict.VariantDict)

{- |
Gets the options there were passed to @/g_application_command_line()/@.

If you did not override @/local_command_line()/@ then these are the same
options that were parsed according to the @/GOptionEntrys/@ added to the
application with 'GI.Gio.Objects.Application.applicationAddMainOptionEntries' and possibly
modified from your GApplication::handle-local-options handler.

If no options were sent then an empty dictionary is returned so that
you don\'t need to check for 'Nothing'.

/Since: 2.40/
-}
applicationCommandLineGetOptionsDict ::
    (B.CallStack.HasCallStack, MonadIO m, IsApplicationCommandLine a) =>
    a
    {- ^ /@cmdline@/: a 'GI.Gio.Objects.ApplicationCommandLine.ApplicationCommandLine' -}
    -> m GLib.VariantDict.VariantDict
    {- ^ __Returns:__ a 'GI.GLib.Structs.VariantDict.VariantDict' with the options -}
applicationCommandLineGetOptionsDict :: a -> m VariantDict
applicationCommandLineGetOptionsDict cmdline :: a
cmdline = IO VariantDict -> m VariantDict
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO VariantDict -> m VariantDict)
-> IO VariantDict -> m VariantDict
forall a b. (a -> b) -> a -> b
$ do
    Ptr ApplicationCommandLine
cmdline' <- a -> IO (Ptr ApplicationCommandLine)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
cmdline
    Ptr VariantDict
result <- Ptr ApplicationCommandLine -> IO (Ptr VariantDict)
g_application_command_line_get_options_dict Ptr ApplicationCommandLine
cmdline'
    Text -> Ptr VariantDict -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "applicationCommandLineGetOptionsDict" Ptr VariantDict
result
    VariantDict
result' <- ((ManagedPtr VariantDict -> VariantDict)
-> Ptr VariantDict -> IO VariantDict
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr VariantDict -> VariantDict
GLib.VariantDict.VariantDict) Ptr VariantDict
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
cmdline
    VariantDict -> IO VariantDict
forall (m :: * -> *) a. Monad m => a -> m a
return VariantDict
result'

#if ENABLE_OVERLOADING
data ApplicationCommandLineGetOptionsDictMethodInfo
instance (signature ~ (m GLib.VariantDict.VariantDict), MonadIO m, IsApplicationCommandLine a) => O.MethodInfo ApplicationCommandLineGetOptionsDictMethodInfo a signature where
    overloadedMethod _ = applicationCommandLineGetOptionsDict

#endif

-- method ApplicationCommandLine::get_platform_data
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "cmdline", argType = TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GApplicationCommandLine", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just TVariant
-- throws : False
-- Skip return : False

foreign import ccall "g_application_command_line_get_platform_data" g_application_command_line_get_platform_data :: 
    Ptr ApplicationCommandLine ->           -- cmdline : TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"})
    IO (Ptr GVariant)

{- |
Gets the platform data associated with the invocation of /@cmdline@/.

This is a 'GVariant' dictionary containing information about the
context in which the invocation occurred.  It typically contains
information like the current working directory and the startup
notification ID.

For local invocation, it will be 'Nothing'.

/Since: 2.28/
-}
applicationCommandLineGetPlatformData ::
    (B.CallStack.HasCallStack, MonadIO m, IsApplicationCommandLine a) =>
    a
    {- ^ /@cmdline@/: 'GI.Gio.Objects.ApplicationCommandLine.ApplicationCommandLine' -}
    -> m (Maybe GVariant)
    {- ^ __Returns:__ the platform data, or 'Nothing' -}
applicationCommandLineGetPlatformData :: a -> m (Maybe GVariant)
applicationCommandLineGetPlatformData cmdline :: a
cmdline = IO (Maybe GVariant) -> m (Maybe GVariant)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe GVariant) -> m (Maybe GVariant))
-> IO (Maybe GVariant) -> m (Maybe GVariant)
forall a b. (a -> b) -> a -> b
$ do
    Ptr ApplicationCommandLine
cmdline' <- a -> IO (Ptr ApplicationCommandLine)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
cmdline
    Ptr GVariant
result <- Ptr ApplicationCommandLine -> IO (Ptr GVariant)
g_application_command_line_get_platform_data Ptr ApplicationCommandLine
cmdline'
    Maybe GVariant
maybeResult <- Ptr GVariant
-> (Ptr GVariant -> IO GVariant) -> IO (Maybe GVariant)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr GVariant
result ((Ptr GVariant -> IO GVariant) -> IO (Maybe GVariant))
-> (Ptr GVariant -> IO GVariant) -> IO (Maybe GVariant)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr GVariant
result' -> do
        GVariant
result'' <- Ptr GVariant -> IO GVariant
B.GVariant.wrapGVariantPtr Ptr GVariant
result'
        GVariant -> IO GVariant
forall (m :: * -> *) a. Monad m => a -> m a
return GVariant
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
cmdline
    Maybe GVariant -> IO (Maybe GVariant)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe GVariant
maybeResult

#if ENABLE_OVERLOADING
data ApplicationCommandLineGetPlatformDataMethodInfo
instance (signature ~ (m (Maybe GVariant)), MonadIO m, IsApplicationCommandLine a) => O.MethodInfo ApplicationCommandLineGetPlatformDataMethodInfo a signature where
    overloadedMethod _ = applicationCommandLineGetPlatformData

#endif

-- method ApplicationCommandLine::get_stdin
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "cmdline", argType = TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GApplicationCommandLine", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "InputStream"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_application_command_line_get_stdin" g_application_command_line_get_stdin :: 
    Ptr ApplicationCommandLine ->           -- cmdline : TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"})
    IO (Ptr Gio.InputStream.InputStream)

{- |
Gets the stdin of the invoking process.

The 'GI.Gio.Objects.InputStream.InputStream' can be used to read data passed to the standard
input of the invoking process.
This doesn\'t work on all platforms.  Presently, it is only available
on UNIX when using a DBus daemon capable of passing file descriptors.
If stdin is not available then 'Nothing' will be returned.  In the
future, support may be expanded to other platforms.

You must only call this function once per commandline invocation.

/Since: 2.34/
-}
applicationCommandLineGetStdin ::
    (B.CallStack.HasCallStack, MonadIO m, IsApplicationCommandLine a) =>
    a
    {- ^ /@cmdline@/: a 'GI.Gio.Objects.ApplicationCommandLine.ApplicationCommandLine' -}
    -> m Gio.InputStream.InputStream
    {- ^ __Returns:__ a 'GI.Gio.Objects.InputStream.InputStream' for stdin -}
applicationCommandLineGetStdin :: a -> m InputStream
applicationCommandLineGetStdin cmdline :: a
cmdline = IO InputStream -> m InputStream
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO InputStream -> m InputStream)
-> IO InputStream -> m InputStream
forall a b. (a -> b) -> a -> b
$ do
    Ptr ApplicationCommandLine
cmdline' <- a -> IO (Ptr ApplicationCommandLine)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
cmdline
    Ptr InputStream
result <- Ptr ApplicationCommandLine -> IO (Ptr InputStream)
g_application_command_line_get_stdin Ptr ApplicationCommandLine
cmdline'
    Text -> Ptr InputStream -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "applicationCommandLineGetStdin" Ptr InputStream
result
    InputStream
result' <- ((ManagedPtr InputStream -> InputStream)
-> Ptr InputStream -> IO InputStream
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr InputStream -> InputStream
Gio.InputStream.InputStream) Ptr InputStream
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
cmdline
    InputStream -> IO InputStream
forall (m :: * -> *) a. Monad m => a -> m a
return InputStream
result'

#if ENABLE_OVERLOADING
data ApplicationCommandLineGetStdinMethodInfo
instance (signature ~ (m Gio.InputStream.InputStream), MonadIO m, IsApplicationCommandLine a) => O.MethodInfo ApplicationCommandLineGetStdinMethodInfo a signature where
    overloadedMethod _ = applicationCommandLineGetStdin

#endif

-- method ApplicationCommandLine::getenv
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "cmdline", argType = TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GApplicationCommandLine", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TFileName, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the environment variable to get", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_application_command_line_getenv" g_application_command_line_getenv :: 
    Ptr ApplicationCommandLine ->           -- cmdline : TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"})
    CString ->                              -- name : TBasicType TFileName
    IO CString

{- |
Gets the value of a particular environment variable of the command
line invocation, as would be returned by 'GI.GLib.Functions.getenv'.  The strings may
contain non-utf8 data.

The remote application usually does not send an environment.  Use
'GI.Gio.Flags.ApplicationFlagsSendEnvironment' to affect that.  Even with this flag
set it is possible that the environment is still not available (due
to invocation messages from other applications).

The return value should not be modified or freed and is valid for as
long as /@cmdline@/ exists.

/Since: 2.28/
-}
applicationCommandLineGetenv ::
    (B.CallStack.HasCallStack, MonadIO m, IsApplicationCommandLine a) =>
    a
    {- ^ /@cmdline@/: a 'GI.Gio.Objects.ApplicationCommandLine.ApplicationCommandLine' -}
    -> [Char]
    {- ^ /@name@/: the environment variable to get -}
    -> m T.Text
    {- ^ __Returns:__ the value of the variable, or 'Nothing' if unset or unsent -}
applicationCommandLineGetenv :: a -> String -> m Text
applicationCommandLineGetenv cmdline :: a
cmdline name :: String
name = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr ApplicationCommandLine
cmdline' <- a -> IO (Ptr ApplicationCommandLine)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
cmdline
    CString
name' <- String -> IO CString
stringToCString String
name
    CString
result <- Ptr ApplicationCommandLine -> CString -> IO CString
g_application_command_line_getenv Ptr ApplicationCommandLine
cmdline' CString
name'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "applicationCommandLineGetenv" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
cmdline
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
name'
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'

#if ENABLE_OVERLOADING
data ApplicationCommandLineGetenvMethodInfo
instance (signature ~ ([Char] -> m T.Text), MonadIO m, IsApplicationCommandLine a) => O.MethodInfo ApplicationCommandLineGetenvMethodInfo a signature where
    overloadedMethod _ = applicationCommandLineGetenv

#endif

-- method ApplicationCommandLine::set_exit_status
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "cmdline", argType = TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GApplicationCommandLine", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "exit_status", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the exit status", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_application_command_line_set_exit_status" g_application_command_line_set_exit_status :: 
    Ptr ApplicationCommandLine ->           -- cmdline : TInterface (Name {namespace = "Gio", name = "ApplicationCommandLine"})
    Int32 ->                                -- exit_status : TBasicType TInt
    IO ()

{- |
Sets the exit status that will be used when the invoking process
exits.

The return value of the 'GI.Gio.Objects.Application.Application'::@/command-line/@ signal is
passed to this function when the handler returns.  This is the usual
way of setting the exit status.

In the event that you want the remote invocation to continue running
and want to decide on the exit status in the future, you can use this
call.  For the case of a remote invocation, the remote process will
typically exit when the last reference is dropped on /@cmdline@/.  The
exit status of the remote process will be equal to the last value
that was set with this function.

In the case that the commandline invocation is local, the situation
is slightly more complicated.  If the commandline invocation results
in the mainloop running (ie: because the use-count of the application
increased to a non-zero value) then the application is considered to
have been \'successful\' in a certain sense, and the exit status is
always zero.  If the application use count is zero, though, the exit
status of the local 'GI.Gio.Objects.ApplicationCommandLine.ApplicationCommandLine' is used.

/Since: 2.28/
-}
applicationCommandLineSetExitStatus ::
    (B.CallStack.HasCallStack, MonadIO m, IsApplicationCommandLine a) =>
    a
    {- ^ /@cmdline@/: a 'GI.Gio.Objects.ApplicationCommandLine.ApplicationCommandLine' -}
    -> Int32
    {- ^ /@exitStatus@/: the exit status -}
    -> m ()
applicationCommandLineSetExitStatus :: a -> Int32 -> m ()
applicationCommandLineSetExitStatus cmdline :: a
cmdline exitStatus :: Int32
exitStatus = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr ApplicationCommandLine
cmdline' <- a -> IO (Ptr ApplicationCommandLine)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
cmdline
    Ptr ApplicationCommandLine -> Int32 -> IO ()
g_application_command_line_set_exit_status Ptr ApplicationCommandLine
cmdline' Int32
exitStatus
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
cmdline
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if ENABLE_OVERLOADING
data ApplicationCommandLineSetExitStatusMethodInfo
instance (signature ~ (Int32 -> m ()), MonadIO m, IsApplicationCommandLine a) => O.MethodInfo ApplicationCommandLineSetExitStatusMethodInfo a signature where
    overloadedMethod _ = applicationCommandLineSetExitStatus

#endif