+
+ build_theme_menu: function () {
+ var application = this.application;
+
+ var theme_switcher = function (menuitem) {
+ var theme_name = menuitem.theme_name;
+ Gilbert.api.plugins.auth.set_preference('gilbert.theme', theme_name, function () {
+ application._set_theme(theme_name);
+ application.do_layout();
+ application.windows.each(function (win) {
+ win.doLayout();
+ });
+ });
+ };
+
+ var menu = [];
+
+ Ext.each(document.getElementsByClassName('gilbert.theme'), function (theme_element) {
+ var theme_id = theme_element.id;
+ var theme_name = theme_id.match(/gilbert.theme.(.*)/)[1];
+ var current_theme = false;
+ if (!theme_element.disabled) {
+ current_theme = true;
+ }
+
+
+ menu.push({
+ text: theme_name.capfirst(),
+ checked: current_theme,
+ group: 'theme',
+ theme_name: theme_name,
+ handler: theme_switcher,
+ });
+ });
+
+ return menu;
+ },
+