done different long timer timeout depend on rich_animation new_logic
authortanya <tanya@moshkanov.oblgaz>
Sat, 24 Apr 2010 19:11:16 +0000 (22:11 +0300)
committertanya <tanya@moshkanov.oblgaz>
Sat, 24 Apr 2010 19:11:16 +0000 (22:11 +0300)
applet/src/livewp-common.h
applet/src/livewp-home-widget.c
applet/src/livewp-home-widget.h

index 53bbecc..9034eae 100644 (file)
 #include <glib/gi18n-lib.h>
 
 #define THEME_PATH "/usr/share/livewp/theme"
-#define SHORT_TIMER 75 /* 100 milisecond */
+#define SHORT_TIMER 75 /* 75 milisecond */
 //#define LONG_TIMER 5*60*1000 /* 10 minutes */
-#define LONG_TIMER  10*1000 /* 10 minutes */
+#define LONG_TIMER1  20*1000 /* 20 second */
+#define LONG_TIMER2  300*1000 /* 5 minutes */
 enum { SHORT_TIMER_TYPE, LONG_TIMER_TYPE };
 #define SKY_LEVEL 0 
 #define SUN_LEVEL 0 
index e8e9904..06fa6f6 100644 (file)
@@ -808,15 +808,28 @@ destroy_scene(void){
 void
 reload_scene(AWallpaperPlugin *desktop_plugin)
 {
-    fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme);  
-    destroy_scene();
-    if (!strcmp(desktop_plugin->priv->theme,"Modern"))
-        init_scene(desktop_plugin);
-    else if (!strcmp(desktop_plugin->priv->theme,"Berlin")) 
-        init_scene1(desktop_plugin);
-    else if (!strcmp(desktop_plugin->priv->theme,"Matrix")) 
-        init_scene2(desktop_plugin);
+    /* change long_timer if change rich_animation */
+    if (desktop_plugin->priv->long_timer){
+        g_source_remove(desktop_plugin->priv->long_timer);
+        desktop_plugin->priv->long_timer = 0;
+    }
 
+    if (desktop_plugin->priv->rich_animation)
+        desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER1, (GtkFunction)long_timeout, desktop_plugin);
+    else 
+        desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER2, (GtkFunction)long_timeout, desktop_plugin);
+
+    /* change theme if need */
+    if (strcmp(scene.name, desktop_plugin->priv->theme)){
+        fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme);  
+        destroy_scene();
+        if (!strcmp(desktop_plugin->priv->theme,"Modern"))
+            init_scene(desktop_plugin);
+        else if (!strcmp(desktop_plugin->priv->theme,"Berlin")) 
+            init_scene1(desktop_plugin);
+        else if (!strcmp(desktop_plugin->priv->theme,"Matrix")) 
+            init_scene2(desktop_plugin);
+    }
 }
 
 static void
@@ -829,7 +842,7 @@ init_scene2(AWallpaperPlugin *desktop_plugin)
   fprintf(stderr, "init scene2 \n");
   //scene.daytime = get_daytime();
   scene.actors = NULL;
-
+  scene.name = g_strdup("Matrix"); 
   
   actor = init_object(desktop_plugin, "background", "bg.png", 
                       0, 0, 5, 800, 480, 
@@ -908,6 +921,7 @@ init_scene(AWallpaperPlugin *desktop_plugin)
   /* init value for random */
   scene.seed = time(NULL);
 
+  scene.name = g_strdup("Modern"); 
  
 
   actor = init_object(desktop_plugin, "sky", "sky0.png", 
@@ -1218,6 +1232,7 @@ init_scene1(AWallpaperPlugin *desktop_plugin)
   /* init value for random */
   scene.seed = time(NULL);
 
+  scene.name = g_strdup("Berlin"); 
   
   actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480, 
                       TRUE, TRUE, 100, 255, 
@@ -1540,7 +1555,7 @@ run_long_timeout(AWallpaperPlugin *desktop_plugin)
 static gboolean
 long_timeout (AWallpaperPlugin *desktop_plugin)
 {
-    /* fprintf(stderr, "long_timeout %i\n", desktop_plugin->priv->long_timer); */
+    //fprintf(stderr, "long_timeout %d %d\n", desktop_plugin->priv->long_timer, time(NULL)); 
     if (desktop_plugin->priv->long_timer == 0 )
         return FALSE;
     if (!desktop_plugin->priv->visible){
@@ -1551,7 +1566,6 @@ long_timeout (AWallpaperPlugin *desktop_plugin)
         desktop_plugin->priv->long_timer = 0;
         return FALSE;
     }
-  
 
     run_long_timeout(desktop_plugin);
     return TRUE; /* keep running this event */
@@ -1568,7 +1582,11 @@ desktop_plugin_visible_notify (GObject    *object,
     if (visible){
         desktop_plugin->priv->visible = TRUE;
         if (desktop_plugin->priv->long_timer == 0 ){
-            desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
+            if (desktop_plugin->priv->rich_animation)
+                desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER1, (GtkFunction)long_timeout, desktop_plugin);
+            else 
+                desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER2, (GtkFunction)long_timeout, desktop_plugin);
+
             run_long_timeout(desktop_plugin);
         }
     }else{
@@ -1649,7 +1667,12 @@ animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
         init_scene1(desktop_plugin);
     else if (!strcmp(priv->theme, "Matrix"))
         init_scene2(desktop_plugin);
-    priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
+    
+    if (priv->rich_animation)
+        priv->long_timer = g_timeout_add(LONG_TIMER1, (GtkFunction)long_timeout, desktop_plugin);
+    else 
+        priv->long_timer = g_timeout_add(LONG_TIMER2, (GtkFunction)long_timeout, desktop_plugin);
+    
     /* TODO Move scene to priv */
     scene.timer_type = LONG_TIMER_TYPE;
     g_signal_connect (desktop_plugin, "notify::is-on-current-desktop",
index f788dd2..786e749 100644 (file)
@@ -48,6 +48,7 @@ G_BEGIN_DECLS
 
 
 typedef struct {
+    gchar *name;
     GSList * actors;
     gint daytime;
     gint timer_type;
@@ -74,6 +75,7 @@ void lw_settings(gpointer user_data, gpointer data);
 void actor_set_position_full(GtkWidget *actor, gint x, gint y, gint z);
 gint read_config(Animation_WallpaperPrivate *priv);
 void save_config(Animation_WallpaperPrivate *priv);
+static gboolean long_timeout(AWallpaperPlugin *desktop_plugin);
 void run_long_timeout(AWallpaperPlugin *desktop_plugin);
 static void init_scene(AWallpaperPlugin *desktop_plugin);
 static void init_scene1(AWallpaperPlugin *desktop_plugin);