dbus_call(c, "SetHeaderSetting", g_variant_new("(s)", headers), NULL);
}
+void ext_proxy_lock_input(Client *c, const char *element_id)
+{
+ dbus_call(c, "LockInput", g_variant_new("(ts)", c->page_id, element_id), NULL);
+}
+
+void ext_proxy_unlock_input(Client *c, const char *element_id)
+{
+ dbus_call(c, "UnlockInput", g_variant_new("(ts)", c->page_id, element_id), NULL);
+}
+
/**
* Call a dbus method.
*/
GVariant *ext_proxy_eval_script_sync(Client *c, char *js);
void ext_proxy_focus_input(Client *c);
void ext_proxy_set_header(Client *c, const char *headers);
+void ext_proxy_lock_input(Client *c, const char *element_id);
+void ext_proxy_unlock_input(Client *c, const char *element_id);
#endif /* end of include guard: _EXT_PROXY_H */
g_strfreev(argv);
/* disable the active element */
- ext_proxy_eval_script(c, "vimb_input_mode_element.disabled=true", NULL);
+ ext_proxy_lock_input(c, element_id);
/* watch the editor process */
EditorData *data = g_slice_new0(EditorData);
}
if (data->element_id && strlen(data->element_id) > 0) {
- jscode_enable = g_strdup_printf(JS_FOCUS_ELEMENT_BY_ID,
- data->element_id, data->element_id);
+ ext_proxy_unlock_input(data->c, data->element_id);
} else {
jscode_enable = g_strdup_printf(JS_FOCUS_EDITOR_MAP_ELEMENT,
data->element_map_key, data->element_map_key);
+ ext_proxy_eval_script(data->c, jscode_enable, NULL);
+ g_free(jscode_enable);
}
- ext_proxy_eval_script(data->c, jscode_enable, NULL);
- g_free(jscode_enable);
-
g_unlink(data->file);
g_free(data->file);
g_free(data->element_id);
+++ /dev/null
-document.getElementById("%s").disabled=false;
-document.getElementById("%s").focus();
{
char *type;
gboolean result = FALSE;
-
+
if (!element) {
return FALSE;
}
-
+
/* element is editable if it's a text area or input with no type, text or
* password */
if (webkit_dom_html_element_get_is_content_editable(WEBKIT_DOM_HTML_ELEMENT(element))
return value;
}
+void ext_dom_lock_input(WebKitDOMDocument *parent, char *element_id)
+{
+ WebKitDOMElement *elem;
+
+ elem = webkit_dom_document_get_element_by_id(parent, element_id);
+ if (elem != NULL) {
+ webkit_dom_element_set_attribute(elem, "disabled", "true", NULL);
+ }
+}
+
+void ext_dom_unlock_input(WebKitDOMDocument *parent, char *element_id)
+{
+ WebKitDOMElement *elem;
+
+ elem = webkit_dom_document_get_element_by_id(parent, element_id);
+ if (elem != NULL) {
+ webkit_dom_element_remove_attribute(elem, "disabled");
+ webkit_dom_element_focus(elem);
+ }
+}
+
/**
* Indicates if the give nelement is visible.
*/
{
return TRUE;
}
+
gboolean ext_dom_is_editable(WebKitDOMElement *element);
gboolean ext_dom_focus_input(WebKitDOMDocument *doc);
char *ext_dom_editable_get_value(WebKitDOMElement *element);
+void ext_dom_lock_input(WebKitDOMDocument *parent, char *element_id);
+void ext_dom_unlock_input(WebKitDOMDocument *parent, char *element_id);
#endif /* end of include guard: _EXT-DOM_H */
" <method name='SetHeaderSetting'>"
" <arg type='s' name='headers' direction='in'/>"
" </method>"
+ " <method name='LockInput'>"
+ " <arg type='t' name='page_id' direction='in'/>"
+ " <arg type='s' name='elemend_id' direction='in'/>"
+ " </method>"
+ " <method name='UnlockInput'>"
+ " <arg type='t' name='page_id' direction='in'/>"
+ " <arg type='s' name='elemend_id' direction='in'/>"
+ " </method>"
" </interface>"
"</node>";
}
ext.headers = soup_header_parse_param_list(value);
g_dbus_method_invocation_return_value(invocation, NULL);
+ } else if (!g_strcmp0(method, "LockInput")) {
+ g_variant_get(parameters, "(ts)", &pageid, &value);
+ page = get_web_page_or_return_dbus_error(invocation, WEBKIT_WEB_EXTENSION(extension), pageid);
+ if (!page) {
+ return;
+ }
+ ext_dom_lock_input(webkit_web_page_get_dom_document(page), value);
+ g_dbus_method_invocation_return_value(invocation, NULL);
+ } else if (!g_strcmp0(method, "UnlockInput")) {
+ g_variant_get(parameters, "(ts)", &pageid, &value);
+ page = get_web_page_or_return_dbus_error(invocation, WEBKIT_WEB_EXTENSION(extension), pageid);
+ if (!page) {
+ return;
+ }
+ ext_dom_unlock_input(webkit_web_page_get_dom_document(page), value);
+ g_dbus_method_invocation_return_value(invocation, NULL);
}
}