diff options
author | Alessio Treglia <alessio@debian.org> | 2012-08-07 18:56:05 +0200 |
---|---|---|
committer | Alessio Treglia <alessio@debian.org> | 2012-08-07 18:56:05 +0200 |
commit | 026e231507aa5dae486255b6450b410f37e3abb0 (patch) | |
tree | 6625869d3e4624b7fb872661390d131054338543 /src/book.vala | |
parent | f61940ebd00dbbcfccf408fd93fb1ab2ec5c78d5 (diff) |
Imported Upstream version 3.5.3upstream/3.5.3
Diffstat (limited to 'src/book.vala')
-rw-r--r-- | src/book.vala | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/book.vala b/src/book.vala index 76a1901..15e79c6 100644 --- a/src/book.vala +++ b/src/book.vala @@ -20,6 +20,7 @@ public class Book public signal void reordered (); public signal void cleared (); public signal void needs_saving_changed (); + public signal void saving (int i); public Book () { @@ -103,11 +104,11 @@ public class Book private void save_multi_file (string type, File file) throws Error { - int i = 0; - foreach (var page in pages) + for (var i = 0; i < get_n_pages (); i++) { + var page = get_page (i); page.save (type, make_indexed_file (file.get_uri (), i)); - i++; + saving (i); } } @@ -126,14 +127,16 @@ public class Book var writer = new PsWriter (stream); var surface = writer.surface; - foreach (var page in pages) + for (var i = 0; i < get_n_pages (); i++) { + var page = get_page (i); var image = page.get_image (true); var width = image.get_width () * 72.0 / page.get_dpi (); var height = image.get_height () * 72.0 / page.get_dpi (); surface.set_size (width, height); save_ps_pdf_surface (surface, image, page.get_dpi ()); surface.show_page (); + saving (i); } } @@ -457,6 +460,8 @@ public class Book writer.write_string ("\n"); writer.write_string ("endstream\n"); writer.write_string ("endobj\n"); + + saving (i); } /* Info */ @@ -490,16 +495,20 @@ public class Book public void save (string type, File file) throws Error { - if (strcmp (type, "jpeg") == 0) - save_multi_file ("jpeg", file); - else if (strcmp (type, "png") == 0) - save_multi_file ("png", file); - else if (strcmp (type, "tiff") == 0) - save_multi_file ("tiff", file); - else if (strcmp (type, "ps") == 0) + switch (type) + { + case "jpeg": + case "png": + case "tiff": + save_multi_file (type, file); + break; + case "ps": save_ps (file); - else if (strcmp (type, "pdf") == 0) + break; + case "pdf": save_pdf (file); + break; + } } public void set_needs_saving (bool needs_saving) |