inspector: hide a11y object path when not using AT-SPI backend
authorJason Francis <jafrancis999@gmail.com>
Tue, 9 May 2023 01:30:10 +0000 (21:30 -0400)
committerJason Francis <jafrancis999@gmail.com>
Tue, 9 May 2023 01:31:21 +0000 (21:31 -0400)
gtk/inspector/a11y.c
gtk/inspector/a11y.ui

index 7fbaec0c924c886cd199b5b7ef1f7e8f3d868079..8d4c20a5cf9d87cbde757577be135673a0dfbd0c 100644 (file)
@@ -201,6 +201,7 @@ struct _GtkInspectorA11y
 
   GtkWidget *box;
   GtkWidget *role;
+  GtkWidget *path_label;
   GtkWidget *path;
   GtkWidget *attributes;
 };
@@ -230,8 +231,8 @@ update_role (GtkInspectorA11y *sl)
 static void
 update_path (GtkInspectorA11y *sl)
 {
-  const char *path = "—";
 #ifdef G_OS_UNIX
+  const char *path = NULL;
   GtkATContext *context;
 
   context = gtk_accessible_get_at_context (GTK_ACCESSIBLE (sl->object));
@@ -242,13 +243,15 @@ update_path (GtkInspectorA11y *sl)
       else
         path = "not realized";
     }
-  else
-    path = "not on bus";
+
+  if (path != NULL)
+      gtk_label_set_label (GTK_LABEL (sl->path), path);
+
+  gtk_widget_set_visible (sl->path, path != NULL);
+  gtk_widget_set_visible (sl->path_label, path != NULL);
 
   g_clear_object (&context);
 #endif
-
-  gtk_label_set_label (GTK_LABEL (sl->path), path);
 }
 
 extern GType gtk_string_pair_get_type (void);
@@ -460,6 +463,11 @@ static void
 gtk_inspector_a11y_init (GtkInspectorA11y *sl)
 {
   gtk_widget_init_template (GTK_WIDGET (sl));
+
+#ifndef G_OS_UNIX
+  gtk_widget_set_visible (sl->path, FALSE);
+  gtk_widget_set_visible (sl->path_label, FALSE);
+#endif
 }
 
 static void
@@ -497,6 +505,7 @@ gtk_inspector_a11y_class_init (GtkInspectorA11yClass *klass)
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/a11y.ui");
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorA11y, box);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorA11y, role);
+  gtk_widget_class_bind_template_child (widget_class, GtkInspectorA11y, path_label);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorA11y, path);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorA11y, attributes);
 
index 8e001f6c95d4bc51e433db9bd1e428c45a551de6..785a337df6b18923f86f20d6a9521520e933ba7f 100644 (file)
@@ -40,7 +40,7 @@
             <property name="spacing">40</property>
             <child>
               <object class="GtkLabel" id="path_label">
-                <property name="label" translatable="yes">Object path</property>
+                <property name="label" translatable="yes">Object Path</property>
                 <property name="halign">start</property>
                 <property name="valign">baseline</property>
                 <property name="xalign">0.0</property>