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.
Merge branch '2.10'
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 Preferences.set ("theme", theme_file); 72 Theme.load_theme (theme_file); 73 74 Toolbox.redraw_tool_box (); 75 GlyphCanvas.redraw (); 76 77 file_tools.redraw (); 78 font_name.redraw (); 79 tb.redraw (0, 0, tb.width, tb.height); 80 81 foreach (ToolCollection tc in toolbox.tool_sets) { 82 tc.redraw (); 83 } 84 85 OverViewItem.label_background = null; 86 OverViewItem.selected_label_background = null; 87 OverViewItem.label_background_no_menu = null; 88 OverViewItem.selected_label_background_no_menu = null; 89 }); 90 91 if (!theme.has_prefix ("generated_")) { 92 themes.add_tool (theme_label); 93 } 94 } 95 96 expanders.add (font_name); 97 expanders.add (file_tools); 98 expanders.add (themes); 99 } 100 101 public override Gee.ArrayList<string> get_displays () { 102 Gee.ArrayList<string> d = new Gee.ArrayList<string> (); 103 return d; 104 } 105 106 public override Gee.ArrayList<Expander> get_expanders () { 107 return expanders; 108 } 109 } 110 111 } 112