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

Add filetype submenus for new file with template menus #3397

Merged
merged 4 commits into from
Mar 9, 2023

Conversation

ntrel
Copy link
Member

@ntrel ntrel commented Feb 13, 2023

Add submenus when there's more than one template per filetype.

Fixes #3357.
Also put menu items with submenus at the top of the menu, not the bottom.

elextr
elextr previously requested changes Feb 14, 2023
Copy link
Member

@elextr elextr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

group may be NULL if a file in the directory does not have a filetype extension

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized ft is never NULL in this function. The if (ft) checks were redundant, removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, ok, filetypes_detect_from_extension() returns filetype none if it doesn't recognise it.

@ntrel
Copy link
Member Author

ntrel commented Feb 27, 2023

OK to merge?

@elextr
Copy link
Member

elextr commented Feb 27, 2023

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
Copy link
Member Author

ntrel commented Mar 1, 2023

Code ok by inspection

Thanks.

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.

@elextr
Copy link
Member

elextr commented Mar 1, 2023

Yeah, thats what I meant ;-)

@ntrel ntrel merged commit 8a9e9be into geany:master Mar 9, 2023
@ntrel ntrel deleted the group-file-templates branch March 9, 2023 16:24
@b4n b4n added this to the 1.39/2.0 milestone Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Idea: Submenus for the "New" Menu
3 participants