diff options
author | portix <portix@gmx.net> | 2013-05-20 14:48:40 +0200 |
---|---|---|
committer | portix <portix@gmx.net> | 2013-05-20 14:48:40 +0200 |
commit | e9ce243ab6db2dac67ab0982a62b4f2e54134087 (patch) | |
tree | 40d7057a7ff99ace373923b8c067746aa86234ef | |
parent | b85e6231bcb0ca9a8d7dddfa76735b35f2da0163 (diff) | |
download | dwb-e9ce243ab6db2dac67ab0982a62b4f2e54134087.zip |
New signal 'error'
-rw-r--r-- | src/scripts.c | 1 | ||||
-rw-r--r-- | src/scripts.h | 1 | ||||
-rw-r--r-- | src/view.c | 32 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/scripts.c b/src/scripts.c index 860079ce..be90e876 100644 --- a/src/scripts.c +++ b/src/scripts.c @@ -134,6 +134,7 @@ static Sigmap s_sigmap[] = { { SCRIPTS_SIG_CHANGE_MODE, "changeMode" }, { SCRIPTS_SIG_EXECUTE_COMMAND, "executeCommand" }, { SCRIPTS_SIG_CONTEXT_MENU, "contextMenu" }, + { SCRIPTS_SIG_ERROR, "error" }, { 0, NULL }, }; diff --git a/src/scripts.h b/src/scripts.h index 8ad87f94..d635f8b5 100644 --- a/src/scripts.h +++ b/src/scripts.h @@ -49,6 +49,7 @@ enum SIGNALS { SCRIPTS_SIG_CHANGE_MODE, SCRIPTS_SIG_EXECUTE_COMMAND, SCRIPTS_SIG_CONTEXT_MENU, + SCRIPTS_SIG_ERROR, SCRIPTS_SIG_LAST, } ; @@ -1164,6 +1164,38 @@ view_load_status_cb(WebKitWebView *web, GParamSpec *pspec, GList *gl) static gboolean view_load_error_cb(WebKitWebView *web, WebKitWebFrame *frame, char *uri, GError *weberror, GList *gl) { + if (EMIT_SCRIPT(ERROR)) + { + /** + * Emitted when an error occurs dureing a page load + * + * @event error + * @memberOf signals + * @param {signals~onError} callback + * Callback function that will be called when the signal is emitted + * */ + /** + * Callback called when the load-status of a WebKitWebView changes + * @callback signals~onLoadStatus + * @param {WebKitWebView} webview + * The webview that emitted the signal + * @param {WebKitWebFrame} frame + * The webframe that emitted the signal + * @param {Object} error + * The error + * @param {Object} error.message + * The error message + * @param {Object} error.code + * The error code + * + * @returns {Boolean} + * Return true to prevent the default action + * */ + char *json = util_create_json(2, INTEGER, "code", weberror->code, + CHAR, "message", weberror->message); + ScriptSignal sig = { SCRIPTS_WV(gl), { G_OBJECT(frame) }, SCRIPTS_SIG_META(json, ERROR, 1) }; + SCRIPTS_EMIT_RETURN(sig, json, true); + } if (weberror->code == WEBKIT_NETWORK_ERROR_CANCELLED || weberror->code == WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD || weberror->code == WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE) |