Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[READY] Added hs.webview.toolbar.uniqueName() #2147

Merged
merged 3 commits into from Aug 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions extensions/webview/toolbar_internal.m
Expand Up @@ -819,6 +819,23 @@ static int newHSToolbar(lua_State *L) {
return 1 ;
}

/// hs.webview.toolbar.uniqueName(toolbarName) -> boolean
/// Function
/// Checks to see is a toolbar name is already in use
///
/// Parameters:
/// * toolbarName - a string specifying the name of a toolbar
///
/// Returns:
/// * `true` if the name is unique otherwise `false`
static int uniqueName(lua_State *L) {
LuaSkin *skin = [LuaSkin shared] ;
[skin checkArgs:LS_TSTRING, LS_TBREAK] ;
NSString *identifier = [skin toNSObjectAtIndex:1] ;
lua_pushboolean(L, ![identifiersInUse containsObject:identifier]);
return 1 ;
}

/// hs.webview.toolbar.attachToolbar([obj1], [obj2]) -> obj1
/// Function
/// Get or attach/detach a toolbar to the webview, chooser, or console.
Expand Down Expand Up @@ -2022,6 +2039,7 @@ static int meta_gc(__unused lua_State* L) {
static luaL_Reg moduleLib[] = {
{"new", newHSToolbar},
{"attachToolbar", attachToolbar},
{"uniqueName", uniqueName},
{NULL, NULL}
};

Expand Down