Remove graphwidgets written in 'C'. We are now 100% python!

This commit is contained in:
Cole Robinson 2009-07-22 11:16:06 -04:00
parent 631b7b9bed
commit 22443dde10
13 changed files with 8 additions and 978 deletions

View File

@ -34,8 +34,6 @@ po/insert-header\.sin
po/quot\.sed
po/remove-potcdate\.sin
^po/.*\.gmo
src/graphWidgets/pysparklinemodule.c
src/graphWidgets/pysparklinemodule.defs
^.*\.o
^.*\.lo
^.*\.Plo

View File

@ -10,5 +10,8 @@ DISTCLEAN_FILES = @PACKAGE@.spec intltool-extract intltool-merge intltool-update
rpm: clean
$(MAKE) dist && rpmbuild -ta $(distdir).tar.gz
srpm: clean
$(MAKE) dist && rpmbuild -ts $(distdir).tar.gz
check-pylint:
tests/pylint-virt-manager.sh

View File

@ -9,14 +9,6 @@ IT_PROG_INTLTOOL([0.35.0], [no-xml])
AM_GNU_GETTEXT_VERSION([0.14.1])
AM_GNU_GETTEXT([external])
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)
dnl ====================================
dnl = Begin tests for scrollkeeper
dnl ====================================
@ -33,7 +25,6 @@ AC_OUTPUT(Makefile
po/Makefile.in
src/Makefile
src/virtManager/Makefile
src/graphWidgets/Makefile
man/Makefile
tests/Makefile
virt-manager.spec

View File

@ -1,5 +1,5 @@
SUBDIRS = graphWidgets virtManager
SUBDIRS = virtManager
bin_SCRIPTS_IN = virt-manager.in
bin_SCRIPTS = virt-manager

View File

@ -1,40 +0,0 @@
sparklinedir = $(pkglibdir)
sparkline_LTLIBRARIES = sparkline.la
CODEGENDIR := $(shell pkg-config --variable=codegendir pygtk-2.0)
DEFSDIR := $(shell pkg-config --variable=defsdir pygtk-2.0)
pysparklinemodule.defs: sparkline.h cellrenderersparkline.h
python $(CODEGENDIR)/h2def.py $^ > $@
pysparklinemodule.c: pysparklinemodule.defs pysparklinemodule.override
pygtk-codegen-2.0 \
--prefix sparkline \
--register $(DEFSDIR)/gdk-types.defs \
--register $(DEFSDIR)/gtk-types.defs \
--override $(srcdir)/pysparklinemodule.override \
pysparklinemodule.defs > $@
sparkline_la_SOURCES = \
sparklinemodule.c \
pysparklinemodule.c \
cellrenderersparkline.c \
cellrenderersparkline.h \
sparkline.c \
sparkline.h
sparkline_la_CFLAGS = -fPIC -Wall \
-DUSE_CAIRO=1 \
$(PYGTK2_CFLAGS) \
$(GTK2_CFLAGS) \
$(PYTHON_CPPFLAGS)
sparkline_la_LIBADD = \
$(PYGTK2_LIBS) \
$(GTK2_LIBS) \
$(PYTHON_LDFLAGS)
sparkline_la_LDFLAGS = -module -avoid-version -fPIC
EXTRA_DIST = pysparklinemodule.override

View File

@ -1,350 +0,0 @@
/* eggcellrenderersparkline.c
* Copyright (C) 2005-2006 Red Hat, Inc., David Malcolm <dmalcolm@redhat.com>
* Copyright (C) 2006 Daniel P. Berrange <berrange@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_DATAARRAY,
PROP_REVERSED,
};
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;
gboolean reversed;
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_object_class_install_property (object_class,
PROP_REVERSED,
g_param_spec_boolean ("reversed",
"Reversed",
"process data from back to front",
FALSE,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_type_class_add_private (object_class, sizeof (GtkCellRendererSparklinePrivate));
}
static void gtk_cell_renderer_sparkline_finalize (GObject *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)
{
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;
case PROP_REVERSED:
g_value_set_boolean(value, priv->reversed);
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)
{
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;
case PROP_REVERSED:
priv->reversed = g_value_get_boolean(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)
{
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_y (GtkCellRendererSparklinePrivate *priv,
GdkRectangle *cell_area,
GValueArray *data,
int index)
{
int n;
double baseline_y = cell_area->y + cell_area->height;
GValue *val;
if (priv->reversed)
n = data->n_values - 1 - index;
else
n = index;
val = g_value_array_get_nth(data, n);
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)
{
GtkCellRendererSparklinePrivate *priv;
GValueArray *data;
GdkPoint *points;
int index;
double pixels_per_point;
#if USE_CAIRO
cairo_t *cr;
#endif
priv = GTK_CELL_RENDERER_SPARKLINE_GET_PRIVATE(cell);
data = priv->data_array;
pixels_per_point = (double)cell_area->width / ((double)data->n_values-1);
points = g_new(GdkPoint, data->n_values);
for (index=0;index<data->n_values;index++) {
double cx = ((double)index * pixels_per_point);
double cy = get_y (priv, cell_area, data, index);
points[index].x = cx + cell_area->x;
points[index].y = cy;
}
#if USE_CAIRO
cr = gdk_cairo_create (GDK_DRAWABLE(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);
/* Render the line: */
cairo_set_line_width (cr, (double)0.5);
#if 0
cairo_move_to(cr, cell_area->x, cell_area->y);
cairo_line_to(cr, cell_area->x, cell_area->y + cell_area->height);
cairo_line_to(cr, cell_area->x + cell_area->width, cell_area->y + cell_area->height);
cairo_line_to(cr, cell_area->x + cell_area->width, cell_area->y);
cairo_line_to(cr, cell_area->x, cell_area->y);
cairo_stroke(cr);
#endif
for (index=0;index<data->n_values;index++) {
double cx = points[index].x;
double cy = points[index].y;
if (index) {
cairo_line_to (cr, cx, cy);
} else {
cairo_move_to (cr, cx, cy);
}
}
if (data->n_values) {
if (priv->filled) {
double baseline_y = cell_area->height + cell_area->y;
cairo_line_to (cr, points[data->n_values-1].x, baseline_y);
cairo_line_to (cr, 0, baseline_y);
cairo_fill (cr);
} else {
cairo_stroke (cr);
}
}
/* Stop clipping: */
cairo_restore (cr);
cairo_destroy (cr);
#else
gdk_draw_lines(GDK_DRAWABLE(window),
widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
points, data->n_values);
#endif
g_free(points);
}
#define __GTK_CELL_RENDERER_SPARKLINE_C__

