[gtkhtml] Remove duplicate policy supplied by EWebView.
- From: Matthew Barnes <mbarnes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtkhtml] Remove duplicate policy supplied by EWebView.
- Date: Sat, 26 Dec 2009 02:04:37 +0000 (UTC)
commit b505c8faa1a6ccc32d14713cd1d47d3d9731c739
Author: Matthew Barnes <mbarnes redhat com>
Date: Fri Dec 25 20:44:55 2009 -0500
Remove duplicate policy supplied by EWebView.
Nothing but Evolution uses GtkhtmlEditor, otherwise this would be a
regression.
GtkhtmlEditor now allows Evoluiton to supply an EWebView instance to use
in the editor window, so remove the asynchronous URI fetching which was
copied from EWebView.
components/editor/gtkhtml-editor-private.c | 206 ----------------------------
components/editor/gtkhtml-editor-private.h | 9 --
components/editor/gtkhtml-editor.c | 66 +---------
3 files changed, 1 insertions(+), 280 deletions(-)
---
diff --git a/components/editor/gtkhtml-editor-private.c b/components/editor/gtkhtml-editor-private.c
index 49aa011..beac781 100644
--- a/components/editor/gtkhtml-editor-private.c
+++ b/components/editor/gtkhtml-editor-private.c
@@ -153,166 +153,6 @@ editor_replace_all_cb (GtkhtmlEditor *editor,
/************************* End Spell Dialog Callbacks ************************/
-/************************ Begin URI Request Callbacks ************************/
-
-static GtkhtmlEditorRequest *
-editor_request_new (GtkhtmlEditor *editor,
- const gchar *uri,
- GtkHTMLStream *stream,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GSimpleAsyncResult *simple;
- GtkhtmlEditorRequest *request;
- GList *list;
-
- request = g_slice_new (GtkhtmlEditorRequest);
-
- simple = g_simple_async_result_new (
- G_OBJECT (editor), callback,
- user_data, gtkhtml_editor_request_async);
-
- if (cancellable != NULL)
- g_object_ref (cancellable);
-
- /* Try to detect file paths posing as URIs. */
- if (*uri == '/')
- request->file = g_file_new_for_path (uri);
- else
- request->file = g_file_new_for_uri (uri);
-
- request->editor = g_object_ref (editor);
- request->cancellable = cancellable;
- request->simple = simple;
- request->input_stream = NULL;
- request->output_stream = stream;
-
- list = request->editor->priv->requests;
- list = g_list_prepend (list, request);
- request->editor->priv->requests = list;
-
- return request;
-}
-
-static void
-editor_request_free (GtkhtmlEditorRequest *request)
-{
- GList *list;
-
- /* Do not free the GSimpleAsyncResult. */
-
- list = request->editor->priv->requests;
- list = g_list_remove (list, request);
- request->editor->priv->requests = list;
-
- g_object_unref (request->file);
- g_object_unref (request->editor);
-
- if (request->cancellable != NULL)
- g_object_unref (request->cancellable);
-
- if (request->input_stream != NULL)
- g_object_unref (request->input_stream);
-
- g_slice_free (GtkhtmlEditorRequest, request);
-}
-
-static gboolean
-editor_request_check_for_error (GtkhtmlEditorRequest *request,
- GError *error)
-{
- GtkHTML *html;
- GtkHTMLStream *stream;
- GSimpleAsyncResult *simple;
-
- if (error == NULL)
- return FALSE;
-
- stream = request->output_stream;
- html = gtkhtml_editor_get_html (request->editor);
- gtk_html_end (html, stream, GTK_HTML_STREAM_ERROR);
-
- /* Steal the result. */
- simple = request->simple;
- request->simple = NULL;
-
- g_simple_async_result_set_from_error (simple, error);
- g_simple_async_result_complete (simple);
- g_error_free (error);
-
- editor_request_free (request);
-
- return TRUE;
-}
-
-static void
-editor_request_stream_read_cb (GInputStream *input_stream,
- GAsyncResult *result,
- GtkhtmlEditorRequest *request)
-{
- GtkHTML *html;
- GtkHTMLStream *stream;
- gssize bytes_read;
- GError *error = NULL;
-
- stream = request->output_stream;
- html = gtkhtml_editor_get_html (request->editor);
-
- bytes_read = g_input_stream_read_finish (input_stream, result, &error);
-
- if (editor_request_check_for_error (request, error))
- return;
-
- if (bytes_read == 0) {
- GSimpleAsyncResult *simple;
-
- /* Steal the result. */
- simple = request->simple;
- request->simple = NULL;
-
- gtk_html_end (html, stream, GTK_HTML_STREAM_OK);
-
- g_simple_async_result_set_op_res_gboolean (simple, TRUE);
- g_simple_async_result_complete (simple);
- editor_request_free (request);
-
- return;
- }
-
- gtk_html_write (html, stream, request->buffer, bytes_read);
-
- g_input_stream_read_async (
- request->input_stream, request->buffer,
- sizeof (request->buffer), G_PRIORITY_DEFAULT,
- request->cancellable, (GAsyncReadyCallback)
- editor_request_stream_read_cb, request);
-}
-
-static void
-editor_request_read_cb (GFile *file,
- GAsyncResult *result,
- GtkhtmlEditorRequest *request)
-{
- GFileInputStream *input_stream;
- GError *error = NULL;
-
- /* Input stream might be NULL, so don't use cast macro. */
- input_stream = g_file_read_finish (file, result, &error);
- request->input_stream = (GInputStream *) input_stream;
-
- if (editor_request_check_for_error (request, error))
- return;
-
- g_input_stream_read_async (
- request->input_stream, request->buffer,
- sizeof (request->buffer), G_PRIORITY_DEFAULT,
- request->cancellable, (GAsyncReadyCallback)
- editor_request_stream_read_cb, request);
-}
-
-/************************* End URI Request Callbacks *************************/
-
void
gtkhtml_editor_private_init (GtkhtmlEditor *editor)
{
@@ -670,52 +510,6 @@ gtkhtml_editor_insert_file (GtkhtmlEditor *editor,
return response;
}
-void
-gtkhtml_editor_request_async (GtkhtmlEditor *editor,
- const gchar *uri,
- GtkHTMLStream *stream,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- GtkhtmlEditorRequest *request;
-
- g_return_if_fail (GTKHTML_IS_EDITOR (editor));
- g_return_if_fail (uri != NULL);
- g_return_if_fail (stream != NULL);
- g_return_if_fail (callback != NULL);
-
- if (cancellable != NULL)
- g_return_if_fail (G_IS_CANCELLABLE (cancellable));
-
- request = editor_request_new (
- editor, uri, stream, cancellable, callback, user_data);
-
- g_file_read_async (
- request->file, G_PRIORITY_DEFAULT,
- request->cancellable, (GAsyncReadyCallback)
- editor_request_read_cb, request);
-}
-
-gboolean
-gtkhtml_editor_request_finish (GtkhtmlEditor *editor,
- GAsyncResult *result,
- GError **error)
-{
- GSimpleAsyncResult *simple;
- gboolean success;
-
- g_return_val_if_fail (GTKHTML_IS_EDITOR (editor), FALSE);
- g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (result), FALSE);
-
- simple = G_SIMPLE_ASYNC_RESULT (result);
- success = g_simple_async_result_get_op_res_gboolean (simple);
- g_simple_async_result_propagate_error (simple, error);
- g_object_unref (simple);
-
- return success;
-}
-
GFile *
gtkhtml_editor_run_open_dialog (GtkhtmlEditor *editor,
const gchar *title,
diff --git a/components/editor/gtkhtml-editor-private.h b/components/editor/gtkhtml-editor-private.h
index 60d34b0..0a9667f 100644
--- a/components/editor/gtkhtml-editor-private.h
+++ b/components/editor/gtkhtml-editor-private.h
@@ -205,15 +205,6 @@ gchar * gtkhtml_editor_find_data_file (const gchar *basename);
gint gtkhtml_editor_insert_file (GtkhtmlEditor *editor,
const gchar *title,
GCallback response_cb);
-void gtkhtml_editor_request_async (GtkhtmlEditor *editor,
- const gchar *uri,
- GtkHTMLStream *stream,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean gtkhtml_editor_request_finish (GtkhtmlEditor *editor,
- GAsyncResult *result,
- GError **error);
GFile * gtkhtml_editor_run_open_dialog (GtkhtmlEditor *editor,
const gchar *title,
GtkCallback customize_func,
diff --git a/components/editor/gtkhtml-editor.c b/components/editor/gtkhtml-editor.c
index cbfc4f0..47918de 100644
--- a/components/editor/gtkhtml-editor.c
+++ b/components/editor/gtkhtml-editor.c
@@ -213,51 +213,7 @@ editor_url_requested_cb (GtkhtmlEditor *editor,
const gchar *url,
GtkHTMLStream *stream)
{
- GtkHTML *html;
- GMappedFile *mapped_file;
- GtkHTMLStreamStatus status;
- gchar *filename = NULL;
- GError *error = NULL;
-
- html = gtkhtml_editor_get_html (editor);
-
- /* We can only handle local URLs here. */
- if (g_ascii_strncasecmp (url, "file:/", 6) != 0) {
- g_signal_emit (editor, signals[URI_REQUESTED], 0, url, stream);
- return;
- }
-
- filename = g_filename_from_uri (url, NULL, &error);
- if (filename == NULL)
- goto exit;
-
- mapped_file = g_mapped_file_new (filename, FALSE, &error);
- if (mapped_file == NULL)
- goto exit;
-
- gtk_html_write (
- html, stream,
- g_mapped_file_get_contents (mapped_file),
- g_mapped_file_get_length (mapped_file));
-
-#if GLIB_CHECK_VERSION(2,21,3)
- g_mapped_file_unref (mapped_file);
-#else
- g_mapped_file_free (mapped_file);
-#endif
-
-exit:
- if (error == NULL)
- status = GTK_HTML_STREAM_OK;
- else {
- status = GTK_HTML_STREAM_ERROR;
- g_warning ("%s", error->message);
- g_error_free (error);
- }
-
- gtk_html_end (html, stream, status);
-
- g_free (filename);
+ g_signal_emit (editor, signals[URI_REQUESTED], 0, url, stream);
}
static void
@@ -795,25 +751,6 @@ editor_select_all (GtkhtmlEditor *editor)
}
static void
-editor_uri_requested_ready_cb (GtkhtmlEditor *editor,
- GAsyncResult *result)
-{
- /* XXX Do something in the event of an error? */
- gtkhtml_editor_request_finish (editor, result, NULL);
-}
-
-static void
-editor_uri_requested (GtkhtmlEditor *editor,
- const gchar *uri,
- GtkHTMLStream *stream)
-{
- /* XXX Currently no way to cancel this. */
- gtkhtml_editor_request_async (
- editor, uri, stream, NULL, (GAsyncReadyCallback)
- editor_uri_requested_ready_cb, NULL);
-}
-
-static void
editor_class_init (GtkhtmlEditorClass *class)
{
GObjectClass *object_class;
@@ -832,7 +769,6 @@ editor_class_init (GtkhtmlEditorClass *class)
class->copy_clipboard = editor_copy_clipboard;
class->paste_clipboard = editor_paste_clipboard;
class->select_all = editor_select_all;
- class->uri_requested = editor_uri_requested;
g_object_class_install_property (
object_class,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]