started slideshow
[livewp] / applet / src / livewp-main.c
index 84abdda..8482706 100644 (file)
@@ -1,21 +1,21 @@
 /* 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
@@ -37,7 +37,7 @@ gboolean long_timeout (AWallpaperPlugin *desktop_plugin);
 void conky_visible(AWallpaperPlugin *desktop_plugin);
 void flash_visible(AWallpaperPlugin *desktop_plugin);
 
-void 
+void
 set_live_bg (Display *display, Window xwindow, int mode){
    Atom atom;
    atom = XInternAtom (display, "_HILDON_LIVE_DESKTOP_BACKGROUND", False);
@@ -63,7 +63,7 @@ void
 view_state_changed (Animation_WallpaperPrivate *priv)
 {
    fprintf(stderr," VIew %i State %i\n", priv->view, priv->visible);
-   if (priv->visible){  
+   if (priv->visible){
        /* ToDo  make undependent function */
        /* For Video */
        if (!strcmp(priv->theme,"Video")){
@@ -123,7 +123,7 @@ view_state_changed (Animation_WallpaperPrivate *priv)
 }
 /*******************************************************************************/
 gboolean
-check_alive_event(Animation_WallpaperPrivate *priv) 
+check_alive_event(Animation_WallpaperPrivate *priv)
 {
     if ( time(NULL) - priv->last_alive_event > 10*60) /* If last event later 10 minute */
         quit_from_program(priv);
@@ -156,7 +156,7 @@ quit_from_program (Animation_WallpaperPrivate *priv)
      fprintf(stderr,"quit_from_program\n");
      if (priv){
             livewp_deinitialize_dbus(priv);
-         if (priv->view_notify != 0) { 
+         if (priv->view_notify != 0) {
             gconf_client_notify_remove (gconf_client_get_default (), priv->view_notify);
             priv->view_notify = 0;
          }
@@ -175,7 +175,7 @@ quit_from_program (Animation_WallpaperPrivate *priv)
          priv->desktop_plugin = NULL;
          g_free(priv);
          priv = NULL;
-     } 
+     }
      fprintf(stderr,"end of quit_from_program\n");
      gtk_main_quit();;
 }
@@ -201,11 +201,11 @@ short_timeout (AWallpaperPlugin *desktop_plugin)
     tmp = desktop_plugin->priv->scene->actors;
     while (tmp != NULL){
            actor = tmp->data;
-           if (now >= actor->time_start_animation  
+           if (now >= actor->time_start_animation
                && actor->time_start_animation > 0
                /* && now - actor->time_start_animation <= actor->duration_animation*/){
                 pfunc = actor->func_change;
-                if (pfunc){ 
+                if (pfunc){
                     (*pfunc)(actor, desktop_plugin);
                     stop_flag = FALSE;
                 }
@@ -222,8 +222,7 @@ short_timeout (AWallpaperPlugin *desktop_plugin)
 void
 run_long_timeout(AWallpaperPlugin *desktop_plugin)
 {
-
-    gint daytime = get_daytime();
+       gint daytime = get_daytime();
     GSList * tmp;
     void (*pfunc)(gpointer, gpointer);
     time_t now;
@@ -244,13 +243,13 @@ run_long_timeout(AWallpaperPlugin *desktop_plugin)
             tmp = g_slist_next(tmp);
         }
     }
-   
+
     now = time(NULL);
     //fprintf(stderr, "Now  %d\n", now);
     tmp = desktop_plugin->priv->scene->actors;
     while (tmp != NULL){
         actor = tmp->data;
-        if (now >= actor->time_start_animation  
+        if (now >= actor->time_start_animation
             && actor->time_start_animation > 0
             && desktop_plugin->priv->short_timer == 0){
             /* fprintf(stderr, "start short timer act = %s %d\n", actor->name, now); */
@@ -264,7 +263,7 @@ run_long_timeout(AWallpaperPlugin *desktop_plugin)
         }
         tmp = g_slist_next(tmp);
     }
+
 }
 /*******************************************************************************/
 gboolean
@@ -282,7 +281,7 @@ long_timeout (AWallpaperPlugin *desktop_plugin)
                gst_object_unref (GST_OBJECT (desktop_plugin->priv->pipeline));
                desktop_plugin->priv->pipeline = NULL;
        }
-       return TRUE;  
+       return TRUE;
     }
 
     if (desktop_plugin->priv->long_timer == 0 )
@@ -335,22 +334,22 @@ main(int argc, char *argv[])
     HildonProgram       *app;
     int view = 1;
 
-     
-    if (argc == 2) 
+
+    if (argc == 2)
         view = atoi(argv[1]);
     if (view < 1 || view > 9)
         view = 1;
 
     AWallpaperPlugin *desktop_plugin = g_new0 (AWallpaperPlugin, 1);
     Animation_WallpaperPrivate *priv = g_new0 (Animation_WallpaperPrivate, 1);
-    desktop_plugin->priv = priv; 
+    desktop_plugin->priv = priv;
 
 
     /* Ininitializing */
     hildon_gtk_init (&argc, &argv);
     app = HILDON_PROGRAM (hildon_program_get_instance());
     g_set_application_name (PACKAGE);
+
     priv->osso = osso_initialize("org.maemo.livewp", VERSION, TRUE, NULL);
     if(!priv->osso){
         fprintf(stderr,"osso_initialize failed\n");
@@ -378,20 +377,20 @@ main(int argc, char *argv[])
 
     /* Check activity of opition "One theme in all views" */
     if (priv->one_in_all_view && view >1)
-        return -1;   
+        return -1;
 
 
-    if (current_active_view() == view && !priv->one_in_all_view) 
+    if (current_active_view() == view && !priv->one_in_all_view)
         priv->visible = TRUE;
-    else 
+    else
         priv->visible = FALSE;
 
 
     create_xwindow(priv);
     /* Initialize DBUS */
     livewp_initialize_dbus(priv);
-        
-    priv->view_notify = 0; 
+
+    priv->view_notify = 0;
     /* fprintf(stderr,"VISIBLE %i %i\n",priv->visible, current_active_view()); */
     gconf_client_add_dir(gconf_client_get_default (), "/apps/osso/hildon-desktop/views", GCONF_CLIENT_PRELOAD_NONE, NULL);
     priv->view_notify = gconf_client_notify_add(gconf_client_get_default (),"/apps/osso/hildon-desktop/views/current",
@@ -404,10 +403,10 @@ main(int argc, char *argv[])
     }
 
     init_scene_theme(desktop_plugin);
-        
+
     priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
 
-    priv->alive_timer = g_timeout_add(60000*10, (GtkFunction)check_alive_event, priv);  /* One per 10 minute */ 
+    priv->alive_timer = g_timeout_add(60000*10, (GtkFunction)check_alive_event, priv);  /* One per 10 minute */
     gtk_main();
     return 0;
 }