Updated Traditional Chinese translation.
[evolution.git] / shell / evolution-test-component.c
blob2fd140b0320c0aa396d4fb5b4041aea457823474
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /* tasks-component.c
4 * Copyright (C) 2004 Novell, Inc.
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.
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.
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.
20 * Author: JP Rosevear <jpr@ximian.com>
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
27 #include <errno.h>
28 #include <string.h>
29 #include <bonobo/bonobo-shlib-factory.h>
30 #include <bonobo/bonobo-control.h>
31 #include <bonobo/bonobo-i18n.h>
32 #include <bonobo/bonobo-exception.h>
33 #include <gtk/gtklabel.h>
34 #include "e-task-bar.h"
35 #include "evolution-test-component.h"
38 #define FACTORY_ID "OAFIID:GNOME_Evolution_Test_Factory:" BASE_VERSION
39 #define TEST_COMPONENT_ID "OAFIID:GNOME_Evolution_Test_Component:" BASE_VERSION
40 #define CREATE_TEST_ID "test"
42 #define PARENT_TYPE bonobo_object_get_type ()
44 static BonoboObjectClass *parent_class = NULL;
46 struct _EvolutionTestComponentPrivate {
47 BonoboControl *view_control;
48 BonoboControl *sidebar_control;
49 BonoboControl *status_control;
52 /* GObject methods */
54 static void
55 impl_dispose (GObject *object)
57 EvolutionTestComponentPrivate *priv;
59 priv = EVOLUTION_TEST_COMPONENT (object)->priv;
61 (* G_OBJECT_CLASS (parent_class)->dispose) (object);
64 static void
65 impl_finalize (GObject *object)
67 EvolutionTestComponentPrivate *priv = EVOLUTION_TEST_COMPONENT (object)->priv;
69 g_free (priv);
71 (* G_OBJECT_CLASS (parent_class)->finalize) (object);
74 /* Evolution::Component CORBA methods */
76 static CORBA_boolean
77 impl_upgradeFromVersion (PortableServer_Servant servant,
78 CORBA_short major,
79 CORBA_short minor,
80 CORBA_short revision,
81 CORBA_Environment *ev)
83 EvolutionTestComponent *component = EVOLUTION_TEST_COMPONENT (bonobo_object_from_servant (servant));
84 EvolutionTestComponentPrivate *priv;
86 priv = component->priv;
88 g_message ("Upgrading from %d.%d.%d", major, minor, revision);
90 return CORBA_TRUE;
93 static void
94 impl_createControls (PortableServer_Servant servant,
95 Bonobo_Control *corba_sidebar_control,
96 Bonobo_Control *corba_view_control,
97 Bonobo_Control *corba_statusbar_control,
98 CORBA_Environment *ev)
100 EvolutionTestComponent *component = EVOLUTION_TEST_COMPONENT (bonobo_object_from_servant (servant));
101 EvolutionTestComponentPrivate *priv;
102 GtkWidget *label, *bar;
104 priv = component->priv;
106 /* Sidebar */
107 label = gtk_label_new ("Side Bar Control");
108 gtk_widget_show (label);
109 priv->sidebar_control = bonobo_control_new (label);
111 /* View */
112 label = gtk_label_new ("View Control");
113 gtk_widget_show (label);
114 priv->view_control = bonobo_control_new (label);
116 /* Status bar */
117 bar = e_task_bar_new ();
118 gtk_widget_show (bar);
119 priv->status_control = bonobo_control_new (bar);
121 /* Return the controls */
122 *corba_sidebar_control = CORBA_Object_duplicate (BONOBO_OBJREF (priv->sidebar_control), ev);
123 *corba_view_control = CORBA_Object_duplicate (BONOBO_OBJREF (priv->view_control), ev);
124 *corba_statusbar_control = CORBA_Object_duplicate (BONOBO_OBJREF (priv->status_control), ev);
127 static GNOME_Evolution_CreatableItemTypeList *
128 impl__get_userCreatableItems (PortableServer_Servant servant,
129 CORBA_Environment *ev)
131 GNOME_Evolution_CreatableItemTypeList *list = GNOME_Evolution_CreatableItemTypeList__alloc ();
133 list->_length = 1;
134 list->_maximum = list->_length;
135 list->_buffer = GNOME_Evolution_CreatableItemTypeList_allocbuf (list->_length);
137 CORBA_sequence_set_release (list, FALSE);
139 list->_buffer[0].id = CREATE_TEST_ID;
140 list->_buffer[0].description = _("New Test");
141 list->_buffer[0].menuDescription = _("_Test");
142 list->_buffer[0].tooltip = _("Create a new test item");
143 list->_buffer[0].menuShortcut = 'i';
144 list->_buffer[0].iconName = "";
146 return list;
149 static void
150 impl_requestCreateItem (PortableServer_Servant servant,
151 const CORBA_char *item_type_name,
152 CORBA_Environment *ev)
154 EvolutionTestComponent *evolution_test_component = EVOLUTION_TEST_COMPONENT (bonobo_object_from_servant (servant));
155 EvolutionTestComponentPrivate *priv;
157 priv = evolution_test_component->priv;
159 if (strcmp (item_type_name, CREATE_TEST_ID) == 0) {
160 g_message ("Creating test item");
161 } else {
162 bonobo_exception_set (ev, ex_GNOME_Evolution_Component_UnknownType);
163 return;
167 /* Initialization */
169 static void
170 evolution_test_component_class_init (EvolutionTestComponentClass *klass)
172 POA_GNOME_Evolution_Component__epv *epv = &klass->epv;
173 GObjectClass *object_class = G_OBJECT_CLASS (klass);
175 parent_class = g_type_class_peek_parent (klass);
177 epv->upgradeFromVersion = impl_upgradeFromVersion;
178 epv->createControls = impl_createControls;
179 epv->_get_userCreatableItems = impl__get_userCreatableItems;
180 epv->requestCreateItem = impl_requestCreateItem;
182 object_class->dispose = impl_dispose;
183 object_class->finalize = impl_finalize;
186 static void
187 evolution_test_component_init (EvolutionTestComponent *component, EvolutionTestComponentClass *klass)
189 EvolutionTestComponentPrivate *priv;
191 priv = g_new0 (EvolutionTestComponentPrivate, 1);
193 component->priv = priv;
196 BONOBO_TYPE_FUNC_FULL (EvolutionTestComponent, GNOME_Evolution_Component, PARENT_TYPE, evolution_test_component)
198 static BonoboObject *
199 factory (BonoboGenericFactory *factory,
200 const char *component_id,
201 void *closure)
203 if (strcmp (component_id, TEST_COMPONENT_ID) == 0) {
204 BonoboObject *object = BONOBO_OBJECT (g_object_new (EVOLUTION_TEST_TYPE_COMPONENT, NULL));
205 bonobo_object_ref (object);
206 return object;
209 g_warning (FACTORY_ID ": Don't know what to do with %s", component_id);
211 return NULL;
214 BONOBO_ACTIVATION_SHLIB_FACTORY (FACTORY_ID, "Evolution Calendar component factory", factory, NULL)