aboutsummaryrefslogtreecommitdiffstats
path: root/executive-summary/component
diff options
context:
space:
mode:
authorIain Holmes <iain@src.gnome.org>2000-11-02 08:42:35 +0800
committerIain Holmes <iain@src.gnome.org>2000-11-02 08:42:35 +0800
commit4f3a4c8234238faaac1dea1ae68cae4d5dca3a5c (patch)
tree6f9b76cee8d456070ca9c849c697f621ff833694 /executive-summary/component
parent35162bcd8728297bff435a5592328051fd1df211 (diff)
downloadgsoc2013-evolution-4f3a4c8234238faaac1dea1ae68cae4d5dca3a5c.tar
gsoc2013-evolution-4f3a4c8234238faaac1dea1ae68cae4d5dca3a5c.tar.gz
gsoc2013-evolution-4f3a4c8234238faaac1dea1ae68cae4d5dca3a5c.tar.bz2
gsoc2013-evolution-4f3a4c8234238faaac1dea1ae68cae4d5dca3a5c.tar.lz
gsoc2013-evolution-4f3a4c8234238faaac1dea1ae68cae4d5dca3a5c.tar.xz
gsoc2013-evolution-4f3a4c8234238faaac1dea1ae68cae4d5dca3a5c.tar.zst
gsoc2013-evolution-4f3a4c8234238faaac1dea1ae68cae4d5dca3a5c.zip
Moving the executive summarys now :)
mail-summary now has clickable names to change to that view executive summary remembers what components are running when you close. selection now blocks ES updating so it won't be cleared. svn path=/trunk/; revision=6330
Diffstat (limited to 'executive-summary/component')
-rw-r--r--executive-summary/component/e-summary-factory.c85
-rw-r--r--executive-summary/component/e-summary-factory.h3
-rw-r--r--executive-summary/component/e-summary-url.c306
-rw-r--r--executive-summary/component/e-summary-url.h3
-rw-r--r--executive-summary/component/e-summary.c381
-rw-r--r--executive-summary/component/e-summary.h40
6 files changed, 742 insertions, 76 deletions
diff --git a/executive-summary/component/e-summary-factory.c b/executive-summary/component/e-summary-factory.c
index 435e6953ad..4593edee47 100644
--- a/executive-summary/component/e-summary-factory.c
+++ b/executive-summary/component/e-summary-factory.c
@@ -50,8 +50,8 @@
static GList *control_list = NULL;
-GtkWidget* embed_service (GtkWidget *widget,
- ESummary *esummary);
+void embed_service (GtkWidget *widget,
+ ESummary *esummary);
BonoboUIVerb verbs[] = {
BONOBO_UI_UNSAFE_VERB ("AddService", embed_service),
@@ -118,11 +118,41 @@ control_activate_cb (BonoboControl *control,
gboolean activate,
gpointer user_data)
{
+ ESummary *summary;
BonoboUIComponent *ui_component;
-
+ Bonobo_ControlFrame control_frame;
+ Evolution_ShellView shell_view_interface;
+ CORBA_Environment ev;
+
ui_component = bonobo_control_get_ui_component (control);
g_assert (ui_component != NULL);
+ if (gtk_object_get_data (GTK_OBJECT (control), "shell_view_interface") == NULL) {
+ control_frame = bonobo_control_get_control_frame (control);
+ if (control_frame == NULL) {
+ goto out;
+ }
+
+ CORBA_exception_init (&ev);
+ shell_view_interface = Bonobo_Unknown_query_interface (control_frame,
+ "IDL:Evolution/ShellView:1.0",
+ &ev);
+ CORBA_exception_free (&ev);
+
+ if (shell_view_interface != CORBA_OBJECT_NIL) {
+ gtk_object_set_data (GTK_OBJECT (control),
+ "shell_view_interface",
+ shell_view_interface);
+ } else {
+ g_warning ("Control frame doesn't have Evolution/ShellView.");
+ }
+
+ summary = E_SUMMARY (user_data);
+ e_summary_set_shell_view_interface (summary,
+ shell_view_interface);
+ }
+
+ out:
if (activate)
control_activate (control, ui_component, user_data);
else
@@ -147,7 +177,6 @@ update (ExecutiveSummary *summary,
ESummary *esummary)
{
ExecutiveSummaryComponentView *view;
- g_print ("OI!\n");
view = e_summary_view_from_id (esummary, id);
executive_summary_component_view_set_html (view, html);
@@ -158,9 +187,12 @@ static void
set_title (ExecutiveSummary *summary,
int id,
const char *title,
- gpointer user_data)
+ ESummary *esummary)
{
- g_print ("Setting title to %s\n", title);
+ ExecutiveSummaryComponentView *view;
+
+ view = e_summary_view_from_id (esummary, id);
+ executive_summary_component_view_set_title (view, title);
}
static void
@@ -186,48 +218,53 @@ view_destroyed (ExecutiveSummaryComponentView *view,
/* A ********very********
temporary function to embed something
*/
-GtkWidget*
+void
embed_service (GtkWidget *widget,
ESummary *esummary)
{
- ExecutiveSummaryComponentClient *client;
- ExecutiveSummary *summary;
- ExecutiveSummaryComponentView *view;
char *required_interfaces[2] = {"IDL:Evolution:SummaryComponent:1.0",
NULL};
char *obj_id;
- char *title;
- char *icon;
- char *html;
-
+
obj_id = bonobo_selector_select_id ("Select a service",
(const char **) required_interfaces);
if (obj_id == NULL)
- return NULL;
+ return;
- client = executive_summary_component_client_new (obj_id);
+ e_summary_factory_embed_service_from_id (esummary, obj_id);
+}
- if (client == NULL)
- return NULL;
+void
+e_summary_factory_embed_service_from_id (ESummary *esummary,
+ const char *obj_id)
+{
+ ExecutiveSummaryComponentClient *client;
+ ExecutiveSummary *summary;
+ ExecutiveSummaryComponentView *view;
+ int id;
+
+ client = executive_summary_component_client_new (obj_id);
+
+ g_return_if_fail (client != NULL);
/* Set the owner */
- summary = executive_summary_new ();
+ summary = EXECUTIVE_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_FUNC (flash), esummary);
gtk_signal_connect (GTK_OBJECT (summary), "set_title",
- GTK_SIGNAL_FUNC (set_title), NULL);
+ GTK_SIGNAL_FUNC (set_title), esummary);
gtk_signal_connect (GTK_OBJECT (summary), "update",
GTK_SIGNAL_FUNC (update), esummary);
/* Create view */
- view = executive_summary_component_client_create_view (client);
+ id = executive_summary_component_create_unique_id ();
+ view = executive_summary_component_client_create_view (client, id);
gtk_signal_connect (GTK_OBJECT (view), "destroy",
GTK_SIGNAL_FUNC (view_destroyed), client);
- e_summary_add_service (esummary, summary, view);
+ e_summary_add_service (esummary, summary, view, obj_id);
e_summary_rebuild_page (esummary);
- return NULL;
}
BonoboControl *
diff --git a/executive-summary/component/e-summary-factory.h b/executive-summary/component/e-summary-factory.h
index e9c8660c82..175988a78c 100644
--- a/executive-summary/component/e-summary-factory.h
+++ b/executive-summary/component/e-summary-factory.h
@@ -25,8 +25,11 @@
#define _E_SUMMARY_FACTORY_H__
#include <Evolution.h>
+#include "e-summary.h"
BonoboControl *e_summary_factory_new_control (const char *uri,
const Evolution_Shell shell);
+void e_summary_factory_embed_service_from_id (ESummary *esummary,
+ const char *obj_id);
#endif
diff --git a/executive-summary/component/e-summary-url.c b/executive-summary/component/e-summary-url.c
index 856297bb68..c07a3efc99 100644
--- a/executive-summary/component/e-summary-url.c
+++ b/executive-summary/component/e-summary-url.c
@@ -39,6 +39,7 @@
#include "e-summary-url.h"
#include "e-summary-util.h"
+#include <evolution-services/executive-summary-component-view.h>
#include "Composer.h"
typedef enum _ESummaryProtocol {
@@ -48,11 +49,37 @@ typedef enum _ESummaryProtocol {
PROTOCOL_VIEW,
PROTOCOL_EXEC,
PROTOCOL_FILE,
+ PROTOCOL_CLOSE,
+ PROTOCOL_LEFT,
+ PROTOCOL_RIGHT,
+ PROTOCOL_UP,
+ PROTOCOL_DOWN,
+ PROTOCOL_CONFIGURE,
PROTOCOL_OTHER
} ESummaryProtocol;
+static char *descriptions[] = {
+ N_("Open %s with the default GNOME application"),
+ N_("Open %s with the default GNOME web browser"),
+ N_("Send an email to %s"),
+ N_("Change the view to %s"),
+ N_("Run %s"),
+ N_("Open %s with the default GNOME application"),
+ N_("Close %s"),
+ N_("Move %s to the left"),
+ N_("Move %s to the right"),
+ N_("Move %s into the previous row"),
+ N_("Move %s into the next row"),
+ N_("Configure %s"),
+ N_("Open %s with the default GNOME application")
+};
+
#define COMPOSER_IID "OAFIID:evolution-composer:evolution-mail:cd8618ea-53e1-4b9e-88cf-ec578bdb903b"
+gboolean e_summary_url_mail_compose (ESummary *esummary,
+ const char *url);
+gboolean e_summary_url_exec (const char *exec);
+
void
e_summary_url_request (GtkHTML *html,
const gchar *url,
@@ -111,6 +138,98 @@ e_summary_url_request (GtkHTML *html,
gnome_vfs_close (handle);
}
+static char *
+parse_uri (const char *uri,
+ ESummaryProtocol protocol,
+ ESummary *esummary)
+{
+ ExecutiveSummaryComponentView *view;
+ char *parsed;
+ char *p;
+ int id;
+
+ switch (protocol) {
+
+ case PROTOCOL_HTTP:
+ /* "http://" == 7 */
+ parsed = g_strdup (uri + 7);
+ break;
+
+ case PROTOCOL_EXEC:
+ /* "exec://" == 7 */
+ parsed = g_strdup (uri + 7);
+ break;
+
+ case PROTOCOL_VIEW:
+ /* "view://" == 7 */
+ parsed = g_strdup (uri + 7);
+ break;
+
+ case PROTOCOL_MAILTO:
+ /* Fun. Mailto's might be "mailto:" or "mailto://" */
+ if (strstr (uri, "mailto://") == NULL) {
+ parsed = (char *) (uri + 7);
+ } else {
+ parsed = (char *) (uri + 9);
+ }
+
+ /* Now strip anything after a question mark,
+ as it is a parameter (that we ignore for the time being) */
+ if ( (p = strchr (parsed, '?')) != NULL) {
+ parsed = g_strndup (parsed, p - parsed);
+ } else {
+ parsed = g_strdup (parsed);
+ }
+
+ break;
+
+ case PROTOCOL_CLOSE:
+ id = atoi (uri + 8);
+ view = e_summary_view_from_id (esummary, id);
+ parsed = g_strdup (executive_summary_component_view_get_title (view));
+ break;
+
+ case PROTOCOL_LEFT:
+ id = atoi (uri + 7);
+ view = e_summary_view_from_id (esummary, id);
+ parsed = g_strdup (executive_summary_component_view_get_title (view));
+ break;
+
+ case PROTOCOL_RIGHT:
+ id = atoi (uri + 8);
+ view = e_summary_view_from_id (esummary, id);
+ parsed = g_strdup (executive_summary_component_view_get_title (view));
+ break;
+
+ case PROTOCOL_UP:
+ id = atoi (uri + 5);
+ view = e_summary_view_from_id (esummary, id);
+ parsed = g_strdup (executive_summary_component_view_get_title (view));
+ break;
+
+ case PROTOCOL_DOWN:
+ id = atoi (uri + 7);
+ view = e_summary_view_from_id (esummary, id);
+ parsed = g_strdup (executive_summary_component_view_get_title (view));
+ break;
+
+ case PROTOCOL_CONFIGURE:
+ id = atoi (uri + 12);
+ view = e_summary_view_from_id (esummary, id);
+ parsed = g_strdup (executive_summary_component_view_get_title (view));
+ break;
+
+ case PROTOCOL_NONE:
+ case PROTOCOL_OTHER:
+ default:
+ /* Just return the uneditted uri. */
+ parsed = g_strdup (uri);
+ break;
+ }
+
+ return parsed;
+}
+
static ESummaryProtocol
get_protocol (const char *url)
{
@@ -134,29 +253,61 @@ get_protocol (const char *url)
}
switch (lowerurl[0]) {
+ case 'c':
+ switch (lowerurl[1]) {
+ case 'l':
+ if (strncmp (lowerurl + 2, "ose", 3) == 0)
+ protocol = PROTOCOL_CLOSE;
+ break;
+ case 'o':
+ if (strncmp (lowerurl + 2, "nfigure", 7) == 0)
+ protocol = PROTOCOL_CONFIGURE;
+ break;
+ }
+
+ case 'd':
+ if (strncmp (lowerurl + 1, "own", 3) == 0)
+ protocol = PROTOCOL_DOWN;
+ break;
+
+ case 'e':
+ if (strncmp (lowerurl + 1, "xec", 3) == 0)
+ protocol = PROTOCOL_EXEC;
+ break;
+
+ case 'f':
+ if (strncmp (lowerurl + 1, "ile", 3) == 0)
+ protocol = PROTOCOL_FILE;
+ break;
+
case 'h':
if (strncmp (lowerurl + 1, "ttp", 3) == 0)
protocol = PROTOCOL_HTTP;
break;
+ case 'l':
+ if (strncmp (lowerurl + 1, "eft", 3) == 0)
+ protocol = PROTOCOL_LEFT;
+ break;
+
case 'm':
if (strncmp (lowerurl + 1, "ailto", 5) == 0)
protocol = PROTOCOL_MAILTO;
break;
- case 'v':
- if (strncmp (lowerurl + 1, "iew", 3) == 0)
- protocol = PROTOCOL_VIEW;
+ case 'r':
+ if (strncmp (lowerurl + 1, "ight", 4) == 0)
+ protocol = PROTOCOL_RIGHT;
break;
-
- case 'e':
- if (strncmp (lowerurl + 1, "xec", 3) == 0)
- protocol = PROTOCOL_EXEC;
+
+ case 'u':
+ if (lowerurl[1] == 'p')
+ protocol = PROTOCOL_UP;
break;
- case 'f':
- if (strncmp (lowerurl + 1, "ile", 3) == 0)
- protocol = PROTOCOL_FILE;
+ case 'v':
+ if (strncmp (lowerurl + 1, "iew", 3) == 0)
+ protocol = PROTOCOL_VIEW;
break;
default:
@@ -174,25 +325,104 @@ e_summary_url_click (GtkWidget *widget,
ESummary *esummary)
{
ESummaryProtocol protocol;
- g_print ("URL: %s\n", url);
-
+ ExecutiveSummaryComponentView *view;
+ gpointer window; /* FIXME */
+ char *parsed;
+ int id;
+
protocol = get_protocol (url);
-
+
+ parsed = parse_uri (url, protocol, esummary);
+
switch (protocol) {
case PROTOCOL_MAILTO:
/* Open a composer window */
- e_summary_url_mail_compose (esummary, url);
+ e_summary_url_mail_compose (esummary, parsed);
break;
case PROTOCOL_VIEW:
/* Change the EShellView's current uri */
+ e_summary_change_current_view (esummary, parsed);
break;
case PROTOCOL_EXEC:
/* Execute the rest of the url */
- e_summary_url_exec (url + 7);
+ e_summary_url_exec (parsed);
break;
-
+
+ case PROTOCOL_CLOSE:
+ /* Close the window. */
+ id = atoi (url + 8);
+ view = e_summary_view_from_id (esummary, id);
+ if (view == NULL)
+ return;
+
+ window = e_summary_window_from_view (esummary, view);
+ e_summary_window_remove_from_ht (window, esummary);
+ e_summary_window_free (window, esummary);
+ e_summary_rebuild_page (esummary);
+ break;
+
+ case PROTOCOL_CONFIGURE:
+ /* Configure the window. . . */
+ id = atoi (url + 12);
+ view = e_summary_view_from_id (esummary, id);
+ if (view == NULL)
+ return;
+
+ /* Issue the configure command some how :) */
+ break;
+
+ case PROTOCOL_LEFT:
+ /* Window left */
+ id = atoi (url + 7);
+ view = e_summary_view_from_id (esummary, id);
+
+ if (view == NULL)
+ return;
+
+ window = e_summary_window_from_view (esummary, view);
+
+ e_summary_window_move_left (esummary, window);
+ e_summary_rebuild_page (esummary);
+ break;
+
+ case PROTOCOL_RIGHT:
+ id = atoi (url + 8);
+ view = e_summary_view_from_id (esummary, id);
+ if (view == NULL)
+ return;
+
+ window = e_summary_window_from_view (esummary, view);
+
+ e_summary_window_move_right (esummary, window);
+ e_summary_rebuild_page (esummary);
+ break;
+
+ case PROTOCOL_UP:
+ id = atoi (url + 5);
+ view = e_summary_view_from_id (esummary, id);
+ if (view == NULL)
+ return;
+
+ window = e_summary_window_from_view (esummary, view);
+
+ e_summary_window_move_up (esummary, window);
+ e_summary_rebuild_page (esummary);
+ break;
+
+ case PROTOCOL_DOWN:
+ id = atoi (url + 7);
+ view = e_summary_view_from_id (esummary, id);
+ if (view == NULL)
+ return;
+
+ window = e_summary_window_from_view (esummary, view);
+
+ e_summary_window_move_down (esummary, window);
+ e_summary_rebuild_page (esummary);
+ break;
+
case PROTOCOL_NONE:
case PROTOCOL_OTHER:
case PROTOCOL_HTTP:
@@ -203,6 +433,8 @@ e_summary_url_click (GtkWidget *widget,
break;
}
+
+ g_free (parsed);
}
gboolean
@@ -225,13 +457,16 @@ e_summary_url_mail_compose (ESummary *esummary,
g_warning ("Unable to start composer component!");
return FALSE;
}
-
+
if ( (proto = strstr (url, "://")) != NULL){
address = proto + 3;
} else {
- address = url + 7;
+ if (strncmp (url, "mailto:", 7) == 0)
+ address = (char *) (url + 7);
+ else
+ address = (char *) url;
}
-
+
to = Evolution_Composer_RecipientList__alloc ();
to->_length = 1;
to->_maximum = 1;
@@ -296,4 +531,37 @@ e_summary_url_exec (const char *exec)
gnome_execute_async (NULL, argc, exec_array);
g_strfreev (exec_array);
+ return TRUE;
+}
+
+static char *
+e_summary_url_describe (const char *uri,
+ ESummary *esummary)
+{
+ ESummaryProtocol protocol;
+ char *contents, *description;
+
+ protocol = get_protocol (uri);
+ contents = parse_uri (uri, protocol, esummary);
+
+ description = g_strdup_printf (_(descriptions[protocol]), contents);
+ g_free (contents);
+
+ return description;
+}
+
+void
+e_summary_url_over (GtkHTML *html,
+ const char *uri,
+ ESummary *esummary)
+{
+ char *description;
+
+ if (uri != NULL) {
+ description = e_summary_url_describe (uri, esummary);
+ e_summary_set_message (esummary, description, FALSE);
+ g_free (description);
+ } else {
+ e_summary_unset_message (esummary);
+ }
}
diff --git a/executive-summary/component/e-summary-url.h b/executive-summary/component/e-summary-url.h
index de45caf7c7..9844d384e0 100644
--- a/executive-summary/component/e-summary-url.h
+++ b/executive-summary/component/e-summary-url.h
@@ -30,5 +30,8 @@ void e_summary_url_request (GtkHTML *html,
void e_summary_url_click (GtkWidget *widget,
const char *url,
ESummary *esummary);
+void e_summary_url_over (GtkHTML *html,
+ const char *uri,
+ ESummary *esummary);
#endif
diff --git a/executive-summary/component/e-summary.c b/executive-summary/component/e-summary.c
index 736398214b..dca8f98f0f 100644
--- a/executive-summary/component/e-summary.c
+++ b/executive-summary/component/e-summary.c
@@ -32,52 +32,52 @@
#include <gtkhtml/gtkhtml-stream.h>
#include <gal/util/e-util.h>
-#include <evolution-services/executive-summary.h>
-#include <evolution-services/executive-summary-component-client.h>
-#include <evolution-services/executive-summary-component-view.h>
-
#include "e-summary.h"
+#include "e-summary-factory.h"
#include "e-summary-util.h"
#include "e-summary-url.h"
#define PARENT_TYPE (gtk_vbox_get_type ())
+/* From component-factory.c */
+extern char *evolution_dir;
+
static GtkObjectClass *e_summary_parent_class;
struct _ESummaryPrivate {
Evolution_Shell shell;
+ Evolution_ShellView shell_view_interface;
GtkWidget *html_scroller;
GtkWidget *html;
GHashTable *id_to_view;
+ GHashTable *view_to_window;
GHashTable *summary_to_window;
GList *window_list;
guint idle;
GtkHTMLStream *stream;
+ gboolean grabbed;
};
-typedef struct _ESummaryWindow {
- ExecutiveSummary *summary;
- ExecutiveSummaryComponentView *view;
-} ESummaryWindow;
-
static gboolean on_object_requested (GtkHTML *html,
GtkHTMLEmbedded *eb,
ESummary *summary);
-static void e_summary_window_free (ESummaryWindow *window,
- ESummaryPrivate *priv);
+static void e_summary_save_state (ESummary *esummary,
+ const char *path);
+static void e_summary_load_state (ESummary *esummary,
+ const char *path);
/* GtkObject methods */
static void
s2w_foreach (gpointer *key,
gpointer *value,
- ESummaryPrivate *priv)
+ ESummary *esummary)
{
- e_summary_window_free ((ESummaryWindow *) value, priv);
+ e_summary_window_free ((ESummaryWindow *) value, esummary);
g_free (value);
}
@@ -86,15 +86,21 @@ e_summary_destroy (GtkObject *object)
{
ESummary *esummary = E_SUMMARY (object);
ESummaryPrivate *priv;
+ char *prefix;
priv = esummary->private;
if (priv == NULL)
return;
+ prefix = g_concat_dir_and_file (evolution_dir, "config/Executive-Summary");
+ e_summary_save_state (esummary, prefix);
+ g_free (prefix);
+
g_hash_table_foreach (priv->summary_to_window,
- s2w_foreach, priv);
+ (GHFunc) s2w_foreach, esummary);
g_hash_table_destroy (priv->summary_to_window);
g_hash_table_destroy (priv->id_to_view);
+ g_hash_table_destroy (priv->view_to_window);
g_free (esummary->private);
esummary->private = NULL;
@@ -133,9 +139,9 @@ load_default (ESummary *summary)
ESummaryPrivate *priv;
char *def = "<table width=\"100%\"><tr><td align=\"right\">"
"<img src=\"ccsplash.png\"></td></tr></table>"
- "<table width=\"100%\"><tr><td><a href=\"exec://bug-buddy\"><img src=\"file://gnome-spider.png\">"
+ "<table><tr><td><a href=\"exec://bug-buddy\"><img src=\"file://gnome-spider.png\" width=\"24\" height=\"24\" border=\"0\">"
"</a></td><td><a href=\"exec://bug-buddy\">Submit a bug report"
- "</a></td><td>All Executive Summary comments to <a href=\"mailto:iain@helixcode.com\">Iain Holmes</a></td></tr></table><hr>";
+ "</a></td></tr></table><hr>";
g_return_if_fail (summary != NULL);
g_return_if_fail (IS_E_SUMMARY (summary));
@@ -151,7 +157,7 @@ static void
e_summary_end_load (ESummary *summary)
{
ESummaryPrivate *priv;
- char *footer = "</body></html>";
+ char *footer = "<hr><p align=\"right\">All Executive Summary comments to <a href=\"mailto:iain@helixcode.com\">Iain Holmes (iain@helixcode.com)</a></p></body></html>";
priv = summary->private;
gtk_html_write (GTK_HTML (priv->html), priv->stream,
@@ -186,7 +192,9 @@ e_summary_init (ESummary *esummary)
GTK_SIGNAL_FUNC (on_object_requested), esummary);
gtk_signal_connect (GTK_OBJECT (priv->html), "link-clicked",
GTK_SIGNAL_FUNC (e_summary_url_click), esummary);
-
+ gtk_signal_connect (GTK_OBJECT (priv->html), "on_url",
+ GTK_SIGNAL_FUNC (e_summary_url_over), esummary);
+
gtk_container_add (GTK_CONTAINER (priv->html_scroller), priv->html);
gtk_widget_show_all (priv->html_scroller);
@@ -199,6 +207,7 @@ e_summary_init (ESummary *esummary)
/* Init hashtables */
priv->summary_to_window = g_hash_table_new (NULL, NULL);
priv->id_to_view = g_hash_table_new (NULL, NULL);
+ priv->view_to_window = g_hash_table_new (NULL, NULL);
}
E_MAKE_TYPE (e_summary, "ESummary", ESummary, e_summary_class_init,
@@ -209,12 +218,19 @@ e_summary_new (const Evolution_Shell shell)
{
ESummary *esummary;
ESummaryPrivate *priv;
+ char *path;
esummary = gtk_type_new (e_summary_get_type ());
priv = esummary->private;
priv->shell = shell;
+ /* Restore services */
+ path = g_concat_dir_and_file (evolution_dir,
+ "config/Executive-Summary");
+ e_summary_load_state (esummary, path);
+ g_free (path);
+
return GTK_WIDGET (esummary);
}
@@ -250,34 +266,49 @@ on_object_requested (GtkHTML *html,
static void
e_summary_display_window (ESummary *esummary,
ESummaryWindow *window,
+ int row,
int col)
{
ESummaryPrivate *priv;
char *footer = "</td></tr></table>";
char *title_html;
+ char *control_html;
char *colour[2] = {"e6e8e4",
"edeeeb"};
char *title_colour[2] = {"bac1b6",
"cdd1c7"};
const char *title, *icon, *html;
+ int id;
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);
+ id = executive_summary_component_view_get_id (window->view);
/** FIXME: Make this faster by caching it? */
+
+ control_html = g_strdup_printf
+ ("<table width=\"32\" height=\"48\"><tr><td>"
+ "<a href=\"close://%d\"><img border=\"0\" src=\"service-close.png\"></a></td>"
+ "<td><a href=\"configure://%d\"><img border=\"0\" src=\"service-configure.png\"></a></td></tr>"
+ "<tr><td><a href=\"left://%d\"><img border=\"0\" src=\"service-left.png\"></a></td>"
+ "<td><a href=\"right://%d\"><img border=\"0\" src=\"service-right.png\"></a></td></tr>"
+ "<tr><td><a href=\"down://%d\"><img border=\"0\" src=\"service-down.png\"></a></td>"
+ "<td><a href=\"up://%d\"><img border=\"0\" src=\"service-up.png\"></a></td></tr></table>", id, id, id, id, id, id);
+
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%%\">",
+ "<b>%s</b></td><td>%s</td></tr></table></td></tr><tr>"
+ "<td bgcolor=\"#%s\" height=\"100%%\">",
title_colour[col % 2], icon, title,
- colour[col % 2]);
+ control_html, colour[col % 2]);
+ g_free (control_html);
gtk_html_write (GTK_HTML (priv->html), priv->stream, title_html,
strlen (title_html));
@@ -312,6 +343,12 @@ e_summary_rebuild_page (ESummary *esummary)
priv = esummary->private;
+ /* If there is a selection, don't redraw the page so that the selection
+ isn't cleared */
+ if (GTK_HTML (priv->html)->in_selection == TRUE ||
+ GTK_HTML (priv->html)->engine->active_selection == TRUE)
+ return TRUE;
+
gtk_layout_freeze (GTK_LAYOUT (priv->html));
e_summary_start_load (esummary);
load_default (esummary);
@@ -339,7 +376,8 @@ e_summary_rebuild_page (ESummary *esummary)
gtk_html_write (GTK_HTML (priv->html), priv->stream,
td, strlen (td));
- e_summary_display_window (esummary, window, (loc % 3));
+ e_summary_display_window (esummary, window,
+ (loc / 3), (loc % 3));
gtk_html_write (GTK_HTML (priv->html), priv->stream, "</td>", 5);
loc++;
@@ -357,7 +395,8 @@ e_summary_rebuild_page (ESummary *esummary)
void
e_summary_add_service (ESummary *esummary,
ExecutiveSummary *summary,
- ExecutiveSummaryComponentView *view)
+ ExecutiveSummaryComponentView *view,
+ const char *iid)
{
ESummaryWindow *window;
ESummaryPrivate *priv;
@@ -372,7 +411,7 @@ e_summary_add_service (ESummary *esummary,
window = g_new0 (ESummaryWindow, 1);
window->summary = summary;
-
+ window->iid = g_strdup (iid);
window->view = view;
priv = esummary->private;
@@ -380,8 +419,8 @@ e_summary_add_service (ESummary *esummary,
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);
+ g_hash_table_insert (priv->view_to_window, view, window);
}
#if 0
@@ -438,11 +477,19 @@ e_summary_add_bonobo_service (ESummary *esummary,
}
#endif
-static void
+void
e_summary_window_free (ESummaryWindow *window,
- ESummaryPrivate *priv)
+ ESummary *esummary)
{
- g_print ("%s\n", __FUNCTION__);
+ ESummaryPrivate *priv;
+
+ g_return_if_fail (window != NULL);
+ g_return_if_fail (esummary != NULL);
+ g_return_if_fail (IS_E_SUMMARY (esummary));
+
+ priv = esummary->private;
+ g_free (window->iid);
+
priv->window_list = g_list_remove (priv->window_list, window);
bonobo_object_unref (BONOBO_OBJECT (window->summary));
@@ -451,10 +498,13 @@ e_summary_window_free (ESummaryWindow *window,
/* Call this before e_summary_window_free, execpt when you are freeing
the hash table */
-static void
+void
e_summary_window_remove_from_ht (ESummaryWindow *window,
- ESummaryPrivate *priv)
+ ESummary *esummary)
{
+ ESummaryPrivate *priv;
+
+ priv = esummary->private;
g_hash_table_remove (priv->summary_to_window, window->summary);
}
@@ -474,7 +524,7 @@ e_summary_update_window (ESummary *esummary,
if (priv->idle != 0)
return;
- priv->idle = g_idle_add (e_summary_rebuild_page, esummary);
+ priv->idle = g_idle_add ((GSourceFunc) e_summary_rebuild_page, esummary);
}
ExecutiveSummaryComponentView *
@@ -491,6 +541,273 @@ e_summary_view_from_id (ESummary *esummary,
priv = esummary->private;
view = g_hash_table_lookup (priv->id_to_view, GINT_TO_POINTER (id));
- g_print ("%d: %p\n", id, view);
return view;
}
+
+void
+e_summary_set_shell_view_interface (ESummary *summary,
+ Evolution_ShellView svi)
+{
+ ESummaryPrivate *priv;
+
+ g_return_if_fail (summary != NULL);
+ g_return_if_fail (IS_E_SUMMARY (summary));
+ g_return_if_fail (svi != CORBA_OBJECT_NIL);
+
+ priv = summary->private;
+ priv->shell_view_interface = svi;
+}
+
+/* Wrappers for Evolution_ShellView */
+void
+e_summary_set_message (ESummary *esummary,
+ const char *message,
+ gboolean busy)
+{
+ ESummaryPrivate *priv;
+ Evolution_ShellView svi;
+ CORBA_Environment ev;
+
+ g_return_if_fail (esummary != NULL);
+ g_return_if_fail (IS_E_SUMMARY (esummary));
+
+ priv = esummary->private;
+
+ svi = priv->shell_view_interface;
+ if (svi == NULL)
+ return;
+
+ CORBA_exception_init (&ev);
+ if (message != NULL)
+ Evolution_ShellView_set_message (svi, message, busy, &ev);
+ else
+ Evolution_ShellView_set_message (svi, "", busy, &ev);
+ CORBA_exception_free (&ev);
+}
+
+void
+e_summary_unset_message (ESummary *esummary)
+{
+ ESummaryPrivate *priv;
+ Evolution_ShellView svi;
+ CORBA_Environment ev;
+
+ g_return_if_fail (esummary != NULL);
+ g_return_if_fail (IS_E_SUMMARY (esummary));
+
+ priv = esummary->private;
+
+ svi = priv->shell_view_interface;
+ if (svi == NULL)
+ return;
+
+ CORBA_exception_init (&ev);
+ Evolution_ShellView_unset_message (svi, &ev);
+ CORBA_exception_free (&ev);
+}
+
+void
+e_summary_change_current_view (ESummary *esummary,
+ const char *uri)
+{
+ ESummaryPrivate *priv;
+ Evolution_ShellView svi;
+ CORBA_Environment ev;
+
+ g_return_if_fail (esummary != NULL);
+ g_return_if_fail (IS_E_SUMMARY (esummary));
+
+ priv = esummary->private;
+
+ svi = priv->shell_view_interface;
+ if (svi == NULL)
+ return;
+
+ CORBA_exception_init (&ev);
+ Evolution_ShellView_change_current_view (svi, uri, &ev);
+ CORBA_exception_free (&ev);
+}
+
+void
+e_summary_set_title (ESummary *esummary,
+ const char *title)
+{
+ ESummaryPrivate *priv;
+ Evolution_ShellView svi;
+ CORBA_Environment ev;
+
+ g_return_if_fail (esummary != NULL);
+ g_return_if_fail (IS_E_SUMMARY (esummary));
+
+ priv = esummary->private;
+
+ svi = priv->shell_view_interface;
+ if (svi == NULL)
+ return;
+
+ CORBA_exception_init (&ev);
+ Evolution_ShellView_set_title (svi, title, &ev);
+ CORBA_exception_free (&ev);
+}
+
+static void
+e_summary_load_state (ESummary *esummary,
+ const char *path)
+{
+ char *fullpath;
+ char **argv;
+ int argc, i;
+
+ g_return_if_fail (esummary != NULL);
+ g_return_if_fail (IS_E_SUMMARY (esummary));
+
+ fullpath = g_strdup_printf ("=%s=/services/iids", path);
+ gnome_config_get_vector (fullpath, &argc, &argv);
+
+ for (i = 0; i < argc; i++) {
+ e_summary_factory_embed_service_from_id (esummary, argv[i]);
+ }
+
+ g_free (argv);
+ g_free (fullpath);
+}
+
+static void
+e_summary_save_state (ESummary *esummary,
+ const char *path)
+{
+ ESummaryPrivate *priv;
+ GList *windows;
+ char *fullpath;
+ char **argv;
+ int argc, i;
+
+ g_return_if_fail (esummary != NULL);
+ g_return_if_fail (IS_E_SUMMARY (esummary));
+
+ fullpath = g_strdup_printf("=%s=/services/iids", path);
+ priv = esummary->private;
+
+ argc = g_list_length (priv->window_list);
+ argv = g_new (char *, argc);
+
+ for (windows = priv->window_list, i = 0; windows;
+ windows = windows->next, i++) {
+ ESummaryWindow *window;
+
+ window = windows->data;
+ g_print ("%s: IID: %s\n", path, window->iid);
+ argv[i] = window->iid;
+ }
+
+ gnome_config_set_vector (fullpath, argc, (const char **)argv);
+
+ gnome_config_sync ();
+ gnome_config_drop_all ();
+
+ g_free (fullpath);
+ g_free (argv);
+}
+
+ESummaryWindow *
+e_summary_window_from_view (ESummary *esummary,
+ ExecutiveSummaryComponentView *view)
+{
+ ESummaryPrivate *priv;
+
+ priv = esummary->private;
+ return g_hash_table_lookup (priv->view_to_window, view);
+}
+
+void
+e_summary_window_move_left (ESummary *esummary,
+ ESummaryWindow *window)
+{
+ ESummaryPrivate *priv;
+ GList *win_item, *grandparent;
+ int position;
+
+ priv = esummary->private;
+
+ /* Need to cache this location */
+ win_item = g_list_find (priv->window_list, window);
+
+ /* Find the item 2 previous. */
+ if (win_item->prev == NULL)
+ return; /* Item was first, can't be moved left */
+
+ grandparent = win_item->prev->prev;
+
+ /* Remove it from the list */
+ priv->window_list = g_list_remove_link (priv->window_list, win_item);
+
+ /* Insert it after the grandparent */
+ position = g_list_position (priv->window_list, grandparent);
+ priv->window_list = g_list_insert (priv->window_list, win_item->data,
+ position + 1);
+ g_list_free_1 (win_item);
+}
+
+void
+e_summary_window_move_right (ESummary *esummary,
+ ESummaryWindow *window)
+{
+ ESummaryPrivate *priv;
+ GList *win_item, *child;
+ int position;
+
+ priv = esummary->private;
+
+ win_item = g_list_find (priv->window_list, window);
+
+ if (win_item->next == NULL)
+ return;
+
+ child = win_item->next;
+
+ priv->window_list = g_list_remove_link (priv->window_list, win_item);
+
+ position = g_list_position (priv->window_list, child);
+ priv->window_list = g_list_insert (priv->window_list, win_item->data,
+ position + 1);
+ g_list_free_1 (win_item);
+}
+
+void
+e_summary_window_move_up (ESummary *esummary,
+ ESummaryWindow *window)
+{
+ ESummaryPrivate *priv;
+ GList *win_item;
+ int position;
+
+ priv = esummary->private;
+
+ win_item = g_list_find (priv->window_list, window);
+
+ position = g_list_position (priv->window_list, win_item);
+ priv->window_list = g_list_remove_link (priv->window_list, win_item);
+
+ priv->window_list = g_list_insert (priv->window_list, win_item->data,
+ position - 3);
+ g_list_free_1 (win_item);
+}
+
+void
+e_summary_window_move_down (ESummary *esummary,
+ ESummaryWindow *window)
+{
+ ESummaryPrivate *priv;
+ GList *win_item;
+ int position;
+
+ priv = esummary->private;
+
+ win_item = g_list_find (priv->window_list, window);
+
+ position = g_list_position (priv->window_list, win_item);
+ priv->window_list = g_list_remove_link (priv->window_list, win_item);
+
+ priv->window_list = g_list_insert (priv->window_list, win_item->data,
+ position + 3);
+}
diff --git a/executive-summary/component/e-summary.h b/executive-summary/component/e-summary.h
index 569cae3331..f68575d76c 100644
--- a/executive-summary/component/e-summary.h
+++ b/executive-summary/component/e-summary.h
@@ -29,8 +29,9 @@
#include <gtk/gtkvbox.h>
#include <evolution-services/executive-summary.h>
#include <evolution-services/executive-summary-component-client.h>
+#include <evolution-services/executive-summary-component-view.h>
-#include "shell/Evolution.h"
+#include <Evolution.h>
#define E_SUMMARY_TYPE (e_summary_get_type ())
#define E_SUMMARY(obj) (GTK_CHECK_CAST ((obj), E_SUMMARY_TYPE, ESummary))
@@ -41,6 +42,13 @@
typedef struct _ESummaryPrivate ESummaryPrivate;
typedef struct _ESummary ESummary;
typedef struct _ESummaryClass ESummaryClass;
+typedef struct _ESummaryWindow ESummaryWindow;
+
+struct _ESummaryWindow {
+ ExecutiveSummary *summary;
+ ExecutiveSummaryComponentView *view;
+ char *iid;
+};
struct _ESummary {
GtkVBox parent;
@@ -70,5 +78,35 @@ void e_summary_add_bonobo_service (ESummary *esummary,
void e_summary_update_window (ESummary *esummary,
ExecutiveSummary *summary,
const char *html);
+void e_summary_window_free (ESummaryWindow *window,
+ ESummary *esummary);
+void e_summary_window_remove_from_ht (ESummaryWindow *window,
+ ESummary *esummary);
+void e_summary_add_service (ESummary *esummary,
+ ExecutiveSummary *summary,
+ ExecutiveSummaryComponentView *view,
+ const char *iid);
+ExecutiveSummaryComponentView * e_summary_view_from_id (ESummary *esummary,
+ int id);
+void e_summary_set_shell_view_interface (ESummary *summary,
+ Evolution_ShellView svi);
+void e_summary_set_message (ESummary *esummary,
+ const char *message,
+ gboolean busy);
+void e_summary_unset_message (ESummary *esummary);
+void e_summary_change_current_view (ESummary *esummary,
+ const char *uri);
+void e_summary_set_title (ESummary *esummary,
+ const char *title);
+ESummaryWindow *e_summary_window_from_view (ESummary *esummary,
+ ExecutiveSummaryComponentView *view);
+void e_summary_window_move_left (ESummary *esummary,
+ ESummaryWindow *window);
+void e_summary_window_move_right (ESummary *esummary,
+ ESummaryWindow *window);
+void e_summary_window_move_up (ESummary *esummary,
+ ESummaryWindow *window);
+void e_summary_window_move_down (ESummary *esummary,
+ ESummaryWindow *window);
#endif