* 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
*/
/*******************************************************************************/
#include "livewp-scene.h"
+/* This code form X11-utils */
+Window Window_With_Name( Display *dpy, Window top, char *name)
+{
+ Window *children, dummy;
+ unsigned int nchildren;
+ int i;
+ Window w=0;
+ char *window_name;
+
+ XClassHint *class_hint;
+ class_hint = XAllocClassHint();
+ XGetClassHint(dpy, top, class_hint);
+ if (class_hint->res_name && name && !strcmp(class_hint->res_name, name)){
+ XFree(class_hint->res_class);
+ XFree(class_hint->res_name);
+ return(top);
+ }
+ XFree(class_hint->res_class);
+ XFree(class_hint->res_name);
+
+ if (XFetchName(dpy, top, &window_name) && !strcmp(window_name, name))
+ return(top);
+
+ if (!XQueryTree(dpy, top, &dummy, &dummy, &children, &nchildren))
+ return(0);
+
+ for (i=0; i<nchildren; i++) {
+ w = Window_With_Name(dpy, children[i], name);
+ if (w)
+ break;
+ }
+ if (children) XFree ((char *)children);
+ return(w);
+}
+
+/*******************************************************************************/
void
destroy_scene(AWallpaperPlugin *desktop_plugin)
{
+ int status = 0;
+
if (desktop_plugin->priv->scene){
GSList * tmp = desktop_plugin->priv->scene->actors;
while (tmp != NULL){
- destroy_actor(tmp->data);
- tmp = g_slist_next(tmp);
+ destroy_actor(tmp->data);
+ tmp = g_slist_next(tmp);
}
if (tmp)
- g_slist_free(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;
+ g_free(desktop_plugin->priv->scene);
+ desktop_plugin->priv->scene = NULL;
}
}
+ if (desktop_plugin->priv->pipeline){
+ gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_NULL);
+ gst_object_unref (GST_OBJECT (desktop_plugin->priv->pipeline));
+ desktop_plugin->priv->pipeline = NULL;
+ }
+ if (desktop_plugin->priv->podpid > 1){
+ kill (desktop_plugin->priv->podpid, SIGTERM);
+ while (TRUE){
+ if (wait(&status) == desktop_plugin->priv->podpid)
+ break;
+ }
+ desktop_plugin->priv->podpid = -1;
+ desktop_plugin->priv->running = FALSE;
+ }
}
-
+/*******************************************************************************/
void
reload_scene(AWallpaperPlugin *desktop_plugin)
{
- fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme);
+ fprintf(stderr,"Reload scene %s\n", desktop_plugin->priv->theme);
destroy_scene(desktop_plugin);
+ fill_priv(desktop_plugin->priv);
+ gtk_widget_destroy(desktop_plugin->priv->window);
+ if (desktop_plugin->priv->one_in_all_view && desktop_plugin->priv->view >1)
+ exit(-1);
+ create_xwindow(desktop_plugin->priv);
init_scene_theme(desktop_plugin);
}
+/*******************************************************************************/
+void
+init_scene_Accel(AWallpaperPlugin *desktop_plugin)
+{
+ Actor *actor;
+ Scene *scene;
+ GPtrArray *child;
+ gint now = time(NULL);
+ gchar *str;
+ gchar *bgfile = NULL;
+ gint sizes1[4] = {57, 76, 43, 50},
+ n, j;
+
+ /* fprintf(stderr, "init scene accel\n"); */
+ scene = g_new0(Scene, 1);
+ scene->actors = NULL;
+ desktop_plugin->priv->scene = scene;
+
+ bgfile = g_strdup_printf("/home/user/.backgrounds/background-%i.png", desktop_plugin->priv->view);
+ actor = init_object(desktop_plugin, "original", bgfile,
+ 0, 0, 0, 800, 480,
+ TRUE, TRUE, 100, 255,
+ NULL, NULL, NULL);
+ scene->actors = g_slist_append(scene->actors, actor);
+
+ child = g_ptr_array_sized_new(16);
+
+ for (j= 0; j<4; j++){
+ for (n=0; n<4; n++){
+ str = g_strdup_printf("tape%i.png", n+1);
+ actor = init_object(desktop_plugin, "tape", str,
+ fast_rnd(800), fast_rnd(480), 2+fast_rnd(6), 800, sizes1[n],
+ TRUE, TRUE, 100, 255,
+ NULL, NULL, NULL);
+ scene->actors = g_slist_append(scene->actors, actor);
+ g_ptr_array_add(child, actor);
+ g_free(str);
+ }
+ }
+ actor = init_object(desktop_plugin, "tape", "",
+ 0, 800, 5, 800, 170,
+ FALSE, FALSE, 100, 255,
+ (gpointer)&change_tape, NULL, child);
+ actor->time_start_animation = now;
+ actor->duration_animation = G_MAXINT;
+ scene->actors = g_slist_append(scene->actors, actor);
+ run_long_timeout(desktop_plugin);
+}
+/*******************************************************************************/
void
parsestring(char *line, char **argv)
{
}
#endif
+/*******************************************************************************/
+static gboolean
+bus_call (GstBus *bus, GstMessage *msg, AWallpaperPlugin *desktop_plugin)
+{
+ switch (GST_MESSAGE_TYPE (msg))
+ {
+ case GST_MESSAGE_EOS:
+ if (desktop_plugin->priv->rich_animation){
+
+ GstClockTime nach = (GstClockTime)(0 * GST_MSECOND);
+ if (!gst_element_seek(desktop_plugin->priv->pipeline, 1.0, GST_FORMAT_TIME,
+ (GstSeekFlags) (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT), GST_SEEK_TYPE_SET,
+ nach, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
+ fprintf(stderr,"ERROR in seek\n");
+
+ gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PLAYING);
+
+ }else{
+ if (desktop_plugin->priv->pipeline){
+ gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_NULL);
+ gst_object_unref (GST_OBJECT (desktop_plugin->priv->pipeline));
+ }
+ }
+ break;
+ case GST_MESSAGE_ERROR: break;
+ default: break;
+ }
+ return TRUE;
+}
+
+/*******************************************************************************/
+void
+init_scene_External(AWallpaperPlugin *desktop_plugin){
+
+ char* child_argv[2048];
+ char *run_string = NULL;
+ gchar *exec_path = NULL,
+ *window_id = NULL,
+ *window_name = NULL,
+ *view = NULL,
+ *strwin = NULL,
+ *strview =NULL;
+ gint i;
+ Window id_xwindow;
+ fprintf(stderr,"init_scene_External1\n");
+ if (!desktop_plugin->priv->visible)
+ return;
+
+ fprintf(stderr,"init_scene_External2\n");
+ exec_path = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "exec_path"));
+ window_id = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "window_id"));
+ view = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "view"));
+ window_name = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "window_name"));
+ if (!exec_path)
+ return;
+ if (window_id){
+ strwin = g_strdup_printf(" %s %i", window_id, (gint)GDK_WINDOW_XID(desktop_plugin->priv->window->window));
+ }else
+ strwin = "";
+
+ if (view){
+ strview = g_strdup_printf(" %s %i", view, desktop_plugin->priv->view);
+ }else
+ strview = "";
+
+ run_string = g_strdup_printf("%s%s%s", exec_path, strwin, strview);
+ fprintf(stderr, "runs string = %s\n", run_string);
+ parsestring(run_string, child_argv);
+
+ desktop_plugin->priv->running = TRUE;
+ desktop_plugin->priv->podpid = fork();
+ if (desktop_plugin->priv->podpid == 0){
+ execvp(child_argv[0], child_argv);
+ fprintf(stderr,"Problem with new podprocess");
+ }
+ g_free(run_string);
+
+ fprintf(stderr, "window name = %s\n", window_name);
+ if (window_name){
+ /* Do 10 trying to search of window */
+ for (i=0; i<10; i++){
+ sleep(1);
+ id_xwindow = Window_With_Name(GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window),
+ RootWindow( GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window), XDefaultScreen( GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window))),
+ window_name);
+ //fprintf(stderr,"name %s %i %i\n", window_name, id_xwindow, i);
+ if (id_xwindow>0){
+ if (desktop_plugin->priv->one_in_all_view)
+ set_live_bg (GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window),
+ id_xwindow, -1);
+ else
+ set_live_bg (GDK_WINDOW_XDISPLAY (desktop_plugin->priv->window->window),
+ id_xwindow, desktop_plugin->priv->view);
+ /* gtk_widget_destroy(desktop_plugin->priv->window); */
+ break;
+ }
+ }
+ }
+}
+/*******************************************************************************/
+gboolean
+cb_timeout0(AWallpaperPlugin *desktop_plugin) {
+
+ if (!desktop_plugin || !desktop_plugin->priv->pipeline)
+ return FALSE;
+ if (desktop_plugin->priv->theme_int_parametr1 == 0){
+ if (!gst_element_seek((GstElement *)GST_PIPELINE (desktop_plugin->priv->pipeline), 1.0, GST_FORMAT_TIME,
+ GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,
+ desktop_plugin->priv->theme_int_parametr1 * GST_SECOND,
+ GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
+ fprintf(stderr,"Error in seek:\n");
+ return FALSE;
+ }
+
+ if (gst_element_get_state (desktop_plugin->priv->pipeline, NULL, NULL, -1) == GST_STATE_CHANGE_FAILURE)
+ return TRUE;
+ else{
+ if (!gst_element_seek((GstElement *)GST_PIPELINE (desktop_plugin->priv->pipeline), 1.0, GST_FORMAT_TIME,
+ GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,
+ desktop_plugin->priv->theme_int_parametr1 * GST_SECOND,
+ GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
+ fprintf(stderr,"Error in seek:\n");
+ return FALSE;
+ }
+}
+/*******************************************************************************/
void
init_scene_Video(AWallpaperPlugin *desktop_plugin)
{
GstElement *bin;
GstElement *videosink;
- GstFormat format;
+ gchar *file_plus_uri;
-
- desktop_plugin->priv->pipeline= gst_pipeline_new("gst-player");
+ /* fprintf(stderr, "init scene Video \n"); */
+ desktop_plugin->priv->pipeline = gst_pipeline_new("gst-player");
bin = gst_element_factory_make ("playbin2", "bin");
videosink = gst_element_factory_make ("ximagesink", "videosink");
g_object_set (G_OBJECT (bin), "video-sink", videosink, NULL);
{
GstBus *bus;
bus = gst_pipeline_get_bus (GST_PIPELINE (desktop_plugin->priv->pipeline));
-// gst_bus_add_watch(bus, bus_call, NULL);
+ gst_bus_add_watch(bus, (GstBusFunc)bus_call, desktop_plugin);
gst_object_unref (bus);
}
- g_object_set (G_OBJECT (bin), "uri", "file:///home/user/MyDocs/.videos/9.mp4", NULL );
+ file_plus_uri = g_strdup_printf("file://%s",desktop_plugin->priv->theme_string_parametr1);
+ g_object_set (G_OBJECT (bin), "uri", file_plus_uri, NULL );
+#if 0
+ /* Doesn't work in real device. Hardware volume buttons can to change volume for mutted track */
+ /* Set Mute */
+ if (!desktop_plugin->priv->theme_bool_parametr1)
+ g_object_set (G_OBJECT (bin), "mute", TRUE, NULL );
+#endif
g_object_set (G_OBJECT (videosink), "force-aspect-ratio", TRUE, NULL );
+
if (GST_IS_X_OVERLAY (videosink))
gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (videosink), GDK_DRAWABLE_XID(desktop_plugin->priv->window->window));
- gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PLAYING);
-}
+ if (desktop_plugin->priv->visible){
+ g_timeout_add(50, (GSourceFunc)cb_timeout0, desktop_plugin);
+ gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PLAYING);
+ }
+
+ //gst_element_get_state(deskddtop_plugin->priv->pipeline, NULL, NULL, 100 * GST_MSECOND);
+
+}
+/*******************************************************************************/
void
init_scene_Matrix(AWallpaperPlugin *desktop_plugin)
{
run_long_timeout(desktop_plugin);
}
-
+/*******************************************************************************/
/* Init Modern Scene */
void
init_scene_Modern(AWallpaperPlugin *desktop_plugin)
scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim);
#endif
}
-
+/*******************************************************************************/
/* Init Berlin Scene */
void
init_scene_Berlin(AWallpaperPlugin *desktop_plugin)
run_long_timeout(desktop_plugin);
}
-
+/*******************************************************************************/
void
init_scene_theme(AWallpaperPlugin *desktop_plugin)
{
+#if 0
void (*func)(gpointer);
func = g_hash_table_lookup(desktop_plugin->priv->hash_scene_func, desktop_plugin->priv->theme);
if (func){
(*func)(desktop_plugin);
}
+#endif
+ fprintf(stderr, "Init_scene_theme\n");
+ void (*func)(gpointer);
+ func = desktop_plugin->priv->scene_func;
+ if (func){
+ fprintf(stderr, "Success init_scene_theme\n");
+ (*func)(desktop_plugin);
+ }
}