View File

@ -1,64 +0,0 @@
/* 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__ */

View File

@ -1,15 +0,0 @@
%%
headers
#include <Python.h>
#include "pygobject.h"
#include "sparkline.h"
#include "cellrenderersparkline.h"
%%
modulename sparkline
%%
import gtk.CellRenderer as PyGtkCellRenderer_Type
import gtk.DrawingArea as PyGtkDrawingArea_Type
%%
ignore-glob
*_get_type
%%

View File

@ -1,376 +0,0 @@
/* eggcellrenderersparkline.c
* Copyright (C) 2005-2006 Red Hat, Inc., David Malcolm <dmalcolm@redhat.com>
* Copyright (C) 2006 Daniel P. Berrange <berrange@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 "sparkline.h"
static void gtk_sparkline_init(GtkSparkline *cellsparkline);
static void gtk_sparkline_class_init(GtkSparklineClass *class);
static void gtk_sparkline_finalize(GObject *object);
static void gtk_sparkline_get_property(GObject *object,
guint param_id,
GValue *value,
GParamSpec *pspec);
static void gtk_sparkline_set_property(GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_sparkline_size_request(GtkWidget *widget,
GtkRequisition *area);
static gboolean gtk_sparkline_expose(GtkWidget *widget,
GdkEventExpose *event,
gpointer data);
enum {
PROP_0,
PROP_DATAARRAY,
PROP_FILLED,
PROP_REVERSED,
PROP_NUMSETS,
PROP_RGB_ARRAY,
};
static gpointer parent_class;
#define GTK_SPARKLINE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_SPARKLINE, GtkSparklinePrivate))
typedef struct _GtkSparklinePrivate GtkSparklinePrivate;
struct _GtkSparklinePrivate
{
gboolean filled;
gboolean reversed;
gint num_sets;
gint points_per_set;
GValueArray *data_array;
GValueArray *rgb_array;
};
GType gtk_sparkline_get_type (void)
{
static GType sparkline_type = 0;
if (!sparkline_type) {
static const GTypeInfo sparkline_info = {
sizeof (GtkSparklineClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gtk_sparkline_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkSparkline),
0, /* n_preallocs */
(GInstanceInitFunc) gtk_sparkline_init,
};
sparkline_type =
g_type_register_static (GTK_TYPE_DRAWING_AREA, "GtkSparkline",
&sparkline_info, 0);
}
return sparkline_type;
}
static void gtk_sparkline_init (GtkSparkline *sparkline)
{
GtkSparklinePrivate *priv;
priv = GTK_SPARKLINE_GET_PRIVATE (sparkline);
priv->filled = TRUE;
priv->reversed = FALSE;
priv->data_array = g_value_array_new(0);
priv->rgb_array = g_value_array_new(0);
priv->num_sets = 1;
priv->points_per_set = 0;
g_signal_connect (G_OBJECT (sparkline), "expose_event",
G_CALLBACK (gtk_sparkline_expose), NULL);
//GTK_WIDGET_SET_FLAGS(GTK_WIDGET(sparkline), GTK_NO_WINDOW);
}
static void gtk_sparkline_class_init (GtkSparklineClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
GParamSpec *data_array_spec;
parent_class = g_type_class_peek_parent (class);
object_class->finalize = gtk_sparkline_finalize;
object_class->get_property = gtk_sparkline_get_property;
object_class->set_property = gtk_sparkline_set_property;
widget_class->size_request = gtk_sparkline_size_request;
//widget_class->expose_event = gtk_sparkline_expose;
data_array_spec = g_param_spec_double("data_array_value",
"Data array value",
"GValueArray element",
0.0,
100.0,
0,
G_PARAM_READABLE | G_PARAM_WRITABLE);
g_object_class_install_property (object_class,
PROP_DATAARRAY,
g_param_spec_value_array ("data_array",
"Data array",
"GValueArray of data",
data_array_spec,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_NUMSETS,
g_param_spec_int ("num_sets",
"Num Sets",
"Number of data sets in data",
1, 2, 1,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_FILLED,
g_param_spec_boolean ("filled",
"Filled",
"fill space under sparcline",
TRUE,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_REVERSED,
g_param_spec_boolean ("reversed",
"Reversed",
"process data from back to front",
FALSE,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (object_class,
PROP_RGB_ARRAY,
g_param_spec_value_array ("rgb",
"RGB Array",
"GValueArray of rgb values",
data_array_spec,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_type_class_add_private (object_class, sizeof (GtkSparklinePrivate));
}
static void gtk_sparkline_finalize (GObject *object)
{
GtkSparklinePrivate *priv;
priv = GTK_SPARKLINE_GET_PRIVATE (object);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
static void gtk_sparkline_get_property (GObject *object,
guint param_id,
GValue *value,
GParamSpec *pspec)
{
GtkSparklinePrivate *priv;
priv = GTK_SPARKLINE_GET_PRIVATE (object);
switch (param_id)
{
case PROP_DATAARRAY:
g_value_set_boxed(value, priv->data_array);
break;
case PROP_NUMSETS:
g_value_set_int(value, priv->num_sets);
break;
case PROP_FILLED:
g_value_set_boolean(value, priv->filled);
break;
case PROP_REVERSED:
g_value_set_boolean(value, priv->reversed);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
}
static void
gtk_sparkline_set_property (GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec)
{
GtkSparklinePrivate *priv;
priv = GTK_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));
priv->points_per_set = priv->data_array->n_values / priv->num_sets;
gtk_widget_queue_draw(GTK_WIDGET(object));
break;
case PROP_RGB_ARRAY:
g_value_array_free(priv->rgb_array);
priv->rgb_array = g_value_array_copy(g_value_get_boxed(value));
break;
case PROP_FILLED:
priv->filled = g_value_get_boolean(value);
break;
case PROP_REVERSED:
priv->reversed = g_value_get_boolean(value);
break;
case PROP_NUMSETS:
priv->num_sets = g_value_get_int(value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
}
static void gtk_sparkline_size_request(GtkWidget *widget,
GtkRequisition *area)
{
GtkSparklinePrivate *priv;
GValueArray *data;
priv = GTK_SPARKLINE_GET_PRIVATE (widget);
data = priv->data_array;
if (area) {
area->width = data->n_values / priv->num_sets;
area->height = 20;
}
}
static double get_y (GtkSparklinePrivate *priv, GtkAllocation *cell_area,
GValueArray *data, int set, int index)
{
double baseline_y = cell_area->height;
int n;
n = set * priv->points_per_set;
if (priv->reversed)
n += priv->points_per_set - 1 - index;
else
n += index;
GValue *val = g_value_array_get_nth(data, n);
return baseline_y - ((cell_area->height-1) * g_value_get_double(val));
}
static gboolean
gtk_sparkline_expose (GtkWidget *widget,
GdkEventExpose *event,
gpointer extra)
{
GtkSparklinePrivate *priv;
GValueArray *data;
int index, set;
double pixels_per_point;
GtkAllocation *cell_area = &widget->allocation;
cairo_t *cr;
priv = GTK_SPARKLINE_GET_PRIVATE (widget);
data = priv->data_array;
pixels_per_point = (double)cell_area->width / ((double)priv->points_per_set-1);
gdk_draw_rectangle(widget->window,
widget->style->mid_gc[GTK_WIDGET_STATE (widget)],
TRUE,
0,
0,
cell_area->width-1,
cell_area->height-1);
gdk_draw_rectangle(widget->window,
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
FALSE,
0,
0,
cell_area->width-1,
cell_area->height-1);
#define NTICKS 4
for (index = 1 ; index < NTICKS ; index++) {
gdk_draw_line(widget->window,
widget->style->dark_gc[GTK_WIDGET_STATE(widget)],
1,
cell_area->height/NTICKS*index,
cell_area->width-2,
cell_area->height/NTICKS*index);
}
cr = gdk_cairo_create (widget->window);
/* Clip to the cell: */
cairo_save (cr);
cairo_rectangle (cr, 0, 0, cell_area->width, cell_area->height);
cairo_clip (cr);
/* Render the lines: */
cairo_set_line_width (cr, (double)0.5);
for (set=0; set < priv->num_sets; set++) {
if (priv->rgb_array->n_values == priv->num_sets * 3) {
cairo_set_source_rgb (cr,
g_value_get_double(g_value_array_get_nth(priv->rgb_array, set*3)),
g_value_get_double(g_value_array_get_nth(priv->rgb_array, set*3+1)),
g_value_get_double(g_value_array_get_nth(priv->rgb_array, set*3+2)));
}
for (index=0; index < priv->points_per_set; index++) {
double cx = ((double)index * pixels_per_point);
double cy = get_y (priv, cell_area, data, set, index);
if (index) {
cairo_line_to (cr, cx, cy);
} else {
cairo_move_to (cr, cx, cy);
}
}
if (priv->points_per_set) {
if (priv->filled) {
double baseline_y = cell_area->height + cell_area->y;
cairo_line_to (cr, cell_area->x + cell_area->width, baseline_y);
cairo_line_to (cr, 0, baseline_y);
cairo_fill (cr);
} else {
cairo_stroke (cr);
}
}
}
/* Stop clipping: */
cairo_restore (cr);
cairo_destroy (cr);
return TRUE;
}
#define __GTK_SPARKLINE_C__

View File

@ -1,65 +0,0 @@
/* sparkline.h
* Copyright (C) 2005 Red Hat, Inc., David Malcolm <dmalcolm@redhat.com>
* Copyright (C) 2006 Red Hat, Inc., Daniel Berrange <berrange@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_SPARKLINE_H__
#define __GTK_SPARKLINE_H__
#include <pango/pango.h>
#include <gtk/gtkdrawingarea.h>
G_BEGIN_DECLS
#define GTK_TYPE_SPARKLINE (gtk_sparkline_get_type ())
#define GTK_SPARKLINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SPARKLINE, GtkSparkline))
#define GTK_SPARKLINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_SPARKLINE, GtkSparklineClass))
#define GTK_IS_SPARKLINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SPARKLINE))
#define GTK_IS_SPARKLINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_SPARKLINE))
#define GTK_SPARKLINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SPARKLINE, GtkSparklineClass))
typedef struct _GtkSparkline GtkSparkline;
typedef struct _GtkSparklineClass GtkSparklineClass;
struct _GtkSparkline
{
GtkDrawingArea parent;
/*< private >*/
};
struct _GtkSparklineClass
{
GtkDrawingAreaClass parent_class;
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
GType gtk_sparkline_get_type (void) G_GNUC_CONST;
GtkWidget *gtk_sparkline_new (void);
G_END_DECLS
#endif /* __GTK_SPARKLINE_H__ */

View File

@ -1,40 +0,0 @@
/*
* Copyright (C) 2006 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange <berrange@redhat.com>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#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");
}
}

View File

@ -75,13 +75,12 @@ def setup_pypath():
if os.path.exists(os.getcwd() + "../gnome/help/virt-manager/C/virt-manager.xml"):
data_dir = os.getcwd() + "../"
# First two are hacks to point python to local dir for source files
# in dev, the third is the main path if you have normal install
# First 2 hacks are to point python to local dir for source files in dev,
# the third is the main path if you have normal install
if os.path.exists(os.getcwd() + "/src/virt-manager.py"):
sys.path.insert(0, os.getcwd() + "/src/graphWidgets/.libs")
pass
elif os.path.exists(os.getcwd() + "/build/src/virt-manager.py"):
sys.path.insert(0, os.getcwd() + "/src")
sys.path.insert(0, os.getcwd() + "/build/src/graphWidgets/.libs")
else:
sys.path.insert(0, pylib_dir)
sys.path.insert(0, pyarchlib_dir)

View File

@ -16,6 +16,7 @@ License: GPLv2+
URL: http://virt-manager.org/
Source0: http://virt-manager.org/download/sources/%{name}/%{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
# These two are just the oldest version tested
Requires: pygtk2 >= 1.99.12-6
@ -60,14 +61,6 @@ Requires: PolicyKit-authentication-agent
Requires: PolicyKit-gnome
%endif
BuildRequires: pygtk2-devel
BuildRequires: gtk2-devel
BuildRequires: pygobject2-devel
BuildRequires: glib2-devel
BuildRequires: python-devel
BuildRequires: pango-devel
BuildRequires: atk-devel
BuildRequires: cairo-devel
BuildRequires: gettext
BuildRequires: scrollkeeper
BuildRequires: intltool
@ -96,8 +89,6 @@ 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
%find_lang %{name}
%clean
@ -137,8 +128,6 @@ fi
%{_sysconfdir}/gconf/schemas/%{name}.schemas
%{_bindir}/%{name}
%{_libexecdir}/%{name}-launch
%dir %{_libdir}/%{name}/
%{_libdir}/%{name}/*
%{_mandir}/man1/%{name}.1*