Skip to content

Commit

Permalink
Added ability to set the dock menu
Browse files Browse the repository at this point in the history
  • Loading branch information
apoco committed Feb 18, 2016
1 parent 1e76371 commit 97c61d7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,12 @@ This `Observable` should contain boolean values; `true` values will cause the do

This sink causes the OS X badge label to be updated.

###### menu$

This sink sets the menu in the OS X dock for the application. See
[the electron documentation](http://electron.atom.io/docs/v0.36.7/api/app/#appdocksetmenumenu-os-x) for details on what
these values should be.

##### ntlmAllowedOverride$

This sink should be an `Observable` of boolean values; when true, NTLM authentication is enabled for sites not
Expand Down
7 changes: 6 additions & 1 deletion src/MainDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ function subscribeToDockSinks(app, dock) {

return subscribeToDockBounceSinks(app, dock.bounce)
.concat(subscribeToDockBadgeLabels(app, dock.badgeLabel$))
.concat(subscribeToDockVisibility(app, dock.visibility$));
.concat(subscribeToDockVisibility(app, dock.visibility$))
.concat(subscribeToDockMenus(app, dock.menu$));
}

function subscribeToDockBounceSinks(app, bounce) {
Expand Down Expand Up @@ -293,3 +294,7 @@ function subscribeToDockVisibility(app, visibility$) {
visibility$.filter(value => value === true).forEach(() => app.dock.show())
];
}

function subscribeToDockMenus(app, menu$) {
return menu$ && menu$.forEach(menu => app.dock.setMenu(menu));
}
24 changes: 22 additions & 2 deletions test/specs/MainDriver.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ describe('MainDriver', () => {
getBadge: stub(),
setBadge: spy(),
show: spy(),
hide: spy()
hide: spy(),
setMenu: spy()
};
driver = new MainDriver(app);
});
Expand Down Expand Up @@ -889,7 +890,26 @@ describe('MainDriver', () => {
}, 1);
});
}
})
});

describe('menu$', () => {
it('causes app.dock.setMenu to be called', done => {
const menu = {};

Cycle.run(() => ({
electron: Observable.just({
dock: {
menu$: Observable.just(menu)
}
})
}), { electron: driver });

setTimeout(() => {
expect(app.dock.setMenu).to.have.been.calledWith(menu);
done();
}, 1);
});
});
});

describe('newChromiumParam$', () => {
Expand Down

0 comments on commit 97c61d7

Please sign in to comment.