# HG changeset patch # User IBBoard # Date 1291237056 0 # Node ID a9c60e6c4b5b66a736679cd4b6c70ea4d0c296d5 # Parent c9aeaeaa3ea2d9ae574f97a176967ad34aae561a Re #47: Add translatable GTK# widgets * Simplify ControlTranslator and avoid infinite loops that cause unlogged crashes. diff -r c9aeaeaa3ea2 -r a9c60e6c4b5b Translatable/ControlTranslator.cs --- a/Translatable/ControlTranslator.cs Tue Nov 23 21:01:28 2010 +0000 +++ b/Translatable/ControlTranslator.cs Wed Dec 01 20:57:36 2010 +0000 @@ -16,32 +16,28 @@ { public static void TranslateWidget(Widget toTranslate) { + TranslateWidget(toTranslate, true); + } + + public static void TranslateWidget(Widget toTranslate, bool cascade) + { if (toTranslate is ITranslatable) { Translation.Translate((ITranslatable)toTranslate); } - } - - public static void TranslateWidget(Widget toTranslate, bool cascade) - { - TranslateWidget(toTranslate); + + if (cascade && toTranslate is Container) + { + CascadeTranslations((Container)toTranslate, cascade); + } } - public static void TranslateWidget(Container toTranslate) - { - TranslateWidget(toTranslate, true); - } - - public static void TranslateWidget(Container toTranslate, bool cascade) + private static void CascadeTranslations(Container container, bool cascade) { - TranslateWidget(toTranslate); - - if (cascade) + foreach (Widget childWidget in container.AllChildren) { - foreach (Widget childWidget in toTranslate.AllChildren) - { - TranslateWidget(childWidget, cascade); - } + System.Console.WriteLine(childWidget); + TranslateWidget(childWidget, cascade); } }