GApplicationCommandLine: add print[err]_literal()

GJS (and likely other language bindigs relying on introspection)
can't use `g_application_command_line_print()`/`_printerr()`.
This commit is contained in:
Aleksandr Mezin 2023-10-18 00:50:11 +03:00
parent 6ad6180b3c
commit b9c90c3a3e
3 changed files with 57 additions and 0 deletions

View File

@ -3366,6 +3366,8 @@ g_application_command_line_get_exit_status
<SUBSECTION>
g_application_command_line_print
g_application_command_line_printerr
g_application_command_line_print_literal
g_application_command_line_printerr_literal
<SUBSECTION Standard>
G_TYPE_APPLICATION_COMMAND_LINE
G_APPLICATION_COMMAND_LINE

View File

@ -654,6 +654,54 @@ g_application_command_line_get_is_remote (GApplicationCommandLine *cmdline)
return IS_REMOTE (cmdline);
}
/**
* g_application_command_line_print_literal:
* @cmdline: a #GApplicationCommandLine
* @message: the message
*
* 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.
*
* Since: 2.80
**/
void
g_application_command_line_print_literal (GApplicationCommandLine *cmdline,
const gchar *message)
{
g_return_if_fail (G_IS_APPLICATION_COMMAND_LINE (cmdline));
g_return_if_fail (message != NULL);
G_APPLICATION_COMMAND_LINE_GET_CLASS (cmdline)
->print_literal (cmdline, message);
}
/**
* g_application_command_line_printerr_literal:
* @cmdline: a #GApplicationCommandLine
* @message: the message
*
* 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.
*
* Since: 2.80
**/
void
g_application_command_line_printerr_literal (GApplicationCommandLine *cmdline,
const gchar *message)
{
g_return_if_fail (G_IS_APPLICATION_COMMAND_LINE (cmdline));
g_return_if_fail (message != NULL);
G_APPLICATION_COMMAND_LINE_GET_CLASS (cmdline)
->printerr_literal (cmdline, message);
}
/**
* g_application_command_line_print:
* @cmdline: a #GApplicationCommandLine

View File

@ -97,6 +97,13 @@ const gchar * g_application_command_line_get_cwd (GApplic
GIO_AVAILABLE_IN_ALL
gboolean g_application_command_line_get_is_remote (GApplicationCommandLine *cmdline);
GIO_AVAILABLE_IN_2_80
void g_application_command_line_print_literal (GApplicationCommandLine *cmdline,
const gchar *message);
GIO_AVAILABLE_IN_2_80
void g_application_command_line_printerr_literal (GApplicationCommandLine *cmdline,
const gchar *message);
GIO_AVAILABLE_IN_ALL
void g_application_command_line_print (GApplicationCommandLine *cmdline,
const gchar *format,