[ease] [ui] Added zoom in/out menu items.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] [ui] Added zoom in/out menu items.
- Date: Fri, 2 Jul 2010 04:47:23 +0000 (UTC)
commit 8f91971b1ab3ce1eecf8f51c23964fbc2cb64ae7
Author: Nate Stedman <natesm gmail com>
Date: Fri Jul 2 00:47:03 2010 -0400
[ui] Added zoom in/out menu items.
data/ui/editor-window.ui | 25 ++++++++++++++
src/ease-editor-window.vala | 12 +++++++
src/ease-zoom-slider.vala | 75 +++++++++++++++++++++++-------------------
3 files changed, 78 insertions(+), 34 deletions(-)
---
diff --git a/data/ui/editor-window.ui b/data/ui/editor-window.ui
index fbcce92..67488c5 100644
--- a/data/ui/editor-window.ui
+++ b/data/ui/editor-window.ui
@@ -189,6 +189,30 @@
<property name="visible">True</property>
<property name="label" translatable="yes">_View</property>
<property name="use_underline">True</property>
+ <child type="submenu">
+ <object class="GtkMenu" id="menu3">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkImageMenuItem" id="Zoom In">
+ <property name="label">gtk-zoom-in</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ <property name="accel_group">Menu Accelerators</property>
+ <signal name="activate" handler="ease_editor_window_zoom_in"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImageMenuItem" id="Zoom Out">
+ <property name="label">gtk-zoom-out</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ <signal name="activate" handler="ease_editor_window_zoom_out"/>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
<child>
@@ -458,4 +482,5 @@
<property name="yalign">0.49000000953674316</property>
<property name="stock">gtk-copy</property>
</object>
+ <object class="GtkAccelGroup" id="Menu Accelerators"/>
</interface>
diff --git a/src/ease-editor-window.vala b/src/ease-editor-window.vala
index 76d0ce1..6142f54 100644
--- a/src/ease-editor-window.vala
+++ b/src/ease-editor-window.vala
@@ -268,6 +268,18 @@ public class Ease.EditorWindow : Gtk.Window
}
[CCode (instance_pos = -1)]
+ public void zoom_in(Gtk.Widget sender)
+ {
+ zoom_slider.zoom_in();
+ }
+
+ [CCode (instance_pos = -1)]
+ public void zoom_out(Gtk.Widget sender)
+ {
+ zoom_slider.zoom_out();
+ }
+
+ [CCode (instance_pos = -1)]
public bool save_document(Gtk.Widget? sender)
{
if (document.filename == null)
diff --git a/src/ease-zoom-slider.vala b/src/ease-zoom-slider.vala
index f54eb74..e75974a 100644
--- a/src/ease-zoom-slider.vala
+++ b/src/ease-zoom-slider.vala
@@ -24,8 +24,8 @@
public class Ease.ZoomSlider : Gtk.Alignment, Clutter.Animatable
{
private Gtk.HScale zoom_slider;
- private Gtk.Button zoom_in;
- private Gtk.Button zoom_out;
+ private Gtk.Button zoom_in_button;
+ private Gtk.Button zoom_out_button;
private int[] values;
private Clutter.Animation zoom_anim;
@@ -75,8 +75,8 @@ public class Ease.ZoomSlider : Gtk.Alignment, Clutter.Animatable
if (value == buttons_shown_priv) return;
buttons_shown_priv = value;
- zoom_in.visible = value;
- zoom_out.visible = value;
+ zoom_in_button.visible = value;
+ zoom_out_button.visible = value;
}
}
@@ -100,18 +100,20 @@ public class Ease.ZoomSlider : Gtk.Alignment, Clutter.Animatable
zoom_slider.digits = 0;
// zoom in button
- zoom_in = new Gtk.Button();
- zoom_in.add(new Gtk.Image.from_stock("gtk-zoom-in", Gtk.IconSize.MENU));
- zoom_in.relief = Gtk.ReliefStyle.NONE;
+ zoom_in_button = new Gtk.Button();
+ zoom_in_button.add(new Gtk.Image.from_stock("gtk-zoom-in",
+ Gtk.IconSize.MENU));
+ zoom_in_button.relief = Gtk.ReliefStyle.NONE;
// zoom out button
- zoom_out = new Gtk.Button();
- zoom_out.add(new Gtk.Image.from_stock("gtk-zoom-out", Gtk.IconSize.MENU));
- zoom_out.relief = Gtk.ReliefStyle.NONE;
+ zoom_out_button = new Gtk.Button();
+ zoom_out_button.add(new Gtk.Image.from_stock("gtk-zoom-out",
+ Gtk.IconSize.MENU));
+ zoom_out_button.relief = Gtk.ReliefStyle.NONE;
// put it all together
var align = new Gtk.Alignment(0, 0.5f, 1, 0);
- align.add(zoom_out);
+ align.add(zoom_out_button);
hbox.pack_start(align, false, false, 0);
align = new Gtk.Alignment(0, 0.5f, 1, 0);
@@ -119,7 +121,7 @@ public class Ease.ZoomSlider : Gtk.Alignment, Clutter.Animatable
hbox.pack_start(align, false, false, 0);
align = new Gtk.Alignment(0, 0.5f, 1, 0);
- align.add(zoom_in);
+ align.add(zoom_in_button);
hbox.pack_start(align, false, false, 0);
set(1, 1, 1, 1);
@@ -127,30 +129,12 @@ public class Ease.ZoomSlider : Gtk.Alignment, Clutter.Animatable
zoom_slider.value_changed.connect(() => value_changed());
- zoom_in.clicked.connect(() => {
- for (var i = 0; i < values.length; i++)
- {
- if (zoom_slider.get_value() < values[i])
- {
- animate_zoom(values[i]);
- break;
- }
- }
- });
+ zoom_in_button.clicked.connect(() => zoom_in());
- zoom_out.clicked.connect(() => {
- for (var i = values.length - 1; i > -1; i--)
- {
- if (zoom_slider.get_value() > values[i])
- {
- animate_zoom(values[i]);
- break;
- }
- }
- });
+ zoom_out_button.clicked.connect(() => zoom_out());
- zoom_in.show.connect(buttons_show_handler);
- zoom_out.show.connect(buttons_show_handler);
+ zoom_in_button.show.connect(buttons_show_handler);
+ zoom_out_button.show.connect(buttons_show_handler);
zoom_slider.format_value.connect(val => {
return "%i%%".printf((int)val);
@@ -170,6 +154,29 @@ public class Ease.ZoomSlider : Gtk.Alignment, Clutter.Animatable
return zoom_slider.get_value();
}
+ public void zoom_out()
+ {
+ for (var i = values.length - 1; i > -1; i--)
+ {
+ if (zoom_slider.get_value() > values[i])
+ {
+ animate_zoom(values[i]);
+ break;
+ }
+ }
+ }
+
+ public void zoom_in()
+ {
+ for (var i = 0; i < values.length; i++)
+ {
+ if (zoom_slider.get_value() < values[i])
+ {
+ animate_zoom(values[i]);
+ break;
+ }
+ }
+ }
private void animate_zoom(double value)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]