// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gio import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" ) // The #GApplicationCommandLineClass-struct // contains private data only. type ApplicationCommandLineClass struct { _ structs.HostLayout ParentClass gobject.ObjectClass xPrintLiteral uintptr xPrinterrLiteral uintptr xGetStdin uintptr xDone uintptr Padding [10]uintptr } func (x *ApplicationCommandLineClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // OverridePrintLiteral sets the "print_literal" callback function. func (x *ApplicationCommandLineClass) OverridePrintLiteral(cb func(*ApplicationCommandLine, string)) { if cb == nil { x.xPrintLiteral = 0 } else { x.xPrintLiteral = purego.NewCallback(func(CmdlineVarp uintptr, MessageVarp string) { cb(ApplicationCommandLineNewFromInternalPtr(CmdlineVarp), MessageVarp) }) } } // GetPrintLiteral gets the "print_literal" callback function. func (x *ApplicationCommandLineClass) GetPrintLiteral() func(*ApplicationCommandLine, string) { if x.xPrintLiteral == 0 { return nil } var rawCallback func(CmdlineVarp uintptr, MessageVarp string) purego.RegisterFunc(&rawCallback, x.xPrintLiteral) return func(CmdlineVar *ApplicationCommandLine, MessageVar string) { rawCallback(CmdlineVar.GoPointer(), MessageVar) } } // OverridePrinterrLiteral sets the "printerr_literal" callback function. func (x *ApplicationCommandLineClass) OverridePrinterrLiteral(cb func(*ApplicationCommandLine, string)) { if cb == nil { x.xPrinterrLiteral = 0 } else { x.xPrinterrLiteral = purego.NewCallback(func(CmdlineVarp uintptr, MessageVarp string) { cb(ApplicationCommandLineNewFromInternalPtr(CmdlineVarp), MessageVarp) }) } } // GetPrinterrLiteral gets the "printerr_literal" callback function. func (x *ApplicationCommandLineClass) GetPrinterrLiteral() func(*ApplicationCommandLine, string) { if x.xPrinterrLiteral == 0 { return nil } var rawCallback func(CmdlineVarp uintptr, MessageVarp string) purego.RegisterFunc(&rawCallback, x.xPrinterrLiteral) return func(CmdlineVar *ApplicationCommandLine, MessageVar string) { rawCallback(CmdlineVar.GoPointer(), MessageVar) } } // OverrideGetStdin sets the "get_stdin" callback function. func (x *ApplicationCommandLineClass) OverrideGetStdin(cb func(*ApplicationCommandLine) *InputStream) { if cb == nil { x.xGetStdin = 0 } else { x.xGetStdin = purego.NewCallback(func(CmdlineVarp uintptr) uintptr { ret := cb(ApplicationCommandLineNewFromInternalPtr(CmdlineVarp)) if ret == nil { return 0 } return ret.GoPointer() }) } } // GetGetStdin gets the "get_stdin" callback function. func (x *ApplicationCommandLineClass) GetGetStdin() func(*ApplicationCommandLine) *InputStream { if x.xGetStdin == 0 { return nil } var rawCallback func(CmdlineVarp uintptr) uintptr purego.RegisterFunc(&rawCallback, x.xGetStdin) return func(CmdlineVar *ApplicationCommandLine) *InputStream { rawRet := rawCallback(CmdlineVar.GoPointer()) if rawRet == 0 { return nil } ret := &InputStream{} ret.Ptr = rawRet return ret } } // OverrideDone sets the "done" callback function. func (x *ApplicationCommandLineClass) OverrideDone(cb func(*ApplicationCommandLine)) { if cb == nil { x.xDone = 0 } else { x.xDone = purego.NewCallback(func(CmdlineVarp uintptr) { cb(ApplicationCommandLineNewFromInternalPtr(CmdlineVarp)) }) } } // GetDone gets the "done" callback function. func (x *ApplicationCommandLineClass) GetDone() func(*ApplicationCommandLine) { if x.xDone == 0 { return nil } var rawCallback func(CmdlineVarp uintptr) purego.RegisterFunc(&rawCallback, x.xDone) return func(CmdlineVar *ApplicationCommandLine) { rawCallback(CmdlineVar.GoPointer()) } } type ApplicationCommandLinePrivate struct { _ structs.HostLayout } func (x *ApplicationCommandLinePrivate) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // `GApplicationCommandLine` represents a command-line invocation of // an application. // // It is created by [class@Gio.Application] and emitted // in the [signal@Gio.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 [struct@GLib.OptionContext] command-line parsing API, // with the [method@Gio.ApplicationCommandLine.get_arguments] function. See // [gapplication-example-cmdline3.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gapplication-example-cmdline3.c) // 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. // // For remote invocation, the originally-invoked process exits when // [method@Gio.ApplicationCommandLine.done] method is called. This method is // also automatically called when the object is disposed. // // The main use for `GApplicationCommandLine` (and the // [signal@Gio.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 // [signal@Gio.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 // 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: // [gapplication-example-cmdline.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gapplication-example-cmdline.c) // // In more complicated cases, the handling of the commandline can be // split between the launcher and the primary instance. // // ```c // static gboolean // // test_local_cmdline (GApplication *application, // gchar ***arguments, // gint *exit_status) // // { // gint i, j; // gchar **argv; // // argv = *arguments; // // if (argv[0] == NULL) // { // *exit_status = 0; // return FALSE; // } // // 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 [signal@Gio.Application::command-line] handler which runs in the primary // instance. // // The complete example can be found here: // [gapplication-example-cmdline2.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gapplication-example-cmdline2.c) // // If handling the commandline requires a lot of work, it may be better to defer it. // // ```c // 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 [signal@Gio.Application::command-line] handler returns. Instead, we keep // a reference to the `GApplicationCommandLine` 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: // [gapplication-example-cmdline3.c](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/gio/tests/gapplication-example-cmdline3.c) type ApplicationCommandLine struct { gobject.Object } var xApplicationCommandLineGLibType func() types.GType func ApplicationCommandLineGLibType() types.GType { return xApplicationCommandLineGLibType() } func ApplicationCommandLineNewFromInternalPtr(ptr uintptr) *ApplicationCommandLine { cls := &ApplicationCommandLine{} cls.Ptr = ptr return cls } var xApplicationCommandLineCreateFileForArg func(uintptr, string) uintptr // Creates a #GFile corresponding to a filename that was given as part // of the invocation of @cmdline. // // This differs from g_file_new_for_commandline_arg() in that it // resolves relative pathnames using the current working directory of // the invoking process rather than the local process. func (x *ApplicationCommandLine) CreateFileForArg(ArgVar string) *FileBase { var cls *FileBase cret := xApplicationCommandLineCreateFileForArg(x.GoPointer(), ArgVar) if cret == 0 { return nil } cls = &FileBase{} cls.Ptr = cret return cls } var xApplicationCommandLineDone func(uintptr) // Signals that command line processing is completed. // // For remote invocation, it causes the invoking process to terminate. // // For local invocation, it does nothing. // // This method should be called in the [signal@Gio.Application::command-line] // handler, after the exit status is set and all messages are printed. // // After this call, g_application_command_line_set_exit_status() has no effect. // Subsequent calls to this method are no-ops. // // This method is automatically called when the #GApplicationCommandLine // object is disposed — so you can omit the call in non-garbage collected // languages. func (x *ApplicationCommandLine) Done() { xApplicationCommandLineDone(x.GoPointer()) } var xApplicationCommandLineGetArguments func(uintptr, *int) []string // 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 #GOptionContext, you must // use g_option_context_parse_strv(). // // The return value is %NULL-terminated and should be freed using // g_strfreev(). func (x *ApplicationCommandLine) GetArguments(ArgcVar *int) []string { cret := xApplicationCommandLineGetArguments(x.GoPointer(), ArgcVar) return cret } var xApplicationCommandLineGetCwd func(uintptr) string // 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 %NULL. // // The return value should not be modified or freed and is valid for as // long as @cmdline exists. func (x *ApplicationCommandLine) GetCwd() string { cret := xApplicationCommandLineGetCwd(x.GoPointer()) return cret } var xApplicationCommandLineGetEnviron func(uintptr) []string // Gets the contents of the 'environ' variable of the command line // invocation, as would be returned by g_get_environ(), ie as a // %NULL-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 // %G_APPLICATION_SEND_ENVIRONMENT 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 g_application_command_line_getenv() if you are only interested // in the value of a single environment variable. func (x *ApplicationCommandLine) GetEnviron() []string { cret := xApplicationCommandLineGetEnviron(x.GoPointer()) return cret } var xApplicationCommandLineGetExitStatus func(uintptr) int // Gets the exit status of @cmdline. See // g_application_command_line_set_exit_status() for more information. func (x *ApplicationCommandLine) GetExitStatus() int { cret := xApplicationCommandLineGetExitStatus(x.GoPointer()) return cret } var xApplicationCommandLineGetIsRemote func(uintptr) bool // Determines if @cmdline represents a remote invocation. func (x *ApplicationCommandLine) GetIsRemote() bool { cret := xApplicationCommandLineGetIsRemote(x.GoPointer()) return cret } var xApplicationCommandLineGetOptionsDict func(uintptr) *glib.VariantDict // Gets the options that 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 g_application_add_main_option_entries() 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 %NULL. // // The data has been passed via an untrusted external process, so the types of // all values must be checked before being used. func (x *ApplicationCommandLine) GetOptionsDict() *glib.VariantDict { cret := xApplicationCommandLineGetOptionsDict(x.GoPointer()) return cret } var xApplicationCommandLineGetPlatformData func(uintptr) *glib.Variant // 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. // // It comes from an untrusted external process and hence the types of all // values must be validated before being used. // // For local invocation, it will be %NULL. func (x *ApplicationCommandLine) GetPlatformData() *glib.Variant { cret := xApplicationCommandLineGetPlatformData(x.GoPointer()) return cret } var xApplicationCommandLineGetStdin func(uintptr) uintptr // Gets the stdin of the invoking process. // // The #GInputStream 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 D-Bus daemon capable of passing file descriptors. // If stdin is not available then %NULL will be returned. In the // future, support may be expanded to other platforms. // // You must only call this function once per commandline invocation. func (x *ApplicationCommandLine) GetStdin() *InputStream { var cls *InputStream cret := xApplicationCommandLineGetStdin(x.GoPointer()) if cret == 0 { return nil } cls = &InputStream{} cls.Ptr = cret return cls } var xApplicationCommandLineGetenv func(uintptr, string) string // Gets the value of a particular environment variable of the command // line invocation, as would be returned by g_getenv(). The strings may // contain non-utf8 data. // // The remote application usually does not send an environment. Use // %G_APPLICATION_SEND_ENVIRONMENT 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. func (x *ApplicationCommandLine) Getenv(NameVar string) string { cret := xApplicationCommandLineGetenv(x.GoPointer(), NameVar) return cret } var xApplicationCommandLinePrint func(uintptr, string, ...interface{}) // Formats a message and prints it using the stdout print handler in the // invoking process. // // If @cmdline is a local invocation then this is exactly equivalent to // g_print(). If @cmdline is remote then this is equivalent to calling // g_print() in the invoking process. func (x *ApplicationCommandLine) Print(FormatVar string, varArgs ...interface{}) { xApplicationCommandLinePrint(x.GoPointer(), FormatVar, varArgs...) } var xApplicationCommandLinePrintLiteral func(uintptr, string) // Prints a message using the stdout print handler in the invoking process. // // Unlike g_application_command_line_print(), @message is not a `printf()`-style // format string. Use this function if @message contains text you don't have // control over, that could include `printf()` escape sequences. func (x *ApplicationCommandLine) PrintLiteral(MessageVar string) { xApplicationCommandLinePrintLiteral(x.GoPointer(), MessageVar) } var xApplicationCommandLinePrinterr func(uintptr, string, ...interface{}) // Formats a message and prints it using the stderr print handler in the // invoking process. // // If @cmdline is a local invocation then this is exactly equivalent to // g_printerr(). If @cmdline is remote then this is equivalent to // calling g_printerr() in the invoking process. func (x *ApplicationCommandLine) Printerr(FormatVar string, varArgs ...interface{}) { xApplicationCommandLinePrinterr(x.GoPointer(), FormatVar, varArgs...) } var xApplicationCommandLinePrinterrLiteral func(uintptr, string) // Prints a message using the stderr print handler in the invoking process. // // Unlike g_application_command_line_printerr(), @message is not // a `printf()`-style format string. Use this function if @message contains text // you don't have control over, that could include `printf()` escape sequences. func (x *ApplicationCommandLine) PrinterrLiteral(MessageVar string) { xApplicationCommandLinePrinterrLiteral(x.GoPointer(), MessageVar) } var xApplicationCommandLineSetExitStatus func(uintptr, int) // Sets the exit status that will be used when the invoking process // exits. // // The return value of the #GApplication::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 #GApplicationCommandLine is used. // // This method is a no-op if g_application_command_line_done() has // been called. func (x *ApplicationCommandLine) SetExitStatus(ExitStatusVar int) { xApplicationCommandLineSetExitStatus(x.GoPointer(), ExitStatusVar) } func (c *ApplicationCommandLine) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *ApplicationCommandLine) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // SetPropertyArguments sets the "arguments" property. // The commandline that caused this [signal@Gio.Application::command-line] // signal emission. func (x *ApplicationCommandLine) SetPropertyArguments(value uintptr) { var v gobject.Value v.Init(gobject.TypePointerVal) v.SetPointer(value) x.SetProperty("arguments", &v) } // GetPropertyIsRemote gets the "is-remote" property. // Whether this is a remote commandline. func (x *ApplicationCommandLine) GetPropertyIsRemote() bool { var v gobject.Value x.GetProperty("is-remote", &v) return v.GetBoolean() } // SetPropertyOptions sets the "options" property. // The options sent along with the commandline. func (x *ApplicationCommandLine) SetPropertyOptions(value uintptr) { var v gobject.Value v.Init(gobject.TypePointerVal) v.SetPointer(value) x.SetProperty("options", &v) } // SetPropertyPlatformData sets the "platform-data" property. // Platform-specific data for the commandline. func (x *ApplicationCommandLine) SetPropertyPlatformData(value uintptr) { var v gobject.Value v.Init(gobject.TypePointerVal) v.SetPointer(value) x.SetProperty("platform-data", &v) } func init() { core.SetPackageName("GIO", "gio-2.0") core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"}) var libs []uintptr for _, libPath := range core.GetPaths("GIO") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xApplicationCommandLineGLibType, libs, "g_application_command_line_get_type") core.PuregoSafeRegister(&xApplicationCommandLineCreateFileForArg, libs, "g_application_command_line_create_file_for_arg") core.PuregoSafeRegister(&xApplicationCommandLineDone, libs, "g_application_command_line_done") core.PuregoSafeRegister(&xApplicationCommandLineGetArguments, libs, "g_application_command_line_get_arguments") core.PuregoSafeRegister(&xApplicationCommandLineGetCwd, libs, "g_application_command_line_get_cwd") core.PuregoSafeRegister(&xApplicationCommandLineGetEnviron, libs, "g_application_command_line_get_environ") core.PuregoSafeRegister(&xApplicationCommandLineGetExitStatus, libs, "g_application_command_line_get_exit_status") core.PuregoSafeRegister(&xApplicationCommandLineGetIsRemote, libs, "g_application_command_line_get_is_remote") core.PuregoSafeRegister(&xApplicationCommandLineGetOptionsDict, libs, "g_application_command_line_get_options_dict") core.PuregoSafeRegister(&xApplicationCommandLineGetPlatformData, libs, "g_application_command_line_get_platform_data") core.PuregoSafeRegister(&xApplicationCommandLineGetStdin, libs, "g_application_command_line_get_stdin") core.PuregoSafeRegister(&xApplicationCommandLineGetenv, libs, "g_application_command_line_getenv") core.PuregoSafeRegister(&xApplicationCommandLinePrint, libs, "g_application_command_line_print") core.PuregoSafeRegister(&xApplicationCommandLinePrintLiteral, libs, "g_application_command_line_print_literal") core.PuregoSafeRegister(&xApplicationCommandLinePrinterr, libs, "g_application_command_line_printerr") core.PuregoSafeRegister(&xApplicationCommandLinePrinterrLiteral, libs, "g_application_command_line_printerr_literal") core.PuregoSafeRegister(&xApplicationCommandLineSetExitStatus, libs, "g_application_command_line_set_exit_status") }