aboutsummaryrefslogtreecommitdiffstats
path: root/executive-summary
diff options
context:
space:
mode:
Diffstat (limited to 'executive-summary')
-rw-r--r--executive-summary/ChangeLog52
-rw-r--r--executive-summary/component/Makefile.am6
-rw-r--r--executive-summary/component/e-summary-factory.c64
-rw-r--r--executive-summary/component/e-summary.c171
-rw-r--r--executive-summary/component/e-summary.h4
-rw-r--r--executive-summary/evolution-services/Makefile.am8
-rw-r--r--executive-summary/evolution-services/executive-summary-client.c41
-rw-r--r--executive-summary/evolution-services/executive-summary-client.h17
-rw-r--r--executive-summary/evolution-services/executive-summary-component-client.c71
-rw-r--r--executive-summary/evolution-services/executive-summary-component-client.h2
-rw-r--r--executive-summary/evolution-services/executive-summary-component-view.c345
-rw-r--r--executive-summary/evolution-services/executive-summary-component-view.h83
-rw-r--r--executive-summary/evolution-services/executive-summary-component.c171
-rw-r--r--executive-summary/evolution-services/executive-summary-component.h27
-rw-r--r--executive-summary/evolution-services/executive-summary.c129
-rw-r--r--executive-summary/evolution-services/executive-summary.h44
-rw-r--r--executive-summary/idl/Summary.idl14
-rw-r--r--executive-summary/idl/SummaryComponent.idl38
-rw-r--r--executive-summary/test-service/Makefile.am2
-rw-r--r--executive-summary/test-service/main.c242
20 files changed, 1136 insertions, 395 deletions
diff --git a/executive-summary/ChangeLog b/executive-summary/ChangeLog
index e9878fa0aa..d74512d3f3 100644
--- a/executive-summary/ChangeLog
+++ b/executive-summary/ChangeLog
@@ -1,3 +1,55 @@
+2000-10-25 Iain Holmes <iain@helixcode.com>
+
+ * test-service/main.c: Store each individual views data with the view.
+ Add comments to explain everything.
+
+ * evolution-services/executive-summary-component.c
+ (impl_Evolution_SummaryComponent_create_view): Only try to create a
+ control if the returned control != NULL.
+
+2000-10-25 Iain Holmes <iain@helixcode.com>
+
+ * evolution-services/executive-summary-component.c
+ (impl_Evolution_SummaryComponent_create_view): Set the UID of the view
+ before passing it to the create_view method.
+
+2000-10-25 Iain Holmes <iain@helixcode.com>
+
+ * idl/Summary.idl: Added set_icon method, and changed update_html_component
+ to update_component. Made all methods take a long ID instead of an
+ SummaryComponent.
+
+ * idl/SummaryComponent.idl: Combined the create_bonobo_view and
+ create_html_view into create_view.
+ Added a destroy_view method.
+
+ * evolution-services/Makefile.am: Added the 2 new files.
+
+ * evolution-services/executive-summary-component-view.[ch]: New
+ files implementing a view of an ExecutiveSummaryComponent.
+
+ * evolution-services/executive-summary.[ch]
+ * evolution-services/executive-summary-client.[ch]
+ * evolution-services/executive-summary-component.[ch]
+ * evolution-services/executive-summary-component-client.[ch]:
+ * component/e-summary-factory.c
+ * component/e-summary.c
+ * test-service/main.c:
+ Updated to use new methods and the new ExecutiveSummaryComponentView
+ object.
+
+2000-10-16 Iain Holmes <iain@helixcode.com>
+
+ * evolution-services/executive-summary.c (executive_summary_class_init):
+ Implement the update, set_title and flash functionality as signals
+ instead of methods.
+ (impl_Evolution_Summary_set_title): Emit signal.
+ (impl_Evolution_Summary_flash): Emit signal.
+ (impl_Evolution_Summary_update_html_component): Emit signal.
+ (executive_summary_new): Don't need the methods anymore.
+ (executive_summary_construct): Same.
+ (executive_summary_init): Remove the private initialisation.
+
2000-10-23 Dan Winship <danw@helixcode.com>
* idl/Makefile.am (INCLUDES):
diff --git a/executive-summary/component/Makefile.am b/executive-summary/component/Makefile.am
index 334069a76b..0731ff40ca 100644
--- a/executive-summary/component/Makefile.am
+++ b/executive-summary/component/Makefile.am
@@ -6,10 +6,8 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir)/shell \
-I$(top_srcdir)/shell \
- -I$(top_builddir)/executive-summary/evolution-services \
- -I$(top_srcdir)/executive-summary/evolution-services \
- -I$(top_builddir)/executive-summary/widdets \
- -I$(top_srcdir)/executive-summary/widgets \
+ -I$(top_builddir)/executive-summary \
+ -I$(top_srcdir)/executive-summary/ \
$(EXTRA_GNOME_CFLAGS) \
$(GNOME_VFS_CFLAGS) \
$(UNICODE_CFLAGS) \
diff --git a/executive-summary/component/e-summary-factory.c b/executive-summary/component/e-summary-factory.c
index c0d0dd5ed4..9eebb82e8d 100644
--- a/executive-summary/component/e-summary-factory.c
+++ b/executive-summary/component/e-summary-factory.c
@@ -42,27 +42,16 @@
#include "e-summary.h"
#include "Evolution.h"
-#include <executive-summary-component-client.h>
-#include <Executive-Summary.h>
-
-#include <executive-summary.h>
-#include <executive-summary-component.h>
+#include <evolution-services/executive-summary-component-client.h>
+#include <evolution-services/Executive-Summary.h>
+#include <evolution-services/executive-summary.h>
+#include <evolution-services/executive-summary-component.h>
+#include <evolution-services/executive-summary-component-view.h>
static GList *control_list = NULL;
GtkWidget* embed_service (GtkWidget *widget,
ESummary *esummary);
-static void update (ExecutiveSummary *summary,
- const Evolution_SummaryComponent component,
- const char *html,
- ESummary *esummary);
-static void set_title (ExecutiveSummary *summary,
- const Evolution_SummaryComponent component,
- const char *title,
- void *closure);
-static void flash (ExecutiveSummary *summary,
- const Evolution_SummaryComponent component,
- void *closure);
BonoboUIVerb verbs[] = {
BONOBO_UI_UNSAFE_VERB ("AddService", embed_service),
@@ -153,30 +142,47 @@ control_destroy_cb (BonoboControl *control,
static void
update (ExecutiveSummary *summary,
- const Evolution_SummaryComponent component,
+ int id,
const char *html,
ESummary *esummary)
{
+ ExecutiveSummaryComponentView *view;
+ g_print ("OI!\n");
+
+ view = e_summary_view_from_id (esummary, id);
+ executive_summary_component_view_set_html (view, html);
e_summary_update_window (esummary, summary, html);
}
static void
set_title (ExecutiveSummary *summary,
- const Evolution_SummaryComponent component,
+ int id,
const char *title,
- void *closure)
+ gpointer user_data)
{
g_print ("Setting title to %s\n", title);
}
static void
flash (ExecutiveSummary *summary,
- const Evolution_SummaryComponent component,
- void *closure)
+ int id,
+ gpointer user_data)
{
g_print ("FLASH!\n");
}
+static void
+view_destroyed (ExecutiveSummaryComponentView *view,
+ ExecutiveSummaryComponentClient *client)
+{
+ int id;
+
+ g_print ("%s\n", __FUNCTION__);
+ id = executive_summary_component_view_get_id (view);
+ g_print ("%d\n", id);
+ executive_summary_component_client_destroy_view (client, view);
+}
+
/* A ********very********
temporary function to embed something
*/
@@ -186,6 +192,7 @@ embed_service (GtkWidget *widget,
{
ExecutiveSummaryComponentClient *client;
ExecutiveSummary *summary;
+ ExecutiveSummaryComponentView *view;
char *required_interfaces[2] = {"IDL:Evolution:SummaryComponent:1.0",
NULL};
char *obj_id;
@@ -204,14 +211,21 @@ embed_service (GtkWidget *widget,
return NULL;
/* Set the owner */
- summary = executive_summary_new (set_title, flash, update, esummary);
+ summary = executive_summary_new ();
executive_summary_component_client_set_owner (client, summary);
+ gtk_signal_connect (GTK_OBJECT (summary), "flash",
+ GTK_SIGNAL_FUNC (flash), NULL);
+ gtk_signal_connect (GTK_OBJECT (summary), "set_title",
+ GTK_SIGNAL_FUNC (set_title), NULL);
+ gtk_signal_connect (GTK_OBJECT (summary), "update",
+ GTK_SIGNAL_FUNC (update), esummary);
/* Create view */
- html = executive_summary_component_client_create_html_view (client, &title, &icon);
- e_summary_add_html_service (esummary, summary, client, html, title, icon);
- g_free (html);
+ view = executive_summary_component_client_create_view (client);
+ gtk_signal_connect (GTK_OBJECT (view), "destroy",
+ GTK_SIGNAL_FUNC (view_destroyed), client);
+ e_summary_add_service (esummary, summary, view);
e_summary_rebuild_page (esummary);
return NULL;
}
diff --git a/executive-summary/component/e-summary.c b/executive-summary/component/e-summary.c
index 1ece837ada..e7cbc4b6e6 100644
--- a/executive-summary/component/e-summary.c
+++ b/executive-summary/component/e-summary.c
@@ -32,10 +32,10 @@
#include <gtkhtml/gtkhtml-stream.h>
#include <gtk/gtkvbox.h>
#include <gal/util/e-util.h>
-#include <e-summary-subwindow.h>
-#include <executive-summary.h>
-#include <executive-summary-component-client.h>
+#include <evolution-services/executive-summary.h>
+#include <evolution-services/executive-summary-component-client.h>
+#include <evolution-services/executive-summary-component-view.h>
#include <libgnomevfs/gnome-vfs.h>
#include "e-summary.h"
@@ -48,6 +48,7 @@ struct _ESummaryPrivate {
GtkWidget *html_scroller;
GtkWidget *html;
+ GHashTable *id_to_view;
GHashTable *summary_to_window;
GList *window_list;
@@ -56,21 +57,9 @@ struct _ESummaryPrivate {
GtkHTMLStream *stream;
};
-typedef enum {
- E_SUMMARY_WINDOW_BONOBO,
- E_SUMMARY_WINDOW_HTML
-} ESummaryWindowType;
-
typedef struct _ESummaryWindow {
ExecutiveSummary *summary;
- ExecutiveSummaryComponentClient *client;
- char *title;
- char *icon;
-
- ESummaryWindowType type;
-
- char *html;
- GtkWidget *control;
+ ExecutiveSummaryComponentView *view;
} ESummaryWindow;
static gboolean on_object_requested (GtkHTML *html,
@@ -86,6 +75,7 @@ s2w_foreach (gpointer *key,
gpointer *value,
ESummaryPrivate *priv)
{
+ g_print ("%s\n", __FUNCTION__);
e_summary_window_free ((ESummaryWindow *) value, priv);
g_free (value);
}
@@ -95,7 +85,8 @@ e_summary_destroy (GtkObject *object)
{
ESummary *esummary = E_SUMMARY (object);
ESummaryPrivate *priv;
-
+
+ g_print ("Destroy\n");
priv = esummary->private;
if (priv == NULL)
return;
@@ -103,6 +94,7 @@ e_summary_destroy (GtkObject *object)
g_hash_table_foreach (priv->summary_to_window,
s2w_foreach, priv);
g_hash_table_destroy (priv->summary_to_window);
+ g_hash_table_destroy (priv->id_to_view);
g_free (esummary->private);
esummary->private = NULL;
@@ -218,7 +210,7 @@ static void
e_summary_start_load (ESummary *summary)
{
ESummaryPrivate *priv;
- char *header = "<html><body>";
+ char *header = "<html><body bgcolor=\"#ffffff\">";
priv = summary->private;
priv->stream = gtk_html_begin (GTK_HTML (priv->html));
@@ -273,12 +265,12 @@ e_summary_init (ESummary *esummary)
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
priv->html = gtk_html_new ();
gtk_html_set_editable (GTK_HTML (priv->html), FALSE);
+ gtk_html_set_default_background_color (GTK_HTML (priv->html), &bgcolour);
gtk_signal_connect (GTK_OBJECT (priv->html), "url-requested",
GTK_SIGNAL_FUNC (request_cb), NULL);
gtk_signal_connect (GTK_OBJECT (priv->html), "object-requested",
GTK_SIGNAL_FUNC (on_object_requested), esummary);
- gtk_html_set_default_background_color (GTK_HTML (priv->html), &bgcolour);
gtk_container_add (GTK_CONTAINER (priv->html_scroller), priv->html);
gtk_widget_show_all (priv->html_scroller);
@@ -288,8 +280,9 @@ e_summary_init (ESummary *esummary)
gtk_box_pack_start (GTK_BOX (esummary), priv->html_scroller,
TRUE, TRUE, 0);
- /* Init hashtable */
+ /* Init hashtables */
priv->summary_to_window = g_hash_table_new (NULL, NULL);
+ priv->id_to_view = g_hash_table_new (NULL, NULL);
}
E_MAKE_TYPE (e_summary, "ESummary", ESummary, e_summary_class_init,
@@ -324,15 +317,7 @@ on_object_requested (GtkHTML *html,
break;
case 2:
- gtk_widget_show (window->control);
-
- gtk_widget_ref (GTK_WIDGET (window->control));
- if (window->control->parent != NULL) {
- gtk_container_remove (GTK_CONTAINER (window->control->parent), window->control);
- }
- gtk_container_add (GTK_CONTAINER (eb), window->control);
-
- gtk_widget_unref (GTK_WIDGET (window->control));
+ g_warning ("Bonobo services are not supported in this version.");
break;
default:
@@ -349,46 +334,45 @@ e_summary_display_window (ESummary *esummary,
{
ESummaryPrivate *priv;
char *footer = "</td></tr></table>";
- char *title_cid, *body_cid;
+ char *title_html;
char *colour[2] = {"e6e8e4",
"edeeeb"};
char *title_colour[2] = {"bac1b6",
"cdd1c7"};
+ const char *title, *icon, *html;
priv = esummary->private;
+ title = executive_summary_component_view_get_title (window->view);
+ icon = executive_summary_component_view_get_icon (window->view);
+ html = executive_summary_component_view_get_html (window->view);
+
/** FIXME: Make this faster by caching it? */
- title_cid = g_strdup_printf ("<table cellspacing=\"0\" "
- "cellpadding=\"0\" border=\"0\" width=\"100%%\" height=\"100%%\">"
- "<tr><td bgcolor=\"#%s\">"
- "<table width=\"100%%\"><tr><td>"
- "<img src=\"%s\"></td>"
- "<td nowrap align=\"center\" width=\"100%%\">"
- "<b>%s</b></td></tr></table></td></tr><tr>"
- "<td bgcolor=\"#%s\" height=\"100%%\">",
- title_colour[col % 2],
- window->icon,
- window->title,
- colour[col % 2]);
-
- gtk_html_write (GTK_HTML (priv->html), priv->stream, title_cid,
- strlen (title_cid));
- g_free (title_cid);
+ title_html = g_strdup_printf ("<table cellspacing=\"0\" "
+ "cellpadding=\"0\" border=\"0\" width=\"100%%\" height=\"100%%\">"
+ "<tr><td bgcolor=\"#%s\">"
+ "<table width=\"100%%\"><tr><td>"
+ "<img src=\"%s\"></td>"
+ "<td nowrap align=\"center\" width=\"100%%\">"
+ "<b>%s</b></td></tr></table></td></tr><tr>"
+ "<td bgcolor=\"#%s\" height=\"100%%\">",
+ title_colour[col % 2], icon, title,
+ colour[col % 2]);
+
+ gtk_html_write (GTK_HTML (priv->html), priv->stream, title_html,
+ strlen (title_html));
+ g_free (title_html);
- switch (window->type) {
- case E_SUMMARY_WINDOW_HTML:
+ if (html != NULL && *html != '\0') {
gtk_html_write (GTK_HTML (priv->html), priv->stream,
- window->html, strlen (window->html));
- break;
-
- case E_SUMMARY_WINDOW_BONOBO:
+ html, strlen (html));
+ } else {
+ g_warning ("Bonobo executive summary components are not supported at this time.");
+#if 0
body_cid = g_strdup_printf ("<object classid=\"cid:2-%p\"></object>", window);
gtk_html_write (GTK_HTML (priv->html), priv->stream,
body_cid, strlen (body_cid));
- break;
-
- default:
- break;
+#endif
}
gtk_html_write (GTK_HTML (priv->html), priv->stream,
@@ -451,6 +435,37 @@ e_summary_rebuild_page (ESummary *esummary)
}
void
+e_summary_add_service (ESummary *esummary,
+ ExecutiveSummary *summary,
+ ExecutiveSummaryComponentView *view)
+{
+ ESummaryWindow *window;
+ ESummaryPrivate *priv;
+ int id;
+
+ g_return_if_fail (esummary != NULL);
+ g_return_if_fail (IS_E_SUMMARY (esummary));
+ g_return_if_fail (summary != NULL);
+ g_return_if_fail (IS_EXECUTIVE_SUMMARY (summary));
+ g_return_if_fail (view != NULL);
+ g_return_if_fail (IS_EXECUTIVE_SUMMARY_COMPONENT_VIEW (view));
+
+ window = g_new0 (ESummaryWindow, 1);
+ window->summary = summary;
+
+ window->view = view;
+
+ priv = esummary->private;
+ priv->window_list = g_list_append (priv->window_list, window);
+ g_hash_table_insert (priv->summary_to_window, summary, window);
+
+ id = executive_summary_component_view_get_id (view);
+ g_print ("--%d: %p\n", id, view);
+ g_hash_table_insert (priv->id_to_view, GINT_TO_POINTER (id), view);
+}
+
+#if 0
+void
e_summary_add_html_service (ESummary *esummary,
ExecutiveSummary *summary,
ExecutiveSummaryComponentClient *client,
@@ -501,22 +516,17 @@ e_summary_add_bonobo_service (ESummary *esummary,
g_hash_table_insert (priv->summary_to_window, summary, window);
}
+#endif
static void
e_summary_window_free (ESummaryWindow *window,
ESummaryPrivate *priv)
{
- g_free (window->title);
- g_free (window->icon);
- if (window->type == E_SUMMARY_WINDOW_BONOBO)
- gtk_widget_unref (window->control);
- else
- g_free (window->html);
-
+ g_print ("%s\n", __FUNCTION__);
priv->window_list = g_list_remove (priv->window_list, window);
bonobo_object_unref (BONOBO_OBJECT (window->summary));
- bonobo_object_unref (BONOBO_OBJECT (window->client));
+ gtk_object_unref (GTK_OBJECT (window->view));
}
/* Call this before e_summary_window_free, execpt when you are freeing
@@ -533,25 +543,34 @@ e_summary_update_window (ESummary *esummary,
ExecutiveSummary *summary,
const char *html)
{
- ESummaryWindow *window;
ESummaryPrivate *priv;
-
+
g_return_if_fail (esummary != NULL);
g_return_if_fail (IS_E_SUMMARY (esummary));
g_return_if_fail (summary != NULL);
-
+
priv = esummary->private;
+
+ if (priv->idle != 0)
+ return;
+
+ priv->idle = g_idle_add (e_summary_rebuild_page, esummary);
+}
- window = g_hash_table_lookup (priv->summary_to_window, summary);
-
- g_return_if_fail (window != NULL);
+ExecutiveSummaryComponentView *
+e_summary_view_from_id (ESummary *esummary,
+ int id)
+{
+ ESummaryPrivate *priv;
+ ExecutiveSummaryComponentView *view;
- g_free (window->html);
- window->html = g_strdup (html);
+ g_return_val_if_fail (esummary != NULL, NULL);
+ g_return_val_if_fail (IS_E_SUMMARY (esummary), NULL);
+ g_return_val_if_fail (id > 0, NULL);
- if (priv->idle != 0)
- return;
+ priv = esummary->private;
+ view = g_hash_table_lookup (priv->id_to_view, GINT_TO_POINTER (id));
- priv->idle = g_idle_add (e_summary_rebuild_page, esummary);
+ g_print ("%d: %p\n", id, view);
+ return view;
}
-
diff --git a/executive-summary/component/e-summary.h b/executive-summary/component/e-summary.h
index 02deb8c7a8..569cae3331 100644
--- a/executive-summary/component/e-summary.h
+++ b/executive-summary/component/e-summary.h
@@ -27,8 +27,8 @@
#include <gtk/gtksignal.h>
#include <gtkhtml/gtkhtml.h>
#include <gtk/gtkvbox.h>
-#include <executive-summary.h>
-#include <executive-summary-component-client.h>
+#include <evolution-services/executive-summary.h>
+#include <evolution-services/executive-summary-component-client.h>
#include "shell/Evolution.h"
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
diff --git a/executive-summary/idl/Summary.idl b/executive-summary/idl/Summary.idl
index 59f13910b3..76f98dd537 100644
--- a/executive-summary/idl/Summary.idl
+++ b/executive-summary/idl/Summary.idl
@@ -11,8 +11,6 @@
#include <Bonobo.idl>
module Evolution {
- interface SummaryComponent;
-
interface Summary: Bonobo::Unknown {
exception NoSubWindow {};
@@ -24,17 +22,21 @@ module Evolution {
* Sets the title of the subwindow that displays @component
* to @title
*/
- void set_title (in SummaryComponent component,
+ void set_title (in long id,
in string title)
raises (NoSubWindow);
+ void set_icon (in long id,
+ in string icon)
+ raises (NoSubWindow);
+
/**
* flash:
* @component: The SummaryComponent that owns a subwindow.
*
* Flashes the subwindow that displays @component.
*/
- void flash (in SummaryComponent component)
+ void flash (in long id)
raises (NoSubWindow);
/**
@@ -45,8 +47,8 @@ module Evolution {
* Requests that the html that displays @component is changed
* to @html.
*/
- void update_html_component (in SummaryComponent component,
- in string html)
+ void update_component (in long id,
+ in string html)
raises (NoSubWindow);
};
};
diff --git a/executive-summary/idl/SummaryComponent.idl b/executive-summary/idl/SummaryComponent.idl
index 55f7b6426d..6cf04b3a01 100644
--- a/executive-summary/idl/SummaryComponent.idl
+++ b/executive-summary/idl/SummaryComponent.idl
@@ -1,9 +1,9 @@
/*-*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
- * CORBA interface for the Evolution shell.
+ * CORBA interface for the Evolution Executive Summary Components.
*
* Authors:
- * Ettore Perazzoli <ettore@helixcode.com>
+ * Iain Holmes <iain@helixcode.com>
*
* Copyright (C) 2000 Helix Code, Inc.
*/
@@ -18,17 +18,6 @@ module Evolution {
interface SummaryComponent: Bonobo::Unknown {
/**
- * supports:
- * @html: Does it support HTML?
- * @bonobo: Does it support Bonobo Controls?
- *
- * Sets the @html and @bonobo arguments to TRUE
- * if the component supports that type of
- * embedding
- */
- void supports (out boolean bonobo, out boolean html);
-
- /**
* set_owner:
* @summary: A Summary object.
*
@@ -45,15 +34,26 @@ module Evolution {
/**
* create_view:
- *
+ * @control: A Bonobo_Control
+ * @html: HTML of the view.
+ * @title: Title of the view.
+ * @icon: Icon to be used for the view.
+ *
* Creates a summary of the data that the component has.
- * Returns: A @BonoboControl of the view.
+ * Returns: The ID of the view.
*/
- Bonobo::Control create_bonobo_view (out string title,
- out string icon);
+ long create_view (out Bonobo::Control control,
+ out string html,
+ out string title,
+ out string icon);
- string create_html_view (out string title,
- out string icon);
+ /**
+ * destroy_view:
+ * @id: ID of the view to be destroyed.
+ *
+ * Tells a service that a view has been destroyed.
+ */
+ void destroy_view (in long id);
/**
* configure:
diff --git a/executive-summary/test-service/Makefile.am b/executive-summary/test-service/Makefile.am
index 4604d89dfc..e294a3ea49 100644
--- a/executive-summary/test-service/Makefile.am
+++ b/executive-summary/test-service/Makefile.am
@@ -3,7 +3,7 @@ bin_PROGRAMS = test-service
CFLAGS += -g
INCLUDES = \
-I$(top_srcdir) \
- -I$(srcdir)/../evolution-services \
+ -I$(top_srcdir)/executive-summary \
$(EXTRA_GNOME_CFLAGS) \
$(BONOBO_HTML_GNOME_CFLAGS) \
$(UNICODE_CFLAGS)
diff --git a/executive-summary/test-service/main.c b/executive-summary/test-service/main.c
index 2f2fcb32b0..8612c2d394 100644
--- a/executive-summary/test-service/main.c
+++ b/executive-summary/test-service/main.c
@@ -1,146 +1,194 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* main.c
+ * Test Service that counts the number of seconds since it was started.
+ *
+ * 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 <gnome.h>
#include <bonobo.h>
-#include <executive-summary-component.h>
+
+#include <evolution-services/executive-summary-component.h>
+#include <evolution-services/executive-summary-component-view.h>
+
#include <liboaf/liboaf.h>
static int running_views = 0;
+struct userdata {
+ int i;
+};
+
#define TEST_SERVICE_ID "OAFIID:evolution-summary-component-factory:test-service:0ea887d5-622b-4b8c-b525-18aa1cbe18a6"
static BonoboGenericFactory *factory = NULL;
+/* The "do something interesting" function */
int
-clicked_cb (ExecutiveSummaryComponent *component)
+add_one (ExecutiveSummaryComponentView *view)
{
- static int i = 1;
- char *html;
-
-#if 0
- executive_summary_component_set_title (component, "Iain's title");
- executive_summary_component_flash (component);
-#endif
-
- html = g_strdup_printf ("Since you started this service<br><center>%d</center><br>seconds have passed.", i);
- executive_summary_component_update (component, html);
- i++;
-
- g_free (html);
- return TRUE;
+ char *html;
+ struct userdata *ud;
+
+ /* Get the user data from the view */
+ ud = gtk_object_get_data (GTK_OBJECT (view), "timer-data");
+ if (ud == NULL) {
+ g_warning ("No user data");
+ return FALSE;
+ }
+
+ /* Generate the new html */
+ html = g_strdup_printf ("Since you started this service<br>"
+ "<center>%d</center><br>seconds have passed.", ud->i);
+
+ /* Change the html on the view
+ which will tell the Executive Summary that something needs updating */
+ executive_summary_component_view_set_html (view, html);
+
+ /* executive_summary_component_view_set_html () makes a copy of the HTML
+ passed into it, so we don't need to keep it around */
+ g_free (html);
+
+ /* Do something "fun" */
+ ud->i++;
+
+ return TRUE;
}
void
-view_destroyed (GtkWidget *widget,
+view_destroyed (GtkObject *object,
gpointer data)
{
- g_print ("Destroying view: %d\n", running_views);
-
- gtk_main_quit ();
+ ExecutiveSummaryComponentView *view;
+ struct userdata *ud;
+ int id;
+
+ /* Free the user data for this view*/
+ ud = gtk_object_get_data (object, "timer-data");
+ gtk_object_set_data (object, "timer-data", NULL);
+ g_free (ud);
+
+ /* Remove one running view */
+ running_views--;
+
+ /* If there are no running views left, quit */
+ if (running_views <= 0)
+ gtk_main_quit ();
}
-static BonoboObject*
+/* Create the view:
+ HTML only */
+static void
create_view (ExecutiveSummaryComponent *component,
- char **title,
- char **icon,
+ ExecutiveSummaryComponentView *view,
void *closure)
{
- BonoboControl *control;
- GtkWidget *button;
-
- *title = g_strdup ("This is the test bonobo service");
- *icon = g_strdup ("gnome-clock.png");
-
- button = gtk_button_new_with_label ("A test service with a whole button");
- gtk_signal_connect (GTK_OBJECT (button), "clicked",
- GTK_SIGNAL_FUNC (clicked_cb), NULL);
-
- control = bonobo_control_new (button);
- gtk_signal_connect (GTK_OBJECT (control), "destroy",
- GTK_SIGNAL_FUNC (view_destroyed), NULL);
-
- gtk_widget_show_all (button);
-
- g_assert (control != NULL);
-
- return BONOBO_OBJECT (control);
-}
-
-static char *
-create_html (ExecutiveSummaryComponent *component,
- char **title,
- char **icon,
- void *closure)
-{
- *title = g_strdup ("The Magic Counter");
- *icon = g_strdup ("gnome-clock.png");
-
- gtk_timeout_add (1000, clicked_cb, component);
- return g_strdup ("Since you started this service<br><center>0</center><br>seconds have passed.");
+ char *html = "Since you started this service<br><center>0</center><br>seconds have passed.";
+ struct userdata *ud;
+
+ /* Create the userdata structure */
+ ud = g_new (struct userdata, 1);
+
+ ud->i = 1;
+ executive_summary_component_view_construct (view, component, NULL,
+ html, "The Magic Counter",
+ "gnome-clock.png");
+ /* Set the user data on the object */
+ gtk_object_set_data (GTK_OBJECT (view), "timer-data", ud);
+
+ /* Connect the the destroyed signal to find out
+ when the view is destroyed */
+ gtk_signal_connect (GTK_OBJECT (view), "destroy",
+ GTK_SIGNAL_FUNC (view_destroyed), NULL);
+
+ /* Increase the number of running views */
+ running_views++;
+
+ /* Do something "interesting" once a second */
+ gtk_timeout_add (1000, add_one, view);
}
static void
configure (ExecutiveSummaryComponent *component,
void *closure)
{
- GtkWidget *window, *label;
-
- g_print ("configuring\n");
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- label = gtk_label_new ("This is a configuration dialog.\nNo it really is");
-
- gtk_container_add (GTK_CONTAINER (window), label);
- gtk_widget_show_all (window);
+ GtkWidget *window, *label;
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ label = gtk_label_new ("This is a configuration dialog.\nNo it really is");
+
+ gtk_container_add (GTK_CONTAINER (window), label);
+ gtk_widget_show_all (window);
}
-
+
static BonoboObject *
factory_fn (BonoboGenericFactory *_factory,
void *closure)
{
- ExecutiveSummaryComponent *component;
-
- running_views++;
- component = executive_summary_component_new (create_view,
- create_html,
- configure,
- NULL);
- gtk_signal_connect (GTK_OBJECT (component), "object_gone",
- GTK_SIGNAL_FUNC (view_destroyed), NULL);
- return BONOBO_OBJECT (component);
+ ExecutiveSummaryComponent *component;
+
+ /* Create an executive summary component for this factory */
+ component = executive_summary_component_new (create_view,
+ configure,
+ NULL);
+ return BONOBO_OBJECT (component);
}
void
test_service_factory_init (void)
{
- if (factory != NULL)
- return;
-
- factory = bonobo_generic_factory_new (TEST_SERVICE_ID, factory_fn, NULL);
- if (factory == NULL) {
- g_warning ("Cannot initialize test service");
- exit (0);
- }
+ if (factory != NULL)
+ return;
+
+ /* Register the factory creation function and the IID */
+ factory = bonobo_generic_factory_new (TEST_SERVICE_ID, factory_fn, NULL);
+ if (factory == NULL) {
+ g_warning ("Cannot initialize test service");
+ exit (0);
+ }
}
int
main (int argc, char **argv)
{
- CORBA_ORB orb;
-
- gnome_init_with_popt_table ("Test service", VERSION,
- argc, argv, oaf_popt_options, 0, NULL);
- orb = oaf_init (argc, argv);
-
- if (bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) {
- g_error ("Could not initialize Bonobo");
- }
-
- test_service_factory_init ();
-
- bonobo_main ();
-
- return 0;
+ CORBA_ORB orb;
+
+ /* Init GNOME, oaf and bonobo */
+ gnome_init_with_popt_table ("Test service", VERSION,
+ argc, argv, oaf_popt_options, 0, NULL);
+ orb = oaf_init (argc, argv);
+
+ if (bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) {
+ g_error ("Could not initialize Bonobo");
+ }
+
+ /* Register the factory */
+ test_service_factory_init ();
+
+ /* Enter main */
+ bonobo_main ();
+
+ return 0;
}