[gtksourceview: 1/2] snippets: use GFile API for reading snippets




commit f147ae84ad75d21d9ad6b925a0ff96b44d983096
Author: Günther Wagner <info gunibert de>
Date:   Mon Apr 25 21:42:59 2022 +0200

    snippets: use GFile API for reading snippets

 gtksourceview/gtksourcesnippetbundle.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/gtksourceview/gtksourcesnippetbundle.c b/gtksourceview/gtksourcesnippetbundle.c
index f896b558..73eace64 100644
--- a/gtksourceview/gtksourcesnippetbundle.c
+++ b/gtksourceview/gtksourcesnippetbundle.c
@@ -433,11 +433,17 @@ gtk_source_snippet_bundle_parse (GtkSourceSnippetBundle  *self,
        gchar *contents = NULL;
        gsize length = 0;
        gboolean ret = FALSE;
+       GFile *file;
 
        g_assert (GTK_SOURCE_IS_SNIPPET_BUNDLE (self));
        g_assert (path != NULL);
 
-       if (g_file_get_contents (path, &contents, &length, NULL))
+       if (g_str_has_prefix (path, "resource://"))
+               file = g_file_new_for_uri (path);
+       else
+               file = g_file_new_for_path (path);
+
+       if (g_file_load_contents (file, NULL, &contents, &length, NULL, NULL))
        {
                GMarkupParseContext *context;
                ParseState state = {0};
@@ -476,6 +482,8 @@ gtk_source_snippet_bundle_parse (GtkSourceSnippetBundle  *self,
 #endif
        }
 
+       g_object_unref (file);
+
        return ret;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]