flash works
[livewp] / applet / src / livewp-main.c
index d11e207..7a267d8 100644 (file)
@@ -7,8 +7,8 @@
  *       for the code
  * 
  * This software is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
+ * 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
@@ -35,12 +35,11 @@ static gboolean short_timeout (AWallpaperPlugin *desktop_plugin);
 void run_long_timeout(AWallpaperPlugin *desktop_plugin);
 gboolean long_timeout (AWallpaperPlugin *desktop_plugin);
 void conky_visible(AWallpaperPlugin *desktop_plugin);
+void flash_visible(AWallpaperPlugin *desktop_plugin);
 
 void 
-set_live_bg (Display *display, Window xwindow, int mode)
-{
+set_live_bg (Display *display, Window xwindow, int mode){
    Atom atom;
-
    atom = XInternAtom (display, "_HILDON_LIVE_DESKTOP_BACKGROUND", False);
    fprintf (stderr, "XID: 0x%x\n", (unsigned)xwindow);
 
@@ -51,7 +50,15 @@ set_live_bg (Display *display, Window xwindow, int mode)
                   (unsigned char *) &mode, 1);
 }
 /*******************************************************************************/
+gboolean
+delayed_pause_video (AWallpaperPlugin *desktop_plugin){
 
+    if (!desktop_plugin->priv->visible){
+        gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PAUSED);
+    }
+    return FALSE;
+}
+/*******************************************************************************/
 void
 view_state_changed (Animation_WallpaperPrivate *priv)
 {
@@ -71,9 +78,14 @@ view_state_changed (Animation_WallpaperPrivate *priv)
            conky_visible(priv->desktop_plugin);
            return;
        }
+       /* For Flash */
+       if (!strcmp(priv->theme,"Flash")&& priv->running){
+           flash_visible(priv->desktop_plugin);
+           return;
+       }
 
        if (!priv->running){
-            if (g_hash_table_lookup(priv->hash_theme, "exec_path")){
+            if (priv->hash_theme && g_hash_table_lookup(priv->hash_theme, "exec_path")){
                 init_scene_External(priv->desktop_plugin);
             }
        }
@@ -86,7 +98,10 @@ view_state_changed (Animation_WallpaperPrivate *priv)
    }else{
         /* For Video */
         if (priv->pipeline){
-           gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
+           if (priv->one_in_all_view)
+                g_timeout_add(200, (GtkFunction)delayed_pause_video, priv->desktop_plugin);
+           else
+                gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
            return;
         }
         /* For Conky */
@@ -94,6 +109,12 @@ view_state_changed (Animation_WallpaperPrivate *priv)
            conky_visible(priv->desktop_plugin);
            return;
         }
+        /* For Flash */
+        if (!strcmp(priv->theme,"Flash")){
+           flash_visible(priv->desktop_plugin);
+           return;
+        }
+
         if (priv->long_timer != 0 ){
             g_source_remove(priv->long_timer);
             priv->long_timer = 0;
@@ -254,7 +275,7 @@ long_timeout (AWallpaperPlugin *desktop_plugin)
 
     /*fprintf(stderr, "long_timeout %i\n", desktop_plugin->priv->long_timer); */
     if (desktop_plugin->priv->pipeline){
-       if (!desktop_plugin->priv->visible){
+       if (!desktop_plugin->priv->visible && !desktop_plugin->priv->theme_bool_parametr1){
                gst_element_query_position(desktop_plugin->priv->pipeline, &fmt, &p);
                desktop_plugin->priv->theme_int_parametr1 = p / GST_SECOND;
                gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_NULL);
@@ -283,14 +304,25 @@ void
 create_xwindow (Animation_WallpaperPrivate *priv){
     GtkWidget *main_widget = NULL;
     GtkWidget *label = NULL;
+
     /* Create Main GUI */
     main_widget = hildon_window_new ();
     priv->window = main_widget;
     gtk_window_set_title(GTK_WINDOW(main_widget), PACKAGE);
     gtk_window_fullscreen(GTK_WINDOW(main_widget));
-    label = gtk_label_new(_("Loading Livewallpaper scene ..."));
-    gtk_container_add (GTK_CONTAINER (main_widget), label);
+
+    /* Check parametr 'gtk_socket_id'. It use in flash player for example */
+    if (g_hash_table_lookup(priv->hash_theme, "gtk_socket_id")){
+        priv->video_socket = gtk_socket_new ();
+        gtk_container_add (GTK_CONTAINER (priv->window), priv->video_socket);
+    }else{
+        label = gtk_label_new(_("Loading Livewallpaper scene ..."));
+        gtk_container_add (GTK_CONTAINER (main_widget), label);
+    }
+
     gtk_widget_show_all(GTK_WIDGET(main_widget));
+
+    /* Set window to background mode */
     if (priv->one_in_all_view)
         set_live_bg(GDK_WINDOW_XDISPLAY (main_widget->window), GDK_WINDOW_XID (main_widget->window), -1);
     else