[gtk/wip/otte/gleanup: 48/53] inspector: Add support for displaying GL errors




commit 89b4b026386aca2b79525d25bfed3193279d9882
Author: Benjamin Otte <otte redhat com>
Date:   Fri Jul 9 03:28:34 2021 +0200

    inspector: Add support for displaying GL errors
    
    Also, no need to show a GL version if GL isn't available.

 gtk/inspector/general.c  | 17 +++++++++++++++++
 gtk/inspector/general.ui | 25 ++++++++++++++++++++++++-
 2 files changed, 41 insertions(+), 1 deletion(-)
---
diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c
index a2066a2d96..8d1fc9f44c 100644
--- a/gtk/inspector/general.c
+++ b/gtk/inspector/general.c
@@ -87,7 +87,10 @@ struct _GtkInspectorGeneral
   GtkWidget *pango_fontmap;
   GtkWidget *media_backend;
   GtkWidget *gl_version;
+  GtkWidget *gl_error;
+  GtkWidget *gl_error_row;
   GtkWidget *gl_vendor;
+  GtkWidget *gl_vendor_row;
   GtkWidget *vk_device;
   GtkWidget *vk_api_version;
   GtkWidget *vk_driver_version;
@@ -298,6 +301,17 @@ get_egl_display (GdkDisplay *display)
 static void
 init_gl (GtkInspectorGeneral *gen)
 {
+  GError *error = NULL;
+
+  if (!gdk_display_prepare_gl (gen->display, &error))
+    {
+      gtk_label_set_text (GTK_LABEL (gen->gl_version), C_("GL version", "None"));
+      gtk_widget_set_visible (gen->gl_vendor_row, FALSE);
+      gtk_widget_set_visible (gen->gl_error_row, TRUE);
+      gtk_label_set_text (GTK_LABEL (gen->gl_error), error->message);
+      g_error_free (error);
+    }
+
   if (gdk_display_get_debug_flags (gen->display) & GDK_DEBUG_GL_DISABLE)
     {
       gtk_label_set_text (GTK_LABEL (gen->gl_version), C_("GL version", "Disabled"));
@@ -1053,7 +1067,10 @@ gtk_inspector_general_class_init (GtkInspectorGeneralClass *klass)
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, pango_fontmap);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, media_backend);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, gl_version);
+  gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, gl_error);
+  gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, gl_error_row);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, gl_vendor);
+  gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, gl_vendor_row);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, vk_device);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, vk_api_version);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorGeneral, vk_driver_version);
diff --git a/gtk/inspector/general.ui b/gtk/inspector/general.ui
index 86cda44b82..e9aeb49a69 100644
--- a/gtk/inspector/general.ui
+++ b/gtk/inspector/general.ui
@@ -499,7 +499,30 @@
                       </object>
                     </child>
                     <child>
-                      <object class="GtkListBoxRow">
+                      <object class="GtkListBoxRow" id="gl_error_row">
+                        <property name="activatable">0</property>
+                        <property name="visible">0</property>
+                        <child>
+                          <object class="GtkBox">
+                            <property name="spacing">40</property>
+                            <child>
+                              <object class="GtkLabel" id="gl_error">
+                                <property name="selectable">1</property>
+                                <property name="halign">end</property>
+                                <property name="valign">baseline</property>
+                                <property name="ellipsize">end</property>
+                                <property name="hexpand">1</property>
+                                <style>
+                                  <class name="error"/>
+                                </style>
+                              </object>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkListBoxRow" id="gl_vendor_row">
                         <property name="activatable">0</property>
                         <child>
                           <object class="GtkBox">


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