[anjal] Composer : Editor renamed : simple-editor -> mail-editor
- From: Johnny Jacob <jjohnny src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjal] Composer : Editor renamed : simple-editor -> mail-editor
- Date: Tue, 24 Mar 2009 03:33:42 -0400 (EDT)
commit 2f453a85574d013138744755f632d5cfd734fcb7
Author: Johnny Jacob <jjohnny novell com>
Date: Tue Mar 24 11:41:42 2009 +0530
Composer : Editor renamed : simple-editor -> mail-editor
---
src/Makefile.am | 4 +-
src/e-msg-composer-utils.c | 2 +-
src/e-msg-composer.c | 24 ++--
src/e-msg-composer.h | 4 +-
src/mail-editor.c | 389 ++++++++++++++++++++++++++++++++++++++++++++
src/mail-editor.h | 69 ++++++++
src/simple-editor.c | 389 --------------------------------------------
src/simple-editor.h | 69 --------
8 files changed, 475 insertions(+), 475 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 8fffd89..7f76864 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -45,8 +45,8 @@ anjal_SOURCES = \
e-composer-header-table.h \
e-msg-composer.h \
e-msg-composer.c \
- simple-editor.c \
- simple-editor.h \
+ mail-editor.c \
+ mail-editor.h \
mail-message-view.h \
em-format-webkit.c \
em-format-webkit.h \
diff --git a/src/e-msg-composer-utils.c b/src/e-msg-composer-utils.c
index 77db49e..dafa1e0 100644
--- a/src/e-msg-composer-utils.c
+++ b/src/e-msg-composer-utils.c
@@ -192,7 +192,7 @@ e_msg_utils_composer_get_message (EMsgComposer *composer, gboolean save_html_obj
/* goto finished; */
/* } */
- html_mode = simple_editor_get_html_mode (SIMPLE_EDITOR (composer));
+ html_mode = mail_editor_get_html_mode (MAIL_EDITOR (composer));
/* Check for no subject */
subject = e_composer_header_table_get_subject (table);
diff --git a/src/e-msg-composer.c b/src/e-msg-composer.c
index 31d20d3..a2fb7d6 100644
--- a/src/e-msg-composer.c
+++ b/src/e-msg-composer.c
@@ -99,7 +99,7 @@
#include "e-msg-composer.h"
#include "e-composer-header-table.h"
-#include "simple-editor.h"
+#include "mail-editor.h"
#ifdef HAVE_XFREE
#include <X11/XF86keysym.h>
#endif
@@ -185,7 +185,7 @@ struct _EMsgComposerPrivate {
/*** UI Management ***/
- SimpleEditor *html_editor;
+ MailEditor *html_editor;
GtkWidget *header_table;
GArray *gconf_bridge_binding_ids;
@@ -492,7 +492,7 @@ msg_composer_notify_header_cb (EMsgComposer *composer)
priv = E_MSG_COMPOSER_GET_PRIVATE (composer);
- simple_editor_set_changed (priv->html_editor, TRUE);
+ mail_editor_set_changed (priv->html_editor, TRUE);
}
static GObject *
@@ -639,7 +639,7 @@ static void
msg_composer_init (EMsgComposer *composer)
{
EComposerHeaderTable *table;
- SimpleEditor *editor;
+ MailEditor *editor;
EMsgComposerPrivate *priv = composer->priv;
@@ -691,10 +691,10 @@ msg_composer_init (EMsgComposer *composer)
priv->header_table, mail_config_get_accounts ());
/* Initialization may have tripped the "changed" state. */
- priv->html_editor = simple_editor_new ();
+ priv->html_editor = mail_editor_new ();
gtk_box_pack_start (GTK_BOX (composer), priv->html_editor, TRUE, TRUE, 6);
gtk_widget_show (priv->html_editor);
- simple_editor_set_changed (priv->html_editor, FALSE);
+ mail_editor_set_changed (priv->html_editor, FALSE);
/*Add attachment, save draft, send.*/ /*TODO : Connect signals*/
container = gtk_hbox_new (FALSE, 6);
@@ -893,7 +893,7 @@ build_message (EMsgComposer *composer,
gboolean html_content,
gboolean save_html_object_data)
{
- SimpleEditor *editor;
+ MailEditor *editor;
EMsgComposerPrivate *p;
EComposerHeaderTable *table;
@@ -954,7 +954,7 @@ build_message (EMsgComposer *composer,
gsize length;
data = g_byte_array_new ();
- text = simple_editor_get_text_plain (editor, &length);
+ text = mail_editor_get_text_plain (editor, &length);
g_byte_array_append (data, (guint8 *) text, (guint) length);
g_free (text);
@@ -1002,7 +1002,7 @@ build_message (EMsgComposer *composer,
/* gtkhtml_editor_run_command (editor, "save-data-on"); */
data = g_byte_array_new ();
- text = simple_editor_get_html (editor, &length);
+ text = mail_editor_get_html (editor, &length);
g_byte_array_append (data, (guint8 *) text, (guint) length);
g_free (text);
@@ -1097,7 +1097,7 @@ CamelMimeMessage *
e_msg_composer_get_message (EMsgComposer *composer,
gboolean save_html_object_data)
{
- SimpleEditor *editor;
+ MailEditor *editor;
gboolean html_content;
EMsgComposerPrivate *priv;
@@ -1105,9 +1105,9 @@ e_msg_composer_get_message (EMsgComposer *composer,
g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL);
- editor = SIMPLE_EDITOR (priv->html_editor);
+ editor = MAIL_EDITOR (priv->html_editor);
- html_content = simple_editor_get_html_mode (editor);
+ html_content = mail_editor_get_html_mode (editor);
return build_message (composer, html_content, save_html_object_data);
}
diff --git a/src/e-msg-composer.h b/src/e-msg-composer.h
index 1000a20..67b2214 100644
--- a/src/e-msg-composer.h
+++ b/src/e-msg-composer.h
@@ -32,7 +32,7 @@
#include <libedataserver/e-account.h>
#include <libebook/e-destination.h>
-#include "simple-editor.h"
+#include "mail-editor.h"
#include "e-composer-header-table.h"
/* Standard GObject macros */
@@ -62,7 +62,7 @@ typedef struct _EMsgComposerPrivate EMsgComposerPrivate;
struct _EMsgComposer {
GtkVBox parent;
- /* SimpleEditor parent; /\*FIXME : Web kit as parent ? *\/ /\*Use a vbox ?*\/ */
+
EMsgComposerPrivate *priv;
};
diff --git a/src/mail-editor.c b/src/mail-editor.c
new file mode 100644
index 0000000..edb41e2
--- /dev/null
+++ b/src/mail-editor.c
@@ -0,0 +1,389 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * 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:
+ * Johnny Jacob <jjohnny novell com>
+ *
+ * Copyright (C) 2009 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "mail-editor.h"
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <webkit/webkit.h>
+
+
+#define MAIL_EDITOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), MAIL_EDITOR_TYPE, MailEditorPrivate))
+
+struct _MailEditorPrivate
+{
+ WebKitWebView *editor; /*TODO : Subclass from webkits ?*/
+ GtkToolbar *toolbar;
+};
+
+static GtkVBoxClass *parent_class = NULL;
+
+static void mail_editor_class_init(MailEditorClass *klass);
+static void mail_editor_init(MailEditor *facet);
+
+GType
+mail_editor_get_type(void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0))
+ {
+ static const GTypeInfo mail_editor_info =
+ {
+ sizeof (MailEditorClass),
+ NULL,
+ NULL,
+ (GClassInitFunc) mail_editor_class_init,
+ NULL,
+ NULL,
+ sizeof (MailEditor),
+ 0,
+ (GInstanceInitFunc) mail_editor_init
+ };
+
+ type = g_type_register_static (GTK_TYPE_VBOX,
+ "MailEditor",
+ &mail_editor_info, 0);
+ }
+
+ return type;
+}
+
+GtkWidget* mail_editor_new()
+{
+ return GTK_WIDGET(g_object_new(mail_editor_get_type(), NULL));
+}
+
+
+static void
+mail_editor_class_init(MailEditorClass *klass)
+{
+
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ parent_class = GTK_WIDGET_CLASS (g_type_class_peek_parent (klass));
+
+ g_type_class_add_private (object_class, sizeof(MailEditorPrivate));
+}
+
+static void
+tb_bold_cb (GtkToggleToolButton *button, MailEditor *editor)
+{
+ MailEditorPrivate *priv;
+ WebKitWebFrame *frame;
+
+ g_return_if_fail (IS_MAIL_EDITOR (editor));
+ priv = MAIL_EDITOR_GET_PRIVATE (editor);
+
+ frame = webkit_web_view_get_focused_frame (priv->editor);
+
+ if (!frame)
+ frame = webkit_web_view_get_main_frame (priv->editor);
+
+ g_return_if_fail (frame != NULL);
+
+ webkit_web_frame_execute_command (frame, "ToggleBold");
+}
+
+static void
+tb_underline_cb (GtkToggleToolButton *button, MailEditor *editor)
+{
+ MailEditorPrivate *priv;
+ WebKitWebFrame *frame;
+
+ g_return_if_fail (IS_MAIL_EDITOR (editor));
+ priv = MAIL_EDITOR_GET_PRIVATE (editor);
+
+ frame = webkit_web_view_get_focused_frame (priv->editor);
+
+ if (!frame)
+ frame = webkit_web_view_get_main_frame (priv->editor);
+
+ g_return_if_fail (frame != NULL);
+
+ webkit_web_frame_execute_command (frame, "ToggleUnderline");
+}
+
+static void
+tb_italics_cb (GtkToggleToolButton *button, MailEditor *editor)
+{
+ MailEditorPrivate *priv;
+ WebKitWebFrame *frame;
+
+ g_return_if_fail (IS_MAIL_EDITOR (editor));
+ priv = MAIL_EDITOR_GET_PRIVATE (editor);
+
+ frame = webkit_web_view_get_focused_frame (priv->editor);
+
+ if (!frame)
+ frame = webkit_web_view_get_main_frame (priv->editor);
+
+ g_return_if_fail (frame != NULL);
+
+ webkit_web_frame_execute_command (frame, "ToggleItalic");
+}
+
+static void
+tb_justify_left_cb (GtkToggleToolButton *button, MailEditor *editor)
+{
+ MailEditorPrivate *priv;
+ WebKitWebFrame *frame;
+
+ g_return_if_fail (IS_MAIL_EDITOR (editor));
+ priv = MAIL_EDITOR_GET_PRIVATE (editor);
+
+ frame = webkit_web_view_get_focused_frame (priv->editor);
+
+ if (!frame)
+ frame = webkit_web_view_get_main_frame (priv->editor);
+
+ g_return_if_fail (frame != NULL);
+
+ webkit_web_frame_execute_command (frame, "JustifyLeft");
+}
+
+static void
+tb_justify_center_cb (GtkToggleToolButton *button, MailEditor *editor)
+{
+ MailEditorPrivate *priv;
+ WebKitWebFrame *frame;
+
+ g_return_if_fail (IS_MAIL_EDITOR (editor));
+ priv = MAIL_EDITOR_GET_PRIVATE (editor);
+
+ frame = webkit_web_view_get_focused_frame (priv->editor);
+
+ if (!frame)
+ frame = webkit_web_view_get_main_frame (priv->editor);
+
+ g_return_if_fail (frame != NULL);
+
+ webkit_web_frame_execute_command (frame, "JustifyCenter");
+}
+
+static void
+tb_justify_right_cb (GtkToggleToolButton *button, MailEditor *editor)
+{
+ MailEditorPrivate *priv;
+ WebKitWebFrame *frame;
+
+ g_return_if_fail (IS_MAIL_EDITOR (editor));
+ priv = MAIL_EDITOR_GET_PRIVATE (editor);
+
+ frame = webkit_web_view_get_focused_frame (priv->editor);
+
+ if (!frame)
+ frame = webkit_web_view_get_main_frame (priv->editor);
+
+ g_return_if_fail (frame != NULL);
+
+ webkit_web_frame_execute_command (frame, "JustifyRight");
+}
+
+static void
+tb_indent_cb (GtkToggleToolButton *button, MailEditor *editor)
+{
+ MailEditorPrivate *priv;
+ WebKitWebFrame *frame;
+
+ g_return_if_fail (IS_MAIL_EDITOR (editor));
+ priv = MAIL_EDITOR_GET_PRIVATE (editor);
+
+ frame = webkit_web_view_get_focused_frame (priv->editor);
+
+ if (!frame)
+ frame = webkit_web_view_get_main_frame (priv->editor);
+
+ g_return_if_fail (frame != NULL);
+
+ webkit_web_frame_execute_command (frame, "Indent");
+}
+
+static void
+tb_outdent_cb (GtkToggleToolButton *button, MailEditor *editor)
+{
+ MailEditorPrivate *priv;
+ WebKitWebFrame *frame;
+
+ g_return_if_fail (IS_MAIL_EDITOR (editor));
+ priv = MAIL_EDITOR_GET_PRIVATE (editor);
+
+ frame = webkit_web_view_get_focused_frame (priv->editor);
+
+ if (!frame)
+ frame = webkit_web_view_get_main_frame (priv->editor);
+
+ g_return_if_fail (frame != NULL);
+
+ webkit_web_frame_execute_command (frame, "Outdent");
+}
+
+static GtkToolbar*
+mail_editor_construct_html_toolbar (MailEditor *editor)
+{
+ GtkToolbar *toolbar;
+ GtkToolItem *item;
+
+ MailEditorPrivate *priv;
+
+ toolbar = gtk_toolbar_new ();
+ priv = MAIL_EDITOR_GET_PRIVATE (editor);
+
+ /*Create items.*/
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_INDENT);
+ gtk_toolbar_insert (toolbar, item, 0);
+ g_signal_connect (item, "clicked", G_CALLBACK(tb_indent_cb), editor);
+
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_UNINDENT);
+ gtk_toolbar_insert (toolbar, item, 0);
+ g_signal_connect (item, "clicked", G_CALLBACK(tb_outdent_cb), editor);
+
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_JUSTIFY_RIGHT);
+ gtk_toolbar_insert (toolbar, item, 0);
+ g_signal_connect (item, "clicked", G_CALLBACK(tb_justify_right_cb), editor);
+
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_JUSTIFY_CENTER);
+ gtk_toolbar_insert (toolbar, item, 0);
+ g_signal_connect (item, "clicked", G_CALLBACK(tb_justify_center_cb), editor);
+
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_JUSTIFY_LEFT);
+ gtk_toolbar_insert (toolbar, item, 0);
+ g_signal_connect (item, "clicked", G_CALLBACK(tb_justify_left_cb), editor);
+
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_BOLD);
+ gtk_toolbar_insert (toolbar, item, 0);
+ g_signal_connect (item, "clicked", G_CALLBACK(tb_bold_cb), editor);
+
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_UNDERLINE);
+ gtk_toolbar_insert (toolbar, item, 0);
+ g_signal_connect (item, "clicked", G_CALLBACK(tb_underline_cb), editor);
+
+ item = gtk_tool_button_new_from_stock (GTK_STOCK_ITALIC);
+ g_signal_connect (item, "clicked", G_CALLBACK(tb_italics_cb), editor);
+ gtk_toolbar_insert (toolbar, item, 0);
+
+ return toolbar;
+}
+
+static void
+editor_loaded_cb (WebKitWebView *view, WebKitWebFrame *frame, MailEditor *editor)
+{
+}
+
+static void
+mail_editor_init(MailEditor *editor)
+{
+ MailEditorPrivate *priv;
+ gchar *index_html;
+
+ priv = MAIL_EDITOR_GET_PRIVATE (editor);
+
+ priv->editor = webkit_web_view_new ();
+
+ /*Dummy html doc*/
+ index_html = "<html><body></body></html>";
+
+ webkit_web_view_load_html_string (priv->editor, index_html, NULL);
+ webkit_web_view_set_editable (priv->editor, TRUE);
+
+ g_signal_connect (priv->editor, "load-finished", G_CALLBACK(editor_loaded_cb), editor);
+
+ gtk_widget_show (priv->editor);
+
+ priv->toolbar = mail_editor_construct_html_toolbar (editor);
+ gtk_widget_show_all (priv->toolbar);
+
+ gtk_box_pack_start (GTK_CONTAINER (editor), priv->toolbar, FALSE, TRUE, 6);
+ gtk_box_pack_start (GTK_CONTAINER (editor), priv->editor, TRUE, TRUE, 2);
+
+}
+
+gchar *
+mail_editor_get_text_plain (MailEditor *editor,
+ gsize *length)
+{
+ MailEditorPrivate *priv;
+ WebKitWebFrame* frame;
+ gchar *contents = NULL;
+
+ g_return_val_if_fail (IS_MAIL_EDITOR (editor), NULL);
+
+ priv = MAIL_EDITOR_GET_PRIVATE (editor);
+
+ frame = webkit_web_view_get_main_frame (priv->editor);
+ contents = webkit_web_frame_get_string (frame);
+
+ *length = g_utf8_strlen (contents, -1); /*FIXME*/
+
+ return contents;
+}
+
+void
+mail_editor_set_changed (MailEditor *editor, gboolean set)
+{
+}
+
+gboolean
+mail_editor_get_html_mode (editor)
+{
+ /*TODO : > */
+ return TRUE;
+}
+
+void
+mail_editor_run_command (MailEditor *editor, gchar *command)
+{
+
+}
+
+void
+mail_editor_set_text_html (MailEditor *editor, gchar *text, gint length)
+{
+ MailEditorPrivate *priv;
+
+ g_return_val_if_fail (IS_MAIL_EDITOR (editor), NULL);
+
+ priv = MAIL_EDITOR_GET_PRIVATE (editor);
+}
+
+
+gchar*
+mail_editor_get_html (MailEditor *editor, gsize *length)
+{
+ MailEditorPrivate *priv;
+ WebKitWebFrame* frame;
+ gchar *contents = NULL;
+
+ g_return_val_if_fail (IS_MAIL_EDITOR (editor), NULL);
+
+ priv = MAIL_EDITOR_GET_PRIVATE (editor);
+ *length = 0;
+
+ frame = webkit_web_view_get_main_frame (priv->editor);
+ contents = webkit_web_frame_get_string (frame);
+ contents = g_strdup_printf ("<html>%s</html>", contents);
+ *length = g_utf8_strlen (contents, -1); /*FIXME ?*/
+
+ return contents;
+}
diff --git a/src/mail-editor.h b/src/mail-editor.h
new file mode 100644
index 0000000..6a75b69
--- /dev/null
+++ b/src/mail-editor.h
@@ -0,0 +1,69 @@
+/*
+ * 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:
+ * Johnny Jacob <jjohnny novell com>
+ *
+ * Copyright (C) 2009 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifndef __MAIL_EDITOR_H
+#define __MAIL_EDITOR_H
+
+#include <gtk/gtk.h>
+
+#define MAIL_EDITOR_TYPE \
+ (mail_editor_get_type ())
+#define MAIL_EDITOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), MAIL_EDITOR_TYPE, MailEditor))
+#define MAIL_EDITOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), MAIL_EDITOR_TYPE, MailEditorClass))
+#define IS_MAIL_EDITOR(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), MAIL_EDITOR_TYPE))
+#define IS_MAIL_EDITOR_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((obj), MAIL_EDITOR_TYPE))
+#define MAIL_EDITOR_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), MAIL_EDITOR_TYPE, MailEditorClass))
+
+typedef struct _MailEditor MailEditor;
+typedef struct _MailEditorClass MailEditorClass;
+typedef struct _MailEditorPrivate MailEditorPrivate;
+
+struct _MailEditor {
+ GtkVBox parent; /*Till Webkits*/
+
+ MailEditorPrivate *priv;
+};
+
+struct _MailEditorClass {
+ GtkVBoxClass parent_class;
+};
+
+GtkWidget *mail_editor_new(void);
+
+gchar *mail_editor_get_text_plain (MailEditor *editor, gsize *length);
+gchar* mail_editor_get_html (MailEditor *editor, gsize *length);
+
+#endif
diff --git a/src/simple-editor.c b/src/simple-editor.c
deleted file mode 100644
index 410c6c0..0000000
--- a/src/simple-editor.c
+++ /dev/null
@@ -1,389 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * 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:
- * Johnny Jacob <jjohnny novell com>
- *
- * Copyright (C) 2009 Novell, Inc. (www.novell.com)
- *
- */
-
-#include "simple-editor.h"
-
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
-#include <webkit/webkit.h>
-
-
-#define SIMPLE_EDITOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), SIMPLE_EDITOR_TYPE, SimpleEditorPrivate))
-
-struct _SimpleEditorPrivate
-{
- WebKitWebView *editor; /*TODO : Subclass from webkits ?*/
- GtkToolbar *toolbar;
-};
-
-static GtkVBoxClass *parent_class = NULL;
-
-static void simple_editor_class_init(SimpleEditorClass *klass);
-static void simple_editor_init(SimpleEditor *facet);
-
-GType
-simple_editor_get_type(void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0))
- {
- static const GTypeInfo simple_editor_info =
- {
- sizeof (SimpleEditorClass),
- NULL,
- NULL,
- (GClassInitFunc) simple_editor_class_init,
- NULL,
- NULL,
- sizeof (SimpleEditor),
- 0,
- (GInstanceInitFunc) simple_editor_init
- };
-
- type = g_type_register_static (GTK_TYPE_VBOX,
- "SimpleEditor",
- &simple_editor_info, 0);
- }
-
- return type;
-}
-
-GtkWidget* simple_editor_new()
-{
- return GTK_WIDGET(g_object_new(simple_editor_get_type(), NULL));
-}
-
-
-static void
-simple_editor_class_init(SimpleEditorClass *klass)
-{
-
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- parent_class = GTK_WIDGET_CLASS (g_type_class_peek_parent (klass));
-
- g_type_class_add_private (object_class, sizeof(SimpleEditorPrivate));
-}
-
-static void
-tb_bold_cb (GtkToggleToolButton *button, SimpleEditor *editor)
-{
- SimpleEditorPrivate *priv;
- WebKitWebFrame *frame;
-
- g_return_if_fail (IS_SIMPLE_EDITOR (editor));
- priv = SIMPLE_EDITOR_GET_PRIVATE (editor);
-
- frame = webkit_web_view_get_focused_frame (priv->editor);
-
- if (!frame)
- frame = webkit_web_view_get_main_frame (priv->editor);
-
- g_return_if_fail (frame != NULL);
-
- webkit_web_frame_execute_command (frame, "ToggleBold");
-}
-
-static void
-tb_underline_cb (GtkToggleToolButton *button, SimpleEditor *editor)
-{
- SimpleEditorPrivate *priv;
- WebKitWebFrame *frame;
-
- g_return_if_fail (IS_SIMPLE_EDITOR (editor));
- priv = SIMPLE_EDITOR_GET_PRIVATE (editor);
-
- frame = webkit_web_view_get_focused_frame (priv->editor);
-
- if (!frame)
- frame = webkit_web_view_get_main_frame (priv->editor);
-
- g_return_if_fail (frame != NULL);
-
- webkit_web_frame_execute_command (frame, "ToggleUnderline");
-}
-
-static void
-tb_italics_cb (GtkToggleToolButton *button, SimpleEditor *editor)
-{
- SimpleEditorPrivate *priv;
- WebKitWebFrame *frame;
-
- g_return_if_fail (IS_SIMPLE_EDITOR (editor));
- priv = SIMPLE_EDITOR_GET_PRIVATE (editor);
-
- frame = webkit_web_view_get_focused_frame (priv->editor);
-
- if (!frame)
- frame = webkit_web_view_get_main_frame (priv->editor);
-
- g_return_if_fail (frame != NULL);
-
- webkit_web_frame_execute_command (frame, "ToggleItalic");
-}
-
-static void
-tb_justify_left_cb (GtkToggleToolButton *button, SimpleEditor *editor)
-{
- SimpleEditorPrivate *priv;
- WebKitWebFrame *frame;
-
- g_return_if_fail (IS_SIMPLE_EDITOR (editor));
- priv = SIMPLE_EDITOR_GET_PRIVATE (editor);
-
- frame = webkit_web_view_get_focused_frame (priv->editor);
-
- if (!frame)
- frame = webkit_web_view_get_main_frame (priv->editor);
-
- g_return_if_fail (frame != NULL);
-
- webkit_web_frame_execute_command (frame, "JustifyLeft");
-}
-
-static void
-tb_justify_center_cb (GtkToggleToolButton *button, SimpleEditor *editor)
-{
- SimpleEditorPrivate *priv;
- WebKitWebFrame *frame;
-
- g_return_if_fail (IS_SIMPLE_EDITOR (editor));
- priv = SIMPLE_EDITOR_GET_PRIVATE (editor);
-
- frame = webkit_web_view_get_focused_frame (priv->editor);
-
- if (!frame)
- frame = webkit_web_view_get_main_frame (priv->editor);
-
- g_return_if_fail (frame != NULL);
-
- webkit_web_frame_execute_command (frame, "JustifyCenter");
-}
-
-static void
-tb_justify_right_cb (GtkToggleToolButton *button, SimpleEditor *editor)
-{
- SimpleEditorPrivate *priv;
- WebKitWebFrame *frame;
-
- g_return_if_fail (IS_SIMPLE_EDITOR (editor));
- priv = SIMPLE_EDITOR_GET_PRIVATE (editor);
-
- frame = webkit_web_view_get_focused_frame (priv->editor);
-
- if (!frame)
- frame = webkit_web_view_get_main_frame (priv->editor);
-
- g_return_if_fail (frame != NULL);
-
- webkit_web_frame_execute_command (frame, "JustifyRight");
-}
-
-static void
-tb_indent_cb (GtkToggleToolButton *button, SimpleEditor *editor)
-{
- SimpleEditorPrivate *priv;
- WebKitWebFrame *frame;
-
- g_return_if_fail (IS_SIMPLE_EDITOR (editor));
- priv = SIMPLE_EDITOR_GET_PRIVATE (editor);
-
- frame = webkit_web_view_get_focused_frame (priv->editor);
-
- if (!frame)
- frame = webkit_web_view_get_main_frame (priv->editor);
-
- g_return_if_fail (frame != NULL);
-
- webkit_web_frame_execute_command (frame, "Indent");
-}
-
-static void
-tb_outdent_cb (GtkToggleToolButton *button, SimpleEditor *editor)
-{
- SimpleEditorPrivate *priv;
- WebKitWebFrame *frame;
-
- g_return_if_fail (IS_SIMPLE_EDITOR (editor));
- priv = SIMPLE_EDITOR_GET_PRIVATE (editor);
-
- frame = webkit_web_view_get_focused_frame (priv->editor);
-
- if (!frame)
- frame = webkit_web_view_get_main_frame (priv->editor);
-
- g_return_if_fail (frame != NULL);
-
- webkit_web_frame_execute_command (frame, "Outdent");
-}
-
-static GtkToolbar*
-simple_editor_construct_html_toolbar (SimpleEditor *editor)
-{
- GtkToolbar *toolbar;
- GtkToolItem *item;
-
- SimpleEditorPrivate *priv;
-
- toolbar = gtk_toolbar_new ();
- priv = SIMPLE_EDITOR_GET_PRIVATE (editor);
-
- /*Create items.*/
- item = gtk_tool_button_new_from_stock (GTK_STOCK_INDENT);
- gtk_toolbar_insert (toolbar, item, 0);
- g_signal_connect (item, "clicked", G_CALLBACK(tb_indent_cb), editor);
-
- item = gtk_tool_button_new_from_stock (GTK_STOCK_UNINDENT);
- gtk_toolbar_insert (toolbar, item, 0);
- g_signal_connect (item, "clicked", G_CALLBACK(tb_outdent_cb), editor);
-
- item = gtk_tool_button_new_from_stock (GTK_STOCK_JUSTIFY_RIGHT);
- gtk_toolbar_insert (toolbar, item, 0);
- g_signal_connect (item, "clicked", G_CALLBACK(tb_justify_right_cb), editor);
-
- item = gtk_tool_button_new_from_stock (GTK_STOCK_JUSTIFY_CENTER);
- gtk_toolbar_insert (toolbar, item, 0);
- g_signal_connect (item, "clicked", G_CALLBACK(tb_justify_center_cb), editor);
-
- item = gtk_tool_button_new_from_stock (GTK_STOCK_JUSTIFY_LEFT);
- gtk_toolbar_insert (toolbar, item, 0);
- g_signal_connect (item, "clicked", G_CALLBACK(tb_justify_left_cb), editor);
-
- item = gtk_tool_button_new_from_stock (GTK_STOCK_BOLD);
- gtk_toolbar_insert (toolbar, item, 0);
- g_signal_connect (item, "clicked", G_CALLBACK(tb_bold_cb), editor);
-
- item = gtk_tool_button_new_from_stock (GTK_STOCK_UNDERLINE);
- gtk_toolbar_insert (toolbar, item, 0);
- g_signal_connect (item, "clicked", G_CALLBACK(tb_underline_cb), editor);
-
- item = gtk_tool_button_new_from_stock (GTK_STOCK_ITALIC);
- g_signal_connect (item, "clicked", G_CALLBACK(tb_italics_cb), editor);
- gtk_toolbar_insert (toolbar, item, 0);
-
- return toolbar;
-}
-
-static void
-editor_loaded_cb (WebKitWebView *view, WebKitWebFrame *frame, SimpleEditor *editor)
-{
-}
-
-static void
-simple_editor_init(SimpleEditor *editor)
-{
- SimpleEditorPrivate *priv;
- gchar *index_html;
-
- priv = SIMPLE_EDITOR_GET_PRIVATE (editor);
-
- priv->editor = webkit_web_view_new ();
-
- /*Dummy html doc*/
- index_html = "<html><body></body></html>";
-
- webkit_web_view_load_html_string (priv->editor, index_html, NULL);
- webkit_web_view_set_editable (priv->editor, TRUE);
-
- g_signal_connect (priv->editor, "load-finished", G_CALLBACK(editor_loaded_cb), editor);
-
- gtk_widget_show (priv->editor);
-
- priv->toolbar = simple_editor_construct_html_toolbar (editor);
- gtk_widget_show_all (priv->toolbar);
-
- gtk_box_pack_start (GTK_CONTAINER (editor), priv->toolbar, FALSE, TRUE, 6);
- gtk_box_pack_start (GTK_CONTAINER (editor), priv->editor, TRUE, TRUE, 2);
-
-}
-
-gchar *
-simple_editor_get_text_plain (SimpleEditor *editor,
- gsize *length)
-{
- SimpleEditorPrivate *priv;
- WebKitWebFrame* frame;
- gchar *contents = NULL;
-
- g_return_val_if_fail (IS_SIMPLE_EDITOR (editor), NULL);
-
- priv = SIMPLE_EDITOR_GET_PRIVATE (editor);
-
- frame = webkit_web_view_get_main_frame (priv->editor);
- contents = webkit_web_frame_get_string (frame);
-
- *length = g_utf8_strlen (contents, -1); /*FIXME*/
-
- return contents;
-}
-
-void
-simple_editor_set_changed (SimpleEditor *editor, gboolean set)
-{
-}
-
-gboolean
-simple_editor_get_html_mode (editor)
-{
- /*TODO : > */
- return TRUE;
-}
-
-void
-simple_editor_run_command (SimpleEditor *editor, gchar *command)
-{
-
-}
-
-void
-simple_editor_set_text_html (SimpleEditor *editor, gchar *text, gint length)
-{
- SimpleEditorPrivate *priv;
-
- g_return_val_if_fail (IS_SIMPLE_EDITOR (editor), NULL);
-
- priv = SIMPLE_EDITOR_GET_PRIVATE (editor);
-}
-
-
-gchar*
-simple_editor_get_html (SimpleEditor *editor, gsize *length)
-{
- SimpleEditorPrivate *priv;
- WebKitWebFrame* frame;
- gchar *contents = NULL;
-
- g_return_val_if_fail (IS_SIMPLE_EDITOR (editor), NULL);
-
- priv = SIMPLE_EDITOR_GET_PRIVATE (editor);
- *length = 0;
-
- frame = webkit_web_view_get_main_frame (priv->editor);
- contents = webkit_web_frame_get_string (frame);
- contents = g_strdup_printf ("<html>%s</html>", contents);
- *length = g_utf8_strlen (contents, -1); /*FIXME ?*/
-
- return contents;
-}
diff --git a/src/simple-editor.h b/src/simple-editor.h
deleted file mode 100644
index 118ed7d..0000000
--- a/src/simple-editor.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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:
- * Johnny Jacob <jjohnny novell com>
- *
- * Copyright (C) 2009 Novell, Inc. (www.novell.com)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifndef __SIMPLE_EDITOR_H
-#define __SIMPLE_EDITOR_H
-
-#include <gtk/gtk.h>
-
-#define SIMPLE_EDITOR_TYPE \
- (simple_editor_get_type ())
-#define SIMPLE_EDITOR(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), SIMPLE_EDITOR_TYPE, SimpleEditor))
-#define SIMPLE_EDITOR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), SIMPLE_EDITOR_TYPE, SimpleEditorClass))
-#define IS_SIMPLE_EDITOR(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), SIMPLE_EDITOR_TYPE))
-#define IS_SIMPLE_EDITOR_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((obj), SIMPLE_EDITOR_TYPE))
-#define SIMPLE_EDITOR_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), SIMPLE_EDITOR_TYPE, SimpleEditorClass))
-
-typedef struct _SimpleEditor SimpleEditor;
-typedef struct _SimpleEditorClass SimpleEditorClass;
-typedef struct _SimpleEditorPrivate SimpleEditorPrivate;
-
-struct _SimpleEditor {
- GtkVBox parent; /*Till Webkits*/
-
- SimpleEditorPrivate *priv;
-};
-
-struct _SimpleEditorClass {
- GtkVBoxClass parent_class;
-};
-
-GtkWidget *simple_editor_new(void);
-
-gchar *simple_editor_get_text_plain (SimpleEditor *editor, gsize *length);
-gchar* simple_editor_get_html (SimpleEditor *editor, gsize *length);
-
-#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]