aboutsummaryrefslogtreecommitdiffstats
path: root/executive-summary/component
diff options
context:
space:
mode:
Diffstat (limited to 'executive-summary/component')
-rw-r--r--executive-summary/component/component-factory.c135
-rw-r--r--executive-summary/component/e-summary-callbacks.c28
-rw-r--r--executive-summary/component/e-summary-factory.c1
-rw-r--r--executive-summary/component/e-summary-prefs.c24
-rw-r--r--executive-summary/component/e-summary-prefs.h9
-rw-r--r--executive-summary/component/e-summary.c95
6 files changed, 179 insertions, 113 deletions
diff --git a/executive-summary/component/component-factory.c b/executive-summary/component/component-factory.c
index 56a516a5eb..7e1dc17b45 100644
--- a/executive-summary/component/component-factory.c
+++ b/executive-summary/component/component-factory.c
@@ -44,8 +44,8 @@ static BonoboGenericFactory *factory = NULL;
static gint running_objects = 0;
static const EvolutionShellComponentFolderType folder_types[] = {
- { "executive-summary", "evolution-today.png" },
- { NULL, NULL }
+ { "executive-summary", "evolution-today.png" },
+ { NULL, NULL }
};
char *evolution_dir;
@@ -59,23 +59,23 @@ create_view (EvolutionShellComponent *shell_component,
BonoboControl **control_return,
void *closure)
{
- EvolutionShellClient *shell_client;
- GNOME_Evolution_Shell corba_shell;
- BonoboControl *control;
-
- if (g_strcasecmp (folder_type, "executive-summary") != 0)
- return EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDTYPE;
-
- shell_client = evolution_shell_component_get_owner (shell_component);
- corba_shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell_client));
-
- control = e_summary_factory_new_control (physical_uri, corba_shell);
- if (!control)
- return EVOLUTION_SHELL_COMPONENT_NOTFOUND;
-
- *control_return = control;
-
- return EVOLUTION_SHELL_COMPONENT_OK;
+ EvolutionShellClient *shell_client;
+ GNOME_Evolution_Shell corba_shell;
+ BonoboControl *control;
+
+ if (g_strcasecmp (folder_type, "executive-summary") != 0)
+ return EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDTYPE;
+
+ shell_client = evolution_shell_component_get_owner (shell_component);
+ corba_shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell_client));
+
+ control = e_summary_factory_new_control (physical_uri, corba_shell);
+ if (!control)
+ return EVOLUTION_SHELL_COMPONENT_NOTFOUND;
+
+ *control_return = control;
+
+ return EVOLUTION_SHELL_COMPONENT_OK;
}
static void
@@ -84,72 +84,79 @@ owner_set_cb (EvolutionShellComponent *shell_component,
const char *evolution_homedir,
gpointer user_data)
{
- GNOME_Evolution_Shell corba_shell;
-
- evolution_dir = g_strdup (evolution_homedir);
-
- corba_shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell_client));
+ GNOME_Evolution_Shell corba_shell;
+
+ evolution_dir = g_strdup (evolution_homedir);
+
+ corba_shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell_client));
}
static void
owner_unset_cb (EvolutionShellComponent *shell_component,
gpointer user_data)
{
- gtk_main_quit ();
+ gtk_main_quit ();
+}
+
+static void
+component_destroy_cb (GtkObject *object,
+ gpointer user_data)
+{
+ gtk_main_quit ();
}
static void
factory_destroy (BonoboEmbeddable *embeddable,
gpointer dummy)
{
- running_objects--;
-
- if (running_objects > 0)
- return;
-
- if (factory)
- bonobo_object_unref (BONOBO_OBJECT (factory));
- else
- g_warning ("Serious ref counting error");
- factory = NULL;
-
- gtk_main_quit ();
+ running_objects--;
+
+ if (running_objects > 0)
+ return;
+
+ if (factory)
+ bonobo_object_unref (BONOBO_OBJECT (factory));
+ else
+ g_warning ("Serious ref counting error");
+ factory = NULL;
+
+ gtk_main_quit ();
}
static BonoboObject *
factory_fn (BonoboGenericFactory *factory,
void *closure)
{
- EvolutionShellComponent *shell_component;
-
- running_objects++;
-
- shell_component = evolution_shell_component_new (folder_types,
- create_view,
- NULL, NULL, NULL, NULL,
- NULL);
- gtk_signal_connect (GTK_OBJECT (shell_component), "destroy",
- GTK_SIGNAL_FUNC (factory_destroy), NULL);
- gtk_signal_connect (GTK_OBJECT (shell_component), "owner_set",
- GTK_SIGNAL_FUNC (owner_set_cb), NULL);
- gtk_signal_connect (GTK_OBJECT (shell_component), "owner_unset",
- GTK_SIGNAL_FUNC (owner_unset_cb), NULL);
-
- return BONOBO_OBJECT (shell_component);
+ EvolutionShellComponent *shell_component;
+
+ running_objects++;
+
+ shell_component = evolution_shell_component_new (folder_types,
+ create_view,
+ NULL, NULL, NULL, NULL,
+ NULL);
+ gtk_signal_connect (GTK_OBJECT (shell_component), "destroy",
+ GTK_SIGNAL_FUNC (factory_destroy), NULL);
+ gtk_signal_connect (GTK_OBJECT (shell_component), "owner_set",
+ GTK_SIGNAL_FUNC (owner_set_cb), NULL);
+ gtk_signal_connect (GTK_OBJECT (shell_component), "owner_unset",
+ GTK_SIGNAL_FUNC (owner_unset_cb), NULL);
+
+ return BONOBO_OBJECT (shell_component);
}
void
component_factory_init (void)
{
- if (factory != NULL)
- return;
-
- factory = bonobo_generic_factory_new (COMPONENT_FACTORY_IID,
- factory_fn, NULL);
-
- if (factory == NULL) {
- e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
- _("Cannot initialize Evolution's Executive Summary component."));
- exit (1);
- }
+ if (factory != NULL)
+ return;
+
+ factory = bonobo_generic_factory_new (COMPONENT_FACTORY_IID,
+ factory_fn, NULL);
+
+ if (factory == NULL) {
+ e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
+ _("Cannot initialize Evolution's Executive Summary component."));
+ exit (1);
+ }
}
diff --git a/executive-summary/component/e-summary-callbacks.c b/executive-summary/component/e-summary-callbacks.c
index 383fe47bc0..4d9929fc7e 100644
--- a/executive-summary/component/e-summary-callbacks.c
+++ b/executive-summary/component/e-summary-callbacks.c
@@ -217,6 +217,23 @@ html_page_changed_cb (GtkEntry *entry,
}
static void
+column_spinner_changed_cb (GtkEntry *entry,
+ PropertyData *data)
+{
+ ESummaryPrefs *prefs;
+ char *value;
+
+ prefs = data->esummary->tmp_prefs;
+
+ gnome_property_box_changed (data->box);
+ value = gtk_entry_get_text (entry);
+ if (value == NULL || *value == '\0')
+ return;
+
+ prefs->columns = atoi (value);
+}
+
+static void
apply_prefs_cb (GnomePropertyBox *property_box,
int page,
ESummary *esummary)
@@ -238,7 +255,8 @@ configure_summary (GtkWidget *widget,
static GtkWidget *prefs = NULL;
PropertyData *data;
GtkWidget *html_page;
- GtkWidget *vbox, *html;
+ GtkWidget *vbox, *html, *spinner;
+ char *tmp;
if (prefs != NULL) {
g_assert (GTK_WIDGET_REALIZED (prefs));
@@ -279,6 +297,14 @@ configure_summary (GtkWidget *widget,
"changed", GTK_SIGNAL_FUNC (html_page_changed_cb),
data);
+ spinner = glade_xml_get_widget (data->xml, "columnspinner");
+
+ tmp = g_strdup_printf ("%d", esummary->prefs->columns);
+ gtk_entry_set_text (GTK_ENTRY (spinner), tmp);
+ g_free (tmp);
+ gtk_signal_connect (GTK_OBJECT (spinner), "changed",
+ GTK_SIGNAL_FUNC (column_spinner_changed_cb), data);
+
gtk_signal_connect (GTK_OBJECT (prefs), "apply",
GTK_SIGNAL_FUNC (apply_prefs_cb), esummary);
diff --git a/executive-summary/component/e-summary-factory.c b/executive-summary/component/e-summary-factory.c
index 5d32b3ee6b..4fcd77db48 100644
--- a/executive-summary/component/e-summary-factory.c
+++ b/executive-summary/component/e-summary-factory.c
@@ -114,6 +114,7 @@ control_deactivate (BonoboControl *control,
BonoboUIComponent *ui_component,
ESummary *esummary)
{
+ e_summary_unset_message (esummary);
bonobo_ui_component_unset_container (ui_component);
}
diff --git a/executive-summary/component/e-summary-prefs.c b/executive-summary/component/e-summary-prefs.c
index ffefdcd583..440c3837f4 100644
--- a/executive-summary/component/e-summary-prefs.c
+++ b/executive-summary/component/e-summary-prefs.c
@@ -56,10 +56,27 @@ e_summary_prefs_copy (ESummaryPrefs *prefs)
copy = e_summary_prefs_new ();
copy->page = g_strdup (prefs->page);
+ copy->columns = prefs->columns;
return copy;
}
+gboolean
+e_summary_prefs_compare (ESummaryPrefs *p1,
+ ESummaryPrefs *p2)
+{
+ if (p1 == p2)
+ return TRUE;
+
+ if (strcmp (p1->page, p2->page) == 0)
+ return TRUE;
+
+ if (p1->columns == p2->columns)
+ return TRUE;
+
+ return FALSE;
+}
+
ESummaryPrefs *
e_summary_prefs_load (const char *path)
{
@@ -75,6 +92,9 @@ e_summary_prefs_load (const char *path)
prefs->page = gnome_config_get_string (item);
g_free (item);
+ item = g_strdup_printf ("=%s/e-summary=/executive-summary/columns=3", path);
+ prefs->columns = gnome_config_get_int (item);
+ g_free (item);
return prefs;
}
@@ -92,6 +112,10 @@ e_summary_prefs_save (ESummaryPrefs *prefs,
gnome_config_set_string (item, prefs->page);
g_free (item);
+ item = g_strdup_printf ("=%s/e-summary=/executive-summary/columns", path);
+ gnome_config_set_int (item, prefs->columns);
+ g_free (item);
+
gnome_config_sync ();
gnome_config_drop_all ();
}
diff --git a/executive-summary/component/e-summary-prefs.h b/executive-summary/component/e-summary-prefs.h
index 95fc6af2c2..9dc7b09404 100644
--- a/executive-summary/component/e-summary-prefs.h
+++ b/executive-summary/component/e-summary-prefs.h
@@ -26,12 +26,19 @@
typedef struct _ESummaryPrefs ESummaryPrefs;
struct _ESummaryPrefs {
- char *page;
+ char *page; /* Background HTML page URL */
+ int columns; /* Number of components per row (Default = 3) */
+
+ /* If anything is added here, don't forget to add
+ copy, compare, load and save routines to the appropriate
+ functions. */
};
ESummaryPrefs *e_summary_prefs_new (void);
void e_summary_prefs_free (ESummaryPrefs *prefs);
ESummaryPrefs *e_summary_prefs_copy (ESummaryPrefs *prefs);
+gboolean e_summary_prefs_compare (ESummaryPrefs *p1,
+ ESummaryPrefs *p2);
ESummaryPrefs *e_summary_prefs_load (const char *path);
void e_summary_prefs_save (ESummaryPrefs *prefs,
const char *path);
diff --git a/executive-summary/component/e-summary.c b/executive-summary/component/e-summary.c
index 4172b7ce0f..ae55f63e53 100644
--- a/executive-summary/component/e-summary.c
+++ b/executive-summary/component/e-summary.c
@@ -104,6 +104,7 @@ e_summary_destroy (GtkObject *object)
e_summary_save_state (esummary, prefix);
g_free (prefix);
+ e_summary_prefs_free (esummary->prefs);
for (l = priv->window_list; l; l = l->next)
e_summary_window_free (l->data);
g_list_free (priv->window_list);
@@ -409,9 +410,10 @@ e_summary_display_window (ESummary *esummary,
header = g_strdup_printf ("<td bgcolor=\"%s\" valign=\"top\">", colour[col % 2]);
gtk_html_write (GTK_HTML (priv->html), priv->stream, header, strlen (header));
+ g_free (header);
if (window->html != CORBA_OBJECT_NIL) {
- char *html;
+ char *html = NULL;
CORBA_Environment ev;
CORBA_exception_init (&ev);
@@ -420,11 +422,14 @@ e_summary_display_window (ESummary *esummary,
if (ev._major != CORBA_NO_EXCEPTION) {
CORBA_exception_free (&ev);
g_warning ("Cannot get HTML.");
+ if (html)
+ CORBA_free (html);
} else {
CORBA_exception_free (&ev);
-
+
gtk_html_write (GTK_HTML (priv->html), priv->stream,
html, strlen (html));
+ CORBA_free (html);
}
} else {
#if 0
@@ -446,9 +451,11 @@ e_summary_rebuild_page (ESummary *esummary)
{
ESummaryPrivate *priv;
GList *windows;
- char *service_table = "<table numcols=\"3\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" height=\"100%\">";
+ char *service_table = "<table numcols=\"%d\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" height=\"100%%\" width=\"100%%\">";
+ char *tmp;
int numwindows, numrows;
int i, j, k;
+ int columns;
g_return_val_if_fail (esummary != NULL, FALSE);
g_return_val_if_fail (IS_E_SUMMARY (esummary), FALSE);
@@ -480,16 +487,19 @@ e_summary_rebuild_page (ESummary *esummary)
}
/* Load the start of the services */
- gtk_html_write (GTK_HTML (priv->html), priv->stream, service_table,
- strlen (service_table));
+ tmp = g_strdup_printf (service_table, esummary->prefs->columns);
+ gtk_html_write (GTK_HTML (priv->html), priv->stream, tmp, strlen (tmp));
+ g_free (tmp);
/* Load each of the services */
numwindows = g_list_length (priv->window_list);
+ columns = esummary->prefs->columns;
+
windows = priv->window_list;
- if (numwindows % 3 == 0)
- numrows = numwindows / 3;
+ if (numwindows % columns == 0)
+ numrows = numwindows / columns;
else
- numrows = numwindows / 3 + 1;
+ numrows = numwindows / columns + 1;
for (i = 0; i < numrows; i++) {
GList *window = windows;
@@ -498,14 +508,15 @@ e_summary_rebuild_page (ESummary *esummary)
/* Do the same row twice:
Once for the title, once for the contents */
for (j = 0; j < 2; j++) {
+ int limit;
gtk_html_write (GTK_HTML (priv->html), priv->stream,
"<tr>", 4);
/* For each window on row i */
- for (k = 0; k < MIN (3, (numwindows - (i * 3))); k++) {
+ limit = MIN (columns, (numwindows - (i * columns)));
+ for (k = 0; k < limit; k++) {
- g_print ("%d of %d\n", k,
- MIN (3, (numwindows - (i * 3))));
+ g_print ("%d of %d\n", k, limit);
if (window == NULL)
break;
@@ -523,7 +534,7 @@ e_summary_rebuild_page (ESummary *esummary)
if (window != NULL)
window = window->next;
-
+
if (window == NULL)
break;
}
@@ -672,20 +683,18 @@ e_summary_add_service (ESummary *esummary,
"IDL:Bonobo/PersistStream:1.0",
&ev);
window->persiststream = (Bonobo_PersistStream) unknown;
-
+
unknown = Bonobo_Unknown_queryInterface (component,
"IDL:Bonobo/PropertyControl:1.0",
&ev);
window->propertycontrol = (Bonobo_PropertyControl) unknown;
/* Cache the title and icon */
- window->title = g_strdup (bonobo_property_bag_client_get_value_string (
- window->propertybag,
- "window_title",
- NULL));
- window->icon = g_strdup (bonobo_property_bag_client_get_value_string (
- window->propertybag,
- "window_icon", NULL));
+ window->title = bonobo_property_bag_client_get_value_string (window->propertybag,
+ "window_title",
+ NULL);
+ window->icon = bonobo_property_bag_client_get_value_string (window->propertybag,
+ "window_icon", NULL);
CORBA_exception_free (&ev);
priv->window_list = g_list_append (priv->window_list, window);
@@ -739,29 +748,15 @@ e_summary_window_free (ESummaryWindow *window)
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("CORBA ERROR: %s", CORBA_exception_id (&ev));
}
- bonobo_object_release_unref (window->event_source, &ev);
- }
-
- if (window->propertybag != CORBA_OBJECT_NIL) {
- bonobo_object_release_unref (window->propertybag, &ev);
- }
-
- if (window->persiststream != CORBA_OBJECT_NIL) {
- bonobo_object_release_unref (window->persiststream, &ev);
- }
-
- if (window->propertycontrol != CORBA_OBJECT_NIL) {
- bonobo_object_release_unref (window->propertycontrol, &ev);
- }
-
- if (window->listener) {
- bonobo_object_unref (BONOBO_OBJECT (window->listener));
- }
-
- if (window->html != CORBA_OBJECT_NIL) {
- bonobo_object_release_unref (window->html, &ev);
+ bonobo_object_release_unref (window->event_source, &ev);
}
+ bonobo_object_release_unref (window->propertybag, &ev);
+ bonobo_object_release_unref (window->persiststream, &ev);
+ bonobo_object_release_unref (window->propertycontrol, &ev);
+ bonobo_object_unref (BONOBO_OBJECT (window->listener));
+ bonobo_object_release_unref (window->html, &ev);
+
bonobo_object_release_unref (window->component, &ev);
CORBA_exception_free (&ev);
@@ -905,10 +900,12 @@ e_summary_load_page (ESummary *esummary)
priv = esummary->private;
- filename = g_strdup (esummary->prefs->page);
/* Pass NULL to reset the page to the default */
- if (filename == NULL || *filename == '\0') {
+ if ((esummary->prefs->page) == NULL ||
+ *(esummary->prefs->page) == '\0') {
filename = g_concat_dir_and_file (EVOLUTION_DATADIR, "/evolution/summary.html");
+ } else {
+ filename = g_strdup (esummary->prefs->page);
}
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (esummary));
@@ -953,8 +950,13 @@ e_summary_load_page (ESummary *esummary)
return;
}
+ if (priv->header != NULL)
+ g_free (priv->header);
priv->header = g_strndup (str, comment - str);
priv->header_len = strlen (priv->header);
+
+ if (priv->footer != NULL)
+ g_free (priv->footer);
priv->footer = g_strdup (comment);
priv->footer_len = strlen (priv->footer);
g_free (str);
@@ -1079,10 +1081,6 @@ load_component (ESummary *esummary,
void
e_summary_reconfigure (ESummary *esummary)
{
- ESummaryPrefs *prefs;
-
- prefs = esummary->prefs;
-
e_summary_load_page (esummary);
e_summary_queue_rebuild (esummary);
}
@@ -1125,6 +1123,9 @@ e_summary_load_state (ESummary *esummary,
g_free (fullpath);
/* Load the preferences */
+ if (esummary->prefs != NULL)
+ e_summary_prefs_free (esummary->prefs);
+
esummary->prefs = e_summary_prefs_load (path);
e_summary_reconfigure (esummary);
}