[sysprof] libsysprof-ui: wire up recording signal
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] libsysprof-ui: wire up recording signal
- Date: Wed, 29 May 2019 22:34:58 +0000 (UTC)
commit 8f335bc5126ffaecf4fb109bdffbfc8829509f11
Author: Christian Hergert <chergert redhat com>
Date: Sat May 18 17:52:04 2019 -0700
libsysprof-ui: wire up recording signal
src/libsysprof-ui/sysprof-display.c | 26 ++++++++++++++
src/libsysprof-ui/sysprof-profiler-assistant.c | 47 ++++++++++++++++++++++++++
src/libsysprof-ui/ui/sysprof-display.ui | 1 +
3 files changed, 74 insertions(+)
---
diff --git a/src/libsysprof-ui/sysprof-display.c b/src/libsysprof-ui/sysprof-display.c
index 9bdff77..f5eb657 100644
--- a/src/libsysprof-ui/sysprof-display.c
+++ b/src/libsysprof-ui/sysprof-display.c
@@ -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);
}
/**
diff --git a/src/libsysprof-ui/sysprof-profiler-assistant.c b/src/libsysprof-ui/sysprof-profiler-assistant.c
index eef31ae..0064274 100644
--- a/src/libsysprof-ui/sysprof-profiler-assistant.c
+++ b/src/libsysprof-ui/sysprof-profiler-assistant.c
@@ -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),
diff --git a/src/libsysprof-ui/ui/sysprof-display.ui b/src/libsysprof-ui/ui/sysprof-display.ui
index 7565a5d..83c017a 100644
--- a/src/libsysprof-ui/ui/sysprof-display.ui
+++ b/src/libsysprof-ui/ui/sysprof-display.ui
@@ -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">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]