Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Wed, 20 Nov 2024 14:58:23 UTC Commit: 0b4732d9f7fae9d7064c5330316f7ed654425294 https://github.com/geany/geany/commit/0b4732d9f7fae9d7064c5330316f7ed6544252...
Log Message: ----------- Regroup filetypes by letter
This patch converts the currently used groups like "Programming languages", "Scripting languages", etc. to groups based on the starting letter of the language only. There are two main reasons for this change:
1. Some languages are hard to categorize by some semantic group name and the group names are not really fitting. In addition, the currently used group name "Programming languages" isn't very good as "Scripting languages" are also a subset of programming languages. On the other hand it's hard to find a good substitute for "Programming languages" - mostly these are "Compiled languages" but not always and some languages allow to be both interpreted and compiled which complicates the situation. 2. The "Programming languages" group is too big and the menu is so long that it doesn't fit the display on smaller screens and one has to scroll the menu to get to the right item which isn't user friendly. Things will get only worse as there are still many "Programming languages" that Geany does not support yet and that might be added to the editor in the future.
The newly introduced alphabetic groups are: A-B C D-E-F G-H-I J-K-L M-N-O P-Q R-S T-U-V-W X-Y-Z
These allow roughly even distribution of existing languages into smaller groups with enough space for possible future language additions. While it would be possible to make the group names more symmetrical, e.g. by having "R-S-T", "U-V-W", I found that the asymmetry helps quicker navigation as one remembers the group with his favorite language is e.g. "the one before the long group" without thinking where exactly in the alphabet the letter is.
Some notes to the implementation: 1. It mostly follows the existing implementation trying to do minimal changes and doing things in a "dumb and straightforward way". This means that group names are hard coded (they could also be autogenerated, possibly auto-attempting to distribute languages into evenly sized groups). 2. Technically this change breaks API as it modifies GeanyFiletypeGroupID which is used for the group member of GeanyFiletype which is accessible to plugins. However, this member isn't documented to plugins and no existing plugin from geany-plugins uses it so probably not a big problem. 3. Because grouping happens automatically now, the [Groups] section from filetype_extensions.conf can be removed and is not read any more. 4. Because grouping happens automatically now, the [5] argument from FT_INIT() can be removed. 5. In addition, this patch also removes the [4] argument from FT_INIT() which determined the suffix in the filetype menu like "C++ source file" - IMO the "source file", "file", etc. suffix for all the languages in the menu introduced just a visual clutter and made legibility worse. In addition with the removal of [Groups] from filetype_extensions.conf in (3), it would not be possible to determine the right suffix for custom file types. 6. The newly introduced groups are untranslatable strings - there should be no need to translate those. 7. If users create a non-builtin filetype starting with a non-alphabetic character, it will be placed into a group called Other. This group won't be displayed if there are no such filetype. 8. Human-readable names of languages are converted to non-translatable strings because otherwise their placement into groups may be confusing. Also, these names should start with the same letter like the language name itself otherwise the grouping in Tools->Configuration Files-> Filetype Configuration might not correspond to the language name.
Modified Paths: -------------- data/filetype_extensions.conf src/dialogs.c src/filetypes.c src/filetypes.h
Modified: data/filetype_extensions.conf 8 lines changed, 0 insertions(+), 8 deletions(-) =================================================================== @@ -88,11 +88,3 @@ YAML=*.yaml;*.yml; Zephir=*.zep; Zig=*.zig; None=*; - -# Note: restarting is required after editing groups -[Groups] -Programming=Arduino;Clojure;CUDA;Cython;Genie;Groovy;Kotlin;Scala;Swift;SystemVerilog; -Script=Dockerfile;Graphviz;TypeScript;Meson; -Markup= -Misc=JSON; -None=
Modified: src/dialogs.c 60 lines changed, 46 insertions(+), 14 deletions(-) =================================================================== @@ -211,36 +211,68 @@ static void filetype_combo_cell_data_func(GtkCellLayout *cell_layout, GtkCellRen static GtkWidget *create_filetype_combo_box(void) { GtkTreeStore *store; - GtkTreeIter iter_compiled, iter_script, iter_markup, iter_misc, iter_detect; + GtkTreeIter iter_a_b, iter_c, iter_d_e_f, iter_g_h_i, iter_j_k_l, iter_m_n_o, + iter_p_q, iter_r_s, iter_t_u_v_w, iter_x_y_z, iter_other, iter_detect; GtkTreeIter *iter_parent; GtkWidget *combo; GtkCellRenderer *renderer; GSList *node;
store = gtk_tree_store_new(2, G_TYPE_INT, G_TYPE_STRING);
- gtk_tree_store_insert_with_values(store, &iter_detect, NULL, -1, + gtk_tree_store_insert_with_values(store, &iter_detect, NULL, -1, 0, -1 /* auto-detect */, 1, _("Detect from file"), -1);
- gtk_tree_store_insert_with_values(store, &iter_compiled, NULL, -1, - 0, -1, 1, _("Programming Languages"), -1); - gtk_tree_store_insert_with_values(store, &iter_script, NULL, -1, - 0, -1, 1, _("Scripting Languages"), -1); - gtk_tree_store_insert_with_values(store, &iter_markup, NULL, -1, - 0, -1, 1, _("Markup Languages"), -1); - gtk_tree_store_insert_with_values(store, &iter_misc, NULL, -1, - 0, -1, 1, _("Miscellaneous"), -1); + gtk_tree_store_insert_with_values(store, &iter_a_b, NULL, -1, + 0, -1, 1, "A-B", -1); + gtk_tree_store_insert_with_values(store, &iter_c, NULL, -1, + 0, -1, 1, "C", -1); + gtk_tree_store_insert_with_values(store, &iter_d_e_f, NULL, -1, + 0, -1, 1, "D-E-F", -1); + gtk_tree_store_insert_with_values(store, &iter_g_h_i, NULL, -1, + 0, -1, 1, "G-H-I", -1); + gtk_tree_store_insert_with_values(store, &iter_j_k_l, NULL, -1, + 0, -1, 1, "J-K-L", -1); + gtk_tree_store_insert_with_values(store, &iter_m_n_o, NULL, -1, + 0, -1, 1, "M-N-O", -1); + gtk_tree_store_insert_with_values(store, &iter_p_q, NULL, -1, + 0, -1, 1, "P-Q", -1); + gtk_tree_store_insert_with_values(store, &iter_r_s, NULL, -1, + 0, -1, 1, "R-S", -1); + gtk_tree_store_insert_with_values(store, &iter_t_u_v_w, NULL, -1, + 0, -1, 1, "T-U-V-W", -1); + gtk_tree_store_insert_with_values(store, &iter_x_y_z, NULL, -1, + 0, -1, 1, "X-Y-Z", -1); + + foreach_slist (node, filetypes_by_title) + { + GeanyFiletype *ft = node->data; + + if (ft->group == GEANY_FILETYPE_GROUP_OTHER) + { + gtk_tree_store_insert_with_values(store, &iter_other, NULL, -1, + 0, -1, 1, _("Other"), -1); + break; + } + }
foreach_slist (node, filetypes_by_title) { GeanyFiletype *ft = node->data;
switch (ft->group) { - case GEANY_FILETYPE_GROUP_COMPILED: iter_parent = &iter_compiled; break; - case GEANY_FILETYPE_GROUP_SCRIPT: iter_parent = &iter_script; break; - case GEANY_FILETYPE_GROUP_MARKUP: iter_parent = &iter_markup; break; - case GEANY_FILETYPE_GROUP_MISC: iter_parent = &iter_misc; break; + case GEANY_FILETYPE_GROUP_A_B: iter_parent = &iter_a_b; break; + case GEANY_FILETYPE_GROUP_C: iter_parent = &iter_c; break; + case GEANY_FILETYPE_GROUP_D_E_F: iter_parent = &iter_d_e_f; break; + case GEANY_FILETYPE_GROUP_G_H_I: iter_parent = &iter_g_h_i; break; + case GEANY_FILETYPE_GROUP_J_K_L: iter_parent = &iter_j_k_l; break; + case GEANY_FILETYPE_GROUP_M_N_O: iter_parent = &iter_m_n_o; break; + case GEANY_FILETYPE_GROUP_P_Q: iter_parent = &iter_p_q; break; + case GEANY_FILETYPE_GROUP_R_S: iter_parent = &iter_r_s; break; + case GEANY_FILETYPE_GROUP_T_U_V_W: iter_parent = &iter_t_u_v_w; break; + case GEANY_FILETYPE_GROUP_X_Y_Z: iter_parent = &iter_x_y_z; break; + case GEANY_FILETYPE_GROUP_OTHER: iter_parent = &iter_other; break; case GEANY_FILETYPE_GROUP_NONE: default: iter_parent = NULL; }
Modified: src/filetypes.c 292 lines changed, 146 insertions(+), 146 deletions(-) =================================================================== @@ -49,6 +49,7 @@
#include <stdlib.h> #include <string.h> +#include <ctype.h>
#include <glib/gstdio.h>
@@ -67,49 +68,68 @@ static void create_set_filetype_menu(gboolean config); static gchar *filetypes_get_filename(GeanyFiletype *ft, gboolean user);
-enum TitleType +static GeanyFiletypeGroupID get_group(const gchar *name) { - TITLE_NONE, - TITLE_SOURCE_FILE, - TITLE_FILE, - TITLE_SCRIPT, - TITLE_DOCUMENT -}; - -/* Save adding many translation strings if the filetype name doesn't need translating */ -static gchar *filetype_make_title(const char *name, enum TitleType type) + gchar ch; + + if (EMPTY(name) || !isalpha(name[0])) + return GEANY_FILETYPE_GROUP_OTHER; + + ch = name[0]; + if (ch >= 'a') + ch -= 'a' - 'A'; + + if (ch >= 'A' && ch <= 'B') + return GEANY_FILETYPE_GROUP_A_B; + else if (ch == 'C') + return GEANY_FILETYPE_GROUP_C; + else if (ch >= 'D' && ch <= 'F') + return GEANY_FILETYPE_GROUP_D_E_F; + else if (ch >= 'G' && ch <= 'I') + return GEANY_FILETYPE_GROUP_G_H_I; + else if (ch >= 'J' && ch <= 'L') + return GEANY_FILETYPE_GROUP_J_K_L; + else if (ch >= 'M' && ch <= 'O') + return GEANY_FILETYPE_GROUP_M_N_O; + else if (ch >= 'P' && ch <= 'Q') + return GEANY_FILETYPE_GROUP_P_Q; + else if (ch >= 'R' && ch <= 'S') + return GEANY_FILETYPE_GROUP_R_S; + else if (ch >= 'T' && ch <= 'W') + return GEANY_FILETYPE_GROUP_T_U_V_W; + else if (ch >= 'X' && ch <= 'Z') + return GEANY_FILETYPE_GROUP_X_Y_Z; + + return GEANY_FILETYPE_GROUP_OTHER; +} + + +static GeanyFiletypeGroupID get_filetype_group(const gchar *title, const gchar *name) { - g_return_val_if_fail(name != NULL, NULL); + GeanyFiletypeGroupID ret;
- switch (type) - { - case TITLE_SOURCE_FILE: return g_strdup_printf(_("%s source file"), name); - case TITLE_FILE: return g_strdup_printf(_("%s file"), name); - case TITLE_SCRIPT: return g_strdup_printf(_("%s script"), name); - case TITLE_DOCUMENT: return g_strdup_printf(_("%s document"), name); - case TITLE_NONE: /* fall through */ - default: return g_strdup(name); - } + if (g_strcmp0(name, "None") == 0) + return GEANY_FILETYPE_GROUP_NONE; + + return get_group(title); }
/* name argument (ie filetype name) must not be translated as it is used for * filetype lookup. Use filetypes_get_display_name() instead.*/ static void ft_init(GeanyFiletypeID ft_id, TMParserType lang, const char *name, - const char *title_name, enum TitleType title_type, - GeanyFiletypeGroupID group_id) + const char *title_name) { GeanyFiletype *ft = filetypes[ft_id]; ft->lang = lang; ft->name = g_strdup(name); - ft->title = filetype_make_title((title_name != NULL) ? title_name : ft->name, title_type); - ft->group = group_id; + ft->title = g_strdup((title_name != NULL) ? title_name : ft->name); + ft->group = get_filetype_group(ft->title, ft->name); }
/* Evil macro to save typing and make init_builtin_filetypes() more readable */ -#define FT_INIT(ft_id, parser_id, name, title_name, title_type, group_id) \ - ft_init(GEANY_FILETYPES_##ft_id, TM_PARSER_##parser_id, name, title_name, \ - TITLE_##title_type, GEANY_FILETYPE_GROUP_##group_id) +#define FT_INIT(ft_id, parser_id, name, title_name) \ + ft_init(GEANY_FILETYPES_##ft_id, TM_PARSER_##parser_id, name, title_name)
/* Note: remember to update HACKING if this function is renamed. */ @@ -118,83 +138,82 @@ static void init_builtin_filetypes(void) /* Column legend: * [0] = Filetype constant (GEANY_FILETYPES_*) * [1] = CTags parser (TM_PARSER_*) - * [2] = Non-translated filetype name (*not* label for display) - * [3] = Translatable human filetype title prefix or NULL to use [2] - * [4] = Title type (TITLE_*) constant (ex. TITLE_SOURCE_FILE is 'source file' suffix) - * [5] = The filetype group constant (GEANY_FILETYPE_GROUP_*) - * -------------------------------------------------------------------------------------------------------------------------- - * [0] [1] [2] [3] [4] [5] */ - FT_INIT( NONE, NONE, "None", _("None"), NONE, NONE ); - FT_INIT( C, C, "C", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( CPP, CPP, "C++", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( OBJECTIVEC, OBJC, "Objective-C", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( CS, CSHARP, "C#", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( VALA, VALA, "Vala", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( D, D, "D", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( JAVA, JAVA, "Java", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( PASCAL, PASCAL, "Pascal", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( ASM, ASM, "ASM", "Assembler", SOURCE_FILE, COMPILED ); - FT_INIT( BASIC, FREEBASIC, "FreeBasic", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( FORTRAN, FORTRAN, "Fortran", "Fortran (F90)", SOURCE_FILE, COMPILED ); - FT_INIT( F77, FORTRAN, "F77", "Fortran (F77)", SOURCE_FILE, COMPILED ); - FT_INIT( GLSL, C, "GLSL", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( CAML, OCAML, "CAML", "(O)Caml", SOURCE_FILE, COMPILED ); - FT_INIT( PERL, PERL, "Perl", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( PHP, PHP, "PHP", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( JS, JAVASCRIPT, "Javascript", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( PYTHON, PYTHON, "Python", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( RUBY, RUBY, "Ruby", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( TCL, TCLOO, "Tcl", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( LUA, LUA, "Lua", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( GDSCRIPT, GDSCRIPT, "GDScript", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( HASKELL, HASKELL, "Haskell", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( MARKDOWN, MARKDOWN, "Markdown", NULL, SOURCE_FILE, MARKUP ); - FT_INIT( TXT2TAGS, TXT2TAGS, "Txt2tags", NULL, SOURCE_FILE, MARKUP ); - FT_INIT( ABC, ABC, "Abc", NULL, FILE, MISC ); - FT_INIT( SH, SH, "Sh", _("Shell"), SCRIPT, SCRIPT ); - FT_INIT( MAKE, MAKEFILE, "Make", _("Makefile"), NONE, SCRIPT ); - FT_INIT( XML, NONE, "XML", NULL, DOCUMENT, MARKUP ); - FT_INIT( DOCBOOK, DOCBOOK, "Docbook", NULL, DOCUMENT, MARKUP ); - FT_INIT( HTML, HTML, "HTML", NULL, DOCUMENT, MARKUP ); - FT_INIT( CSS, CSS, "CSS", _("Cascading Stylesheet"), NONE, MARKUP ); /* not really markup but fit quite well to HTML */ - FT_INIT( SQL, SQL, "SQL", NULL, FILE, MISC ); - FT_INIT( COBOL, COBOL, "COBOL", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( LATEX, LATEX, "LaTeX", NULL, SOURCE_FILE, MARKUP ); - FT_INIT( BIBTEX, BIBTEX, "BibTeX", NULL, SOURCE_FILE, MARKUP ); - FT_INIT( VHDL, VHDL, "VHDL", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( VERILOG, VERILOG, "Verilog", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( DIFF, DIFF, "Diff", NULL, FILE, MISC ); - FT_INIT( LISP, LISP, "Lisp", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( ERLANG, ERLANG, "Erlang", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( CONF, CONF, "Conf", _("Config"), FILE, MISC ); - FT_INIT( PO, NONE, "Po", _("Gettext translation"), FILE, MISC ); - FT_INIT( HAXE, HAXE, "Haxe", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( AS, ACTIONSCRIPT, "ActionScript", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( R, R, "R", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( REST, REST, "reStructuredText", NULL, SOURCE_FILE, MARKUP ); - FT_INIT( MATLAB, MATLAB, "Matlab/Octave", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( YAML, NONE, "YAML", NULL, FILE, MISC ); - FT_INIT( CMAKE, NONE, "CMake", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( NSIS, NSIS, "NSIS", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( ADA, ADA, "Ada", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( FORTH, FORTH, "Forth", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( ASCIIDOC, ASCIIDOC, "Asciidoc", NULL, SOURCE_FILE, MARKUP ); - FT_INIT( ABAQUS, ABAQUS, "Abaqus", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( BATCH, BATCH, "Batch", NULL, SCRIPT, SCRIPT ); - FT_INIT( POWERSHELL, POWERSHELL, "PowerShell", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( RUST, RUST, "Rust", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( COFFEESCRIPT, NONE, "CoffeeScript", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( GO, GO, "Go", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( ZEPHIR, ZEPHIR, "Zephir", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( SMALLTALK, NONE, "Smalltalk", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( JULIA, JULIA, "Julia", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( AU3, AUTOIT, "AutoIt", NULL, SCRIPT, SCRIPT ); - FT_INIT( RAKU, RAKU, "Raku", NULL, SOURCE_FILE, SCRIPT ); - FT_INIT( CIL, NONE, "CIL", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( PROLOG, NONE, "Prolog", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( NIM, NONE, "Nim", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( ZIG, NONE, "Zig", NULL, SOURCE_FILE, COMPILED ); - FT_INIT( DART, NONE, "Dart", NULL, SOURCE_FILE, COMPILED ); + * [2] = Non-translatable filetype name (*not* label for display) + * [3] = Non-translatable filetype label for display or NULL to use [2]. + * It should start with the same letter as [2] for correct categorization. + * ---------------------------------------------------------------------------------- + * [0] [1] [2] [3] */ + FT_INIT( NONE, NONE, "None", _("None") ); + FT_INIT( C, C, "C", NULL ); + FT_INIT( CPP, CPP, "C++", NULL ); + FT_INIT( OBJECTIVEC, OBJC, "Objective-C", NULL ); + FT_INIT( CS, CSHARP, "C#", NULL ); + FT_INIT( VALA, VALA, "Vala", NULL ); + FT_INIT( D, D, "D", NULL ); + FT_INIT( JAVA, JAVA, "Java", NULL ); + FT_INIT( PASCAL, PASCAL, "Pascal", NULL ); + FT_INIT( ASM, ASM, "ASM", "Assembler" ); + FT_INIT( BASIC, FREEBASIC, "FreeBasic", NULL ); + FT_INIT( FORTRAN, FORTRAN, "Fortran", "Fortran (F90)" ); + FT_INIT( F77, FORTRAN, "F77", "Fortran (F77)" ); + FT_INIT( GLSL, C, "GLSL", NULL ); + FT_INIT( CAML, OCAML, "CAML", "Caml/OCaml" ); + FT_INIT( PERL, PERL, "Perl", NULL ); + FT_INIT( PHP, PHP, "PHP", NULL ); + FT_INIT( JS, JAVASCRIPT, "Javascript", NULL ); + FT_INIT( PYTHON, PYTHON, "Python", NULL ); + FT_INIT( RUBY, RUBY, "Ruby", NULL ); + FT_INIT( TCL, TCLOO, "Tcl", NULL ); + FT_INIT( LUA, LUA, "Lua", NULL ); + FT_INIT( GDSCRIPT, GDSCRIPT, "GDScript", NULL ); + FT_INIT( HASKELL, HASKELL, "Haskell", NULL ); + FT_INIT( MARKDOWN, MARKDOWN, "Markdown", NULL ); + FT_INIT( TXT2TAGS, TXT2TAGS, "Txt2tags", NULL ); + FT_INIT( ABC, ABC, "Abc", NULL ); + FT_INIT( SH, SH, "Sh", "Shell" ); + FT_INIT( MAKE, MAKEFILE, "Make", "Makefile" ); + FT_INIT( XML, NONE, "XML", NULL ); + FT_INIT( DOCBOOK, DOCBOOK, "Docbook", NULL ); + FT_INIT( HTML, HTML, "HTML", NULL ); + FT_INIT( CSS, CSS, "CSS", NULL ); + FT_INIT( SQL, SQL, "SQL", NULL ); + FT_INIT( COBOL, COBOL, "COBOL", NULL ); + FT_INIT( LATEX, LATEX, "LaTeX", NULL ); + FT_INIT( BIBTEX, BIBTEX, "BibTeX", NULL ); + FT_INIT( VHDL, VHDL, "VHDL", NULL ); + FT_INIT( VERILOG, VERILOG, "Verilog", NULL ); + FT_INIT( DIFF, DIFF, "Diff", NULL ); + FT_INIT( LISP, LISP, "Lisp", NULL ); + FT_INIT( ERLANG, ERLANG, "Erlang", NULL ); + FT_INIT( CONF, CONF, "Conf", "Conf/Ini" ); + FT_INIT( PO, NONE, "Po", "Po (Gettext)" ); + FT_INIT( HAXE, HAXE, "Haxe", NULL ); + FT_INIT( AS, ACTIONSCRIPT, "ActionScript", NULL ); + FT_INIT( R, R, "R", NULL ); + FT_INIT( REST, REST, "reStructuredText", NULL ); + FT_INIT( MATLAB, MATLAB, "Matlab/Octave", NULL ); + FT_INIT( YAML, NONE, "YAML", NULL ); + FT_INIT( CMAKE, NONE, "CMake", NULL ); + FT_INIT( NSIS, NSIS, "NSIS", NULL ); + FT_INIT( ADA, ADA, "Ada", NULL ); + FT_INIT( FORTH, NONE, "Forth", NULL ); + FT_INIT( ASCIIDOC, ASCIIDOC, "Asciidoc", NULL ); + FT_INIT( ABAQUS, ABAQUS, "Abaqus", NULL ); + FT_INIT( BATCH, BATCH, "Batch", NULL ); + FT_INIT( POWERSHELL, POWERSHELL, "PowerShell", NULL ); + FT_INIT( RUST, RUST, "Rust", NULL ); + FT_INIT( COFFEESCRIPT, NONE, "CoffeeScript", NULL ); + FT_INIT( GO, GO, "Go", NULL ); + FT_INIT( ZEPHIR, ZEPHIR, "Zephir", NULL ); + FT_INIT( SMALLTALK, NONE, "Smalltalk", NULL ); + FT_INIT( JULIA, JULIA, "Julia", NULL ); + FT_INIT( AU3, AUTOIT, "AutoIt", NULL ); + FT_INIT( RAKU, RAKU, "Raku", NULL ); + FT_INIT( CIL, NONE, "CIL", NULL ); + FT_INIT( PROLOG, NONE, "Prolog", NULL ); + FT_INIT( NIM, NONE, "Nim", NULL ); + FT_INIT( ZIG, NONE, "Zig", NULL ); + FT_INIT( DART, NONE, "Dart", NULL ); }
@@ -284,7 +303,8 @@ static void add_custom_filetype(const gchar *filename)
ft = filetype_new(); ft->name = g_strdup(fn); - ft->title = filetype_make_title(ft->name, TITLE_FILE); + ft->title = g_strdup(ft->name); + ft->group = get_filetype_group(ft->title, ft->name); ft->priv->custom = TRUE; filetype_add(ft); geany_debug("Added filetype %s (%d).", ft->name, ft->id); @@ -437,10 +457,27 @@ static void create_set_filetype_menu(gboolean config) menu = config ? ui_widgets.config_files_filetype_menu : ui_lookup_widget(main_widgets.window, "set_filetype1_menu");
- group_menus[GEANY_FILETYPE_GROUP_COMPILED] = create_sub_menu(menu, _("_Programming Languages")); - group_menus[GEANY_FILETYPE_GROUP_SCRIPT] = create_sub_menu(menu, _("_Scripting Languages")); - group_menus[GEANY_FILETYPE_GROUP_MARKUP] = create_sub_menu(menu, _("_Markup Languages")); - group_menus[GEANY_FILETYPE_GROUP_MISC] = create_sub_menu(menu, _("M_iscellaneous")); + group_menus[GEANY_FILETYPE_GROUP_A_B] = create_sub_menu(menu, "A-B"); + group_menus[GEANY_FILETYPE_GROUP_C] = create_sub_menu(menu, "C"); + group_menus[GEANY_FILETYPE_GROUP_D_E_F] = create_sub_menu(menu, "D-E-F"); + group_menus[GEANY_FILETYPE_GROUP_G_H_I] = create_sub_menu(menu, "G-H-I"); + group_menus[GEANY_FILETYPE_GROUP_J_K_L] = create_sub_menu(menu, "J-K-L"); + group_menus[GEANY_FILETYPE_GROUP_M_N_O] = create_sub_menu(menu, "M-N-O"); + group_menus[GEANY_FILETYPE_GROUP_P_Q] = create_sub_menu(menu, "P-Q"); + group_menus[GEANY_FILETYPE_GROUP_R_S] = create_sub_menu(menu, "R-S"); + group_menus[GEANY_FILETYPE_GROUP_T_U_V_W] = create_sub_menu(menu, "T-U-V-W"); + group_menus[GEANY_FILETYPE_GROUP_X_Y_Z] = create_sub_menu(menu, "X-Y-Z"); + + foreach_slist(node, filetypes_by_title) + { + GeanyFiletype *ft = node->data; + + if (ft->group == GEANY_FILETYPE_GROUP_OTHER) + { + group_menus[GEANY_FILETYPE_GROUP_OTHER] = create_sub_menu(menu, _("Other")); + break; + } + }
/* Append all filetypes to the menu */ foreach_slist(node, filetypes_by_title) @@ -1436,41 +1473,6 @@ static void read_extensions(GKeyFile *sysconfig, GKeyFile *userconfig) }
-static void read_group(GKeyFile *config, const gchar *group_name, GeanyFiletypeGroupID group_id) -{ - gchar **names = g_key_file_get_string_list(config, "Groups", group_name, NULL, NULL); - gchar **name; - - foreach_strv(name, names) - { - GeanyFiletype *ft = filetypes_lookup_by_name(*name); - - if (ft) - { - ft->group = group_id; - if (ft->priv->custom && - (group_id == GEANY_FILETYPE_GROUP_COMPILED || group_id == GEANY_FILETYPE_GROUP_SCRIPT)) - { - SETPTR(ft->title, filetype_make_title(ft->name, TITLE_SOURCE_FILE)); - } - } - else - geany_debug("Filetype '%s' not found for group '%s'!", *name, group_name); - } - g_strfreev(names); -} - - -static void read_groups(GKeyFile *config) -{ - read_group(config, "Programming", GEANY_FILETYPE_GROUP_COMPILED); - read_group(config, "Script", GEANY_FILETYPE_GROUP_SCRIPT); - read_group(config, "Markup", GEANY_FILETYPE_GROUP_MARKUP); - read_group(config, "Misc", GEANY_FILETYPE_GROUP_MISC); - read_group(config, "None", GEANY_FILETYPE_GROUP_NONE); -} - - static void read_filetype_config(void) { gchar *sysconfigfile = g_build_filename(app->datadir, "filetype_extensions.conf", NULL); @@ -1482,8 +1484,6 @@ static void read_filetype_config(void) g_key_file_load_from_file(userconfig, userconfigfile, G_KEY_FILE_NONE, NULL);
read_extensions(sysconfig, userconfig); - read_groups(sysconfig); - read_groups(userconfig);
g_free(sysconfigfile); g_free(userconfigfile);
Modified: src/filetypes.h 15 lines changed, 11 insertions(+), 4 deletions(-) =================================================================== @@ -128,10 +128,17 @@ GeanyFiletypeID; typedef enum { GEANY_FILETYPE_GROUP_NONE, - GEANY_FILETYPE_GROUP_COMPILED, - GEANY_FILETYPE_GROUP_SCRIPT, - GEANY_FILETYPE_GROUP_MARKUP, - GEANY_FILETYPE_GROUP_MISC, + GEANY_FILETYPE_GROUP_OTHER, + GEANY_FILETYPE_GROUP_A_B, + GEANY_FILETYPE_GROUP_C, + GEANY_FILETYPE_GROUP_D_E_F, + GEANY_FILETYPE_GROUP_G_H_I, + GEANY_FILETYPE_GROUP_J_K_L, + GEANY_FILETYPE_GROUP_M_N_O, + GEANY_FILETYPE_GROUP_P_Q, + GEANY_FILETYPE_GROUP_R_S, + GEANY_FILETYPE_GROUP_T_U_V_W, + GEANY_FILETYPE_GROUP_X_Y_Z, GEANY_FILETYPE_GROUP_COUNT } GeanyFiletypeGroupID;
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).