[anjal] Add mozilla as another renderer.



commit 3674a42982258479eb933426cabc0f0123dea48f
Author: Srinivasa Ragavan <sragavan novell com>
Date:   Fri Apr 17 13:47:35 2009 +0530

    Add mozilla as another renderer.
---
 src/em-mozembed-stream.c |  151 ++++++++++++++++++++++++++++++++++++++++++++++
 src/em-mozembed-stream.h |   66 ++++++++++++++++++++
 2 files changed, 217 insertions(+), 0 deletions(-)

diff --git a/src/em-mozembed-stream.c b/src/em-mozembed-stream.c
new file mode 100644
index 0000000..41d70a9
--- /dev/null
+++ b/src/em-mozembed-stream.c
@@ -0,0 +1,151 @@
+/*
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>  
+ *
+ *
+ * Authors:
+ *		Srinivasa Ragavan <sragavan novell com
+ *
+ * Copyright (C) 2009 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <gtk/gtk.h>
+#include "em-mozembed-stream.h"
+
+#define d(x)
+
+static void em_mozembed_stream_class_init (EMMozEmbedStreamClass *klass);
+static void em_mozembed_stream_init (CamelObject *object);
+static void em_mozembed_stream_finalize (CamelObject *object);
+
+static ssize_t emms_sync_write(CamelStream *stream, const char *buffer, size_t n);
+static int emms_sync_close(CamelStream *stream);
+static int emms_sync_flush(CamelStream *stream);
+
+static EMSyncStreamClass *parent_class = NULL;
+
+CamelType
+em_mozembed_stream_get_type (void)
+{
+	static CamelType type = CAMEL_INVALID_TYPE;
+
+	if (type == CAMEL_INVALID_TYPE) {
+		parent_class = (EMSyncStreamClass *)em_sync_stream_get_type();
+		type = camel_type_register (em_sync_stream_get_type(),
+					    "EMMozEmbedStream",
+					    sizeof (EMMozEmbedStream),
+					    sizeof (EMMozEmbedStreamClass),
+					    (CamelObjectClassInitFunc) em_mozembed_stream_class_init,
+					    NULL,
+					    (CamelObjectInitFunc) em_mozembed_stream_init,
+					    (CamelObjectFinalizeFunc) em_mozembed_stream_finalize);
+	}
+
+	return type;
+}
+
+static void
+em_mozembed_stream_class_init (EMMozEmbedStreamClass *klass)
+{
+	((EMSyncStreamClass *)klass)->sync_write = emms_sync_write;
+	((EMSyncStreamClass *)klass)->sync_flush = emms_sync_flush;
+	((EMSyncStreamClass *)klass)->sync_close = emms_sync_close;
+}
+
+static void
+em_mozembed_stream_init (CamelObject *object)
+{
+	EMMozEmbedStream *emms = (EMMozEmbedStream *)object;
+
+	emms->open = FALSE;
+}
+
+static void
+emms_cleanup(EMMozEmbedStream *emms)
+{
+	emms->sync.cancel = TRUE;	
+}
+
+static void
+em_mozembed_stream_finalize (CamelObject *object)
+{
+	EMMozEmbedStream *emms = (EMMozEmbedStream *)object;
+
+	camel_stream_close((CamelStream *)emms);
+}
+
+static ssize_t
+emms_sync_write(CamelStream *stream, const char *buffer, size_t n)
+{
+	EMMozEmbedStream *emms = EM_MOZEMBED_STREAM (stream);
+
+	gtk_moz_embed_append_data (emms->view, buffer, n); 
+	return (ssize_t) n;
+}
+
+static int
+emms_sync_flush(CamelStream *stream)
+{
+	EMMozEmbedStream *emms = (EMMozEmbedStream *)stream;
+
+	return 0;
+}
+
+static int
+emms_sync_close(CamelStream *stream)
+{
+	EMMozEmbedStream *emms = (EMMozEmbedStream *)stream;
+	
+	if (emms->open) {
+		emms->open = FALSE;
+		gtk_moz_embed_close_stream (emms->view);
+		gtk_moz_embed_reload (emms->view, GTK_MOZ_EMBED_FLAG_RELOADNORMAL);
+		gtk_widget_set_size_request (emms->view, -1, gtk_moz_embed_get_page_height(emms->view));
+	}
+	return 0;
+}
+
+CamelStream *
+em_mozembed_stream_new(GtkMozEmbed *view, GtkWidget *body)
+{
+	EMMozEmbedStream *new;
+
+	new = EM_MOZEMBED_STREAM (camel_object_new (EM_MOZEMBED_STREAM_TYPE));
+	new->flags = 0;
+	new->view = view;
+	new->body = body;
+	gtk_moz_embed_open_stream (view, "file:///", "text/html");
+	new->open = TRUE;
+	em_sync_stream_set_buffer_size(&new->sync, 8192);
+
+	return (CamelStream *)new;
+}
+
+void
+em_mozembed_stream_set_flags (EMMozEmbedStream *emms, int flags)
+{
+	emms->flags = flags;
+}
+
+GtkWidget *
+em_mozembed_stream_get_body (EMMozEmbedStream *emms)
+{
+	return emms->body;
+}
diff --git a/src/em-mozembed-stream.h b/src/em-mozembed-stream.h
new file mode 100644
index 0000000..c769d2f
--- /dev/null
+++ b/src/em-mozembed-stream.h
@@ -0,0 +1,66 @@
+/*
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>  
+ *
+ *
+ * Authors:
+ *		Srinivasa Ragavan <sragavan novell com>
+ *
+ * Copyright (C) 2009 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef EM_MOZEMBED_STREAM_H
+#define EM_MOZEMBED_STREAM_H
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+#define EM_MOZEMBED_STREAM_TYPE     (em_mozembed_stream_get_type ())
+#define EM_MOZEMBED_STREAM(obj)     (CAMEL_CHECK_CAST((obj), EM_MOZEMBED_STREAM_TYPE, EMMozEmbedStream))
+#define EM_MOZEMBED_STREAM_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), EM_MOZEMBED_STREAM_TYPE, EMMozEmbedStreamClass))
+#define EM_IS_MOZEMBED_STREAM(o)    (CAMEL_CHECK_TYPE((o), EM_MOZEMBED_STREAM_TYPE))
+
+#include "mail/em-sync-stream.h"
+#include <gtkmozembed.h>
+
+typedef struct _EMMozEmbedStream {
+	EMSyncStream sync;
+
+	GtkMozEmbed *view;
+	GtkWidget *body;
+	guint destroy_id;
+	int flags;
+	gboolean open;
+} EMMozEmbedStream;
+
+typedef struct {
+	EMSyncStreamClass parent_class;
+
+} EMMozEmbedStreamClass;
+
+
+CamelType    em_mozembed_stream_get_type (void);
+
+CamelStream *em_mozembed_stream_new(GtkMozEmbed *, GtkWidget *);
+void em_mozembed_stream_set_flags (EMMozEmbedStream *emhs, int flags);
+GtkWidget * em_mozembed_stream_get_body (EMMozEmbedStream *emms);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* EM_MOZEMBED_STREAM_H */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]