Merge branch 'master' of https://vcs.maemo.org/git/livewp
authorVlad <vlad@gas.by>
Mon, 10 May 2010 10:19:12 +0000 (13:19 +0300)
committerVlad <vlad@gas.by>
Mon, 10 May 2010 10:19:12 +0000 (13:19 +0300)
Conflicts:
applet/src/livewp-home-widget.c

1  2 
applet/src/livewp-common.h
applet/src/livewp-home-widget.c
applet/src/livewp-scene.c

@@@ -61,13 -61,10 +61,13 @@@ struct _Scen
      double wind_angle; // [-1 .. 1]
      guint seed; /* init value for random  */
  };
 +
  typedef struct _AWallpaperPlugin AWallpaperPlugin;
  typedef struct _AWallpaperPluginClass AWallpaperPluginClass;
  typedef struct _Animation_WallpaperPrivate Animation_WallpaperPrivate;
  
 +
 +
  struct _Animation_WallpaperPrivate
  {
      gint long_timer;
@@@ -84,6 -81,7 +84,7 @@@
      gint xapplet;
      gint yapplet;
      Scene *scene;
+     GHashTable * hash_scene_func;
  };
  
  struct _AWallpaperPlugin
@@@ -94,7 -92,8 +95,7 @@@
  
  struct _AWallpaperPluginClass
  {
 -    HDHomePluginItemClass parent_class;
 -
 +  HDHomePluginItemClass parent_class;
  };
  
  
