Commit 5a3b8c9
Theme selection label in file tools
Changed files (3)
modifiedlibbirdfont/FileTools.valamodifiedlibbirdfont/LabelTool.valamodifiedlibbirdfont/ThemeTab.vala
Diff
@@ -51,9 +51,39 @@ public class FileTools : ToolCollection { MenuTab.show_settings_tab (); }); file_tools.add_tool (settings);+ + Expander themes = new Expander (t_("Themes"));++ foreach (string theme in Theme.themes) { + string label;+ LabelTool theme_label;+ + label = ThemeTab.get_label_from_file_name (theme);+ + theme_label = new LabelTool (label);+ theme_label.data = theme;+ + theme_label.select_action.connect((self) => {+ TabBar tb;+ LabelTool s = (LabelTool) self;+ string theme_file = s.data;++ Preferences.set ("theme", theme_file);+ Theme.load_theme (theme_file);++ Toolbox.redraw_tool_box ();+ GlyphCanvas.redraw (); + tb = MainWindow.get_tab_bar ();+ tb.redraw (0, 0, tb.width, tb.height);+ });+ + themes.add_tool (theme_label);+ }+ expanders.add (font_name); expanders.add (file_tools);+ expanders.add (themes); } public override Gee.ArrayList<string> get_displays () {@@ -23,6 +23,7 @@ public class LabelTool : Tool { public bool has_counter { get; set; } public bool has_delete_button { get; set; } public signal void delete_action (LabelTool self);+ public string data = ""; double counter_box_width = 24; double counter_box_height = 11;@@ -30,7 +30,7 @@ public class ThemeTab : SettingsDisplay { Gee.ArrayList<Tool> theme_buttons = new Gee.ArrayList<Tool> (); - foreach (string theme in Theme.themes) { + foreach (string theme in Theme.themes) { string label; Tool select_theme = new Tool (theme); @@ -62,17 +62,7 @@ public class ThemeTab : SettingsDisplay { select_theme.set_icon ("theme"); - if (theme == "dark.theme") {- label = t_("Dark theme");- } else if (theme == "bright.theme") {- label = t_("Bright theme");- } else if (theme == "high_contrast.theme") {- label = t_("High contrast theme");- } else if (theme == "custom.theme") {- label = t_("Custom theme");- } else {- label = theme.replace (".theme", "");- }+ label = get_label_from_file_name (theme); tools.add (new SettingsItem (select_theme, label)); theme_buttons.add (select_theme);@@ -113,6 +103,24 @@ public class ThemeTab : SettingsDisplay { } } + public static string get_label_from_file_name (string theme) {+ string label;+ + if (theme == "dark.theme") {+ label = t_("Dark");+ } else if (theme == "bright.theme") {+ label = t_("Bright");+ } else if (theme == "high_contrast.theme") {+ label = t_("High contrast");+ } else if (theme == "custom.theme") {+ label = t_("Custom");+ } else {+ label = theme.replace (".theme", "");+ }+ + return label;+ }+ public override string get_label () { return t_("Themes"); }