Add submenus when there's more than one template per filetype.
Fixes #3357. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/3397
-- Commit Summary --
* Put items with submenus at the top of the menu * Add filetype submenus for new file template menus
-- File Changes --
M src/templates.c (40) M src/ui_utils.c (9) M src/ui_utils.h (2)
-- Patch Links --
https://github.com/geany/geany/pull/3397.patch https://github.com/geany/geany/pull/3397.diff
@elextr requested changes on this pull request.
AFAICT this requires files in the templates directory to have a filetype extension, this is not backward compatible and undocumented as currently files with any name are added to the menu, whereas now Geany would crash (see comment).
There are a lot of file formats that are not supported by a Geany filetype, this change would now preclude the user from having templates for them.
Instead, if a file does not have a filetype extension it should be added to the menu top level like those with a count of 1.
- add_file_item(fname, menu); + if (ft) + group = &ft_groups[ft->id]; + if (group->count == 1)
`group` may be NULL if a file in the directory does not have a filetype extension
@ntrel pushed 1 commit.
295e11db65384e29ed4ff815e32b90b7507c79d6 Remove redundant checks for null ft
@ntrel commented on this pull request.
- add_file_item(fname, menu); + if (ft) + group = &ft_groups[ft->id]; + if (group->count == 1)
I realized `ft` is never NULL in this function. The `if (ft)` checks were redundant, removed.
@ntrel pushed 1 commit.
db3c3814b0b04185bfd3bdd0230951c0e79621d0 Remove redundant checks for null ft
@elextr commented on this pull request.
- add_file_item(fname, menu); + if (ft) + group = &ft_groups[ft->id]; + if (group->count == 1)
Ahh, ok, `filetypes_detect_from_extension()` returns filetype none if it doesn't recognise it.
@ntrel pushed 1 commit.
ae583e62dcaa2c5b7c1a53911441a6976c3232e6 Update docs
@ntrel pushed 0 commits.
OK to merge?
Code ok by inspection (I spend blocks of time away from my dev machine and can't build anything, so can't test ATM).
Need to update https://www.geany.org/manual/current/index.html#file-templates to describe using directories.
@ntrel pushed 1 commit.
6e611ae02e7105d516b4ff63fff29cbe47dd27d2 Update docs
Need to update https://www.geany.org/manual/current/index.html#file-templates to describe using directories.
Now mentioned filetype submenus. Directories aren't used.
Yeah, thats what I meant ;-)
Merged #3397 into master.
github-comments@lists.geany.org