[libdazzle] examples: add GJS cpu graph example



commit 18fa6a6572b61dd2ad1ead4cb53e56c3f0bc81b8
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jun 26 13:19:26 2017 -0700

    examples: add GJS cpu graph example

 examples/graph/js/cpu_graph.js |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/examples/graph/js/cpu_graph.js b/examples/graph/js/cpu_graph.js
new file mode 100755
index 0000000..8fa8cbf
--- /dev/null
+++ b/examples/graph/js/cpu_graph.js
@@ -0,0 +1,31 @@
+#!/usr/bin/env gjs
+
+imports.gi.versions["Gdk"] = "3.0"
+imports.gi.versions["Gtk"] = "3.0"
+
+const GLib = imports.gi.GLib;
+const Gdk = imports.gi.Gdk;
+const Gtk = imports.gi.Gtk;
+const Dazzle = imports.gi.Dazzle;
+
+Gtk.init(null);
+
+/*
+ * NOTE: If you are using Dazzle.Application as your base GApplication,
+ *       then the following theme loading is handled for you. You need
+ *       not manually register CSS.
+ */
+Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
+                                         Dazzle.CssProvider.new ("resource:///org/gnome/dazzle/themes"),
+                                         Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+let win = new Gtk.Window({title: "Cpu Graph"});
+let graph = new Dazzle.CpuGraph({timespan: GLib.TIME_SPAN_MINUTE, max_samples: 120});
+
+win.add(graph);
+win.connect('delete-event', function(){
+  Gtk.main_quit();
+});
+win.show_all();
+
+Gtk.main();


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