@@@ -39,6 -39,7 +39,6 @@@ HD_DEFINE_PLUGIN_MODULE (AWallpaperPlug
  #define Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE (obj,\
                                                            Animation_Wallpaper_TYPE_HOME_PLUGIN,\
                                                            Animation_WallpaperPrivate))
 -
  static void
  lw_applet_realize (GtkWidget *widget)
  {
@@@ -101,6 -102,7 +101,6 @@@ realize (GtkWidget *widget
      screen = gtk_widget_get_screen (widget);
      gtk_widget_set_colormap (widget, gdk_screen_get_rgba_colormap (screen));
  }
 -
  /* Set position of widget on desktop */
  static void
  init_applet_position(gint *xapplet, gint *yapplet)
@@@ -197,7 -199,6 +197,7 @@@ create_hildon_actor(Actor *actor, AWall
    //g_object_set_data(G_OBJECT(ha), "image", image);
    actor->image = image;
    hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (ha), GTK_WINDOW(desktop_plugin));
 +
    actor->widget = ha;
    set_actor_position(actor, actor->x, actor->y, actor->z, desktop_plugin);
    set_actor_scale(actor, (double)actor->scale/100, (double)actor->scale/100);
@@@ -295,8 -296,7 +295,8 @@@ run_long_timeout(AWallpaperPlugin *desk
      time_t now;
      Actor *actor;
  
 -
 +    if (!desktop_plugin->priv->scene)
 +      return;
      //fprintf(stderr, "!!!run long timeout short_timer=%d\n", desktop_plugin->priv->short_timer);
      if (desktop_plugin->priv->scene->daytime != daytime){
          desktop_plugin->priv->scene->daytime = daytime;
@@@ -375,12 -375,14 +375,12 @@@ desktop_plugin_visible_notify (GObjec
          }
      }
  }
 -
  gboolean
  rich_animation_press(GtkWidget *widget, GdkEvent *event,
                                              gpointer user_data){
      fprintf(stderr,"gggggggggggggggggggg2222\n");
      return FALSE;
  }    
 -
  static void
  animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
  {
      priv->short_timer = 0;
      priv->xapplet = 0;
      priv->yapplet = 0;
 +    priv->scene = NULL;
 +//    priv->theme = g_strdup("Modern");
+ //#if 0 
+     priv->hash_scene_func = g_hash_table_new(g_str_hash, g_str_equal);
+     
+     g_hash_table_insert(priv->hash_scene_func, g_strdup("Berlin"), (gpointer)&init_scene_Berlin);
+     g_hash_table_insert(priv->hash_scene_func, g_strdup("Modern"), (gpointer)&init_scene_Modern);
+     g_hash_table_insert(priv->hash_scene_func, g_strdup("Matrix"), (gpointer)&init_scene_Matrix);
+ //#endif
+     //priv->theme = g_strdup("Modern");
      desktop_plugin->priv->main_widget = gtk_fixed_new();
  
      gtk_widget_set_size_request(desktop_plugin->priv->main_widget, 100, 32);
          g_signal_connect(rich_animation, "button-press-event", G_CALLBACK(rich_animation_press), desktop_plugin);
          gtk_fixed_put(GTK_FIXED(desktop_plugin->priv->main_widget), rich_animation, 0, 0);
      }
 -/*
 -    GtkWidget *label = gtk_label_new ("ddddddddddddd"); 
 +#if 0
 +    GtkWidget *label = gtk_label_new ("1111ddddddddd");
      gtk_widget_set_size_request(label, 95, 30);
      gtk_widget_show (label);
      gtk_container_add (GTK_CONTAINER (desktop_plugin), label);
 -    gtk_fixed_put(GTK_FIXED(widget), label, 0, 0);
 -*/
 +#endif
      hd_home_plugin_item_set_settings (HD_HOME_PLUGIN_ITEM (desktop_plugin), TRUE);
      g_signal_connect (desktop_plugin, "show-settings",
                             G_CALLBACK (show_settings), priv);
      priv->scene = NULL;
  #if 0
      if (!strcmp(priv->theme,"Modern"))
-         init_scene(desktop_plugin);
+         init_scene_Modern(desktop_plugin);
      else if (!strcmp(priv->theme,"Berlin")) 
-         init_scene1(desktop_plugin);
+         init_scene_Berlin(desktop_plugin);
      else if (!strcmp(priv->theme, "Matrix"))
-         init_scene2(desktop_plugin);
+         init_scene_Matrix(desktop_plugin);
  #endif
      init_scene_theme(desktop_plugin);
          
      /* TODO Move scene to priv */
      //scene.timer_type = LONG_TIMER_TYPE;
      g_signal_connect (desktop_plugin, "notify::is-on-current-desktop",
 -                     G_CALLBACK (desktop_plugin_visible_notify), desktop_plugin);
 +                   G_CALLBACK (desktop_plugin_visible_notify), desktop_plugin);
  
     
      //sleep(2);
  static void
  lw_applet_finalize (GObject *object)
  {
 +fprintf(stderr,"lw_applet_finalize\n");
 +/*
       AWallpaperPlugin *desktop_plugin = Animation_Wallpaper_HOME_PLUGIN (object);
       Animation_WallpaperPrivate *priv = desktop_plugin->priv;
 -
 -     livewp_deinitialize_dbus(priv);
 -     fprintf(stderr,"finalaze %i\n", priv->long_timer);
 -     if (priv->long_timer){
 -        g_source_remove(priv->long_timer);
 -        priv->long_timer = 0;
 -     }
 -     if (priv->short_timer){
 -        g_source_remove(priv->short_timer);
 -        priv->short_timer = 0;
 +     
 +     if (priv){
 +           livewp_deinitialize_dbus(priv);
 +           fprintf(stderr,"finalaze %i\n", priv->long_timer);
 +           if (priv->long_timer){
 +              g_source_remove(priv->long_timer);
 +              priv->long_timer = 0;
 +           }
 +           if (priv->short_timer){
 +              g_source_remove(priv->short_timer);
 +              priv->short_timer = 0;
 +           }
 +
 +           destroy_scene(desktop_plugin);
       }
 +*/
 +}
  
 -     destroy_scene(desktop_plugin);
 +static void
 +desktop_widget_finalize (GObject *object)
 +{
 +     AWallpaperPlugin *desktop_plugin = Animation_Wallpaper_HOME_PLUGIN (object);
 +     Animation_WallpaperPrivate *priv = desktop_plugin->priv;
 +     
 +     if (priv){
 +           livewp_deinitialize_dbus(priv);
 +           fprintf(stderr,"finalaze %i\n", priv->long_timer);
 +           if (priv->long_timer){
 +              g_source_remove(priv->long_timer);
 +              priv->long_timer = 0;
 +           }
 +           if (priv->short_timer){
 +              g_source_remove(priv->short_timer);
 +              priv->short_timer = 0;
 +           }
 +
 +           destroy_scene(desktop_plugin);
 +     }
 +      /* Call the base class's implementation: */
 +      G_OBJECT_CLASS (animation_wallpaper_plugin_parent_class)->finalize (object);
  }
  
  static void
