Commit f0b70ad
Use native image conversion on Mac OS X
Changed files (5)
modifiedbirdfont/GtkWindow.valamodifiedinstall.pymodifiedlibbirdfont/BackgroundSelection.valamodifiedlibbirdfont/GlyphBackgroundImage.valamodifiedlibbirdfont/NativeWindow.vala
Diff
@@ -20,6 +20,7 @@ using Gtk; using Gdk; using BirdFont; using WebKit;+using Pixbuf; namespace BirdFont { @@ -835,6 +836,20 @@ public class GtkWindow : Gtk.Window, NativeWindow { text_entry.grab_focus (); text_input_is_active = true; }+ + public bool convert_to_png (string from, string to) {+ Pixbuf pixbuf;+ + try {+ pixbuf = new Pixbuf.from_file (from);+ pixbuf.save (to, "png");+ } catch (GLib.Error e) {+ warning (e.message);+ return false;+ }+ + return true;+ } } class TabbarCanvas : DrawingArea {@@ -98,6 +98,7 @@ elif os.path.isfile ('build/libbirdfont.so.' + version.SO_VERSION): elif os.path.isfile ('build/bin/libbirdfont.' + version.SO_VERSION + '.dylib'): install ('build/bin/libbirdfont.' + version.SO_VERSION + '.dylib', libdir, 644) link (libdir, 'libbirdfont.' + version.SO_VERSION + '.dylib', ' libbirdfont.dylib.' + version.SO_VERSION_MAJOR)+ link (libdir, 'libbirdfont.' + version.SO_VERSION + '.dylib', ' libbirdfont.dylib') else: print ("Can not find libbirdfont.") exit (1)@@ -187,7 +187,7 @@ class BackgroundSelection : FontDisplay { return; } - file = background_images.nth (active_box - 1).data; // Fixa: check bounds+ file = background_images.nth (active_box - 1).data; bg = new GlyphBackgroundImage (file); tb = MainWindow.get_tab_bar (); @@ -57,7 +57,8 @@ public class GlyphBackgroundImage { public int size_margin { get { if (unlikely (size == -1)) {- size = (int) (Math.sqrt (Math.pow (get_img ().get_height (), 2) + Math.pow (get_img ().get_width (), 2)) + 0.5);+ size = (int) (Math.sqrt (Math.pow (get_img ().get_height (), 2) + + Math.pow (get_img ().get_width (), 2)) + 0.5); } return size;@@ -206,27 +207,31 @@ public class GlyphBackgroundImage { private void create_png () { #if !ANDROID- string fn = @"$path.png";- + string file_name = @"$path.png"; Font font = BirdFont.get_current_font (); File folder = font.get_backgrounds_folder ();- File original = File.new_for_path (fn);+ File original = File.new_for_path (file_name); File png_image = folder.get_child (@"full_$((!)original.get_basename ())");- Pixbuf pixbuf;+ bool converted; if (png_image.query_exists ()) { path = (!) png_image.get_path (); return; } - try {- pixbuf = new Pixbuf.from_file (path);- pixbuf.save ((!) png_image.get_path (), "png");- path = (!) png_image.get_path ();- } catch (GLib.Error e) {- warning (e.message);+ if (is_null (path)) {+ warning ("Background image path is null.");+ return; }+ + converted = MainWindow.native_window.convert_to_png (path, (!) png_image.get_path ());+ + if (!converted) {+ warning ("Failed to convert image: $(path)");+ }+ + path = (!) png_image.get_path (); #endif // FIXME: android@@ -48,6 +48,9 @@ public interface NativeWindow : GLib.Object { /** Exit the application. */ public abstract void quit ();++ /** Convert an image to PNG format. */+ public abstract bool convert_to_png (string from, string to); } }