[cheese] Refactor effects page next/previous logic



commit a149d17cc4e6f1b529e3c50cb0644a9a148117ac
Author: David King <amigadave amigadave com>
Date:   Thu Dec 12 10:19:52 2013 +0000

    Refactor effects page next/previous logic
    
    Add is_next_effects_page() and is_previous_effects_page() to
    CheeseWindow.

 src/cheese-window.vala |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index 9e83ddb..5096a1a 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -931,7 +931,7 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
      */
     private void on_effects_previous ()
     {
-        if (current_effects_page != 0)
+        if (is_previous_effects_page ())
         {
             activate_effects_page ((int)current_effects_page - 1);
         }
@@ -942,8 +942,7 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
      */
     private void on_effects_next ()
     {
-        if (current_effects_page != (effects_manager.effects.length ()
-                                     / EFFECTS_PER_PAGE))
+        if (is_next_effects_page ())
         {
             activate_effects_page ((int)current_effects_page + 1);
         }
@@ -1009,9 +1008,19 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
         var effects_previous = this.lookup_action ("effects-previous") as SimpleAction;
 
         effects_next.set_enabled (is_effects_selector_active
-                                  && current_effects_page != effects_manager.effects.length () / 
EFFECTS_PER_PAGE);
+                                  && is_next_effects_page ());
         effects_previous.set_enabled (is_effects_selector_active
-                                      && current_effects_page != 0);
+                                      && is_previous_effects_page ());
+    }
+
+    private bool is_next_effects_page ()
+    {
+        return current_effects_page != effects_manager.effects.length () / EFFECTS_PER_PAGE;
+    }
+
+    private bool is_previous_effects_page ()
+    {
+        return current_effects_page != 0;
     }
 
     /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]