[cheese/three-point-oh] Added code to turn to previous and next pages
- From: Yuvaraj Pandian <yuvipanda src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese/three-point-oh] Added code to turn to previous and next pages
- Date: Sat, 10 Jul 2010 08:03:00 +0000 (UTC)
commit 671573429d6e7aa1404cdfb9dad12f64428f5dbc
Author: Yuvaraj Pandian T <yuvipanda gmail com>
Date: Sat Jul 10 13:32:29 2010 +0530
Added code to turn to previous and next pages
data/cheese-actions.ui | 20 +++++++++++++++++++-
src/cheese-window.vala | 36 ++++++++++++++++++++++++++++++++++--
2 files changed, 53 insertions(+), 3 deletions(-)
---
diff --git a/data/cheese-actions.ui b/data/cheese-actions.ui
index a434575..8d43345 100644
--- a/data/cheese-actions.ui
+++ b/data/cheese-actions.ui
@@ -208,7 +208,23 @@
<property name="label">_Effects</property>
<signal name="toggled" handler="cheese_main_window_on_effects_toggle" />
</object>
- </child>
+ </child>
+ <child>
+ <object class="GtkAction" id="effects_page_prev">
+ <property name="name">Previous Effects Page</property>
+ <property name="label">Previous Effects Page</property>
+ <signal name="activate" handler="cheese_main_window_on_prev_effects_page" />
+ </object>
+ <accelerator key="j" modifiers="GDK_CONTROL_MASK"/>
+ </child>
+ <child>
+ <object class="GtkAction" id="effects_page_next">
+ <property name="name">Next Effects Page</property>
+ <property name="label">Next Effects Page</property>
+ <signal name="activate" handler="cheese_main_window_on_next_effects_page" />
+ </object>
+ <accelerator key="k" modifiers="GDK_CONTROL_MASK"/>
+ </child>
</object>
</child>
@@ -242,6 +258,8 @@
</menu>
<menu action="edit_action">
<menuitem action="effects_toggle" />
+ <menuitem action="effects_page_next" />
+ <menuitem action="effects_page_prev" />
<separator />
<menuitem action="move_to_trash" />
<menuitem action="move_all_to_trash" />
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index 41dbb17..c7f4732 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -9,6 +9,7 @@ using Mx;
using Gee;
const int FULLSCREEN_TIMEOUT_INTERVAL = 5 * 1000;
+const int EFFECTS_PER_PAGE = 9;
public class Cheese.MainWindow : Gtk.Window
{
@@ -439,12 +440,43 @@ public class Cheese.MainWindow : Gtk.Window
effects_toggle_action.set_active (false);
}
+ [CCode (instance_pos = -1)]
+ internal void on_prev_effects_page (Gtk.Action action)
+ {
+ if (current_effects_page != 0)
+ {
+ activate_effects_page (current_effects_page - 1);
+ }
+ }
+
+ [CCode (instance_pos = -1)]
+ internal void on_next_effects_page (Gtk.Action action)
+ {
+ debug ("Hi");
+ if (current_effects_page != (effects_manager.effects.size / EFFECTS_PER_PAGE))
+ {
+ activate_effects_page (current_effects_page + 1);
+ }
+ }
+
private void activate_effects_page (int number)
{
current_effects_page = number;
viewport_layout.remove ((Clutter.Actor)current_effects_grid);
current_effects_grid = effects_grids[number];
viewport_layout.add ((Clutter.Actor)current_effects_grid);
+ for (int i = 0; i < effects_manager.effects.size; i++)
+ {
+ int page_of_effect = i / EFFECTS_PER_PAGE;
+ if (page_of_effect == page_of_effect)
+ {
+ effects_manager.effects[i].enable_preview ();
+ }
+ else
+ {
+ effects_manager.effects[i].disable_preview ();
+ }
+ }
this.current_effects_grid.set_size (viewport.width, viewport.height);
}
@@ -464,7 +496,7 @@ public class Cheese.MainWindow : Gtk.Window
effects_grids = new ArrayList<Mx.Grid>();
- for (int i = 0; i < (effects_manager.effects.size / 9) + 1; i++)
+ for (int i = 0; i <= effects_manager.effects.size / EFFECTS_PER_PAGE; i++)
{
Mx.Grid grid = new Mx.Grid ();
effects_grids.add (grid);
@@ -490,7 +522,7 @@ public class Cheese.MainWindow : Gtk.Window
button.set_data ("effect", effect);
button.clicked.connect (on_selected_effect_change);
- effects_grids[i / 9].add ((Clutter.Actor)button);
+ effects_grids[i / EFFECTS_PER_PAGE].add ((Clutter.Actor)button);
camera.connect_effect_texture (effect, texture);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]