fixed problem with reload of plugin
authorVlad Vasiliev <vlad@toshiba2.oblgaz>
Mon, 12 Apr 2010 22:55:26 +0000 (01:55 +0300)
committerVlad Vasiliev <vlad@toshiba2.oblgaz>
Mon, 12 Apr 2010 22:55:26 +0000 (01:55 +0300)
applet/src/livewp-home-widget.c

index 01daa18..9071927 100644 (file)
@@ -948,6 +948,9 @@ long_timeout (AWallpaperPlugin *desktop_plugin)
     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;
     /* TODO  remove timeout */
     if (!desktop_plugin->priv->visible){
         desktop_plugin->priv->short_timer = 0;
@@ -994,12 +997,17 @@ desktop_plugin_visible_notify (GObject    *object,
 {
     gboolean visible;
     g_object_get (object, "is-on-current-desktop", &visible, NULL);
+    /* fprintf (stderr, "is-on-current-desktop changed. visible: %u", visible); */
     if (visible){
         desktop_plugin->priv->visible = TRUE;
-        desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
-    }else
+        if ( desktop_plugin->priv->long_timer == 0){
+            desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
+        }
+    }else{
         desktop_plugin->priv->visible = FALSE;
-   /*   fprintf (stderr, "is-on-current-desktop changed. visible: %u", visible); */
+        g_source_remove(desktop_plugin->priv->long_timer);
+        desktop_plugin->priv->long_timer = 0;
+    }
 }
 
 gboolean
@@ -1010,36 +1018,50 @@ rich_animation_press(GtkWidget *widget, GdkEvent *event,
 static void
 animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
 {
-    GtkWidget *label;
+    GtkWidget *widget;
     GtkWidget *rich_animation;
+    gchar           buffer[2048];
+
+    GtkWidget  *background_town = NULL;
+
     fprintf(stderr, "!!!!!!!plugin init \n");
     Animation_WallpaperPrivate *priv =  Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
     desktop_plugin->priv =  Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
+
     /* Load config */
     read_config(priv);
     priv->desktop_plugin = desktop_plugin;
+    widget = gtk_fixed_new();
+
+    gtk_widget_set_size_request(widget, 95, 68);
+    snprintf(buffer, sizeof(buffer) - 1, "%s/%s/%s", THEME_PATH, desktop_plugin->priv->theme, "town_right_corner.png");
+    background_town = gtk_image_new_from_file (buffer);
+    if (background_town){
+        gtk_fixed_put(GTK_FIXED(widget), background_town, 0, 0);
+        gtk_widget_show (background_town);
+    }
     /* Create rich animation event */
     rich_animation = gtk_event_box_new();
     if(rich_animation){
         gtk_widget_set_events(rich_animation, GDK_BUTTON_PRESS_MASK);
         gtk_event_box_set_visible_window(GTK_EVENT_BOX(rich_animation), FALSE);
-        gtk_widget_set_size_request(rich_animation, 95, 30);
-       gtk_widget_show (rich_animation);
+        gtk_widget_set_size_request(rich_animation, 95, 60);
+        gtk_widget_show (rich_animation);
         g_signal_connect(rich_animation, "button-press-event", G_CALLBACK(rich_animation_press), desktop_plugin);
+        gtk_fixed_put(GTK_FIXED(widget), rich_animation, 0, 0);
     }
 /*
-    label = gtk_label_new (""); 
+    GtkWidget *label = gtk_label_new ("ddddddddddddd"); 
     gtk_widget_set_size_request(label, 95, 30);
     gtk_widget_show (label);
-    gtk_container_add (GTK_CONTAINER (desktop_plugin), label);
+//    gtk_container_add (GTK_CONTAINER (desktop_plugin), label);
+    gtk_fixed_put(GTK_FIXED(widget), label, 0, 0);
 */
     hd_home_plugin_item_set_settings (HD_HOME_PLUGIN_ITEM (desktop_plugin), TRUE);
     g_signal_connect (desktop_plugin, "show-settings",
                             G_CALLBACK (lw_settings), priv);
-    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), rich_animation);
+    gtk_widget_show (widget);
+    gtk_container_add (GTK_CONTAINER (desktop_plugin), widget);
     init_applet_position();
 
     /* start value for random */
@@ -1054,7 +1076,10 @@ animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
     priv->short_timer = 0;
     /* 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);
+
+   
     //sleep(2);
 }
 
@@ -1063,7 +1088,8 @@ lw_applet_finalize (GObject *object)
 {
      AWallpaperPlugin *desktop_plugin = Animation_Wallpaper_HOME_PLUGIN (object);
      Animation_WallpaperPrivate *priv = desktop_plugin->priv;
-
+     
+     fprintf(stderr,"finalaze %i\n", priv->long_timer);
      if (priv->long_timer){
         g_source_remove(priv->long_timer);
         priv->long_timer = 0;