redisigned timer
authorVlad Vasiliev <vlad@toshiba2.oblgaz>
Tue, 13 Apr 2010 19:13:25 +0000 (22:13 +0300)
committerVlad Vasiliev <vlad@toshiba2.oblgaz>
Tue, 13 Apr 2010 19:13:25 +0000 (22:13 +0300)
applet/src/livewp-home-widget.c

index ddef6ba..edced3c 100644 (file)
@@ -1198,27 +1198,16 @@ short_timeout (AWallpaperPlugin *desktop_plugin)
          return TRUE; /* keep running this event */
 }
 
+void
+run_long_timeout(AWallpaperPlugin *desktop_plugin){
 
-static gboolean
-long_timeout (AWallpaperPlugin *desktop_plugin)
-{
     gint daytime = get_daytime();
     GSList * tmp;
     void (*pfunc)(gpointer, gpointer);
     time_t now;
     Actor *actor;
 
-    /* fprintf(stderr, "long_timeout %i\n", desktop_plugin->priv->long_timer); */
-    if (desktop_plugin->priv->long_timer == 0 )
-        return FALSE;
-    if (!desktop_plugin->priv->visible){
-        if(desktop_plugin->priv->short_timer != 0){
-            g_source_remove(desktop_plugin->priv->short_timer);
-            desktop_plugin->priv->short_timer = 0;
-        }
-        desktop_plugin->priv->long_timer = 0;
-        return FALSE;
-    }
+
     //fprintf(stderr, "timer daytime=%d\n", daytime);
     if (scene.daytime != daytime){
         scene.daytime = daytime;
@@ -1252,8 +1241,26 @@ long_timeout (AWallpaperPlugin *desktop_plugin)
         }
         tmp = g_slist_next(tmp);
     }
-   
+}
+
+static gboolean
+long_timeout (AWallpaperPlugin *desktop_plugin)
+{
+    /* fprintf(stderr, "long_timeout %i\n", desktop_plugin->priv->long_timer); */
+    if (desktop_plugin->priv->long_timer == 0 )
+        return FALSE;
+    if (!desktop_plugin->priv->visible){
+        if(desktop_plugin->priv->short_timer != 0){
+            g_source_remove(desktop_plugin->priv->short_timer);
+            desktop_plugin->priv->short_timer = 0;
+        }
+        desktop_plugin->priv->long_timer = 0;
+        return FALSE;
+    }
+  
 
+    run_long_timeout(desktop_plugin);
     return TRUE; /* keep running this event */
 }
 
@@ -1267,8 +1274,10 @@ desktop_plugin_visible_notify (GObject    *object,
     /* fprintf (stderr, "is-on-current-desktop changed. visible: %u", visible); */
     if (visible){
         desktop_plugin->priv->visible = TRUE;
-        if (desktop_plugin->priv->long_timer == 0 )
+        if (desktop_plugin->priv->long_timer == 0 ){
             desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
+            run_long_timeout(desktop_plugin);
+        }
     }else{
         desktop_plugin->priv->visible = FALSE;
         if (desktop_plugin->priv->long_timer != 0 ){