[gnome-boxes] express,winxp,fedora: Setup user's avatar



commit 2c3ba934f3f70e9a8d76cc6e0f63a5114732ea12
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed May 23 04:43:19 2012 +0300

    express,winxp,fedora: Setup user's avatar
    
    We show the user's avatar in the express install setup as if it'll be
    used so its very disapointing for user when its not. This patch fixes
    that for Windows XP and Fedora.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=676834

 data/fedora.ks                    |   12 ++
 data/winxp.cmd                    |    1 +
 src/fedora-installer.vala         |    3 +-
 src/unattended-installer.vala     |  114 ++++++++++++++---
 src/util.vala                     |   39 ++++++
 src/vm-creator.vala               |    3 +-
 src/winxp-installer.vala          |    7 +-
 vapi/upstream/Makefile.am         |    2 +
 vapi/upstream/gdk-pixbuf-2.0.deps |    1 +
 vapi/upstream/gdk-pixbuf-2.0.vapi |  242 +++++++++++++++++++++++++++++++++++++
 10 files changed, 398 insertions(+), 26 deletions(-)
---
diff --git a/data/fedora.ks b/data/fedora.ks
index f23b7bc..a2f7ccd 100644
--- a/data/fedora.ks
+++ b/data/fedora.ks
@@ -45,6 +45,18 @@ spice-vdagent
 # Add user to admin group
 usermod -a -G wheel BOXES_USERNAME
 
+# Set user avatar
+mkdir /mnt/unattended-media
+mount /dev/sda /mnt/unattended-media
+cp /mnt/unattended-media/BOXES_USERNAME /var/lib/AccountsService/icons/
+umount /mnt/unattended-media
+echo "
+[User]
+Language=
+XSession=
+Icon=/var/lib/AccountsService/icons/BOXES_USERNAME
+" >> /var/lib/AccountsService/users/BOXES_USERNAME
+
 # Enable autologin
 echo "[daemon]
 AutomaticLoginEnable=true
diff --git a/data/winxp.cmd b/data/winxp.cmd
index 004de19..d1f5c54 100644
--- a/data/winxp.cmd
+++ b/data/winxp.cmd
@@ -2,5 +2,6 @@ sc config TlntSvr start= auto
 net user BOXES_USERNAME BOXES_PASSWORD /add /passwordreq:no
 net localgroup administrators BOXES_USERNAME /add
 net accounts /maxpwage:unlimited
+copy a:\BOXES_USERNAME.bmp "c:\Documents and Settings\All Users\Application Data\Microsoft\User Account Pictures"
 REGEDIT /S a:\winxp.reg
 EXIT
diff --git a/src/fedora-installer.vala b/src/fedora-installer.vala
index 083ba85..ec7e015 100644
--- a/src/fedora-installer.vala
+++ b/src/fedora-installer.vala
@@ -94,8 +94,7 @@ private class Boxes.FedoraInstaller: UnattendedInstaller {
     }
 
     protected override string fill_unattended_data (string data, string hostname) throws RegexError {
-        var host = hostname.replace (" ", "-");
-        var str = base.fill_unattended_data (data, host);
+        var str = base.fill_unattended_data (data, hostname);
 
         str = kbd_regex.replace (str, str.length, 0, kbd);
 
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index 54081e7..014125c 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -46,6 +46,8 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
     protected string timezone;
     protected string lang;
 
+    protected AvatarFormat avatar_format;
+
     private static Regex username_regex;
     private static Regex password_regex;
     private static Regex timezone_regex;
@@ -79,7 +81,8 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
     }
     public UnattendedInstaller.copy (InstallerMedia media,
                                      string         unattended_src_path,
-                                     string         unattended_dest_name) throws GLib.Error {
+                                     string         unattended_dest_name,
+                                     AvatarFormat?  avatar_format = null) throws GLib.Error {
         os = media.os;
         os_media = media.os_media;
         label = media.label;
@@ -92,7 +95,7 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
         newline_type = DataStreamNewlineType.LF;
 
         unattended_files = new GLib.List<UnattendedFile> ();
-        unattended_files.append (new UnattendedFile (this, unattended_src_path, unattended_dest_name));
+        unattended_files.append (new UnattendedTextFile (this, unattended_src_path, unattended_dest_name));
 
         var time = TimeVal ();
         var date = new DateTime.from_timeval_local (time);
@@ -101,6 +104,10 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
         var langs = Intl.get_language_names ();
         lang = langs[0];
 
+        this.avatar_format = avatar_format;
+        if (avatar_format == null)
+            this.avatar_format = new AvatarFormat ();
+
         setup_ui ();
     }
 
