[gtk/gtk-4-6] gtk-builder-tool: Operate without display
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/gtk-4-6] gtk-builder-tool: Operate without display
- Date: Wed, 16 Mar 2022 02:20:18 +0000 (UTC)
commit 38bbcb74115b69263a63fae3a70bc6c11e701814
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Mar 14 15:40:12 2022 -0400
gtk-builder-tool: Operate without display
The simplify and validate commands can function
without a display connection, only preview absolutely
needs one. Allow this, by using gtk_init_check().
tools/gtk-builder-tool.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/tools/gtk-builder-tool.c b/tools/gtk-builder-tool.c
index bc89207049..b62773738a 100644
--- a/tools/gtk-builder-tool.c
+++ b/tools/gtk-builder-tool.c
@@ -109,11 +109,13 @@ log_writer_func (GLogLevelFlags level,
int
main (int argc, const char *argv[])
{
+ gboolean has_display;
+
g_set_prgname ("gtk-builder-tool");
g_log_set_writer_func (log_writer_func, NULL, NULL);
- gtk_init ();
+ has_display = gtk_init_check ();
gtk_test_register_all_types ();
@@ -133,7 +135,15 @@ main (int argc, const char *argv[])
else if (strcmp (argv[0], "enumerate") == 0)
do_enumerate (&argc, &argv);
else if (strcmp (argv[0], "preview") == 0)
- do_preview (&argc, &argv);
+ {
+ if (!has_display)
+ {
+ g_printerr ("Could not initialize windowing system\n");
+ return 1;
+ }
+
+ do_preview (&argc, &argv);
+ }
else
usage ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]