Commit 482a60ad authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa

No longer destroys the Bonobo objects here.

1999-04-14  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* src/sheet.c (sheet_destroy): No longer destroys the Bonobo
	objects here.

	* src/sheet.h (Sheet): No longer keeps track of the ClientSites
	here.

	* src/sheet-object.c (sheet_finish_object_creation): Invoke new
	class method to signal finalization of object creation.

	* src/sheet-object-container.c, src/sheet-object-container.h: New
	files that implement the Bonobo ClientSites
	(SheetObjectContainers).

	* src/Makefile.am (gnumeric_bonobo_SOURCES): Sources for Bonobo
	compilation.

	* src/sheet-object.c (sheet_object_construct): Create the bounding
	box points here.
	(sheet_set_mode_type): Fix from my previous reorganization:  Only
	stop editing mode if the mode is SHEET_MODE_SHEET.
	(sheet_button_press): Strategy change: now we accept
	sheet->current_object and we stop editing here the object.

	* src/sheet-object.h: points has been renamed to bbox_points.

	* src/sheet-object-graphic.c (sheet_object_filled_realize):
	Simplified this routine.  Also, we now update the bounding box
	here.
parent a2aa062a
1999-04-14 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet.c (sheet_destroy): No longer destroys the Bonobo
objects here.
* src/sheet.h (Sheet): No longer keeps track of the ClientSites
here.
* src/sheet-object.c (sheet_finish_object_creation): Invoke new
class method to signal finalization of object creation.
* src/sheet-object-container.c, src/sheet-object-container.h: New
files that implement the Bonobo ClientSites
(SheetObjectContainers).
* src/Makefile.am (gnumeric_bonobo_SOURCES): Sources for Bonobo
compilation.
* src/sheet-object.c (sheet_object_construct): Create the bounding
box points here.
(sheet_set_mode_type): Fix from my previous reorganization: Only
stop editing mode if the mode is SHEET_MODE_SHEET.
(sheet_button_press): Strategy change: now we accept
sheet->current_object and we stop editing here the object.
* src/sheet-object.h: points has been renamed to bbox_points.
* src/sheet-object-graphic.c (sheet_object_filled_realize):
Simplified this routine. Also, we now update the bounding box
here.
1999-04-15 Michael Meeks <michael@mejm2.dow.cam.ac.uk>
* src/fn-lookup.c: Silly bug in types fixed.
......
1999-04-14 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet.c (sheet_destroy): No longer destroys the Bonobo
objects here.
* src/sheet.h (Sheet): No longer keeps track of the ClientSites
here.
* src/sheet-object.c (sheet_finish_object_creation): Invoke new
class method to signal finalization of object creation.
* src/sheet-object-container.c, src/sheet-object-container.h: New
files that implement the Bonobo ClientSites
(SheetObjectContainers).
* src/Makefile.am (gnumeric_bonobo_SOURCES): Sources for Bonobo
compilation.
* src/sheet-object.c (sheet_object_construct): Create the bounding
box points here.
(sheet_set_mode_type): Fix from my previous reorganization: Only
stop editing mode if the mode is SHEET_MODE_SHEET.
(sheet_button_press): Strategy change: now we accept
sheet->current_object and we stop editing here the object.
* src/sheet-object.h: points has been renamed to bbox_points.
* src/sheet-object-graphic.c (sheet_object_filled_realize):
Simplified this routine. Also, we now update the bounding box
here.
1999-04-15 Michael Meeks <michael@mejm2.dow.cam.ac.uk>
* src/fn-lookup.c: Silly bug in types fixed.
......
1999-04-14 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet.c (sheet_destroy): No longer destroys the Bonobo
objects here.
* src/sheet.h (Sheet): No longer keeps track of the ClientSites
here.
* src/sheet-object.c (sheet_finish_object_creation): Invoke new
class method to signal finalization of object creation.
* src/sheet-object-container.c, src/sheet-object-container.h: New
files that implement the Bonobo ClientSites
(SheetObjectContainers).
* src/Makefile.am (gnumeric_bonobo_SOURCES): Sources for Bonobo
compilation.
* src/sheet-object.c (sheet_object_construct): Create the bounding
box points here.
(sheet_set_mode_type): Fix from my previous reorganization: Only
stop editing mode if the mode is SHEET_MODE_SHEET.
(sheet_button_press): Strategy change: now we accept
sheet->current_object and we stop editing here the object.
* src/sheet-object.h: points has been renamed to bbox_points.
* src/sheet-object-graphic.c (sheet_object_filled_realize):
Simplified this routine. Also, we now update the bounding box
here.
1999-04-15 Michael Meeks <michael@mejm2.dow.cam.ac.uk>
* src/fn-lookup.c: Silly bug in types fixed.
......
1999-04-14 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet.c (sheet_destroy): No longer destroys the Bonobo
objects here.
* src/sheet.h (Sheet): No longer keeps track of the ClientSites
here.
* src/sheet-object.c (sheet_finish_object_creation): Invoke new
class method to signal finalization of object creation.
* src/sheet-object-container.c, src/sheet-object-container.h: New
files that implement the Bonobo ClientSites
(SheetObjectContainers).
* src/Makefile.am (gnumeric_bonobo_SOURCES): Sources for Bonobo
compilation.
* src/sheet-object.c (sheet_object_construct): Create the bounding
box points here.
(sheet_set_mode_type): Fix from my previous reorganization: Only
stop editing mode if the mode is SHEET_MODE_SHEET.
(sheet_button_press): Strategy change: now we accept
sheet->current_object and we stop editing here the object.
* src/sheet-object.h: points has been renamed to bbox_points.
* src/sheet-object-graphic.c (sheet_object_filled_realize):
Simplified this routine. Also, we now update the bounding box
here.
1999-04-15 Michael Meeks <michael@mejm2.dow.cam.ac.uk>
* src/fn-lookup.c: Silly bug in types fixed.
......
# CFLAGS += -g -Wall \
# -Wshadow -Wpointer-arith \
# -Wmissing-prototypes -Wmissing-declarations
#
# Gnumeric's Makefile.
# Author: Miguel de Icaza (miguel@kernel.org)
#
# This Makefile has targets for three programs:
#
# gnumeric:
# the plain spreadsheet
#
# gnumeric-corba:
# spreadsheet with CORBA additions
#
# gnumeric-bonobo:
# spreadsheet with CORBA and Bonobo additions
#
# Note that gnumeric/gnumeric-corba and gnumeric-bonobo are mutually
# exclusive.
#
if BONOBO
bin_PROGRAMS = gnumeric-bonobo
......@@ -126,6 +141,10 @@ GNUMERIC_CORBA_GENERATED = \
Gnumeric-stubs.c \
Gnumeric.h
GNUMERIC_BONOBO_SOURCES = \
sheet-object-container.c \
sheet-object-container.h
BUILT_SOURCES = $(GNUMERIC_CORBA_GENERATED)
Gnumeric-impl.c: Gnumeric.h
......@@ -145,6 +164,14 @@ gnumeric_corba_SOURCES = \
$(GNUMERIC_CORBA_GENERATED) \
$(GNUMERIC_BASE_SOURCES)
gnumeric_bonobo_SOURCES = \
main.c \
corba-args.c \
Gnumeric-impl.c \
$(GNUMERIC_CORBA_GENERATED) \
$(GNUMERIC_BASE_SOURCES) \
$(GNUMERIC_BONOBO_SOURCES)
gnumeric_LDFLAGS = -export-dynamic
gnumeric_LDADD = \
......@@ -170,6 +197,9 @@ gnumeric_bonobo_LDADD = \
wc:
wc -l $(gnumeric_SOURCES)
wc_bonobo:
wc -l $(gnumeric_SOURCES) $(GNUMERIC_BONOBO_SOURCES)
dist-hook:
mkdir $(distdir)/pixmaps
cp $(srcdir)/pixmaps/*.xpm $(distdir)/pixmaps
......
......@@ -603,7 +603,10 @@ cell_set_text_simple (Cell *cell, char *text)
case 'E': case 'e': case '+': case ':': case '.': case ',':
if (*p == 'e' || *p == 'E') {
seen_exp = TRUE;
if (*(p+1)=='-') p++; /* Lookahead */
/* Lookahead */
if (*(p+1) == '-')
p++;
}
if (*p == ',' || *p == '.')
......
......@@ -10,5 +10,6 @@
#include "pixmaps/oval.xpm"
#include "pixmaps/bold.xpm"
#include "pixmaps/italic.xpm"
#include "pixmaps/graphic.xpm"
#endif /* GNUMERIC_PIXMAPS_H */
......@@ -12,7 +12,6 @@
#include "gnumeric-sheet.h"
#include "dialogs.h"
#include "sheet-object-graphic.h"
#include "cursors.h"
static SheetObject *sheet_object_graphic_parent_class;
static SheetObjectGraphic *sheet_object_filled_parent_class;
......@@ -40,7 +39,7 @@ sheet_object_graphic_realize (SheetObject *so, SheetView *sheet_view)
item = gnome_canvas_item_new (
sheet_view->object_group,
gnome_canvas_line_get_type (),
"points", so->points,
"points", so->bbox_points,
"fill_color", sog->color->str,
"width_pixels", sog->width,
NULL);
......@@ -50,7 +49,7 @@ sheet_object_graphic_realize (SheetObject *so, SheetView *sheet_view)
item = gnome_canvas_item_new (
sheet_view->object_group,
gnome_canvas_line_get_type (),
"points", so->points,
"points", so->bbox_points,
"fill_color", sog->color->str,
"width_pixels", sog->width,
"arrow_shape_a", 8.0,
......@@ -73,13 +72,13 @@ sheet_object_graphic_update (SheetObject *sheet_object, gdouble to_x, gdouble to
SheetObjectGraphic *sog = SHEET_OBJECT_GRAPHIC (sheet_object);
GList *l;
sheet_object->points->coords [2] = (gdouble) to_x;
sheet_object->points->coords [3] = (gdouble) to_y;
sheet_object->bbox_points->coords [2] = (gdouble) to_x;
sheet_object->bbox_points->coords [3] = (gdouble) to_y;
for (l = sheet_object->realized_list; l; l = l->next){
GnomeCanvasItem *item = l->data;
gnome_canvas_item_set (item, "points", sheet_object->points, NULL);
gnome_canvas_item_set (item, "points", sheet_object->bbox_points, NULL);
}
}
......@@ -87,10 +86,13 @@ static void
sheet_object_graphic_class_init (GtkObjectClass *object_class)
{
SheetObjectClass *sheet_object_class = SHEET_OBJECT_CLASS (object_class);
sheet_object_graphic_parent_class = gtk_type_class (sheet_object_get_type ());
/* Object class method overrides */
object_class->destroy = sheet_object_graphic_destroy;
/* SheetObject class method overrides */
sheet_object_class->realize = sheet_object_graphic_realize;
sheet_object_class->update = sheet_object_graphic_update;
}
......@@ -141,11 +143,10 @@ sheet_object_create_line (Sheet *sheet, int is_arrow,
sheet_object_construct (so, sheet);
sog->type = is_arrow ? SHEET_OBJECT_ARROW : SHEET_OBJECT_LINE;
so->points = gnome_canvas_points_new (2);
so->points->coords [0] = (gdouble) x1;
so->points->coords [1] = (gdouble) y1;
so->points->coords [2] = (gdouble) x2;
so->points->coords [3] = (gdouble) y2;
so->bbox_points->coords [0] = (gdouble) x1;
so->bbox_points->coords [1] = (gdouble) y1;
so->bbox_points->coords [2] = (gdouble) x2;
so->bbox_points->coords [3] = (gdouble) y2;
sog->color = string_get (color);
sog->width = w;
......@@ -171,50 +172,40 @@ sheet_object_filled_realize (SheetObject *so, SheetView *sheet_view)
SheetObjectGraphic *sog = SHEET_OBJECT_GRAPHIC (so);
SheetObjectFilled *sof = SHEET_OBJECT_FILLED (so);
GnomeCanvasItem *item = NULL;
double *c;
GtkType type;
g_return_val_if_fail (so != NULL, NULL);
g_return_val_if_fail (sheet_view != NULL, NULL);
switch (sog->type){
case SHEET_OBJECT_RECTANGLE: {
double *c = so->points->coords;
item = gnome_canvas_item_new (
sheet_view->object_group,
gnome_canvas_rect_get_type (),
"x1", MIN (c [0], c [2]),
"y1", MIN (c [1], c [3]),
"x2", MAX (c [0], c [2]),
"y2", MAX (c [1], c [3]),
"fill_color", sof->fill_color ?
sof->fill_color->str : NULL,
"outline_color", sog->color->str,
"width_pixels", sog->width,
NULL);
case SHEET_OBJECT_RECTANGLE:
type = gnome_canvas_rect_get_type ();
break;
}
case SHEET_OBJECT_ELLIPSE: {
double *c = so->points->coords;
item = gnome_canvas_item_new (
sheet_view->object_group,
gnome_canvas_ellipse_get_type (),
"x1", MIN (c [0], c [2]),
"y1", MIN (c [1], c [3]),
"x2", MAX (c [0], c [2]),
"y2", MAX (c [1], c [3]),
"fill_color", sof->fill_color ? sof->fill_color->str : NULL,
"outline_color", sog->color->str,
"width_pixels", sog->width,
NULL);
case SHEET_OBJECT_ELLIPSE:
type = gnome_canvas_ellipse_get_type ();
break;
}
default:
type = 0;
g_assert_not_reached ();
}
c = so->bbox_points->coords;
item = gnome_canvas_item_new (
sheet_view->object_group,
type,
"x1", c [0] = MIN (c [0], c [2]),
"y1", c [1] = MIN (c [1], c [3]),
"x2", c [2] = MAX (c [0], c [2]),
"y2", c [3] = MAX (c [1], c [3]),
"fill_color", sof->fill_color ? sof->fill_color->str : NULL,
"outline_color", sog->color->str,
"width_pixels", sog->width,
NULL);
return item;
}
......@@ -224,10 +215,10 @@ sheet_object_filled_update (SheetObject *sheet_object, gdouble to_x, gdouble to_
double x1, x2, y1, y2;
GList *l;
x1 = MIN (sheet_object->points->coords [0], to_x);
x2 = MAX (sheet_object->points->coords [0], to_x);
y1 = MIN (sheet_object->points->coords [1], to_y);
y2 = MAX (sheet_object->points->coords [1], to_y);
x1 = MIN (sheet_object->bbox_points->coords [0], to_x);
x2 = MAX (sheet_object->bbox_points->coords [0], to_x);
y1 = MIN (sheet_object->bbox_points->coords [1], to_y);
y2 = MAX (sheet_object->bbox_points->coords [1], to_y);
for (l = sheet_object->realized_list; l; l = l->next){
GnomeCanvasItem *item = l->data;
......@@ -277,11 +268,10 @@ sheet_object_create_filled (Sheet *sheet, int type,
sog = SHEET_OBJECT_GRAPHIC (so);
sog->type = type;
so->points = gnome_canvas_points_new (2);
so->points->coords [0] = x1;
so->points->coords [1] = y1;
so->points->coords [2] = x2;
so->points->coords [3] = y2;
so->bbox_points->coords [0] = x1;
so->bbox_points->coords [1] = y1;
so->bbox_points->coords [2] = x2;
so->bbox_points->coords [3] = y2;
sog->width = w;
sof->pattern = 0;
......
......@@ -79,7 +79,7 @@ sheet_object_destroy (GtkObject *object)
g_list_free (so->realized_list);
sheet->objects = g_list_remove (sheet->objects, so);
sheet->modified = TRUE;
gnome_canvas_points_free (so->points);
gnome_canvas_points_free (so->bbox_points);
(*sheet_object_parent_class->destroy)(object);
}
......@@ -124,7 +124,7 @@ sheet_object_construct (SheetObject *sheet_object, Sheet *sheet)
g_return_if_fail (IS_SHEET (sheet));
sheet_object->sheet = sheet;
sheet_object->bbox_points = gnome_canvas_points_new (2);
}
/*
......@@ -246,8 +246,14 @@ create_object (Sheet *sheet, gdouble to_x, gdouble to_y)
{
SheetObject *o = NULL;
ObjectCoords *oc;
double x1, x2, y1, y2;
oc = sheet->coords->data;
x1 = MIN (oc->x, to_x);
x2 = MAX (oc->x, to_x);
y1 = MIN (oc->y, to_y);
y2 = MAX (oc->y, to_y);
switch (sheet->mode){
case SHEET_MODE_CREATE_LINE:
......@@ -267,13 +273,6 @@ create_object (Sheet *sheet, gdouble to_x, gdouble to_y)
break;
case SHEET_MODE_CREATE_BOX: {
double x1, x2, y1, y2;
x1 = MIN (oc->x, to_x);
x2 = MAX (oc->x, to_x);
y1 = MIN (oc->y, to_y);
y2 = MAX (oc->y, to_y);
o = sheet_object_create_filled (
sheet, SHEET_OBJECT_RECTANGLE,
x1, y1, x2, y2,
......@@ -282,20 +281,20 @@ create_object (Sheet *sheet, gdouble to_x, gdouble to_y)
}
case SHEET_MODE_CREATE_OVAL: {
double x1, x2, y1, y2;
x1 = MIN (oc->x, to_x);
x2 = MAX (oc->x, to_x);
y1 = MIN (oc->y, to_y);
y2 = MAX (oc->y, to_y);
o = sheet_object_create_filled (
sheet, SHEET_OBJECT_ELLIPSE,
x1, y1, x2, y2,
NULL, "black", 1);
break;
}
case SHEET_MODE_CREATE_GRAPHIC:
#ifdef ENABLE_BONOBO
o = sheet_object_graphic_new (
sheet, x1, y1, x2, y2);
break;
#endif
case SHEET_MODE_SHEET:
case SHEET_MODE_OBJECT_SELECTED:
g_assert_not_reached ();
......@@ -360,7 +359,10 @@ sheet_button_press (GnumericSheet *gsheet, GdkEventButton *event, Sheet *sheet)
{
ObjectCoords *oc;
g_assert (sheet->current_object == NULL);
if (sheet->current_object){
sheet_object_stop_editing (sheet->current_object);
sheet->current_object = NULL;
}
/* Do not propagate this event further */
gtk_signal_emit_stop_by_name (GTK_OBJECT (gsheet), "button_press_event");
......@@ -420,6 +422,9 @@ sheet_finish_object_creation (Sheet *sheet, SheetObject *o)
GTK_SIGNAL_FUNC (sheet_motion_notify), sheet);
}
if (SO_CLASS (o)->creation_finished)
SO_CLASS (o)->creation_finished (o);
}
/*
......@@ -457,20 +462,21 @@ sheet_set_mode_type (Sheet *sheet, SheetModeType mode)
return;
}
sheet_show_cursor (sheet);
if (sheet->current_object){
sheet_object_stop_editing (sheet->current_object);
sheet->current_object = NULL;
}
if (mode == SHEET_MODE_SHEET)
if (mode == SHEET_MODE_SHEET){
sheet_show_cursor (sheet);
if (sheet->current_object){
sheet_object_stop_editing (sheet->current_object);
sheet->current_object = NULL;
}
return;
}
switch (sheet->mode){
case SHEET_MODE_CREATE_LINE:
case SHEET_MODE_CREATE_ARROW:
case SHEET_MODE_CREATE_OVAL:
case SHEET_MODE_CREATE_BOX:
case SHEET_MODE_CREATE_BOX:
case SHEET_MODE_CREATE_GRAPHIC:
for (l = sheet->sheet_views; l; l = l->next){
SheetView *sheet_view = l->data;
GnumericSheet *gsheet = GNUMERIC_SHEET (sheet_view->sheet_view);
......@@ -480,7 +486,7 @@ sheet_set_mode_type (Sheet *sheet, SheetModeType mode)
GTK_SIGNAL_FUNC (sheet_button_press), sheet);
}
break;
default:
g_assert_not_reached ();
}
......@@ -588,7 +594,7 @@ control_point_handle_event (GnomeCanvasItem *item, GdkEvent *event, SheetObject
break;
case GDK_MOTION_NOTIFY: {
double *coords = object->points->coords;
double *coords = object->bbox_points->coords;
int change = 0;
if (!object->dragging)
......@@ -743,10 +749,10 @@ object_event (GnomeCanvasItem *item, GdkEvent *event, SheetObject *object)
gnome_canvas_item_ungrab (item, event->button.time);
sheet_object_unrealize (object->sheet, object);
object->points->coords [0] += total_x;
object->points->coords [1] += total_y;
object->points->coords [2] += total_x;
object->points->coords [3] += total_y;
object->bbox_points->coords [0] += total_x;
object->bbox_points->coords [1] += total_y;
object->bbox_points->coords [2] += total_x;
object->bbox_points->coords [3] += total_y;
sheet_object_realize (object->sheet, object);
sheet_object_make_current (object->sheet, object);
......@@ -823,7 +829,7 @@ static void
sheet_object_start_editing (SheetObject *object)
{
Sheet *sheet = object->sheet;
double *points = object->points->coords;
double *points = object->bbox_points->coords;
GList *l;
for (l = sheet->sheet_views; l; l = l->next){
......
......@@ -18,7 +18,7 @@ typedef struct {
int dragging;
/* Bounding box */
GnomeCanvasPoints *points;
GnomeCanvasPoints *bbox_points;
} SheetObject;
typedef struct {
......@@ -27,6 +27,7 @@ typedef struct {
/* Virtual methods */
GnomeCanvasItem *(*realize) (SheetObject *sheet_object, SheetView *sheet_view);
void (*update) (SheetObject *sheet_object, gdouble x, gdouble y);
void (*creation_finished) (SheetObject *sheet_object);
} SheetObjectClass;
GtkType sheet_object_get_type (void);
......@@ -58,12 +59,12 @@ void sheet_object_make_current (Sheet *sheet,
void sheet_object_register (Sheet *sheet,
SheetObject *object);
SheetObject *sheet_object_create_line (Sheet *sheet, int is_arrow,
SheetObject *sheet_object_create_line (Sheet *sheet, int is_arrow,
double x1, double y1,
double x2, double y2,
char *color, int width);
SheetObject *sheet_object_create_filled (Sheet *sheet, int type,
SheetObject *sheet_object_create_filled (Sheet *sheet, int type,
double x1, double y1,
double x2, double y2,
char *fill_color, char *outline_color,
......
......@@ -2208,23 +2208,6 @@ sheet_destroy_columns_and_rows (Sheet *sheet)
sheet->rows_info = NULL;
}
#ifdef ENABLE_BONOBO
static void
sheet_destroy_objects (Sheet *sheet)
{
GListClientSite *l;
/*
* Kill any Bonobo links
*/
for (l = sheet->client_site_list; l; l = g_list_next (l)){
GnomeClientSite *client_site = l->data;
gtk_object_unref (GTK_OBJECT (client_site));
}
}
#endif
/**
* sheet_destroy:
* @sheet: the sheet to destroy
......@@ -2243,10 +2226,7 @@ sheet_destroy (Sheet *sheet)
g_return_if_fail (IS_SHEET (sheet));
g_return_if_fail (sheet->workbook == NULL);
#ifdef ENABLE_BONOBO
sheet_destroy_objects (sheet);
#endif
g_warning ("Reminder: need to destroy SheetObjects");
sheet_selections_free (sheet);
g_free (sheet->name);
......
......@@ -90,17 +90,22 @@ typedef struct {