[gnome-builder/wip/chergert/visualizers] sysprof: add empty and recording state views



commit ad5095100056eadf53a75191015ebe8988cfc3f3
Author: Christian Hergert <chergert redhat com>
Date:   Sun Oct 9 15:28:41 2016 -0700

    sysprof: add empty and recording state views
    
    These have always been missing in our perspective, which makes
    things feel too different from the real Sysprof.

 plugins/sysprof/gbp-sysprof-perspective.c     |   31 ++++++++++++++++++++++--
 plugins/sysprof/gbp-sysprof-perspective.h     |    6 +++-
 plugins/sysprof/gbp-sysprof-perspective.ui    |   11 ++++++++-
 plugins/sysprof/gbp-sysprof-workbench-addin.c |    4 +++
 4 files changed, 46 insertions(+), 6 deletions(-)
---
diff --git a/plugins/sysprof/gbp-sysprof-perspective.c b/plugins/sysprof/gbp-sysprof-perspective.c
index ca5fd49..bbe51f0 100644
--- a/plugins/sysprof/gbp-sysprof-perspective.c
+++ b/plugins/sysprof/gbp-sysprof-perspective.c
@@ -26,10 +26,12 @@
 
 struct _GbpSysprofPerspective
 {
-  GtkBin            parent_instance;
+  GtkBin                parent_instance;
 
-  SpCallgraphView  *callgraph_view;
-  SpVisualizerView *visualizers;
+  GtkStack             *stack;
+  SpCallgraphView      *callgraph_view;
+  SpVisualizerView     *visualizers;
+  SpRecordingStateView *recording_view;
 };
 
 static void perspective_iface_init (IdePerspectiveInterface *iface);
@@ -44,11 +46,14 @@ gbp_sysprof_perspective_class_init (GbpSysprofPerspectiveClass *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, stack);
+  gtk_widget_class_bind_template_child (widget_class, GbpSysprofPerspective, recording_view);
   gtk_widget_class_bind_template_child (widget_class, GbpSysprofPerspective, visualizers);
 
   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_RECORDING_STATE_VIEW);
   g_type_ensure (SP_TYPE_VISUALIZER_VIEW);
 }
 
@@ -130,6 +135,8 @@ gbp_sysprof_perspective_set_reader (GbpSysprofPerspective *self,
   if (reader == NULL)
     {
       sp_callgraph_view_set_profile (self->callgraph_view, NULL);
+      sp_visualizer_view_set_reader (self->visualizers, NULL);
+      gtk_stack_set_visible_child_name (self->stack, "empty");
       return;
     }
 
@@ -138,4 +145,22 @@ gbp_sysprof_perspective_set_reader (GbpSysprofPerspective *self,
   sp_profile_generate (profile, NULL, generate_cb, g_object_ref (self));
 
   sp_visualizer_view_set_reader (self->visualizers, reader);
+
+  gtk_stack_set_visible_child_name (self->stack, "results");
+}
+
+void
+gbp_sysprof_perspective_set_profiler (GbpSysprofPerspective *self,
+                                      SpProfiler            *profiler)
+{
+  g_return_if_fail (GBP_IS_SYSPROF_PERSPECTIVE (self));
+  g_return_if_fail (!profiler || SP_IS_PROFILER (profiler));
+
+  sp_recording_state_view_set_profiler (self->recording_view, profiler);
+
+  if (profiler != NULL)
+    {
+      gtk_stack_set_visible_child_name (self->stack, "recording");
+      /* TODO: Wire up failure state */
+    }
 }
diff --git a/plugins/sysprof/gbp-sysprof-perspective.h b/plugins/sysprof/gbp-sysprof-perspective.h
index 54355c4..7aff7ab 100644
--- a/plugins/sysprof/gbp-sysprof-perspective.h
+++ b/plugins/sysprof/gbp-sysprof-perspective.h
@@ -28,8 +28,10 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (GbpSysprofPerspective, gbp_sysprof_perspective, GBP, SYSPROF_PERSPECTIVE, GtkBin)
 
-void gbp_sysprof_perspective_set_reader (GbpSysprofPerspective *self,
-                                         SpCaptureReader       *reader);
+void gbp_sysprof_perspective_set_profiler (GbpSysprofPerspective *self,
+                                           SpProfiler            *profiler);
+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 0fcfdac..1b7afc0 100644
--- a/plugins/sysprof/gbp-sysprof-perspective.ui
+++ b/plugins/sysprof/gbp-sysprof-perspective.ui
@@ -2,11 +2,12 @@
 <interface>
   <template class="GbpSysprofPerspective" parent="GtkBin">
     <child>
-      <object class="GtkStack">
+      <object class="GtkStack" id="stack">
         <property name="homogeneous">false</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>
@@ -14,6 +15,14 @@
           </packing>
         </child>
         <child>
+          <object class="SpRecordingStateView" id="recording_view">
+            <property name="visible">true</property>
+          </object>
+          <packing>
+            <property name="name">recording</property>
+          </packing>
+        </child>
+        <child>
           <object class="PnlMultiPaned">
             <property name="visible">true</property>
             <child>
diff --git a/plugins/sysprof/gbp-sysprof-workbench-addin.c b/plugins/sysprof/gbp-sysprof-workbench-addin.c
index 8f338e0..1788d8d 100644
--- a/plugins/sysprof/gbp-sysprof-workbench-addin.c
+++ b/plugins/sysprof/gbp-sysprof-workbench-addin.c
@@ -160,6 +160,10 @@ profiler_run_handler (IdeRunManager *run_manager,
                            G_CALLBACK (profiler_stopped),
                            self,
                            G_CONNECT_SWAPPED);
+
+  gbp_sysprof_perspective_set_profiler (self->perspective, self->profiler);
+
+  ide_workbench_set_visible_perspective (self->workbench, IDE_PERSPECTIVE (self->perspective));
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]