Skip to content

Commit

Permalink
feat(js): add prepend_child/append_child to child menu item
Browse files Browse the repository at this point in the history
  • Loading branch information
std-microblock committed Feb 4, 2025
1 parent b328221 commit 0fd381b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/shell/script/binding_qjs.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ template<> struct js_bind<mb_shell::js::menu_item_parent_item_controller> {
.fun<&mb_shell::js::menu_item_parent_item_controller::remove>("remove")
.fun<&mb_shell::js::menu_item_parent_item_controller::valid>("valid")
.fun<&mb_shell::js::menu_item_parent_item_controller::append_child_after>("append_child_after")
.fun<&mb_shell::js::menu_item_parent_item_controller::append_child>("append_child")
.fun<&mb_shell::js::menu_item_parent_item_controller::prepend_child>("prepend_child")
;
}

Expand Down Expand Up @@ -501,6 +503,8 @@ template <> struct qjs::js_traits<mb_shell::js::caller_window_data> {

obj.executable_path = js_traits<std::string>::unwrap(ctx, JS_GetPropertyStr(ctx, v, "executable_path"));

obj.title = js_traits<std::string>::unwrap(ctx, JS_GetPropertyStr(ctx, v, "title"));

return obj;
}

Expand All @@ -527,6 +531,8 @@ template <> struct qjs::js_traits<mb_shell::js::caller_window_data> {

JS_SetPropertyStr(ctx, obj, "executable_path", js_traits<std::string>::wrap(ctx, val.executable_path));

JS_SetPropertyStr(ctx, obj, "title", js_traits<std::string>::wrap(ctx, val.title));

return obj;
}
};
Expand All @@ -544,6 +550,7 @@ template<> struct js_bind<mb_shell::js::caller_window_data> {
.fun<&mb_shell::js::caller_window_data::focused>("focused")
.fun<&mb_shell::js::caller_window_data::visible>("visible")
.fun<&mb_shell::js::caller_window_data::executable_path>("executable_path")
.fun<&mb_shell::js::caller_window_data::title>("title")
;
}

Expand Down
17 changes: 17 additions & 0 deletions src/shell/script/binding_types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,22 @@ export class menu_item_parent_item_controller {
*/
append_child_after: ((arg1: js_menu_data, arg2: number) => menu_item_controller)


/**
*
* @param data: js_menu_data
* @returns menu_item_controller
*/
append_child: ((arg1: js_menu_data) => menu_item_controller)


/**
*
* @param data: js_menu_data
* @returns menu_item_controller
*/
prepend_child: ((arg1: js_menu_data) => menu_item_controller)

}

export class window_prop_data {
Expand All @@ -665,6 +681,7 @@ export class caller_window_data {
focused: boolean
visible: boolean
executable_path: string
title: string

}

Expand Down
10 changes: 10 additions & 0 deletions src/shell/script/binding_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,16 @@ struct menu_item_parent_item_controller {

std::shared_ptr<mb_shell::js::menu_item_controller>
append_child_after(mb_shell::js::js_menu_data data, int after_index);

inline std::shared_ptr<mb_shell::js::menu_item_controller>
append_child(mb_shell::js::js_menu_data data) {
return append_child_after(data, -1);
}

inline std::shared_ptr<mb_shell::js::menu_item_controller>
prepend_child(mb_shell::js::js_menu_data data) {
return append_child_after(data, 0);
}
};

struct window_prop_data {
Expand Down

0 comments on commit 0fd381b

Please sign in to comment.