.
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 TabBar tb;
68 LabelTool s = (LabelTool) self;
69 string theme_file = s.data;
70
71 Preferences.set ("theme", theme_file);
72 Theme.load_theme (theme_file);
73
74 Toolbox.redraw_tool_box ();
75 GlyphCanvas.redraw ();
76
77 tb = MainWindow.get_tab_bar ();
78 tb.redraw (0, 0, tb.width, tb.height);
79 });
80
81 if (!theme.has_prefix ("generated_")) {
82 themes.add_tool (theme_label);
83 }
84 }
85
86 expanders.add (font_name);
87 expanders.add (file_tools);
88 expanders.add (themes);
89 }
90
91 public override Gee.ArrayList<string> get_displays () {
92 Gee.ArrayList<string> d = new Gee.ArrayList<string> ();
93 return d;
94 }
95
96 public override Gee.ArrayList<Expander> get_expanders () {
97 return expanders;
98 }
99 }
100
101 }
102