@@ -256,8 +263,8 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
 
     protected virtual async void prepare_direct_boot (Cancellable? cancellable) throws GLib.Error {}
 
-    protected void add_unattended_file (string unattended_src_path, string unattended_dest_name) {
-        unattended_files.append (new UnattendedFile (this, unattended_src_path, unattended_dest_name));
+    protected void add_unattended_text_file (string unattended_src_path, string unattended_dest_name) {
+        unattended_files.append (new UnattendedTextFile (this, unattended_src_path, unattended_dest_name));
     }
 
     private async void create_disk_image (Cancellable? cancellable) throws GLib.Error {
@@ -289,33 +296,29 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
             return;
 
         var username = Environment.get_user_name ();
-        var avatar_file = "/var/lib/AccountsService/icons/" + username;
+        var avatar_file = new UnattendedAvatarFile (this, "/var/lib/AccountsService/icons/" + username, avatar_format);
 
         try {
             var path = yield accounts.FindUserByName (Environment.get_user_name ());
             Fdo.AccountsUser user = yield Bus.get_proxy (BusType.SYSTEM, "org.freedesktop.Accounts", path);
-            avatar_file = user.IconFile;
+            avatar_file.src_path = user.IconFile;
         } catch (GLib.IOError error) {
             warning ("Failed to retrieve information about user '%s': %s", username, error.message);
         }
 
-        var file = File.new_for_path (avatar_file);
-        if (file.query_exists ())
-            avatar.file = avatar_file;
+        var file = File.new_for_path (avatar_file.src_path);
+        if (file.query_exists ()) {
+            avatar.file = avatar_file.src_path;
+            unattended_files.append (avatar_file);
+        }
     }
 }
 
