libsysprof-ui: update samples while recording

This commit is contained in:
Christian Hergert
2019-05-19 17:46:55 -07:00
parent a8383832de
commit ef6c402b80
2 changed files with 64 additions and 21 deletions

View File

@ -25,8 +25,9 @@
typedef struct
{
SysprofProfiler *profiler;
gulong notify_elapsed_handler;
GtkLabel *elapsed;
GtkLabel *samples;
gulong notify_elapsed_handler;
} SysprofRecordingStateViewPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (SysprofRecordingStateView, sysprof_recording_state_view, GTK_TYPE_BIN)
@ -52,6 +53,7 @@ sysprof_recording_state_view_notify_elapsed (SysprofRecordingStateView *self,
{
SysprofRecordingStateViewPrivate *priv = sysprof_recording_state_view_get_instance_private (self);
g_autofree gchar *str = NULL;
SysprofCaptureWriter *writer;
gint64 elapsed;
guint hours;
guint minutes;
@ -60,6 +62,16 @@ sysprof_recording_state_view_notify_elapsed (SysprofRecordingStateView *self,
g_assert (SYSPROF_IS_RECORDING_STATE_VIEW (self));
g_assert (SYSPROF_IS_PROFILER (profiler));
if ((writer = sysprof_profiler_get_writer (profiler)))
{
SysprofCaptureStat st;
g_autofree gchar *samples = NULL;
sysprof_capture_writer_stat (writer, &st);
samples = g_strdup_printf ("%"G_GINT64_FORMAT, st.frame_count[SYSPROF_CAPTURE_FRAME_SAMPLE]);
gtk_label_set_label (priv->samples, samples);
}
elapsed = (gint64)sysprof_profiler_get_elapsed (profiler);
hours = elapsed / (60 * 60);

View File

@ -43,6 +43,34 @@
</style>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="spacing">6</property>
<property name="visible">true</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Samples</property>
<property name="xalign">1.0</property>
<property name="valign">baseline</property>
<property name="visible">true</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkLabel" id="samples">
<property name="label">0</property>
<property name="visible">true</property>
<property name="hexpand">true</property>
<property name="valign">baseline</property>
<property name="xalign">0.0</property>
<attributes>
<attribute name="font-features" value="font-feature-settings: &apos;tnum&apos;"/>
</attributes>
</object>
</child>
<child>
<object class="GtkButton">
<property name="action-name">display.stop-recording</property>
@ -51,6 +79,7 @@
<property name="label" translatable="yes">_Stop Recording</property>
<property name="halign">end</property>
<property name="width-request">125</property>
<property name="valign">baseline</property>
<property name="use-underline">true</property>
<style>
<class name="destructive-action"/>
@ -59,5 +88,7 @@
</child>
</object>
</child>
</object>
</child>
</template>
</interface>