[ease] [editor] Allow "zoom to fit"
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] [editor] Allow "zoom to fit"
- Date: Mon, 9 Aug 2010 01:31:58 +0000 (UTC)
commit ff4604d87c55ac79e3940b6f9267d5881274799e
Author: Nate Stedman <natesm gmail com>
Date: Sun Aug 8 21:31:31 2010 -0400
[editor] Allow "zoom to fit"
Added menu item for zoom to fit
data/ui/editor-window.ui | 8 ++++++++
ease/ease-editor-embed.vala | 12 +++++++++++-
ease/ease-editor-window.vala | 21 +++++++++++++++++++--
3 files changed, 38 insertions(+), 3 deletions(-)
---
diff --git a/data/ui/editor-window.ui b/data/ui/editor-window.ui
index 4d445c9..080696a 100644
--- a/data/ui/editor-window.ui
+++ b/data/ui/editor-window.ui
@@ -329,6 +329,14 @@
<signal name="activate" handler="ease_editor_window_zoom_out"/>
</object>
</child>
+ <child>
+ <object class="GtkCheckMenuItem" id="Zoom Fit">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Zoom to _Fit</property>
+ <property name="use_underline">True</property>
+ <signal name="toggled" handler="ease_editor_window_on_zoom_fit"/>
+ </object>
+ </child>
</object>
</child>
</object>
diff --git a/ease/ease-editor-embed.vala b/ease/ease-editor-embed.vala
index bd41eea..2beace2 100644
--- a/ease/ease-editor-embed.vala
+++ b/ease/ease-editor-embed.vala
@@ -191,7 +191,7 @@ internal class Ease.EditorEmbed : ScrollableEmbed, UndoSource
/**
* If the zoom factor should automatically be set to fill the EditorEmbed.
*/
- private bool zoom_fit { get; set; }
+ internal bool zoom_fit { get; set; }
/**
* Create an EditorEmbed representing a { link Document}.
@@ -241,6 +241,16 @@ internal class Ease.EditorEmbed : ScrollableEmbed, UndoSource
}
});
+ // fit the slide to the window
+ notify["zoom-fit"].connect((o, pspec) => {
+ if (!zoom_fit) return;
+
+ zoom = width / height > (float)document.width / document.height
+ ? height / document.height
+ : width / document.width;
+ reposition_group();
+ });
+
connect_keys();
}
diff --git a/ease/ease-editor-window.vala b/ease/ease-editor-window.vala
index ffd3faa..1a6d2b8 100644
--- a/ease/ease-editor-window.vala
+++ b/ease/ease-editor-window.vala
@@ -122,6 +122,11 @@ internal class Ease.EditorWindow : Gtk.Window
private Gtk.RadioMenuItem show_sorter;
/**
+ * The zoom fit check item.
+ */
+ private Gtk.CheckMenuItem zoom_fit;
+
+ /**
* The time the document was last saved.
*/
long last_saved = 0;
@@ -178,8 +183,8 @@ internal class Ease.EditorWindow : Gtk.Window
editor = builder.get_object("editor") as Gtk.Widget;
show_sorter =
builder.get_object("slide-sorter-radio") as Gtk.RadioMenuItem;
- show_editor =
- builder.get_object("editor-radio") as Gtk.RadioMenuItem;
+ show_editor = builder.get_object("editor-radio") as Gtk.RadioMenuItem;
+ zoom_fit = builder.get_object("Zoom Fit") as Gtk.CheckMenuItem;
// slide display
slide_button_panel = new SlideButtonPanel(document, this);
@@ -547,16 +552,26 @@ internal class Ease.EditorWindow : Gtk.Window
[CCode (instance_pos = -1)]
internal void zoom_in(Gtk.Widget sender)
{
+ embed.zoom_fit = false;
+ zoom_fit.active = false;
zoom_slider.zoom_in();
}
[CCode (instance_pos = -1)]
internal void zoom_out(Gtk.Widget sender)
{
+ embed.zoom_fit = false;
+ zoom_fit.active = false;
zoom_slider.zoom_out();
}
[CCode (instance_pos = -1)]
+ internal void on_zoom_fit(Gtk.Widget sender)
+ {
+ embed.zoom_fit = (sender as Gtk.CheckMenuItem).active;
+ }
+
+ [CCode (instance_pos = -1)]
internal bool save_document(Gtk.Widget? sender)
{
if (document.filename == null)
@@ -774,6 +789,8 @@ internal class Ease.EditorWindow : Gtk.Window
zoom_slider.digits = 0;
zoom_slider.value_changed.connect(() => {
+ embed.zoom_fit = false;
+ zoom_fit.active = false;
embed.zoom = (float)zoom_slider.get_value() / 100f;
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]