Commit 27f5e542 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

accept printf-style format strings.

2006-10-09  Sven Neumann  <sven@gimp.org>

	* app/dialogs/tips-parser.[ch]: accept printf-style format strings.

	* app/dialogs/tips-dialog.c: avoid markup in translatable messages
	(bug #360458).
parent f5afb754
2006-10-09 Sven Neumann <sven@gimp.org>
* app/dialogs/tips-parser.[ch]: accept printf-style format strings.
* app/dialogs/tips-dialog.c: avoid markup in translatable messages
(bug #360458).
2006-10-09 Michael Natterer <mitch@gimp.org>
 
Added message severities and make sure all messages are routed
......
......@@ -79,22 +79,23 @@ tips_dialog_create (Gimp *gimp)
tips = gimp_tips_from_file (filename, &error);
if (!tips)
if (! tips)
{
GimpTip *tip;
if (error->code == G_FILE_ERROR_NOENT)
{
tip = gimp_tip_new (_("<b>Your GIMP tips file appears to be missing!</b>"),
NULL);
tip->thetip = g_strdup_printf (_("There should be a file called '%s'. "
"Please check your installation."),
filename);
tip = gimp_tip_new ("<b>%s</b>",
_("Your GIMP tips file appears to be missing!"));
gimp_tip_set (tip,
_("There should be a file called '%s'. "
"Please check your installation."), filename);
}
else
{
tip = gimp_tip_new (_("<b>The GIMP tips file could not be parsed!</b>"),
error->message);
tip = gimp_tip_new ("<b>%s</b>",
_("The GIMP tips file could not be parsed!"));
gimp_tip_set (tip, "%s", error->message);
}
tips = g_list_prepend (tips, tip);
......
......@@ -106,21 +106,47 @@ static const GMarkupParser markup_parser =
GimpTip *
gimp_tip_new (const gchar *welcome,
const gchar *thetip)
gimp_tip_new (const gchar *format,
...)
{
GimpTip *tip = g_new (GimpTip, 1);
GimpTip *tip;
va_list args;
tip->welcome = welcome ? g_strdup (welcome) : NULL;
tip->thetip = thetip ? g_strdup (thetip) : NULL;
g_return_val_if_fail (format != NULL, NULL);
tip = g_new0 (GimpTip, 1);
va_start (args, format);
tip->welcome = g_strdup_vprintf (format, args);
va_end (args);
return tip;
}
void
gimp_tip_set (GimpTip *tip,
const gchar *format,
...)
{
va_list args;
g_return_if_fail (tip != NULL);
g_return_if_fail (format != NULL);
va_start (args, format);
g_free (tip->thetip);
tip->thetip = g_strdup_vprintf (format, args);
va_end (args);
}
void
gimp_tip_free (GimpTip *tip)
{
if (!tip)
if (! tip)
return;
g_free (tip->welcome);
......
......@@ -32,8 +32,11 @@ struct _GimpTip
};
GimpTip * gimp_tip_new (const gchar *welcome,
const gchar *thetip);
GimpTip * gimp_tip_new (const gchar *format,
...) G_GNUC_PRINTF(1, 2);
void gimp_tip_set (GimpTip *tip,
const gchar *format,
...) G_GNUC_PRINTF(2, 3);
void gimp_tip_free (GimpTip *tip);
GList * gimp_tips_from_file (const gchar *filename,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment