aboutsummaryrefslogtreecommitdiffstats
path: root/executive-summary/evolution-services/executive-summary-component-view.c
diff options
context:
space:
mode:
Diffstat (limited to 'executive-summary/evolution-services/executive-summary-component-view.c')
-rw-r--r--executive-summary/evolution-services/executive-summary-component-view.c345
1 files changed, 345 insertions, 0 deletions
diff --git a/executive-summary/evolution-services/executive-summary-component-view.c b/executive-summary/evolution-services/executive-summary-component-view.c
new file mode 100644
index 0000000000..b61b69a7fa
--- /dev/null
+++ b/executive-summary/evolution-services/executive-summary-component-view.c
@@ -0,0 +1,345 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* executive-summary-component.c - Bonobo implementation of
+ * SummaryComponent.idl
+ *
+ * Authors: Iain Holmes <iain@helixcode.com>
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <bonobo.h>
+#include <gnome.h>
+#include <gal/util/e-util.h>
+
+#include <evolution-services/executive-summary-component.h>
+#include <evolution-services/executive-summary-component-view.h>
+
+struct _ExecutiveSummaryComponentViewPrivate {
+ ExecutiveSummaryComponent *component;
+
+ BonoboControl *control;
+ char *html;
+
+ char *title;
+ char *icon;
+
+ int id;
+};
+
+static GtkObjectClass *parent_class = NULL;
+#define PARENT_TYPE (gtk_object_get_type ())
+
+static void
+executive_summary_component_view_destroy (GtkObject *object)
+{
+ ExecutiveSummaryComponentView *view;
+ ExecutiveSummaryComponentViewPrivate *priv;
+
+ view = EXECUTIVE_SUMMARY_COMPONENT_VIEW (object);
+ priv = view->private;
+ if (priv == NULL)
+ return;
+
+ if (priv->component)
+ bonobo_object_unref (BONOBO_OBJECT (priv->component));
+
+ if (priv->control)
+ bonobo_object_unref (BONOBO_OBJECT (priv->control));
+
+ g_free (priv->html);
+ g_free (priv->title);
+ g_free (priv->icon);
+
+ g_free (priv);
+ view->private = NULL;
+
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+}
+
+static void
+executive_summary_component_view_class_init (ExecutiveSummaryComponentViewClass *view_class)
+{
+ GtkObjectClass *object_class;
+
+ object_class = GTK_OBJECT_CLASS (view_class);
+
+ object_class->destroy = executive_summary_component_view_destroy;
+
+ parent_class = gtk_type_class (PARENT_TYPE);
+}
+
+static void
+executive_summary_component_view_init (ExecutiveSummaryComponentView *view)
+{
+ ExecutiveSummaryComponentViewPrivate *priv;
+
+ priv = g_new (ExecutiveSummaryComponentViewPrivate, 1);
+ view->private = priv;
+
+ priv->control = NULL;
+ priv->html = NULL;
+ priv->title = NULL;
+ priv->icon = NULL;
+ priv->id = -1;
+}
+
+E_MAKE_TYPE (executive_summary_component_view, "ExecutiveSummaryComponentView",
+ ExecutiveSummaryComponentView,
+ executive_summary_component_view_class_init,
+ executive_summary_component_view_init, PARENT_TYPE);
+
+void
+executive_summary_component_view_construct (ExecutiveSummaryComponentView *view,
+ ExecutiveSummaryComponent *component,
+ BonoboControl *control,
+ const char *html,
+ const char *title,
+ const char *icon)
+{
+ ExecutiveSummaryComponentViewPrivate *priv;
+
+ g_return_if_fail (view != NULL);
+ g_return_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT_VIEW (view));
+ g_return_if_fail (control != NULL || html != NULL);
+
+ priv = view->private;
+
+ if (component != NULL) {
+ bonobo_object_ref (BONOBO_OBJECT (component));
+ priv->component = component;
+ } else {
+ priv->component = NULL;
+ }
+
+ if (control != NULL) {
+ bonobo_object_ref (BONOBO_OBJECT (control));
+ priv->control = control;
+ } else {
+ priv->control = NULL;
+ }
+
+ if (html) {
+ priv->html = g_strdup (html);
+ } else {
+ priv->html = NULL;
+ }
+
+ if (title) {
+ priv->title = g_strdup (title);
+ } else {
+ priv->title = NULL;
+ }
+
+ if (icon) {
+ priv->icon = g_strdup (icon);
+ } else {
+ priv->icon = NULL;
+ }
+}
+
+ExecutiveSummaryComponentView *
+executive_summary_component_view_new (ExecutiveSummaryComponent *component,
+ BonoboControl *control,
+ const char *html,
+ const char *title,
+ const char *icon)
+{
+ ExecutiveSummaryComponentView *view;
+
+ g_return_val_if_fail (control != NULL || html != NULL, NULL);
+
+ view = gtk_type_new (executive_summary_component_view_get_type ());
+ executive_summary_component_view_construct (view, component, control,
+ html, title, icon);
+
+ return view;
+}
+
+void
+executive_summary_component_view_set_title (ExecutiveSummaryComponentView *view,
+ const char *title)
+{
+ ExecutiveSummaryComponentViewPrivate *priv;
+ ExecutiveSummaryComponent *component;
+
+ g_return_if_fail (view != NULL);
+ g_return_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT_VIEW (view));
+
+ priv = view->private;
+ if (priv->title)
+ g_free (priv->title);
+ priv->title = g_strdup (title);
+
+ component = priv->component;
+ if (component == NULL) {
+ g_warning ("Calling %s from the wrong side of the CORBA interface", __FUNCTION__);
+ return;
+ }
+
+ executive_summary_component_set_title (component, view);
+}
+
+const char *
+executive_summary_component_view_get_title (ExecutiveSummaryComponentView *view)
+{
+ ExecutiveSummaryComponentViewPrivate *priv;
+
+ g_return_val_if_fail (view != NULL, NULL);
+ g_return_val_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT_VIEW (view), NULL);
+
+ priv = view->private;
+
+ return priv->title;
+}
+
+void
+executive_summary_component_view_set_icon (ExecutiveSummaryComponentView *view,
+ const char *icon)
+{
+ ExecutiveSummaryComponentViewPrivate *priv;
+ ExecutiveSummaryComponent *component;
+
+ g_return_if_fail (view != NULL);
+ g_return_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT_VIEW (view));
+
+ priv = view->private;
+ if (priv->icon)
+ g_free (priv->icon);
+ priv->icon = g_strdup (icon);
+
+ component = priv->component;
+ if (component == NULL) {
+ return;
+ }
+
+
+ executive_summary_component_set_icon (component, view);
+}
+
+const char *
+executive_summary_component_view_get_icon (ExecutiveSummaryComponentView *view)
+{
+ ExecutiveSummaryComponentViewPrivate *priv;
+
+ g_return_val_if_fail (view != NULL, NULL);
+ g_return_val_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT_VIEW (view), NULL);
+
+ priv = view->private;
+
+ return priv->icon;
+}
+
+void
+executive_summary_component_view_flash (ExecutiveSummaryComponentView *view)
+{
+ ExecutiveSummaryComponentViewPrivate *priv;
+ ExecutiveSummaryComponent *component;
+
+ g_return_if_fail (view != NULL);
+ g_return_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT_VIEW (view));
+
+ priv = view->private;
+ component = priv->component;
+ if (component == NULL) {
+ g_warning ("Calling %s from the wrong side of the CORBA interface", __FUNCTION__);
+ return;
+ }
+
+ executive_summary_component_flash (component, view);
+}
+
+void
+executive_summary_component_view_set_html (ExecutiveSummaryComponentView *view,
+ const char *html)
+{
+ ExecutiveSummaryComponentViewPrivate *priv;
+ ExecutiveSummaryComponent *component;
+
+ g_return_if_fail (view != NULL);
+ g_return_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT_VIEW (view));
+
+ priv = view->private;
+ if (priv->html)
+ g_free (priv->html);
+
+ priv->html = g_strdup (html);
+
+ component = priv->component;
+ if (component == NULL) {
+ return;
+ }
+
+ executive_summary_component_update (component, view);
+}
+
+const char *
+executive_summary_component_view_get_html (ExecutiveSummaryComponentView *view)
+{
+ ExecutiveSummaryComponentViewPrivate *priv;
+
+ g_return_val_if_fail (view != NULL, NULL);
+ g_return_val_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT_VIEW (view), NULL);
+
+ priv = view->private;
+
+ return priv->html;
+}
+
+BonoboObject *
+executive_summary_component_view_get_control (ExecutiveSummaryComponentView *view)
+{
+ ExecutiveSummaryComponentViewPrivate *priv;
+
+ g_return_val_if_fail (view != NULL, NULL);
+ g_return_val_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT_VIEW (view), NULL);
+
+ priv = view->private;
+
+ return BONOBO_OBJECT (priv->control);
+}
+
+void
+executive_summary_component_view_set_id (ExecutiveSummaryComponentView *view,
+ int id)
+{
+ ExecutiveSummaryComponentViewPrivate *priv;
+
+ g_return_if_fail (view != NULL);
+ g_return_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT_VIEW (view));
+
+ priv = view->private;
+
+ priv->id = id;
+}
+
+int
+executive_summary_component_view_get_id (ExecutiveSummaryComponentView *view)
+{
+ ExecutiveSummaryComponentViewPrivate *priv;
+
+ g_return_val_if_fail (view != NULL, -1);
+ g_return_val_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT_VIEW (view), -1);
+
+ priv = view->private;
+
+ return priv->id;
+}