diff --git a/docs/reference/gio/gio-sections-common.txt b/docs/reference/gio/gio-sections-common.txt index 43da80c50..2f3973956 100644 --- a/docs/reference/gio/gio-sections-common.txt +++ b/docs/reference/gio/gio-sections-common.txt @@ -3366,6 +3366,8 @@ g_application_command_line_get_exit_status g_application_command_line_print g_application_command_line_printerr +g_application_command_line_print_literal +g_application_command_line_printerr_literal G_TYPE_APPLICATION_COMMAND_LINE G_APPLICATION_COMMAND_LINE diff --git a/gio/gapplicationcommandline.c b/gio/gapplicationcommandline.c index 44845f60e..1c8cbd3bf 100644 --- a/gio/gapplicationcommandline.c +++ b/gio/gapplicationcommandline.c @@ -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 diff --git a/gio/gapplicationcommandline.h b/gio/gapplicationcommandline.h index abb68526f..b6fdcd893 100644 --- a/gio/gapplicationcommandline.h +++ b/gio/gapplicationcommandline.h @@ -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,