diff options
Diffstat (limited to 'executive-summary/component')
-rw-r--r-- | executive-summary/component/Makefile.am | 6 | ||||
-rw-r--r-- | executive-summary/component/e-summary-factory.c | 64 | ||||
-rw-r--r-- | executive-summary/component/e-summary.c | 171 | ||||
-rw-r--r-- | executive-summary/component/e-summary.h | 4 |
4 files changed, 138 insertions, 107 deletions
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" |