Commit 0e9a694d authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

use NONE__POINTER rather than NONE_OBJECT so that we can remove the


2002-09-17  Jody Goldberg <jody@gnome.org>

	* src/application.c (gnumeric_application_class_init) : use
	  NONE__POINTER rather than NONE_OBJECT so that we can remove the
	  workbook during finalization.
parent 82eb995e
2002-09-17 Jody Goldberg <jody@gnome.org>
* src/application.c (gnumeric_application_class_init) : use
NONE__POINTER rather than NONE_OBJECT so that we can remove the
workbook during finalization.
2002-09-17 Jody Goldberg <jody@gnome.org>
* configure.in : conditionally enable guppi
......
2002-09-17 Jody Goldberg <jody@gnome.org>
* src/application.c (gnumeric_application_class_init) : use
NONE__POINTER rather than NONE_OBJECT so that we can remove the
workbook during finalization.
2002-09-17 Jody Goldberg <jody@gnome.org>
* configure.in : conditionally enable guppi
......
2002-09-17 Jody Goldberg <jody@gnome.org>
* src/application.c (gnumeric_application_class_init) : use
NONE__POINTER rather than NONE_OBJECT so that we can remove the
workbook during finalization.
2002-09-17 Jody Goldberg <jody@gnome.org>
* configure.in : conditionally enable guppi
......
......@@ -58,7 +58,7 @@ AC_ARG_WITH(guppi,
[--{with,without}-guppi ],
if test "x$withval" = xyes; then
try_guppi=true
guppi_msg=$marker_ok
guppi_msg=yes
fi
)
if test "$try_guppi" = "true"; then
......
......@@ -286,8 +286,6 @@ GNUMERIC_BONOBO = \
workbook-control-component.h \
workbook-control-component-priv.h
# $(GNUMERIC_CORBA)
# embeddable-grid.c
# embeddable-grid.h
if WITH_BONOBO
gnumeric_SOURCES = \
......@@ -299,7 +297,6 @@ gnumeric_SOURCES = \
gnumeric_LDADD = \
$(gnumeric_app_libs) \
../idl/libGnumericIDL.a \
$(GNUMERIC_LIBS) \
$(LIBBONOBO_LIBS) \
$(INTLLIBS)
......
......@@ -626,7 +626,7 @@ gnumeric_application_class_init (GObjectClass *object_class)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GnumericApplicationClass, workbook_added),
(GSignalAccumulator) NULL, NULL,
gnm__VOID__OBJECT,
gnm__VOID__POINTER,
G_TYPE_NONE,
1, WORKBOOK_TYPE);
signals [WORKBOOK_REMOVED] = g_signal_new ("workbook_removed",
......@@ -634,7 +634,7 @@ gnumeric_application_class_init (GObjectClass *object_class)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GnumericApplicationClass, workbook_removed),
(GSignalAccumulator) NULL, NULL,
gnm__VOID__OBJECT,
gnm__VOID__POINTER,
G_TYPE_NONE,
1, WORKBOOK_TYPE);
signals [CLIPBOARD_MODIFIED] = g_signal_new ("clipboard_modified",
......
This diff is collapsed.
/*
* corba-workbook-factory.c: CORBA Workbook factory.
*
* If you are looking for a good example of Bonobo use, this is not it.
* please see bonobo/samples/ for a better starting point.
*
* Author:
* Miguel de Icaza (miguel@gnu.org)
*/
#warning re-write me with BonoboObject
#ifdef GNOME2_CONVERSION_COMPLETE
#include <gnumeric-config.h>
#include "gnumeric.h"
#include <idl/Gnumeric.h>
#include "sheet.h"
#include "workbook.h"
#include "corba.h"
#include <bonobo.h>
#include <bonobo/bonobo-object-directory.h>
PortableServer_POA gnumeric_poa;
typedef struct {
POA_GNOME_Gnumeric_WorkbookFactory servant;
PortableServer_POA poa;
} WorkbookFactoryServant;
/* The servant for the workbook factory */
static WorkbookFactoryServant workbook_factory_servant;
/* The workbook factory object */
static GNOME_Gnumeric_WorkbookFactory gnumeric_workbook_factory;
static PortableServer_ServantBase__epv gnumeric_workbook_factory_base_epv;
static POA_GNOME_ObjectFactory__epv gnumeric_wb_object_factory;
static POA_GNOME_Gnumeric_WorkbookFactory__epv gnumeric_wb_factory_epv;
static POA_GNOME_Gnumeric_WorkbookFactory__vepv gnumeric_workbook_factory_vepv;
static GNOME_Gnumeric_Workbook
WorkbookFactory_read (PortableServer_Servant servant, const CORBA_char *filename, CORBA_Environment *ev)
{
WorkbookControl *context;
Workbook *workbook;
context = command_context_corba (NULL);
workbook = workbook_read (context, filename);
gtk_object_unref (GTK_OBJECT (context));
if (workbook)
return CORBA_Object_duplicate (workbook->corba_server, ev);
else
return CORBA_OBJECT_NIL;
}
static CORBA_boolean
WorkbookFactory_manufactures (PortableServer_Servant servant,
const CORBA_char *obj_goad_id,
CORBA_Environment *ev)
{
g_warning ("Request for: %s.", obj_goad_id);
printf ("Getting: %s\n", obj_goad_id);
if (strcmp (obj_goad_id, "IDL:GNOME:Gnumeric:Workbook:1.0") == 0)
return CORBA_TRUE;
else {
if (strcmp (obj_goad_id, "GOAD_ID:GNOME:Gnumeric:Workbook:1.0") == 0)
return CORBA_TRUE;
else
return CORBA_FALSE;
}
}
static CORBA_Object
WorkbookFactory_create_object (PortableServer_Servant servant,
const CORBA_char *activation_id,
const GNOME_stringlist *params,
CORBA_Environment *ev)
{
Workbook *workbook;
if (strcmp (activation_id, "IDL:GNOME:Gnumeric:Workbook:1.0") != 0) {
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
ex_GNOME_ObjectFactory_CannotActivate,
NULL);
return CORBA_OBJECT_NIL;
}
workbook = workbook_new ();
return CORBA_Object_duplicate (workbook->corba_server, ev);
}
/*
* Workbook factory server bootstrap
*/
static GNOME_Gnumeric_WorkbookFactory
GNOME_Gnumeric_WorkbookFactory__create (PortableServer_POA poa, CORBA_Environment *ev)
{
WorkbookFactoryServant *wfs = &workbook_factory_servant;
PortableServer_ObjectId *objid;
/*
* Set up our tables
*/
gnumeric_wb_factory_epv.read = WorkbookFactory_read;
gnumeric_wb_object_factory.manufactures = WorkbookFactory_manufactures;
gnumeric_wb_object_factory.create_object = WorkbookFactory_create_object;
gnumeric_workbook_factory_vepv.GNOME_Gnumeric_WorkbookFactory_epv =
&gnumeric_wb_factory_epv;
gnumeric_workbook_factory_vepv.GNOME_ObjectFactory_epv =
&gnumeric_wb_object_factory;
gnumeric_workbook_factory_vepv._base_epv =
&gnumeric_workbook_factory_base_epv;
wfs->servant.vepv = &gnumeric_workbook_factory_vepv;
POA_GNOME_Gnumeric_WorkbookFactory__init ((PortableServer_Servant) wfs, ev);
objid = PortableServer_POA_activate_object (poa, wfs, ev);
CORBA_free (objid);
return PortableServer_POA_servant_to_reference (poa, wfs, ev);
}
/*
* CORBA services bootstrap
*/
static gboolean
_WorkbookFactory_init (CORBA_Environment *ev)
{
PortableServer_POAManager poa_manager;
CORBA_ORB orb;
int v;
orb = oaf_orb_get ();
/*
* Get the POA and create the server
*/
gnumeric_poa = (PortableServer_POA)
CORBA_ORB_resolve_initial_references (
orb, "RootPOA", ev);
if (ev->_major != CORBA_NO_EXCEPTION)
return FALSE;
poa_manager = PortableServer_POA__get_the_POAManager (gnumeric_poa, ev);
if (ev->_major != CORBA_NO_EXCEPTION)
return FALSE;
PortableServer_POAManager_activate (poa_manager, ev);
if (ev->_major != CORBA_NO_EXCEPTION)
return FALSE;
/*
* Create our workbook factory
*/
gnumeric_workbook_factory = GNOME_Gnumeric_WorkbookFactory__create (gnumeric_poa, ev);
if (ev->_major != CORBA_NO_EXCEPTION)
return FALSE;
/*
* Register the server and see if it was already there
*/
v = bonobo_directory_register_server (gnumeric_workbook_factory,
"OAFIID:GNOME_Gnumeric_WorkbookFactory");
if (v == 0)
return TRUE;
return FALSE;
}
gboolean
WorkbookFactory_init (void)
{
CORBA_Environment ev;
gboolean retval;
CORBA_exception_init (&ev);
retval = _WorkbookFactory_init (&ev);
CORBA_exception_free (&ev);
return retval;
}
#endif
/*
* corba-workbook.c: CORBA Workbook exporting.
*
* Author:
* Miguel de Icaza (miguel@gnu.org)
*/
#include <gnumeric-config.h>
#include "gnumeric.h"
#include <idl/Gnumeric.h>
#include "sheet.h"
#include "workbook.h"
#include "xml-io.h"
#include "corba.h"
#include "commands.h"
#include "command-context-corba.h"
#include "sheet-private.h"
#include <bonobo/bonobo-object.h>
typedef struct {
POA_GNOME_Gnumeric_Workbook servant;
Workbook *workbook;
} WorkbookServant;
static POA_GNOME_Gnumeric_Workbook__vepv gnome_gnumeric_workbook_vepv;
static POA_GNOME_Gnumeric_Workbook__epv gnome_gnumeric_workbook_epv;
static Workbook *
workbook_from_servant (PortableServer_Servant servant)
{
WorkbookServant *ws = (WorkbookServant *) servant;
return ws->workbook;
}
static inline GNOME_Gnumeric_Sheet
corba_sheet (Sheet *sheet, CORBA_Environment *ev)
{
return CORBA_Object_duplicate (sheet->priv->corba_server, ev);
}
static GNOME_Gnumeric_Sheet
Workbook_sheet_new (PortableServer_Servant servant, const CORBA_char *name, CORBA_Environment *ev)
{
Workbook *workbook = workbook_from_servant (servant);
Sheet *sheet;
if (workbook_sheet_by_name (workbook, name)){
CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Gnumeric_Workbook_NameExists, NULL);
return CORBA_OBJECT_NIL;
}
sheet = sheet_new (workbook, name);
workbook_sheet_attach (workbook, sheet, NULL);
return corba_sheet (sheet, ev);
}
static GNOME_Gnumeric_Sheet
Workbook_sheet_lookup (PortableServer_Servant servant, const CORBA_char *name, CORBA_Environment *ev)
{
Workbook *workbook = workbook_from_servant (servant);
Sheet *sheet;
sheet = workbook_sheet_by_name (workbook, name);
if (sheet == NULL)
return CORBA_OBJECT_NIL;
return corba_sheet (sheet, ev);
}
/*
* FIXME: This breaks the link between name, saver and level.
*/
static void
Workbook_set_filename (PortableServer_Servant servant, const CORBA_char *name, CORBA_Environment *ev)
{
Workbook *workbook = workbook_from_servant (servant);
workbook_set_filename (workbook, name);
}
static void
Workbook_save_to (PortableServer_Servant servant, const CORBA_char *filename, CORBA_Environment *ev)
{
Workbook *wb = workbook_from_servant (servant);
/* <FIXME> */
g_warning ("Failure to save will not be noticed");
if (gnumeric_xml_write_workbook (command_context_corba (wb),
wb, filename) == 0)
workbook_set_dirty (wb, FALSE);
else
g_error ("Could not save to file %s", wb->filename);
/* </FIXME> */
}
static GNOME_Gnumeric_Sheet
Workbook_sheet_current (PortableServer_Servant servant, CORBA_Environment * ev)
{
Workbook *wb = workbook_from_servant (servant);
Sheet *sheet = wb->current_sheet;
return corba_sheet (sheet, ev);
}
static GNOME_Gnumeric_Sheet
Workbook_sheet_nth (PortableServer_Servant servant, const CORBA_long n, CORBA_Environment * ev)
{
g_error ("Same stuff!");
return CORBA_OBJECT_NIL;
}
static CORBA_long
Workbook_sheet_count (PortableServer_Servant servant, CORBA_Environment * ev)
{
Workbook *workbook = workbook_from_servant (servant);
return workbook_sheet_count (workbook);
}
static void
Workbook_set_dirty (PortableServer_Servant servant, const CORBA_boolean is_dirty, CORBA_Environment * ev)
{
Workbook *workbook = workbook_from_servant (servant);
workbook_set_dirty (workbook, is_dirty);
}
static CORBA_boolean
Workbook_sheet_rename (PortableServer_Servant servant,
const CORBA_char *old_name,
const CORBA_char *new_name, CORBA_Environment *ev)
{
Workbook *workbook = workbook_from_servant (servant);
return cmd_rename_sheet (command_context_corba (workbook),
workbook, old_name, new_name);
}
static void
Workbook_recalc (PortableServer_Servant servant, CORBA_Environment * ev)
{
Workbook *workbook = workbook_from_servant (servant);
workbook_recalc (workbook);
}
static void
Workbook_recalc_all (PortableServer_Servant servant, CORBA_Environment * ev)
{
Workbook *workbook = workbook_from_servant (servant);
workbook_recalc_all (workbook);
}
static void
Workbook_parse (PortableServer_Servant servant,
const CORBA_char *cellref,
GNOME_Gnumeric_Sheet *sheet,
CORBA_long *col,
CORBA_long *row, CORBA_Environment *ev)
{
}
static void
Workbook_corba_class_init (void)
{
static int inited;
if (inited)
return;
inited = TRUE;
gnome_gnumeric_workbook_vepv.GNOME_Gnumeric_Workbook_epv =
&gnome_gnumeric_workbook_epv;
gnome_gnumeric_workbook_vepv.Bonobo_Unknown_epv =
bonobo_object_get_epv ();
gnome_gnumeric_workbook_epv.sheet_new = Workbook_sheet_new;
gnome_gnumeric_workbook_epv.sheet_lookup = Workbook_sheet_lookup;
gnome_gnumeric_workbook_epv.set_filename = Workbook_set_filename;
gnome_gnumeric_workbook_epv.save_to = Workbook_save_to;
gnome_gnumeric_workbook_epv.sheet_current = Workbook_sheet_current;
gnome_gnumeric_workbook_epv.sheet_nth = Workbook_sheet_nth;
gnome_gnumeric_workbook_epv.sheet_count = Workbook_sheet_count;
gnome_gnumeric_workbook_epv.set_dirty = Workbook_set_dirty;
gnome_gnumeric_workbook_epv.sheet_rename = Workbook_sheet_rename;
gnome_gnumeric_workbook_epv.recalc = Workbook_recalc;
gnome_gnumeric_workbook_epv.recalc_all = Workbook_recalc_all;
gnome_gnumeric_workbook_epv.parse = Workbook_parse;
gnome_gnumeric_workbook_epv.show = Workbook_show;
}
/**
* 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;
Workbook_corba_class_init ();
ws = g_new0 (WorkbookServant, 1);
ws->servant.vepv = &gnome_gnumeric_workbook_vepv;
ws->workbook = workbook;
CORBA_exception_init (&ev);
POA_GNOME_Gnumeric_Workbook__init ((PortableServer_Servant) ws, &ev);
objid = PortableServer_POA_activate_object (gnumeric_poa, ws, &ev);
CORBA_free (objid);
workbook->corba_server = PortableServer_POA_servant_to_reference (gnumeric_poa, ws, &ev);
workbook->priv->corba_context = command_context_corba_new ();
CORBA_exception_free (&ev);
}
void
workbook_corba_shutdown (Workbook *wb)
{
CORBA_Environment ev;
g_return_if_fail (wb != NULL);
g_return_if_fail (wb->corba_server != NULL);
g_warning ("Should release all the corba resources here");
gtk_object_destroy (GTK_OBJECT (wb->priv->corba_context));
CORBA_exception_init (&ev);
PortableServer_POA_deactivate_object (gnumeric_poa, wb->corba_server, &ev);
CORBA_exception_free (&ev);
}
WorkbookControl *
command_context_corba (Workbook *wb)
{
/* When we are operating before a workbook is created
* wb can be NULL
*/
if (!wb)
return command_context_corba_new ();
g_return_val_if_fail (wb->priv && wb->priv->corba_context, NULL);
return wb->priv->corba_context;
}
/*
* embeddable-grid.c: An Embeddable Grid part of Gnumeric
*
* Contains:
* 1. EmbeddableGrid Gtk object implementation.
* 2. CORBA server routines for GNOME::Gnumeric::Grid
* 3. GridView Gtk object implementation
*
* Author:
* Miguel de Icaza (miguel@gnu.org)
*/
#include <gnumeric-config.h>
#include "gnumeric.h"
#include "embeddable-grid.h"
#include "sheet.h"
#include "workbook.h"
#include "sheet-private.h"
#include <bonobo/bonobo-generic-factory.h>
static BonoboGenericFactory *bonobo_embeddable_grid_factory;
static inline EmbeddableGrid *
embeddable_grid_from_servant (PortableServer_Servant servant)
{
return EMBEDDABLE_GRID (bonobo_object_from_servant (servant));
}
static GNOME_Gnumeric_Sheet
Grid_get_sheet (PortableServer_Servant servant, CORBA_Environment *ev)
{
EmbeddableGrid *eg = embeddable_grid_from_servant (servant);
return CORBA_Object_duplicate (eg->sheet->priv->corba_server, ev);
}
static void
Grid_set_header_visibility (PortableServer_Servant servant,
const CORBA_boolean col_headers_visible,
const CORBA_boolean row_headers_visible,
CORBA_Environment *ev)
{
EmbeddableGrid *eg = embeddable_grid_from_servant (servant);
g_return_if_fail (IS_EMBEDDABLE_GRID (eg));
eg->sheet->hide_col_header = !col_headers_visible;
eg->sheet->hide_row_header = !row_headers_visible;
sheet_adjust_preferences (eg->sheet, TRUE, FALSE);
}
static void
Grid_get_header_visibility (PortableServer_Servant servant,
CORBA_boolean *col_headers_visible,
CORBA_boolean *row_headers_visible,
CORBA_Environment *ev)
{
EmbeddableGrid *eg = embeddable_grid_from_servant (servant);
*col_headers_visible = !eg->sheet->hide_col_header;
*row_headers_visible = !eg->sheet->hide_row_header;
}
static BonoboView *
embeddable_grid_view_factory (BonoboEmbeddable *embeddable,
const Bonobo_ViewFrame view_frame,
void *data)
{
BonoboView *view;
EmbeddableGrid *eg = EMBEDDABLE_GRID (embeddable);
view = grid_view_new (eg);
return BONOBO_VIEW (view);
}
static void
embeddable_grid_class_init (EmbeddableGridClass *klass)
{
POA_GNOME_Gnumeric_Grid__epv *epv = &klass->epv;
epv->get_sheet = Grid_get_sheet;
epv->set_header_visibility = Grid_set_header_visibility;
epv->get_header_visibility = Grid_get_header_visibility;
}
static void
embeddable_grid_init_anon (EmbeddableGrid *eg)
{
eg->workbook = workbook_new_with_sheets (1);
eg->sheet = workbook_sheet_by_index (eg->workbook, 0);
}
EmbeddableGrid *
embeddable_grid_new_anon (void)
{
EmbeddableGrid *embeddable_grid;
embeddable_grid = gtk_type_new (EMBEDDABLE_GRID_TYPE);
embeddable_grid_init_anon (embeddable_grid);
bonobo_embeddable_construct (
BONOBO_EMBEDDABLE (embeddable_grid),
embeddable_grid_view_factory, NULL);
return embeddable_grid;
}
EmbeddableGrid *
embeddable_grid_new (Workbook *wb, Sheet *sheet)
{
EmbeddableGrid *embeddable_grid;
embeddable_grid = gtk_type_new (EMBEDDABLE_GRID_TYPE);
embeddable_grid->workbook = wb;
embeddable_grid->sheet = sheet;
/*
* We keep a handle to the Workbook
*/
bonobo_object_ref (BONOBO_OBJECT (embeddable_grid->workbook->priv));
bonobo_embeddable_construct (
BONOBO_EMBEDDABLE (embeddable_grid),
embeddable_grid_view_factory, NULL);
return embeddable_grid;
}
static BonoboObject *
embeddable_grid_factory (BonoboGenericFactory *This, void *data)
{
EmbeddableGrid *embeddable_grid;
embeddable_grid = embeddable_grid_new_anon ();
if (embeddable_grid == NULL) {
g_warning ("Failed to create new embeddable grid");
return NULL;
}
/*
* Populate verb list here.
*/
return BONOBO_OBJECT (embeddable_grid);
}
GType
embeddable_grid_get_type (void)
{
static GType type = 0;
if (!type){
GTypeInfo info = {
"IDL:GNOME/Gnumeric/EmbeddableGrid:1.0",
sizeof (EmbeddableGrid),
sizeof (EmbeddableGridClass),
(GtkClassInitFunc) embeddable_grid_class_init,
NULL,
NULL, /* reserved 1 */
NULL, /* reserved 2 */
(GtkClassInitFunc) NULL
};
type = bonobo_x_type_unique (
bonobo_embeddable_get_type (),
POA_GNOME_Gnumeric_Grid__init, NULL,
GTK_STRUCT_OFFSET (EmbeddableGridClass, epv),
&info);
}