Commit 09c4dd3c authored by Arturo Espinosa's avatar Arturo Espinosa

More work

parent 7d6085ea
......@@ -7,8 +7,9 @@
* (C) 1999 International GNOME Support (http://www.gnome-support.com)
*/
#include <Gnumeric-value.idl>
#include <gnome-unknown.idl>
#include <bonobo.idl>
#include "Gnumeric-value.idl"
module GNOME {
......
INCLUDES = \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DGNUMERIC_VERSION=\""$(VERSION)"\" \
-DGNUMERIC_GLADEDIR=\""$(gladedir)"\" \
-DGNUMERIC_ICONDIR=\""$(iconsdir)"\" \
-I$(includedir) \
-I$(top_srcdir) \
$(EXTRA_GNOME_CFLAGS)
bin_PROGRAMS = graph
GRAPH_CORBA_GENERATED = \
Graph-common.c \
Graph-skels.c \
Graph-stubs.c \
Graph.h
graph_SOURCES = \
data-source.c \
data-source.h \
series.c \
series.h
series.h \
$(GRAPH_CORBA_GENERATED)
BUILT_SOURCES = $(GRAPH_CORBA_GENERATED)
$(GRAPH_CORBA_GENERATED): my_graph_idl
my_graph_idl: Graph.idl $(top_srcdir)/src/Gnumeric-value.idl $(top_srcdir)/src/Gnumeric.idl
orbit-idl -I`$(GNOME_CONFIG) --datadir`/idl -I$(srcdir) $(srcdir)/Graph.idl
touch my_graph_idl
CLEANFILES = my_graph_idl
MYHACKAROUNDAUTOMAKE=$(shell echo $(GNUMERIC_CORBA_GENERATED))
#ifndef DATA_SOURCE_H
#define DATA_SOURCE_H
#include <gtk/gtkobject.h>
#include "src/value.h"
typedef struct {
GtkObject parent;
} DataSource;
......@@ -8,12 +11,17 @@ typedef struct {
typedef struct {
GtkObjectClass parent_class;
Value (*get_value)(DataSource *source, const char *spec, int pos);
gboolean (*set_value)(DataSource *source, const char *spec, int pos, Value *value);
Value *(*get_value)(DataSource *source, const char *spec, int pos);
gboolean (*set_value)(DataSource *source, const char *spec, int pos, Value *value);
} DataSourceClass;
typedef enum {
DATA_SET_OK,
DATA_SET_ERROR
} DataResult;
GtkType data_source_get_type (void);
Value *data_source_get_value (DataSource *source, const char *spec, int pos);
DataResult data_source_set_value (DataSource *source, const char *spec, int pos, Value *value);
gboolean data_source_set_value (DataSource *source, const char *spec, int pos, Value *value);
#endif /* DATA_SOURCE_H */
#ifndef GRAPH_GRAPH_VIEW_H_
#define GRAPH_GRAPH_VIEW_H_
#include <libgnome/gnome-defs.h>
#include <libgnomeui/gnome-canvas.h>
#define GRAPH_VIEW_TYPE (graph_view_get_type ())
#define GRAPH_VIEW(o) (GTK_CHECK_CAST ((o), GRAPH_VIEW_TYPE, GraphView))
#define GRAPH_VIEW_CLASS(k) (GTK_CHECK_CLASS_CAST((k), GRAPH_VIEW_TYPE, GraphViewClass))
#define IS_GRAPH_VIEW(o) (GTK_CHECK_TYPE ((o), GRAPH_VIEW_TYPE))
#define IS_GRAPH_VIEW_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), GRAPH_VIEW_TYPE))
typedef struct {
GnomeCanvasItem base;
} GraphView;
typedef struct {
GnomeCanvasItemClass parent_class;
} GraphViewClass;
GtkType graph_view_get_type (void);
void graph_view_update (GraphView *graph_view);
#endif /* GRAPH_GRAPH_VIEW_H_ */
......@@ -8,4 +8,316 @@
*/
#include <config.h>
#include "graph.h"
#include "graph-view.h"
static GnomeObjectClass *graph_parent_class;
/* The entry point vectors for the server we provide */
POA_GNOME_Graph_Chart__epv graph_epv;
POA_GNOME_Graph_Chart__vepv graph_vepv;
#define graph_from_servant(x) GRAPH (gnome_object_from_servant (x))
static void
graph_destroy (GtkObject *object)
{
GTK_OBJECT_CLASS (graph_parent_class)->destroy (object);
}
static void
graph_update (Graph *graph)
{
GSList *l;
if (graph->frozen){
graph->need_update = TRUE;
return;
}
for (l = graph->views; l; l = l->next){
GraphView *graph_view = GRAPH_VIEW (l->data);
graph_view_update (graph_view);
}
graph->need_update = FALSE;
}
GNOME_Graph_ChartType
impl_graph_get_chart_type (PortableServer_Servant servant, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
return graph->chart_type;
}
void
impl_graph_set_chart_type (PortableServer_Servant servant, GNOME_Graph_ChartType value, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
if (graph->chart_type != value){
graph->chart_type = value;
graph_update (graph);
}
}
GNOME_Graph_PlotMode
impl_graph_get_plot_mode (PortableServer_Servant servant, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
return graph->plot_mode;
}
void
impl_graph_set_plot_mode (PortableServer_Servant servant, GNOME_Graph_PlotMode value, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
if (graph->plot_mode != value){
graph->plot_mode = value;
graph_update (graph);
}
}
GNOME_Graph_ColBarMode
impl_graph_get_col_bar_mode (PortableServer_Servant servant, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
return graph->col_bar_mode;
}
void
impl_graph_set_col_bar_mode (PortableServer_Servant servant, GNOME_Graph_ColBarMode value, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
if (graph->col_bar_mode != value){
graph->col_bar_mode = value;
graph_update (graph);
}
}
GNOME_Graph_DirMode
impl_graph_get_direction (PortableServer_Servant servant, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
return graph->direction;
}
void
impl_graph_set_direction (PortableServer_Servant servant, GNOME_Graph_DirMode value, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
if (graph->direction != value){
graph->direction = value;
graph_update (graph);
}
}
GNOME_Graph_LineMode
impl_graph_get_line_mode (PortableServer_Servant servant, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
return graph->line_mode;
}
void
impl_graph_set_line_mode (PortableServer_Servant servant, GNOME_Graph_LineMode value, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
if (graph->line_mode != value){
graph->line_mode = value;
graph_update (graph);
}
}
GNOME_Graph_PieMode
impl_graph_get_pie_mode (PortableServer_Servant servant, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
return graph->pie_mode;
}
void
impl_graph_set_pie_mode (PortableServer_Servant servant, GNOME_Graph_PieMode value, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
if (graph->pie_mode != value){
graph->pie_mode = value;
graph_update (graph);
}
}
GNOME_Graph_PieDimension
impl_graph_get_pie_dim (PortableServer_Servant servant, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
return graph->pie_dim;
}
void
impl_graph_set_pie_dim (PortableServer_Servant servant, GNOME_Graph_PieDimension value, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
if (graph->pie_dim != value){
graph->pie_dim = value;
graph_update (graph);
}
}
GNOME_Graph_ScatterPoints
impl_graph_get_scatter_mode (PortableServer_Servant servant, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
return graph->scatter_mode;
}
void
impl_graph_set_scatter_mode (PortableServer_Servant servant, GNOME_Graph_ScatterPoints value, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
if (graph->scatter_mode != value){
graph->scatter_mode = value;
graph_update (graph);
}
}
GNOME_Graph_ScatterConn
impl_graph_get_scatter_conn (PortableServer_Servant servant, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
return graph->scatter_conn;
}
void
impl_graph_set_scatter_conn (PortableServer_Servant servant, GNOME_Graph_ScatterConn value, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
if (graph->scatter_conn != value){
graph->scatter_conn = value;
graph_update (graph);
}
}
GNOME_Graph_SurfaceMode
impl_graph_get_surface_mode (PortableServer_Servant servant, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
return graph->surface_mode;
}
void
impl_graph_set_surface_mode (PortableServer_Servant servant, GNOME_Graph_SurfaceMode value, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
if (graph->surface_mode != value){
graph->surface_mode = value;
graph_update (graph);
}
}
void
impl_graph_freeze (PortableServer_Servant servant, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
graph->frozen++;
}
void
impl_graph_thaw (PortableServer_Servant servant, CORBA_Environment * ev)
{
Graph *graph = graph_from_servant (servant);
graph->frozen--;
if (graph->frozen == 0 && graph->need_update)
graph_update (graph);
}
static void
init_graph_corba_class (void)
{
graph_epv._get_chart_type = &impl_graph_get_chart_type;
graph_epv._set_chart_type = &impl_graph_set_chart_type;
graph_epv._get_plot_mode = &impl_graph_get_plot_mode;
graph_epv._set_plot_mode = &impl_graph_set_plot_mode;
graph_epv._get_col_bar_mode = &impl_graph_get_col_bar_mode;
graph_epv._set_col_bar_mode = &impl_graph_set_col_bar_mode;
graph_epv._get_direction = &impl_graph_get_direction;
graph_epv._set_direction = &impl_graph_set_direction;
graph_epv._get_line_mode = &impl_graph_get_line_mode;
graph_epv._set_line_mode = &impl_graph_set_line_mode;
graph_epv._get_pie_mode = &impl_graph_get_pie_mode;
graph_epv._set_pie_mode = &impl_graph_set_pie_mode;
graph_epv._get_pie_dim = &impl_graph_get_pie_dim;
graph_epv._set_pie_dim = &impl_graph_set_pie_dim;
graph_epv._get_scatter_mode = &impl_graph_get_scatter_mode;
graph_epv._set_scatter_mode = &impl_graph_set_scatter_mode;
graph_epv._get_scatter_conn = &impl_graph_get_scatter_conn;
graph_epv._set_scatter_conn = &impl_graph_set_scatter_conn;
graph_epv._get_surface_mode = &impl_graph_get_surface_mode;
graph_epv._set_surface_mode = &impl_graph_set_surface_mode;
graph_epv.freeze = &impl_graph_freeze;
graph_epv.thaw = &impl_graph_thaw;
/*
* The Vepv
*/
graph_vepv.GNOME_Unknown_epv = &gnome_object_epv;
graph_vepv.GNOME_Graph_Chart_epv = &graph_epv;
}
static void
graph_class_init (GtkObjectClass *object_class)
{
graph_parent_class = gtk_type_class (gnome_object_get_type ());
object_class->destroy = graph_destroy;
init_graph_corba_class ();
}
static void
graph_init (GtkObject *object)
{
}
GtkType
graph_get_type (void)
{
static GtkType type = 0;
if (!type){
GtkTypeInfo info = {
"GraphGnumeric",
sizeof (Graph),
sizeof (GraphClass),
(GtkClassInitFunc) graph_class_init,
(GtkObjectInitFunc) graph_init,
NULL, /* reserved 1 */
NULL, /* reserved 2 */
(GtkClassInitFunc) NULL
};
type = gtk_type_unique (gnome_object_get_type (), &info);
}
return type;
}
......@@ -4,6 +4,7 @@
#include <libgnome/gnome-defs.h>
#include <bonobo/gnome-object.h>
#include "Graph.h"
BEGIN_GNOME_DECLS
......@@ -13,7 +14,7 @@ BEGIN_GNOME_DECLS
#define IS_GRAPH(o) (GTK_CHECK_TYPE ((o), GRAPH_TYPE))
#define IS_GRAPH_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), GRAPH_TYPE))
struct Graph {
typedef struct {
GnomeObject base;
GNOME_Graph_ChartType chart_type;
......@@ -27,11 +28,16 @@ struct Graph {
GNOME_Graph_ScatterPoints scatter_mode;
GNOME_Graph_ScatterConn scatter_conn;
GNOME_Graph_SurfaceMode surface_mode;
};
struct GraphClass {
GSList *views;
int frozen;
gboolean need_update;
} Graph;
typedef struct {
GnomeObjectClass parent_class;
};
} GraphClass;
GtkType graph_get_type (void);
......
#ifndef GRAPH_REFERENCE_H
#define GRAPH_REFERENCE_H
#include "data-source.h"
typedef struct _Reference Reference;
Reference *reference_new (DataSource *data_source, const char *spec);
Reference *reference_duplicate (Reference *reference);
void reference_destroy (Reference *reference);
Value *referece_value (Reference *reference);
Value *reference_value (Reference *reference);
#endif /* GRAPH_REFERENCE_H */
......@@ -6,6 +6,8 @@
*/
#include <config.h>
#include "series.h"
#include "reference.h"
#include "data-source.h"
struct _SeriesName {
Reference *ref;
......@@ -91,17 +93,17 @@ series_new (DataSource *source, const char *value_spec)
Series *series;
g_return_val_if_fail (source != NULL, NULL);
g_return_val_if_fail (name_spec != NULL, NULL);
g_return_val_if_fail (value_spec != NULL, NULL);
series = g_new (Series, 1);
series->source = source;
gtk_object_ref (GTK_OBJECT (series->source));
series->name_spec = NULL
series->series_name = NULL;
series->value_spec = g_strdup (value_spec);
return series
return series;
}
void
......@@ -110,18 +112,18 @@ series_set_name (Series *series, SeriesName *series_name)
g_return_if_fail (series != NULL);
g_return_if_fail (series_name != NULL);
if (series->name_spec)
series_name_destroy (series->name_spec);
if (series->series_name)
series_name_destroy (series->series_name);
series->name_spec = series_name;
series->series_name = series_name;
}
void
series_set_source (Series *series, DataSource *source, const char *value_spec)
{
g_return_val_if_fail (source != NULL, NULL);
g_return_val_if_fail (value_spec != NULL, NULL);
g_return_val_if_fail (series != NULL, NULL);
g_return_if_fail (source != NULL);
g_return_if_fail (value_spec != NULL);
g_return_if_fail (series != NULL);
gtk_object_unref (GTK_OBJECT (series->source));
series->source = source;
......@@ -134,8 +136,8 @@ series_set_source (Series *series, DataSource *source, const char *value_spec)
void
series_destroy (Series *series)
{
if (series->name_spec)
series_name_destroy (series->name_spec);
if (series->series_name)
series_name_destroy (series->series_name);
gtk_object_unref (GTK_OBJECT (series->source));
g_free (series->value_spec);
g_free (series);
......@@ -146,7 +148,7 @@ series_get_series_name (Series *series)
{
g_return_val_if_fail (series != NULL, NULL);
return series->name_spec;
return series->series_name;
}
char *
......@@ -154,21 +156,22 @@ series_get_name (Series *series)
{
g_return_val_if_fail (series != NULL, NULL);
return series_name_get_string (series->name_spec);
return series_name_get_string (series->series_name);
}
Value *
series_get_value (Series *series, int n)
{
g_return_val_if_fail (series != NULL);
g_return_val_if_fail (series != NULL, NULL);
return data_source_fetch_value (series->data_source, series->value_spec, n);
return data_source_get_value (series->source, series->value_spec, n);
}
void
data_set_set_value (Series *series, int n, Value *value)
gboolean
series_set_value (Series *series, int n, Value *value)
{
g_return_val_if_fail (series != NULL);p
g_return_val_if_fail (series != NULL, FALSE);
return data_source_set_value (series->data_source, series->value_spec, n, value);
return data_source_set_value (series->source, series->value_spec, n, value);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment