inspector: Show app ID and resource path in the General tab

This makes it easier to figure out those values (which are mentioned in
the GtkApplication documentation) rather than working that out from the
way they're generated (or documented as being generated).
This commit is contained in:
Bastien Nocera
2022-02-17 12:24:51 +01:00
parent 7394f6c720
commit 5c92e6ddc6
2 changed files with 109 additions and 0 deletions

View File

@ -62,6 +62,9 @@ struct _GtkInspectorGeneralPrivate
GtkWidget *device_box;
GtkWidget *gtk_version;
GtkWidget *gdk_backend;
GtkWidget *app_id_frame;
GtkWidget *app_id;
GtkWidget *resource_path;
GtkWidget *gl_version;
GtkWidget *gl_vendor;
GtkWidget *prefix;
@ -119,6 +122,24 @@ init_version (GtkInspectorGeneral *gen)
gtk_label_set_text (GTK_LABEL (gen->priv->gdk_backend), backend);
}
static void
init_app_id (GtkInspectorGeneral *gen)
{
GApplication *app;
app = g_application_get_default ();
if (!app)
{
gtk_widget_hide (gen->priv->app_id_frame);
return;
}
gtk_label_set_text (GTK_LABEL (gen->priv->app_id),
g_application_get_application_id (app));
gtk_label_set_text (GTK_LABEL (gen->priv->resource_path),
g_application_get_resource_base_path (app));
}
static G_GNUC_UNUSED void
add_check_row (GtkInspectorGeneral *gen,
GtkListBox *list,
@ -646,6 +667,7 @@ gtk_inspector_general_init (GtkInspectorGeneral *gen)
gen->priv = gtk_inspector_general_get_instance_private (gen);
gtk_widget_init_template (GTK_WIDGET (gen));
init_version (gen);
init_app_id (gen);
init_env (gen);
init_display (gen);
init_gl (gen);
@ -735,6 +757,9 @@ gtk_inspector_general_class_init (GtkInspectorGeneralClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, gl_box);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, gtk_version);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, gdk_backend);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, app_id_frame);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, app_id);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, resource_path);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, gl_version);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, gl_vendor);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, prefix);

View File

@ -91,6 +91,87 @@
</object>
</child>
<child>
<object class="GtkFrame" id="app_id_frame">
<property name="visible">True</property>
<property name="halign">center</property>
<child>
<object class="GtkListBox" id="app_id_box">
<property name="visible">True</property>
<property name="selection-mode">none</property>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="activatable">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<property name="margin">10</property>
<property name="spacing">40</property>
<child>
<object class="GtkLabel" id="app_id_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Application ID</property>
<property name="halign">start</property>
<property name="valign">baseline</property>
<property name="xalign">0.0</property>
</object>
</child>
<child>
<object class="GtkLabel" id="app_id">
<property name="visible">True</property>
<property name="selectable">True</property>
<property name="halign">end</property>
<property name="valign">baseline</property>
</object>
<packing>
<property name="expand">True</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="visible">True</property>
<property name="activatable">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<property name="margin">10</property>
<property name="spacing">40</property>
<child>
<object class="GtkLabel" id="resource_path_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Resource Path</property>
<property name="halign">start</property>
<property name="valign">baseline</property>
<property name="xalign">0.0</property>
</object>
</child>
<child>
<object class="GtkLabel" id="resource_path">
<property name="visible">True</property>
<property name="selectable">True</property>
<property name="halign">end</property>
<property name="valign">baseline</property>
</object>
<packing>
<property name="expand">True</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkFrame" id="env_frame">
<property name="visible">True</property>
@ -569,6 +650,8 @@
<widgets>
<widget name="gtk_version_label"/>
<widget name="gdk_backend_label"/>
<widget name="app_id_label"/>
<widget name="resource_path_label"/>
<widget name="gl_version_label"/>
<widget name="gl_vendor_label"/>
<widget name="prefix_label"/>
@ -587,6 +670,7 @@
<property name="mode">horizontal</property>
<widgets>
<widget name="version_frame"/>
<widget name="app_id_frame"/>
<widget name="gl_frame"/>
<widget name="env_frame"/>
<widget name="display_frame"/>