[gtksourceview/wip/chergert/pcre2: 6/9] tests: allow passing filename to test-widget
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/pcre2: 6/9] tests: allow passing filename to test-widget
- Date: Wed, 30 Sep 2020 19:42:08 +0000 (UTC)
commit 89dfadf93ca32f9f124b57e2e250c2638e7e5c1c
Author: Christian Hergert <chergert redhat com>
Date: Fri Sep 25 13:38:07 2020 -0700
tests: allow passing filename to test-widget
Just for convenience to open new files that may error on specific
conditions.
tests/test-widget.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/tests/test-widget.c b/tests/test-widget.c
index 9885d927..5d4e6575 100644
--- a/tests/test-widget.c
+++ b/tests/test-widget.c
@@ -72,6 +72,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (TestWidget, test_widget, GTK_TYPE_GRID)
static GMainLoop *main_loop;
static gchar *last_dir;
+static const char *cmd_filename;
static void
remove_all_marks (GtkSourceBuffer *buffer)
@@ -1112,7 +1113,11 @@ test_widget_init (TestWidget *self)
space_drawer, "enable-matrix",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
- file = g_file_new_for_path (TOP_SRCDIR "/gtksourceview/gtksourcebuffer.c");
+ if (cmd_filename)
+ file = g_file_new_for_commandline_arg (cmd_filename);
+ else
+ file = g_file_new_for_path (TOP_SRCDIR "/gtksourceview/gtksourcebuffer.c");
+
open_file (self, file);
g_object_unref (file);
}
@@ -1152,6 +1157,11 @@ main (int argc, char *argv[])
main_loop = g_main_loop_new (NULL, FALSE);
+ if (argc == 2 && g_file_test (argv[1], G_FILE_TEST_IS_REGULAR))
+ {
+ cmd_filename = argv[1];
+ }
+
gtk_init ();
gtk_source_init ();
setup_search_paths ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]