[ease] [general] Fixed some PDF element-related bugs
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] [general] Fixed some PDF element-related bugs
- Date: Mon, 11 Oct 2010 19:07:52 +0000 (UTC)
commit 6b5ecee8c892915d13633552b1f495bcb7a59505
Author: Nate Stedman <natesm gmail com>
Date: Sat Oct 9 11:13:03 2010 -0400
[general] Fixed some PDF element-related bugs
- Don't segfault when switching page, this is bad
behaviour
- Redraw properly when undoing/redoing and changing properties
- Added property for flipping through a PDF in a presentation,
but this is not implemented yet.
data/ui/inspector-element-pdf.ui | 14 ++++++++-
ease-core/ease-pdf-actor.vala | 4 +-
ease-core/ease-pdf-element.vala | 64 +++++++++++++++++++++++++++++--------
ease-core/ease-theme.vala | 1 +
4 files changed, 66 insertions(+), 17 deletions(-)
---
diff --git a/data/ui/inspector-element-pdf.ui b/data/ui/inspector-element-pdf.ui
index 238e44c..6ca3d94 100644
--- a/data/ui/inspector-element-pdf.ui
+++ b/data/ui/inspector-element-pdf.ui
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
@@ -41,6 +41,18 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="allow-flipping">
+ <property name="label" translatable="yes">Allow page change</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/ease-core/ease-pdf-actor.vala b/ease-core/ease-pdf-actor.vala
index 729d3cb..83b6e2a 100644
--- a/ease-core/ease-pdf-actor.vala
+++ b/ease-core/ease-pdf-actor.vala
@@ -44,13 +44,13 @@ public class Ease.PdfActor : Actor
y = e.y;
add_actor(contents);
- current_page = e.default_page;
+ current_page = e.displayed_page;
doc = e.pdf_doc;
draw_page();
// redraw when the element is changed
e.changed.connect(() => {
- current_page = e.default_page;
+ current_page = e.displayed_page;
draw_page();
});
}
diff --git a/ease-core/ease-pdf-element.vala b/ease-core/ease-pdf-element.vala
index 3c970cc..a96170b 100644
--- a/ease-core/ease-pdf-element.vala
+++ b/ease-core/ease-pdf-element.vala
@@ -20,12 +20,18 @@
*/
public class Ease.PdfElement : MediaElement
{
- private const string UI_FILE = "inspector-element-pdf.ui";
+ private const string UI_FILE = "inspector-element-pdf.ui";
+ private const int DEFAULT_PAGE = 0;
/**
* The page of the PDF file that is initially displayed.
*/
- public int default_page { get; set; default = 0; }
+ public int displayed_page { get; set; default = 0; }
+
+ /**
+ * Whether or not the user can change pages in the presentation.
+ */
+ public bool allow_flipping { get; set; default = true; }
/**
* The background displayed behind the PDF (if it is visible)
@@ -41,9 +47,8 @@ public class Ease.PdfElement : MediaElement
public PdfElement(string filename)
{
- pdf_doc = new Poppler.Document.from_file(
- Filename.to_uri(filename),
- null);
+ pdf_doc = new Poppler.Document.from_file(Filename.to_uri(filename),
+ null);
background = new Background.white();
signals();
}
@@ -52,14 +57,14 @@ public class Ease.PdfElement : MediaElement
{
base.from_json(obj);
parent = owner;
- default_page = obj.get_string_member(Theme.PDF_DEFAULT_PAGE).to_int();
+ displayed_page = obj.get_string_member(Theme.PDF_DEFAULT_PAGE).to_int();
+ allow_flipping = obj.get_boolean_member(Theme.PDF_ALLOW_FLIPPING);
background =
new Background.from_json(obj.get_object_member(Theme.BACKGROUND));
- pdf_doc = new Poppler.Document.from_file(
- Filename.to_uri(full_filename),
- null);
+ pdf_doc = new Poppler.Document.from_file(Filename.to_uri(full_filename),
+ null);
}
public override Actor actor(ActorContext c)
@@ -71,7 +76,8 @@ public class Ease.PdfElement : MediaElement
{
var obj = base.to_json();
obj.set_object_member(Theme.BACKGROUND, background.to_json());
- obj.set_string_member(Theme.PDF_DEFAULT_PAGE, default_page.to_string());
+ obj.set_string_member(Theme.PDF_DEFAULT_PAGE, displayed_page.to_string());
+ obj.set_boolean_member(Theme.PDF_ALLOW_FLIPPING, allow_flipping);
return obj;
}
@@ -115,7 +121,7 @@ public class Ease.PdfElement : MediaElement
parent.parent.path);
// get the current page
- var page = pdf_doc.get_page(default_page);
+ var page = pdf_doc.get_page(displayed_page);
// scale the context
double w = 0, h = 0;
@@ -128,6 +134,8 @@ public class Ease.PdfElement : MediaElement
public override Gtk.Widget inspector_widget()
{
+ bool silence_undo = false;
+
var builder = new Gtk.Builder();
try
{
@@ -148,12 +156,40 @@ public class Ease.PdfElement : MediaElement
// connect the slider's changed signal
scale.value_changed.connect(() => {
// create an undo acton
- var action = new UndoAction(this, "default-page");
+ var action = new UndoAction(this, "displayed-page");
+ changed();
- default_page = (int)scale.adjustment.value;
+ displayed_page = (int)scale.adjustment.value;
// emit the undoaction
- undo(action);
+ if (!silence_undo) undo(action);
+ });
+
+ notify["displayed-page"].connect(() => {
+ silence_undo = true;
+ scale.adjustment.value = displayed_page;
+ changed();
+ silence_undo = false;
+ });
+
+ // set up the flipping
+ var flip = builder.get_object("allow-flipping") as Gtk.CheckButton;
+ flip.active = allow_flipping;
+
+ flip.toggled.connect((button) => {
+ // create an undo acton
+ var action = new UndoAction(this, "allow-flipping");
+
+ allow_flipping = button.active;
+
+ // emit the undoaction
+ if (!silence_undo) undo(action);
+ });
+
+ notify["allow-flipping"].connect(() => {
+ silence_undo = true;
+ flip.active = allow_flipping;
+ silence_undo = false;
});
// add a background widget
diff --git a/ease-core/ease-theme.vala b/ease-core/ease-theme.vala
index 4cdf1a0..0a52d78 100644
--- a/ease-core/ease-theme.vala
+++ b/ease-core/ease-theme.vala
@@ -102,6 +102,7 @@ public class Ease.Theme : GLib.Object
// pdf properties
public const string PDF_DEFAULT_PAGE = "pdf-default-page";
+ public const string PDF_ALLOW_FLIPPING = "pdf-allow-flipping";
// gradient types
public const string GRAD_LINEAR = "linear";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]