[evolution/webkit-composer: 27/30] Port plugins do EEditor and drop Gtkhtml dependency
- From: Dan VrÃtil <dvratil src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit-composer: 27/30] Port plugins do EEditor and drop Gtkhtml dependency
- Date: Tue, 28 Aug 2012 16:28:47 +0000 (UTC)
commit fc710262ca2499de69f617fb3ae0cbede5485278
Author: Dan VrÃtil <dvratil redhat com>
Date: Tue Aug 28 18:15:35 2012 +0200
Port plugins do EEditor and drop Gtkhtml dependency
plugins/attachment-reminder/Makefile.am | 6 +-
plugins/attachment-reminder/attachment-reminder.c | 4 +-
plugins/bbdb/Makefile.am | 6 +-
plugins/email-custom-header/Makefile.am | 6 +-
plugins/email-custom-header/email-custom-header.c | 10 ++-
plugins/external-editor/Makefile.am | 6 +-
plugins/external-editor/external-editor.c | 97 +++++++++++++++------
plugins/face/Makefile.am | 6 +-
plugins/face/face.c | 12 ++--
plugins/mail-notification/Makefile.am | 6 +-
plugins/mailing-list-actions/Makefile.am | 6 +-
plugins/templates/Makefile.am | 6 +-
plugins/templates/templates.c | 6 +-
13 files changed, 104 insertions(+), 73 deletions(-)
---
diff --git a/plugins/attachment-reminder/Makefile.am b/plugins/attachment-reminder/Makefile.am
index 0339e01..c4f4cff 100644
--- a/plugins/attachment-reminder/Makefile.am
+++ b/plugins/attachment-reminder/Makefile.am
@@ -16,8 +16,7 @@ liborg_gnome_evolution_attachment_reminder_la_CPPFLAGS = \
-I$(top_srcdir)/widgets \
-DEVOLUTION_PLUGINDIR="\"$(plugindir)\"" \
$(EVOLUTION_DATA_SERVER_CFLAGS) \
- $(GNOME_PLATFORM_CFLAGS) \
- $(GTKHTML_CFLAGS)
+ $(GNOME_PLATFORM_CFLAGS)
liborg_gnome_evolution_attachment_reminder_la_SOURCES = attachment-reminder.c
@@ -33,8 +32,7 @@ liborg_gnome_evolution_attachment_reminder_la_LIBADD = \
$(top_builddir)/mail/libevolution-mail.la \
$(top_builddir)/libevolution-utils/libevolution-utils.la \
$(EVOLUTION_DATA_SERVER_LIBS) \
- $(GNOME_PLATFORM_LIBS) \
- $(GTKHTML_LIBS)
+ $(GNOME_PLATFORM_LIBS)
EXTRA_DIST = org-gnome-evolution-attachment-reminder.eplug.xml \
org-gnome-attachment-reminder.error.xml
diff --git a/plugins/attachment-reminder/attachment-reminder.c b/plugins/attachment-reminder/attachment-reminder.c
index 0079014..45a076b 100644
--- a/plugins/attachment-reminder/attachment-reminder.c
+++ b/plugins/attachment-reminder/attachment-reminder.c
@@ -136,8 +136,10 @@ ask_for_missing_attachment (EPlugin *ep,
gtk_widget_destroy (dialog);
- if (response == GTK_RESPONSE_OK)
+ if (response == GTK_RESPONSE_OK) {
+ EEditor *editor = e_editor_window_get_editor (E_EDITOR_WINDOW (window));
gtk_action_activate (E_COMPOSER_ACTION_ATTACH (window));
+ }
return response == GTK_RESPONSE_YES;
}
diff --git a/plugins/bbdb/Makefile.am b/plugins/bbdb/Makefile.am
index d3e006e..be81908 100644
--- a/plugins/bbdb/Makefile.am
+++ b/plugins/bbdb/Makefile.am
@@ -17,8 +17,7 @@ liborg_gnome_evolution_bbdb_la_CPPFLAGS = \
-I$(top_srcdir) \
-I$(top_srcdir)/widgets \
$(EVOLUTION_DATA_SERVER_CFLAGS) \
- $(GNOME_PLATFORM_CFLAGS) \
- $(GTKHTML_CFLAGS)
+ $(GNOME_PLATFORM_CFLAGS)
liborg_gnome_evolution_bbdb_la_SOURCES = bbdb.c bbdb.h gaimbuddies.c
@@ -32,8 +31,7 @@ liborg_gnome_evolution_bbdb_la_LIBADD = \
$(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.la \
$(top_builddir)/libevolution-utils/libevolution-utils.la \
$(EVOLUTION_DATA_SERVER_LIBS) \
- $(GNOME_PLATFORM_LIBS) \
- $(GTKHTML_LIBS)
+ $(GNOME_PLATFORM_LIBS)
EXTRA_DIST = org-gnome-evolution-bbdb.eplug.xml
diff --git a/plugins/email-custom-header/Makefile.am b/plugins/email-custom-header/Makefile.am
index a8d6016..feb60fb 100644
--- a/plugins/email-custom-header/Makefile.am
+++ b/plugins/email-custom-header/Makefile.am
@@ -13,8 +13,7 @@ liborg_gnome_email_custom_header_la_CPPFLAGS = \
-I$(top_builddir)/mail \
-I$(top_builddir)/composer \
$(EVOLUTION_DATA_SERVER_CFLAGS) \
- $(GNOME_PLATFORM_CFLAGS) \
- $(GTKHTML_CFLAGS)
+ $(GNOME_PLATFORM_CFLAGS)
liborg_gnome_email_custom_header_la_SOURCES = \
email-custom-header.c \
@@ -27,8 +26,7 @@ liborg_gnome_email_custom_header_la_LIBADD = \
$(top_builddir)/mail/libevolution-mail.la \
$(top_builddir)/libevolution-utils/libevolution-utils.la \
$(EVOLUTION_DATA_SERVER_LIBS) \
- $(GNOME_PLATFORM_LIBS) \
- $(GTKHTML_LIBS)
+ $(GNOME_PLATFORM_LIBS)
liborg_gnome_email_custom_header_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED)
diff --git a/plugins/email-custom-header/email-custom-header.c b/plugins/email-custom-header/email-custom-header.c
index 07d0f28..01c7e55 100644
--- a/plugins/email-custom-header/email-custom-header.c
+++ b/plugins/email-custom-header/email-custom-header.c
@@ -494,8 +494,10 @@ static void action_email_custom_header_cb (GtkAction *action, EMsgComposer *comp
GdkWindow *window;
CustomHeaderOptionsDialog *dialog = NULL;
EmailCustomHeaderWindow *new_email_custom_header_window = NULL;
+ EEditor *editor;
- ui_manager = gtkhtml_editor_get_ui_manager (GTKHTML_EDITOR (composer));
+ editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
+ ui_manager = e_editor_get_ui_manager (editor);
menuitem = gtk_ui_manager_get_widget (ui_manager, "/main-menu/insert-menu/insert-menu-top/Custom Header");
new_email_custom_header_window = g_object_get_data ((GObject *) composer, "compowindow");
@@ -537,13 +539,13 @@ gboolean
e_plugin_ui_init (GtkUIManager *ui_manager,
EMsgComposer *composer)
{
- GtkhtmlEditor *editor;
+ EEditor *editor;
- editor = GTKHTML_EDITOR (composer);
+ editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
/* Add actions to the "composer" action group. */
gtk_action_group_add_actions (
- gtkhtml_editor_get_action_group (editor, "composer"),
+ e_editor_get_action_group (editor, "composer"),
entries, G_N_ELEMENTS (entries), composer);
return TRUE;
diff --git a/plugins/external-editor/Makefile.am b/plugins/external-editor/Makefile.am
index f0ffd1a..4898049 100644
--- a/plugins/external-editor/Makefile.am
+++ b/plugins/external-editor/Makefile.am
@@ -28,8 +28,7 @@ liborg_gnome_external_editor_la_CPPFLAGS = \
-I$(top_srcdir)/composer \
-I$(top_srcdir)/widgets \
$(EVOLUTION_DATA_SERVER_CFLAGS) \
- $(GNOME_PLATFORM_CFLAGS) \
- $(GTKHTML_CFLAGS)
+ $(GNOME_PLATFORM_CFLAGS)
liborg_gnome_external_editor_la_SOURCES = \
external-editor.c
@@ -45,8 +44,7 @@ liborg_gnome_external_editor_la_LIBADD = \
$(top_builddir)/mail/libevolution-mail.la \
$(top_builddir)/libevolution-utils/libevolution-utils.la \
$(EVOLUTION_DATA_SERVER_LIBS) \
- $(GNOME_PLATFORM_LIBS) \
- $(GTKHTML_LIBS)
+ $(GNOME_PLATFORM_LIBS)
EXTRA_DIST = \
org-gnome-external-editor.eplug.xml \
diff --git a/plugins/external-editor/external-editor.c b/plugins/external-editor/external-editor.c
index cac0a63..f1c641e 100644
--- a/plugins/external-editor/external-editor.c
+++ b/plugins/external-editor/external-editor.c
@@ -150,29 +150,30 @@ static void
enable_disable_composer (EMsgComposer *composer,
gboolean enable)
{
- GtkhtmlEditor *editor;
+ EEditor *editor;
GtkAction *action;
GtkActionGroup *action_group;
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
- editor = GTKHTML_EDITOR (composer);
+ editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
- if (enable)
- gtkhtml_editor_run_command (editor, "editable-on");
- else
- gtkhtml_editor_run_command (editor, "editable-off");
+ if (enable) {
+ webkit_web_view_set_editable (WEBKIT_WEB_VIEW (editor), TRUE);
+ } else {
+ webkit_web_view_set_editable (WEBKIT_WEB_VIEW (editor), FALSE);
+ }
- action = GTKHTML_EDITOR_ACTION_EDIT_MENU (composer);
+ action = E_EDITOR_ACTION_EDIT_MENU (editor);
gtk_action_set_sensitive (action, enable);
- action = GTKHTML_EDITOR_ACTION_FORMAT_MENU (composer);
+ action = E_EDITOR_ACTION_FORMAT_MENU (editor);
gtk_action_set_sensitive (action, enable);
- action = GTKHTML_EDITOR_ACTION_INSERT_MENU (composer);
+ action = E_EDITOR_ACTION_INSERT_MENU (editor);
gtk_action_set_sensitive (action, enable);
- action_group = gtkhtml_editor_get_action_group (editor, "composer");
+ action_group = e_editor_get_action_group (editor, "composer");
gtk_action_group_set_sensitive (action_group, enable);
}
@@ -249,6 +250,49 @@ numlines (const gchar *text,
return lineno;
}
+static gint
+get_caret_position (EEditorWidget *widget)
+{
+ WebKitDOMDocument *document;
+ WebKitDOMDOMWindow *window;
+ WebKitDOMDOMSelection *selection;
+ WebKitDOMRange *range;
+ gint range_count;
+ WebKitDOMNodeList *nodes;
+ gulong ii, length;
+
+ document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (widget));
+ window = webkit_dom_document_get_default_view (document);
+ selection = webkit_dom_dom_window_get_selection (window);
+ if (webkit_dom_dom_selection_get_range_count (selection) < 1) {
+ return 0;
+ }
+
+ range = webkit_dom_dom_selection_get_range_at (selection, 0, NULL);
+ range_count = 0;
+ nodes = webkit_dom_node_get_child_nodes (
+ webkit_dom_node_get_parent_node (
+ webkit_dom_dom_selection_get_anchor_node (
+ selection)));
+ length = webkit_dom_node_list_get_length (nodes);
+ for (ii = 0; ii < length; ii++) {
+ WebKitDOMNode *node;
+
+ node = webkit_dom_node_list_item (nodes, ii);
+ if (webkit_dom_node_is_same_node (
+ node, webkit_dom_dom_selection_get_anchor_node (selection))) {
+
+ break;
+ } else if (webkit_dom_node_get_node_type (node) == 3) {
+ gchar *text = webkit_dom_node_get_text_content (node);
+ range_count += strlen (text);
+ g_free (text);
+ }
+ }
+
+ return webkit_dom_range_get_start_offset (range, NULL) + range_count;
+}
+
void
async_external_editor (EMsgComposer *composer)
{
@@ -257,18 +301,21 @@ async_external_editor (EMsgComposer *composer)
GSettings *settings;
gchar *editor_cmd_line = NULL, *editor_cmd = NULL, *content;
gint fd, position = -1, offset = -1;
+ EEditor *editor;
+ EEditorWidget *editor_widget;
+
+ editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
+ editor_widget = e_editor_get_editor_widget (editor);
/* prefix temp files with evo so .*vimrc can be setup to recognize them */
fd = g_file_open_tmp ("evoXXXXXX", &filename, NULL);
if (fd > 0) {
- gsize length = 0;
-
close (fd);
d (printf ("\n\aTemporary-file Name is : [%s] \n\a", filename));
/* Push the text (if there is one) from the composer to the file */
- content = gtkhtml_editor_get_text_plain (GTKHTML_EDITOR (composer), &length);
- g_file_set_contents (filename, content, length, NULL);
+ content = e_editor_widget_get_text_plain (editor_widget);
+ g_file_set_contents (filename, content, strlen (content), NULL);
} else {
struct run_error_dialog_data *data;
@@ -294,11 +341,8 @@ async_external_editor (EMsgComposer *composer)
}
g_object_unref (settings);
- if (g_strrstr (editor_cmd, "vim") != NULL
- && gtk_html_get_cursor_pos (
- gtkhtml_editor_get_html (
- GTKHTML_EDITOR (composer)), &position, &offset)
- && position >= 0 && offset >= 0) {
+ if (g_strrstr (editor_cmd, "vim") != NULL &&
+ ((position = get_caret_position (editor_widget)) > 0)) {
gchar *tmp = editor_cmd;
gint lineno;
gboolean set_nofork;
@@ -468,24 +512,23 @@ gboolean
e_plugin_ui_init (GtkUIManager *manager,
EMsgComposer *composer)
{
- GtkhtmlEditor *editor;
- EWebViewGtkHTML *web_view;
+ EEditor *editor;
+ EEditorWidget *editor_widget;
- editor = GTKHTML_EDITOR (composer);
+ editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
+ editor_widget = e_editor_get_editor_widget (editor);
/* Add actions to the "composer" action group. */
gtk_action_group_add_actions (
- gtkhtml_editor_get_action_group (editor, "composer"),
+ e_editor_get_action_group (editor, "composer"),
entries, G_N_ELEMENTS (entries), composer);
- web_view = e_msg_composer_get_web_view (composer);
-
g_signal_connect (
- web_view, "key_press_event",
+ editor_widget, "key_press_event",
G_CALLBACK (key_press_cb), composer);
g_signal_connect (
- web_view, "delete-event",
+ editor_widget, "delete-event",
G_CALLBACK (delete_cb), composer);
return TRUE;
diff --git a/plugins/face/Makefile.am b/plugins/face/Makefile.am
index 0522cc0..36f0a1a 100644
--- a/plugins/face/Makefile.am
+++ b/plugins/face/Makefile.am
@@ -13,8 +13,7 @@ liborg_gnome_face_la_CPPFLAGS = \
-I$(top_builddir)/mail \
-I$(top_builddir)/composer \
$(EVOLUTION_DATA_SERVER_CFLAGS) \
- $(GNOME_PLATFORM_CFLAGS) \
- $(GTKHTML_CFLAGS)
+ $(GNOME_PLATFORM_CFLAGS)
liborg_gnome_face_la_SOURCES = face.c
@@ -25,8 +24,7 @@ liborg_gnome_face_la_LIBADD = \
$(top_builddir)/mail/libevolution-mail.la \
$(top_builddir)/libevolution-utils/libevolution-utils.la \
$(EVOLUTION_DATA_SERVER_LIBS) \
- $(GNOME_PLATFORM_LIBS) \
- $(GTKHTML_LIBS)
+ $(GNOME_PLATFORM_LIBS)
liborg_gnome_face_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED)
diff --git a/plugins/face/face.c b/plugins/face/face.c
index c9023dc..02e728b 100644
--- a/plugins/face/face.c
+++ b/plugins/face/face.c
@@ -427,7 +427,7 @@ gboolean
e_plugin_ui_init (GtkUIManager *ui_manager,
EMsgComposer *composer)
{
- GtkhtmlEditor *editor;
+ EEditor *editor;
static GtkToggleActionEntry entries[] = {
{ "face-plugin",
@@ -448,11 +448,11 @@ e_plugin_ui_init (GtkUIManager *ui_manager,
g_free (face);
}
- editor = GTKHTML_EDITOR (composer);
+ editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
/* Add actions to the "composer" action group. */
gtk_action_group_add_toggle_actions (
- gtkhtml_editor_get_action_group (editor, "composer"),
+ e_editor_get_action_group (editor, "composer"),
entries, G_N_ELEMENTS (entries), composer);
return TRUE;
@@ -468,11 +468,11 @@ void
face_handle_send (EPlugin *ep,
EMEventTargetComposer *target)
{
- GtkhtmlEditor *editor;
+ EEditor *editor;
GtkAction *action;
- editor = GTKHTML_EDITOR (target->composer);
- action = gtkhtml_editor_get_action (editor, "face-plugin");
+ editor = e_editor_window_get_editor (E_EDITOR_WINDOW (target->composer));
+ action = e_editor_get_action (editor, "face-plugin");
g_return_if_fail (action != NULL);
diff --git a/plugins/mail-notification/Makefile.am b/plugins/mail-notification/Makefile.am
index 042dcd0..ad8c862 100644
--- a/plugins/mail-notification/Makefile.am
+++ b/plugins/mail-notification/Makefile.am
@@ -18,8 +18,7 @@ liborg_gnome_mail_notification_la_CPPFLAGS = \
$(EVOLUTION_DATA_SERVER_CFLAGS) \
$(GNOME_PLATFORM_CFLAGS) \
$(LIBNOTIFY_CFLAGS) \
- $(CANBERRA_CFLAGS) \
- $(GTKHTML_CFLAGS)
+ $(CANBERRA_CFLAGS)
liborg_gnome_mail_notification_la_SOURCES = mail-notification.c
@@ -34,8 +33,7 @@ liborg_gnome_mail_notification_la_LIBADD = \
$(EVOLUTION_DATA_SERVER_LIBS) \
$(GNOME_PLATFORM_LIBS) \
$(LIBNOTIFY_LIBS) \
- $(CANBERRA_LIBS) \
- $(GTKHTML_LIBS)
+ $(CANBERRA_LIBS)
BUILT_SOURCES = $(plugin_DATA)
diff --git a/plugins/mailing-list-actions/Makefile.am b/plugins/mailing-list-actions/Makefile.am
index ea1ce2e..6a28a4c 100644
--- a/plugins/mailing-list-actions/Makefile.am
+++ b/plugins/mailing-list-actions/Makefile.am
@@ -9,8 +9,7 @@ liborg_gnome_mailing_list_actions_la_CPPFLAGS = \
-I$(top_srcdir)/widgets \
-I$(top_builddir)/composer \
$(EVOLUTION_DATA_SERVER_CFLAGS) \
- $(GNOME_PLATFORM_CFLAGS) \
- $(GTKHTML_CFLAGS)
+ $(GNOME_PLATFORM_CFLAGS)
liborg_gnome_mailing_list_actions_la_SOURCES = mailing-list-actions.c
@@ -25,8 +24,7 @@ liborg_gnome_mailing_list_actions_la_LIBADD = \
$(top_builddir)/libemail-utils/libemail-utils.la \
$(top_builddir)/libevolution-utils/libevolution-utils.la \
$(EVOLUTION_DATA_SERVER_LIBS) \
- $(GNOME_PLATFORM_LIBS) \
- $(GTKHTML_LIBS)
+ $(GNOME_PLATFORM_LIBS)
error_DATA = org-gnome-mailing-list-actions.error
errordir = $(privdatadir)/errors
diff --git a/plugins/templates/Makefile.am b/plugins/templates/Makefile.am
index d4a637d..f5641ca 100644
--- a/plugins/templates/Makefile.am
+++ b/plugins/templates/Makefile.am
@@ -11,8 +11,7 @@ liborg_gnome_templates_la_CPPFLAGS = \
-I$(top_builddir) \
-I$(top_builddir)/composer \
$(EVOLUTION_DATA_SERVER_CFLAGS) \
- $(GNOME_PLATFORM_CFLAGS) \
- $(GTKHTML_CFLAGS)
+ $(GNOME_PLATFORM_CFLAGS)
liborg_gnome_templates_la_SOURCES = templates.c
@@ -26,8 +25,7 @@ liborg_gnome_templates_la_LIBADD = \
$(top_builddir)/libemail-engine/libemail-engine.la \
$(top_builddir)/libevolution-utils/libevolution-utils.la \
$(EVOLUTION_DATA_SERVER_LIBS) \
- $(GNOME_PLATFORM_LIBS) \
- $(GTKHTML_LIBS)
+ $(GNOME_PLATFORM_LIBS)
EXTRA_DIST = org-gnome-templates.eplug.xml
diff --git a/plugins/templates/templates.c b/plugins/templates/templates.c
index 75876f9..d4729ba 100644
--- a/plugins/templates/templates.c
+++ b/plugins/templates/templates.c
@@ -1298,13 +1298,13 @@ gboolean
init_composer_actions (GtkUIManager *ui_manager,
EMsgComposer *composer)
{
- GtkhtmlEditor *editor;
+ EEditor *editor;
- editor = GTKHTML_EDITOR (composer);
+ editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
/* Add actions to the "composer" action group. */
gtk_action_group_add_actions (
- gtkhtml_editor_get_action_group (editor, "composer"),
+ e_editor_get_action_group (editor, "composer"),
composer_entries, G_N_ELEMENTS (composer_entries), composer);
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]