The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Theme selection label in file tools

These changes was commited to the Birdfont repository Fri, 24 Apr 2015 09:12:14 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Fri, 24 Apr 2015 09:12:14 +0000]

Updated Files

libbirdfont/FileTools.vala
libbirdfont/LabelTool.vala
libbirdfont/ThemeTab.vala
--- a/libbirdfont/FileTools.vala +++ b/libbirdfont/FileTools.vala @@ -51,9 +51,39 @@ 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 () {
--- a/libbirdfont/LabelTool.vala +++ b/libbirdfont/LabelTool.vala @@ -23,6 +23,7 @@ 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;
--- a/libbirdfont/ThemeTab.vala +++ b/libbirdfont/ThemeTab.vala @@ -30,7 +30,7 @@ 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 @@ 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); @@ -111,6 +101,24 @@ GlyphCanvas.redraw (); }); } + } + + 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 () {