Hooked up David Malcolm's 'sparkline' widget for CPU display
This commit is contained in:
parent
56f857a637
commit
7b6e3d375d
|
@ -9,3 +9,8 @@ Makefile\.in$
|
|||
.*\.gladep$
|
||||
.*\.bak$
|
||||
.*\.pyc$
|
||||
^compile$
|
||||
^depcomp$
|
||||
^ltmain\.sh$
|
||||
^config\.guess$
|
||||
^config\.sub$
|
|
@ -1,3 +1,4 @@
|
|||
ACLOCAL_AMFLAGS = -I m4/
|
||||
|
||||
SUBDIRS = src pixmaps
|
||||
|
||||
|
|
11
configure.ac
11
configure.ac
|
@ -1,9 +1,18 @@
|
|||
AC_INIT(gnome-virt-manager.spec.in)
|
||||
AM_INIT_AUTOMAKE(gnome-virt-manager, 0.1.0)
|
||||
AM_INIT_AUTOMAKE(gnome-virt-manager, 0.1.1)
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_LIBTOOL
|
||||
|
||||
AC_PYTHON_DEVEL([>= '2.3.4'])
|
||||
|
||||
PKG_CHECK_MODULES(PYGTK2, pygtk-2.0 >= 1.99.11)
|
||||
PKG_CHECK_MODULES(GTK2, gtk+-2.0 >= 2.2.0)
|
||||
|
||||
AC_OUTPUT(Makefile
|
||||
src/Makefile
|
||||
src/virtManager/Makefile
|
||||
src/vncViewer/Makefile
|
||||
src/graphWidgets/Makefile
|
||||
pixmaps/Makefile
|
||||
gnome-virt-manager.spec)
|
||||
|
|
|
@ -27,7 +27,8 @@ Requires: python-imaging
|
|||
#Requires: pygame
|
||||
# But not both!
|
||||
|
||||
BuildArchitectures: noarch
|
||||
BuildRequires: pygtk2-devel
|
||||
BuildRequires: gtk2-devel
|
||||
|
||||
%description
|
||||
GNOME Virtual Machine Manager provides a graphical tool for administering
|
||||
|
@ -44,17 +45,20 @@ make %{?_smp_mflags}
|
|||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
make install DESTDIR=$RPM_BUILD_ROOT
|
||||
rm -f $RPM_BUILD_ROOT%{_libdir}/%{name}/sparkline.a
|
||||
rm -f $RPM_BUILD_ROOT%{_libdir}/%{name}/sparkline.la
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
/usr/bin/%{name}
|
||||
/usr/libexec/%{name}-launch
|
||||
/usr/share/%{name}/*
|
||||
/usr/share/applications/%{name}.desktop
|
||||
/usr/share/dbus-1/services/%{name}.service
|
||||
%{_bindir}/%{name}
|
||||
%{_libexecdir}/%{name}-launch
|
||||
%{_libdir}/%{name}/*
|
||||
%{_datadir}/%{name}/*
|
||||
%{_datadir}/applications/%{name}.desktop
|
||||
%{_datadir}/dbus-1/services/%{name}.service
|
||||
|
||||
%changelog
|
||||
* Fri Jun 16 2006 Daniel Berrange <berrange@redhat.com> - 0.1.0-1
|
||||
|
|
|
@ -0,0 +1,185 @@
|
|||
dnl @synopsis AC_PYTHON_DEVEL([version])
|
||||
dnl
|
||||
dnl Checks for Python and tries to get the include path to 'Python.h'.
|
||||
dnl It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS) output
|
||||
dnl variables. Also exports $(PYTHON_EXTRA_LIBS) and
|
||||
dnl $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code.
|
||||
dnl
|
||||
dnl You can search for some particular version of Python by passing a
|
||||
dnl parameter to this macro, for example ">= '2.3.1'", or "== '2.4'".
|
||||
dnl Please note that you *have* to pass also an operator along with the
|
||||
dnl version to match, and pay special attention to the single quotes
|
||||
dnl surrounding the version number.
|
||||
dnl
|
||||
dnl If the user wants to employ a particular version of Python, she can
|
||||
dnl now pass to configure the PYTHON_VERSION environment variable. This
|
||||
dnl is only limited by the macro parameter set by the packager.
|
||||
dnl
|
||||
dnl This macro should work for all versions of Python >= 2.1.0. You can
|
||||
dnl disable the check for the python version by setting the
|
||||
dnl PYTHON_NOVERSIONCHECK environment variable to something else than
|
||||
dnl the empty string.
|
||||
dnl
|
||||
dnl If you need to use this macro for an older Python version, please
|
||||
dnl contact the authors. We're always open for feedback.
|
||||
dnl
|
||||
dnl @category InstalledPackages
|
||||
dnl @author Sebastian Huber <sebastian-huber@web.de>
|
||||
dnl @author Alan W. Irwin <irwin@beluga.phys.uvic.ca>
|
||||
dnl @author Rafael Laboissiere <laboissiere@psy.mpg.de>
|
||||
dnl @author Andrew Collier <colliera@nu.ac.za>
|
||||
dnl @author Matteo Settenvini <matteo@member.fsf.org>
|
||||
dnl @version 2006-02-05
|
||||
dnl @license GPLWithACException
|
||||
|
||||
AC_DEFUN([AC_PYTHON_DEVEL],[
|
||||
#
|
||||
# Allow the use of a (user set) custom python version
|
||||
#
|
||||
AC_ARG_VAR([PYTHON_VERSION],[The installed Python
|
||||
version to use, for example '2.3'. This string
|
||||
will be appended to the Python interpreter
|
||||
canonical name.])
|
||||
|
||||
AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]])
|
||||
if test -z "$PYTHON"; then
|
||||
AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system path])
|
||||
fi
|
||||
|
||||
#
|
||||
# Check for a version of Python >= 2.1.0
|
||||
#
|
||||
AC_MSG_CHECKING([for a version of Python >= '2.1.0'])
|
||||
ac_supports_python_ver=`echo "import sys, string; \
|
||||
ver = string.split(sys.version)[[0]]; \
|
||||
print ver >= '2.1.0'" | $PYTHON`
|
||||
if test "$ac_supports_python_ver" != "True"; then
|
||||
if test -z "$PYTHON_NOVERSIONCHECK"; then
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_FAILURE([
|
||||
This version of the AC@&t@_PYTHON_DEVEL macro
|
||||
doesn't work properly with versions of Python before
|
||||
2.1.0. You may need to re-run configure, setting the
|
||||
variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG,
|
||||
PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand.
|
||||
Moreover, to disable this check, set PYTHON_NOVERSIONCHECK
|
||||
to something else than an empty string.
|
||||
])dnl
|
||||
else
|
||||
AC_MSG_RESULT([skip at user request])
|
||||
fi
|
||||
else
|
||||
AC_MSG_RESULT([yes])
|
||||
fi
|
||||
|
||||
#
|
||||
# if the macro parameter ``version'' is set, honour it
|
||||
#
|
||||
if test -n "$1"; then
|
||||
AC_MSG_CHECKING([for a version of Python $1])
|
||||
ac_supports_python_ver=`echo "import sys, string; \
|
||||
ver = string.split(sys.version)[[0]]; \
|
||||
print ver $1" | $PYTHON`
|
||||
if test "$ac_supports_python_ver" = "True"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([this package requires Python $1.
|
||||
If you have it installed, but it isn't the default Python
|
||||
interpreter in your system path, please pass the PYTHON_VERSION
|
||||
variable to configure. See ``configure --help'' for reference.
|
||||
])dnl
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Check if you have distutils, else fail
|
||||
#
|
||||
AC_MSG_CHECKING([for the distutils Python package])
|
||||
ac_distutils_result=`echo "import distutils" | $PYTHON 2>&1`
|
||||
if test -z "$ac_distutils_result"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([cannot import Python module "distutils".
|
||||
Please check your Python installation. The error was:
|
||||
$ac_distutils_result])
|
||||
fi
|
||||
|
||||
#
|
||||
# Check for Python include path
|
||||
#
|
||||
AC_MSG_CHECKING([for Python include path])
|
||||
if test -z "$PYTHON_CPPFLAGS"; then
|
||||
python_path=`echo "import distutils.sysconfig; \
|
||||
print distutils.sysconfig.get_python_inc();" | $PYTHON`
|
||||
if test -n "${python_path}"; then
|
||||
python_path="-I$python_path"
|
||||
fi
|
||||
PYTHON_CPPFLAGS=$python_path
|
||||
fi
|
||||
AC_MSG_RESULT([$PYTHON_CPPFLAGS])
|
||||
AC_SUBST([PYTHON_CPPFLAGS])
|
||||
|
||||
#
|
||||
# Check for Python library path
|
||||
#
|
||||
AC_MSG_CHECKING([for Python library path])
|
||||
if test -z "$PYTHON_LDFLAGS"; then
|
||||
# (makes two attempts to ensure we've got a version number
|
||||
# from the interpreter)
|
||||
py_version=`echo "from distutils.sysconfig import *; \
|
||||
from string import join; \
|
||||
print join(get_config_vars('VERSION'))" | $PYTHON`
|
||||
if test "$py_version" == "[None]"; then
|
||||
if test -n "$PYTHON_VERSION"; then
|
||||
py_version=$PYTHON_VERSION
|
||||
else
|
||||
py_version=`$PYTHON -c "import sys; \
|
||||
print sys.version[[:3]]"`
|
||||
fi
|
||||
fi
|
||||
|
||||
PYTHON_LDFLAGS=`echo "from distutils.sysconfig import *; \
|
||||
from string import join; \
|
||||
print '-L' + get_python_lib(0,1), \
|
||||
'-lpython';" | $PYTHON`$py_version
|
||||
fi
|
||||
AC_MSG_RESULT([$PYTHON_LDFLAGS])
|
||||
AC_SUBST([PYTHON_LDFLAGS])
|
||||
|
||||
#
|
||||
# Check for site packages
|
||||
#
|
||||
AC_MSG_CHECKING([for Python site-packages path])
|
||||
if test -z "$PYTHON_SITE_PKG"; then
|
||||
PYTHON_SITE_PKG=`echo "import distutils.sysconfig; \
|
||||
print distutils.sysconfig.get_python_lib(0,0);" | $PYTHON`
|
||||
fi
|
||||
AC_MSG_RESULT([$PYTHON_SITE_PKG])
|
||||
AC_SUBST([PYTHON_SITE_PKG])
|
||||
|
||||
#
|
||||
# libraries which must be linked in when embedding
|
||||
#
|
||||
AC_MSG_CHECKING(python extra libraries)
|
||||
if test -z "$PYTHON_EXTRA_LIBS"; then
|
||||
PYTHON_EXTRA_LIBS=`echo "import distutils.sysconfig; \
|
||||
conf = distutils.sysconfig.get_config_var; \
|
||||
print conf('LOCALMODLIBS'), conf('LIBS')" | $PYTHON`
|
||||
fi
|
||||
AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
|
||||
AC_SUBST(PYTHON_EXTRA_LIBS)
|
||||
|
||||
#
|
||||
# linking flags needed when embedding
|
||||
#
|
||||
AC_MSG_CHECKING(python extra linking flags)
|
||||
if test -z "$PYTHON_EXTRA_LDFLAGS"; then
|
||||
PYTHON_EXTRA_LDFLAGS=`echo "import distutils.sysconfig; \
|
||||
conf = distutils.sysconfig.get_config_var; \
|
||||
print conf('LINKFORSHARED')" | $PYTHON`
|
||||
fi
|
||||
AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
|
||||
AC_SUBST(PYTHON_EXTRA_LDFLAGS)
|
||||
])
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
SUBDIRS = virtManager vncViewer
|
||||
SUBDIRS = virtManager vncViewer graphWidgets
|
||||
|
||||
bin_SOURCES = gnome-virt-manager.in
|
||||
bin_SCRIPTS = gnome-virt-manager
|
||||
|
@ -34,7 +34,10 @@ EXTRA_DIST = $(bin_SOURCES) $(desktop_SOURCES) $(dbus_SOURCES) $(python_SOURCES)
|
|||
sed -e "s,::PACKAGE::,$(PACKAGE)," -e "s,::PREFIX::,$(prefix)," < $< > $@
|
||||
|
||||
%.py: $(srcdir)/%.py.in
|
||||
sed -e "s,::PACKAGE::,$(PACKAGE)," -e "s,::ASSETDIR::,$(pkgdatadir)," < $< > $@
|
||||
sed -e "s,::PACKAGE::,$(PACKAGE)," \
|
||||
-e "s,::ASSETDIR::,$(pkgdatadir)," \
|
||||
-e "s,::PYLIBDIR::,$(pkgdatadir)," \
|
||||
-e "s,::PYARCHLIBDIR::,$(pkglibdir)," < $< > $@
|
||||
|
||||
gnome-virt-manager: $(srcdir)/gnome-virt-manager.in
|
||||
sed -e "s,::PACKAGE::,$(PACKAGE)," -e "s,::PYTHONDIR::,$(pkgdatadir)," < $< > $@
|
||||
|
|
|
@ -22,6 +22,7 @@ asset_dir = "::ASSETDIR::"
|
|||
glade_dir = asset_dir
|
||||
icon_dir = asset_dir + "/pixmaps"
|
||||
pylib_dir = "::PYLIBDIR::"
|
||||
pyarchlib_dir = "::PYARCHLIBDIR::"
|
||||
|
||||
# Hack for dev purposes
|
||||
if os.path.exists(os.getcwd() + "/src/" + appname + ".glade"):
|
||||
|
@ -31,6 +32,10 @@ if os.path.exists(os.getcwd() + "/pixmaps/icon_run.png"):
|
|||
|
||||
if os.path.exists(os.getcwd() + "/src/" + appname + "/__init__.py"):
|
||||
sys.path.insert(0, os.getcwd() + "/src")
|
||||
sys.path.insert(0, os.getcwd() + "/build/src/.libs")
|
||||
else:
|
||||
sys.path.insert(0, pylib_dir)
|
||||
sys.path.insert(0, pyarchlib_dir)
|
||||
|
||||
# Obnoxious matplotlib sets its own icon as the default
|
||||
# which is a totally inappropriate action for a library
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
|
||||
sparklinedir = $(pkglibdir)
|
||||
sparkline_LTLIBRARIES = sparkline.la
|
||||
|
||||
CODEGENDIR := $(shell pkg-config --variable=codegendir pygtk-2.0)
|
||||
DEFSDIR := $(shell pkg-config --variable=defsdir pygtk-2.0)
|
||||
|
||||
py%.defs: %.h
|
||||
python $(CODEGENDIR)/h2def.py $< > $@
|
||||
|
||||
py%.c: py%.defs py%.override
|
||||
pygtk-codegen-2.0 --prefix sparkline \
|
||||
--register $(DEFSDIR)/gdk-types.defs \
|
||||
--register $(DEFSDIR)/gtk-types.defs \
|
||||
--override $(srcdir)/pycellrenderersparkline.override \
|
||||
pycellrenderersparkline.defs > $@
|
||||
|
||||
sparkline_la_SOURCES = \
|
||||
sparklinemodule.c \
|
||||
pycellrenderersparkline.c \
|
||||
cellrenderersparkline.c \
|
||||
cellrenderersparkline.h
|
||||
|
||||
sparkline_la_CFLAGS = -fPIC -Wall \
|
||||
$(PYGTK2_CFLAGS) \
|
||||
$(GTK2_CFLAGS) \
|
||||
$(PYTHON_CPPFLAGS)
|
||||
|
||||
sparkline_la_LIBADD = \
|
||||
$(PYGTK2_LIBS) \
|
||||
$(GTK2_LIBS) \
|
||||
$(PYTHON_LDFLAGS)
|
||||
|
||||
sparkline_la_LDFLAGS = -module -avoid-version -fPIC
|
|
@ -0,0 +1,324 @@
|
|||
/* eggcellrenderersparkline.c
|
||||
* Copyright (C) 2005 Red Hat, Inc., David Malcolm <dmalcolm@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "cellrenderersparkline.h"
|
||||
|
||||
static void gtk_cell_renderer_sparkline_init(GtkCellRendererSparkline *cellsparkline);
|
||||
static void gtk_cell_renderer_sparkline_class_init(GtkCellRendererSparklineClass *class);
|
||||
static void gtk_cell_renderer_sparkline_finalize(GObject *object);
|
||||
|
||||
static void gtk_cell_renderer_sparkline_get_property(GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_cell_renderer_sparkline_set_property(GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_cell_renderer_sparkline_get_size(GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *cell_area,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gint *width,
|
||||
gint *height);
|
||||
static void gtk_cell_renderer_sparkline_render(GtkCellRenderer *cell,
|
||||
GdkWindow *window,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
GtkCellRendererState flags);
|
||||
|
||||
enum {
|
||||
EDITED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_NUMDATAPOINTS,
|
||||
PROP_DATAARRAY
|
||||
};
|
||||
|
||||
static gpointer parent_class;
|
||||
static guint sparkline_cell_renderer_signals [LAST_SIGNAL];
|
||||
|
||||
#define GTK_CELL_RENDERER_SPARKLINE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_CELL_RENDERER_SPARKLINE, GtkCellRendererSparklinePrivate))
|
||||
|
||||
typedef struct _GtkCellRendererSparklinePrivate GtkCellRendererSparklinePrivate;
|
||||
struct _GtkCellRendererSparklinePrivate
|
||||
{
|
||||
gboolean filled;
|
||||
GValueArray *data_array;
|
||||
};
|
||||
|
||||
|
||||
GType gtk_cell_renderer_sparkline_get_type (void)
|
||||
{
|
||||
static GType cell_sparkline_type = 0;
|
||||
|
||||
if (!cell_sparkline_type) {
|
||||
static const GTypeInfo cell_sparkline_info = {
|
||||
sizeof (GtkCellRendererSparklineClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) gtk_cell_renderer_sparkline_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GtkCellRendererSparkline),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gtk_cell_renderer_sparkline_init,
|
||||
};
|
||||
|
||||
cell_sparkline_type =
|
||||
g_type_register_static (GTK_TYPE_CELL_RENDERER, "GtkCellRendererSparkline",
|
||||
&cell_sparkline_info, 0);
|
||||
}
|
||||
|
||||
return cell_sparkline_type;
|
||||
}
|
||||
|
||||
static void gtk_cell_renderer_sparkline_init (GtkCellRendererSparkline *cellsparkline)
|
||||
{
|
||||
GtkCellRendererSparklinePrivate *priv;
|
||||
|
||||
priv = GTK_CELL_RENDERER_SPARKLINE_GET_PRIVATE (cellsparkline);
|
||||
|
||||
priv->filled = TRUE;
|
||||
priv->filled = FALSE;
|
||||
priv->data_array = g_value_array_new(0);
|
||||
}
|
||||
|
||||
static void gtk_cell_renderer_sparkline_class_init (GtkCellRendererSparklineClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class);
|
||||
|
||||
parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
object_class->finalize = gtk_cell_renderer_sparkline_finalize;
|
||||
|
||||
object_class->get_property = gtk_cell_renderer_sparkline_get_property;
|
||||
object_class->set_property = gtk_cell_renderer_sparkline_set_property;
|
||||
|
||||
cell_class->get_size = gtk_cell_renderer_sparkline_get_size;
|
||||
cell_class->render = gtk_cell_renderer_sparkline_render;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_DATAARRAY,
|
||||
g_param_spec_value_array ("data_array",
|
||||
"Data array",
|
||||
"GValueArray of data",
|
||||
g_param_spec_double("data_array_value",
|
||||
"Data array value",
|
||||
"GValueArray element",
|
||||
0.0,
|
||||
100.0,
|
||||
0,
|
||||
G_PARAM_READABLE | G_PARAM_WRITABLE),
|
||||
G_PARAM_READABLE | G_PARAM_WRITABLE));
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (GtkCellRendererSparklinePrivate));
|
||||
}
|
||||
|
||||
static void gtk_cell_renderer_sparkline_finalize (GObject *object)
|
||||
{
|
||||
GtkCellRendererSparkline *cellsparkline = GTK_CELL_RENDERER_SPARKLINE (object);
|
||||
GtkCellRendererSparklinePrivate *priv;
|
||||
|
||||
priv = GTK_CELL_RENDERER_SPARKLINE_GET_PRIVATE (object);
|
||||
|
||||
|
||||
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
|
||||
}
|
||||
|
||||
static void gtk_cell_renderer_sparkline_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkCellRendererSparkline *cellsparkline = GTK_CELL_RENDERER_SPARKLINE (object);
|
||||
GtkCellRendererSparklinePrivate *priv;
|
||||
|
||||
priv = GTK_CELL_RENDERER_SPARKLINE_GET_PRIVATE (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_DATAARRAY:
|
||||
g_value_set_boxed(value, priv->data_array);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_sparkline_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkCellRendererSparkline *cellsparkline = GTK_CELL_RENDERER_SPARKLINE (object);
|
||||
GtkCellRendererSparklinePrivate *priv;
|
||||
|
||||
priv = GTK_CELL_RENDERER_SPARKLINE_GET_PRIVATE (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_DATAARRAY:
|
||||
g_value_array_free(priv->data_array);
|
||||
priv->data_array = g_value_array_copy(g_value_get_boxed(value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void gtk_cell_renderer_sparkline_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *cell_area,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
GtkCellRendererSparkline *cellsparkline = (GtkCellRendererSparkline *) cell;
|
||||
GtkCellRendererSparklinePrivate *priv;
|
||||
GValueArray *data;
|
||||
|
||||
priv = GTK_CELL_RENDERER_SPARKLINE_GET_PRIVATE (cell);
|
||||
|
||||
data = priv->data_array;
|
||||
|
||||
if (width)
|
||||
*width = data->n_values;
|
||||
|
||||
if (height)
|
||||
*height = 20;
|
||||
|
||||
if (cell_area) {
|
||||
if (x_offset) {
|
||||
*x_offset = 0;
|
||||
}
|
||||
if (y_offset) {
|
||||
*y_offset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static double get_x (double right_margin_x,
|
||||
double data_points_per_pixel,
|
||||
int index,
|
||||
int num_data_points)
|
||||
{
|
||||
return right_margin_x - ((double)(num_data_points-(index+1))/data_points_per_pixel);
|
||||
}
|
||||
|
||||
static double get_y (GdkRectangle *cell_area,
|
||||
GValueArray *data,
|
||||
int index)
|
||||
{
|
||||
double baseline_y = cell_area->y + cell_area->height;
|
||||
GValue *val = g_value_array_get_nth(data, index);
|
||||
return baseline_y - (cell_area->height * g_value_get_double(val));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_sparkline_render (GtkCellRenderer *cell,
|
||||
GdkDrawable *window,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
GtkCellRendererState flags)
|
||||
{
|
||||
cairo_t *cr;
|
||||
int index;
|
||||
double right_margin_x;
|
||||
double margin = 2.0;
|
||||
double dot_radius = 1.0;
|
||||
double data_points_per_pixel = 1.0;
|
||||
double baseline_y = cell_area->y + cell_area->height;
|
||||
|
||||
GtkCellRendererSparklinePrivate *priv;
|
||||
GValueArray *data;
|
||||
|
||||
priv = GTK_CELL_RENDERER_SPARKLINE_GET_PRIVATE (cell);
|
||||
|
||||
data = priv->data_array;
|
||||
|
||||
/*
|
||||
printf ("sparkline_render\n");
|
||||
printf ("background_area=(%d,%d,%d,%d)\n", background_area->x, background_area->y, background_area->width, background_area->height);
|
||||
printf ("cell_area=(%d,%d,%d,%d)\n", cell_area->x, cell_area->y, cell_area->width, cell_area->height);
|
||||
printf ("expose_area=(%d,%d,%d,%d)\n", expose_area->x, expose_area->y, expose_area->width, expose_area->height);
|
||||
*/
|
||||
|
||||
cr = gdk_cairo_create (window);
|
||||
|
||||
/* Clip to the cell: */
|
||||
cairo_save (cr);
|
||||
cairo_rectangle (cr, cell_area->x, cell_area->y, cell_area->width, cell_area->height);
|
||||
cairo_clip (cr);
|
||||
|
||||
right_margin_x = cell_area->x + cell_area->width - margin;
|
||||
|
||||
/* Render the line: */
|
||||
//cairo_set_line_width (cr, (double)cell_area->width*0.5/(double)NUM_VALUES);
|
||||
cairo_set_line_width (cr, (double)0.5);
|
||||
|
||||
for (index=0;index<data->n_values;index++) {
|
||||
double cx = get_x (right_margin_x, data_points_per_pixel, index, data->n_values);
|
||||
double cy = get_y (cell_area, data, index);
|
||||
if (index) {
|
||||
cairo_line_to (cr, cx, cy);
|
||||
} else {
|
||||
cairo_move_to (cr, cx, cy);
|
||||
}
|
||||
}
|
||||
if (priv->filled) {
|
||||
cairo_line_to (cr, right_margin_x, baseline_y);
|
||||
cairo_line_to (cr, get_x (right_margin_x, data_points_per_pixel, 0, data->n_values), baseline_y);
|
||||
cairo_fill (cr);
|
||||
} else {
|
||||
cairo_stroke (cr);
|
||||
}
|
||||
|
||||
/* Stop clipping: */
|
||||
cairo_restore (cr);
|
||||
|
||||
/* Render the dot for the last value: */
|
||||
/*
|
||||
if (data->n_values>0) {
|
||||
cairo_set_source_rgb (cr, 1., 0., 0.);
|
||||
cairo_arc (cr, right_margin_x, get_y (cell_area, data, data->n_values-1), dot_radius, 0., 2 * 3.14159265359);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
*/
|
||||
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
|
||||
#define __GTK_CELL_RENDERER_SPARKLINE_C__
|
|
@ -0,0 +1,64 @@
|
|||
/* eggcellrenderersparkline.h
|
||||
* Copyright (C) 2005 Red Hat, Inc., David Malcolm <dmalcolm@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CELL_RENDERER_SPARKLINE_H__
|
||||
#define __GTK_CELL_RENDERER_SPARKLINE_H__
|
||||
|
||||
#include <pango/pango.h>
|
||||
#include <gtk/gtkcellrenderer.h>
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define GTK_TYPE_CELL_RENDERER_SPARKLINE (gtk_cell_renderer_sparkline_get_type ())
|
||||
#define GTK_CELL_RENDERER_SPARKLINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CELL_RENDERER_SPARKLINE, GtkCellRendererSparkline))
|
||||
#define GTK_CELL_RENDERER_SPARKLINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CELL_RENDERER_SPARKLINE, GtkCellRendererSparklineClass))
|
||||
#define GTK_IS_CELL_RENDERER_SPARKLINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CELL_RENDERER_SPARKLINE))
|
||||
#define GTK_IS_CELL_RENDERER_SPARKLINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CELL_RENDERER_SPARKLINE))
|
||||
#define GTK_CELL_RENDERER_SPARKLINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CELL_RENDERER_SPARKLINE, GtkCellRendererSparklineClass))
|
||||
|
||||
typedef struct _GtkCellRendererSparkline GtkCellRendererSparkline;
|
||||
typedef struct _GtkCellRendererSparklineClass GtkCellRendererSparklineClass;
|
||||
|
||||
struct _GtkCellRendererSparkline
|
||||
{
|
||||
GtkCellRenderer parent;
|
||||
|
||||
/*< private >*/
|
||||
};
|
||||
|
||||
struct _GtkCellRendererSparklineClass
|
||||
{
|
||||
GtkCellRendererClass parent_class;
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
};
|
||||
|
||||
GType gtk_cell_renderer_sparkline_get_type (void) G_GNUC_CONST;
|
||||
GtkCellRenderer *gtk_cell_renderer_sparkline_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
#endif /* __GTK_CELL_RENDERER_SPARKLINE_H__ */
|
|
@ -0,0 +1,13 @@
|
|||
%%
|
||||
headers
|
||||
#include <Python.h>
|
||||
#include "pygobject.h"
|
||||
#include "cellrenderersparkline.h"
|
||||
%%
|
||||
modulename cellrenderersparkline
|
||||
%%
|
||||
import gtk.CellRenderer as PyGtkCellRenderer_Type
|
||||
%%
|
||||
ignore-glob
|
||||
*_get_type
|
||||
%%
|
|
@ -0,0 +1,21 @@
|
|||
#include <pygobject.h>
|
||||
|
||||
void sparkline_register_classes (PyObject *d);
|
||||
extern PyMethodDef sparkline_functions[];
|
||||
|
||||
DL_EXPORT(void)
|
||||
initsparkline(void)
|
||||
{
|
||||
PyObject *m, *d;
|
||||
|
||||
init_pygobject ();
|
||||
|
||||
m = Py_InitModule ("sparkline", sparkline_functions);
|
||||
d = PyModule_GetDict (m);
|
||||
|
||||
sparkline_register_classes(d);
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
Py_FatalError ("can't initialise module sparkline");
|
||||
}
|
||||
}
|
|
@ -196,7 +196,7 @@ class vmmConsole(gobject.GObject):
|
|||
else:
|
||||
self.try_login()
|
||||
except:
|
||||
print "Bad shit"
|
||||
print "Couldn't open console " + str(sys.exc_info())
|
||||
self.ignorePause = False
|
||||
self.ignorePause = False
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ class vmmDomain(gobject.GObject):
|
|||
return self.uuid
|
||||
|
||||
def _normalize_status(self, status):
|
||||
if self.lastStatus == libvirt.VIR_DOMAIN_NOSTATE:
|
||||
if status == libvirt.VIR_DOMAIN_NOSTATE:
|
||||
return libvirt.VIR_DOMAIN_RUNNING
|
||||
elif self.lastStatus == libvirt.VIR_DOMAIN_BLOCKED:
|
||||
elif status == libvirt.VIR_DOMAIN_BLOCKED:
|
||||
return libvirt.VIR_DOMAIN_RUNNING
|
||||
return status
|
||||
|
||||
|
@ -153,7 +153,7 @@ class vmmDomain(gobject.GObject):
|
|||
stats = self.record
|
||||
for i in range(self.config.get_stats_history_length()+1):
|
||||
if i < len(stats):
|
||||
vector.append(stats[i]["cpuTimePercent"])
|
||||
vector.append(stats[i]["cpuTimePercent"]/100.0*10)
|
||||
else:
|
||||
vector.append(0)
|
||||
return vector
|
||||
|
@ -229,7 +229,8 @@ class vmmDomain(gobject.GObject):
|
|||
# XXX don't hardcode me! need to really extract info from
|
||||
# the libvirt XML as & when the display device info gets
|
||||
# added
|
||||
return ["vnc", "localhost", 5901 + self.get_id()]
|
||||
prin
|
||||
return ["vnc", "localhost", 5900 + self.get_id()]
|
||||
|
||||
|
||||
gobject.type_register(vmmDomain)
|
||||
|
|
|
@ -3,6 +3,8 @@ import gobject
|
|||
import gtk
|
||||
import gtk.glade
|
||||
|
||||
import sparkline
|
||||
|
||||
VMLIST_SORT_NAME = 1
|
||||
VMLIST_SORT_CPU_USAGE = 2
|
||||
VMLIST_SORT_MEMORY_USAGE = 3
|
||||
|
@ -234,7 +236,8 @@ class vmmManager(gobject.GObject):
|
|||
|
||||
|
||||
cpuUsage_txt = gtk.CellRendererText()
|
||||
cpuUsage_img = gtk.CellRendererProgress()
|
||||
#cpuUsage_img = gtk.CellRendererProgress()
|
||||
cpuUsage_img = sparkline.CellRendererSparkline()
|
||||
cpuUsageCol.pack_start(cpuUsage_txt, False)
|
||||
cpuUsageCol.pack_start(cpuUsage_img, False)
|
||||
cpuUsageCol.set_cell_data_func(cpuUsage_txt, self.cpu_usage_text, None)
|
||||
|
@ -361,8 +364,11 @@ class vmmManager(gobject.GObject):
|
|||
|
||||
def cpu_usage_img(self, column, cell, model, iter, data):
|
||||
uuid = model.get_value(iter, 0)
|
||||
cell.set_property('text', '')
|
||||
cell.set_property('value', self.connection.get_vm(uuid).cpu_time_percentage())
|
||||
#cell.set_property('text', '')
|
||||
#cell.set_property('value', self.connection.get_vm(uuid).cpu_time_percentage())
|
||||
data = self.connection.get_vm(uuid).cpu_time_vector()
|
||||
data.reverse()
|
||||
cell.set_property('data_array', data)
|
||||
|
||||
def memory_usage_text(self, column, cell, model, iter, data):
|
||||
uuid = model.get_value(iter, 0)
|
||||
|
|
Loading…
Reference in New Issue