aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--calendar/AUTHORS2
-rw-r--r--calendar/ChangeLog12
-rw-r--r--calendar/cal-client/cal-listener.c119
-rw-r--r--calendar/cal-client/cal-listener.h5
-rw-r--r--calendar/cal-listener.c119
-rw-r--r--calendar/cal-listener.h5
-rw-r--r--calendar/cal.c35
-rw-r--r--calendar/pcs/cal.c35
8 files changed, 241 insertions, 91 deletions
diff --git a/calendar/AUTHORS b/calendar/AUTHORS
index 374733f0e2..7e482aef97 100644
--- a/calendar/AUTHORS
+++ b/calendar/AUTHORS
@@ -1,4 +1,4 @@
Miguel de Icaza <miguel@kernel.org>
-Federico Mena <quartic@gimp.org>
+Federico Mena <federico@helixcode.com>
Arturo Esponosa <arturo@nuclecu.unam.mx>
Russell Steinthal <rms39@columbia.edu>
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 6ba65647f6..21812d4f17 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,17 @@
2000-01-11 Federico Mena Quintero <federico@helixcode.com>
+ * cal.c: Removed the CORBA listener methods, adjusted for the new
+ IDL.
+
+ * cal-listener.c (cal_listener_init): Create the private
+ structure. In it we hold a reference to the calendar the listener
+ is watching.
+ (cal_listener_destroy): Destroy the private structure and unref
+ the calendar.
+ (Listener_cal_loaded): Stuff the calendar into our private data.
+ (Listener_obj_added): Adjusted for new IDL.
+ (Listener_obj_removed): Likewise.
+
* gnome-calendar.idl: New IDL for the personal calendar server.
* cal.h cal.c: New files with the calendar object.
diff --git a/calendar/cal-client/cal-listener.c b/calendar/cal-client/cal-listener.c
index 3c6e3c57f7..581f7eeb6e 100644
--- a/calendar/cal-client/cal-listener.c
+++ b/calendar/cal-client/cal-listener.c
@@ -24,6 +24,14 @@
+/* Private part of the CalListener structure */
+typedef struct {
+ /* The calendar this listener refers to */
+ GNOME_Calendar_Cal cal;
+} CalListenerPrivate;
+
+
+
/* Signal IDs */
enum {
CAL_LOADED,
@@ -34,11 +42,15 @@ enum {
};
static void cal_listener_class_init (CalListenerClass *class);
+static void cal_listener_init (CalListener *listener);
+static void cal_listener_destroy (GtkObject *object);
static POA_GNOME_Calendar_Listener__vepv cal_listener_vepv;
static guint cal_listener_signals[LAST_SIGNAL];
+static GnomeObjectClass *parent_class;
+
/**
@@ -61,7 +73,7 @@ cal_listener_get_type (void)
sizeof (CalListener),
sizeof (CalListenerClass),
(GtkClassInitFunc) cal_listener_class_init,
- (GtkObjectInitFunc) NULL,
+ (GtkObjectInitFunc) cal_listener_init,
NULL, /* reserved_1 */
NULL, /* reserved_2 */
(GtkClassInitFunc) NULL
@@ -89,6 +101,8 @@ cal_listener_class_init (CalListenerClass *class)
object_class = (GtkObjectClass *) class;
+ parent_class = gtk_type_class (gnome_object_get_type ());
+
cal_listener_signals[CAL_LOADED] =
gtk_signal_new ("cal_loaded",
GTK_RUN_FIRST,
@@ -103,34 +117,86 @@ cal_listener_class_init (CalListenerClass *class)
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (CalListenerClass, obj_added),
- gtk_marshal_NONE__POINTER_POINTER,
- GTK_TYPE_NONE, 2,
- GTK_TYPE_POINTER,
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1,
GTK_TYPE_POINTER);
cal_listener_signals[OBJ_REMOVED] =
gtk_signal_new ("obj_removed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (CalListenerClass, obj_removed),
- gtk_marshal_NONE__POINTER_POINTER,
- GTK_TYPE_NONE, 2,
- GTK_TYPE_POINTER,
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1,
GTK_TYPE_POINTER);
cal_listener_signals[OBJ_CHANGED] =
gtk_signal_new ("obj_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (CalListenerClass, obj_changed),
- gtk_marshal_NONE__POINTER_POINTER,
- GTK_TYPE_NONE, 2,
- GTK_TYPE_POINTER,
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1,
GTK_TYPE_POINTER);
gtk_object_class_add_signals (object_class, cal_listener_signals, LAST_SIGNAL);
+ object_class->destroy = cal_listener_destroy;
+
init_cal_listener_corba_class ();
}
+/* Object initialization function for the calendar listener */
+static void
+cal_listener_init (CalListener *listener)
+{
+ CalListenerPrivate *priv;
+
+ priv = g_new0 (CalListenerPrivate, 1);
+ listener->priv = priv;
+
+ priv->cal = CORBA_OBJECT_NIL;
+}
+
+/* Returns whether a CORBA object is nil */
+static gboolean
+corba_object_is_nil (CORBA_Object object)
+{
+ CORBA_Environment ev;
+ gboolean retval;
+
+ CORBA_exception_init (&ev);
+ retval = CORBA_Object_is_nil (object, &ev);
+ CORBA_exception_free (&ev);
+
+ return retval;
+}
+
+/* Destroy handler for the calendar listener */
+static void
+cal_listener_destroy (GtkObject *object)
+{
+ CalListener *listener;
+ CalListenerPrivate *priv;
+ CORBA_Environment ev;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (IS_CAL_LISTENER (object));
+
+ listener = CAL_LISTENER (object);
+ priv = listener->priv;
+
+ CORBA_exception_init (&ev);
+
+ if (!CORBA_Object_is_nil (priv->cal, &ev)) {
+ GNOME_Unknown_unref (priv->cal, &ev);
+ CORBA_Object_release (priv->cal, &ev);
+ }
+
+ g_free (priv);
+
+ if (GTK_OBJECT_CLASS (parent_class)->destroy)
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+}
+
/* CORBA servant implementation */
@@ -143,8 +209,12 @@ Listener_cal_loaded (PortableServer_Servant servant,
CORBA_Environment *ev)
{
CalListener *listener;
+ CalListenerPrivate *priv;
listener = CAL_LISTENER (gnome_object_from_servant (servant));
+ priv = listener->priv;
+
+ priv->cal = CORBA_Object_duplicate (cal, ev);
gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[CAL_LOADED],
cal, calobj);
}
@@ -152,7 +222,6 @@ Listener_cal_loaded (PortableServer_Servant servant,
/* Listener::obj_added method */
static void
Listener_obj_added (PortableServer_Servant servant,
- GNOME_Calendar_Cal cal,
GNOME_Calendar_CalObj calobj,
CORBA_Environment *ev)
{
@@ -160,13 +229,12 @@ Listener_obj_added (PortableServer_Servant servant,
listener = CAL_LISTENER (gnome_object_from_servant (servant));
gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_ADDED],
- cal, calobj);
+ calobj);
}
/* Listener::obj_removed method */
static void
Listener_obj_removed (PortableServer_Servant servant,
- GNOME_Calendar_Cal cal,
GNOME_Calendar_CalObjUID uid,
CORBA_Environment *ev)
{
@@ -174,13 +242,12 @@ Listener_obj_removed (PortableServer_Servant servant,
listener = CAL_LISTENER (gnome_object_from_servant (servant));
gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_REMOVED],
- cal, uid);
+ uid);
}
/* Listener::obj_changed method */
static void
Listener_obj_changed (PortableServer_Servant servant,
- GNOME_Calendar_Cal cal,
GNOME_Calendar_CalObj calobj,
CORBA_Environment *ev)
{
@@ -188,7 +255,7 @@ Listener_obj_changed (PortableServer_Servant servant,
listener = CAL_LISTENER (gnome_object_from_servant (servant));
gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_CHANGED],
- cal, calobj);
+ calobj);
}
/**
@@ -308,3 +375,23 @@ cal_listener_new (void)
return cal_listener_construct (listener, corba_listener);
}
+
+/**
+ * cal_listener_get_calendar:
+ * @listener: A calendar listener.
+ *
+ * Queries the calendar that a listener is watching.
+ *
+ * Return value: The calendar that the listener is watching.
+ **/
+GNOME_Calendar_Cal
+cal_listener_get_calendar (CalListener *listener)
+{
+ CalListenerPrivate *priv;
+
+ g_return_val_if_fail (listener != NULL, CORBA_OBJECT_NIL);
+ g_return_val_if_fail (IS_CAL_LISTENER (listener), CORBA_OBJECT_NIL);
+
+ priv = listener->priv;
+ return priv->cal;
+}
diff --git a/calendar/cal-client/cal-listener.h b/calendar/cal-client/cal-listener.h
index aa502f3fb3..55772cb1ba 100644
--- a/calendar/cal-client/cal-listener.h
+++ b/calendar/cal-client/cal-listener.h
@@ -42,6 +42,9 @@ typedef struct _CalListenerClass CalListenerClass;
struct _CalListener {
GnomeObject object;
+
+ /* Private data */
+ gpointer priv;
};
struct _CalListenerClass {
@@ -61,6 +64,8 @@ GNOME_Calendar_Listener cal_listener_corba_object_create (GnomeObject *object);
CalListener *cal_listener_new (void);
+GNOME_Calendar_Cal cal_listener_get_calendar (CalListener *listener);
+
POA_GNOME_Calendar_Listener__epv *cal_listener_get_epv (void);
diff --git a/calendar/cal-listener.c b/calendar/cal-listener.c
index 3c6e3c57f7..581f7eeb6e 100644
--- a/calendar/cal-listener.c
+++ b/calendar/cal-listener.c
@@ -24,6 +24,14 @@
+/* Private part of the CalListener structure */
+typedef struct {
+ /* The calendar this listener refers to */
+ GNOME_Calendar_Cal cal;
+} CalListenerPrivate;
+
+
+
/* Signal IDs */
enum {
CAL_LOADED,
@@ -34,11 +42,15 @@ enum {
};
static void cal_listener_class_init (CalListenerClass *class);
+static void cal_listener_init (CalListener *listener);
+static void cal_listener_destroy (GtkObject *object);
static POA_GNOME_Calendar_Listener__vepv cal_listener_vepv;
static guint cal_listener_signals[LAST_SIGNAL];
+static GnomeObjectClass *parent_class;
+
/**
@@ -61,7 +73,7 @@ cal_listener_get_type (void)
sizeof (CalListener),
sizeof (CalListenerClass),
(GtkClassInitFunc) cal_listener_class_init,
- (GtkObjectInitFunc) NULL,
+ (GtkObjectInitFunc) cal_listener_init,
NULL, /* reserved_1 */
NULL, /* reserved_2 */
(GtkClassInitFunc) NULL
@@ -89,6 +101,8 @@ cal_listener_class_init (CalListenerClass *class)
object_class = (GtkObjectClass *) class;
+ parent_class = gtk_type_class (gnome_object_get_type ());
+
cal_listener_signals[CAL_LOADED] =
gtk_signal_new ("cal_loaded",
GTK_RUN_FIRST,
@@ -103,34 +117,86 @@ cal_listener_class_init (CalListenerClass *class)
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (CalListenerClass, obj_added),
- gtk_marshal_NONE__POINTER_POINTER,
- GTK_TYPE_NONE, 2,
- GTK_TYPE_POINTER,
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1,
GTK_TYPE_POINTER);
cal_listener_signals[OBJ_REMOVED] =
gtk_signal_new ("obj_removed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (CalListenerClass, obj_removed),
- gtk_marshal_NONE__POINTER_POINTER,
- GTK_TYPE_NONE, 2,
- GTK_TYPE_POINTER,
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1,
GTK_TYPE_POINTER);
cal_listener_signals[OBJ_CHANGED] =
gtk_signal_new ("obj_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (CalListenerClass, obj_changed),
- gtk_marshal_NONE__POINTER_POINTER,
- GTK_TYPE_NONE, 2,
- GTK_TYPE_POINTER,
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1,
GTK_TYPE_POINTER);
gtk_object_class_add_signals (object_class, cal_listener_signals, LAST_SIGNAL);
+ object_class->destroy = cal_listener_destroy;
+
init_cal_listener_corba_class ();
}
+/* Object initialization function for the calendar listener */
+static void
+cal_listener_init (CalListener *listener)
+{
+ CalListenerPrivate *priv;
+
+ priv = g_new0 (CalListenerPrivate, 1);
+ listener->priv = priv;
+
+ priv->cal = CORBA_OBJECT_NIL;
+}
+
+/* Returns whether a CORBA object is nil */
+static gboolean
+corba_object_is_nil (CORBA_Object object)
+{
+ CORBA_Environment ev;
+ gboolean retval;
+
+ CORBA_exception_init (&ev);
+ retval = CORBA_Object_is_nil (object, &ev);
+ CORBA_exception_free (&ev);
+
+ return retval;
+}
+
+/* Destroy handler for the calendar listener */
+static void
+cal_listener_destroy (GtkObject *object)
+{
+ CalListener *listener;
+ CalListenerPrivate *priv;
+ CORBA_Environment ev;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (IS_CAL_LISTENER (object));
+
+ listener = CAL_LISTENER (object);
+ priv = listener->priv;
+
+ CORBA_exception_init (&ev);
+
+ if (!CORBA_Object_is_nil (priv->cal, &ev)) {
+ GNOME_Unknown_unref (priv->cal, &ev);
+ CORBA_Object_release (priv->cal, &ev);
+ }
+
+ g_free (priv);
+
+ if (GTK_OBJECT_CLASS (parent_class)->destroy)
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+}
+
/* CORBA servant implementation */
@@ -143,8 +209,12 @@ Listener_cal_loaded (PortableServer_Servant servant,
CORBA_Environment *ev)
{
CalListener *listener;
+ CalListenerPrivate *priv;
listener = CAL_LISTENER (gnome_object_from_servant (servant));
+ priv = listener->priv;
+
+ priv->cal = CORBA_Object_duplicate (cal, ev);
gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[CAL_LOADED],
cal, calobj);
}
@@ -152,7 +222,6 @@ Listener_cal_loaded (PortableServer_Servant servant,
/* Listener::obj_added method */
static void
Listener_obj_added (PortableServer_Servant servant,
- GNOME_Calendar_Cal cal,
GNOME_Calendar_CalObj calobj,
CORBA_Environment *ev)
{
@@ -160,13 +229,12 @@ Listener_obj_added (PortableServer_Servant servant,
listener = CAL_LISTENER (gnome_object_from_servant (servant));
gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_ADDED],
- cal, calobj);
+ calobj);
}
/* Listener::obj_removed method */
static void
Listener_obj_removed (PortableServer_Servant servant,
- GNOME_Calendar_Cal cal,
GNOME_Calendar_CalObjUID uid,
CORBA_Environment *ev)
{
@@ -174,13 +242,12 @@ Listener_obj_removed (PortableServer_Servant servant,
listener = CAL_LISTENER (gnome_object_from_servant (servant));
gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_REMOVED],
- cal, uid);
+ uid);
}
/* Listener::obj_changed method */
static void
Listener_obj_changed (PortableServer_Servant servant,
- GNOME_Calendar_Cal cal,
GNOME_Calendar_CalObj calobj,
CORBA_Environment *ev)
{
@@ -188,7 +255,7 @@ Listener_obj_changed (PortableServer_Servant servant,
listener = CAL_LISTENER (gnome_object_from_servant (servant));
gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_CHANGED],
- cal, calobj);
+ calobj);
}
/**
@@ -308,3 +375,23 @@ cal_listener_new (void)
return cal_listener_construct (listener, corba_listener);
}
+
+/**
+ * cal_listener_get_calendar:
+ * @listener: A calendar listener.
+ *
+ * Queries the calendar that a listener is watching.
+ *
+ * Return value: The calendar that the listener is watching.
+ **/
+GNOME_Calendar_Cal
+cal_listener_get_calendar (CalListener *listener)
+{
+ CalListenerPrivate *priv;
+
+ g_return_val_if_fail (listener != NULL, CORBA_OBJECT_NIL);
+ g_return_val_if_fail (IS_CAL_LISTENER (listener), CORBA_OBJECT_NIL);
+
+ priv = listener->priv;
+ return priv->cal;
+}
diff --git a/calendar/cal-listener.h b/calendar/cal-listener.h
index aa502f3fb3..55772cb1ba 100644
--- a/calendar/cal-listener.h
+++ b/calendar/cal-listener.h
@@ -42,6 +42,9 @@ typedef struct _CalListenerClass CalListenerClass;
struct _CalListener {
GnomeObject object;
+
+ /* Private data */
+ gpointer priv;
};
struct _CalListenerClass {
@@ -61,6 +64,8 @@ GNOME_Calendar_Listener cal_listener_corba_object_create (GnomeObject *object);
CalListener *cal_listener_new (void);
+GNOME_Calendar_Cal cal_listener_get_calendar (CalListener *listener);
+
POA_GNOME_Calendar_Listener__epv *cal_listener_get_epv (void);
diff --git a/calendar/cal.c b/calendar/cal.c
index 44b9361398..3394ead5d8 100644
--- a/calendar/cal.c
+++ b/calendar/cal.c
@@ -130,8 +130,10 @@ cal_destroy (GtkObject *object)
CORBA_exception_init (&ev);
- for (l = priv->listeners; l; l = l->next)
+ for (l = priv->listeners; l; l = l->next) {
+ GNOME_Unknown_unref (l->data, &ev);
CORBA_Object_release (l->data, &ev);
+ }
g_list_free (priv->listeners);
@@ -160,30 +162,6 @@ Cal_get_uri (PortableServer_Servant servant,
return CORBA_string_dup (priv->uri);
}
-/* Cal::add_listener method */
-static void
-Cal_add_listener (PortableServer_Servant servant,
- GNOME_Calendar_Listener listener,
- CORBA_Environment *ev)
-{
- Cal *cal;
-
- cal = CAL (gnome_object_from_servant (servant));
- cal_add_listener (cal, listener);
-}
-
-/* Cal::remove_listener method */
-static void
-Cal_remove_listener (PortableServer_Servant servant,
- GNOME_Calendar_Listener listener,
- CORBA_Environment *ev)
-{
- Cal *cal;
-
- cal = CAL (gnome_object_from_servant (servant));
- cal_remove_listener (cal, listener);
-}
-
/**
* cal_get_epv:
* @void:
@@ -199,8 +177,6 @@ cal_get_epv (void)
epv = g_new0 (POA_GNOME_Calendar_Cal__epv, 1);
epv->get_uri = Cal_get_uri;
- epv->add_listener = Cal_add_listener;
- epv->remove_listener = Cal_remove_listener;
return epv;
}
@@ -244,10 +220,10 @@ cal_construct (Cal *cal, GNOME_Calendar_Cal corba_cal)
/**
* cal_corba_object_create:
* @object: #GnomeObject that will wrap the CORBA object.
- *
+ *
* Creates and activates the CORBA object that is wrapped by the specified
* calendar @object.
- *
+ *
* Return value: An activated object reference or #CORBA_OBJECT_NIL in case of
* failure.
**/
@@ -334,6 +310,7 @@ cal_remove_listener (Cal *cal, GNOME_Calendar_Listener listener)
for (l = priv->listeners; l; l = l->next)
if (CORBA_Object_is_equivalent (listener, l->data)) {
GNOME_Unknown_unref (listener, &ev);
+ CORBA_Object_release (listener, &ev);
priv->listeners = g_list_remove_link (priv->listeners, l);
g_list_free_1 (l);
break;
diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c
index 44b9361398..3394ead5d8 100644
--- a/calendar/pcs/cal.c
+++ b/calendar/pcs/cal.c
@@ -130,8 +130,10 @@ cal_destroy (GtkObject *object)
CORBA_exception_init (&ev);
- for (l = priv->listeners; l; l = l->next)
+ for (l = priv->listeners; l; l = l->next) {
+ GNOME_Unknown_unref (l->data, &ev);
CORBA_Object_release (l->data, &ev);
+ }
g_list_free (priv->listeners);
@@ -160,30 +162,6 @@ Cal_get_uri (PortableServer_Servant servant,
return CORBA_string_dup (priv->uri);
}
-/* Cal::add_listener method */
-static void
-Cal_add_listener (PortableServer_Servant servant,
- GNOME_Calendar_Listener listener,
- CORBA_Environment *ev)
-{
- Cal *cal;
-
- cal = CAL (gnome_object_from_servant (servant));
- cal_add_listener (cal, listener);
-}
-
-/* Cal::remove_listener method */
-static void
-Cal_remove_listener (PortableServer_Servant servant,
- GNOME_Calendar_Listener listener,
- CORBA_Environment *ev)
-{
- Cal *cal;
-
- cal = CAL (gnome_object_from_servant (servant));
- cal_remove_listener (cal, listener);
-}
-
/**
* cal_get_epv:
* @void:
@@ -199,8 +177,6 @@ cal_get_epv (void)
epv = g_new0 (POA_GNOME_Calendar_Cal__epv, 1);
epv->get_uri = Cal_get_uri;
- epv->add_listener = Cal_add_listener;
- epv->remove_listener = Cal_remove_listener;
return epv;
}
@@ -244,10 +220,10 @@ cal_construct (Cal *cal, GNOME_Calendar_Cal corba_cal)
/**
* cal_corba_object_create:
* @object: #GnomeObject that will wrap the CORBA object.
- *
+ *
* Creates and activates the CORBA object that is wrapped by the specified
* calendar @object.
- *
+ *
* Return value: An activated object reference or #CORBA_OBJECT_NIL in case of
* failure.
**/
@@ -334,6 +310,7 @@ cal_remove_listener (Cal *cal, GNOME_Calendar_Listener listener)
for (l = priv->listeners; l; l = l->next)
if (CORBA_Object_is_equivalent (listener, l->data)) {
GNOME_Unknown_unref (listener, &ev);
+ CORBA_Object_release (listener, &ev);
priv->listeners = g_list_remove_link (priv->listeners, l);
g_list_free_1 (l);
break;