Skip to content

Commit

Permalink
Merge pull request #5 from mmuffins/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
mmuffins authored Dec 19, 2020
2 parents 9d881f8 + 07145f4 commit f233d6b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
# Addon Menu for MediaMonkey
[![Build status](https://dev.azure.com/mmuffins/github/_apis/build/status/MediaMonkey.AddonMenu)](https://dev.azure.com/mmuffins/github/_build/latest?definitionId=79)

This addon adds an additional item to the MediaMonkey 5 main menu bar that allows addon developers to present an entry point or functionality of their addon in a central and consistent way to the user.

## Installation
Download the latest release from the releases section and double click addonMenu.mmip. An MediaMonkey dialog will automatically pop up, prompting you to confirm the installation.
Download the latest release from the releases section and double click the downloaded mmip file. An MediaMonkey dialog will automatically pop up, prompting you to confirm the installation. Once installed, the addon menu will automatically look for actions exposed by installed addons and add them to a new Addons item in the main menu bar.

### I don't see the addon menu after I installed the addon
The addon menu will only be displayed if addon actions were found. You can validate this by opening the addon configuration page for the addon menu.

### I installed an addon, but the menu doesn't contain any actions for it
If an installed addon doesn't show up in the menu, it either doesn't expose any actions or the actions are not configured to work with the addon menu. If there is an addon you would like to see added to the menu, please point the maintainer of the addon to this page, menu support can usually be added with a few lines of code.

## Registering actions
The addon menu automatically imports all valid actions from the global actions object if they are in the Extenions category. The following properties are required for an action to be considered valid:
## Developer information
### Registering actions
The addon menu automatically imports all valid actions from the global actions object if they are in the addons category. The following properties are required for an action to be considered valid:

| Name | Type | Description |
| :------------ |:---------- | :---------- |
| title | function | Display name of the action |
| addon | function | Folder name to group actions |
| addon | function | Folder name to group actions |
| execute | function | Function to execute when calling the action |

## Example
### Example
To create new actions, simply add new actions to the global actions object.

```javascript
Expand All @@ -28,8 +33,8 @@ if(!window.actionCategories.hasOwnProperty('addons')){
// Create the needed actions
window.actions.MyAddonAction = {
title: () => _('&My Addon Action'),
hotkeyAble: true,
category: actionCategories.addons, // Should always be actionCategories.addons, otherwise the action won't be discovered by the addon menu
hotkeyAble: true, // If set to true, the action can be mapped to a hotkey in the settings screen under Options > General > Hotkeys.
category: actionCategories.addons,
icon: 'myAddonIcon',
addon: () => _("My &Addon"),
execute: () => alert('My Addon Action')
Expand Down
8 changes: 5 additions & 3 deletions actions_add.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Add global section to register addon actions if it doesn't exist yet
if(typeof addons == "undefined" )
addons = {};
if (typeof window.addons == "undefined")
window.addons = {}

actionCategories.addons = () => _('Addons');
if(!window.actionCategories.hasOwnProperty('addons')){
window.actionCategories.addons = () => _('Addons');
}
4 changes: 3 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ window.configInfo = {

// the config menu runs in a separate context from the main window
let mainAppWindow = app.dialogs.getMainWindow()._window;
mainAppWindow.addons.addonMenu.refresh();
if(mainAppWindow.addons && mainAppWindow.addons.addonMenu){
mainAppWindow.addons.addonMenu.refresh();
}
},

handleButtonsDisableState: function(e){
Expand Down
4 changes: 2 additions & 2 deletions info.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"title": "Addon Menu",
"id": "addonMenu",
"description": "Adds an Addons Section to the Main Menu",
"description": "Adds an Addons section to the main menu bar.",
"version": "4.0.0",
"type": "general",
"author": "mmuffins",
"config": "config.js",
"icon": "/skin/icon/addonMenu.svg"
"icon": "info.svg"
}
File renamed without changes

0 comments on commit f233d6b

Please sign in to comment.