[cheese/gnome-3-8] Refactor effects page next/previous logic



commit 38fbfc73b48b146d018db9f3696a9f108e82cc6d
Author: David King <amigadave amigadave com>
Date:   Thu Dec 12 12:35:47 2013 +0000

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

 src/cheese-window.vala |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index 70293aa..54d7c06 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -1062,7 +1062,7 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
   [CCode (instance_pos = -1)]
   public void on_prev_effects_page (Gtk.Action action)
   {
-    if (current_effects_page != 0)
+    if (is_previous_effects_page ())
     {
       activate_effects_page ((int)current_effects_page - 1);
     }
@@ -1076,7 +1076,7 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
   [CCode (instance_pos = -1)]
   public void on_next_effects_page (Gtk.Action action)
   {
-    if (current_effects_page != (effects_manager.effects.length () / EFFECTS_PER_PAGE))
+    if (is_next_effects_page ())
     {
       activate_effects_page ((int)current_effects_page + 1);
     }
@@ -1133,11 +1133,22 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow
    */
   private void setup_effects_page_switch_sensitivity ()
   {
-    effects_page_prev_action.sensitive = (is_effects_selector_active && current_effects_page != 0);
-    effects_page_next_action.sensitive =
-      (is_effects_selector_active && current_effects_page != effects_manager.effects.length () / 
EFFECTS_PER_PAGE);
+    effects_page_prev_action.sensitive = is_effects_selector_active
+                                         && is_previous_effects_page ();
+    effects_page_next_action.sensitive = is_effects_selector_active
+                                         && is_next_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;
+    }
+
   /**
    * Toggle the visibility of the effects selector.
    *


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