Commit f8361526 authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa
Browse files

Use the standard procedure to set the font.

1999-08-06  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* src/corba-sheet.c (Sheet_cell_set_font): Use the standard
	procedure to set the font.

	* src/cell.c: deleted finally cell_set_font.

	* src/workbook.c: Reorganization to make the code be a GtkObject.
	Redone the destruction bits of the Workbook.

	* src/workbook.h: Split sheet.h into workbook.h and sheet.h

	* src/workbook.h: Now the Workbook is a GtkObject or a
	GnomeObject, depending on the compilation flags.
parent d58463af
1999-08-06 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/corba-sheet.c (Sheet_cell_set_font): Use the standard
procedure to set the font.
* src/cell.c: deleted finally cell_set_font.
* src/workbook.c: Reorganization to make the code be a GtkObject.
Redone the destruction bits of the Workbook.
* src/workbook.h: Split sheet.h into workbook.h and sheet.h
* src/workbook.h: Now the Workbook is a GtkObject or a
GnomeObject, depending on the compilation flags.
1999-08-05 Morten Welinder <terra@diku.dk>
* src/dialog-printer-setup.c (dialog_print_info_destroy): Plug
......
1999-08-06 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/corba-sheet.c (Sheet_cell_set_font): Use the standard
procedure to set the font.
* src/cell.c: deleted finally cell_set_font.
* src/workbook.c: Reorganization to make the code be a GtkObject.
Redone the destruction bits of the Workbook.
* src/workbook.h: Split sheet.h into workbook.h and sheet.h
* src/workbook.h: Now the Workbook is a GtkObject or a
GnomeObject, depending on the compilation flags.
1999-08-05 Morten Welinder <terra@diku.dk>
* src/dialog-printer-setup.c (dialog_print_info_destroy): Plug
......
......@@ -2,6 +2,12 @@
Gnumeric Spread Sheet task list
* Workbook
Have a new "manager" file that will take over the details of open
workbooks and active servers, instead of the current approach we
use to have this management in the workbook.c file
* Component
Make sheet_selection_changed_hook execute a list of hooks
......
......@@ -174,6 +174,7 @@ GNUMERIC_BASE_SOURCES = \
widget-font-selector.c \
widget-font-selector.h \
workbook.c \
workbook.h \
xml-io.c \
xml-io.h
......
......@@ -201,30 +201,6 @@ cell_set_font_from_style (Cell *cell, StyleFont *style_font)
cell_queue_redraw (cell);
}
#if 0
/* Ready for deletion? */
static void
cell_set_font (Cell *cell, const char *font_name, double points)
{
StyleFont *style_font;
Sheet *sheet;
g_return_if_fail (cell != NULL);
g_return_if_fail (font_name != NULL);
sheet = cell->sheet;
style_font = style_font_new (
font_name,
points,
sheet->last_zoom_factor_used,
cell->style->font->is_bold,
cell->style->font->is_italic);
if (style_font)
cell_set_font_from_style (cell, style_font);
}
#endif
void
cell_set_style (Cell *cell, Style *reference_style)
{
......
......@@ -498,13 +498,21 @@ Sheet_cell_set_font (PortableServer_Servant servant,
CORBA_Environment *ev)
{
Sheet *sheet = sheet_from_servant (servant);
StyleFont *style_font;
Cell *cell;
verify_col (col);
verify_row (row);
cell = sheet_cell_fetch (sheet, col, row);
cell_set_font (cell, font, points);
style_font = style_font_new (
font, points, sheet->last_zoom_factor_used,
cell->style->font->is_bold,
cell->style->font->is_italic);
if (style_font)
cell_set_font_from_style (cell, style_font);
}
static CORBA_char *
......
......@@ -179,13 +179,22 @@ Workbook_corba_class_init ()
gnome_gnumeric_workbook_epv.parse = Workbook_parse;
}
/**
* Initializes the CORBA side of a Workbook structure.
*
* Creates the POA servant to handle requests for this Workbook and makes
* the Workbook a GNOME object server.
*/
void
workbook_corba_setup (Workbook *workbook)
{
WorkbookServant *ws;
CORBA_Environment ev;
PortableServer_ObjectId *objid;
/*
* 1. The CORBA servant for the Workbook
*/
Workbook_corba_class_init ();
ws = g_new0 (WorkbookServant, 1);
......
......@@ -111,7 +111,7 @@ embeddable_grid_init (GtkObject *object)
{
EmbeddableGrid *eg = EMBEDDABLE_GRID (object);
eg->workbook = workbook_core_new ();
eg->workbook = gtk_type_new (WORKBOOK_TYPE);
eg->sheet = sheet_new (eg->workbook, _("Embedded Sheet"));
workbook_attach_sheet (eg->workbook, eg->sheet);
......
......@@ -41,6 +41,7 @@ typedef struct {
#include "symbol.h"
#include "cell.h"
#include "summary.h"
#include "workbook.h"
#define SHEET_MAX_ROWS (16 * 1024)
#define SHEET_MAX_COLS 256
......@@ -54,77 +55,6 @@ typedef struct {
Style *style;
} StyleRegion;
/* Forward declaration */
struct _PrintInformation;
typedef struct _PrintInformation PrintInformation;
struct _Workbook {
char *filename;
GtkWidget *toplevel;
GtkWidget *notebook;
GtkWidget *table;
/* Edit area */
GtkWidget *ea_status;
GtkWidget *ea_button_box;
GtkWidget *ea_input;
/* The status bar */
GnomeAppBar * appbar;
/* The auto-expression */
ExprTree *auto_expr;
String *auto_expr_desc;
GnomeCanvasItem *auto_expr_label;
/* Styles */
Style style;
/* The sheets */
GHashTable *sheets; /* keeps a list of the Sheets on this workbook */
/* User defined names */
GList *names;
/* A list with all of the formulas */
GList *formula_cell_list;
/* A queue with the cells to be evaluated */
GList *eval_queue;
int max_iterations;
int generation;
/* The clipboard for this workbook */
CellRegion *clipboard_contents;
gboolean have_x_selection;
/* The Symbol table used for naming cell ranges in the workbook */
SymbolTable *symbol_names;
/* Attached summary information */
SummaryInfo *sin;
/*
* This is used during the clipboard paste command to pass information
* to the asyncronous paste callback
*/
void *clipboard_paste_callback_data;
PrintInformation *print_info;
void *toolbar;
#ifdef ENABLE_BONOBO
/* A GnomeContainer */
GnomeContainer *gnome_container;
#endif
void *corba_server;
};
typedef struct {
int base_col, base_row;
int start_col, start_row;
......@@ -440,87 +370,9 @@ char *cellref_name (CellRef *cell_ref,
*/
void sheet_insert_object (Sheet *sheet, char *repoid);
/*
* Workbook
*/
Workbook *workbook_new (void);
Workbook *workbook_core_new (void);
void workbook_destroy (Workbook *wb);
Workbook *workbook_new_with_sheets (int sheet_count);
void workbook_set_filename (Workbook *, const char *);
void workbook_set_title (Workbook *, const char *);
Workbook *workbook_read (const char *filename);
void workbook_save_as (Workbook *);
void workbook_save (Workbook *);
void workbook_print (Workbook *);
void workbook_attach_sheet (Workbook *, Sheet *);
gboolean workbook_detach_sheet (Workbook *, Sheet *, gboolean);
Sheet *workbook_focus_current_sheet (Workbook *wb);
void workbook_focus_sheet (Sheet *sheet);
Sheet *workbook_get_current_sheet (Workbook *wb);
char *workbook_sheet_get_free_name (Workbook *wb);
void workbook_auto_expr_label_set (Workbook *wb, const char *text);
void workbook_next_generation (Workbook *wb);
void workbook_set_region_status (Workbook *wb, const char *str);
int workbook_parse_and_jump (Workbook *wb, const char *text);
Sheet *workbook_sheet_lookup (Workbook *wb, const char *sheet_name);
void workbook_mark_clean (Workbook *wb);
void workbook_set_dirty (Workbook *wb, gboolean is_dirty);
gboolean workbook_rename_sheet (Workbook *wb,
const char *old_name,
const char *new_name);
int workbook_sheet_count (Workbook *wb);
gboolean workbook_can_detach_sheet (Workbook *wb, Sheet *sheet);
GList *workbook_sheets (Workbook *wb);
char *workbook_selection_to_string (Workbook *wb, Sheet *base_sheet);
/*
* Does any pending recalculations
*/
void workbook_recalc (Workbook *wb);
void workbook_recalc_all (Workbook *wb);
/*
* Callback routine: invoked when the first view ItemGrid
* is realized to allocate the default styles
*/
void workbook_realized (Workbook *, GdkWindow *);
typedef gboolean (*WorkbookCallback)(Workbook *, gpointer data);
void workbook_foreach (WorkbookCallback cback,
gpointer data);
void workbook_fixup_references (Workbook *wb, Sheet *sheet,
int col, int row,
int coldelta, int rowdelta);
void workbook_invalidate_references (Workbook *wb, Sheet *sheet,
int col, int row,
int colcount, int rowcount);
/*
* Feedback routines
*/
typedef enum {
WORKBOOK_FEEDBACK_BOLD,
WORKBOOK_FEEDBACK_ITALIC
} WorkbookFeedbackType;
void workbook_feedback_set (Workbook *,
WorkbookFeedbackType type,
void *data);
extern Workbook *current_workbook;
/*
* Hooks for CORBA bootstrap: they create the
*/
void workbook_corba_setup (Workbook *);
void workbook_corba_shutdown (Workbook *);
void sheet_corba_setup (Sheet *);
void sheet_corba_shutdown (Sheet *);
#endif /* GNUMERIC_SHEET_H */
......
#ifndef GNUMERIC_WORKBOOK_H
#define GNUMERIC_WORKBOOK_H
#ifdef ENABLE_BONOBO
# include <bonobo/gnome-object.h>
#else
# include <gtk/gtkobject.h>
#endif
#define WORKBOOK_TYPE (workbook_get_type ())
#define WORKBOOK(o) (GTK_CHECK_CAST ((o), WORKBOOK_TYPE, Workbook))
#define WORKBOOK_CLASS(k) (GTK_CHECK_CLASS_CAST((k), WORKBOOK_TYPE, WorkbookClass))
#define IS_WORKBOOK(o) (GTK_CHECK_TYPE ((o), WORKBOOK_TYPE))
#define IS_WORKBOOK_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), WORKBOOK_TYPE))
#ifdef ENABLE_BONOBO
# define WORKBOOK_PARENT_CLASS GnomeObject
# define WORKBOOK_PARENT_CLASS_TYPE GNOME_OBJECT_TYPE
#else
# define WORKBOOK_PARENT_CLASS GtkObject
# define WORKBOOK_PARENT_CLASS_TYPE GTK_OBJECT_TYPE
#endif
/* Forward declaration */
struct _PrintInformation;
typedef struct _PrintInformation PrintInformation;
struct _Workbook {
#ifdef ENABLE_BONOBO
/* The base object for the Workbook */
GnomeObject bonobo_object;
/* A GnomeContainer */
GnomeContainer *gnome_container;
#else
GtkObject gtk_object;
#endif
char *filename;
GtkWidget *toplevel;
GtkWidget *notebook;
GtkWidget *table;
/* Edit area */
GtkWidget *ea_status;
GtkWidget *ea_button_box;
GtkWidget *ea_input;
/* The status bar */
GnomeAppBar * appbar;
/* The auto-expression */
ExprTree *auto_expr;
String *auto_expr_desc;
GnomeCanvasItem *auto_expr_label;
/* Styles */
Style style;
/* The sheets */
GHashTable *sheets; /* keeps a list of the Sheets on this workbook */
/* User defined names */
GList *names;
/* A list with all of the formulas */
GList *formula_cell_list;
/* A queue with the cells to be evaluated */
GList *eval_queue;
int max_iterations;
int generation;
/* The clipboard for this workbook */
CellRegion *clipboard_contents;
gboolean have_x_selection;
/* The Symbol table used for naming cell ranges in the workbook */
SymbolTable *symbol_names;
/* Attached summary information */
SummaryInfo *sin;
/*
* This is used during the clipboard paste command to pass information
* to the asyncronous paste callback
*/
void *clipboard_paste_callback_data;
PrintInformation *print_info;
void *toolbar;
void *corba_server;
};
typedef struct {
#ifdef ENABLE_BONOBO
GnomeObjectClass bonobo_parent_class;
#else
GtkObjectClass gtk_parent_class;
#endif
} WorkbookClass;
GtkType workbook_get_type (void);
Workbook *workbook_new (void);
Workbook *workbook_core_new (void);
Workbook *workbook_new_with_sheets (int sheet_count);
void workbook_set_filename (Workbook *, const char *);
void workbook_set_title (Workbook *, const char *);
Workbook *workbook_read (const char *filename);
void workbook_save_as (Workbook *);
void workbook_save (Workbook *);
void workbook_print (Workbook *);
void workbook_attach_sheet (Workbook *, Sheet *);
gboolean workbook_detach_sheet (Workbook *, Sheet *, gboolean);
Sheet *workbook_focus_current_sheet (Workbook *wb);
void workbook_focus_sheet (Sheet *sheet);
Sheet *workbook_get_current_sheet (Workbook *wb);
char *workbook_sheet_get_free_name (Workbook *wb);
void workbook_auto_expr_label_set (Workbook *wb, const char *text);
void workbook_next_generation (Workbook *wb);
void workbook_set_region_status (Workbook *wb, const char *str);
int workbook_parse_and_jump (Workbook *wb, const char *text);
Sheet *workbook_sheet_lookup (Workbook *wb, const char *sheet_name);
void workbook_mark_clean (Workbook *wb);
void workbook_set_dirty (Workbook *wb, gboolean is_dirty);
gboolean workbook_rename_sheet (Workbook *wb,
const char *old_name,
const char *new_name);
int workbook_sheet_count (Workbook *wb);
gboolean workbook_can_detach_sheet (Workbook *wb, Sheet *sheet);
GList *workbook_sheets (Workbook *wb);
char *workbook_selection_to_string (Workbook *wb, Sheet *base_sheet);
/*
* Does any pending recalculations
*/
void workbook_recalc (Workbook *wb);
void workbook_recalc_all (Workbook *wb);
/*
* Callback routine: invoked when the first view ItemGrid
* is realized to allocate the default styles
*/
void workbook_realized (Workbook *, GdkWindow *);
typedef gboolean (*WorkbookCallback)(Workbook *, gpointer data);
void workbook_foreach (WorkbookCallback cback,
gpointer data);
void workbook_fixup_references (Workbook *wb, Sheet *sheet,
int col, int row,
int coldelta, int rowdelta);
void workbook_invalidate_references (Workbook *wb, Sheet *sheet,
int col, int row,
int colcount, int rowcount);
/*
* Feedback routines
*/
typedef enum {
WORKBOOK_FEEDBACK_BOLD,
WORKBOOK_FEEDBACK_ITALIC
} WorkbookFeedbackType;
void workbook_feedback_set (Workbook *,
WorkbookFeedbackType type,
void *data);
extern Workbook *current_workbook;
/*
* Hooks for CORBA bootstrap: they create the
*/
void workbook_corba_setup (Workbook *);
void workbook_corba_shutdown (Workbook *);
#endif
......@@ -37,6 +37,8 @@ static int workbook_count;
static GList *workbook_list = NULL;
static WORKBOOK_PARENT_CLASS *workbook_parent_class;
static void
new_cmd (void)
{
......@@ -258,8 +260,14 @@ dump_dep (gpointer key, gpointer value, gpointer closure)
static void
workbook_do_destroy (Workbook *wb)
{
/* First do all deletions that leave the workbook in a working
order. */
if (!GTK_OBJECT_DESTROYED (wb->toplevel))
gtk_object_destroy (GTK_OBJECT (wb->toplevel));
/*
* Do all deletions that leave the workbook in a working
* order.
*/
summary_info_free (wb->sin);
wb->sin = NULL;
......@@ -354,16 +362,19 @@ workbook_do_destroy (Workbook *wb)
gtk_main_quit ();
}
void
workbook_destroy (Workbook *wb)
static void
workbook_destroy (GtkObject *wb_object)
{
gtk_widget_destroy (wb->toplevel);
Workbook *wb = WORKBOOK (wb_object);
workbook_do_destroy (wb);
GTK_OBJECT_CLASS (workbook_parent_class)->destroy (wb_object);
}
static void
workbook_widget_destroy (GtkWidget *widget, Workbook *wb)
{
workbook_do_destroy (wb);
gtk_object_unref (GTK_OBJECT (wb));
}
static void
......@@ -475,14 +486,14 @@ static void
close_cmd (GtkWidget *widget, Workbook *wb)
{
if (workbook_can_close (wb))
workbook_destroy (wb);
gtk_object_destroy (GTK_OBJECT (wb));
}
static int
workbook_delete_event (GtkWidget *widget, GdkEvent *event, Workbook *wb)
{
if (workbook_can_close (wb)){
workbook_destroy (wb);
gtk_object_destroy (GTK_OBJECT (wb));
return FALSE;
} else
return TRUE;
......@@ -505,7 +516,7 @@ quit_cmd (void)
Workbook *wb = l->data;
if (workbook_can_close (wb))
workbook_destroy (wb);
gtk_object_destroy (GTK_OBJECT (wb));
}
g_list_free (n);
......@@ -1667,12 +1678,10 @@ workbook_configure_minimized_pixmap (Workbook *wb)
/* FIXME: Use the new function provided by Raster */
}
Workbook *
workbook_core_new (void)
static void
workbook_init (GtkObject *object)
{
Workbook *wb;
wb = g_new0 (Workbook, 1);
Workbook *wb = WORKBOOK (object);
wb->sheets = g_hash_table_new (gnumeric_strcase_hash, gnumeric_strcase_equal);
wb->names = NULL;
......@@ -1701,6 +1710,41 @@ workbook_core_new (void)
return wb;
}
static void
workbook_class_init (GtkObjectClass *object_class)
{
workbook_parent_class = gtk_type_class (WORKBOOK_PARENT_CLASS_TYPE);
object_class->destroy = workbook_destroy;
}
GtkType
workbook_get_type (void)
{
static GtkType type = 0;
if (!type){
GtkTypeInfo info = {
"Workbook",
sizeof (Workbook),
sizeof (WorkbookClass),
(GtkClassInitFunc) workbook_class_init,
(GtkObjectInitFunc) workbook_init,
NULL, /* reserved 1 */
NULL, /* reserved 2 */
(GtkClassInitFunc) NULL
};
#ifdef ENABLE_BONOBO
type = gtk_type_unique (gnome_object_get_type (), &info);
#else
type = gtk_type_unique (gtk_object_get_type (), &info);
#endif