From 9bdd9b79794d00d2343c8132232dcc9d9490f1ed Mon Sep 17 00:00:00 2001 From: portix Date: Sat, 1 Dec 2012 15:22:35 +0100 Subject: Script access to tab widgets --- src/scripts.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/scripts.c b/src/scripts.c index b77f2d4c..fb4d6239 100644 --- a/src/scripts.c +++ b/src/scripts.c @@ -118,11 +118,19 @@ static JSValueRef wv_get_main_frame(JSContextRef ctx, JSObjectRef object, JSStri static JSValueRef wv_get_focused_frame(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef* exception); static JSValueRef wv_get_all_frames(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef* exception); static JSValueRef wv_get_number(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef* exception); +static JSValueRef wv_get_tab_widget(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef* exception); +static JSValueRef wv_get_tab_box(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef* exception); +static JSValueRef wv_get_tab_label(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef* exception); +static JSValueRef wv_get_tab_icon(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef* exception); static JSStaticValue wv_values[] = { { "mainFrame", wv_get_main_frame, NULL, kJSDefaultAttributes }, { "focusedFrame", wv_get_focused_frame, NULL, kJSDefaultAttributes }, { "allFrames", wv_get_all_frames, NULL, kJSDefaultAttributes }, { "number", wv_get_number, NULL, kJSDefaultAttributes }, + { "tabWidget", wv_get_tab_widget, NULL, kJSDefaultAttributes }, + { "tabWidget", wv_get_tab_box, NULL, kJSDefaultAttributes }, + { "tabLabel", wv_get_tab_label, NULL, kJSDefaultAttributes }, + { "tabIcon", wv_get_tab_icon, NULL, kJSDefaultAttributes }, { 0, 0, 0, 0 }, }; @@ -593,7 +601,8 @@ wv_get_all_frames(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSV /* wv_get_number {{{*/ static JSValueRef -wv_get_number(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef* exception) { +wv_get_number(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef* exception) +{ GList *gl = dwb.state.views; for (int i=0; gl; i++, gl=gl->next) { @@ -603,6 +612,39 @@ wv_get_number(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValue return JSValueMakeNumber(ctx, -1); }/*}}}*/ +static JSValueRef +wv_get_tab_widget(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef* exception) +{ + GList *gl = find_webview(object); + if (gl == NULL) + return JSValueMakeUndefined(ctx); + return make_object_for_class(ctx, m_default_class, G_OBJECT(VIEW(gl)->tabevent), false); +} +static JSValueRef +wv_get_tab_box(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef* exception) +{ + GList *gl = find_webview(object); + if (gl == NULL) + return JSValueMakeUndefined(ctx); + return make_object_for_class(ctx, m_default_class, G_OBJECT(VIEW(gl)->tabbox), false); +} +static JSValueRef +wv_get_tab_label(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef* exception) +{ + GList *gl = find_webview(object); + if (gl == NULL) + return JSValueMakeUndefined(ctx); + return make_object_for_class(ctx, m_default_class, G_OBJECT(VIEW(gl)->tablabel), false); +} +static JSValueRef +wv_get_tab_icon(JSContextRef ctx, JSObjectRef object, JSStringRef js_name, JSValueRef* exception) +{ + GList *gl = find_webview(object); + if (gl == NULL) + return JSValueMakeUndefined(ctx); + return make_object_for_class(ctx, m_default_class, G_OBJECT(VIEW(gl)->tabicon), false); +} + static JSValueRef wv_set_title(JSContextRef ctx, JSObjectRef function, JSObjectRef this, size_t argc, const JSValueRef argv[], JSValueRef* exc) -- cgit v1.2.3