Skip to content

Commit

Permalink
Implement submenus for actions.
Browse files Browse the repository at this point in the history
- allow submenus, separators
- allow nested menus
- menu editor
  - drag-and-drop
  - allow submenus to have icons
  - allow overriding action labels, icons
  - enable/disable actions
- refactor blank-desktop-view, treeview-sidebar and places-
  sidebar to utilize GtkActions
- refactor action manager to work everywhere, not just the primary
  view
- refactor nemo-actions.c to clean up, reduce code.
  • Loading branch information
mtwebster committed Feb 5, 2024
1 parent 086a29d commit ef4adc0
Show file tree
Hide file tree
Showing 26 changed files with 3,463 additions and 1,627 deletions.
99 changes: 99 additions & 0 deletions action-layout-editor/actions-tree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@

## Actions layout JSON format

- The layout file is saved as `~/.config/nemo/actions/actions-tree.json`.
- A missing or invalid layout will result in a flat list of all actions.
- Definition requirements may change...

#### Structure and node elements

##### The definition must have a 'toplevel' root object, which contains an array of objects (with these possibly having arrays of children also):
```json
{
"toplevel": [
]
}
```

##### Children must adhere to the following definitions:
- `'uuid': string` - For valid 'spices'-based actions, this will be their UUID. For legacy/non-spice actions, it will be the action file's basename, suffixed by `@untracked`. For submenus, it will be the submenu's label.
- `'type': string` - `action`, `submenu` or `separator`
- `'position': integer` - The action or submenu's position at the current tree depth. This is currently for reference only, as the order is preserved when parsing or creating json files, and saved position is ignored.
- `'user-label': string` - can be `null` - The action or submenu's label. In the case of actions, this will be `null` initially, and the action's `Name` field will be used. It can be overridden, and the new value is kept here.
- `'user-icon': string` - can be `null` or empty - The action or submenu's icon. In the case of actions, this will be `null` initially, and the icon string will be drawn from the action's `Icon-Name` field. It can be overridden - the new value is kept here. The special value of `""` (empty string) will suppress any icon altogether.
- `'children': array` (submenu types only) - contains another level of actions and possibly submenus.

##### Example
```json
{
"toplevel": [
{
"uuid": "sample@untracked",
"type": "action",
"position": 0,
"user-label": null,
"user-icon": null
},
{
"uuid": "mint_dev_tool_make_thumbnail@untracked",
"type": "action",
"position": 1,
"user-label": null,
"user-icon": null
},
{
"uuid": "92_show-expo@untracked",
"type": "action",
"position": 2,
"user-label": "Manage workspaces",
"user-icon": "address-book-new-symbolic"
},
{
"uuid": "Test category",
"type": "submenu",
"position": 3,
"user-label": "Test category",
"user-icon": "face-smile",
"children": [
{
"uuid": "change-background@untracked",
"type": "action",
"position": 0,
"user-label": null,
"user-icon": null
},
{
"uuid": "Sub test category",
"type": "submenu",
"position": 1,
"user-label": "Sub test category",
"user-icon": null,
"children": [
{
"uuid": "mint_dev_tool_show_file_metadata@untracked",
"type": "action",
"position": 0,
"user-label": null,
"user-icon": null
}
]
},
{
"uuid": "mint_dev_tool_add_shadow@untracked",
"type": "action",
"position": 2,
"user-label": null,
"user-icon": null
}
]
},
{
"uuid": "91_delete-workspace@untracked",
"type": "action",
"position": 4,
"user-label": null,
"user-icon": null
}
]
}
```
6 changes: 6 additions & 0 deletions action-layout-editor/leconfig.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Generated file - DO NOT EDIT. Edit config.py.in instead.

LOCALE_DIR=@LOCALE_DIR@
PACKAGE=@PACKAGE@
VERSION=@VERSION@
PKG_DATADIR=@PKG_DATADIR@
36 changes: 36 additions & 0 deletions action-layout-editor/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
conf = configuration_data()
conf.set_quoted('PKG_DATADIR', nemoDataPath)
conf.set_quoted('LOCALE_DIR', join_paths(get_option('prefix'), get_option('localedir')))
conf.set_quoted('PACKAGE', meson.project_name())
conf.set_quoted('VERSION', meson.project_version())

config_py = configure_file(
input: 'leconfig.py.in',
output: 'leconfig.py',
configuration: conf,
install: true,
install_dir: nemoDataPath / 'layout-editor',
)

bin_conf = configuration_data()
bin_conf.set('PKG_DATADIR', nemoDataPath)

bin = configure_file(
input: 'nemo-action-layout-editor.in',
output: 'nemo-action-layout-editor',
configuration: bin_conf,
install: true,
install_dir: get_option('bindir'),
install_mode: 'rwxr-xr-x'
)

install_data(
'nemo-action-layout-editor.py',
install_dir: nemoDataPath / 'layout-editor',
install_mode: 'rwxr-xr-x'
)

install_data(
'nemo-action-layout-editor.glade',
install_dir: nemoDataPath / 'layout-editor'
)
Loading

0 comments on commit ef4adc0

Please sign in to comment.