summaryrefslogtreecommitdiff
path: root/libnautilus-private/nautilus-undo-context.c
diff options
context:
space:
mode:
Diffstat (limited to 'libnautilus-private/nautilus-undo-context.c')
-rw-r--r--libnautilus-private/nautilus-undo-context.c101
1 files changed, 42 insertions, 59 deletions
diff --git a/libnautilus-private/nautilus-undo-context.c b/libnautilus-private/nautilus-undo-context.c
index ee5153e8c..f64639e59 100644
--- a/libnautilus-private/nautilus-undo-context.c
+++ b/libnautilus-private/nautilus-undo-context.c
@@ -1,6 +1,7 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* NautilusUndoContext
+/* NautilusUndoContext - Used internally by undo machinery.
+ * Not public.
*
* Copyright (C) 2000 Eazel, Inc.
*
@@ -23,16 +24,11 @@
*/
#include <config.h>
+#include "nautilus-undo-context.h"
+
+#include "nautilus-gtk-macros.h"
#include <gtk/gtksignal.h>
-#include <gtk/gtkmain.h>
#include <bonobo/bonobo-main.h>
-#include <bonobo/bonobo-object.h>
-#include <bonobo/bonobo-control.h>
-#include <libnautilus-extensions/nautilus-gtk-macros.h>
-
-#include "nautilus-undo.h"
-
-#include "nautilus-undo-context.h"
typedef struct {
POA_Nautilus_Undo_Context servant;
@@ -57,7 +53,7 @@ POA_Nautilus_Undo_Context__epv libnautilus_Nautilus_Undo_Context_epv =
};
static PortableServer_ServantBase__epv base_epv;
-static POA_Nautilus_Undo_Context__vepv impl_Nautilus_Undo_Context_vepv =
+static POA_Nautilus_Undo_Context__vepv vepv =
{
&base_epv,
NULL,
@@ -65,54 +61,42 @@ static POA_Nautilus_Undo_Context__vepv impl_Nautilus_Undo_Context_vepv =
};
static void
-impl_Nautilus_Undo_Context__destroy (BonoboObject *obj, impl_POA_Nautilus_Undo_Context *servant)
+impl_Nautilus_Undo_Context__destroy (BonoboObject *object,
+ PortableServer_Servant servant)
{
- PortableServer_ObjectId *objid;
+ PortableServer_ObjectId *object_id;
CORBA_Environment ev;
- void (*servant_destroy_func) (PortableServer_Servant servant, CORBA_Environment *ev);
CORBA_exception_init (&ev);
- servant_destroy_func = NAUTILUS_UNDO_CONTEXT_CLASS
- (GTK_OBJECT (servant->bonobo_object)->klass)->servant_destroy_func;
- objid = PortableServer_POA_servant_to_id (bonobo_poa (), servant, &ev);
- PortableServer_POA_deactivate_object (bonobo_poa (), objid, &ev);
- CORBA_free (objid);
- obj->servant = NULL;
-
- (* servant_destroy_func) ((PortableServer_Servant) servant, &ev);
+ object_id = PortableServer_POA_servant_to_id (bonobo_poa (), servant, &ev);
+ PortableServer_POA_deactivate_object (bonobo_poa (), object_id, &ev);
+ CORBA_free (object_id);
+ object->servant = NULL;
+ POA_Nautilus_Undo_Context__fini (servant, &ev);
g_free (servant);
+
CORBA_exception_free (&ev);
}
static Nautilus_Undo_Context
-impl_Nautilus_Undo_Context__create (NautilusUndoContext *context, CORBA_Environment * ev)
+impl_Nautilus_Undo_Context__create (NautilusUndoContext *bonobo_object,
+ CORBA_Environment *ev)
{
- Nautilus_Undo_Context retval;
impl_POA_Nautilus_Undo_Context *servant;
- void (*servant_init_func) (PortableServer_Servant servant, CORBA_Environment *ev);
- NautilusUndoContextClass *context_class;
- context_class = NAUTILUS_UNDO_CONTEXT_CLASS (GTK_OBJECT (context)->klass);
-
- servant_init_func = context_class->servant_init_func;
servant = g_new0 (impl_POA_Nautilus_Undo_Context, 1);
- servant->servant.vepv = context_class->vepv;
- if (servant->servant.vepv->Bonobo_Unknown_epv == NULL) {
- servant->servant.vepv->Bonobo_Unknown_epv = bonobo_object_get_epv ();
- }
- (* servant_init_func) ((PortableServer_Servant) servant, ev);
-
- servant->bonobo_object = context;
+ servant->servant.vepv = &vepv;
+ vepv.Bonobo_Unknown_epv = bonobo_object_get_epv ();
+ POA_Nautilus_Undo_Context__init ((PortableServer_Servant) servant, ev);
- retval = bonobo_object_activate_servant (BONOBO_OBJECT (context), servant);
-
- gtk_signal_connect (GTK_OBJECT (context), "destroy",
+ gtk_signal_connect (GTK_OBJECT (bonobo_object), "destroy",
GTK_SIGNAL_FUNC (impl_Nautilus_Undo_Context__destroy),
servant);
- return retval;
+ servant->bonobo_object = bonobo_object;
+ return bonobo_object_activate_servant (BONOBO_OBJECT (bonobo_object), servant);
}
static Nautilus_Undo_Manager
@@ -122,23 +106,26 @@ impl_Nautilus_Undo_Context__get_undo_manager (PortableServer_Servant servant,
NautilusUndoContext *context;
context = ((impl_POA_Nautilus_Undo_Context *) servant)->bonobo_object;
-
g_assert (NAUTILUS_IS_UNDO_CONTEXT (context));
return CORBA_Object_duplicate (context->undo_manager, ev);
}
-/* nautilus_undo_manager_new */
NautilusUndoContext *
nautilus_undo_context_new (Nautilus_Undo_Manager undo_manager)
{
+ CORBA_Environment ev;
NautilusUndoContext *context;
+ CORBA_exception_init (&ev);
+
context = gtk_type_new (nautilus_undo_context_get_type ());
- context->undo_manager = undo_manager;
+ context->undo_manager = CORBA_Object_duplicate (undo_manager, &ev);
+
+ CORBA_exception_free (&ev);
+
return context;
}
-/* Object initialization function for the NautilusUndoContext */
static void
nautilus_undo_context_initialize (NautilusUndoContext *context)
{
@@ -152,28 +139,24 @@ nautilus_undo_context_initialize (NautilusUndoContext *context)
CORBA_exception_free (&ev);
}
-/* Class initialization function for the NautilusUndoManager. */
static void
-nautilus_undo_context_initialize_class (NautilusUndoContextClass *klass)
+destroy (GtkObject *object)
{
- GtkObjectClass *object_class;
-
- object_class = GTK_OBJECT_CLASS (klass);
+ CORBA_Environment ev;
+ NautilusUndoContext *context;
- object_class->destroy = destroy;
+ CORBA_exception_init (&ev);
- klass->servant_init_func = POA_Nautilus_Undo_Context__init;
- klass->servant_destroy_func = POA_Nautilus_Undo_Context__fini;
- klass->vepv = &impl_Nautilus_Undo_Context_vepv;
+ context = NAUTILUS_UNDO_CONTEXT (object);
+ CORBA_Object_release (context->undo_manager, &ev);
+
+ CORBA_exception_free (&ev);
+
+ NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
}
-/* destroy */
static void
-destroy (GtkObject *object)
+nautilus_undo_context_initialize_class (NautilusUndoContextClass *klass)
{
- NautilusUndoContext *context;
-
- context = NAUTILUS_UNDO_CONTEXT (object);
-
- NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
+ GTK_OBJECT_CLASS (klass)->destroy = destroy;
}