The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

FileTools.vala in libbirdfont

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git

Revisions

View the latest version of libbirdfont/FileTools.vala.
Parse more style attributes in SVG files
1 /* 2 Copyright (C) 2015 Johan Mattsson 3 4 This library is free software; you can redistribute it and/or modify 5 it under the terms of the GNU Lesser General Public License as 6 published by the Free Software Foundation; either version 3 of the 7 License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, but 10 WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 */ 14 15 using Cairo; 16 using Math; 17 18 namespace BirdFont { 19 20 public class FileTools : ToolCollection { 21 public static Gee.ArrayList<Expander> expanders; 22 23 public FileTools () { 24 expanders = new Gee.ArrayList<Expander> (); 25 26 Expander font_name = new Expander (); 27 font_name.add_tool (new FontName ()); 28 29 Expander file_tools = new Expander (); 30 31 Tool new_font = new Tool ("new_font", t_("New font")); 32 new_font.select_action.connect ((self) => { 33 MenuTab.new_file (); 34 }); 35 file_tools.add_tool (new_font); 36 37 Tool open_font = new Tool ("open_font", t_("Open font")); 38 open_font.select_action.connect ((self) => { 39 MenuTab.load (); 40 }); 41 file_tools.add_tool (open_font); 42 43 Tool save_font = new Tool ("save_font", t_("Save font")); 44 save_font.select_action.connect ((self) => { 45 MenuTab.save (); 46 }); 47 file_tools.add_tool (save_font); 48 49 Tool settings = new Tool ("settings", t_("Settings")); 50 settings.select_action.connect ((self) => { 51 MenuTab.show_settings_tab (); 52 }); 53 file_tools.add_tool (settings); 54 55 Expander themes = new Expander (t_("Themes")); 56 57 foreach (string theme in Theme.themes) { 58 string label; 59 LabelTool theme_label; 60 61 label = ThemeTab.get_label_from_file_name (theme); 62 63 theme_label = new LabelTool (label); 64 theme_label.data = theme; 65 66 theme_label.select_action.connect((self) => { 67 LabelTool s = (LabelTool) self; 68 Toolbox toolbox = MainWindow.get_toolbox (); 69 string theme_file = s.data; 70 TabBar tb = MainWindow.get_tab_bar (); 71 72 Preferences.set ("theme", theme_file); 73 Theme.load_theme (theme_file); 74 75 Toolbox.redraw_tool_box (); 76 GlyphCanvas.redraw (); 77 78 file_tools.redraw (); 79 font_name.redraw (); 80 tb.redraw (0, 0, tb.width, tb.height); 81 82 foreach (ToolCollection tc in toolbox.tool_sets) { 83 tc.redraw (); 84 } 85 86 OverViewItem.label_background = null; 87 OverViewItem.selected_label_background = null; 88 OverViewItem.label_background_no_menu = null; 89 OverViewItem.selected_label_background_no_menu = null; 90 91 foreach (Tool t in themes.tool) { 92 t.set_selected (false); 93 } 94 95 self.set_selected (true); 96 }); 97 98 if (!theme.has_prefix ("generated_")) { 99 themes.add_tool (theme_label); 100 } 101 } 102 103 string theme_in_use = Preferences.get ("theme"); 104 foreach (Tool t in themes.tool) { 105 if (t is LabelTool) { 106 LabelTool lt = (LabelTool) t; 107 t.set_selected (theme_in_use == lt.data); 108 } 109 } 110 111 expanders.add (font_name); 112 expanders.add (file_tools); 113 expanders.add (themes); 114 } 115 116 public override Gee.ArrayList<string> get_displays () { 117 Gee.ArrayList<string> d = new Gee.ArrayList<string> (); 118 return d; 119 } 120 121 public override Gee.ArrayList<Expander> get_expanders () { 122 return expanders; 123 } 124 } 125 126 } 127