@@@ -517,11 -497,9 +525,11 @@@ animation_wallpaper_plugin_class_init (
  
      GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
      GtkObjectClass *gobject_class = GTK_OBJECT_CLASS (klass);
 +    GObjectClass *object_class = G_OBJECT_CLASS (klass);
  
      /* gobject */
      gobject_class->destroy = (gpointer)lw_applet_finalize;
 +    object_class->finalize = desktop_widget_finalize;
      widget_class->realize = lw_applet_realize;
      widget_class->expose_event = lw_applet_expose_event;
  
@@@ -533,9 -511,4 +541,9 @@@ static voi
  animation_wallpaper_plugin_class_finalize (AWallpaperPluginClass *class) {
  }
  
 +Animation_WallpaperPrivate*
 +animation_wallpaper_plugin_new (void)
 +{
 +  return g_object_new (Animation_Wallpaper_TYPE_HOME_PLUGIN , NULL);
 +}
  
  void 
  destroy_scene(AWallpaperPlugin *desktop_plugin)
  {
 -    GSList * tmp = desktop_plugin->priv->scene->actors;
 -    while (tmp != NULL){
 -        destroy_actor(tmp->data);
 -        tmp = g_slist_next(tmp);
 -    }
 -    g_slist_free(tmp);
 -    desktop_plugin->priv->scene->actors = NULL;
      if (desktop_plugin->priv->scene){
 -      g_free(desktop_plugin->priv->scene);
 -      desktop_plugin->priv->scene = NULL;
 +          GSList * tmp = desktop_plugin->priv->scene->actors;
 +          while (tmp != NULL){
 +              destroy_actor(tmp->data);
 +              tmp = g_slist_next(tmp);
 +          }
 +          if (tmp)
 +              g_slist_free(tmp);
 +          desktop_plugin->priv->scene->actors = NULL;
 +          if (desktop_plugin->priv->scene){
 +              g_free(desktop_plugin->priv->scene);
 +              desktop_plugin->priv->scene = NULL;
 +          }
      }
  }
  
@@@ -50,17 -47,17 +50,17 @@@ reload_scene(AWallpaperPlugin *desktop_
      destroy_scene(desktop_plugin);
  #if 0
      if (!strcmp(desktop_plugin->priv->theme,"Modern"))
-         init_scene(desktop_plugin);
+         init_scene_Modern(desktop_plugin);
      else if (!strcmp(desktop_plugin->priv->theme,"Berlin")) 
-         init_scene1(desktop_plugin);
+         init_scene_Berlin(desktop_plugin);
      else if (!strcmp(desktop_plugin->priv->theme,"Matrix")) 
-         init_scene2(desktop_plugin);
+         init_scene_Matrix(desktop_plugin);
  #endif
      init_scene_theme(desktop_plugin);
  }
  
  void
- init_scene2(AWallpaperPlugin *desktop_plugin)
+ init_scene_Matrix(AWallpaperPlugin *desktop_plugin)
  {
    Actor *actor;
    Scene *scene;
  
  /* Init Modern Scene */
  void
- init_scene(AWallpaperPlugin *desktop_plugin)
+ init_scene_Modern(AWallpaperPlugin *desktop_plugin)
  {
    Actor *actor;
    Scene *scene;
    /* init value for random */
    scene->seed = time(NULL);
    desktop_plugin->priv->scene = scene;
 -
    actor = init_object(desktop_plugin, "sky", "sky0.png", 
                        0, 0, 5, 800, 480, 
                        TRUE , TRUE, 100, 255, 
                        (gpointer)&change_static_actor, NULL, NULL);
 -  change_static_actor(actor, desktop_plugin);
    scene->actors = g_slist_append(scene->actors, actor);
 +  change_static_actor(actor, desktop_plugin);
    
    actor = init_object(desktop_plugin, "sun", "sun.png", 
                        0, 0, 6, 88, 88, 
  
  /* Init Berlin Scene */
  void
- init_scene1(AWallpaperPlugin *desktop_plugin)
+ init_scene_Berlin(AWallpaperPlugin *desktop_plugin)
  {
    Actor *actor, *actor1, *actor2;
    Scene *scene;
  void 
  init_scene_theme(AWallpaperPlugin *desktop_plugin)
  {
-     GHashTable * hash;
      void (*func)(gpointer);
-     hash = g_hash_table_new(g_str_hash, g_str_equal);
-     
-     g_hash_table_insert(hash, g_strdup("Berlin"), (gpointer)&init_scene1);
-     g_hash_table_insert(hash, g_strdup("Modern"), (gpointer)&init_scene);
-     g_hash_table_insert(hash, g_strdup("Matrix"), (gpointer)&init_scene2);
-     func = g_hash_table_lookup(hash, desktop_plugin->priv->theme);
+     func = g_hash_table_lookup(desktop_plugin->priv->hash_scene_func, desktop_plugin->priv->theme);
      if (func){
          (*func)(desktop_plugin);
      }