diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2002-03-13 12:50:30 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2002-03-13 12:50:30 +0800 |
commit | 9a3b0141daad42713cdeae13ffb0d2e8af786540 (patch) | |
tree | db27f6df6801b143cd3a9d15194830822812c74c /shell/evolution-config-control.c | |
parent | 8ffcf0b7552e8b921228a8aa372335a161d262b8 (diff) | |
download | gsoc2013-evolution-9a3b0141daad42713cdeae13ffb0d2e8af786540.tar.gz gsoc2013-evolution-9a3b0141daad42713cdeae13ffb0d2e8af786540.tar.zst gsoc2013-evolution-9a3b0141daad42713cdeae13ffb0d2e8af786540.zip |
Update to create an EvolutionConfigControl instead of just a
* 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'.
svn path=/trunk/; revision=16134
Diffstat (limited to 'shell/evolution-config-control.c')
-rw-r--r-- | shell/evolution-config-control.c | 222 |
1 files changed, 222 insertions, 0 deletions
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)) |