Commit e056293
Set default license
Changed files (6)
modifiedlibbirdfont/DescriptionDisplay.valamodifiedlibbirdfont/Font.valamodifiedlibbirdfont/MenuTab.valamodifiedlibbirdfont/PenTool.valamodifiedlibbirdfont/Renderer/Text.valamodifiedlibbirdfont/Renderer/TextArea.vala
Diff
@@ -39,6 +39,8 @@ public class DescriptionDisplay : FontDisplay { Gee.ArrayList<Widget> widgets; + private static bool disable_copyright = false;+ public DescriptionDisplay () { double margin = 12 * MainWindow.units; double label_size = 20 * MainWindow.units;@@ -151,9 +153,14 @@ public class DescriptionDisplay : FontDisplay { copyright.text_changed.connect ((t) => { font.copyright = t; });+ copyright.set_editable (!disable_copyright); widgets.add (copyright); } + public static void set_copyright_editable (bool t) {+ disable_copyright = !t;+ }+ public override void draw (WidgetAllocation allocation, Context cr) { this.allocation = allocation; @@ -302,6 +309,7 @@ public class DescriptionDisplay : FontDisplay { } public override void selected_canvas () {+ copyright.set_editable (!disable_copyright); update_scrollbar (); GlyphCanvas.redraw (); }@@ -96,6 +96,8 @@ public class Font : GLib.Object { Ligatures ligatures_substitution; + public static string? default_license = null; + public Font () { KerningClasses kerning_classes; @@ -106,7 +108,7 @@ public class Font : GLib.Object { unique_identifier = "Typeface"; version = "Version 1.0"; description = "";- copyright = "";+ copyright = default_license != null ? ((!) default_license).dup () : ""; glyph_cache = new GlyphTable (); glyph_name = new GlyphTable ();@@ -132,6 +134,10 @@ public class Font : GLib.Object { background_images = new Gee.ArrayList<BackgroundImage> (); } + public static void set_default_license (string license) {+ default_license = license;+ }+ public Ligatures get_ligatures () { return ligatures_substitution; }@@ -78,8 +78,7 @@ public class MenuTab : FontDisplay { public static void export_fonts_in_background () { if (suppress_event || MainWindow.native_window.can_export ()) {- warning ("suppress_event is already set");- return false;+ return; } MenuTab.export_callback = new ExportCallback ();@@ -223,6 +223,8 @@ public class PenTool : Tool { last_point_y = selected_point.y; } }+ + GlyphCanvas.redraw (); }); key_release_action.connect ((self, keyval) => {@@ -22,7 +22,7 @@ public class Text : Widget { public Font font { get { if (current_font == null) {- load_default_font ();+ current_font = get_default_font (); } return (!) current_font;@@ -68,11 +68,15 @@ public class Text : Widget { } public static void load_default_font () {- File path = SearchPaths.find_file (null, "roboto.bf");- if (FontCache.get_default_cache ().get_font ((!) path.get_path ()) == null) {+ if (get_default_font () == null) { warning ("Default font not found."); } }+ + public static Font? get_default_font () {+ File path = SearchPaths.find_file (null, "roboto.bf");+ return FontCache.get_default_cache ().get_font ((!) path.get_path ());+ } public void set_font_size (double height_in_pixels) { font_size = height_in_pixels;@@ -62,11 +62,13 @@ public class TextArea : Widget { Gee.ArrayList<TextUndoItem> redo_items = new Gee.ArrayList<TextUndoItem> (); bool store_undo_state_at_next_event = false;+ bool editable; public TextArea (double font_size = 20) { this.font_size = font_size; width = min_width; height = min_height;+ editable = true; } public override double get_height () {@@ -114,7 +116,11 @@ public class TextArea : Widget { public void key_press (uint keyval) { unichar c; TextUndoItem ui;- + + if (!editable) {+ return;+ }+ c = (unichar) keyval; switch (c) {@@ -1383,6 +1389,10 @@ public class TextArea : Widget { } } + public void set_editable (bool editable) {+ this.editable = editable;+ }+ public class TextUndoItem : GLib.Object { public Carret carret; public Gee.ArrayList<Paragraph> added = new Gee.ArrayList<Paragraph> ();