[gimp] app: some filename -> GFile in the tips parsing code
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: some filename -> GFile in the tips parsing code
- Date: Wed, 23 Jul 2014 21:40:29 +0000 (UTC)
commit e49d9739bbea6537240704ae55880121b3d203bb
Author: Michael Natterer <mitch gimp org>
Date: Wed Jul 23 23:40:01 2014 +0200
app: some filename -> GFile in the tips parsing code
app/dialogs/tips-dialog.c | 11 +++++++----
app/dialogs/tips-parser.c | 10 +++++-----
app/dialogs/tips-parser.h | 2 +-
3 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/app/dialogs/tips-dialog.c b/app/dialogs/tips-dialog.c
index 717098d..7c09cc0 100644
--- a/app/dialogs/tips-dialog.c
+++ b/app/dialogs/tips-dialog.c
@@ -74,11 +74,14 @@ tips_dialog_create (Gimp *gimp)
{
GError *error = NULL;
gchar *filename;
+ GFile *file;
filename = g_build_filename (gimp_data_directory (), "tips",
"gimp-tips.xml", NULL);
+ file = g_file_new_for_path (filename);
+ g_free (filename);
- tips = gimp_tips_from_file (filename, &error);
+ tips = gimp_tips_from_file (file, &error);
if (! tips)
{
@@ -94,7 +97,7 @@ tips_dialog_create (Gimp *gimp)
"missing!"),
_("There should be a file called '%s'. "
"Please check your installation."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
}
else
{
@@ -107,11 +110,11 @@ tips_dialog_create (Gimp *gimp)
else if (error)
{
g_printerr ("Error while parsing '%s': %s\n",
- filename, error->message);
+ gimp_file_get_utf8_name (file), error->message);
}
g_clear_error (&error);
- g_free (filename);
+ g_object_unref (file);
}
tips_count = g_list_length (tips);
diff --git a/app/dialogs/tips-parser.c b/app/dialogs/tips-parser.c
index add9ebf..3c8a590 100644
--- a/app/dialogs/tips-parser.c
+++ b/app/dialogs/tips-parser.c
@@ -153,7 +153,7 @@ gimp_tip_free (GimpTip *tip)
/**
* gimp_tips_from_file:
- * @filename: the name of the tips file to parse
+ * @file: the tips file to parse
* @error: return location for a #GError
*
* Reads a gimp-tips XML file, creates a new #GimpTip for
@@ -166,15 +166,15 @@ gimp_tip_free (GimpTip *tip)
* Return value: a #Glist of #GimpTips.
**/
GList *
-gimp_tips_from_file (const gchar *filename,
- GError **error)
+gimp_tips_from_file (GFile *file,
+ GError **error)
{
GimpXmlParser *xml_parser;
TipsParser parser = { 0, };
const gchar *tips_locale;
GList *tips = NULL;
- g_return_val_if_fail (filename != NULL, NULL);
+ g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
parser.value = g_string_new (NULL);
@@ -200,7 +200,7 @@ gimp_tips_from_file (const gchar *filename,
xml_parser = gimp_xml_parser_new (&markup_parser, &parser);
- gimp_xml_parser_parse_file (xml_parser, filename, error);
+ gimp_xml_parser_parse_gfile (xml_parser, file, error);
gimp_xml_parser_free (xml_parser);
diff --git a/app/dialogs/tips-parser.h b/app/dialogs/tips-parser.h
index afd0e83..2d0d65b 100644
--- a/app/dialogs/tips-parser.h
+++ b/app/dialogs/tips-parser.h
@@ -36,7 +36,7 @@ GimpTip * gimp_tip_new (const gchar *title,
...) G_GNUC_PRINTF(2, 3);
void gimp_tip_free (GimpTip *tip);
-GList * gimp_tips_from_file (const gchar *filename,
+GList * gimp_tips_from_file (GFile *file,
GError **error);
void gimp_tips_free (GList *tips);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]