changed license to GPL v2
[livewp] / applet / src / fifteen.c
index 984797d..3de9265 100644 (file)
@@ -1,3 +1,27 @@
+/*vim: set sw=4 ts=4 et: */
+/*
+ * This file is part of Live Wallpaper (livewp)
+ * 
+ * Copyright (C) 2010 Vlad Vasiliev
+ * Copyright (C) 2010 Tanya Makova
+ *       for the code
+ * 
+ * This software is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ * 
+ * This software is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+*/
+/*******************************************************************************/
 #include <hildon/hildon.h>
 #include <time.h>
 #include <unistd.h>
@@ -58,7 +82,6 @@ void reinit(AWallpaperPlugin *desktop_plugin)
         set_actor_position(actor, actor->x, actor->y, actor->z, desktop_plugin);
         //set_actor_position(actor, (i%4)*width, (i/4)*height, 2, desktop_plugin);
     }
-    fprintf(stderr,"end reinit\n");
 }
 
 void moving_actor(gint num, gint max, AWallpaperPlugin *desktop_plugin)
@@ -102,7 +125,7 @@ gboolean main_timer(AWallpaperPlugin *desktop_plugin)
         if (scene->bone>-1)
             moving_actor(scene->timer_num, 10, desktop_plugin);
         else 
-            moving_all(scene->timer_num, 20, desktop_plugin);
+            moving_all(scene->timer_num, 15, desktop_plugin);
         return;
     } 
     char * accel_filename = "/sys/class/i2c-adapter/i2c-3/3-001d/coord";
@@ -127,7 +150,7 @@ gboolean main_timer(AWallpaperPlugin *desktop_plugin)
     if (az < -2000) {
         //reinit(desktop_plugin);
         //sleep(1);
-        scene->timer_num = 20;
+        scene->timer_num = 15;
         scene->bone = -1;
         return TRUE;
     }
@@ -155,7 +178,7 @@ gboolean main_timer(AWallpaperPlugin *desktop_plugin)
             if (bone < 0) return TRUE;
         }
     } else return TRUE;
-    fprintf(stderr, "move %d\n", bone);
+    //fprintf(stderr, "move %d\n", bone);
     scene->bone = bone;
     scene->timer_num = 10;
         
@@ -166,7 +189,7 @@ void init_actors(AWallpaperPlugin *desktop_plugin)
     gint i;
     Actor *actor;
     actor = init_object(desktop_plugin, "background", g_strdup("background.jpg"),
-                                -180, -10, 2, 800, 480,
+                                -180, -15, 2, 800, 480,
                                 TRUE, TRUE, 100, 255,
                                 NULL, NULL, NULL);
     for (i=0; i<15; i++){
@@ -186,10 +209,13 @@ quit_from_program (Animation_WallpaperPrivate *priv)
 void
 view_state_changed (Animation_WallpaperPrivate *priv)
 {
-    if (priv->visible){
-        priv->long_timer = g_timeout_add(50, main_timer, priv->desktop_plugin);
+    if (priv->visible && priv->long_timer == 0){
+        priv->long_timer = g_timeout_add(100, main_timer, priv->desktop_plugin);
+        //fprintf(stderr, "visible = 1 timeout_add %d\n", priv->long_timer);
     }else {
+        //fprintf(stderr, "visible = 0 timer remove %d\n", priv->long_timer);
         g_source_remove(priv->long_timer);
+        priv->long_timer = 0;
     }
     
 }
@@ -218,21 +244,24 @@ int main( int   argc, char *argv[] )
         }
     }
 
-    fprintf(stderr, "view=%d window_id=%d\n", view, window_id);
+    //fprintf(stderr, "view=%d window_id=%d\n", view, window_id);
 
     hildon_gtk_init (&argc, &argv);
-    g_set_application_name ("fifteen");
+    g_set_application_name ("Fifteen");
     window = hildon_window_new ();
-    gtk_window_set_title(window,"fifteen");
+    //gtk_window_fullscreen (GTK_WINDOW(window));
+    gtk_window_set_title(window,"Fifteen");
+    gtk_window_set_wmclass(window,"Fifteen_exec","Fifteen_exec");
     //window->window = window_id;
     g_signal_connect (G_OBJECT (window), "delete_event",
                         G_CALLBACK (gtk_main_quit), NULL);
     priv->window = window;
     priv->theme = g_strdup("Fifteen"); 
     priv->xapplet = -180;
-    priv->yapplet = -10;
+    priv->yapplet = -15;
     priv->desktop_plugin = desktop_plugin;
     priv->view = view;
+    priv->long_timer = 0;
     desktop_plugin->priv = priv;
 
     priv->osso = osso_initialize("org.maemo.livewp", VERSION, TRUE, NULL);
@@ -246,7 +275,8 @@ int main( int   argc, char *argv[] )
     scene->timer_num = 0;
     reinit(desktop_plugin);
     gtk_widget_show  (window);
-    priv->long_timer = g_timeout_add(50, main_timer, desktop_plugin);
+    //priv->long_timer = g_timeout_add(100, main_timer, desktop_plugin);
+    //fprintf(stderr, "create timer %d\n", priv->long_timer);
     gtk_main ();
     return 0;
 }