summaryrefslogtreecommitdiff
path: root/src/book.vala
diff options
context:
space:
mode:
authorAlessio Treglia <alessio@debian.org>2012-08-07 18:56:06 +0200
committerAlessio Treglia <alessio@debian.org>2012-08-07 18:56:06 +0200
commit9593993c7d0c8ea122f55cb7d5c2a6348a0daa1a (patch)
tree8fa94b9a5176e3809a2d082a4164fc57d81d4e9c /src/book.vala
parentdf5fff91e1df71a8e9d9932183e28ad48a4c4e81 (diff)
parent026e231507aa5dae486255b6450b410f37e3abb0 (diff)
Merge tag 'upstream/3.5.3'
Upstream version 3.5.3
Diffstat (limited to 'src/book.vala')
-rw-r--r--src/book.vala33
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)