[gnome-builder] editor: add cpu graph easter egg



commit c8e9beddb4a4b613abcce6fec5be13338844581d
Author: Christian Hergert <christian hergert me>
Date:   Mon Jun 1 22:42:51 2015 -0700

    editor: add cpu graph easter egg
    
    This is mostly so we can watch performance easily while building Builder.
    However, there will probably be some neat things we can do later on to
    make this type of feature more generally available.
    
    Either way, helpful to get things going.
    
    From Command Bar: cpu-graph

 data/ui/gb-editor-workspace.ui           |   14 +++++++++++++
 src/Makefile.am                          |    2 +
 src/editor/gb-editor-workspace-actions.c |   31 +++++++++++++++++++++++++++++-
 src/editor/gb-editor-workspace-private.h |    4 +++
 src/editor/gb-editor-workspace.c         |    3 ++
 5 files changed, 53 insertions(+), 1 deletions(-)
---
diff --git a/data/ui/gb-editor-workspace.ui b/data/ui/gb-editor-workspace.ui
index 9bef3dc..931b78a 100644
--- a/data/ui/gb-editor-workspace.ui
+++ b/data/ui/gb-editor-workspace.ui
@@ -80,6 +80,20 @@
                 </child>
               </object>
             </child>
+            <child>
+              <object class="GtkSeparator" id="cpu_graph_sep">
+                <property name="visible">false</property>
+                <property name="orientation">horizontal</property>
+              </object>
+            </child>
+            <child>
+              <object class="RgCpuGraph" id="cpu_graph">
+                <property name="visible">false</property>
+                <property name="height-request">50</property>
+                <property name="timespan">15000000</property>
+                <property name="max-samples">30</property>
+              </object>
+            </child>
           </object>
         </child>
         <child>
diff --git a/src/Makefile.am b/src/Makefile.am
index ebb37fc..52926a7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -190,6 +190,7 @@ libgnome_builder_la_LIBADD = \
        $(top_builddir)/contrib/egg/libegg.la \
        $(top_builddir)/contrib/gedit/libgedit.la \
        $(top_builddir)/contrib/nautilus/libnautilus.la \
+       $(top_builddir)/contrib/rg/librg.la \
        -lm
 
 libgnome_builder_la_CFLAGS = \
@@ -227,6 +228,7 @@ libgnome_builder_la_CFLAGS = \
        -I$(top_srcdir)/contrib/egg \
        -I$(top_srcdir)/contrib/gedit \
        -I$(top_srcdir)/contrib/nautilus \
+       -I$(top_srcdir)/contrib/rg \
        $(NULL)
 
 gnome_builder_SOURCES = main.c
diff --git a/src/editor/gb-editor-workspace-actions.c b/src/editor/gb-editor-workspace-actions.c
index 2297875..8ac5ab8 100644
--- a/src/editor/gb-editor-workspace-actions.c
+++ b/src/editor/gb-editor-workspace-actions.c
@@ -132,7 +132,35 @@ gb_editor_workspace_actions_focus_sidebar (GSimpleAction *action,
 }
 
 static void
-gb_editor_workspace_actions_focus_stack (GSimpleAction *aciton,
+gb_editor_workspace_actions_cpu_graph (GSimpleAction *action,
+                                       GVariant      *variant,
+                                       gpointer       user_data)
+{
+  GbEditorWorkspace *self = user_data;
+
+  g_assert (GB_IS_EDITOR_WORKSPACE (self));
+
+  /*
+   * FIXME:
+   *
+   * Hi, you've found a hidden feature.
+   *
+   * I'm not sure how we want to use this long term, but I really want to start
+   * watching system performance while hacking on Builder. So, for that purpose,
+   * we'll shove this performance graph right in here.
+   *
+   * Longer term, I hope to show things like this when running applications and
+   * collection runtime statistics for later analysis. But first things first.
+   */
+
+  gtk_widget_set_visible (GTK_WIDGET (self->cpu_graph),
+                          !gtk_widget_get_visible (GTK_WIDGET (self->cpu_graph)));
+  gtk_widget_set_visible (GTK_WIDGET (self->cpu_graph_sep),
+                          !gtk_widget_get_visible (GTK_WIDGET (self->cpu_graph_sep)));
+}
+
+static void
+gb_editor_workspace_actions_focus_stack (GSimpleAction *action,
                                          GVariant      *variant,
                                          gpointer       user_data)
 {
@@ -164,6 +192,7 @@ static const GActionEntry GbEditorWorkspaceActions[] = {
   { "focus-sidebar", gb_editor_workspace_actions_focus_sidebar },
   { "show-sidebar", NULL, NULL, "false", gb_editor_workspace_actions_show_sidebar },
   { "toggle-sidebar", gb_editor_workspace_actions_toggle_sidebar },
+  { "cpu-graph", gb_editor_workspace_actions_cpu_graph },
 };
 
 void
diff --git a/src/editor/gb-editor-workspace-private.h b/src/editor/gb-editor-workspace-private.h
index 5f4e2b5..6556912 100644
--- a/src/editor/gb-editor-workspace-private.h
+++ b/src/editor/gb-editor-workspace-private.h
@@ -19,6 +19,8 @@
 #ifndef GB_EDITOR_WORKSPACE_PRIVATE_H
 #define GB_EDITOR_WORKSPACE_PRIVATE_H
 
+#include <realtime-graphs.h>
+
 #include "gb-project-tree.h"
 #include "gb-view-grid.h"
 #include "gb-workspace.h"
@@ -39,6 +41,8 @@ struct _GbEditorWorkspace
   GtkSpinner    *project_spinner;
   GbProjectTree *project_tree;
   GbViewGrid    *view_grid;
+  GtkSeparator  *cpu_graph_sep;
+  RgCpuGraph    *cpu_graph;
 
   guint          project_tree_position_timeout;
 };
diff --git a/src/editor/gb-editor-workspace.c b/src/editor/gb-editor-workspace.c
index 84388cd..95f74f3 100644
--- a/src/editor/gb-editor-workspace.c
+++ b/src/editor/gb-editor-workspace.c
@@ -369,6 +369,8 @@ gb_editor_workspace_class_init (GbEditorWorkspaceClass *klass)
 
   GB_WIDGET_CLASS_TEMPLATE (klass, "gb-editor-workspace.ui");
 
+  GB_WIDGET_CLASS_BIND (klass, GbEditorWorkspace, cpu_graph);
+  GB_WIDGET_CLASS_BIND (klass, GbEditorWorkspace, cpu_graph_sep);
   GB_WIDGET_CLASS_BIND (klass, GbEditorWorkspace, project_button);
   GB_WIDGET_CLASS_BIND (klass, GbEditorWorkspace, project_paned);
   GB_WIDGET_CLASS_BIND (klass, GbEditorWorkspace, project_popover);
@@ -380,6 +382,7 @@ gb_editor_workspace_class_init (GbEditorWorkspaceClass *klass)
 
   g_type_ensure (GB_TYPE_PROJECT_TREE);
   g_type_ensure (GB_TYPE_VIEW_GRID);
+  g_type_ensure (RG_TYPE_CPU_GRAPH);
 }
 
 static void


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