inspector: Don't lie with statistics

If we don't have statistics, despite GOBJECT_DEBUG being set,
explain how to fix this.
This commit is contained in:
Matthias Clasen 2016-04-14 22:52:59 -04:00
parent 7552b7fca8
commit 8a2061f581
2 changed files with 12 additions and 1 deletions

View File

@ -26,6 +26,7 @@
#include "gtkcellrenderertext.h" #include "gtkcellrenderertext.h"
#include "gtkcelllayout.h" #include "gtkcelllayout.h"
#include "gtksearchbar.h" #include "gtksearchbar.h"
#include "gtklabel.h"
enum enum
{ {
@ -36,6 +37,7 @@ enum
struct _GtkInspectorStatisticsPrivate struct _GtkInspectorStatisticsPrivate
{ {
GtkWidget *stack; GtkWidget *stack;
GtkWidget *excuse;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeView *view; GtkTreeView *view;
GtkWidget *button; GtkWidget *button;
@ -168,6 +170,12 @@ toggle_record (GtkToggleButton *button,
static gboolean static gboolean
has_instance_counts (void) has_instance_counts (void)
{
return g_type_get_instance_count (GTK_TYPE_LABEL) > 0;
}
static gboolean
instance_counts_enabled (void)
{ {
const gchar *string; const gchar *string;
guint flags = 0; guint flags = 0;
@ -365,6 +373,8 @@ constructed (GObject *object)
update_type_counts (sl); update_type_counts (sl);
else else
{ {
if (instance_counts_enabled ())
gtk_label_set_text (GTK_LABEL (sl->priv->excuse), _("GLib must be configured with --enable-debug"));
gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->stack), "excuse"); gtk_stack_set_visible_child_name (GTK_STACK (sl->priv->stack), "excuse");
gtk_widget_set_sensitive (sl->priv->button, FALSE); gtk_widget_set_sensitive (sl->priv->button, FALSE);
} }
@ -452,6 +462,7 @@ gtk_inspector_statistics_class_init (GtkInspectorStatisticsClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, renderer_cumulative2); gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, renderer_cumulative2);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, search_entry); gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, search_entry);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, search_bar); gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, search_bar);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, excuse);
} }

View File

@ -159,7 +159,7 @@
<property name="halign">center</property> <property name="halign">center</property>
<property name="valign">center</property> <property name="valign">center</property>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel" id="excuse">
<property name="visible">True</property> <property name="visible">True</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<property name="label" translatable="yes">Enable statistics with GOBJECT_DEBUG=instance-count</property> <property name="label" translatable="yes">Enable statistics with GOBJECT_DEBUG=instance-count</property>