mirror of
https://github.com/rkd77/elinks.git
synced 2025-04-18 00:47:36 -04:00
Use update_bookmark() in SMJS bookmark object.
When setting the title or URL of a bookmark from SMJS user scripting, use update_bookmark() instead of writing directly to struct bookmark. It triggers the bookmark-update event and sets the bookmarks_dirty flag.
This commit is contained in:
parent
97d72d15a0
commit
11acd03eb2
@ -180,6 +180,9 @@ static JSBool
|
|||||||
bookmark_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
bookmark_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||||
{
|
{
|
||||||
struct bookmark *bookmark;
|
struct bookmark *bookmark;
|
||||||
|
unsigned char *title = NULL;
|
||||||
|
unsigned char *url = NULL;
|
||||||
|
int ok;
|
||||||
|
|
||||||
/* This can be called if @obj if not itself an instance of the
|
/* This can be called if @obj if not itself an instance of the
|
||||||
* appropriate class but has one in its prototype chain. Fail
|
* appropriate class but has one in its prototype chain. Fail
|
||||||
@ -197,9 +200,13 @@ bookmark_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
|
|
||||||
switch (JSVAL_TO_INT(id)) {
|
switch (JSVAL_TO_INT(id)) {
|
||||||
case BOOKMARK_TITLE:
|
case BOOKMARK_TITLE:
|
||||||
return jsval_to_bookmark_string(ctx, *vp, &bookmark->title);
|
if (!jsval_to_bookmark_string(ctx, *vp, &title))
|
||||||
|
return JS_FALSE;
|
||||||
|
break;
|
||||||
case BOOKMARK_URL:
|
case BOOKMARK_URL:
|
||||||
return jsval_to_bookmark_string(ctx, *vp, &bookmark->url);
|
if (!jsval_to_bookmark_string(ctx, *vp, &url))
|
||||||
|
return JS_FALSE;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
/* Unrecognized integer property ID; someone is using
|
/* Unrecognized integer property ID; someone is using
|
||||||
* the object as an array. SMJS builtin classes (e.g.
|
* the object as an array. SMJS builtin classes (e.g.
|
||||||
@ -207,6 +214,11 @@ bookmark_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
* Do the same here. */
|
* Do the same here. */
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ok = update_bookmark(bookmark, get_cp_index("UTF-8"), title, url);
|
||||||
|
mem_free_if(title);
|
||||||
|
mem_free_if(url);
|
||||||
|
return ok ? JS_TRUE : JS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const JSClass bookmark_class = {
|
static const JSClass bookmark_class = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user