Commit 53a8f4f
spawn native threads spawning threads in libbirdfont was a bad idea
Changed files (5)
modifiedbirdfont/GtkWindow.valamodifiedlibbirdfont/CharDatabase.valamodifiedlibbirdfont/CharDatabaseParser.valaaddedlibbirdfont/EmptyTab.valamodifiedlibbirdfont/TabBar.vala
Diff
@@ -568,7 +568,7 @@ public class GtkWindow : Gtk.Window, NativeWindow { MainWindow.get_current_glyph ().select_all_paths (); }); - Gtk.MenuItem search_item = new Gtk.MenuItem.with_mnemonic (_("Search"));+ Gtk.MenuItem search_item = new Gtk.MenuItem.with_mnemonic (_("_Search")); edit_menu.append (search_item); search_item.activate.connect (() => { OverView.search (); }); search_item.add_accelerator ("activate", accel_group, 'F', Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE);@@ -29,8 +29,6 @@ public class CharDatabase { index = new HashMultiMap<string, string> (); full_unicode_range = new GlyphRange ();- - CharDatabaseParser.run (); } public static GlyphRange search (string s) {@@ -16,35 +16,13 @@ using Gee; namespace BirdFont { -class CharDatabaseParser : GLib.Object {- - MainContext? context;+public class CharDatabaseParser : GLib.Object {++ signal void sync (); - public CharDatabaseParser (MainContext? c) { - context = c;- - if (context == null) {- warning ("No main context set.");- }+ public CharDatabaseParser () { } - public static void run () {- CharDatabaseParser thread_data;- thread_data = new CharDatabaseParser (MainContext.default ());- - if (!Thread.supported ()) {- warning ("Threads not supported, this might take a while.");- thread_data.load ();- } else {- try {- //new Thread<int> ("database parser", thread_data.load);- Thread<int>.create<int> (thread_data.load, false);- } catch (GLib.Error e) {- warning (e.message);- }- }- }- private void add_entry (string data) { string[] e; string[] r;@@ -52,8 +30,7 @@ class CharDatabaseParser : GLib.Object { string index_values; unichar ch; string unicode_hex;- Mutex mutex = new Mutex (); // wait for callback to finish- + if (data.has_prefix ("@")) { // ignore comments return; }@@ -79,26 +56,24 @@ class CharDatabaseParser : GLib.Object { ch = Font.to_unichar ("U+" + unicode_hex.down ()); - mutex.lock (); Idle.add (() => { CharDatabase.full_unicode_range.add_single (ch); CharDatabase.entries.set (unicode_hex, data);- mutex.unlock (); return false; });-+ sync ();+ foreach (string s in e) { r = s.split ("\n"); foreach (string t in r) { d = t.split (" "); foreach (string token in d) { if (token != "") {- mutex.lock (); Idle.add (() => { CharDatabase.index.set (token, unicode_hex);- mutex.unlock (); return false; });+ sync (); } } }new file mode 100644@@ -0,0 +1,38 @@+/*+ Copyright (C) 2013 Johan Mattsson++ This library is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version.++ This library is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details.+*/++using Cairo;++namespace BirdFont {++public class EmptyTab : FontDisplay {+ + string name;+ string label;+ + public EmptyTab (string name, string label) {+ this.name = name;+ this.label = label;+ }+ + public override string get_name () {+ return name;+ }++ public override string get_label () {+ return label;+ }+}++}\ No newline at end of file@@ -586,6 +586,10 @@ public class TabBar : GLib.Object { i++; } }+ + public void add_empty_tab (string name, string label) {+ add_tab (new EmptyTab (name, label));+ } } }