inspector: Replace reload with record
and when pressed, record instance counts at 1fps.
This commit is contained in:
parent
43ad7c9714
commit
eaa872f6c3
@ -42,6 +42,7 @@ struct _GtkInspectorStatisticsPrivate
|
||||
GtkTreeViewColumn *column_cumulative2;
|
||||
GtkCellRenderer *renderer_cumulative2;
|
||||
GHashTable *counts;
|
||||
guint update_source_id;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@ -113,9 +114,10 @@ add_type_count (GtkInspectorStatistics *sl, GType type)
|
||||
return cumulative;
|
||||
}
|
||||
|
||||
static void
|
||||
update_type_counts (GtkInspectorStatistics *sl)
|
||||
static gboolean
|
||||
update_type_counts (gpointer data)
|
||||
{
|
||||
GtkInspectorStatistics *sl = data;
|
||||
GType type;
|
||||
gpointer class;
|
||||
|
||||
@ -130,12 +132,29 @@ update_type_counts (GtkInspectorStatistics *sl)
|
||||
|
||||
add_type_count (sl, type);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
refresh_clicked (GtkWidget *button, GtkInspectorStatistics *sl)
|
||||
toggle_record (GtkToggleToolButton *button,
|
||||
GtkInspectorStatistics *sl)
|
||||
{
|
||||
update_type_counts (sl);
|
||||
if (gtk_toggle_tool_button_get_active (button) == (sl->priv->update_source_id != 0))
|
||||
return;
|
||||
|
||||
if (gtk_toggle_tool_button_get_active (button))
|
||||
{
|
||||
sl->priv->update_source_id = gdk_threads_add_timeout_seconds (1,
|
||||
update_type_counts,
|
||||
sl);
|
||||
update_type_counts (sl);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_source_remove (sl->priv->update_source_id);
|
||||
sl->priv->update_source_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -250,6 +269,9 @@ finalize (GObject *object)
|
||||
{
|
||||
GtkInspectorStatistics *sl = GTK_INSPECTOR_STATISTICS (object);
|
||||
|
||||
if (sl->priv->update_source_id)
|
||||
g_source_remove (sl->priv->update_source_id);
|
||||
|
||||
g_hash_table_unref (sl->priv->counts);
|
||||
|
||||
G_OBJECT_CLASS (gtk_inspector_statistics_parent_class)->finalize (object);
|
||||
@ -276,7 +298,7 @@ gtk_inspector_statistics_class_init (GtkInspectorStatisticsClass *klass)
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, column_cumulative2);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, renderer_cumulative2);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorStatistics, button);
|
||||
gtk_widget_class_bind_template_callback (widget_class, refresh_clicked);
|
||||
gtk_widget_class_bind_template_callback (widget_class, toggle_record);
|
||||
}
|
||||
|
||||
// vim: set et sw=2 ts=2:
|
||||
|
@ -27,11 +27,11 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-size">small-toolbar</property>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="button">
|
||||
<object class="GtkToggleToolButton" id="button">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">view-refresh-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Refresh</property>
|
||||
<signal name="clicked" handler="refresh_clicked"/>
|
||||
<property name="icon-name">media-record-symbolic</property>
|
||||
<property name="tooltip-text" translatable="yes">Collect Statistics</property>
|
||||
<signal name="toggled" handler="toggle_record"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -1,4 +1,4 @@
|
||||
N_("Refresh");
|
||||
N_("Collect Statistics");
|
||||
N_("Type");
|
||||
N_("Self 1");
|
||||
N_("Cumulative 1");
|
||||
@ -6,4 +6,6 @@ N_("Self 2");
|
||||
N_("Cumulative 2");
|
||||
N_("Self");
|
||||
N_("Cumulative");
|
||||
N_("Self");
|
||||
N_("Cumulative");
|
||||
N_("Enable statistics with GOBJECT_DEBUG=instance-count");
|
||||
|
Loading…
Reference in New Issue
Block a user