inspector: Show surface scale
authorMatthias Clasen <mclasen@redhat.com>
Sat, 1 Apr 2023 18:09:23 +0000 (14:09 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 1 Apr 2023 23:11:00 +0000 (19:11 -0400)
For Wayland surfaces, show the fractional scale
if we have it.

gtk/inspector/misc-info.c
gtk/inspector/misc-info.ui

index a9a061927ee369074cef8b21ccc15c811eba9f60..f6a58f08823d7a3eb87276e8bd68fd212867e31b 100644 (file)
@@ -34,7 +34,6 @@
 #include "gtkbinlayout.h"
 #include "gtkwidgetprivate.h"
 
-
 struct _GtkInspectorMiscInfo
 {
   GtkWidget parent;
@@ -79,6 +78,8 @@ struct _GtkInspectorMiscInfo
   GtkWidget *tick_callback;
   GtkWidget *framerate_row;
   GtkWidget *framerate;
+  GtkWidget *scale_row;
+  GtkWidget *scale;
   GtkWidget *framecount_row;
   GtkWidget *framecount;
   GtkWidget *mapped_row;
@@ -424,6 +425,15 @@ update_info (gpointer data)
       sl->last_frame = frame;
     }
 
+  if (GDK_IS_SURFACE (sl->object))
+    {
+      char buf[64];
+
+      g_snprintf (buf, sizeof (buf), "%g", gdk_surface_get_scale (GDK_SURFACE (sl->object)));
+
+      gtk_label_set_label (GTK_LABEL (sl->scale), buf);
+    }
+
   return G_SOURCE_CONTINUE;
 }
 
@@ -507,6 +517,7 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl,
   gtk_widget_set_visible (sl->buildable_id_row, GTK_IS_BUILDABLE (object));
   gtk_widget_set_visible (sl->framecount_row, GDK_IS_FRAME_CLOCK (object));
   gtk_widget_set_visible (sl->framerate_row, GDK_IS_FRAME_CLOCK (object));
+  gtk_widget_set_visible (sl->scale_row, GDK_IS_SURFACE (object));
 
   if (GTK_IS_WIDGET (object))
     {
@@ -618,6 +629,8 @@ gtk_inspector_misc_info_class_init (GtkInspectorMiscInfoClass *klass)
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, framecount);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, framerate_row);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, framerate);
+  gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, scale_row);
+  gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, scale);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, mapped_row);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, mapped);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, realized_row);
index 3a7696b7a4bd66097346acb5afcab1ed97b27d17..5db3e98bf9480b2a5a989dbb03bab606879ad9ff 100644 (file)
                     </child>
                   </object>
                 </child>
+                <child>
+                  <object class="GtkListBoxRow" id="scale_row">
+                    <property name="activatable">0</property>
+                    <child>
+                      <object class="GtkBox">
+                        <property name="spacing">40</property>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="label" translatable="yes">Scale</property>
+                            <property name="halign">start</property>
+                            <property name="valign">baseline</property>
+                            <property name="xalign">0</property>
+                            <property name="hexpand">1</property>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkLabel" id="scale">
+                            <property name="halign">end</property>
+                            <property name="valign">baseline</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
                 <child>
                   <object class="GtkListBoxRow" id="mapped_row">
                     <property name="activatable">0</property>