Commit a910f071 authored by Michael Meeks's avatar Michael Meeks Committed by Michael Meeks

re-hash to use BonoboObject.

2002-09-20  Michael Meeks  <michael@ximian.com>

        * corba-sheet.c: re-hash to use BonoboObject.
parent 71e89ad7
2002-09-20 Michael Meeks <michael@ximian.com>
* corba-sheet.c: re-hash to use BonoboObject.
2002-09-19 Jody Goldberg <jody@gnome.org>
* corba-application.c : move init into a 'general' service so that
......
......@@ -9,6 +9,7 @@ gnumeric_plugin_corba_LTLIBRARIES = corba.la
corba_la_LDFLAGS = -module -avoid-version
corba_la_SOURCES = $(GNUMERIC_GENERATED) \
corba-application.c \
corba-application.h \
corba-workbook.c \
corba-workbook.h \
corba-sheet.c
......
......@@ -32,36 +32,18 @@
#include <gsf/gsf-impl-utils.h>
#include <bonobo.h>
typedef struct {
SheetControl base;
BONOBO_TYPE_FUNC_FULL (SheetControl,
GNOME_Gnumeric_Sheet,
BONOBO_OBJECT_TYPE,
csheet);
POA_GNOME_Gnumeric_Sheet servant;
gboolean initialized, activated;
CORBA_Object corba_obj; /* local CORBA object */
CORBA_Environment *ev; /* exception from the caller */
} SheetControlCORBA;
typedef struct {
SheetControlClass base;
} SheetControlCORBAClass;
static SheetControlCORBA *
scc_from_servant (PortableServer_Servant serv)
{
SheetControlCORBA *scc = (SheetControlCORBA *)(((char *)serv) - G_STRUCT_OFFSET (SheetControlCORBA, servant));
g_return_val_if_fail (IS_SHEET_CONTROL (scc), NULL);
return scc;
}
#define SERVANT_TO_SC(s) (SHEET_CONTROL (bonobo_object (s)))
static CORBA_string
csheet_get_name (PortableServer_Servant servant,
CORBA_Environment *ev)
{
SheetControlCORBA *scc = scc_from_servant (servant);
Sheet *sheet = sc_sheet (SHEET_CONTROL (scc));
Sheet *sheet = sc_sheet (SERVANT_TO_SC (servant));
return CORBA_string_dup (sheet->name_unquoted);
}
......@@ -69,8 +51,7 @@ static void
csheet_set_name (PortableServer_Servant servant, CORBA_char const * value,
CORBA_Environment *ev)
{
SheetControlCORBA *scc = scc_from_servant (servant);
Sheet *sheet = sc_sheet (SHEET_CONTROL (scc));
Sheet *sheet = sc_sheet (SERVANT_TO_SC (servant));
/* DO NOT CALL sheet_rename that is too low level */
}
......@@ -79,110 +60,53 @@ static CORBA_short
csheet_get_index (PortableServer_Servant servant,
CORBA_Environment *ev)
{
SheetControlCORBA *scc = scc_from_servant (servant);
Sheet *sheet = sc_sheet (SHEET_CONTROL (scc));
Sheet *sheet = sc_sheet (SERVANT_TO_SC (servant));
return sheet->index_in_wb;
}
static void
csheet_set_index (PortableServer_Servant servant, CORBA_short indx,
csheet_set_index (PortableServer_Servant servant,
CORBA_short indx,
CORBA_Environment *ev)
{
SheetControlCORBA *scc = scc_from_servant (servant);
Sheet *sheet = sc_sheet (SHEET_CONTROL (scc));
Sheet *sheet = sc_sheet (SERVANT_TO_SC (servant));
/* FIXME: do something */
}
static POA_GNOME_Gnumeric_Sheet__vepv sheet_vepv;
static POA_GNOME_Gnumeric_Sheet__epv sheet_epv;
static void
scc_finalize (GObject *obj)
csheet_dispose (SheetControl *sc)
{
GObjectClass *parent_class;
CORBA_Environment ev;
SheetControlCORBA *scc = SHEET_CONTROL_CORBA (obj);
CORBA_exception_init (&ev);
if (scc->activated) {
PortableServer_POA poa = bonobo_poa ();
PortableServer_ObjectId *oid = PortableServer_POA_servant_to_id (poa,
&scc->servant, &ev);
PortableServer_POA_deactivate_object (poa, oid, &ev);
scc->activated = FALSE;
CORBA_free (oid);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("unexpected exception while finalizing");
}
if (sc->view) {
SheetView *v = sc->view;
sc->view = NULL;
g_object_unref (v);
}
if (scc->initialized) {
POA_GNOME_Gnumeric_Sheet__fini (&scc->servant, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("unexpected exception while finalizing");
}
scc->initialized = FALSE;
}
CORBA_exception_free (&ev);
parent_class = g_type_class_peek (SHEET_CONTROL_TYPE);
if (parent_class->finalize)
parent_class->finalize (obj);
}
static void
scc_class_init (GObjectClass *object_class)
csheet_instance_init (SheetControl *sc)
{
object_class->finalize = &scc_finalize;
sheet_vepv.GNOME_Gnumeric_Sheet_epv = &sheet_epv;
sheet_epv._get_name = csheet_get_name;
sheet_epv._set_name = csheet_set_name;
sheet_epv._get_index = csheet_get_index;
sheet_epv._set_index = csheet_set_index;
}
static void
scc_init (SheetControlCORBA *scc)
csheet_class_init (SheetControlClass *sc_class)
{
CORBA_Environment ev;
scc->initialized = FALSE;
scc->activated = FALSE;
CORBA_exception_init (&ev);
scc->servant.vepv = &sheet_vepv;
POA_GNOME_Gnumeric_Sheet__init (&scc->servant, &ev);
if (ev._major == CORBA_NO_EXCEPTION) {
PortableServer_ObjectId *oid;
PortableServer_POA poa = bonobo_poa ();
scc->initialized = TRUE;
oid = PortableServer_POA_activate_object (poa,
&scc->servant, &ev);
scc->activated = (ev._major == CORBA_NO_EXCEPTION);
scc->corba_obj = PortableServer_POA_servant_to_reference (poa,
&scc->servant, &ev);
CORBA_free (oid);
} else {
g_warning ("'%s' : while creating a corba control",
bonobo_exception_get_text (&ev));
}
CORBA_exception_free (&ev);
}
GObjectClass *gobject_class = (GObjectClass *) sc_class;
GSF_CLASS (SheetControlCORBA, sheet_control_corba,
scc_class_init, scc_init, SHEET_CONTROL_TYPE);
gobject_class->dispose = csheet_dispose;
/* populate CORBA epv */
sc_class->epv._get_name = csheet_get_name;
sc_class->epv._set_name = csheet_set_name;
sc_class->epv._get_index = csheet_get_index;
sc_class->epv._set_index = csheet_set_index;
}
SheetControl *
sheet_control_corba_new (SheetView *sv)
{
SheetControl *sc =
g_object_new (sheet_control_corba_get_type (), NULL);
sv_attach_control (sv, SHEET_CONTROL (sc));
sc->view = g_object_ref (sv);
return sc;
}
......@@ -3,11 +3,33 @@
#include "sheet-control.h"
#define SHEET_CONTROL_CORBA_TYPE (sheet_control_corba_get_type ())
#define SHEET_CONTROL_CORBA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SHEET_CONTROL_CORBA_TYPE, SheetControlCORBA))
#define IS_SHEET_CONTROL_CORBA(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SHEET_CONTROL_CORBA_TYPE))
GType sheet_control_corba_get_type (void);
SheetControl *sheet_control_corba_new (SheetView *view);
#define SHEET_TYPE_CONTROL (sheet_control_get_type ())
#define SHEET_CONTROL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SHEET_TYPE_CONTROL, SheetControl))
#define SHEET_CONTROL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SHEET_TYPE_CONTROL, SheetControlClass))
#define SHEET_IS_CONTROL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SHEET_TYPE_CONTROL))
#define SHEET_IS_CONTROL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SHEET_TYPE_CONTROL))
typedef struct _SheetControlPrivate SheetControlPrivate;
struct _SheetControl {
BonoboObject base;
/*
* Of course, proxy objects are a painful pile of
* typing, but then using CORBA types internally is
* perhaps harder ?
*/
SheetView *view;
};
typedef struct {
BonoboObjectClass parent_class;
POA_GNOME_Gnumeric_Sheet__epv epv;
} SheetControlClass;
GType sheet_control_corba_get_type (void);
SheetControl *sheet_control_corba_new (SheetView *view);
#endif /* GNUMERIC_SHEET_CONTROL_CORBA_H */
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