aboutsummaryrefslogtreecommitdiffstats
path: root/executive-summary/component
diff options
context:
space:
mode:
Diffstat (limited to 'executive-summary/component')
-rw-r--r--executive-summary/component/e-summary-url.c63
-rw-r--r--executive-summary/component/e-summary.c92
-rw-r--r--executive-summary/component/e-summary.h6
3 files changed, 35 insertions, 126 deletions
diff --git a/executive-summary/component/e-summary-url.c b/executive-summary/component/e-summary-url.c
index a997184e42..ab7dacc52d 100644
--- a/executive-summary/component/e-summary-url.c
+++ b/executive-summary/component/e-summary-url.c
@@ -75,7 +75,8 @@ static char *descriptions[] = {
typedef struct _PropertyDialog {
BonoboListener *listener;
- Bonobo_Listener corba_listener;
+ int listener_id;
+
Bonobo_EventSource eventsource;
GtkWidget *dialog;
} PropertyDialog;
@@ -85,8 +86,6 @@ typedef struct _PropertyDialog {
static ESummaryCache *image_cache = NULL;
#endif
-#define USE_ASYNC
-
gboolean e_summary_url_mail_compose (ESummary *esummary,
const char *url);
gboolean e_summary_url_exec (const char *exec);
@@ -100,8 +99,6 @@ struct _DownloadInfo {
};
typedef struct _DownloadInfo DownloadInfo;
-#ifdef USE_ASYNC
-
static void
close_callback (GnomeVFSAsyncHandle *handle,
GnomeVFSResult result,
@@ -157,7 +154,6 @@ open_callback (GnomeVFSAsyncHandle *handle,
info->buffer = g_new (char, 4096);
gnome_vfs_async_read (handle, info->buffer, 4095, read_callback, info);
}
-#endif
void
e_summary_url_request (GtkHTML *html,
@@ -165,14 +161,10 @@ e_summary_url_request (GtkHTML *html,
GtkHTMLStream *stream)
{
char *filename;
-#ifndef USE_ASYNC
- GnomeVFSHandle *handle = NULL;
- GnomeVFSResult result;
-#else
GnomeVFSAsyncHandle *handle;
DownloadInfo *info;
-#endif
+ g_print ("url: %s\n", url);
if (strncasecmp (url, "file:", 5) == 0) {
url += 5;
filename = e_pixmap_file (url);
@@ -187,42 +179,7 @@ e_summary_url_request (GtkHTML *html,
}
g_print ("Filename: %s\n", filename);
-#ifndef USE_ASYNC
- result = gnome_vfs_open (&handle, filename, GNOME_VFS_OPEN_READ);
-
- if (result != GNOME_VFS_OK) {
- g_warning ("%s: %s", filename,
- gnome_vfs_result_to_string (result));
- g_free (filename);
- gtk_html_stream_close (stream, GTK_HTML_STREAM_ERROR);
- return;
- }
-
- g_free (filename);
- while (1) {
- char buffer[4096];
- GnomeVFSFileSize size;
-
- /* Clear buffer */
- memset (buffer, 0x00, 4096);
-
- result = gnome_vfs_read (handle, buffer, 4096, &size);
- if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) {
- g_warning ("Error reading data: %s",
- gnome_vfs_result_to_string (result));
- gnome_vfs_close (handle);
- gtk_html_stream_close (stream, GTK_HTML_STREAM_ERROR);
- }
- if (size == 0)
- break; /* EOF */
-
- gtk_html_stream_write (stream, buffer, size);
- }
-
- gtk_html_stream_close (stream, GTK_HTML_STREAM_OK);
- gnome_vfs_close (handle);
-#else
info = g_new (DownloadInfo, 1);
info->stream = stream;
info->uri = filename;
@@ -230,8 +187,6 @@ e_summary_url_request (GtkHTML *html,
gnome_vfs_async_open (&handle, filename, GNOME_VFS_OPEN_READ,
(GnomeVFSAsyncOpenCallback) open_callback, info);
-#endif
-
}
static char *
@@ -463,13 +418,12 @@ dialog_destroyed (GtkObject *object,
CORBA_exception_init (&ev);
Bonobo_EventSource_removeListener (dialog->eventsource,
- dialog->corba_listener, &ev);
+ dialog->listener_id, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("Error: %s", CORBA_exception_id (&ev));
}
bonobo_object_unref (BONOBO_OBJECT (dialog->listener));
- bonobo_object_release_unref (dialog->eventsource, &ev);
CORBA_exception_free (&ev);
g_free (dialog);
}
@@ -484,6 +438,7 @@ e_summary_url_click (GtkWidget *widget,
int address;
ESummaryWindow *window;
Bonobo_Control control;
+ Bonobo_Listener corba_listener;
GtkWidget *prefsbox, *control_widget;
CORBA_Environment ev;
PropertyDialog *data;
@@ -533,11 +488,11 @@ e_summary_url_click (GtkWidget *widget,
data->dialog = prefsbox;
CORBA_exception_init (&ev);
- data->eventsource = bonobo_object_dup_ref (window->event_source, &ev);
+ data->eventsource = window->event_source;
data->listener = bonobo_listener_new (property_event, data);
- data->corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (data->listener));
- Bonobo_EventSource_addListener (data->eventsource,
- data->corba_listener, &ev);
+ corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (data->listener));
+ data->listener_id = Bonobo_EventSource_addListener (data->eventsource,
+ corba_listener, &ev);
gtk_signal_connect (GTK_OBJECT (prefsbox), "apply",
GTK_SIGNAL_FUNC (property_apply),
diff --git a/executive-summary/component/e-summary.c b/executive-summary/component/e-summary.c
index 12ed32376e..4172b7ce0f 100644
--- a/executive-summary/component/e-summary.c
+++ b/executive-summary/component/e-summary.c
@@ -572,44 +572,31 @@ e_summary_queue_rebuild (ESummary *esummary)
}
static void
-html_event (BonoboListener *listener,
- char *event_name,
- CORBA_any *any,
- CORBA_Environment *ev,
- gpointer user_data)
+listener_event (BonoboListener *listener,
+ char *event_name,
+ BonoboArg *event_data,
+ CORBA_Environment *ev,
+ gpointer user_data)
{
ESummaryWindow *window = (ESummaryWindow *) user_data;
- g_print ("Event: %s\n", event_name);
- if (strcmp (event_name, EXECUTIVE_SUMMARY_HTML_VIEW_HTML_CHANGED) != 0) {
- return;
- }
-
- e_summary_queue_rebuild (window->esummary);
-}
-
-static void
-prop_changed_cb (BonoboListener *listener,
- char *name,
- BonoboArg *arg,
- CORBA_Environment *ev,
- ESummaryWindow *window)
-{
- if (strcmp (name, "window_title") == 0) {
+ if (strcmp (event_name, "Bonobo/Property:change:window_title") == 0) {
if (window->title != NULL)
g_free (window->title);
- window->title = g_strdup (BONOBO_ARG_GET_STRING (arg));
- e_summary_queue_rebuild (window->esummary);
- return;
- }
- if (strcmp (name, "window_icon") == 0) {
+ window->title = g_strdup (BONOBO_ARG_GET_STRING (event_data));
+ e_summary_queue_rebuild (window->esummary);
+ } else if (strcmp (event_name, "Bonobo/Property:change:window_icon") == 0) {
if (window->icon != NULL)
g_free (window->icon);
- window->icon = g_strdup (BONOBO_ARG_GET_STRING (arg));
+
+ window->icon = g_strdup (BONOBO_ARG_GET_STRING (event_data));
+ e_summary_queue_rebuild (window->esummary);
+ } else if (strcmp (event_name, EXECUTIVE_SUMMARY_HTML_VIEW_HTML_CHANGED) == 0) {
e_summary_queue_rebuild (window->esummary);
- return;
}
+
+ return;
}
ESummaryWindow *
@@ -620,6 +607,7 @@ e_summary_add_service (ESummary *esummary,
ESummaryWindow *window;
ESummaryPrivate *priv;
Bonobo_Unknown unknown = CORBA_OBJECT_NIL;
+ Bonobo_Listener listener;
CORBA_Environment ev;
g_return_val_if_fail (esummary != NULL, NULL);
@@ -669,25 +657,11 @@ e_summary_add_service (ESummary *esummary,
return NULL;
}
- if (window->html != CORBA_OBJECT_NIL) {
- Bonobo_Listener listener;
- CORBA_Environment ev2;
-
- /* If HTML view, then set up the listeners. */
- window->event_source = Bonobo_Unknown_queryInterface (window->html,
- "IDL:Bonobo/EventSource:1.0",
- &ev);
- window->html_listener = bonobo_listener_new (html_event,
- window);
- listener = bonobo_object_corba_objref (BONOBO_OBJECT (window->html_listener));
- window->html_corba_listener = listener;
-
- CORBA_exception_init (&ev2);
- Bonobo_EventSource_addListener (window->event_source,
- listener, &ev2);
- /* Catch error? FIXME */
- CORBA_exception_free (&ev2);
- }
+ window->listener = bonobo_listener_new (NULL, NULL);
+ gtk_signal_connect (GTK_OBJECT (window->listener), "event_notify",
+ GTK_SIGNAL_FUNC (listener_event), window);
+ listener = bonobo_object_corba_objref (BONOBO_OBJECT (window->listener));
+ window->listener_id = Bonobo_EventSource_addListener (window->event_source, listener, &ev);
unknown = Bonobo_Unknown_queryInterface (component,
"IDL:Bonobo/PropertyBag:1.0",
@@ -712,20 +686,6 @@ e_summary_add_service (ESummary *esummary,
window->icon = g_strdup (bonobo_property_bag_client_get_value_string (
window->propertybag,
"window_icon", NULL));
- /* Listen to changes */
- if (window->propertycontrol != CORBA_OBJECT_NIL) {
- Bonobo_Listener listener;
- CORBA_Environment ev2;
-
- window->listener = bonobo_listener_new (NULL, NULL);
- listener = bonobo_object_corba_objref (BONOBO_OBJECT (window->html_listener));
-
- Bonobo_EventSource_addListener (window->event_source,
- listener, &ev);
-
- gtk_signal_connect (GTK_OBJECT (window->listener), "event_notify",
- GTK_SIGNAL_FUNC (prop_changed_cb), window);
- }
CORBA_exception_free (&ev);
priv->window_list = g_list_append (priv->window_list, window);
@@ -774,7 +734,7 @@ e_summary_window_free (ESummaryWindow *window)
if (window->event_source != CORBA_OBJECT_NIL) {
Bonobo_EventSource_removeListener (window->event_source,
- window->html_corba_listener,
+ window->listener_id,
&ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("CORBA ERROR: %s", CORBA_exception_id (&ev));
@@ -782,10 +742,6 @@ e_summary_window_free (ESummaryWindow *window)
bonobo_object_release_unref (window->event_source, &ev);
}
- if (window->html != CORBA_OBJECT_NIL) {
- bonobo_object_release_unref (window->html, &ev);
- }
-
if (window->propertybag != CORBA_OBJECT_NIL) {
bonobo_object_release_unref (window->propertybag, &ev);
}
@@ -802,8 +758,8 @@ e_summary_window_free (ESummaryWindow *window)
bonobo_object_unref (BONOBO_OBJECT (window->listener));
}
- if (window->html_listener) {
- bonobo_object_unref (BONOBO_OBJECT (window->html_listener));
+ if (window->html != CORBA_OBJECT_NIL) {
+ bonobo_object_release_unref (window->html, &ev);
}
bonobo_object_release_unref (window->component, &ev);
diff --git a/executive-summary/component/e-summary.h b/executive-summary/component/e-summary.h
index 3ac6b1eaeb..470863a9f5 100644
--- a/executive-summary/component/e-summary.h
+++ b/executive-summary/component/e-summary.h
@@ -54,13 +54,11 @@ struct _ESummaryWindow {
Bonobo_PersistStream persiststream;
Bonobo_PropertyBag propertybag;
Bonobo_PropertyControl propertycontrol;
- Bonobo_EventSource property_event_source;
Bonobo_EventSource event_source;
-
+ /* Listener for the event_source */
BonoboListener *listener;
- BonoboListener *html_listener;
- Bonobo_Listener html_corba_listener;
+ int listener_id;
char *iid;
char *title;