.
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 ExportSettings : TableLayout {
21 TextArea file_name;
22 CheckBox ttf;
23 CheckBox eot;
24 CheckBox svg;
25 Button export_action;
26 Button name_tab;
27
28 public ExportSettings () {
29 Headline headline;
30 Font font;
31 double margin = 12 * MainWindow.units;
32 double label_size = 20 * MainWindow.units;
33 double label_margin = 4 * MainWindow.units;
34 string fn;
35
36 font = BirdFont.get_current_font ();
37 font.settings.set_setting ("has_export_settings", "true");
38
39 headline = new Headline (t_("Export Settings"));
40 headline.margin_bottom = 20 * MainWindow.units;
41 widgets.add (headline);
42
43 widgets.add (new Text (t_("File Name"), label_size, label_margin));
44
45 file_name = new LineTextArea (label_size);
46 file_name.margin_bottom = margin;
47
48 fn = get_file_name (font);
49 file_name.set_text (fn);
50 file_name.text_changed.connect ((t) => {
51 Font f = BirdFont.get_current_font ();
52 f.settings.set_setting ("file_name", t);
53 });
54
55 widgets.add (file_name);
56 focus_ring.add (file_name);
57
58 widgets.add (new Text (t_("Formats"), label_size, label_margin));
59
60 ttf = new CheckBox ("TTF", label_size);
61 ttf.updated.connect ((c) => {
62 Font f = BirdFont.get_current_font ();
63 string v = c ? "true" : "false";
64 f.settings.set_setting ("export_ttf", v);
65 });
66 ttf.checked = export_ttf_setting (font);
67 widgets.add (ttf);
68 focus_ring.add (ttf);
69
70 eot = new CheckBox ("EOT", label_size);
71 eot.updated.connect ((c) => {
72 Font f = BirdFont.get_current_font ();
73 string v = c ? "true" : "false";
74 f.settings.set_setting ("export_eot", v);
75 });
76 eot.checked = export_eot_setting (font);
77 widgets.add (eot);
78 focus_ring.add (eot);
79
80 svg = new CheckBox ("SVG", label_size);
81 svg.updated.connect ((c) => {
82 Font f = BirdFont.get_current_font ();
83 string v = c ? "true" : "false";
84 f.settings.set_setting ("export_eot", v);
85 });
86 svg.checked = export_svg_setting (font);
87 svg.margin_bottom = margin;
88 widgets.add (svg);
89 focus_ring.add (svg);
90
91 name_tab = new Button (t_("Name and Description"), margin);
92 name_tab.action.connect ((c) => {
93 MenuTab.show_description ();
94 });
95 widgets.add (name_tab);
96
97 export_action = new Button (t_("Export"), margin);
98 export_action.action.connect ((c) => {
99 MenuTab.export_fonts_in_background ();
100 });
101 widgets.add (export_action);
102
103 set_focus (file_name);
104 }
105
106 public static string get_file_name (Font font) {
107 string n = font.settings.get_setting ("file_name");
108
109 if (n == "") {
110 n = font.full_name;
111 }
112
113 return n;
114 }
115
116 public static bool export_ttf_setting (Font f) {
117 return f.settings.get_setting ("export_ttf") != "false";
118 }
119
120 public static bool export_eot_setting (Font f) {
121 return f.settings.get_setting ("export_eot") != "false";
122 }
123
124 public static bool export_svg_setting (Font f) {
125 return f.settings.get_setting ("export_svg") != "false";
126 }
127
128 public static bool has_export_settings (Font f) {
129 return f.settings.get_setting ("has_export_settings") == "true";
130 }
131
132 public override string get_label () {
133 return t_("Export Settings");
134 }
135
136 public override string get_name () {
137 return "Export Settings";
138 }
139 }
140
141 }
142