.
1 /*
2 Copyright (C) 2012, 2014 Johan Mattsson
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 using BirdFont;
19
20 public static int main (string[] arg) {
21 GtkWindow native_window;
22 MainWindow window;
23 string file;
24 BirdFont.BirdFont birdfont;
25
26 Icons.use_high_resolution (true);
27 birdfont = new BirdFont.BirdFont ();
28 birdfont.init (arg, null);
29 Gtk.init (ref arg);
30
31 window = new MainWindow ();
32 native_window = new GtkWindow ("birdfont");
33
34 window.set_native (native_window);
35 native_window.init ();
36
37 birdfont.load_font_from_command_line ();
38
39 load_ucd ();
40 Gtk.main ();
41
42 return 0;
43 }
44
45 /** Load descriptions from the unicode character database in a
46 * background thread.
47 */
48 void load_ucd () {
49 CharDatabaseParser db;
50 unowned Thread<CharDatabaseParser> db_thread;
51 Mutex database_mutex = new Mutex ();
52 Cond main_loop_idle = new Cond ();
53 bool in_idle = false;
54
55 try {
56 db = new CharDatabaseParser ();
57 db_thread = Thread.create<CharDatabaseParser> (db.load, false);
58
59 // wait until main loop is done
60 db.sync.connect (() => {
61 database_mutex.lock ();
62 IdleSource idle = new IdleSource ();
63 in_idle = false;
64
65 idle.set_callback (() => {
66 database_mutex.lock ();
67 in_idle = true;
68 main_loop_idle.broadcast ();
69 database_mutex.unlock ();
70 return false;
71 });
72 idle.attach (null);
73
74 while (!in_idle) {
75 main_loop_idle.wait (database_mutex);
76 }
77
78 database_mutex.unlock ();
79 });
80 } catch (GLib.Error e) {
81 warning (e.message);
82 }
83 }
84
85
86