diff --git a/api.cpp b/api.cpp index 9e7679b1b..306ec2b70 100644 --- a/api.cpp +++ b/api.cpp @@ -84,6 +84,16 @@ class Context { }); } + val summary() { + return gpp_rethrow([=]() { + val result = val::object(); + auto summary = GPP_CALL( + CameraText, gp_camera_get_summary(camera.get(), _, context.get())); + result.set("text", static_cast(summary.text)); + return result; + }); + } + val supportedOps() { return gpp_rethrow([=]() { auto ops = @@ -350,5 +360,6 @@ EMSCRIPTEN_BINDINGS(gphoto2_js_api) { .function("capturePreviewAsBlob", &Context::capturePreviewAsBlob) .function("captureImageAsFile", &Context::captureImageAsFile) .function("consumeEvents", &Context::consumeEvents) + .function("summary", &Context::summary) .function("supportedOps", &Context::supportedOps); } diff --git a/ui/index.js b/ui/index.js index 6a76964c4..7ba8675d9 100644 --- a/ui/index.js +++ b/ui/index.js @@ -222,7 +222,17 @@ class App extends Component { '⭐ Star on Github' ) ), - h(Widget, { config: state.config, setValue: this.setValue }) + h(Widget, { config: state.config, setValue: this.setValue }), + h( + 'fieldset', + null, + h('legend', null, 'Camera Summary'), + h( + 'pre', + { style: 'white-space: pre-wrap' }, + this.connection.summary.text + ) + ) ) ) ); diff --git a/ui/libapi.mjs.d.ts b/ui/libapi.mjs.d.ts index b94c6ca10..9e2595139 100644 --- a/ui/libapi.mjs.d.ts +++ b/ui/libapi.mjs.d.ts @@ -31,6 +31,10 @@ export type Config = { | { type: 'datetime'; value: number } ); +declare interface Summary { + text: string; +} + declare interface SupportedOps { captureImage: boolean; captureVideo: boolean; @@ -49,6 +53,7 @@ declare class Context { capturePreviewAsBlob(): Promise; captureImageAsFile(): Promise; consumeEvents(): Promise; + summary(): Summary; supportedOps(): SupportedOps; delete(): void; diff --git a/ui/ops.js b/ui/ops.js index 833d185b3..1b48117c7 100644 --- a/ui/ops.js +++ b/ui/ops.js @@ -34,6 +34,7 @@ export async function connect() { const Module = await ModulePromise; let context = await new Module.Context(); + let summary = await context.summary(); let supportedOps = await context.supportedOps(); /** @type {Promise} */ @@ -51,6 +52,7 @@ export async function connect() { } return { + summary, supportedOps, schedule, disconnect() {