aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--shell/ChangeLog22
-rw-r--r--shell/Evolution-ConfigControl.idl3
-rw-r--r--shell/Makefile.am2
-rw-r--r--shell/e-corba-config-page.c54
-rw-r--r--shell/e-corba-config-page.h8
-rw-r--r--shell/evolution-config-control.c222
-rw-r--r--shell/evolution-config-control.h70
-rw-r--r--shell/evolution-test-component.c3
8 files changed, 362 insertions, 22 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index a911c7716b..68fa649e76 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,25 @@
+2002-03-12 Ettore Perazzoli <ettore@ximian.com>
+
+ * evolution-test-component.c (create_configuration_page): Update
+ to create an EvolutionConfigControl instead of just a
+ BonoboControl.
+
+ * e-corba-config-page.c (e_corba_config_page_construct): Get a
+ GNOME_Evolution_ConfigControl instead of a CORBA_Object. Retrieve
+ the control from it using ::_get_control instead of just assuming
+ it's a control. Also return a boolen indicating success or
+ failure.
+ (e_corba_config_page_new): Likewise, get a
+ GNOME_Evolution_ConfigControl.
+ (setup_listener): Renamed from `setup_config_control_interface'.
+ Get a ::ConfigControl instead of a CORBA::Object. Thus, no need
+ to queryInterface here anymore.
+
+ * evolution-config-control.c, evolution-config-control.h: New,
+ implementation for the Evolution::ConfigControl interface.
+
+ * Evolution-ConfigControl.idl: New attribute `control'.
+
2002-03-09 Ettore Perazzoli <ettore@ximian.com>
* e-shell-folder-commands.c (e_shell_command_rename_folder): Make
diff --git a/shell/Evolution-ConfigControl.idl b/shell/Evolution-ConfigControl.idl
index d6b080d29c..059ed6b286 100644
--- a/shell/Evolution-ConfigControl.idl
+++ b/shell/Evolution-ConfigControl.idl
@@ -14,6 +14,9 @@ module Evolution {
/* Apply the current settings. */
void apply ();
+ /* The actual Control. */
+ readonly attribute Bonobo::Control control;
+
/* Get the event source for this control. */
readonly attribute Bonobo::EventSource eventSource;
diff --git a/shell/Makefile.am b/shell/Makefile.am
index be375a8736..31cb6321e5 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -78,6 +78,8 @@ libeshell_la_SOURCES = \
e-shell-corba-icon-utils.c \
e-shell-corba-icon-utils.h \
evolution-activity-client.c \
+ evolution-config-control.c \
+ evolution-config-control.h \
evolution-session.c \
evolution-shell-client.c \
evolution-shell-component-client.c \
diff --git a/shell/e-corba-config-page.c b/shell/e-corba-config-page.c
index 85ad38668c..f9b49bcdab 100644
--- a/shell/e-corba-config-page.c
+++ b/shell/e-corba-config-page.c
@@ -32,6 +32,7 @@
#include <bonobo/bonobo-widget.h>
#include <bonobo/bonobo-exception.h>
+#include <bonobo/bonobo-object.h>
#include <bonobo/bonobo-listener.h>
@@ -66,11 +67,10 @@ listener_event_callback (BonoboListener *listener,
}
static void
-setup_config_control_interface (ECorbaConfigPage *corba_config_page,
- CORBA_Object corba_object)
+setup_listener (ECorbaConfigPage *corba_config_page,
+ GNOME_Evolution_ConfigControl config_control_interface)
{
ECorbaConfigPagePrivate *priv;
- GNOME_Evolution_ConfigControl config_control_interface;
Bonobo_EventSource event_source;
CORBA_Environment ev;
@@ -78,14 +78,10 @@ setup_config_control_interface (ECorbaConfigPage *corba_config_page,
CORBA_exception_init (&ev);
- config_control_interface = Bonobo_Unknown_queryInterface (corba_object, "IDL:GNOME/Evolution/ConfigControl:1.0", &ev);
- if (BONOBO_EX (&ev) || config_control_interface == CORBA_OBJECT_NIL) {
- CORBA_exception_free (&ev);
- return;
- }
-
event_source = GNOME_Evolution_ConfigControl__get_eventSource (config_control_interface, &ev);
- if (!BONOBO_EX (&ev)) {
+ if (BONOBO_EX (&ev)) {
+ g_warning ("Cannot get eventSource interface for ConfigPage -- %s", BONOBO_EX_ID (&ev));
+ } else {
priv->listener = bonobo_listener_new (listener_event_callback, corba_config_page);
priv->listener_id = Bonobo_EventSource_addListener (event_source,
bonobo_object_corba_objref (BONOBO_OBJECT (priv->listener)),
@@ -197,24 +193,43 @@ init (ECorbaConfigPage *corba_config_page)
}
-void
+gboolean
e_corba_config_page_construct (ECorbaConfigPage *corba_config_page,
- CORBA_Object corba_object)
+ GNOME_Evolution_ConfigControl corba_object)
{
+ Bonobo_Control control;
GtkWidget *control_widget;
+ CORBA_Environment ev;
+
+ g_return_val_if_fail (E_IS_CORBA_CONFIG_PAGE (corba_config_page), FALSE);
+ g_return_val_if_fail (corba_object != CORBA_OBJECT_NIL, FALSE);
- g_return_if_fail (E_IS_CORBA_CONFIG_PAGE (corba_config_page));
- g_return_if_fail (corba_object != CORBA_OBJECT_NIL);
+ CORBA_exception_init (&ev);
- control_widget = bonobo_widget_new_control_from_objref (corba_object, CORBA_OBJECT_NIL);
+ control = GNOME_Evolution_ConfigControl__get_control (corba_object, &ev);
+ if (BONOBO_EX (&ev)) {
+ g_warning ("Can't get control from ::ConfigControl -- %s", BONOBO_EX_ID (&ev));
+ CORBA_exception_init (&ev);
+ return FALSE;
+ }
+
+ control_widget = bonobo_widget_new_control_from_objref (control, CORBA_OBJECT_NIL);
gtk_widget_show (control_widget);
gtk_container_add (GTK_CONTAINER (corba_config_page), control_widget);
- setup_config_control_interface (corba_config_page, corba_object);
+ setup_listener (corba_config_page, corba_object);
+
+ /* Notice we *don't* unref the corba_object here as
+ bonobo_widget_new_control_from_objref() effectively takes ownership
+ for the object that we get from ::__get_control. */
+
+ CORBA_exception_free (&ev);
+
+ return TRUE;
}
GtkWidget *
-e_corba_config_page_new_from_objref (CORBA_Object corba_object)
+e_corba_config_page_new_from_objref (GNOME_Evolution_ConfigControl corba_object)
{
ECorbaConfigPage *corba_config_page;
@@ -222,7 +237,10 @@ e_corba_config_page_new_from_objref (CORBA_Object corba_object)
g_return_val_if_fail (corba_object != CORBA_OBJECT_NIL, NULL);
corba_config_page = gtk_type_new (e_corba_config_page_get_type ());
- e_corba_config_page_construct (corba_config_page, corba_object);
+ if (! e_corba_config_page_construct (corba_config_page, corba_object)) {
+ gtk_widget_destroy (GTK_WIDGET (corba_config_page));
+ return NULL;
+ }
return GTK_WIDGET (corba_config_page);
}
diff --git a/shell/e-corba-config-page.h b/shell/e-corba-config-page.h
index a0e050baad..c50334899d 100644
--- a/shell/e-corba-config-page.h
+++ b/shell/e-corba-config-page.h
@@ -29,6 +29,8 @@
#include "e-config-page.h"
+#include "Evolution.h"
+
#include <bonobo/bonobo-object.h>
#ifdef __cplusplus
@@ -59,9 +61,9 @@ struct _ECorbaConfigPageClass {
GtkType e_corba_config_page_get_type (void);
-GtkWidget *e_corba_config_page_new_from_objref (CORBA_Object objref);
-void e_corba_config_page_construct (ECorbaConfigPage *corba_config_page,
- CORBA_Object corba_object);
+GtkWidget *e_corba_config_page_new_from_objref (GNOME_Evolution_ConfigControl objref);
+gboolean e_corba_config_page_construct (ECorbaConfigPage *corba_config_page,
+ GNOME_Evolution_ConfigControl objref);
#ifdef __cplusplus
}
diff --git a/shell/evolution-config-control.c b/shell/evolution-config-control.c
new file mode 100644
index 0000000000..c5c4bba09a
--- /dev/null
+++ b/shell/evolution-config-control.c
@@ -0,0 +1,222 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* evolution-config-control.c
+ *
+ * Copyright (C) 2002 Ximian, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Ettore Perazzoli
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "evolution-config-control.h"
+
+#include <gal/util/e-util.h>
+
+#include <gtk/gtksignal.h>
+
+#include <bonobo/bonobo-control.h>
+#include <bonobo/bonobo-event-source.h>
+
+
+#define PARENT_TYPE BONOBO_X_OBJECT_TYPE
+static BonoboXObjectClass *parent_class = NULL;
+
+struct _EvolutionConfigControlPrivate {
+ gboolean changed;
+ BonoboControl *control;
+ BonoboEventSource *event_source;
+};
+
+enum {
+ APPLY,
+ LAST_SIGNAL
+};
+static int signals[LAST_SIGNAL] = { 0 };
+
+
+/* GtkObject methods. */
+
+static void
+impl_destroy (GtkObject *object)
+{
+ EvolutionConfigControl *config_control;
+ EvolutionConfigControlPrivate *priv;
+
+ config_control = EVOLUTION_CONFIG_CONTROL (object);
+ priv = config_control->priv;
+
+ if (priv != NULL) {
+ bonobo_object_unref (BONOBO_OBJECT (priv->control));
+ bonobo_object_unref (BONOBO_OBJECT (priv->event_source));
+
+ g_free (priv);
+ config_control->priv = NULL;
+ }
+
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+}
+
+
+/* Evolution::ConfigControl CORBA methods. */
+
+static void
+impl_apply (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ EvolutionConfigControl *config_control;
+ EvolutionConfigControlPrivate *priv;
+
+ config_control = EVOLUTION_CONFIG_CONTROL (bonobo_object_from_servant (servant));
+ priv = config_control->priv;
+
+ gtk_signal_emit (GTK_OBJECT (config_control), signals[APPLY]);
+
+ priv->changed = FALSE;
+}
+
+static Bonobo_Control
+impl__get_control (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ EvolutionConfigControl *config_control;
+ EvolutionConfigControlPrivate *priv;
+
+ config_control = EVOLUTION_CONFIG_CONTROL (bonobo_object_from_servant (servant));
+ priv = config_control->priv;
+
+ bonobo_object_ref (BONOBO_OBJECT (priv->control));
+
+ return CORBA_Object_duplicate (bonobo_object_corba_objref (BONOBO_OBJECT (priv->control)), ev);
+}
+
+static Bonobo_EventSource
+impl__get_eventSource (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ EvolutionConfigControl *config_control;
+ EvolutionConfigControlPrivate *priv;
+
+ config_control = EVOLUTION_CONFIG_CONTROL (bonobo_object_from_servant (servant));
+ priv = config_control->priv;
+
+ bonobo_object_ref (BONOBO_OBJECT (priv->event_source));
+
+ return CORBA_Object_duplicate (bonobo_object_corba_objref (BONOBO_OBJECT (priv->event_source)), ev);
+}
+
+
+static void
+class_init (EvolutionConfigControlClass *class)
+{
+ POA_GNOME_Evolution_ConfigControl__epv *epv;
+ GtkObjectClass *object_class;
+
+ object_class = GTK_OBJECT_CLASS (class);
+ object_class->destroy = impl_destroy;
+
+ epv = &class->epv;
+ epv->apply = impl_apply;
+ epv->_get_control = impl__get_control;
+ epv->_get_eventSource = impl__get_eventSource;
+
+ signals[APPLY] = gtk_signal_new ("apply", GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EvolutionConfigControlClass, apply),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+
+ gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
+
+ parent_class = gtk_type_class (PARENT_TYPE);
+}
+
+static void
+init (EvolutionConfigControl *config_control)
+{
+ EvolutionConfigControlPrivate *priv;
+
+ priv = g_new (EvolutionConfigControlPrivate, 1);
+ priv->changed = FALSE;
+ priv->control = NULL;
+ priv->event_source = bonobo_event_source_new ();
+
+ config_control->priv = priv;
+}
+
+
+void
+evolution_config_control_construct (EvolutionConfigControl *control,
+ GtkWidget *widget)
+{
+ EvolutionConfigControlPrivate *priv;
+
+ g_return_if_fail (EVOLUTION_IS_CONFIG_CONTROL (control));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ priv = control->priv;
+
+ priv->control = bonobo_control_new (widget);
+}
+
+EvolutionConfigControl *
+evolution_config_control_new (GtkWidget *widget)
+{
+ EvolutionConfigControl *new;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+ new = gtk_type_new (evolution_config_control_get_type ());
+ evolution_config_control_construct (new, widget);
+
+ return new;
+}
+
+void
+evolution_config_control_changed (EvolutionConfigControl *config_control)
+{
+ EvolutionConfigControlPrivate *priv;
+ CORBA_Environment ev;
+ CORBA_any *null_value;
+
+ g_return_if_fail (EVOLUTION_IS_CONFIG_CONTROL (config_control));
+
+ priv = config_control->priv;
+
+ if (priv->changed)
+ return;
+
+ priv->changed = TRUE;
+
+ CORBA_exception_init (&ev);
+
+ null_value = CORBA_any__alloc ();
+ null_value->_type = TC_null;
+
+ bonobo_event_source_notify_listeners (priv->event_source, "changed", null_value, &ev);
+
+ CORBA_free (null_value);
+
+ CORBA_exception_free (&ev);
+}
+
+
+E_MAKE_X_TYPE (evolution_config_control, "EvolutionConfigControl", EvolutionConfigControl,
+ class_init, init, PARENT_TYPE,
+ POA_GNOME_Evolution_ConfigControl__init,
+ GTK_STRUCT_OFFSET (EvolutionConfigControlClass, epv))
diff --git a/shell/evolution-config-control.h b/shell/evolution-config-control.h
new file mode 100644
index 0000000000..9048297b5b
--- /dev/null
+++ b/shell/evolution-config-control.h
@@ -0,0 +1,70 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* evolution-config-control.h
+ *
+ * Copyright (C) 2002 Ximian, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Ettore Perazzoli
+ */
+
+#ifndef EVOLUTION_CONFIG_CONTROL_H
+#define EVOLUTION_CONFIG_CONTROL_H
+
+#include "Evolution.h"
+
+#include <bonobo/bonobo-xobject.h>
+#include <gtk/gtkwidget.h>
+
+#ifdef cplusplus
+extern "C" {
+#pragma }
+#endif /* cplusplus */
+
+#define EVOLUTION_TYPE_CONFIG_CONTROL (evolution_config_control_get_type ())
+#define EVOLUTION_CONFIG_CONTROL(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_TYPE_CONFIG_CONTROL, EvolutionConfigControl))
+#define EVOLUTION_CONFIG_CONTROL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_CONFIG_CONTROL, EvolutionConfigControlClass))
+#define EVOLUTION_IS_CONFIG_CONTROL(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_TYPE_CONFIG_CONTROL))
+#define EVOLUTION_IS_CONFIG_CONTROL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_CONFIG_CONTROL))
+
+typedef struct _EvolutionConfigControl EvolutionConfigControl;
+typedef struct _EvolutionConfigControlPrivate EvolutionConfigControlPrivate;
+typedef struct _EvolutionConfigControlClass EvolutionConfigControlClass;
+
+struct _EvolutionConfigControl {
+ BonoboXObject parent;
+
+ EvolutionConfigControlPrivate *priv;
+};
+
+struct _EvolutionConfigControlClass {
+ BonoboXObjectClass parent_class;
+
+ POA_GNOME_Evolution_ConfigControl__epv epv;
+
+ /* Signals. */
+
+ void (* apply) (EvolutionConfigControl *control);
+};
+
+
+GtkType evolution_config_control_get_type (void);
+EvolutionConfigControl *evolution_config_control_new (GtkWidget *widget);
+void evolution_config_control_construct (EvolutionConfigControl *control,
+ GtkWidget *widget);
+
+void evolution_config_control_changed (EvolutionConfigControl *config_control);
+
+#endif /* EVOLUTION_CONFIG_CONTROL_H */
diff --git a/shell/evolution-test-component.c b/shell/evolution-test-component.c
index 916bf3c8f7..71b41d7627 100644
--- a/shell/evolution-test-component.c
+++ b/shell/evolution-test-component.c
@@ -28,6 +28,7 @@
#include "evolution-shell-component.h"
#include "evolution-activity-client.h"
+#include "evolution-config-control.h"
#include <bonobo/bonobo-generic-factory.h>
#include <bonobo/bonobo-main.h>
@@ -63,7 +64,7 @@ create_configuration_page (void)
label = gtk_label_new ("This is the configuration page for the test component.");
gtk_widget_show (label);
- return BONOBO_OBJECT (bonobo_control_new (label));
+ return BONOBO_OBJECT (evolution_config_control_new (label));
}
static BonoboObject *