source: trunk/third/evolution/shell/evolution-config-control.c @ 18142

Revision 18142, 5.5 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18141, which included commits to RCS files with non-trunk default branches.
Line 
1/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2/* evolution-config-control.c
3 *
4 * Copyright (C) 2002 Ximian, Inc.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of version 2 of the GNU General Public
8 * License as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 *
20 * Author: Ettore Perazzoli
21 */
22
23#ifdef HAVE_CONFIG_H
24#include <config.h>
25#endif
26
27#include "evolution-config-control.h"
28
29#include <gal/util/e-util.h>
30
31#include <gtk/gtksignal.h>
32
33#include <bonobo/bonobo-control.h>
34#include <bonobo/bonobo-event-source.h>
35
36
37#define PARENT_TYPE BONOBO_X_OBJECT_TYPE
38static BonoboXObjectClass *parent_class = NULL;
39
40struct _EvolutionConfigControlPrivate {
41        gboolean changed;
42        BonoboControl *control;
43        BonoboEventSource *event_source;
44};
45
46enum {
47        APPLY,
48        LAST_SIGNAL
49};
50static int signals[LAST_SIGNAL] = { 0 };
51
52
53/* GtkObject methods.  */
54
55static void
56impl_destroy (GtkObject *object)
57{
58        EvolutionConfigControl *config_control;
59        EvolutionConfigControlPrivate *priv;
60
61        config_control = EVOLUTION_CONFIG_CONTROL (object);
62        priv = config_control->priv;
63
64        if (priv != NULL) {
65                bonobo_object_unref (BONOBO_OBJECT (priv->control));
66                bonobo_object_unref (BONOBO_OBJECT (priv->event_source));
67
68                g_free (priv);
69                config_control->priv = NULL;
70        }
71
72        (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
73}
74
75
76/* Evolution::ConfigControl CORBA methods.  */
77
78static void
79impl_apply (PortableServer_Servant servant,
80            CORBA_Environment *ev)
81{
82        EvolutionConfigControl *config_control;
83        EvolutionConfigControlPrivate *priv;
84
85        config_control = EVOLUTION_CONFIG_CONTROL (bonobo_object_from_servant (servant));
86        priv = config_control->priv;
87
88        gtk_signal_emit (GTK_OBJECT (config_control), signals[APPLY]);
89
90        priv->changed = FALSE;
91}
92
93static Bonobo_Control
94impl__get_control (PortableServer_Servant servant,
95                   CORBA_Environment *ev)
96{
97        EvolutionConfigControl *config_control;
98        EvolutionConfigControlPrivate *priv;
99
100        config_control = EVOLUTION_CONFIG_CONTROL (bonobo_object_from_servant (servant));
101        priv = config_control->priv;
102
103        bonobo_object_ref (BONOBO_OBJECT (priv->control));
104
105        return CORBA_Object_duplicate (bonobo_object_corba_objref (BONOBO_OBJECT (priv->control)), ev);
106}
107
108static Bonobo_EventSource
109impl__get_eventSource (PortableServer_Servant servant,
110                       CORBA_Environment *ev)
111{
112        EvolutionConfigControl *config_control;
113        EvolutionConfigControlPrivate *priv;
114
115        config_control = EVOLUTION_CONFIG_CONTROL (bonobo_object_from_servant (servant));
116        priv = config_control->priv;
117
118        bonobo_object_ref (BONOBO_OBJECT (priv->event_source));
119
120        return CORBA_Object_duplicate (bonobo_object_corba_objref (BONOBO_OBJECT (priv->event_source)), ev);
121}
122
123
124static void
125class_init (EvolutionConfigControlClass *class)
126{
127        POA_GNOME_Evolution_ConfigControl__epv *epv;
128        GtkObjectClass *object_class;
129
130        object_class = GTK_OBJECT_CLASS (class);
131        object_class->destroy = impl_destroy;
132
133        epv = &class->epv;
134        epv->apply            = impl_apply;
135        epv->_get_control     = impl__get_control;
136        epv->_get_eventSource = impl__get_eventSource;
137
138        signals[APPLY] = gtk_signal_new ("apply", GTK_RUN_FIRST,
139                                         object_class->type,
140                                         GTK_SIGNAL_OFFSET (EvolutionConfigControlClass, apply),
141                                         gtk_marshal_NONE__NONE,
142                                         GTK_TYPE_NONE, 0);
143
144        gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
145
146        parent_class = gtk_type_class (PARENT_TYPE);
147}
148
149static void
150init (EvolutionConfigControl *config_control)
151{
152        EvolutionConfigControlPrivate *priv;
153
154        priv = g_new (EvolutionConfigControlPrivate, 1);
155        priv->changed      = FALSE;
156        priv->control      = NULL;
157        priv->event_source = bonobo_event_source_new ();
158
159        config_control->priv = priv;
160}
161
162
163void
164evolution_config_control_construct (EvolutionConfigControl *control,
165                                    GtkWidget *widget)
166{
167        EvolutionConfigControlPrivate *priv;
168
169        g_return_if_fail (EVOLUTION_IS_CONFIG_CONTROL (control));
170        g_return_if_fail (GTK_IS_WIDGET (widget));
171
172        priv = control->priv;
173
174        priv->control = bonobo_control_new (widget);
175}
176
177EvolutionConfigControl *
178evolution_config_control_new (GtkWidget *widget)
179{
180        EvolutionConfigControl *new;
181
182        g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
183
184        new = gtk_type_new (evolution_config_control_get_type ());
185        evolution_config_control_construct (new, widget);
186
187        return new;
188}
189
190void
191evolution_config_control_changed (EvolutionConfigControl *config_control)
192{
193        EvolutionConfigControlPrivate *priv;
194        CORBA_Environment ev;
195        CORBA_any *null_value;
196
197        g_return_if_fail (EVOLUTION_IS_CONFIG_CONTROL (config_control));
198
199        priv = config_control->priv;
200
201        if (priv->changed)
202                return;
203
204        priv->changed = TRUE;
205
206        CORBA_exception_init (&ev);
207
208        null_value = CORBA_any__alloc ();
209        null_value->_type = TC_null;
210
211        bonobo_event_source_notify_listeners (priv->event_source, "changed", null_value, &ev);
212
213        CORBA_free (null_value);
214
215        CORBA_exception_free (&ev);
216}
217
218
219E_MAKE_X_TYPE (evolution_config_control, "EvolutionConfigControl", EvolutionConfigControl,
220               class_init, init, PARENT_TYPE,
221               POA_GNOME_Evolution_ConfigControl__init,
222               GTK_STRUCT_OFFSET (EvolutionConfigControlClass, epv))
Note: See TracBrowser for help on using the repository browser.