[gnome-builder] sysmon: add prototype sysmon plugin



commit f503f57dd29af767d8691fbfa05525db690ff6de
Author: Christian Hergert <christian hergert me>
Date:   Sun Jun 7 23:51:46 2015 -0700

    sysmon: add prototype sysmon plugin
    
    Just somewhere to land the cpu graphing code. Not final design or anything.
    Once we get a few more of these in here, we can look at simplifying the
    abstractions.

 configure.ac                           |    1 +
 plugins/Makefile.am                    |    1 +
 plugins/sysmon/Makefile.am             |   47 +++++++++++
 plugins/sysmon/gb-sysmon-addin.c       |  141 ++++++++++++++++++++++++++++++++
 plugins/sysmon/gb-sysmon-addin.h       |   32 +++++++
 plugins/sysmon/gb-sysmon-panel.c       |   54 ++++++++++++
 plugins/sysmon/gb-sysmon-panel.h       |   32 +++++++
 plugins/sysmon/gb-sysmon-panel.ui      |   15 ++++
 plugins/sysmon/gb-sysmon.gresource.xml |    7 ++
 plugins/sysmon/gb-sysmon.plugin        |    6 ++
 src/Makefile.am                        |    1 +
 11 files changed, 337 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4016725..df957de 100644
--- a/configure.ac
+++ b/configure.ac
@@ -381,6 +381,7 @@ AC_CONFIG_FILES([
        plugins/command-bar/Makefile
        plugins/devhelp/Makefile
        plugins/symbol-tree/Makefile
+       plugins/sysmon/Makefile
 
        data/Makefile
        data/gsettings/Makefile
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 225ff3e..7a9a9ad 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -2,6 +2,7 @@ SUBDIRS = \
        command-bar \
        devhelp \
        symbol-tree \
+       sysmon \
        $(NULL)
 
 -include $(top_srcdir)/git.mk
diff --git a/plugins/sysmon/Makefile.am b/plugins/sysmon/Makefile.am
new file mode 100644
index 0000000..387cb68
--- /dev/null
+++ b/plugins/sysmon/Makefile.am
@@ -0,0 +1,47 @@
+DISTCLEANFILES =
+BUILT_SOURCES =
+CLEANFILES =
+EXTRA_DIST =
+
+noinst_LTLIBRARIES = libsysmon.la
+
+libsysmon_la_SOURCES = \
+       gb-sysmon-panel.c \
+       gb-sysmon-panel.h \
+       gb-sysmon-addin.c \
+       gb-sysmon-addin.h \
+       $(NULL)
+
+nodist_libsysmon_la_SOURCES = \
+       gb-sysmon-resources.c \
+       gb-sysmon-resources.h \
+       $(NULL)
+
+libsysmon_la_CFLAGS = \
+       $(BUILDER_CFLAGS) \
+       -I$(top_srcdir)/libide \
+       -I$(top_srcdir)/src \
+       -I$(top_srcdir)/src/workbench \
+       -I$(top_srcdir)/src/workspace \
+       -I$(top_srcdir)/contrib/egg \
+       -I$(top_srcdir)/contrib/rg \
+       $(NULL)
+
+libsysmon_la_LIBADD = \
+       $(BUILDER_LIBS) \
+       $(top_builddir)/contrib/rg/librg.la \
+       $(NULL)
+
+libsysmon_la_LDFLAGS = \
+       -avoid-version \
+       -module \
+       $(NULL)
+
+glib_resources_c = gb-sysmon-resources.c
+glib_resources_h = gb-sysmon-resources.h
+glib_resources_xml = gb-sysmon.gresource.xml
+glib_resources_namespace = gb_sysmon
+include $(top_srcdir)/build/autotools/Makefile.am.gresources
+
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/sysmon/gb-sysmon-addin.c b/plugins/sysmon/gb-sysmon-addin.c
new file mode 100644
index 0000000..7808b59
--- /dev/null
+++ b/plugins/sysmon/gb-sysmon-addin.c
@@ -0,0 +1,141 @@
+/* gb-sysmon-addin.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib/gi18n.h>
+
+#include "gb-plugins.h"
+#include "gb-sysmon-addin.h"
+#include "gb-sysmon-panel.h"
+#include "gb-sysmon-resources.h"
+#include "gb-workbench-addin.h"
+#include "gb-workspace.h"
+
+struct _GbSysmonAddin
+{
+  GObject      parent_instance;
+
+  GbWorkbench *workbench;
+  GtkWidget   *panel;
+};
+
+static void workbench_addin_iface_init (GbWorkbenchAddinInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GbSysmonAddin, gb_sysmon_addin, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (GB_TYPE_WORKBENCH_ADDIN,
+                                                workbench_addin_iface_init))
+
+enum {
+  PROP_0,
+  PROP_WORKBENCH,
+  LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+static void
+gb_sysmon_addin_load (GbWorkbenchAddin *addin)
+{
+  GbSysmonAddin *self = (GbSysmonAddin *)addin;
+  GtkWidget *workspace;
+  GtkWidget *pane;
+
+  g_assert (GB_IS_SYSMON_ADDIN (self));
+
+  workspace = gb_workbench_get_workspace (self->workbench);
+  pane = gb_workspace_get_bottom_pane (GB_WORKSPACE (workspace));
+  self->panel = g_object_new (GB_TYPE_SYSMON_PANEL, "visible", TRUE, NULL);
+  gb_workspace_pane_add_page (GB_WORKSPACE_PANE (pane),
+                              GTK_WIDGET (self->panel),
+                              _("System Monitor"),
+                              "utilities-system-monitor-symbolic");
+}
+
+static void
+gb_sysmon_addin_unload (GbWorkbenchAddin *addin)
+{
+  GbSysmonAddin *self = (GbSysmonAddin *)addin;
+  GtkWidget *parent;
+
+  parent = gtk_widget_get_parent (self->panel);
+  gtk_container_remove (GTK_CONTAINER (parent), self->panel);
+  self->panel = NULL;
+}
+
+static void
+gb_sysmon_addin_finalize (GObject *object)
+{
+  GbSysmonAddin *self = (GbSysmonAddin *)object;
+
+  ide_clear_weak_pointer (&self->workbench);
+
+  G_OBJECT_CLASS (gb_sysmon_addin_parent_class)->finalize (object);
+}
+
+static void
+gb_sysmon_addin_set_property (GObject      *object,
+                              guint         prop_id,
+                              const GValue *value,
+                              GParamSpec   *pspec)
+{
+  GbSysmonAddin *self = GB_SYSMON_ADDIN (object);
+
+  switch (prop_id)
+    {
+    case PROP_WORKBENCH:
+      ide_set_weak_pointer (&self->workbench, g_value_get_object (value));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+workbench_addin_iface_init (GbWorkbenchAddinInterface *iface)
+{
+  iface->load = gb_sysmon_addin_load;
+  iface->unload = gb_sysmon_addin_unload;
+}
+
+static void
+gb_sysmon_addin_class_init (GbSysmonAddinClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = gb_sysmon_addin_finalize;
+  object_class->set_property = gb_sysmon_addin_set_property;
+
+  gParamSpecs [PROP_WORKBENCH] =
+    g_param_spec_object ("workbench",
+                         _("Workbench"),
+                         _("Workbench"),
+                         GB_TYPE_WORKBENCH,
+                         (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_properties (object_class, LAST_PROP, gParamSpecs);
+}
+
+static void
+gb_sysmon_addin_init (GbSysmonAddin *self)
+{
+}
+
+GB_DEFINE_EMBEDDED_PLUGIN (gb_sysmon,
+                           gb_sysmon_get_resource (),
+                           "resource:///org/gnome/builder/plugins/sysmon/gb-sysmon.plugin",
+                           GB_DEFINE_PLUGIN_TYPE (GB_TYPE_WORKBENCH_ADDIN, GB_TYPE_SYSMON_ADDIN))
diff --git a/plugins/sysmon/gb-sysmon-addin.h b/plugins/sysmon/gb-sysmon-addin.h
new file mode 100644
index 0000000..914d962
--- /dev/null
+++ b/plugins/sysmon/gb-sysmon-addin.h
@@ -0,0 +1,32 @@
+/* gb-sysmon-addin.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GB_SYSMON_ADDIN_H
+#define GB_SYSMON_ADDIN_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_SYSMON_ADDIN (gb_sysmon_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (GbSysmonAddin, gb_sysmon_addin, GB, SYSMON_ADDIN, GObject)
+
+G_END_DECLS
+
+#endif /* GB_SYSMON_ADDIN_H */
diff --git a/plugins/sysmon/gb-sysmon-panel.c b/plugins/sysmon/gb-sysmon-panel.c
new file mode 100644
index 0000000..c12f32a
--- /dev/null
+++ b/plugins/sysmon/gb-sysmon-panel.c
@@ -0,0 +1,54 @@
+/* gb-sysmon-panel.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib/gi18n.h>
+#include <realtime-graphs.h>
+
+#include "gb-sysmon-panel.h"
+
+struct _GbSysmonPanel
+{
+  GtkBox      parent_instance;
+  RgCpuGraph *cpu_graph;
+};
+
+G_DEFINE_TYPE (GbSysmonPanel, gb_sysmon_panel, GTK_TYPE_BOX)
+
+static void
+gb_sysmon_panel_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (gb_sysmon_panel_parent_class)->finalize (object);
+}
+
+static void
+gb_sysmon_panel_class_init (GbSysmonPanelClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  object_class->finalize = gb_sysmon_panel_finalize;
+
+  gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/builder/plugins/sysmon/gb-sysmon-panel.ui");
+  gtk_widget_class_bind_template_child (widget_class, GbSysmonPanel, cpu_graph);
+}
+
+static void
+gb_sysmon_panel_init (GbSysmonPanel *self)
+{
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/plugins/sysmon/gb-sysmon-panel.h b/plugins/sysmon/gb-sysmon-panel.h
new file mode 100644
index 0000000..195e77f
--- /dev/null
+++ b/plugins/sysmon/gb-sysmon-panel.h
@@ -0,0 +1,32 @@
+/* gb-sysmon-panel.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GB_SYSMON_PANEL_H
+#define GB_SYSMON_PANEL_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_SYSMON_PANEL (gb_sysmon_panel_get_type())
+
+G_DECLARE_FINAL_TYPE (GbSysmonPanel, gb_sysmon_panel, GB, SYSMON_PANEL, GtkBox)
+
+G_END_DECLS
+
+#endif /* GB_SYSMON_PANEL_H */
diff --git a/plugins/sysmon/gb-sysmon-panel.ui b/plugins/sysmon/gb-sysmon-panel.ui
new file mode 100644
index 0000000..196b564
--- /dev/null
+++ b/plugins/sysmon/gb-sysmon-panel.ui
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.16 -->
+  <template class="GbSysmonPanel" parent="GtkBox">
+    <property name="visible">true</property>
+    <child>
+      <object class="RgCpuGraph" id="cpu_graph">
+        <property name="expand">true</property>
+        <property name="visible">true</property>
+        <property name="timespan">30000000</property>
+        <property name="max-samples">60</property>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/plugins/sysmon/gb-sysmon.gresource.xml b/plugins/sysmon/gb-sysmon.gresource.xml
new file mode 100644
index 0000000..737066b
--- /dev/null
+++ b/plugins/sysmon/gb-sysmon.gresource.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/builder/plugins/sysmon">
+    <file>gb-sysmon.plugin</file>
+    <file>gb-sysmon-panel.ui</file>
+  </gresource>
+</gresources>
diff --git a/plugins/sysmon/gb-sysmon.plugin b/plugins/sysmon/gb-sysmon.plugin
new file mode 100644
index 0000000..8056d3b
--- /dev/null
+++ b/plugins/sysmon/gb-sysmon.plugin
@@ -0,0 +1,6 @@
+[Plugin]
+Module=sysmon
+Name=System Monitor
+Description=Basic system information
+Authors=Christian Hergert <christian hergert me>
+Copyright=Copyright © 2015 Christian Hergert
diff --git a/src/Makefile.am b/src/Makefile.am
index bab880e..187101b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -212,6 +212,7 @@ gnome_builder_PLUGINS = \
        devhelp \
        command-bar \
        symbol-tree \
+       sysmon \
        $(NULL)
 
 gnome_builder_SOURCES = \


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