seed r165 - trunk/examples
- From: hortont svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r165 - trunk/examples
- Date: Fri, 7 Nov 2008 16:45:55 +0000 (UTC)
Author: hortont
Date: Fri Nov 7 16:45:54 2008
New Revision: 165
URL: http://svn.gnome.org/viewvc/seed?rev=165&view=rev
Log:
Fix Robb's poppler example. Now runs, doesn't let you go past the first
page (especially in single page PDFs).
Modified:
trunk/examples/poppler.js
Modified: trunk/examples/poppler.js
==============================================================================
--- trunk/examples/poppler.js (original)
+++ trunk/examples/poppler.js Fri Nov 7 16:45:54 2008
@@ -3,7 +3,6 @@
Seed.import_namespace("Gdk");
Seed.import_namespace("Gtk");
Seed.import_namespace("Poppler");
-Seed.import_namespace("PopplerGlib");
Gtk.init(null, null);
@@ -17,29 +16,38 @@
{
if (current_page != null)
{
- drawing_area.window.clear();
+ drawing_area.window.clear();
cairo = Gdk.cairo_create(drawing_area.window);
current_page.render(cairo);
}
-
+
return true;
}
+
function set_page(num)
{
+ if(num >= num_pages)
+ {
+ set_page(num_pages - 1);
+ return;
+ }
+
current_page = current_document.get_page(num);
draw_document();
//Get rid of precision.
entry.text = Seed.sprintf("%d",num+1);
page_num = num;
+
if (page_num == num_pages-1)
- next_button.sensitive = false;
+ next_button.sensitive = false;
else
- next_button.sensitive = true;
+ next_button.sensitive = true;
+
if (page_num == 0)
- previous_button.sensitive = false;
+ previous_button.sensitive = false;
else
- previous_button.sensitive = true;
+ previous_button.sensitive = true;
}
function open_file(sv)
@@ -54,16 +62,21 @@
if(file_chooser.run() == Gtk.ResponseType.accept)
{
- // Poppler.Document will not take a uri as a construction property,
- // use this:
- current_document =
- Poppler.Document.new_from_file(file_chooser.get_uri());
- set_page(0);
- num_pages = current_document.get_n_pages();
- page_label.label = " of " + num_pages;
- draw_document();
- if (num_pages > 1)
- next_button.sensitive = true;
+ // Poppler.Document will not take a uri as a construction property,
+ // use this:
+ current_document =
+ Poppler.Document.new_from_file(file_chooser.get_uri());
+ num_pages = current_document.get_n_pages();
+ set_page(0);
+
+ if(num_pages == 1)
+ next_button.sensitive = previous_button.sensitive = false;
+
+ page_label.label = " of " + num_pages;
+ draw_document();
+
+ if (num_pages > 1)
+ next_button.sensitive = true;
}
file_chooser.destroy();
@@ -82,7 +95,7 @@
entry = new Gtk.Entry({text:"0"});
entry_item.add(entry);
entry_item.width_request = 40;
- entry.signal.activate.connect(function(){set_page(parseInt(entry.text)-1)});
+ entry.signal.activate.connect(function(){set_page(parseInt(entry.text, 10)-1)});
var label_item = new Gtk.ToolItem();
page_label = new Gtk.Label({label: " of 0"});
label_item.add(page_label);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]