fixed structure of code
[livewp] / applet / src / livewp-home-widget.c
index 1c44f0e..4d5a088 100644 (file)
@@ -22,8 +22,7 @@
  * 02110-1301 USA
 */
 /*******************************************************************************/
-#include <gtk/gtk.h>
-#include <hildon/hildon.h>
+#include "livewp-common.h"
 #include "livewp-home-widget.h"
 #include <gconf/gconf-client.h>
 #include "livewp-rules.h"
@@ -45,6 +44,7 @@ HD_DEFINE_PLUGIN_MODULE (AWallpaperPlugin, animation_wallpaper_plugin, HD_TYPE_H
 
 gint xapplet = 0, yapplet = 0;
 GSList * objects_list = NULL;
+MultiActor * ma1;
 Scene scene;
 
 static void
@@ -149,7 +149,7 @@ init_applet_position(void)
   g_object_unref(gconf_client);
 }
 
-static void
+void
 actor_set_position_full(GtkWidget *actor, gint x, gint y, gint z)
 {
  fprintf(stderr, "actor_set_position_full\n");
@@ -159,7 +159,6 @@ actor_set_position_full(GtkWidget *actor, gint x, gint y, gint z)
 static GtkWidget* 
 init_object(gchar * name, gint x, gint y, gint z, gint width, gint height)
 {
-  Actor  a;  
   GtkWidget *actor;
   GdkPixbuf *pixbuf;
   GtkWidget *image;
@@ -168,7 +167,7 @@ init_object(gchar * name, gint x, gint y, gint z, gint width, gint height)
   actor = hildon_animation_actor_new();
   gchar str[256];
   snprintf(str, 255, "/usr/share/anwall/%s.png", name);
-  /* fprintf(stderr, "!!!init object !!!!\nname = %s file = %s\n", name, str); */
+  //fprintf(stderr, "!!!init object !!!!\nname = %s file = %s\n", name, str);
   pixbuf = gdk_pixbuf_new_from_file_at_size (str, 
                                              width, 
                                              height, 
@@ -192,6 +191,9 @@ init_object(gchar * name, gint x, gint y, gint z, gint width, gint height)
   g_object_set_data(G_OBJECT(actor), "y", y);
   g_object_set_data(G_OBJECT(actor), "z", z);
   g_object_set_data(G_OBJECT(actor), "scale", 10);
+  g_object_set_data(G_OBJECT(actor), "visible", 1);
+  
+  hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (actor), scene.window);
 /*
   a.widget = actor;
   a.name = name;
@@ -222,22 +224,28 @@ init_scene(GtkWidget *window)
   get_sun_screen_pos(alt, azm, &x, &y);
   fprintf(stderr, "init scene\n");
   actor = init_object("sun", x, y, 20, 88, 88);
-  hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (actor), window);
   scene.static_actors = g_slist_append(scene.static_actors, G_OBJECT(actor));
   scene.dynamic_actors = g_slist_append(scene.dynamic_actors, G_OBJECT(actor));
 
   actor = init_object("sky", 0, 0, 0, 800, 480);
-  hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (actor), window);
   scene.static_actors = g_slist_append(scene.static_actors, G_OBJECT(actor));
 
   actor = init_object("town", 0, 0, 10, 800, 480);
-  hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (actor), window);
   scene.static_actors = g_slist_append(scene.static_actors, G_OBJECT(actor));
 
   actor = init_object("cloud1", 400, 150, 2, 200, 150);
-  hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (actor), window);
   scene.dynamic_actors = g_slist_append(scene.dynamic_actors, G_OBJECT(actor));
 
+  GSList * list = NULL;
+  actor = init_object("sun", 10, 10, 50, 88, 88);
+  list = g_slist_append(list, G_OBJECT(actor));
+  actor = init_object("cloud1", 50, 50, 49, 150, 100);
+  list = g_slist_append(list, G_OBJECT(actor));
+
+  ma1 = multiactor_init("multi", list, 0, 0, 50, 1.0, TRUE);
+  //objects_list = g_slist_append(objects_list, G_OBJECT(ma)); 
+  
+
 }
 
 void 
@@ -250,6 +258,26 @@ get_sun_screen_pos(double alt, double azm, gint * x, gint * y)
     *y = (int)((1 - alt) * y0) - 64;
 }
 
+void change_multiactor()
+{
+    gboolean fl;
+    double scale;
+    gint x, y, z;
+    if (ma1->visible) fl = FALSE;
+    else fl = TRUE;
+    //multiactor_set_visible(ma1, fl);
+
+    scale = ma1->scale;
+    scale -= 0.1;
+    if (scale == 0) scale = 1;
+    //multiactor_set_scale(ma1, scale);
+
+    x = ma1->x + 10;
+    y = ma1->y + 10;
+    multiactor_set_position(ma1, x, y, 0);
+
+}
+
 static void 
 change_actor(GtkWidget * actor)
 {
@@ -324,6 +352,8 @@ plugin_on_timeout (gpointer data)
   GSList * tmp;
   fprintf(stderr, "on timeout\n");
 
+  change_multiactor();
+
   if (scene.daytime == daytime){
       /* Change dynamic actors */
       tmp = scene.dynamic_actors;
@@ -376,10 +406,17 @@ plugin_on_timeout (gpointer data)
   */
   return TRUE; /* keep running this event */
 }
-void
-live_wallpaper_settings(GtkWidget *widget, gpointer user_data){
-       fprintf(stderr,"test\n");
+
+static void
+desktop_plugin_visible_notify (GObject    *object,
+                                          GParamSpec *spec,
+                                          AWallpaperPlugin *desktop_plugin)
+{
+      gboolean visible;
+      g_object_get (object, "is-on-current-desktop", &visible, NULL);
+      fprintf (stderr, "is-on-current-desktop changed. visible: %u", visible);
 }
+
 static void
 animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
 {
@@ -390,6 +427,9 @@ animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
   hd_home_plugin_item_set_settings (HD_HOME_PLUGIN_ITEM (desktop_plugin), TRUE);
   g_signal_connect (desktop_plugin, "show-settings",
                             G_CALLBACK (live_wallpaper_settings), NULL);
+  g_signal_connect (desktop_plugin, "notify::is-on-current-desktop",
+                     G_CALLBACK (desktop_plugin_visible_notify), desktop_plugin);
+
   gtk_container_add (GTK_CONTAINER (desktop_plugin), label);
   init_applet_position();
   init_scene(desktop_plugin);