[gnome-builder/wip/chergert/visualizers: 16/19] sysprof: add failure state view and info bar error messages
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/visualizers: 16/19] sysprof: add failure state view and info bar error messages
- Date: Mon, 10 Oct 2016 22:45:31 +0000 (UTC)
commit 02274074c93f743bde59ee3efb164c7e61e8f616
Author: Christian Hergert <chergert redhat com>
Date: Sun Oct 9 20:56:42 2016 -0700
sysprof: add failure state view and info bar error messages
This gets things a bit closer to how they look in sysprof
including the error infobar and showing the "fail whale"
for when we fail to authorize perf events.
plugins/sysprof/gbp-sysprof-perspective.c | 60 +++++++++++++-
plugins/sysprof/gbp-sysprof-perspective.h | 11 ++-
plugins/sysprof/gbp-sysprof-perspective.ui | 115 ++++++++++++++++++-------
plugins/sysprof/gbp-sysprof-workbench-addin.c | 32 ++++++-
4 files changed, 175 insertions(+), 43 deletions(-)
---
diff --git a/plugins/sysprof/gbp-sysprof-perspective.c b/plugins/sysprof/gbp-sysprof-perspective.c
index 84f1f58..dc74315 100644
--- a/plugins/sysprof/gbp-sysprof-perspective.c
+++ b/plugins/sysprof/gbp-sysprof-perspective.c
@@ -30,6 +30,9 @@ struct _GbpSysprofPerspective
GtkStack *stack;
SpCallgraphView *callgraph_view;
+ GtkLabel *info_bar_label;
+ GtkButton *info_bar_close;
+ GtkRevealer *info_bar_revealer;
SpVisualizerView *visualizers;
SpRecordingStateView *recording_view;
SpZoomManager *zoom_manager;
@@ -41,12 +44,24 @@ G_DEFINE_TYPE_EXTENDED (GbpSysprofPerspective, gbp_sysprof_perspective, GTK_TYPE
G_IMPLEMENT_INTERFACE (IDE_TYPE_PERSPECTIVE, perspective_iface_init))
static void
+hide_info_bar (GbpSysprofPerspective *self,
+ GtkButton *button)
+{
+ g_assert (GBP_IS_SYSPROF_PERSPECTIVE (self));
+
+ gtk_revealer_set_reveal_child (self->info_bar_revealer, FALSE);
+}
+
+static void
gbp_sysprof_perspective_class_init (GbpSysprofPerspectiveClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/builder/plugins/sysprof-plugin/gbp-sysprof-perspective.ui");
gtk_widget_class_bind_template_child (widget_class, GbpSysprofPerspective, callgraph_view);
+ gtk_widget_class_bind_template_child (widget_class, GbpSysprofPerspective, info_bar_label);
+ gtk_widget_class_bind_template_child (widget_class, GbpSysprofPerspective, info_bar_close);
+ gtk_widget_class_bind_template_child (widget_class, GbpSysprofPerspective, info_bar_revealer);
gtk_widget_class_bind_template_child (widget_class, GbpSysprofPerspective, stack);
gtk_widget_class_bind_template_child (widget_class, GbpSysprofPerspective, recording_view);
gtk_widget_class_bind_template_child (widget_class, GbpSysprofPerspective, visualizers);
@@ -55,6 +70,7 @@ gbp_sysprof_perspective_class_init (GbpSysprofPerspectiveClass *klass)
g_type_ensure (SP_TYPE_CALLGRAPH_VIEW);
g_type_ensure (SP_TYPE_CPU_VISUALIZER_ROW);
g_type_ensure (SP_TYPE_EMPTY_STATE_VIEW);
+ g_type_ensure (SP_TYPE_FAILED_STATE_VIEW);
g_type_ensure (SP_TYPE_RECORDING_STATE_VIEW);
g_type_ensure (SP_TYPE_VISUALIZER_VIEW);
}
@@ -63,6 +79,12 @@ static void
gbp_sysprof_perspective_init (GbpSysprofPerspective *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
+
+ g_signal_connect_object (self->info_bar_close,
+ "clicked",
+ G_CALLBACK (hide_info_bar),
+ self,
+ G_CONNECT_SWAPPED);
}
static gchar *
@@ -126,6 +148,14 @@ generate_cb (GObject *object,
sp_callgraph_view_set_profile (self->callgraph_view, profile);
}
+SpCaptureReader *
+gbp_sysprof_perspective_get_reader (GbpSysprofPerspective *self)
+{
+ g_return_val_if_fail (GBP_IS_SYSPROF_PERSPECTIVE (self), NULL);
+
+ return sp_visualizer_view_get_reader (self->visualizers);
+}
+
void
gbp_sysprof_perspective_set_reader (GbpSysprofPerspective *self,
SpCaptureReader *reader)
@@ -142,6 +172,10 @@ gbp_sysprof_perspective_set_reader (GbpSysprofPerspective *self,
return;
}
+ /* If we failed, ignore the (probably mostly empty) reader */
+ if (g_strcmp0 (gtk_stack_get_visible_child_name (self->stack), "failed") == 0)
+ return;
+
profile = sp_callgraph_profile_new ();
sp_profile_set_reader (profile, reader);
sp_profile_generate (profile, NULL, generate_cb, g_object_ref (self));
@@ -151,6 +185,25 @@ gbp_sysprof_perspective_set_reader (GbpSysprofPerspective *self,
gtk_stack_set_visible_child_name (self->stack, "results");
}
+static void
+gbp_sysprof_perspective_profiler_failed (GbpSysprofPerspective *self,
+ const GError *error,
+ SpProfiler *profiler)
+{
+ IDE_ENTRY;
+
+ g_assert (GBP_IS_SYSPROF_PERSPECTIVE (self));
+ g_assert (error != NULL);
+ g_assert (SP_IS_PROFILER (profiler));
+
+ gtk_stack_set_visible_child_name (self->stack, "failed");
+
+ gtk_label_set_label (self->info_bar_label, error->message);
+ gtk_revealer_set_reveal_child (self->info_bar_revealer, TRUE);
+
+ IDE_EXIT;
+}
+
void
gbp_sysprof_perspective_set_profiler (GbpSysprofPerspective *self,
SpProfiler *profiler)
@@ -163,7 +216,12 @@ gbp_sysprof_perspective_set_profiler (GbpSysprofPerspective *self,
if (profiler != NULL)
{
gtk_stack_set_visible_child_name (self->stack, "recording");
- /* TODO: Wire up failure state */
+
+ g_signal_connect_object (profiler,
+ "failed",
+ G_CALLBACK (gbp_sysprof_perspective_profiler_failed),
+ self,
+ G_CONNECT_SWAPPED);
}
}
diff --git a/plugins/sysprof/gbp-sysprof-perspective.h b/plugins/sysprof/gbp-sysprof-perspective.h
index b61272b..e953860 100644
--- a/plugins/sysprof/gbp-sysprof-perspective.h
+++ b/plugins/sysprof/gbp-sysprof-perspective.h
@@ -28,11 +28,12 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GbpSysprofPerspective, gbp_sysprof_perspective, GBP, SYSPROF_PERSPECTIVE, GtkBin)
-SpZoomManager *gbp_sysprof_perspective_get_zoom_manager (GbpSysprofPerspective *self);
-void gbp_sysprof_perspective_set_profiler (GbpSysprofPerspective *self,
- SpProfiler *profiler);
-void gbp_sysprof_perspective_set_reader (GbpSysprofPerspective *self,
- SpCaptureReader *reader);
+SpZoomManager *gbp_sysprof_perspective_get_zoom_manager (GbpSysprofPerspective *self);
+void gbp_sysprof_perspective_set_profiler (GbpSysprofPerspective *self,
+ SpProfiler *profiler);
+SpCaptureReader *gbp_sysprof_perspective_get_reader (GbpSysprofPerspective *self);
+void gbp_sysprof_perspective_set_reader (GbpSysprofPerspective *self,
+ SpCaptureReader *reader);
G_END_DECLS
diff --git a/plugins/sysprof/gbp-sysprof-perspective.ui b/plugins/sysprof/gbp-sysprof-perspective.ui
index 6d1ac2b..5632cd8 100644
--- a/plugins/sysprof/gbp-sysprof-perspective.ui
+++ b/plugins/sysprof/gbp-sysprof-perspective.ui
@@ -2,55 +2,104 @@
<interface>
<template class="GbpSysprofPerspective" parent="GtkBin">
<child>
- <object class="GtkStack" id="stack">
- <property name="homogeneous">false</property>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
<property name="visible">true</property>
<child>
- <object class="SpEmptyStateView">
- <property name="subtitle" translatable="yes">Select “Run with profiler” from the run menu to
begin</property>
- <property name="visible">true</property>
- </object>
- <packing>
- <property name="name">empty</property>
- </packing>
- </child>
- <child>
- <object class="SpRecordingStateView" id="recording_view">
+ <object class="GtkRevealer" id="info_bar_revealer">
<property name="visible">true</property>
+ <property name="reveal-child">false</property>
+ <child>
+ <object class="GtkInfoBar" id="info_bar">
+ <property name="visible">true</property>
+ <child internal-child="content_area">
+ <object class="GtkBox">
+ <child>
+ <object class="GtkLabel" id="info_bar_label">
+ <property name="hexpand">true</property>
+ <property name="label">Failure</property>
+ <property name="visible">true</property>
+ <property name="wrap">true</property>
+ <property name="xalign">0</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="info_bar_close">
+ <property name="label" translatable="yes">_Close</property>
+ <property name="use-underline">true</property>
+ <property name="visible">true</property>
+ <property name="width-request">100</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">info_bar_close</action-widget>
+ </action-widgets>
+ </object>
+ </child>
</object>
- <packing>
- <property name="name">recording</property>
- </packing>
</child>
<child>
- <object class="PnlMultiPaned">
+ <object class="GtkStack" id="stack">
+ <property name="homogeneous">false</property>
<property name="visible">true</property>
<child>
- <object class="SpVisualizerView" id="visualizers">
+ <object class="SpEmptyStateView">
+ <property name="subtitle" translatable="yes">Select “Run with profiler” from the run menu to
begin</property>
<property name="visible">true</property>
- <property name="zoom-manager">zoom_manager</property>
- <child type="visualizer">
- <object class="SpCpuVisualizerRow" id="cpu_visualizer">
- <property name="title" translatable="yes">CPU</property>
- <property name="height-request">75</property>
- <property name="selectable">false</property>
- <property name="y-lower">0.0</property>
- <property name="y-upper">100.0</property>
- <property name="visible">true</property>
- </object>
- </child>
</object>
+ <packing>
+ <property name="name">empty</property>
+ </packing>
</child>
<child>
- <object class="SpCallgraphView" id="callgraph_view">
- <property name="vexpand">true</property>
+ <object class="SpRecordingStateView" id="recording_view">
<property name="visible">true</property>
</object>
+ <packing>
+ <property name="name">recording</property>
+ </packing>
+ </child>
+ <child>
+ <object class="SpFailedStateView" id="failed_view">
+ <property name="visible">true</property>
+ </object>
+ <packing>
+ <property name="name">failed</property>
+ </packing>
+ </child>
+ <child>
+ <object class="PnlMultiPaned">
+ <property name="visible">true</property>
+ <child>
+ <object class="SpVisualizerView" id="visualizers">
+ <property name="visible">true</property>
+ <property name="zoom-manager">zoom_manager</property>
+ <child type="visualizer">
+ <object class="SpCpuVisualizerRow" id="cpu_visualizer">
+ <property name="title" translatable="yes">CPU</property>
+ <property name="height-request">75</property>
+ <property name="selectable">false</property>
+ <property name="y-lower">0.0</property>
+ <property name="y-upper">100.0</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="SpCallgraphView" id="callgraph_view">
+ <property name="vexpand">true</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="name">results</property>
+ </packing>
</child>
</object>
- <packing>
- <property name="name">results</property>
- </packing>
</child>
</object>
</child>
diff --git a/plugins/sysprof/gbp-sysprof-workbench-addin.c b/plugins/sysprof/gbp-sysprof-workbench-addin.c
index 8dfe35a..fda459f 100644
--- a/plugins/sysprof/gbp-sysprof-workbench-addin.c
+++ b/plugins/sysprof/gbp-sysprof-workbench-addin.c
@@ -41,6 +41,21 @@ G_DEFINE_TYPE_EXTENDED (GbpSysprofWorkbenchAddin, gbp_sysprof_workbench_addin, G
G_IMPLEMENT_INTERFACE (IDE_TYPE_WORKBENCH_ADDIN, workbench_addin_iface_init))
static void
+gbp_sysprof_workbench_addin_update_controls (GbpSysprofWorkbenchAddin *self)
+{
+ IdePerspective *perspective;
+ gboolean visible;
+
+ g_assert (GBP_IS_SYSPROF_WORKBENCH_ADDIN (self));
+
+ perspective = ide_workbench_get_visible_perspective (self->workbench);
+ visible = GBP_IS_SYSPROF_PERSPECTIVE (perspective) &&
+ !!gbp_sysprof_perspective_get_reader (GBP_SYSPROF_PERSPECTIVE (perspective));
+
+ gtk_widget_set_visible (GTK_WIDGET (self->zoom_controls), visible);
+}
+
+static void
profiler_stopped (GbpSysprofWorkbenchAddin *self,
SpProfiler *profiler)
{
@@ -73,6 +88,8 @@ profiler_stopped (GbpSysprofWorkbenchAddin *self,
ide_workbench_set_visible_perspective_name (self->workbench, "profiler");
+ gbp_sysprof_workbench_addin_update_controls (self);
+
IDE_EXIT;
}
@@ -129,6 +146,14 @@ profiler_run_handler (IdeRunManager *run_manager,
self->profiler = sp_local_profiler_new ();
+ g_signal_connect_object (self->profiler,
+ "stopped",
+ G_CALLBACK (gbp_sysprof_workbench_addin_update_controls),
+ self,
+ G_CONNECT_SWAPPED);
+
+ gtk_widget_hide (GTK_WIDGET (self->zoom_controls));
+
sp_profiler_set_whole_system (SP_PROFILER (self->profiler), FALSE);
proc_source = sp_proc_source_new ();
@@ -191,6 +216,8 @@ gbp_sysprof_workbench_addin_open_cb (GObject *object,
}
gbp_sysprof_perspective_set_reader (self->perspective, reader);
+
+ gbp_sysprof_workbench_addin_update_controls (self);
}
static void
@@ -484,14 +511,11 @@ gbp_sysprof_workbench_addin_perspective_set (IdeWorkbenchAddin *addin,
IdePerspective *perspective)
{
GbpSysprofWorkbenchAddin *self = (GbpSysprofWorkbenchAddin *)addin;
- gboolean visible;
g_assert (IDE_IS_WORKBENCH_ADDIN (addin));
g_assert (IDE_IS_PERSPECTIVE (perspective));
- visible = GBP_IS_SYSPROF_PERSPECTIVE (perspective);
-
- gtk_widget_set_visible (GTK_WIDGET (self->zoom_controls), visible);
+ gbp_sysprof_workbench_addin_update_controls (self);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]