libsysprof-ui: wire up recording signal

This commit is contained in:
Christian Hergert
2019-05-18 17:52:04 -07:00
parent 809c24622e
commit 8f335bc512
3 changed files with 74 additions and 0 deletions

View File

@ -28,6 +28,7 @@
#include <sysprof-ui.h>
#include <sysprof.h>
#include "sysprof-profiler-assistant.h"
#include "sysprof-capture-view.h"
#include "sysprof-display.h"
#include "sysprof-empty-state-view.h"
@ -39,6 +40,7 @@ typedef struct
SysprofProfiler *profiler;
/* Template Objects */
SysprofProfilerAssistant *assistant;
SysprofCaptureView *capture_view;
SysprofEmptyStateView *failed_view;
SysprofEmptyStateView *empty_view;
@ -71,6 +73,21 @@ sysprof_display_new (void)
return g_object_new (SYSPROF_TYPE_DISPLAY, NULL);
}
static void
sysprof_display_start_recording_cb (SysprofDisplay *self,
SysprofProfiler *profiler,
SysprofProfilerAssistant *assistant)
{
SysprofDisplayPrivate *priv = sysprof_display_get_instance_private (self);
g_return_if_fail (SYSPROF_IS_DISPLAY (self));
g_return_if_fail (SYSPROF_IS_PROFILER (profiler));
g_return_if_fail (SYSPROF_IS_PROFILER_ASSISTANT (assistant));
sysprof_recording_state_view_set_profiler (priv->recording_view, profiler);
gtk_stack_set_visible_child (priv->stack, GTK_WIDGET (priv->recording_view));
}
gchar *
sysprof_display_dup_title (SysprofDisplay *self)
{
@ -194,6 +211,7 @@ sysprof_display_class_init (SysprofDisplayClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, SysprofDisplay, empty_view);
gtk_widget_class_bind_template_child_private (widget_class, SysprofDisplay, failed_view);
gtk_widget_class_bind_template_child_private (widget_class, SysprofDisplay, recording_view);
gtk_widget_class_bind_template_child_private (widget_class, SysprofDisplay, assistant);
gtk_widget_class_bind_template_child_private (widget_class, SysprofDisplay, stack);
g_type_ensure (SYSPROF_TYPE_CAPTURE_VIEW);
@ -204,7 +222,15 @@ sysprof_display_class_init (SysprofDisplayClass *klass)
static void
sysprof_display_init (SysprofDisplay *self)
{
SysprofDisplayPrivate *priv = sysprof_display_get_instance_private (self);
gtk_widget_init_template (GTK_WIDGET (self));
g_signal_connect_object (priv->assistant,
"start-recording",
G_CALLBACK (sysprof_display_start_recording_cb),
self,
G_CONNECT_SWAPPED);
}
/**

View File

@ -35,6 +35,7 @@ struct _SysprofProfilerAssistant
GtkBin parent_instance;
/* Template Objects */
GtkButton *record_button;
GtkEntry *command_line;
GtkRevealer *process_revealer;
GtkListBox *process_list_box;
@ -42,6 +43,13 @@ struct _SysprofProfilerAssistant
GtkFlowBox *aid_flow_box;
};
enum {
START_RECORDING,
N_SIGNALS
};
static guint signals [N_SIGNALS];
G_DEFINE_TYPE (SysprofProfilerAssistant, sysprof_profiler_assistant, GTK_TYPE_BIN)
/**
@ -137,17 +145,50 @@ sysprof_profiler_assistant_command_line_changed_cb (SysprofProfilerAssistant *se
gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_ERROR);
}
static void
sysprof_profiler_assistant_record_clicked_cb (SysprofProfilerAssistant *self,
GtkButton *button)
{
g_autoptr(SysprofProfiler) profiler = NULL;
g_assert (SYSPROF_IS_PROFILER_ASSISTANT (self));
g_assert (GTK_IS_BUTTON (button));
gtk_widget_set_sensitive (GTK_WIDGET (self), FALSE);
profiler = sysprof_local_profiler_new ();
g_signal_emit (self, signals [START_RECORDING], 0, profiler);
}
static void
sysprof_profiler_assistant_class_init (SysprofProfilerAssistantClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
/**
* SysprofProfilerAssistant::start-recording:
* @self: a #SysprofProfilerAssistant
* @profiler: a #SysprofProfiler
*
* This signal is emitted when a new profiling session should start.
*/
signals [START_RECORDING] =
g_signal_new ("start-recording",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, SYSPROF_TYPE_PROFILER);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/ui/sysprof-profiler-assistant.ui");
gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, aid_flow_box);
gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, command_line);
gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, environ_editor);
gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, process_list_box);
gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, process_revealer);
gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, record_button);
g_type_ensure (SYSPROF_TYPE_AID_ICON);
g_type_ensure (SYSPROF_TYPE_CPU_AID);
@ -161,6 +202,12 @@ sysprof_profiler_assistant_init (SysprofProfilerAssistant *self)
gtk_widget_init_template (GTK_WIDGET (self));
g_signal_connect_object (self->record_button,
"clicked",
G_CALLBACK (sysprof_profiler_assistant_record_clicked_cb),
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (self->command_line,
"changed",
G_CALLBACK (sysprof_profiler_assistant_command_line_changed_cb),

View File

@ -4,6 +4,7 @@
<child>
<object class="GtkStack" id="stack">
<property name="homogeneous">false</property>
<property name="transition-type">crossfade</property>
<property name="visible">true</property>
<child>
<object class="SysprofProfilerAssistant" id="assistant">