-private class Boxes.UnattendedFile {
-    public string src_path;
-    public string dest_name;
+private interface Boxes.UnattendedFile : GLib.Object {
+    public abstract string src_path { get; set; }
+    public abstract string dest_name { get; set; }
 
-    private UnattendedInstaller installer;
-
-    public UnattendedFile (UnattendedInstaller installer, string src_path, string dest_name) {
-       this.installer = installer;
-       this.src_path = src_path;
-       this.dest_name = dest_name;
-    }
+    protected abstract UnattendedInstaller installer  { get; set; }
 
     public async void copy (string hostname, Cancellable? cancellable) throws GLib.Error {
         var unattended_tmp = yield create (hostname, cancellable);
@@ -333,7 +336,22 @@ private class Boxes.UnattendedFile {
         debug ("Deleted temporary file '%s'", unattended_tmp.get_path ());
     }
 
-    private async File create (string hostname, Cancellable? cancellable)  throws GLib.Error {
+    protected abstract async File create (string hostname, Cancellable? cancellable)  throws GLib.Error;
+}
+
+private class Boxes.UnattendedTextFile : GLib.Object, Boxes.UnattendedFile {
+    public string src_path { get; set; }
+    public string dest_name { get; set; }
+
+    protected UnattendedInstaller installer  { get; set; }
+
+    public UnattendedTextFile (UnattendedInstaller installer, string src_path, string dest_name) {
+       this.installer = installer;
+       this.src_path = src_path;
+       this.dest_name = dest_name;
+    }
+
+    protected async File create (string hostname, Cancellable? cancellable)  throws GLib.Error {
         var source = File.new_for_path (src_path);
         var destination_path = get_user_unattended (dest_name);
         var destination = File.new_for_path (destination_path);
@@ -361,3 +379,59 @@ private class Boxes.UnattendedFile {
         return destination;
     }
 }
+
+private class Boxes.UnattendedAvatarFile : GLib.Object, Boxes.UnattendedFile {
+    public string src_path { get; set; }
+    public string dest_name { get; set; }
+
+    protected UnattendedInstaller installer  { get; set; }
+
+    private AvatarFormat dest_format;
+
+    public UnattendedAvatarFile (UnattendedInstaller installer, string src_path, AvatarFormat dest_format) {
+        this.installer = installer;
+        this.src_path = src_path;
+
+        this.dest_format = dest_format;
+    }
+
+    protected async File create (string hostname, Cancellable? cancellable)  throws GLib.Error {
+        dest_name = installer.username + dest_format.extension;
+        var destination_path = get_user_unattended (dest_name);
+
+        try {
+            var pixbuf = new Gdk.Pixbuf.from_file_at_scale (src_path, dest_format.width, dest_format.height, true);
+
+            if (!dest_format.alpha && pixbuf.get_has_alpha ())
+                pixbuf = remove_alpha (pixbuf);
+
+            debug ("Saving user avatar file at '%s'..", destination_path);
+            pixbuf.save (destination_path, dest_format.type);
+            debug ("Saved user avatar file at '%s'.", destination_path);
+        } catch (GLib.Error error) {
+            warning ("Failed to save user avatar: %s.", error.message);
+        }
+
+        return File.new_for_path (destination_path);
+    }
+}
+
+private class AvatarFormat {
+    public string type;
+    public string extension;
+    public bool alpha;
+    public int width;
+    public int height;
+
+    public AvatarFormat (string type = "png",
+                         string extension = "",
+                         bool   alpha = true,
+                         int    width = -1,
+                         int    height = -1) {
+        this.type = type;
+        this.extension = extension;
+        this.alpha = alpha;
+        this.width = width;
+        this.height = height;
+    }
+}
diff --git a/src/util.vala b/src/util.vala
index 88ae9ae..c7ca635 100644
--- a/src/util.vala
+++ b/src/util.vala
@@ -499,4 +499,43 @@ namespace Boxes {
         if (exit_status != 0)
             throw new Boxes.Error.COMMAND_FAILED ("Failed to execute: %s", string.joinv (" ", argv));
     }
+
+    // FIXME: Better ways to remove alpha more than welcome
+    private Gdk.Pixbuf remove_alpha (Gdk.Pixbuf pixbuf) {
+        const uint8 ALPHA_TRESHOLD = 50;
+
+        return_val_if_fail (pixbuf.get_n_channels () == 4 && pixbuf.get_bits_per_sample () == 8, pixbuf);
+
+        var width = pixbuf.get_width ();
+        var height = pixbuf.get_height ();
+        var rowstride = pixbuf.get_rowstride ();
+        unowned uint8[] orig_pixels = pixbuf.get_pixels ();
+        var pixels = new uint8[rowstride * height];
+
+        for (var i = 0; i < height; i++) {
+            for (var j = 0, k = 0; j < width * 4; j += 4, k += 3) {
+                var orig_index = rowstride * i + j;
+                var index = rowstride * i + k;
+
+                if (orig_pixels[orig_index + 3] < ALPHA_TRESHOLD) {
+                    pixels[index] = 0xFF;
+                    pixels[index + 1] = 0xFF;
+                    pixels[index + 2] = 0xFF;
+                } else {
+                    pixels[index] = orig_pixels[orig_index];
+                    pixels[index + 1] = orig_pixels[orig_index + 1];
+                    pixels[index + 2] = orig_pixels[orig_index + 2];
+                }
+            }
+        }
+
+        return new Gdk.Pixbuf.from_data (pixels,
+                                         pixbuf.get_colorspace (),
+                                         false,
+                                         8,
+                                         width,
+                                         height,
+                                         rowstride,
+                                         null);
+    }
 }
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index cd6e6a6..fba7a8a 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -48,7 +48,8 @@ private class Boxes.VMCreator {
         if (install_media is UnattendedInstaller) {
             var unattended = install_media as UnattendedInstaller;
 
-            yield unattended.setup (name, cancellable);
+            var hostname = name.replace (" ", "-");
+            yield unattended.setup (hostname, cancellable);
             fullscreen = !unattended.express_install;
         }
 
diff --git a/src/winxp-installer.vala b/src/winxp-installer.vala
index da2f44d..dd51d2c 100644
--- a/src/winxp-installer.vala
+++ b/src/winxp-installer.vala
@@ -23,15 +23,16 @@ private class Boxes.WinXPInstaller: WindowsInstaller {
 
     public WinXPInstaller.copy (InstallerMedia media) throws GLib.Error {
         var unattended_source = get_unattended (media.os.short_id + ".sif");
-        base.copy (media, unattended_source, "Winnt.sif");
+        var avatar_format = new AvatarFormat ("bmp", ".bmp", false, 48, 48);
+        base.copy (media, unattended_source, "Winnt.sif", avatar_format);
 
         var name = media.os.short_id + ".cmd";
         unattended_source = get_unattended (name);
-        add_unattended_file (unattended_source, name);
+        add_unattended_text_file (unattended_source, name);
 
         name = media.os.short_id + ".reg";
         unattended_source = get_unattended (name);
-        add_unattended_file (unattended_source, name);
+        add_unattended_text_file (unattended_source, name);
 
         newline_type = DataStreamNewlineType.CR_LF;
     }
diff --git a/vapi/upstream/Makefile.am b/vapi/upstream/Makefile.am
index 9ffb9d4..3a2153a 100644
--- a/vapi/upstream/Makefile.am
+++ b/vapi/upstream/Makefile.am
@@ -14,4 +14,6 @@ EXTRA_DIST =					\
 	gdk-3.0.vapi				\
 	gtk+-3.0.deps				\
 	gtk+-3.0.vapi				\
+	gdk-pixbuf-2.0.deps			\
+	gdk-pixbuf-2.0.vapi			\
 	$(NULL)
diff --git a/vapi/upstream/gdk-pixbuf-2.0.deps b/vapi/upstream/gdk-pixbuf-2.0.deps
new file mode 100644
index 0000000..cd10dfd
--- /dev/null
+++ b/vapi/upstream/gdk-pixbuf-2.0.deps
@@ -0,0 +1 @@
+gio-2.0
diff --git a/vapi/upstream/gdk-pixbuf-2.0.vapi b/vapi/upstream/gdk-pixbuf-2.0.vapi
new file mode 100644
index 0000000..ee919cd
--- /dev/null
+++ b/vapi/upstream/gdk-pixbuf-2.0.vapi
@@ -0,0 +1,242 @@
+/* gdk-pixbuf-2.0.vapi generated by vapigen, do not modify. */
+
+[CCode (cprefix = "Gdk", gir_namespace = "GdkPixbuf", gir_version = "2.0", lower_case_cprefix = "gdk_")]
+namespace Gdk {
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h")]
+	public class Pixbuf : GLib.Object, GLib.Icon {
+		[CCode (has_construct_function = false)]
+		public Pixbuf (Gdk.Colorspace colorspace, bool has_alpha, int bits_per_sample, int width, int height);
+		public Gdk.Pixbuf add_alpha (bool substitute_color, uint8 r, uint8 g, uint8 b);
+		public Gdk.Pixbuf apply_embedded_orientation ();
+		public void composite (Gdk.Pixbuf dest, int dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double offset_y, double scale_x, double scale_y, Gdk.InterpType interp_type, int overall_alpha);
+		public void composite_color (Gdk.Pixbuf dest, int dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double offset_y, double scale_x, double scale_y, Gdk.InterpType interp_type, int overall_alpha, int check_x, int check_y, int check_size, uint32 color1, uint32 color2);
+		public Gdk.Pixbuf? composite_color_simple (int dest_width, int dest_height, Gdk.InterpType interp_type, int overall_alpha, int check_size, uint32 color1, uint32 color2);
+		public Gdk.Pixbuf copy ();
+		public void copy_area (int src_x, int src_y, int width, int height, Gdk.Pixbuf dest_pixbuf, int dest_x, int dest_y);
+		public void fill (uint32 pixel);
+		public Gdk.Pixbuf? flip (bool horizontal);
+		[CCode (has_construct_function = false)]
+		public Pixbuf.from_data ([CCode (array_length = false)] owned uint8[] data, Gdk.Colorspace colorspace, bool has_alpha, int bits_per_sample, int width, int height, int rowstride, [CCode (type = "GdkPixbufDestroyNotify")] Gdk.PixbufDestroyNotify? destroy_fn = GLib.free);
+		[CCode (has_construct_function = false)]
+		public Pixbuf.from_file (string filename) throws GLib.Error;
+		[CCode (has_construct_function = false)]
+		public Pixbuf.from_file_at_scale (string filename, int width, int height, bool preserve_aspect_ratio) throws GLib.Error;
+		[CCode (has_construct_function = false)]
+		public Pixbuf.from_file_at_size (string filename, int width, int height) throws GLib.Error;
+		[CCode (has_construct_function = false)]
+		public Pixbuf.from_inline ([CCode (array_length_cname = "data_length", array_length_pos = 0.5)] uint8[] data, bool copy_pixels = true) throws GLib.Error;
+		[CCode (cheader_filename = "gdk-pixbuf/gdk-pixdata.h")]
+		public static Gdk.Pixbuf from_pixdata (Gdk.Pixdata pixdata, bool copy_pixels = true) throws GLib.Error;
+		[CCode (has_construct_function = false)]
+		public Pixbuf.from_stream (GLib.InputStream stream, GLib.Cancellable? cancellable = null) throws GLib.Error;
+		[CCode (has_construct_function = false)]
+		public Pixbuf.from_stream_at_scale (GLib.InputStream stream, int width, int height, bool preserve_aspect_ratio, GLib.Cancellable? cancellable = null) throws GLib.Error;
+		[CCode (has_construct_function = false)]
+		public Pixbuf.from_xpm_data ([CCode (array_length = false, type = "char**")] string[] data);
+		public int get_bits_per_sample ();
+		public size_t get_byte_length ();
+		public Gdk.Colorspace get_colorspace ();
+		public static unowned Gdk.PixbufFormat get_file_info (string filename, out int width, out int height);
+		public static GLib.SList<weak Gdk.PixbufFormat> get_formats ();
+		public bool get_has_alpha ();
+		public int get_height ();
+		public int get_n_channels ();
+		public unowned string get_option (string key);
+		[CCode (array_length = false)]
+		public unowned uint8[] get_pixels ();
+		[CCode (array_length_pos = 0.1, array_length_type = "guint")]
+		public unowned uint8[] get_pixels_with_length ();
+		public int get_rowstride ();
+		public int get_width ();
+		[CCode (cname = "gdk_pixbuf_new_from_stream_async", finish_name = "gdk_pixbuf_new_from_stream_finish")]
+		public static async Gdk.Pixbuf new_from_stream_async (GLib.InputStream stream, GLib.Cancellable? cancellable = null) throws GLib.Error;
+		[CCode (cname = "gdk_pixbuf_new_from_stream_at_scale_async", finish_name = "gdk_pixbuf_new_from_stream_finish")]
+		public static async Gdk.Pixbuf new_from_stream_at_scale_async (GLib.InputStream stream, int width, int height, bool preserve_aspect_ratio, GLib.Cancellable? cancellable = null) throws GLib.Error;
+		public Gdk.Pixbuf rotate_simple (Gdk.PixbufRotation angle);
+		public void saturate_and_pixelate (Gdk.Pixbuf dest, float saturation, bool pixelate);
+		public bool save (string filename, string type, ...) throws GLib.Error;
+		public bool save_to_buffer ([CCode (array_length_type = "gsize", type = "gchar**")] out uint8[] buffer, string type, ...) throws GLib.Error;
+		public bool save_to_bufferv ([CCode (array_length_cname = "buffer_size", array_length_pos = 1.5, array_length_type = "gsize")] out uint8[] buffer, string type, [CCode (array_length = false, array_null_terminated = true)] string[] option_keys, [CCode (array_length = false, array_null_terminated = true)] string[] option_values) throws GLib.Error;
+		public bool save_to_callback (Gdk.PixbufSaveFunc save_func, string type, ...) throws GLib.Error;
+		public bool save_to_callbackv ([CCode (delegate_target_pos = 1.5)] Gdk.PixbufSaveFunc save_func, string type, [CCode (array_length = false, array_null_terminated = true)] string[] option_keys, [CCode (array_length = false, array_null_terminated = true)] string[] option_values) throws GLib.Error;
+		public bool save_to_stream (GLib.OutputStream stream, string type, GLib.Cancellable? cancellable = null) throws GLib.Error;
+		[CCode (finish_name = "gdk_pixbuf_save_to_stream_finish")]
+		public async bool save_to_stream_async (GLib.OutputStream stream, string type, GLib.Cancellable? cancellable = null) throws GLib.Error;
+		public bool savev (string filename, string type, [CCode (array_length = false, array_null_terminated = true)] string[] option_keys, [CCode (array_length = false, array_null_terminated = true)] string[] option_values) throws GLib.Error;
+		public void scale (Gdk.Pixbuf dest, int dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double offset_y, double scale_x, double scale_y, Gdk.InterpType interp_type);
+		public Gdk.Pixbuf scale_simple (int dest_width, int dest_height, Gdk.InterpType interp_type);
+		[CCode (has_construct_function = false)]
+		public Pixbuf.subpixbuf (Gdk.Pixbuf src_pixbuf, int src_x, int src_y, int width, int height);
+		[CCode (cname = "gdk_pixbuf_new_from_data", has_construct_function = false)]
+		public Pixbuf.take_data ([CCode (array_length = false)] uint8[] data, Gdk.Colorspace colorspace, bool has_alpha, int bits_per_sample, int width, int height, int rowstride, [CCode (type = "GdkPixbufDestroyNotify")] Gdk.PixbufDestroyNotify? destroy_fn = null);
+		public int bits_per_sample { get; construct; }
+		public Gdk.Colorspace colorspace { get; construct; }
+		public bool has_alpha { get; construct; }
+		public int height { get; construct; }
+		public int n_channels { get; construct; }
+		public void* pixels { get; construct; }
+		public int rowstride { get; construct; }
+		public int width { get; construct; }
+	}
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", type_id = "gdk_pixbuf_animation_get_type ()")]
+	public class PixbufAnimation : GLib.Object {
+		[CCode (has_construct_function = false)]
+		protected PixbufAnimation ();
+		[CCode (has_construct_function = false)]
+		public PixbufAnimation.from_file (string filename) throws GLib.Error;
+		public int get_height ();
+		public Gdk.PixbufAnimationIter get_iter (GLib.TimeVal start_time);
+		public unowned Gdk.Pixbuf get_static_image ();
+		public int get_width ();
+		public bool is_static_image ();
+	}
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", type_id = "gdk_pixbuf_animation_iter_get_type ()")]
+	public class PixbufAnimationIter : GLib.Object {
+		[CCode (has_construct_function = false)]
+		protected PixbufAnimationIter ();
+		public bool advance (GLib.TimeVal current_time);
+		public int get_delay_time ();
+		public unowned Gdk.Pixbuf get_pixbuf ();
+		public bool on_currently_loading_frame ();
+	}
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "gdk_pixbuf_format_get_type ()")]
+	[Compact]
+	public class PixbufFormat {
+		public Gdk.PixbufFormat copy ();
+		public void free ();
+		public string get_description ();
+		[CCode (array_length = false, array_null_terminated = true)]
+		public string[] get_extensions ();
+		public string get_license ();
+		[CCode (array_length = false, array_null_terminated = true)]
+		public string[] get_mime_types ();
+		public string get_name ();
+		public bool is_disabled ();
+		public bool is_scalable ();
+		public bool is_writable ();
+		public void set_disabled (bool disabled);
+	}
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", type_id = "gdk_pixbuf_loader_get_type ()")]
+	public class PixbufLoader : GLib.Object {
+		[CCode (has_construct_function = false)]
+		public PixbufLoader ();
+		public bool close () throws GLib.Error;
+		public unowned Gdk.PixbufAnimation get_animation ();
+		public unowned Gdk.PixbufFormat get_format ();
+		public unowned Gdk.Pixbuf get_pixbuf ();
+		public void set_size (int width, int height);
+		[CCode (has_construct_function = false)]
+		public PixbufLoader.with_mime_type (string mime_type) throws GLib.Error;
+		[CCode (has_construct_function = false)]
+		public PixbufLoader.with_type (string image_type) throws GLib.Error;
+		public bool write ([CCode (array_length_cname = "count", array_length_pos = 1.1, array_length_type = "gsize")] uint8[] buf) throws GLib.Error;
+		public virtual signal void area_prepared ();
+		public virtual signal void area_updated (int x, int y, int width, int height);
+		public virtual signal void closed ();
+		public virtual signal void size_prepared (int width, int height);
+	}
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", type_id = "gdk_pixbuf_simple_anim_get_type ()")]
+	public class PixbufSimpleAnim : Gdk.PixbufAnimation {
+		[CCode (has_construct_function = false)]
+		public PixbufSimpleAnim (int width, int height, float rate);
+		public void add_frame (Gdk.Pixbuf pixbuf);
+		public bool get_loop ();
+		public void set_loop (bool loop);
+		public bool loop { get; set; }
+	}
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", type_id = "gdk_pixbuf_simple_anim_iter_get_type ()")]
+	public class PixbufSimpleAnimIter : Gdk.PixbufAnimationIter {
+		[CCode (has_construct_function = false)]
+		protected PixbufSimpleAnimIter ();
+	}
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixdata.h", has_type_id = false)]
+	public struct Pixdata {
+		public uint32 magic;
+		public int32 length;
+		public uint32 pixdata_type;
+		public uint32 rowstride;
+		public uint32 width;
+		public uint32 height;
+		[CCode (array_length = false, array_null_terminated = true)]
+		public weak uint8[] pixel_data;
+		public bool deserialize ([CCode (array_length_cname = "stream_length", array_length_pos = 0.5, array_length_type = "guint")] uint8[] stream) throws GLib.Error;
+		[CCode (array_length_pos = 0.1, array_length_type = "guint")]
+		public uint8[] serialize ();
+		public GLib.StringBuilder to_csource (string name, Gdk.PixdataDumpType dump_type);
+	}
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", cprefix = "GDK_COLORSPACE_")]
+	public enum Colorspace {
+		RGB
+	}
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", cprefix = "GDK_INTERP_")]
+	public enum InterpType {
+		NEAREST,
+		TILES,
+		BILINEAR,
+		HYPER
+	}
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", cprefix = "GDK_PIXBUF_ALPHA_")]
+	public enum PixbufAlphaMode {
+		BILEVEL,
+		FULL
+	}
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", cprefix = "GDK_PIXBUF_ROTATE_")]
+	public enum PixbufRotation {
+		NONE,
+		COUNTERCLOCKWISE,
+		UPSIDEDOWN,
+		CLOCKWISE
+	}
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixdata.h", cprefix = "GDK_PIXDATA_DUMP_")]
+	[Flags]
+	public enum PixdataDumpType {
+		PIXDATA_STREAM,
+		PIXDATA_STRUCT,
+		MACROS,
+		GTYPES,
+		CTYPES,
+		STATIC,
+		CONST,
+		RLE_DECODER
+	}
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixdata.h", cprefix = "GDK_PIXDATA_")]
+	[Flags]
+	public enum PixdataType {
+		COLOR_TYPE_RGB,
+		COLOR_TYPE_RGBA,
+		COLOR_TYPE_MASK,
+		SAMPLE_WIDTH_8,
+		SAMPLE_WIDTH_MASK,
+		ENCODING_RAW,
+		ENCODING_RLE,
+		ENCODING_MASK
+	}
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", cprefix = "GDK_PIXBUF_ERROR_")]
+	public errordomain PixbufError {
+		CORRUPT_IMAGE,
+		INSUFFICIENT_MEMORY,
+		BAD_OPTION,
+		UNKNOWN_TYPE,
+		UNSUPPORTED_OPERATION,
+		FAILED;
+		public static GLib.Quark quark ();
+	}
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixdata.h")]
+	public delegate void PixbufDestroyNotify ([CCode (array_length = false)] uint8[] pixels);
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixdata.h", instance_pos = -0.9)]
+	public delegate bool PixbufSaveFunc ([CCode (array_length_type = "gsize")] uint8[] buf) throws GLib.Error;
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", cname = "GDK_PIXBUF_FEATURES_H")]
+	public const int PIXBUF_FEATURES_H;
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", cname = "GDK_PIXBUF_MAGIC_NUMBER")]
+	public const int PIXBUF_MAGIC_NUMBER;
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", cname = "GDK_PIXBUF_MAJOR")]
+	public const int PIXBUF_MAJOR;
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", cname = "GDK_PIXBUF_MICRO")]
+	public const int PIXBUF_MICRO;
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", cname = "GDK_PIXBUF_MINOR")]
+	public const int PIXBUF_MINOR;
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", cname = "GDK_PIXBUF_VERSION")]
+	public const string PIXBUF_VERSION;
+	[CCode (cheader_filename = "gdk-pixbuf/gdk-pixbuf.h", cname = "GDK_PIXDATA_HEADER_LENGTH")]
+	public const int PIXDATA_HEADER_LENGTH;
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]