Commit 2ba8959f authored by Chema Celorio's avatar Chema Celorio Committed by Jose Maria Celorio

add the header for clone_sheet

2001-04-27  Chema Celorio  <chema@celorio.com>

	* src/sheet-object.h: add the header for clone_sheet

	* src/sheet-object.c (sheet_object_clone): implement
	(sheet_object_clone_sheet): implemnt.

	* src/sheet-object-widget.c (SOW_MAKE_TYPE): add read_xml, write_xml
	and clone methods to macro
	(sheet_object_widget_clone): implement.
	Implement for X in label, frame, button, checkbox
	(sheet_widget_x_construct_with_label):
	(sheet_widget_x_destroy):
	(sheet_widget_x_clone):
	(sheet_widget_x_write_xml):
	(sheet_widget_x_read_xml):

	(sheet_object_widget_register): implement

	* src/sheet-object-impl.h: add the clone method

	* src/sheet-object-graphic.c (sheet_object_graphic_clone): implement.
	(sheet_object_filled_clone): implement.

	* src/sheet-object-cell-comment.c (cell_comment_clone): implement
parent 97e49011
2001-04-27 Chema Celorio <chema@celorio.com>
* src/sheet-object.h: add the header for clone_sheet
* src/sheet-object.c (sheet_object_clone): implement
(sheet_object_clone_sheet): implemnt.
* src/sheet-object-widget.c (SOW_MAKE_TYPE): add read_xml, write_xml
and clone methods to macro
(sheet_object_widget_clone): implement.
Implement for X in label, frame, button, checkbox
(sheet_widget_x_construct_with_label):
(sheet_widget_x_destroy):
(sheet_widget_x_clone):
(sheet_widget_x_write_xml):
(sheet_widget_x_read_xml):
(sheet_object_widget_register): implement
* src/sheet-object-impl.h: add the clone method
* src/sheet-object-graphic.c (sheet_object_graphic_clone): implement.
(sheet_object_filled_clone): implement.
* src/sheet-object-cell-comment.c (cell_comment_clone): implement
2001-04-26 Jon K Hellan <hellan@acm.org>
* src/item-grid.c (item_grid_button_1): Invoke
......
......@@ -6,7 +6,7 @@ Almer:
Chema:
* GNUMERIC_ENABLE_XL_OVERWRITE
* Implemented clone, write and load for some sheet objects
Jody:
* Outline mode
* Restore horizontal FILL alignment.
......
2001-04-27 Chema Celorio <chema@celorio.com>
* src/sheet-object.h: add the header for clone_sheet
* src/sheet-object.c (sheet_object_clone): implement
(sheet_object_clone_sheet): implemnt.
* src/sheet-object-widget.c (SOW_MAKE_TYPE): add read_xml, write_xml
and clone methods to macro
(sheet_object_widget_clone): implement.
Implement for X in label, frame, button, checkbox
(sheet_widget_x_construct_with_label):
(sheet_widget_x_destroy):
(sheet_widget_x_clone):
(sheet_widget_x_write_xml):
(sheet_widget_x_read_xml):
(sheet_object_widget_register): implement
* src/sheet-object-impl.h: add the clone method
* src/sheet-object-graphic.c (sheet_object_graphic_clone): implement.
(sheet_object_filled_clone): implement.
* src/sheet-object-cell-comment.c (cell_comment_clone): implement
2001-04-26 Jon K Hellan <hellan@acm.org>
* src/item-grid.c (item_grid_button_1): Invoke
......
2001-04-27 Chema Celorio <chema@celorio.com>
* src/sheet-object.h: add the header for clone_sheet
* src/sheet-object.c (sheet_object_clone): implement
(sheet_object_clone_sheet): implemnt.
* src/sheet-object-widget.c (SOW_MAKE_TYPE): add read_xml, write_xml
and clone methods to macro
(sheet_object_widget_clone): implement.
Implement for X in label, frame, button, checkbox
(sheet_widget_x_construct_with_label):
(sheet_widget_x_destroy):
(sheet_widget_x_clone):
(sheet_widget_x_write_xml):
(sheet_widget_x_read_xml):
(sheet_object_widget_register): implement
* src/sheet-object-impl.h: add the clone method
* src/sheet-object-graphic.c (sheet_object_graphic_clone): implement.
(sheet_object_filled_clone): implement.
* src/sheet-object-cell-comment.c (cell_comment_clone): implement
2001-04-26 Jon K Hellan <hellan@acm.org>
* src/item-grid.c (item_grid_button_1): Invoke
......
2001-04-27 Chema Celorio <chema@celorio.com>
* src/sheet-object.h: add the header for clone_sheet
* src/sheet-object.c (sheet_object_clone): implement
(sheet_object_clone_sheet): implemnt.
* src/sheet-object-widget.c (SOW_MAKE_TYPE): add read_xml, write_xml
and clone methods to macro
(sheet_object_widget_clone): implement.
Implement for X in label, frame, button, checkbox
(sheet_widget_x_construct_with_label):
(sheet_widget_x_destroy):
(sheet_widget_x_clone):
(sheet_widget_x_write_xml):
(sheet_widget_x_read_xml):
(sheet_object_widget_register): implement
* src/sheet-object-impl.h: add the clone method
* src/sheet-object-graphic.c (sheet_object_graphic_clone): implement.
(sheet_object_filled_clone): implement.
* src/sheet-object-cell-comment.c (cell_comment_clone): implement
2001-04-26 Jon K Hellan <hellan@acm.org>
* src/item-grid.c (item_grid_button_1): Invoke
......
2001-04-27 Chema Celorio <chema@celorio.com>
* src/sheet-object.h: add the header for clone_sheet
* src/sheet-object.c (sheet_object_clone): implement
(sheet_object_clone_sheet): implemnt.
* src/sheet-object-widget.c (SOW_MAKE_TYPE): add read_xml, write_xml
and clone methods to macro
(sheet_object_widget_clone): implement.
Implement for X in label, frame, button, checkbox
(sheet_widget_x_construct_with_label):
(sheet_widget_x_destroy):
(sheet_widget_x_clone):
(sheet_widget_x_write_xml):
(sheet_widget_x_read_xml):
(sheet_object_widget_register): implement
* src/sheet-object-impl.h: add the clone method
* src/sheet-object-graphic.c (sheet_object_graphic_clone): implement.
(sheet_object_filled_clone): implement.
* src/sheet-object-cell-comment.c (cell_comment_clone): implement
2001-04-26 Jon K Hellan <hellan@acm.org>
* src/item-grid.c (item_grid_button_1): Invoke
......
2001-04-27 Chema Celorio <chema@celorio.com>
* boot.c (excel_save): add a message explaining that you could set an env variable to
enable XL overwrite. This is not the optimal solution tho.
2001-04-26 Jody Goldberg <jgoldberg@home.com>
* ms-excel-write.c (write_colinfos) : Rework to simplify and use
......
......@@ -150,7 +150,9 @@ excel_save (IOContext *context, WorkbookView *wb_view, const char *filename,
if (disable_safety == NULL) {
gnumeric_io_error_save (context,
_("Saving over old Excel files disabled for safety"));
_("Saving over old Excel files disabled for safety\n\n"
"(You can turn this safety feature off by setting the\n"
"enviromental variable GNUMERIC_ENABLE_XL_OVERWRITE)"));
return;
}
}
......
/* vim: set sw=8: */
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* commands.c: Handlers to undo & redo commands
......@@ -2925,6 +2925,7 @@ cmd_merge_cells (WorkbookControl *wbc, Sheet *sheet, GList const *selection)
return command_push_undo (wbc, obj);
}
/******************************************************************/
#define CMD_SEARCH_REPLACE_TYPE (cmd_search_replace_get_type())
#define CMD_SEARCH_REPLACE(o) (GTK_CHECK_CAST ((o), CMD_SEARCH_REPLACE_TYPE, CmdSearchReplace))
......
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef GNUMERIC_COMMANDS_H
#define GNUMERIC_COMMANDS_H
......
/* vim: set sw=8: */
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* sheet-object-cell-comment.c: A SheetObject to support cell comments.
......@@ -205,6 +205,20 @@ cell_comment_print (SheetObject const *so, SheetObjectPrintInfo const *pi)
{
}
static SheetObject *
cell_comment_clone (SheetObject const *so, Sheet *sheet)
{
CellComment *comment = CELL_COMMENT (so);
CellComment *new_comment;
new_comment = gtk_type_new (CELL_COMMENT_TYPE);
new_comment->author = comment->author ? g_strdup (comment->author) : NULL;
new_comment->text = comment->text ? g_strdup (comment->text) : NULL;
return SHEET_OBJECT (new_comment);
}
static void
cell_comment_class_init (GtkObjectClass *object_class)
{
......@@ -221,6 +235,7 @@ cell_comment_class_init (GtkObjectClass *object_class)
sheet_object_class->read_xml = &cell_comment_read_xml;
sheet_object_class->write_xml = &cell_comment_write_xml;
sheet_object_class->print = &cell_comment_print;
sheet_object_class->clone = &cell_comment_clone;
}
GNUMERIC_MAKE_TYPE (cell_comment,
......
/* vim: set sw=8: */
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* sheet-object-graphic.c: Implements the drawing object manipulation for Gnumeric
......@@ -174,6 +174,21 @@ sheet_object_graphic_write_xml (SheetObject const *so,
return FALSE;
}
static SheetObject *
sheet_object_graphic_clone (SheetObject const *so, Sheet *sheet)
{
SheetObjectGraphic *sog = SHEET_OBJECT_GRAPHIC (so);
SheetObjectGraphic *new_sog;
new_sog = SHEET_OBJECT_GRAPHIC (gtk_type_new (GTK_OBJECT_TYPE (sog)));
new_sog->type = sog->type;
new_sog->width = sog->width;
new_sog->color = sog->color ? string_ref (sog->color) : NULL;
return SHEET_OBJECT (new_sog);
}
static void
sheet_object_graphic_print (SheetObject const *so, SheetObjectPrintInfo const *pi)
{
......@@ -225,7 +240,9 @@ sheet_object_graphic_class_init (GtkObjectClass *object_class)
sheet_object_class->update_bounds = sheet_object_graphic_update_bounds;
sheet_object_class->new_view = sheet_object_graphic_new_view;
sheet_object_class->read_xml = sheet_object_graphic_read_xml;
sheet_object_class->write_xml = sheet_object_graphic_write_xml;
sheet_object_class->print = sheet_object_graphic_print;
sheet_object_class->clone = sheet_object_graphic_clone;
}
static void
......@@ -393,6 +410,22 @@ sheet_object_filled_write_xml (SheetObject const *so,
return sheet_object_graphic_write_xml (so, ctxt, tree);
}
static SheetObject *
sheet_object_filled_clone (SheetObject const *so, Sheet *sheet)
{
SheetObjectFilled *sof = SHEET_OBJECT_FILLED (so);
SheetObjectFilled *new_sof;
SheetObject *new_so;
new_so = sheet_object_graphic_clone (so, sheet);
new_sof = SHEET_OBJECT_FILLED (new_so);
new_sof->pattern = sof->pattern;
new_sof->fill_color = sof->fill_color ? string_ref (sof->fill_color) : NULL;
return SHEET_OBJECT (new_sof);
}
static void
sheet_object_filled_class_init (GtkObjectClass *object_class)
{
......@@ -404,6 +437,7 @@ sheet_object_filled_class_init (GtkObjectClass *object_class)
sheet_object_class->update_bounds = sheet_object_filled_update_bounds;
sheet_object_class->read_xml = sheet_object_filled_read_xml;
sheet_object_class->write_xml = sheet_object_filled_write_xml;
sheet_object_class->clone = sheet_object_filled_clone;
}
static void
......
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef GNUMERIC_SHEET_OBJECT_PRIV_H
#define GNUMERIC_SHEET_OBJECT_PRIV_H
......@@ -28,7 +29,7 @@ typedef struct {
gboolean (*assign_to_sheet) (SheetObject *sheet_object,
Sheet *sheet);
GtkObject * (*new_view) (SheetObject *sheet_object,
GtkObject * (*new_view) (SheetObject *sheet_object,
SheetControlGUI *s_control);
void (*populate_menu) (SheetObject *sheet_object,
GnomeCanvasItem *obj_view,
......@@ -40,7 +41,7 @@ typedef struct {
SheetControlGUI *s_control);
void (*set_active) (SheetObject *so,
gboolean val);
gboolean (*read_xml) (SheetObject *so,
gboolean (*read_xml) (SheetObject *so,
XmlParseContext const *ctxt,
xmlNodePtr tree);
gboolean (*write_xml) (SheetObject const *so,
......@@ -48,6 +49,9 @@ typedef struct {
xmlNodePtr tree);
void (*print) (SheetObject const *so,
SheetObjectPrintInfo const *pi);
SheetObject * (*clone) (SheetObject const *so,
Sheet *sheet);
double default_width_pts, default_height_pts;
} SheetObjectClass;
......
/* vim: set sw=8: */
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* sheet-object-widget.c: SheetObject wrappers for simple gtk widgets.
......@@ -34,6 +34,7 @@
#include "sheet-object-impl.h"
#include "expr.h"
#include "value.h"
#include "ranges.h"
#include "selection.h"
#include "workbook-edit.h"
#include "workbook.h"
......@@ -45,7 +46,8 @@
#define IS_SHEET_WIDGET_OBJECT(o) (GTK_CHECK_TYPE((o), SHEET_OBJECT_WIDGET_TYPE))
#define SOW_CLASS(so) (SHEET_OBJECT_WIDGET_CLASS (GTK_OBJECT(so)->klass))
#define SOW_MAKE_TYPE_WITH_SHEET(n1, n2, fn_config, fn_set_sheet, fn_clear_sheet) \
#define SOW_MAKE_TYPE(n1, n2, fn_config, fn_set_sheet, fn_clear_sheet,\
fn_clone, fn_write_xml, fn_read_xml) \
static void \
sheet_widget_ ## n1 ## _class_init (GtkObjectClass *object_class) \
{ \
......@@ -55,6 +57,9 @@ sheet_widget_ ## n1 ## _class_init (GtkObjectClass *object_class) \
so_class->user_config = fn_config; \
so_class->assign_to_sheet = fn_set_sheet; \
so_class->remove_from_sheet = fn_clear_sheet; \
so_class->clone = fn_clone; \
so_class->write_xml = fn_write_xml; \
so_class->read_xml = fn_read_xml; \
object_class->destroy = & sheet_widget_ ## n1 ## _destroy; \
} \
static GNUMERIC_MAKE_TYPE(sheet_widget_ ## n1, "SheetWidget" #n2, SheetWidget ## n2, \
......@@ -73,8 +78,6 @@ sheet_widget_ ## n1 ## _new(Sheet *sheet) \
return SHEET_OBJECT (sow); \
}
#define SOW_MAKE_TYPE(n1, n2, config) SOW_MAKE_TYPE_WITH_SHEET(n1, n2, config, NULL, NULL)
typedef struct _SheetObjectWidget SheetObjectWidget;
struct _SheetObjectWidget {
......@@ -131,7 +134,7 @@ sheet_object_widget_update_bounds (SheetObject *so, GtkObject *view,
double coords [4];
/* NOTE : far point is EXCLUDED so we add 1 */
scg_object_view_position (scg, so, coords);
scg_object_view_position (scg, so, coords);
gnome_canvas_item_set (GNOME_CANVAS_ITEM (view),
"x", coords [0], "y", coords [1],
"width", coords [2] - coords [0] + 1.,
......@@ -163,6 +166,28 @@ sheet_object_widget_construct (SheetObjectWidget *sow, Sheet *sheet)
so->type = SHEET_OBJECT_ACTION_CAN_PRESS;
}
/**
* sheet_object_widget_clone:
* @so: The source object for that we are going to use as cloning source
* @sheet: The destination sheet of the cloned object
*
* The common part of the clone rutine of all the objects
*
* Return Value: a newly created SheetObjectWidget
**/
static SheetObjectWidget *
sheet_object_widget_clone (SheetObject const *so, Sheet *sheet)
{
SheetObjectWidget *sow = SHEET_OBJECT_WIDGET (so);
SheetObjectWidget *new_sow;
new_sow = SHEET_OBJECT_WIDGET (gtk_type_new (GTK_OBJECT_TYPE (sow)));
sheet_object_widget_construct (new_sow, sheet);
return new_sow;
}
static GNUMERIC_MAKE_TYPE (sheet_object_widget,
"SheetObjectWidget", SheetObjectWidget,
&sheet_object_widget_class_init, NULL,
......@@ -174,29 +199,96 @@ static GtkType sheet_widget_label_get_type (void);
#define SHEET_WIDGET_LABEL(obj) (GTK_CHECK_CAST((obj), SHEET_WIDGET_LABEL_TYPE, SheetWidgetLabel))
typedef struct {
SheetObjectWidget sow;
char *label;
} SheetWidgetLabel;
typedef struct {
SheetObjectWidgetClass sow;
} SheetWidgetLabelClass;
static void
sheet_widget_label_construct_with_label (SheetObjectWidget *sow, const char *text)
{
SheetWidgetLabel *swl = SHEET_WIDGET_LABEL (sow);
swl->label = g_strdup (text);
}
static void
sheet_widget_label_construct (SheetObjectWidget *sow, Sheet *sheet)
{
sheet_widget_label_construct_with_label (sow, _("Label"));
}
static void
sheet_widget_label_destroy (GtkObject *obj)
{
SheetWidgetLabel *swl = SHEET_WIDGET_LABEL (obj);
g_free (swl->label);
swl->label = NULL;
(*sheet_object_widget_class->destroy)(obj);
}
static GtkWidget *
sheet_widget_label_create_widget (SheetObjectWidget *sow, SheetControlGUI *sview)
{
return gtk_label_new ("Label");
SheetWidgetLabel *swl = SHEET_WIDGET_LABEL (sow);
return gtk_label_new (swl->label);
}
static SheetObject *
sheet_widget_label_clone (SheetObject const *so, Sheet *new_sheet)
{
SheetObjectWidget *new_sow;
new_sow = sheet_object_widget_clone (so, new_sheet);
sheet_widget_label_construct_with_label (new_sow, SHEET_WIDGET_LABEL (so)->label);
return SHEET_OBJECT (new_sow);
}
SOW_MAKE_TYPE(label, Label, NULL)
static gboolean
sheet_widget_label_write_xml (SheetObject const *so,
XmlParseContext const *context,
xmlNodePtr tree)
{
SheetWidgetLabel *swl = SHEET_WIDGET_LABEL (so);
xml_set_value_cstr (tree, "Label", swl->label);
return FALSE;
}
static gboolean
sheet_widget_label_read_xml (SheetObject *so,
XmlParseContext const *context,
xmlNodePtr tree)
{
SheetWidgetLabel *swl = SHEET_WIDGET_LABEL (so);
char *label = xmlGetProp (tree, "Label");
if (!label) {
g_warning ("Could not read a SheetWidgetLabel beacause it lacks a label property\n");
return TRUE;
}
swl->label = g_strdup (label);
xmlFree (label);
return FALSE;
}
SOW_MAKE_TYPE(label, Label,
NULL,
NULL,
NULL,
&sheet_widget_label_clone,
&sheet_widget_label_write_xml,
&sheet_widget_label_read_xml);
/****************************************************************************/
static GtkType sheet_widget_frame_get_type (void);
......@@ -204,59 +296,193 @@ static GtkType sheet_widget_frame_get_type (void);
#define SHEET_WIDGET_FRAME(obj) (GTK_CHECK_CAST((obj), SHEET_WIDGET_FRAME_TYPE, SheetWidgetFrame))
typedef struct {
SheetObjectWidget sow;
char *label;
} SheetWidgetFrame;
typedef struct {
SheetObjectWidgetClass sow;
} SheetWidgetFrameClass;
static void
sheet_widget_frame_construct_with_label (SheetObjectWidget *sow, const char *text)
{
SheetWidgetFrame *swf = SHEET_WIDGET_FRAME (sow);
swf->label = g_strdup (text);
}
static void
sheet_widget_frame_construct (SheetObjectWidget *sow, Sheet *sheet)
{
sheet_widget_frame_construct_with_label (sow, _("Frame"));
}
static void
sheet_widget_frame_destroy (GtkObject *obj)
{
SheetWidgetFrame *swf = SHEET_WIDGET_FRAME (obj);
g_free (swf->label);
swf->label = NULL;
(*sheet_object_widget_class->destroy)(obj);
}
static GtkWidget *
sheet_widget_frame_create_widget (SheetObjectWidget *sow, SheetControlGUI *sview)
{
return gtk_frame_new ("Frame");
SheetWidgetFrame *swf = SHEET_WIDGET_FRAME (sow);
return gtk_frame_new (swf->label);
}
SOW_MAKE_TYPE(frame, Frame, NULL)
static SheetObject *
sheet_widget_frame_clone (SheetObject const *so, Sheet *new_sheet)
{
SheetObjectWidget *new_sow;
new_sow = sheet_object_widget_clone (so, new_sheet);
sheet_widget_frame_construct_with_label (new_sow,
SHEET_WIDGET_FRAME (so)->label);
return SHEET_OBJECT (new_sow);
}
static gboolean
sheet_widget_frame_write_xml (SheetObject const *so,
XmlParseContext const *context,
xmlNodePtr tree)
{
SheetWidgetFrame *swf = SHEET_WIDGET_FRAME (so);
xml_set_value_cstr (tree, "Label", swf->label);
return FALSE;
}
static gboolean
sheet_widget_frame_read_xml (SheetObject *so,
XmlParseContext const *context,
xmlNodePtr tree)
{
SheetWidgetFrame *swf = SHEET_WIDGET_FRAME (so);
char *label = xmlGetProp (tree, "Label");
if (!label) {
g_warning ("Could not read a SheetWidgetFrame beacause it lacks a label property\n");
return TRUE;
}
swf->label = g_strdup (label);
xmlFree (label);
return FALSE;
}
SOW_MAKE_TYPE(frame, Frame,
NULL,
NULL,
NULL,
&sheet_widget_frame_clone,
&sheet_widget_frame_write_xml,
&sheet_widget_frame_read_xml);
/****************************************************************************/
static GtkType sheet_widget_button_get_type (void);
#define SHEET_WIDGET_BUTTON_TYPE (sheet_widget_button_get_type ())
#define SHEET_WIDGET_BUTTON(obj) (GTK_CHECK_CAST((obj), SHEET_WIDGET_BUTTON_TYPE, SheetWidgetbutton))
#define SHEET_WIDGET_BUTTON(obj) (GTK_CHECK_CAST((obj), SHEET_WIDGET_BUTTON_TYPE, SheetWidgetButton))
typedef struct {
SheetObjectWidget sow;
char *label;
} SheetWidgetButton;
typedef struct {
SheetObjectWidgetClass sow;
} SheetWidgetButtonClass;
static void
sheet_widget_button_construct_with_label (SheetObjectWidget *sow, const char *text)
{
SheetWidgetButton *swb = SHEET_WIDGET_BUTTON (sow);
swb->label = g_strdup (text);
}
static void
sheet_widget_button_construct (SheetObjectWidget *sow, Sheet *sheet)
{
sheet_widget_button_construct_with_label (sow, _("Button"));
}
static void
sheet_widget_button_destroy (GtkObject *obj)
{
SheetWidgetButton *swb = SHEET_WIDGET_BUTTON (obj);
g_free (swb->label);
swb->label = NULL;
(*sheet_object_widget_class->destroy)(obj);
}
static GtkWidget *
sheet_widget_button_create_widget (SheetObjectWidget *sow, SheetControlGUI *sview)
{
return gtk_button_new_with_label (_("Button"));
SheetWidgetButton *swb = SHEET_WIDGET_BUTTON (sow);
return gtk_button_new_with_label (swb->label);
}
SOW_MAKE_TYPE(button, Button, NULL)
static SheetObject *
sheet_widget_button_clone (SheetObject const *so, Sheet *new_sheet)
{
SheetObjectWidget *new_sow;
new_sow = sheet_object_widget_clone (so, new_sheet);
sheet_widget_button_construct_with_label (new_sow, SHEET_WIDGET_BUTTON (so)->label);
return SHEET_OBJECT (new_sow);
}
static gboolean
sheet_widget_button_write_xml (SheetObject const *so,
XmlParseContext const *context,
xmlNodePtr tree)
{
SheetWidgetButton *swb = SHEET_WIDGET_BUTTON (so);
xml_set_value_cstr (tree, "Label", swb->label);
return FALSE;
}
static gboolean
sheet_widget_button_read_xml (SheetObject *so,
XmlParseContext const *context,
xmlNodePtr tree)
{
SheetWidgetButton *swb = SHEET_WIDGET_BUTTON (so);
char *label = xmlGetProp (tree, "Label");
if (!label) {
g_warning ("Could not read a SheetWidgetButton beacause it lacks a label property\n");
return TRUE;
}
swb->label = g_strdup (label);
xmlFree (label);
return FALSE;
}
SOW_MAKE_TYPE(button, Button,
NULL,
NULL,
NULL,
&sheet_widget_button_clone,
&sheet_widget_button_write_xml,
&sheet_widget_button_read_xml);
/****************************************************************************/
static GtkType sheet_widget_checkbox_get_type (void);
......@@ -345,11 +571,12 @@ checkbox_get_dep_type (void)
}
static void
sheet_widget_checkbox_construct (SheetObjectWidget *sow, Sheet *sheet)
sheet_widget_checkbox_construct_with_range (SheetObjectWidget *sow,
Sheet *sheet,
const Range *range)
{
static int counter = 0;
SheetWidgetCheckbox *swc = SHEET_WIDGET_CHECKBOX (sow);
Range const * range = selection_first_range (sheet, TRUE);
CellRef ref;
g_return_if_fail (swc != NULL);
......@@ -368,6 +595,14 @@ sheet_widget_checkbox_construct (SheetObjectWidget *sow, Sheet *sheet)
swc->dep.expression = expr_tree_new_var (&ref);
}
static void
sheet_widget_checkbox_construct (SheetObjectWidget *sow, Sheet *sheet)
{
Range const * range = selection_first_range (sheet, TRUE);
sheet_widget_checkbox_construct_with_range (sow, sheet, range);
}
static void
sheet_widget_checkbox_destroy (GtkObject *obj)
{
......@@ -377,6 +612,7 @@ sheet_widget_checkbox_destroy (GtkObject *obj)
g_free (swc->label);
swc->label = NULL;
dependent_unlink (&swc->dep, NULL);
if (swc->dep.expression != NULL) {
expr_tree_unref (swc->dep.expression);
......@@ -422,6 +658,61 @@ sheet_widget_checkbox_create_widget (SheetObjectWidget *sow, SheetControlGUI *sv
return button;
}
static void
sheet_widget_checkbox_get_ref (SheetWidgetCheckbox *swc, const CellRef **ref)
{
const ExprTree *tree;
g_return_if_fail (swc != NULL);