Revision: 4048 http://geany.svn.sourceforge.net/geany/?rev=4048&view=rev Author: ntrel Date: 2009-07-30 12:38:10 +0000 (Thu, 30 Jul 2009)
Log Message: ----------- Add filetype_make_title() instead of using: ft->title = g_strdup_printf(_("%s source file"), ft->name); It also supports "%s file" strings.
Modified Paths: -------------- trunk/ChangeLog trunk/src/filetypes.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-07-30 11:56:25 UTC (rev 4047) +++ trunk/ChangeLog 2009-07-30 12:38:10 UTC (rev 4048) @@ -13,6 +13,10 @@ Add Markdown filetype (patch by Jon Strait, thanks). * src/pluginprivate.h, src/pluginutils.c, src/plugins.c: Fix disconnecting plugin signal id when not using geany_object. + * src/filetypes.c: + Add filetype_make_title() instead of using: + ft->title = g_strdup_printf(_("%s source file"), ft->name); + It also supports "%s file" strings.
2009-07-29 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/filetypes.c =================================================================== --- trunk/src/filetypes.c 2009-07-30 11:56:25 UTC (rev 4047) +++ trunk/src/filetypes.c 2009-07-30 12:38:10 UTC (rev 4048) @@ -79,6 +79,29 @@ static void create_radio_menu_item(GtkWidget *menu, GeanyFiletype *ftype);
+enum TitleType +{ + TITLE_SOURCE_FILE, + TITLE_FILE +}; + +/* Save adding many translation strings if the filetype name doesn't need translating */ +static void filetype_make_title(GeanyFiletype *ft, enum TitleType type) +{ + const gchar *fmt = NULL; + + switch (type) + { + default: + case TITLE_SOURCE_FILE: fmt = _("%s source file"); break; + case TITLE_FILE: fmt = _("%s file"); break; + } + g_assert(!ft->title); + g_assert(ft->name); + ft->title = g_strdup_printf(fmt, ft->name); +} + + /* Note: remember to update HACKING if this function is renamed. */ static void init_builtin_filetypes(void) { @@ -99,7 +122,7 @@ ft = filetypes[GEANY_FILETYPES_C]; ft->lang = 0; ft->name = g_strdup("C"); - ft->title = g_strdup_printf(_("%s source file"), "C"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("c"); ft->pattern = utils_strv_new("*.c", "*.h", NULL); ft->comment_open = g_strdup("/*"); @@ -110,7 +133,7 @@ ft = filetypes[GEANY_FILETYPES_CPP]; ft->lang = 1; ft->name = g_strdup("C++"); - ft->title = g_strdup_printf(_("%s source file"), "C++"); + filetype_make_title(ft, TITLE_FILE); ft->extension = g_strdup("cpp"); ft->pattern = utils_strv_new("*.cpp", "*.cxx", "*.c++", "*.cc", "*.h", "*.hpp", "*.hxx", "*.h++", "*.hh", "*.C", NULL); @@ -122,7 +145,7 @@ ft = filetypes[GEANY_FILETYPES_CS]; ft->lang = 25; ft->name = g_strdup("C#"); - ft->title = g_strdup_printf(_("%s source file"), "C#"); + filetype_make_title(ft, TITLE_FILE); ft->extension = g_strdup("cs"); ft->pattern = utils_strv_new("*.cs", NULL); ft->comment_open = g_strdup("//"); @@ -133,7 +156,7 @@ ft = filetypes[GEANY_FILETYPES_VALA]; ft->lang = 33; ft->name = g_strdup("Vala"); - ft->title = g_strdup_printf(_("%s source file"), "Vala"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("vala"); ft->pattern = utils_strv_new("*.vala", "*.vapi", NULL); ft->comment_open = g_strdup("//"); @@ -144,7 +167,7 @@ ft = filetypes[GEANY_FILETYPES_D]; ft->lang = 17; ft->name = g_strdup("D"); - ft->title = g_strdup_printf(_("%s source file"), "D"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("d"); ft->pattern = utils_strv_new("*.d", "*.di", NULL); ft->comment_open = g_strdup("//"); @@ -155,7 +178,7 @@ ft = filetypes[GEANY_FILETYPES_JAVA]; ft->lang = 2; ft->name = g_strdup("Java"); - ft->title = g_strdup_printf(_("%s source file"), "Java"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("java"); ft->pattern = utils_strv_new("*.java", "*.jsp", NULL); ft->comment_open = g_strdup("/*"); @@ -166,7 +189,7 @@ ft = filetypes[GEANY_FILETYPES_PASCAL]; ft->lang = 4; ft->name = g_strdup("Pascal"); - ft->title = g_strdup_printf(_("%s source file"), "Pascal"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("pas"); ft->pattern = utils_strv_new("*.pas", "*.pp", "*.inc", "*.dpr", "*.dpk", NULL); @@ -189,7 +212,7 @@ ft = filetypes[GEANY_FILETYPES_BASIC]; ft->lang = 26; ft->name = g_strdup("FreeBasic"); - ft->title = g_strdup_printf(_("%s source file"), "FreeBasic"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("bas"); ft->pattern = utils_strv_new("*.bas", "*.bi", NULL); ft->comment_open = g_strdup("'"); @@ -222,7 +245,7 @@ ft = filetypes[GEANY_FILETYPES_GLSL]; ft->lang = 31; ft->name = g_strdup("GLSL"); - ft->title = g_strdup_printf(_("%s source file"), "GLSL"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("glsl"); ft->pattern = utils_strv_new("*.glsl", "*.frag", "*.vert", NULL); ft->comment_open = g_strdup("/*"); @@ -244,7 +267,7 @@ ft = filetypes[GEANY_FILETYPES_PERL]; ft->lang = 5; ft->name = g_strdup("Perl"); - ft->title = g_strdup_printf(_("%s source file"), "Perl"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("pl"); ft->pattern = utils_strv_new("*.pl", "*.perl", "*.pm", "*.agi", "*.pod", NULL); @@ -256,7 +279,7 @@ ft = filetypes[GEANY_FILETYPES_PHP]; ft->lang = 6; ft->name = g_strdup("PHP"); - ft->title = g_strdup_printf(_("%s source file"), "PHP"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("php"); ft->pattern = utils_strv_new("*.php", "*.php3", "*.php4", "*.php5", "*.phtml", NULL); @@ -268,7 +291,7 @@ ft = filetypes[GEANY_FILETYPES_JS]; ft->lang = 23; ft->name = g_strdup("Javascript"); - ft->title = g_strdup_printf(_("%s source file"), "Javascript"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("js"); ft->pattern = utils_strv_new("*.js", NULL); ft->comment_open = g_strdup("//"); @@ -279,7 +302,7 @@ ft = filetypes[GEANY_FILETYPES_PYTHON]; ft->lang = 7; ft->name = g_strdup("Python"); - ft->title = g_strdup_printf(_("%s source file"), "Python"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("py"); ft->pattern = utils_strv_new("*.py", "*.pyw", NULL); ft->comment_open = g_strdup("#"); @@ -290,7 +313,7 @@ ft = filetypes[GEANY_FILETYPES_RUBY]; ft->lang = 14; ft->name = g_strdup("Ruby"); - ft->title = g_strdup_printf(_("%s source file"), "Ruby"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("rb"); ft->pattern = utils_strv_new("*.rb", "*.rhtml", "*.ruby", NULL); ft->comment_open = g_strdup("#"); @@ -301,7 +324,7 @@ ft = filetypes[GEANY_FILETYPES_TCL]; ft->lang = 15; ft->name = g_strdup("Tcl"); - ft->title = g_strdup_printf(_("%s source file"), "Tcl"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("tcl"); ft->pattern = utils_strv_new("*.tcl", "*.tk", "*.wish", NULL); ft->comment_open = g_strdup("#"); @@ -312,7 +335,7 @@ ft = filetypes[GEANY_FILETYPES_LUA]; ft->lang = 22; ft->name = g_strdup("Lua"); - ft->title = g_strdup_printf(_("%s source file"), "Lua"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("lua"); ft->pattern = utils_strv_new("*.lua", NULL); ft->comment_open = g_strdup("--"); @@ -323,7 +346,7 @@ ft = filetypes[GEANY_FILETYPES_FERITE]; ft->lang = 19; ft->name = g_strdup("Ferite"); - ft->title = g_strdup_printf(_("%s source file"), "Ferite"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("fe"); ft->pattern = utils_strv_new("*.fe", NULL); ft->comment_open = g_strdup("/*"); @@ -334,7 +357,7 @@ ft = filetypes[GEANY_FILETYPES_HASKELL]; ft->lang = 24; ft->name = g_strdup("Haskell"); - ft->title = g_strdup_printf(_("%s source file"), "Haskell"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("hs"); ft->pattern = utils_strv_new("*.hs", "*.lhs", NULL); ft->comment_open = g_strdup("--"); @@ -345,7 +368,7 @@ ft = filetypes[GEANY_FILETYPES_MARKDOWN]; ft->lang = 36; ft->name = g_strdup("Markdown"); - ft->title = g_strdup_printf(_("%s source file"), "Markdown"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("md"); ft->pattern = utils_strv_new("*.mdml", "*.mdwn", "*.markdown", "*.md", NULL); ft->comment_open = NULL; @@ -392,7 +415,7 @@ ft = filetypes[GEANY_FILETYPES_DOCBOOK]; ft->lang = 12; ft->name = g_strdup("Docbook"); - ft->title = g_strdup_printf(_("%s source file"), "Docbook"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("docbook"); ft->pattern = utils_strv_new("*.docbook", NULL); ft->comment_open = g_strdup("<!--"); @@ -403,7 +426,7 @@ ft = filetypes[GEANY_FILETYPES_HTML]; ft->lang = 29; ft->name = g_strdup("HTML"); - ft->title = g_strdup_printf(_("%s source file"), "HTML"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("html"); ft->pattern = utils_strv_new( "*.htm", "*.html", "*.shtml", "*.hta", "*.htd", "*.htt", "*.cfm", NULL); @@ -437,7 +460,7 @@ ft = filetypes[GEANY_FILETYPES_LATEX]; ft->lang = 8; ft->name = g_strdup("LaTeX"); - ft->title = g_strdup_printf(_("%s source file"), "LaTeX"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("tex"); ft->pattern = utils_strv_new("*.tex", "*.sty", "*.idx", "*.ltx", NULL); ft->comment_open = g_strdup("%"); @@ -448,7 +471,7 @@ ft = filetypes[GEANY_FILETYPES_VHDL]; ft->lang = 21; ft->name = g_strdup("VHDL"); - ft->title = g_strdup_printf(_("%s source file"), "VHDL"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("vhd"); ft->pattern = utils_strv_new("*.vhd", "*.vhdl", NULL); ft->comment_open = g_strdup("--"); @@ -459,7 +482,7 @@ ft = filetypes[GEANY_FILETYPES_DIFF]; ft->lang = 20; ft->name = g_strdup("Diff"); - ft->title = g_strdup(_("Diff file")); + filetype_make_title(ft, TITLE_FILE); ft->extension = g_strdup("diff"); ft->pattern = utils_strv_new("*.diff", "*.patch", "*.rej", NULL); ft->comment_open = g_strdup("#"); @@ -493,7 +516,7 @@ ft = filetypes[GEANY_FILETYPES_HAXE]; ft->lang = 27; ft->name = g_strdup("Haxe"); - ft->title = g_strdup_printf(_("%s source file"), "Haxe"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("hx"); ft->pattern = utils_strv_new("*.hx", NULL); ft->comment_open = g_strdup("//"); @@ -504,7 +527,7 @@ ft = filetypes[GEANY_FILETYPES_AS]; ft->lang = 34; ft->name = g_strdup("ActionScript"); - ft->title = g_strdup_printf(_("%s source file"), "Actionscript"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("as"); ft->pattern = utils_strv_new("*.as", NULL); ft->comment_open = g_strdup("//"); @@ -526,7 +549,7 @@ ft = filetypes[GEANY_FILETYPES_REST]; ft->lang = 28; ft->name = g_strdup("reStructuredText"); - ft->title = g_strdup(_("reStructuredText file")); + filetype_make_title(ft, TITLE_FILE); ft->extension = g_strdup("rst"); ft->pattern = utils_strv_new( "*.rest", "*.reST", "*.rst", NULL); @@ -538,7 +561,7 @@ ft = filetypes[GEANY_FILETYPES_MATLAB]; ft->lang = 32; ft->name = g_strdup("Matlab"); - ft->title = g_strdup_printf(_("%s source file"), "Matlab"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("m"); ft->pattern = utils_strv_new("*.m", NULL); ft->comment_open = g_strdup("%"); @@ -549,7 +572,7 @@ ft = filetypes[GEANY_FILETYPES_YAML]; ft->lang = -2; ft->name = g_strdup("YAML"); - ft->title = g_strdup_printf(_("%s source file"), "YAML"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("yaml"); ft->pattern = utils_strv_new("*.yaml", "*.yml", NULL); ft->comment_open = g_strdup("#"); @@ -560,7 +583,7 @@ ft = filetypes[GEANY_FILETYPES_CMAKE]; ft->lang = -2; ft->name = g_strdup("CMake"); - ft->title = g_strdup_printf(_("%s source file"), "CMake"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("cmake"); ft->pattern = utils_strv_new("CMakeLists.txt", "*.cmake", "*.ctest", NULL); ft->comment_open = g_strdup("#"); @@ -571,7 +594,7 @@ ft = filetypes[GEANY_FILETYPES_NSIS]; ft->lang = 35; ft->name = g_strdup("NSIS"); - ft->title = g_strdup_printf(_("%s source file"), "NSIS"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("nsis"); ft->pattern = utils_strv_new("*.nsi", "*.nsh", NULL); ft->comment_open = g_strdup(";"); @@ -582,7 +605,7 @@ ft = filetypes[GEANY_FILETYPES_ADA]; ft->lang = -2; ft->name = g_strdup("Ada"); - ft->title = g_strdup_printf(_("%s source file"), "Ada"); + filetype_make_title(ft, TITLE_SOURCE_FILE); ft->extension = g_strdup("adb"); ft->pattern = utils_strv_new("*.adb", "*.ads", NULL); ft->comment_open = g_strdup("--");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.