diff options
author | Iain Holmes <iain@src.gnome.org> | 2000-10-26 07:03:33 +0800 |
---|---|---|
committer | Iain Holmes <iain@src.gnome.org> | 2000-10-26 07:03:33 +0800 |
commit | 20394851919f80269d11aa460e60f2bd1e46b7dc (patch) | |
tree | 6b3fc7cd84913f288434f58e5a4a9cb86604b073 /executive-summary/evolution-services | |
parent | 8ab09706d1ddaa55f1e76dc395fdee2104e4d105 (diff) | |
download | gsoc2013-evolution-20394851919f80269d11aa460e60f2bd1e46b7dc.tar gsoc2013-evolution-20394851919f80269d11aa460e60f2bd1e46b7dc.tar.gz gsoc2013-evolution-20394851919f80269d11aa460e60f2bd1e46b7dc.tar.bz2 gsoc2013-evolution-20394851919f80269d11aa460e60f2bd1e46b7dc.tar.lz gsoc2013-evolution-20394851919f80269d11aa460e60f2bd1e46b7dc.tar.xz gsoc2013-evolution-20394851919f80269d11aa460e60f2bd1e46b7dc.tar.zst gsoc2013-evolution-20394851919f80269d11aa460e60f2bd1e46b7dc.zip |
Summary is back in :D
Fixed a silly size issue for composer file selectors.
svn path=/trunk/; revision=6187
Diffstat (limited to 'executive-summary/evolution-services')
11 files changed, 773 insertions, 165 deletions
diff --git a/executive-summary/evolution-services/Makefile.am b/executive-summary/evolution-services/Makefile.am index 693fb65905..a2dc6c845a 100644 --- a/executive-summary/evolution-services/Makefile.am +++ b/executive-summary/evolution-services/Makefile.am @@ -1,11 +1,11 @@ lib_LTLIBRARIES = libevolution-services.la INCLUDES = \ - -I$(top_srcdir)/widgets \ - -I$(top_srcdir)/widgets/e-text \ -I$(top_srcdir) \ -I$(top_builddir)/shell \ -I$(top_srcdir)/shell \ + -I$(top_srcdir)/executive-summary \ + -I$(top_builddir)/executive-summary \ $(EXTRA_GNOME_CFLAGS) \ $(GNOME_VFS_CFLAGS) \ $(UNICODE_CFLAGS) \ @@ -43,7 +43,9 @@ libevolution_services_la_SOURCES = \ executive-summary-component.c \ executive-summary-component.h \ executive-summary-component-client.c \ - executive-summary-component-client.h + executive-summary-component-client.h \ + executive-summary-component-view.c \ + executive-summary-component-view.h libevolution_services_la_LIBADD = \ $(top_builddir)/e-util/libeutil.la \ diff --git a/executive-summary/evolution-services/executive-summary-client.c b/executive-summary/evolution-services/executive-summary-client.c index f608b0908f..88796d1753 100644 --- a/executive-summary/evolution-services/executive-summary-client.c +++ b/executive-summary/evolution-services/executive-summary-client.c @@ -95,18 +95,16 @@ E_MAKE_TYPE (executive_summary_client, "ExecutiveSummaryClient", void executive_summary_client_set_title (ExecutiveSummaryClient *client, - ExecutiveSummaryComponent *component, + int id, const char *title) { Evolution_Summary summary; - Evolution_SummaryComponent corba_object; CORBA_Environment ev; CORBA_exception_init (&ev); summary = bonobo_object_corba_objref (BONOBO_OBJECT (client)); - corba_object = bonobo_object_corba_objref (BONOBO_OBJECT (component)); - Evolution_Summary_set_title (summary, corba_object, title, &ev); + Evolution_Summary_set_title (summary, id, title, &ev); if (ev._major != CORBA_NO_EXCEPTION) { g_warning ("Error setting title to %s:%s", title, CORBA_exception_id (&ev)); @@ -116,18 +114,36 @@ executive_summary_client_set_title (ExecutiveSummaryClient *client, } void +executive_summary_client_set_icon (ExecutiveSummaryClient *client, + int id, + const char *icon) +{ + Evolution_Summary summary; + CORBA_Environment ev; + + CORBA_exception_init (&ev); + summary = bonobo_object_corba_objref (BONOBO_OBJECT (client)); + + Evolution_Summary_set_icon (summary, id, icon, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("Error setting icon to %s:%s", icon, CORBA_exception_id (&ev)); + } + + CORBA_exception_free (&ev); +} + +void executive_summary_client_flash (ExecutiveSummaryClient *client, - ExecutiveSummaryComponent *component) + int id) { Evolution_Summary summary; - Evolution_SummaryComponent corba_object; CORBA_Environment ev; CORBA_exception_init (&ev); summary = bonobo_object_corba_objref (BONOBO_OBJECT (client)); - corba_object = bonobo_object_corba_objref (BONOBO_OBJECT (component)); - Evolution_Summary_flash (summary, corba_object, &ev); + Evolution_Summary_flash (summary, id, &ev); if (ev._major != CORBA_NO_EXCEPTION) { g_warning ("Error flashing"); @@ -138,19 +154,16 @@ executive_summary_client_flash (ExecutiveSummaryClient *client, void executive_summary_client_update (ExecutiveSummaryClient *client, - ExecutiveSummaryComponent *component, - char *html) + int id, + const char *html) { Evolution_Summary summary; - Evolution_SummaryComponent corba_object; CORBA_Environment ev; CORBA_exception_init (&ev); summary = bonobo_object_corba_objref (BONOBO_OBJECT (client)); - corba_object = bonobo_object_corba_objref (BONOBO_OBJECT (component)); - Evolution_Summary_update_html_component (summary, corba_object, - html, &ev); + Evolution_Summary_update_component (summary, id, html, &ev); if (ev._major != CORBA_NO_EXCEPTION) { g_warning ("Error updating the component"); } diff --git a/executive-summary/evolution-services/executive-summary-client.h b/executive-summary/evolution-services/executive-summary-client.h index a2b350c4c6..c6c138dd69 100644 --- a/executive-summary/evolution-services/executive-summary-client.h +++ b/executive-summary/evolution-services/executive-summary-client.h @@ -21,11 +21,11 @@ * Boston, MA 02111-1307, USA. */ -#ifndef _EXECUTIVE_SUMMARY_COMPONENT_CLIENT_H__ -#define _EXECUTIVE_SUMMARY_COMPONENT_CLIENT_H__ +#ifndef _EXECUTIVE_SUMMARY_CLIENT_H__ +#define _EXECUTIVE_SUMMARY_CLIENT_H__ #include <bonobo.h> -#include "executive-summary-component.h" +#include <evolution-services/executive-summary-component.h> #define EXECUTIVE_SUMMARY_CLIENT_TYPE (executive_summary_client_get_type ()) #define EXECUTIVE_SUMMARY_CLIENT(obj) (GTK_CHECK_CAST ((obj), EXECUTIVE_SUMMARY_CLIENT_TYPE, ExecutiveSummaryClient)) @@ -51,12 +51,15 @@ GtkType executive_summary_client_get_type (void); void executive_summary_client_construct (ExecutiveSummaryClient *client, CORBA_Object object); void executive_summary_client_set_title (ExecutiveSummaryClient *client, - ExecutiveSummaryComponent *component, + int id, const char *title); +void executive_summary_client_set_icon (ExecutiveSummaryClient *client, + int id, + const char *icon); void executive_summary_client_flash (ExecutiveSummaryClient *client, - ExecutiveSummaryComponent *component); + int id); void executive_summary_client_update (ExecutiveSummaryClient *client, - ExecutiveSummaryComponent *component, - char *html); + int id, + const char *html); #endif diff --git a/executive-summary/evolution-services/executive-summary-component-client.c b/executive-summary/evolution-services/executive-summary-component-client.c index 7702785692..7c0477af41 100644 --- a/executive-summary/evolution-services/executive-summary-component-client.c +++ b/executive-summary/evolution-services/executive-summary-component-client.c @@ -33,6 +33,7 @@ #include <Executive-Summary.h> #include "executive-summary-component-client.h" +#include "executive-summary-component-view.h" #include "executive-summary.h" #define PARENT_TYPE BONOBO_OBJECT_CLIENT_TYPE @@ -173,6 +174,7 @@ executive_summary_component_client_unset_owner (ExecutiveSummaryComponentClient return; } +#if 0 void executive_summary_component_client_supports (ExecutiveSummaryComponentClient *client, gboolean *bonobo, @@ -196,35 +198,52 @@ executive_summary_component_client_supports (ExecutiveSummaryComponentClient *cl CORBA_exception_free (&ev); return; } +#endif -Bonobo_Control -executive_summary_component_client_create_bonobo_view (ExecutiveSummaryComponentClient *client, - char **title, - char **icon) +ExecutiveSummaryComponentView * +executive_summary_component_client_create_view (ExecutiveSummaryComponentClient *client) { - Bonobo_Control control; + ExecutiveSummaryComponentView *view; Evolution_SummaryComponent component; + char *html, *title, *icon; + Bonobo_Control control; + BonoboControl *bc; + int id; CORBA_Environment ev; - - g_return_val_if_fail (client != NULL, CORBA_OBJECT_NIL); + + g_return_val_if_fail (client != NULL, NULL); g_return_val_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT_CLIENT (client), - CORBA_OBJECT_NIL); - + NULL); + CORBA_exception_init (&ev); component = bonobo_object_corba_objref (BONOBO_OBJECT (client)); - control = Evolution_SummaryComponent_create_bonobo_view (component, title, icon, &ev); + /* Get all the details about the view */ + id = Evolution_SummaryComponent_create_view (component, &control, + &html, &title, &icon, &ev); if (ev._major != CORBA_NO_EXCEPTION) { g_warning ("Error creating view"); CORBA_exception_free (&ev); - return CORBA_OBJECT_NIL; + return NULL; } CORBA_exception_free (&ev); + + /* Create a local copy of the remote view */ + if (control != CORBA_OBJECT_NIL) { + bc = BONOBO_CONTROL (bonobo_widget_new_control_from_objref (control, NULL)); + } else { + bc = NULL; + } + + view = executive_summary_component_view_new (NULL, bc, html, title, + icon); + executive_summary_component_view_set_id (view, id); - return control; + return view; } +#if 0 char * executive_summary_component_client_create_html_view (ExecutiveSummaryComponentClient *client, char **title, @@ -253,6 +272,7 @@ executive_summary_component_client_create_html_view (ExecutiveSummaryComponentCl return (char *)g_strdup (ret_html); } +#endif void executive_summary_component_client_configure (ExecutiveSummaryComponentClient *client) @@ -279,6 +299,33 @@ executive_summary_component_client_configure (ExecutiveSummaryComponentClient *c return; } +void +executive_summary_component_client_destroy_view (ExecutiveSummaryComponentClient *client, + ExecutiveSummaryComponentView *view) { + int id; + Evolution_SummaryComponent component; + CORBA_Environment ev; + + g_return_if_fail (client != NULL); + g_return_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT_CLIENT (client)); + g_return_if_fail (view != NULL); + g_return_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT_VIEW (view)); + + id = executive_summary_component_view_get_id (view); + + CORBA_exception_init (&ev); + component = bonobo_object_corba_objref (BONOBO_OBJECT (client)); + Evolution_SummaryComponent_destroy_view (component, id, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("Error destroying view #%d", id); + } + + CORBA_exception_free (&ev); + + return; +} + E_MAKE_TYPE (executive_summary_component_client, "ExecutiveSummaryComponentClient", ExecutiveSummaryComponentClient, diff --git a/executive-summary/evolution-services/executive-summary-component-client.h b/executive-summary/evolution-services/executive-summary-component-client.h index d38f860430..849bec6c99 100644 --- a/executive-summary/evolution-services/executive-summary-component-client.h +++ b/executive-summary/evolution-services/executive-summary-component-client.h @@ -25,7 +25,7 @@ #define _EXECUTIVE_SUMMARY_COMPONENT_CLIENT_H__ #include <bonobo.h> -#include <executive-summary.h> +#include <evolution-services/executive-summary.h> #define EXECUTIVE_SUMMARY_COMPONENT_CLIENT_TYPE (executive_summary_component_client_get_type ()) #define EXECUTIVE_SUMMARY_COMPONENT_CLIENT(obj) (GTK_CHECK_CAST ((obj), EXECUTIVE_SUMMARY_COMPONENT_CLIENT_TYPE, ExecutiveSummaryComponentClient)) 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; +} diff --git a/executive-summary/evolution-services/executive-summary-component-view.h b/executive-summary/evolution-services/executive-summary-component-view.h new file mode 100644 index 0000000000..ecd0c7ab33 --- /dev/null +++ b/executive-summary/evolution-services/executive-summary-component-view.h @@ -0,0 +1,83 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* executive-summary-component.h + * + * 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. + */ + +#ifndef __EXECUTIVE_SUMMARY_COMPONENT_VIEW_H__ +#define __EXECUTIVE_SUMMARY_COMPONENT_VIEW_H__ + +#include <evolution-services/executive-summary-component.h> + +#define EXECUTIVE_SUMMARY_COMPONENT_VIEW_TYPE (executive_summary_component_view_get_type ()) +#define EXECUTIVE_SUMMARY_COMPONENT_VIEW(obj) (GTK_CHECK_CAST ((obj), EXECUTIVE_SUMMARY_COMPONENT_VIEW_TYPE, ExecutiveSummaryComponentView)) +#define EXECUTIVE_SUMMARY_COMPONENT_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EXECUTIVE_SUMMARY_COMPONENT_VIEW_TYPE, ExecutiveSummaryComponentClass)) +#define IS_EXECUTIVE_SUMMARY_COMPONENT_VIEW(obj) (GTK_CHECK_TYPE ((obj), EXECUTIVE_SUMMARY_COMPONENT_VIEW_TYPE)) +#define IS_EXECUTIVE_SUMMARY_COMPONENT_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EXECUTIVE_SUMMARY_COMPONENT_VIEW_CLASS_TYPE)) + +typedef struct _ExecutiveSummaryComponentViewPrivate ExecutiveSummaryComponentViewPrivate; +typedef struct _ExecutiveSummaryComponentView ExecutiveSummaryComponentView; +typedef struct _ExecutiveSummaryComponentViewClass ExecutiveSummaryComponentViewClass; + +struct _ExecutiveSummaryComponentView { + GtkObject object; + + ExecutiveSummaryComponentViewPrivate *private; +}; + +struct _ExecutiveSummaryComponentViewClass { + GtkObjectClass parent_class; +}; + +GtkType executive_summary_component_view_get_type (void); +void +executive_summary_component_view_construct (ExecutiveSummaryComponentView *view, + ExecutiveSummaryComponent *component, + BonoboControl *control, + const char *html, + const char *title, + const char *icon); +ExecutiveSummaryComponentView * +executive_summary_component_view_new (ExecutiveSummaryComponent *component, + BonoboControl *control, + const char *html, + const char *title, + const char *icon); + +void executive_summary_component_view_set_title (ExecutiveSummaryComponentView *view, + const char *title); +const char *executive_summary_component_view_get_title (ExecutiveSummaryComponentView *view); + +void executive_summary_component_view_set_icon (ExecutiveSummaryComponentView *view, + const char *icon); +const char *executive_summary_component_view_get_icon (ExecutiveSummaryComponentView *view); + +void executive_summary_component_view_flash (ExecutiveSummaryComponentView *view); + +void executive_summary_component_view_set_html (ExecutiveSummaryComponentView *view, + const char *html); +const char *executive_summary_component_view_get_html (ExecutiveSummaryComponentView *view); +BonoboObject *executive_summary_component_view_get_control (ExecutiveSummaryComponentView *view); + +int executive_summary_component_view_get_id (ExecutiveSummaryComponentView *view); + +#endif + + diff --git a/executive-summary/evolution-services/executive-summary-component.c b/executive-summary/evolution-services/executive-summary-component.c index 596a780033..116736f051 100644 --- a/executive-summary/evolution-services/executive-summary-component.c +++ b/executive-summary/evolution-services/executive-summary-component.c @@ -33,6 +33,7 @@ #include "Executive-Summary.h" #include "executive-summary.h" #include "executive-summary-component.h" +#include "executive-summary-component-view.h" #include "executive-summary-client.h" static void executive_summary_component_destroy (GtkObject *object); @@ -44,13 +45,14 @@ static void executive_summary_component_class_init (ExecutiveSummaryComponentCla static BonoboObjectClass *parent_class; struct _ExecutiveSummaryComponentPrivate { - EvolutionServicesCreateBonoboViewFn create_bonobo_view; - EvolutionServicesCreateHtmlViewFn create_html_view; + EvolutionServicesCreateViewFn create_view; EvolutionServicesConfigureFn configure; ExecutiveSummaryClient *owner_client; void *closure; + + GHashTable *id_to_view; }; /* CORBA interface */ @@ -78,6 +80,7 @@ create_servant (void) return servant; } +#if 0 static void impl_Evolution_SummaryComponent_supports (PortableServer_Servant servant, CORBA_boolean *html, @@ -95,6 +98,7 @@ impl_Evolution_SummaryComponent_supports (PortableServer_Servant servant, *html = (priv->create_html_view != NULL); *bonobo = (priv->create_bonobo_view != NULL); } +#endif static void impl_Evolution_SummaryComponent_set_owner (PortableServer_Servant servant, @@ -139,34 +143,56 @@ impl_Evolution_SummaryComponent_unset_owner (PortableServer_Servant servant, priv->owner_client = NULL; } -static Bonobo_Control -impl_Evolution_SummaryComponent_create_bonobo_view (PortableServer_Servant servant, - CORBA_char **title, - CORBA_char **icon, - CORBA_Environment *ev) +static CORBA_long +impl_Evolution_SummaryComponent_create_view (PortableServer_Servant servant, + Bonobo_Control *control, + CORBA_char **html, + CORBA_char **title, + CORBA_char **icon, + CORBA_Environment *ev) { + ExecutiveSummaryComponentView *view; BonoboObject *bonobo_object; ExecutiveSummaryComponent *component; ExecutiveSummaryComponentPrivate *priv; - BonoboControl *control; - char *initial_title, *initial_icon; + BonoboObject *initial_control; + const char *initial_title, *initial_icon, *initial_html; + int id; bonobo_object = bonobo_object_from_servant (servant); component = EXECUTIVE_SUMMARY_COMPONENT (bonobo_object); priv = component->private; - control = (* priv->create_bonobo_view) (component, &initial_title, - &initial_icon, - priv->closure); + view = gtk_type_new (executive_summary_component_view_get_type ()); + id = executive_summary_component_create_unique_id (); + executive_summary_component_view_set_id (view, id); + + (* priv->create_view) (component, view, priv->closure); + /* Extract the values */ + initial_title = executive_summary_component_view_get_title (view); + initial_icon = executive_summary_component_view_get_icon (view); + initial_html = executive_summary_component_view_get_html (view); + initial_control = executive_summary_component_view_get_control (view); + + /* Put the view in the hash table so it can be found later */ + g_hash_table_insert (priv->id_to_view, GINT_TO_POINTER (id), view); + + /* Duplicate the values */ + if (initial_control != NULL) { + *control = bonobo_object_corba_objref (BONOBO_OBJECT (initial_control)); + } else { + *control = NULL; + } + + *html = CORBA_string_dup (initial_html ? initial_html:""); *title = CORBA_string_dup (initial_title ? initial_title:""); *icon = CORBA_string_dup (initial_icon ? initial_icon:""); - g_free (initial_title); - g_free (initial_icon); - return bonobo_object_corba_objref (BONOBO_OBJECT (control)); + return id; } +#if 0 static CORBA_char * impl_Evolution_SummaryComponent_create_html_view (PortableServer_Servant servant, CORBA_char **title, @@ -197,7 +223,33 @@ impl_Evolution_SummaryComponent_create_html_view (PortableServer_Servant servant g_free (ret_html); return ret_str; } - +#endif + +static void +impl_Evolution_SummaryComponent_destroy_view (PortableServer_Servant servant, + CORBA_long id, + CORBA_Environment *ev) +{ + BonoboObject *bonobo_object; + ExecutiveSummaryComponent *component; + ExecutiveSummaryComponentPrivate *priv; + ExecutiveSummaryComponentView *view; + + g_print ("%s\n", __FUNCTION__); + bonobo_object = bonobo_object_from_servant (servant); + component = EXECUTIVE_SUMMARY_COMPONENT (bonobo_object); + priv = component->private; + + view = g_hash_table_lookup (priv->id_to_view, GINT_TO_POINTER (id)); + if (view == NULL) { + g_warning ("Unknown view: %d. Emit exception", id); + return; + } + + /* Destroy the view */ + gtk_object_unref (GTK_OBJECT (view)); +} + static void impl_Evolution_SummaryComponent_configure (PortableServer_Servant servant, CORBA_Environment *ev) @@ -255,11 +307,10 @@ corba_class_init (void) base_epv->default_POA = NULL; epv = g_new0 (POA_Evolution_SummaryComponent__epv, 1); - epv->supports = impl_Evolution_SummaryComponent_supports; epv->set_owner = impl_Evolution_SummaryComponent_set_owner; epv->unset_owner = impl_Evolution_SummaryComponent_unset_owner; - epv->create_bonobo_view = impl_Evolution_SummaryComponent_create_bonobo_view; - epv->create_html_view = impl_Evolution_SummaryComponent_create_html_view; + epv->create_view = impl_Evolution_SummaryComponent_create_view; + epv->destroy_view = impl_Evolution_SummaryComponent_destroy_view; epv->configure = impl_Evolution_SummaryComponent_configure; vepv = &SummaryComponent_vepv; @@ -275,7 +326,7 @@ executive_summary_component_class_init (ExecutiveSummaryComponentClass *klass) object_class = GTK_OBJECT_CLASS (klass); object_class->destroy = executive_summary_component_destroy; - + parent_class = gtk_type_class (PARENT_TYPE); corba_class_init (); @@ -288,21 +339,20 @@ executive_summary_component_init (ExecutiveSummaryComponent *component) priv = g_new0 (ExecutiveSummaryComponentPrivate, 1); - priv->create_bonobo_view = NULL; - priv->create_html_view = NULL; + priv->create_view = NULL; priv->configure = NULL; priv->owner_client = NULL; priv->closure = NULL; - + + priv->id_to_view = g_hash_table_new (NULL, NULL); component->private = priv; } -void +static void executive_summary_component_construct (ExecutiveSummaryComponent *component, Evolution_SummaryComponent corba_object, - EvolutionServicesCreateBonoboViewFn create_bonobo, - EvolutionServicesCreateHtmlViewFn create_html, + EvolutionServicesCreateViewFn create_view, EvolutionServicesConfigureFn configure, void *closure) { @@ -315,16 +365,14 @@ executive_summary_component_construct (ExecutiveSummaryComponent *component, priv = component->private; - priv->create_bonobo_view = create_bonobo; - priv->create_html_view = create_html; + priv->create_view = create_view; priv->configure = configure; priv->closure = closure; } BonoboObject * -executive_summary_component_new (EvolutionServicesCreateBonoboViewFn create_bonobo, - EvolutionServicesCreateHtmlViewFn create_html, +executive_summary_component_new (EvolutionServicesCreateViewFn create_view, EvolutionServicesConfigureFn configure, void *closure) { @@ -341,8 +389,7 @@ executive_summary_component_new (EvolutionServicesCreateBonoboViewFn create_bono servant); executive_summary_component_construct (component, corba_object, - create_bonobo, create_html, - configure, closure); + create_view, configure, closure); return BONOBO_OBJECT (component); } @@ -353,9 +400,11 @@ E_MAKE_TYPE (executive_summary_component, "ExecutiveSummaryComponent", void executive_summary_component_set_title (ExecutiveSummaryComponent *component, - const char *title) + gpointer view) { ExecutiveSummaryComponentPrivate *priv; + int id; + const char *title; g_return_if_fail (component != NULL); g_return_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT (component)); @@ -367,14 +416,19 @@ executive_summary_component_set_title (ExecutiveSummaryComponent *component, return; } - executive_summary_client_set_title (priv->owner_client, component, - title); + id = executive_summary_component_view_get_id (EXECUTIVE_SUMMARY_COMPONENT_VIEW (view)); + title = executive_summary_component_view_get_title (EXECUTIVE_SUMMARY_COMPONENT_VIEW (view)); + + executive_summary_client_set_title (priv->owner_client, id, title); } void -executive_summary_component_flash (ExecutiveSummaryComponent *component) +executive_summary_component_set_icon (ExecutiveSummaryComponent *component, + gpointer view) { ExecutiveSummaryComponentPrivate *priv; + int id; + const char *icon; g_return_if_fail (component != NULL); g_return_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT (component)); @@ -386,14 +440,41 @@ executive_summary_component_flash (ExecutiveSummaryComponent *component) return; } - executive_summary_client_flash (priv->owner_client, component); + id = executive_summary_component_view_get_id (EXECUTIVE_SUMMARY_COMPONENT_VIEW (view)); + icon = executive_summary_component_view_get_icon (EXECUTIVE_SUMMARY_COMPONENT_VIEW (view)); + + executive_summary_client_set_icon (priv->owner_client, id, icon); +} + +void +executive_summary_component_flash (ExecutiveSummaryComponent *component, + gpointer view) +{ + ExecutiveSummaryComponentPrivate *priv; + int id; + + g_return_if_fail (component != NULL); + g_return_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT (component)); + + priv = component->private; + + if (priv->owner_client == NULL) { + g_warning ("Component not owned!"); + return; + } + + id = executive_summary_component_view_get_id (EXECUTIVE_SUMMARY_COMPONENT_VIEW (view)); + + executive_summary_client_flash (priv->owner_client, id); } void executive_summary_component_update (ExecutiveSummaryComponent *component, - char *html) + gpointer view) { ExecutiveSummaryComponentPrivate *priv; + int id; + const char *html; g_return_if_fail (component != NULL); g_return_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT (component)); @@ -405,5 +486,17 @@ executive_summary_component_update (ExecutiveSummaryComponent *component, return; } - executive_summary_client_update (priv->owner_client, component, html); + id = executive_summary_component_view_get_id (EXECUTIVE_SUMMARY_COMPONENT_VIEW (view)); + html = executive_summary_component_view_get_html (EXECUTIVE_SUMMARY_COMPONENT_VIEW (view)); + + executive_summary_client_update (priv->owner_client, id, html); +} + +int +executive_summary_component_create_unique_id (void) +{ + static int id = 0; + + id++; + return id; } diff --git a/executive-summary/evolution-services/executive-summary-component.h b/executive-summary/evolution-services/executive-summary-component.h index 3cf5dade19..7d5ab904cc 100644 --- a/executive-summary/evolution-services/executive-summary-component.h +++ b/executive-summary/evolution-services/executive-summary-component.h @@ -37,14 +37,10 @@ typedef struct _ExecutiveSummaryComponentPrivate ExecutiveSummaryComponentPrivat typedef struct _ExecutiveSummaryComponent ExecutiveSummaryComponent; typedef struct _ExecutiveSummaryComponentClass ExecutiveSummaryComponentClass; -typedef BonoboObject *(* EvolutionServicesCreateBonoboViewFn) (ExecutiveSummaryComponent *component, - char **title, - char **icon, - void *closure); -typedef char *(* EvolutionServicesCreateHtmlViewFn) (ExecutiveSummaryComponent *component, - char **title, - char **icon, - void *closure); +/* view is a ExecutiveSummaryComponentView * */ +typedef void (* EvolutionServicesCreateViewFn) (ExecutiveSummaryComponent *component, + gpointer view, + void *closure); typedef void (* EvolutionServicesConfigureFn) (ExecutiveSummaryComponent *component, void *closure); @@ -60,13 +56,18 @@ struct _ExecutiveSummaryComponentClass { GtkType executive_summary_component_get_type (void); -BonoboObject *executive_summary_component_new (EvolutionServicesCreateBonoboViewFn create_bonobo, - EvolutionServicesCreateHtmlViewFn create_html, +BonoboObject *executive_summary_component_new (EvolutionServicesCreateViewFn create_view, EvolutionServicesConfigureFn configure, void *closure); void executive_summary_component_set_title (ExecutiveSummaryComponent *component, - const char *title); -void executive_summary_component_flash (ExecutiveSummaryComponent *component); + gpointer view); +void executive_summary_component_set_icon (ExecutiveSummaryComponent *component, + gpointer view); + +void executive_summary_component_flash (ExecutiveSummaryComponent *component, + gpointer view); void executive_summary_component_update (ExecutiveSummaryComponent *component, - char *html); + gpointer view); +int executive_summary_component_create_unique_id (void); + #endif diff --git a/executive-summary/evolution-services/executive-summary.c b/executive-summary/evolution-services/executive-summary.c index f3e36f1735..f8a0f7ecf8 100644 --- a/executive-summary/evolution-services/executive-summary.c +++ b/executive-summary/evolution-services/executive-summary.c @@ -38,14 +38,19 @@ static void executive_summary_init (ExecutiveSummary *es); #define PARENT_TYPE (bonobo_object_get_type ()) +enum { + UPDATE, + SET_TITLE, + SET_ICON, + FLASH, + LAST_SIGNAL +}; + +static guint32 summary_signals [LAST_SIGNAL] = { 0 }; static BonoboObjectClass *parent_class; struct _ExecutiveSummaryPrivate { - EvolutionServicesSetTitleFn set_title; - EvolutionServicesFlashFn flash; - EvolutionServicesUpdateFn update; - - void *closure; + int dummy; }; /* CORBA interface implementation */ @@ -76,53 +81,64 @@ create_servant (void) static void impl_Evolution_Summary_set_title (PortableServer_Servant servant, - const Evolution_SummaryComponent component, + CORBA_long id, const CORBA_char *title, CORBA_Environment *ev) { BonoboObject *bonobo_object; ExecutiveSummary *summary; - ExecutiveSummaryPrivate *priv; bonobo_object = bonobo_object_from_servant (servant); summary = EXECUTIVE_SUMMARY (bonobo_object); - priv = summary->private; - (* priv->set_title) (summary, component, title, priv->closure); + gtk_signal_emit (GTK_OBJECT (summary), summary_signals[SET_TITLE], + id, title); +} + +static void +impl_Evolution_Summary_set_icon (PortableServer_Servant servant, + CORBA_long id, + const CORBA_char *title, + CORBA_Environment *ev) +{ + BonoboObject *bonobo_object; + ExecutiveSummary *summary; + + bonobo_object = bonobo_object_from_servant (servant); + summary = EXECUTIVE_SUMMARY (bonobo_object); + + gtk_signal_emit (GTK_OBJECT (summary), summary_signals[SET_ICON], + id, title); } static void impl_Evolution_Summary_flash (PortableServer_Servant servant, - const Evolution_SummaryComponent component, + CORBA_long id, CORBA_Environment *ev) { BonoboObject *bonobo_object; ExecutiveSummary *summary; - ExecutiveSummaryPrivate *priv; bonobo_object = bonobo_object_from_servant (servant); summary = EXECUTIVE_SUMMARY (bonobo_object); - priv = summary->private; - (* priv->flash) (summary, component, priv->closure); + gtk_signal_emit (GTK_OBJECT (summary), summary_signals[FLASH], id); } static void -impl_Evolution_Summary_update_html_component (PortableServer_Servant servant, - const Evolution_SummaryComponent component, - CORBA_char *html, - CORBA_Environment *ev) +impl_Evolution_Summary_update_component (PortableServer_Servant servant, + CORBA_long id, + CORBA_char *html, + CORBA_Environment *ev) { BonoboObject *bonobo_object; ExecutiveSummary *summary; - ExecutiveSummaryPrivate *priv; - struct _queuedata *qd; bonobo_object = bonobo_object_from_servant (servant); summary = EXECUTIVE_SUMMARY (bonobo_object); - priv = summary->private; - (*priv->update) (summary, component, html, priv->closure); + gtk_signal_emit (GTK_OBJECT (summary), summary_signals[UPDATE], + id, html); } /* GtkObject methods */ @@ -158,8 +174,9 @@ corba_class_init (void) epv = g_new0 (POA_Evolution_Summary__epv, 1); epv->set_title = impl_Evolution_Summary_set_title; + epv->set_icon = impl_Evolution_Summary_set_icon; epv->flash = impl_Evolution_Summary_flash; - epv->update_html_component = impl_Evolution_Summary_update_html_component; + epv->update_component = impl_Evolution_Summary_update_component; vepv = &Summary_vepv; vepv->_base_epv = base_epv; @@ -177,6 +194,40 @@ executive_summary_class_init (ExecutiveSummaryClass *es_class) object_class->destroy = executive_summary_destroy; parent_class = gtk_type_class (PARENT_TYPE); + + summary_signals[UPDATE] = gtk_signal_new ("update", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ExecutiveSummaryClass, update), + gtk_marshal_NONE__POINTER_POINTER, + GTK_TYPE_NONE, 2, + GTK_TYPE_POINTER, + GTK_TYPE_POINTER); + summary_signals[SET_TITLE] = gtk_signal_new ("set_title", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ExecutiveSummaryClass, set_title), + gtk_marshal_NONE__POINTER_POINTER, + GTK_TYPE_NONE, 2, + GTK_TYPE_POINTER, + GTK_TYPE_POINTER); + summary_signals[SET_ICON] = gtk_signal_new ("set_icon", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ExecutiveSummaryClass, set_icon), + gtk_marshal_NONE__POINTER_POINTER, + GTK_TYPE_NONE, 2, + GTK_TYPE_POINTER, + GTK_TYPE_POINTER); + summary_signals[FLASH] = gtk_signal_new ("flash", + GTK_RUN_LAST, + object_class->type, + GTK_SIGNAL_OFFSET (ExecutiveSummaryClass, flash), + gtk_marshal_NONE__POINTER, + GTK_TYPE_NONE, 1, + GTK_TYPE_POINTER); + gtk_object_class_add_signals (object_class, summary_signals, LAST_SIGNAL); + corba_class_init (); } @@ -184,13 +235,9 @@ static void executive_summary_init (ExecutiveSummary *es) { ExecutiveSummaryPrivate *priv; - - priv = g_new0 (ExecutiveSummaryPrivate, 1); - es->private = priv; - priv->set_title = NULL; - priv->flash = NULL; - priv->closure = NULL; + priv = g_new (ExecutiveSummaryPrivate, 1); + es->private = priv; } E_MAKE_TYPE (executive_summary, "ExecutiveSummary", ExecutiveSummary, @@ -198,28 +245,13 @@ E_MAKE_TYPE (executive_summary, "ExecutiveSummary", ExecutiveSummary, void executive_summary_construct (ExecutiveSummary *es, - Evolution_Summary corba_object, - EvolutionServicesSetTitleFn set_title, - EvolutionServicesFlashFn flash, - EvolutionServicesUpdateFn update, - void *closure) + Evolution_Summary corba_object) { - ExecutiveSummaryPrivate *priv; - bonobo_object_construct (BONOBO_OBJECT (es), corba_object); - - priv = es->private; - priv->set_title = set_title; - priv->flash = flash; - priv->update = update; - priv->closure = closure; } BonoboObject * -executive_summary_new (EvolutionServicesSetTitleFn set_title, - EvolutionServicesFlashFn flash, - EvolutionServicesUpdateFn update, - void *closure) +executive_summary_new (void) { POA_Evolution_Summary *servant; Evolution_Summary corba_object; @@ -233,10 +265,7 @@ executive_summary_new (EvolutionServicesSetTitleFn set_title, corba_object = bonobo_object_activate_servant (BONOBO_OBJECT (es), servant); - executive_summary_construct (es, corba_object, set_title, flash, - update, closure); + executive_summary_construct (es, corba_object); return BONOBO_OBJECT (es); -} - - +} diff --git a/executive-summary/evolution-services/executive-summary.h b/executive-summary/evolution-services/executive-summary.h index e2d5557d69..4f6b959a9c 100644 --- a/executive-summary/evolution-services/executive-summary.h +++ b/executive-summary/evolution-services/executive-summary.h @@ -38,38 +38,30 @@ typedef struct _ExecutiveSummaryPrivate ExecutiveSummaryPrivate; typedef struct _ExecutiveSummary ExecutiveSummary; typedef struct _ExecutiveSummaryClass ExecutiveSummaryClass; -typedef void (* EvolutionServicesSetTitleFn) (ExecutiveSummary *summary, - const Evolution_SummaryComponent component, - const char *title, - void *closure); -typedef void (* EvolutionServicesFlashFn) (ExecutiveSummary *summary, - const Evolution_SummaryComponent component, - void *closure); -typedef void (* EvolutionServicesUpdateFn) (ExecutiveSummary *summary, - const Evolution_SummaryComponent component, - const char *html, - void *closure); - struct _ExecutiveSummary { - BonoboObject parent; - - ExecutiveSummaryPrivate *private; + BonoboObject parent; + + ExecutiveSummaryPrivate *private; }; struct _ExecutiveSummaryClass { - BonoboObjectClass parent_class; + BonoboObjectClass parent_class; + + void (* update) (ExecutiveSummary *summary, + const Evolution_SummaryComponent component, + const char *html); + void (* set_title) (ExecutiveSummary *summary, + const Evolution_SummaryComponent component, + const char *title); + void (* set_icon) (ExecutiveSummary *summary, + const Evolution_SummaryComponent component, + const char *icon); + void (* flash) (ExecutiveSummary *summary, + const Evolution_SummaryComponent component); }; GtkType executive_summary_get_type (void); void executive_summary_construct (ExecutiveSummary *es, - Evolution_Summary corba_object, - EvolutionServicesSetTitleFn set_title, - EvolutionServicesFlashFn flash, - EvolutionServicesUpdateFn update, - void *closure); -BonoboObject *executive_summary_new (EvolutionServicesSetTitleFn set_title, - EvolutionServicesFlashFn flash, - EvolutionServicesUpdateFn update, - void *closure); - + Evolution_Summary corba_object); +BonoboObject *executive_summary_new (void); #endif |