[gtksourceview/wip/chergert/snippets: 134/134] tests: setup search paths in test-widget



commit a3c1b5d4ba9fc331708bc751c3593cc6efe57b76
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 29 08:32:21 2020 -0800

    tests: setup search paths in test-widget
    
    We want to be using data from our installation so that we can test changes
    made in-tree. This ensures that we have those paths available without
    having to first install.

 tests/test-widget.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
---
diff --git a/tests/test-widget.c b/tests/test-widget.c
index e928eb8b..d5a75211 100644
--- a/tests/test-widget.c
+++ b/tests/test-widget.c
@@ -1099,6 +1099,26 @@ test_widget_new (void)
        return g_object_new (test_widget_get_type (), NULL);
 }
 
+static void
+setup_search_paths (void)
+{
+       GtkSourceSnippetManager *snippets;
+       GtkSourceStyleSchemeManager *styles;
+       GtkSourceLanguageManager *languages;
+       static const gchar *snippets_path[] = { TOP_SRCDIR"/data/snippets", NULL };
+       static const gchar *langs_path[] = { TOP_SRCDIR"/data/language-specs", NULL };
+
+       snippets = gtk_source_snippet_manager_get_default ();
+       gtk_source_snippet_manager_set_search_path (snippets, snippets_path);
+
+       /* Allow use of system styles, but prefer in-tree */
+       styles = gtk_source_style_scheme_manager_get_default ();
+       gtk_source_style_scheme_manager_prepend_search_path (styles, TOP_SRCDIR"/data/styles");
+
+       languages = gtk_source_language_manager_get_default ();
+       gtk_source_language_manager_set_search_path (languages, langs_path);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -1107,6 +1127,7 @@ main (int argc, char *argv[])
 
        gtk_init ();
        gtk_source_init ();
+       setup_search_paths ();
 
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
        gtk_window_set_default_size (GTK_WINDOW (window), 900, 600);


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