[gnome-panel/wip/free-the-fish: 7/8] Free-the-fish: Move code to separate function



commit a1bf6efc3e406976911c883fbc3ada39d3740fb1
Author: Sebastian Geiger <sbastig gmx net>
Date:   Tue Jun 2 15:40:18 2015 +0200

    Free-the-fish: Move code to separate function

 gnome-panel/free-the-fish.c |   32 +++++++++++++++++++-------------
 1 files changed, 19 insertions(+), 13 deletions(-)
---
diff --git a/gnome-panel/free-the-fish.c b/gnome-panel/free-the-fish.c
index e7a0114..d9457c4 100644
--- a/gnome-panel/free-the-fish.c
+++ b/gnome-panel/free-the-fish.c
@@ -133,6 +133,24 @@ fish_move (gpointer data)
         return TRUE;
 }
 
+/* Starts Wandas hide mode. Wanda will move fast and it will move towards the
+ * side of the screen that is closer to it.*/
+static void fish_start_hide_mode() {
+        g_source_remove ((guint) fish.handler);
+        fish.handler = g_timeout_add (FISH_HIDE_TIMEOUT,
+                                      fish_move, NULL);
+        fish.x_speed *= FISH_XS_HIDE_FACTOR;
+        fish.y_speed *= FISH_YS_HIDE_FACTOR;
+        fish.hide_mode = TRUE;
+        if (fish.x_speed > 0) {
+                if (fish.x < (gdk_screen_width () / 2))
+                        fish.x_speed *= -1;
+        } else {
+                if (fish.x > (gdk_screen_width () / 2))
+                        fish.x_speed *= -1;
+        }
+}
+
 static void
 fish_handle_event (GdkEvent *event)
 {
@@ -147,19 +165,7 @@ fish_handle_event (GdkEvent *event)
                 case GDK_BUTTON_PRESS:
                 case GDK_2BUTTON_PRESS:
                 case GDK_3BUTTON_PRESS:
-                        g_source_remove ((guint) fish.handler);
-                        fish.handler = g_timeout_add (FISH_HIDE_TIMEOUT,
-                                                      fish_move, NULL);
-                        fish.xs *= FISH_XS_HIDE_FACTOR;
-                        fish.ys *= FISH_YS_HIDE_FACTOR;
-                        fish.hide_mode = TRUE;
-                        if (fish.xs > 0) {
-                                if (fish.x < (gdk_screen_width () / 2))
-                                        fish.xs *= -1;
-                        } else {
-                                if (fish.x > (gdk_screen_width () / 2))
-                                        fish.xs *= -1;
-                        }
+                        fish_start_hide_mode();
                         break;
                 default:
                         break;


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