[evolution] EHTMLEditorView - Introduce the is-ready signal
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] EHTMLEditorView - Introduce the is-ready signal
- Date: Fri, 29 Apr 2016 11:38:43 +0000 (UTC)
commit 054abd58830b1d2b4ad8730fde1799b6506ac8eb
Author: Tomas Popela <tpopela redhat com>
Date: Fri Apr 29 13:36:35 2016 +0200
EHTMLEditorView - Introduce the is-ready signal
Instead of working directly with the WebKitWebView abstract the current load
status into the is-ready signal. There is no change in functionality it is
basically a refactoring needed for the WebKit2 port.
composer/e-composer-private.c | 28 ++++++++++++++++------------
e-util/e-html-editor-view.c | 35 +++++++++++++++++++++++++++++++++++
e-util/e-html-editor-view.h | 2 ++
3 files changed, 53 insertions(+), 12 deletions(-)
---
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 3a83fb5..da1bdff 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -839,6 +839,18 @@ composer_web_view_load_status_changed_cb (WebKitWebView *webkit_web_view,
e_composer_update_signature (composer);
}
+static void
+html_editor_view_is_ready_cb (EHTMLEditorView *view,
+ EMsgComposer *composer)
+{
+ g_signal_handlers_disconnect_by_func (
+ view,
+ G_CALLBACK (html_editor_view_is_ready_cb),
+ composer);
+
+ e_composer_update_signature (composer);
+}
+
void
e_composer_update_signature (EMsgComposer *composer)
{
@@ -846,7 +858,6 @@ e_composer_update_signature (EMsgComposer *composer)
EMailSignatureComboBox *combo_box;
EHTMLEditor *editor;
EHTMLEditorView *view;
- WebKitLoadStatus status;
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
@@ -860,18 +871,11 @@ e_composer_update_signature (EMsgComposer *composer)
editor = e_msg_composer_get_editor (composer);
view = e_html_editor_get_view (editor);
- status = webkit_web_view_get_load_status (WEBKIT_WEB_VIEW (view));
- /* If document is not loaded, we will wait for him */
- if (status != WEBKIT_LOAD_FINISHED) {
- /* Disconnect previous handlers */
- g_signal_handlers_disconnect_by_func (
- WEBKIT_WEB_VIEW (view),
- G_CALLBACK (composer_web_view_load_status_changed_cb),
- composer);
+ if (!e_html_editor_view_is_ready (view)) {
g_signal_connect (
- WEBKIT_WEB_VIEW(view), "notify::load-status",
- G_CALLBACK (composer_web_view_load_status_changed_cb),
- composer);
+ view, "is-ready",
+ G_CALLBACK (html_editor_view_is_ready_cb), composer);
+
return;
}
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index ac97beb..c5a9808 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -148,6 +148,7 @@ enum {
enum {
POPUP_EVENT,
PASTE_PRIMARY_CLIPBOARD,
+ IS_READY,
LAST_SIGNAL
};
@@ -6509,6 +6510,7 @@ e_html_editor_view_class_init (EHTMLEditorViewClass *class)
e_marshal_BOOLEAN__BOXED,
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+
/**
* EHTMLEditorView:paste-primary-clipboad
*
@@ -6522,6 +6524,20 @@ e_html_editor_view_class_init (EHTMLEditorViewClass *class)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ /**
+ * EHTMLEditorView:is-ready
+ *
+ * Emitted when the view is ready.
+ */
+ signals[IS_READY] = g_signal_new (
+ "is-ready",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EHTMLEditorViewClass, is_ready),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
static void
@@ -11050,6 +11066,7 @@ html_editor_view_load_status_changed (EHTMLEditorView *view)
return;
}
+ g_signal_emit (view, signals[IS_READY], 0);
view->priv->reload_in_progress = FALSE;
document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
@@ -15702,3 +15719,21 @@ insert:
return NULL;
}
+
+/**
+ * e_html_editor_view_is_ready;
+ * @view: an #EHTMLEditorView
+ *
+ * Checks the current load status of the view.
+ *
+ * Returns: TRUE when the view is loaded and ready for manipulations.
+ */
+gboolean
+e_html_editor_view_is_ready (EHTMLEditorView *view)
+{
+ WebKitLoadStatus status;
+
+ status = webkit_web_view_get_load_status (WEBKIT_WEB_VIEW (view));
+
+ return status == WEBKIT_LOAD_FINISHED;
+}
diff --git a/e-util/e-html-editor-view.h b/e-util/e-html-editor-view.h
index 4784983..67c399f 100644
--- a/e-util/e-html-editor-view.h
+++ b/e-util/e-html-editor-view.h
@@ -82,6 +82,7 @@ struct _EHTMLEditorViewClass {
GdkEventButton *event);
void (*paste_primary_clipboard)
(EHTMLEditorView *view);
+ void (*is_ready) (EHTMLEditorView *view);
};
enum EHTMLEditorViewHistoryEventType {
@@ -333,6 +334,7 @@ gchar * e_html_editor_view_insert_signature
gboolean *set_signature_from_message,
gboolean *check_if_signature_is_changed,
gboolean *ignore_next_signature_change);
+gboolean e_html_editor_view_is_ready (EHTMLEditorView *view);
G_END_DECLS
#endif /* E_HTML_EDITOR_VIEW_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]