SF.net SVN: geany:[5366] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Thu Nov 4 18:06:09 UTC 2010


Revision: 5366
          http://geany.svn.sourceforge.net/geany/?rev=5366&view=rev
Author:   ntrel
Date:     2010-11-04 18:06:09 +0000 (Thu, 04 Nov 2010)

Log Message:
-----------
Add filetypes_get_display_name() to get translations for filetype
None.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/document.c
    trunk/src/filetypes.c
    trunk/src/filetypes.h
    trunk/src/symbols.c
    trunk/src/ui_utils.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2010-11-04 16:45:47 UTC (rev 5365)
+++ trunk/ChangeLog	2010-11-04 18:06:09 UTC (rev 5366)
@@ -4,7 +4,11 @@
    Do not translate 'name' field for filetype None because it is used
    for hash table lookup. This fixes missing files in the Open dialog
    for the 'All files' filter with non-English locales (thanks to Sardem
-   FF7).
+   FF7, fixes #3094771).
+ * src/filetypes.c, src/filetypes.h, src/document.c, src/symbols.c,
+   src/ui_utils.c:
+   Add filetypes_get_display_name() to get translations for filetype
+   None.
 
 
 2010-11-02  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2010-11-04 16:45:47 UTC (rev 5365)
+++ trunk/src/document.c	2010-11-04 18:06:09 UTC (rev 5366)
@@ -2526,7 +2526,7 @@
 	old_ft = doc->file_type;
 	geany_debug("%s : %s (%s)",
 		(doc->file_name != NULL) ? doc->file_name : "unknown",
-		(type->name != NULL) ? type->name : "unknown",
+		type->name,
 		(doc->encoding != NULL) ? doc->encoding : "unknown");
 
 	ft_changed = (doc->file_type != type); /* filetype has changed */

Modified: trunk/src/filetypes.c
===================================================================
--- trunk/src/filetypes.c	2010-11-04 16:45:47 UTC (rev 5365)
+++ trunk/src/filetypes.c	2010-11-04 18:06:09 UTC (rev 5366)
@@ -93,7 +93,8 @@
 
 #define NONE	/* these macros are only to ease navigation */
 	ft = filetypes[GEANY_FILETYPES_NONE];
-	/* ft->name must not be translated as it is used for filetype lookup */
+	/* ft->name must not be translated as it is used for filetype lookup.
+	 * Use filetypes_get_display_name() instead. */
 	ft->name = g_strdup("None");
 	ft->title = g_strdup(_("None"));
 	ft->group = GEANY_FILETYPE_GROUP_NONE;
@@ -1359,7 +1360,7 @@
 		gchar buf[256];
 		regerror(retval, regex, buf, sizeof buf);
 		ui_set_statusbar(TRUE, _("Bad regex for filetype %s: %s"),
-			ft->name, buf);
+			filetypes_get_display_name(ft), buf);
 	}
 	/* regex will be freed in set_error_regex(). */
 }
@@ -1541,3 +1542,12 @@
 }
 
 
+/** Gets @c ft->name or a translation for filetype None.
+ * @param ft .
+ * @return .
+ * @since Geany 0.20 */
+const gchar *filetypes_get_display_name(GeanyFiletype *ft)
+{
+	return ft->id == GEANY_FILETYPES_NONE ? _("None") : ft->name;
+}
+

Modified: trunk/src/filetypes.h
===================================================================
--- trunk/src/filetypes.h	2010-11-04 16:45:47 UTC (rev 5365)
+++ trunk/src/filetypes.h	2010-11-04 18:06:09 UTC (rev 5366)
@@ -118,8 +118,12 @@
 	/** Represents the langType of tagmanager (see the table
 	 * in tagmanager/parsers.h), -1 represents all, -2 none. */
 	langType 		  lang;
-	gchar			 *name;				/**< Short name, e.g. "C". */
-	gchar			 *title;			/**< Shown in the file open dialog. E.g. "C source file". */
+	/** Untranslated short name, such as "C", "None".
+	 * Must not be translated as it's used for hash table lookups - use
+	 * filetypes_get_display_name() instead. */
+	gchar			 *name;
+	/** Shown in the file open dialog, such as "C source file". */
+	gchar			 *title;
 	gchar			 *extension;		/**< Default file extension for new files, or @c NULL. */
 	gchar			**pattern;			/**< Array of filename-matching wildcard strings. */
 	gchar			 *context_action_cmd;
@@ -176,6 +180,8 @@
 
 GeanyFiletype *filetypes_index(gint idx);
 
+const gchar *filetypes_get_display_name(GeanyFiletype *ft);
+
 GeanyFiletype *filetypes_detect_from_document(GeanyDocument *doc);
 
 GeanyFiletype *filetypes_detect_from_extension(const gchar *utf8_filename);

Modified: trunk/src/symbols.c
===================================================================
--- trunk/src/symbols.c	2010-11-04 16:45:47 UTC (rev 5365)
+++ trunk/src/symbols.c	2010-11-04 18:06:09 UTC (rev 5366)
@@ -1441,7 +1441,8 @@
 
 			if (ft != NULL && symbols_load_global_tags(fname, ft))
 				/* For translators: the first wildcard is the filetype, the second the filename */
-				ui_set_statusbar(TRUE, _("Loaded %s tags file '%s'."), ft->name, utf8_fname);
+				ui_set_statusbar(TRUE, _("Loaded %s tags file '%s'."),
+					filetypes_get_display_name(ft), utf8_fname);
 			else
 				ui_set_statusbar(TRUE, _("Could not load tags file '%s'."), utf8_fname);
 

Modified: trunk/src/ui_utils.c
===================================================================
--- trunk/src/ui_utils.c	2010-11-04 16:45:47 UTC (rev 5365)
+++ trunk/src/ui_utils.c	2010-11-04 18:06:09 UTC (rev 5366)
@@ -249,7 +249,7 @@
 				}
 				break;
 			case 'f':
-				g_string_append(stats_str, doc->file_type->name);
+				g_string_append(stats_str, filetypes_get_display_name(doc->file_type));
 				break;
 			case 'S':
 				symbols_get_current_function(doc, &cur_tag);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list