From: tanya Date: Thu, 30 Sep 2010 13:25:11 +0000 (+0300) Subject: started slideshow X-Git-Url: https://vcs.maemo.org/git/?p=livewp;a=commitdiff_plain;h=9c465d9bd80c62dd68c586c372b0568198084d48 started slideshow --- diff --git a/applet/src/livewp-actor.c b/applet/src/livewp-actor.c index 30f8002..b12a2c5 100644 --- a/applet/src/livewp-actor.c +++ b/applet/src/livewp-actor.c @@ -1,21 +1,21 @@ /*vim: set sw=4 ts=4 et: */ /* * This file is part of Live Wallpaper (livewp) - * + * * Copyright (C) 2010 Vlad Vasiliev * Copyright (C) 2010 Tanya Makova * for the code - * + * * This software is free software; you can redistribute it and/or * 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 * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA @@ -38,7 +38,7 @@ expose_event (GtkWidget *widget,GdkEventExpose *event, { cairo_t *cr; GdkPixbuf *pixbuf = (GdkPixbuf *) data; - + cr = gdk_cairo_create(widget->window); if (cr){ gdk_cairo_region(cr, event->region); @@ -59,23 +59,23 @@ destroy_hildon_actor(Actor *actor) } void -create_hildon_actor_text(Actor *actor, AWallpaperPlugin *desktop_plugin) +create_hildon_actor_text(Actor *actor, AWallpaperPlugin *desktop_plugin) { GtkWidget *ha = NULL; GtkWidget *label = NULL; ha = hildon_animation_actor_new(); - label = gtk_label_new(NULL); + label = gtk_label_new(NULL); if (label){ //g_signal_connect(G_OBJECT(label), "expose_event", G_CALLBACK(expose_event), NULL); gtk_container_add (GTK_CONTAINER (ha), label); - } + } realize(ha); gtk_widget_show(label); gtk_widget_show_all(ha); - + /* TO DO check it */ /* gdk_flush (); */ @@ -89,7 +89,7 @@ create_hildon_actor_text(Actor *actor, AWallpaperPlugin *desktop_plugin) } void -create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) +create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) { GtkWidget *ha = NULL; GdkPixbuf *pixbuf = NULL; @@ -99,12 +99,13 @@ create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) ha = hildon_animation_actor_new(); if (!strcmp(actor->name, "original")) str = g_strdup(actor->filename); - else - str = g_strdup_printf( "%s/%s/%s", THEME_PATH, + else + str = g_strdup_printf( "%s/%s/%s", THEME_PATH, desktop_plugin->priv->theme, actor->filename); - pixbuf = gdk_pixbuf_new_from_file_at_size (str, - actor->width, - actor->height, + /* fprintf(stderr, "create hildon actor file=%s\n", str); */ + pixbuf = gdk_pixbuf_new_from_file_at_size (str, + actor->width, + actor->height, NULL); if (str) g_free(str); @@ -116,10 +117,10 @@ create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) g_signal_connect(G_OBJECT(image), "expose_event", G_CALLBACK(expose_event), pixbuf); gtk_container_add (GTK_CONTAINER (ha), image); - } + } realize(ha); gtk_widget_show_all(ha); - + /* TO DO check it */ /* gdk_flush (); */ @@ -140,12 +141,12 @@ change_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) GdkPixbuf *pixbuf = NULL; gchar *str = NULL; - str = g_strdup_printf( "%s/%s/%s", THEME_PATH, + str = g_strdup_printf( "%s/%s/%s", THEME_PATH, desktop_plugin->priv->theme, actor->filename); - - pixbuf = gdk_pixbuf_new_from_file_at_size (str, - actor->width, - actor->height, + + pixbuf = gdk_pixbuf_new_from_file_at_size (str, + actor->width, + actor->height, NULL); if(str) g_free(str); @@ -153,12 +154,12 @@ change_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) image = gtk_image_new_from_pixbuf (pixbuf); g_object_unref(G_OBJECT(pixbuf)); } - if (image){ + if (image){ g_signal_connect(G_OBJECT(image), "expose_event", G_CALLBACK(expose_event), pixbuf); //if (g_object_get_data(G_OBJECT(actor->widget), "image")){ if (actor->image){ - gtk_container_remove(GTK_CONTAINER(actor->widget), actor->image); + gtk_container_remove(GTK_CONTAINER(actor->widget), actor->image); } //g_object_set_data(G_OBJECT(actor->widget), "image", image); actor->image = image; @@ -172,19 +173,19 @@ change_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) } } -Actor* -init_object(AWallpaperPlugin *desktop_plugin, - gchar * name, - gchar * filename, - gint x, - gint y, - gint z, - gint width, - gint height, - gboolean visible, +Actor* +init_object(AWallpaperPlugin *desktop_plugin, + gchar * name, + gchar * filename, + gint x, + gint y, + gint z, + gint width, + gint height, + gboolean visible, gboolean load_image, - gint scale, - gint opacity, + gint scale, + gint opacity, void (*pfunc_change)(Actor*), void (*pfunc_probability)(Actor*), GPtrArray *child @@ -202,20 +203,20 @@ init_object(AWallpaperPlugin *desktop_plugin, actor->opacity = opacity; actor->filename = g_strdup(filename); actor->name = g_strdup(name); - actor->func_change = (gpointer)pfunc_change; + actor->func_change = (gpointer)pfunc_change; actor->func_probability = (gpointer)pfunc_probability; actor->child = child; if (load_image){ create_hildon_actor(actor, desktop_plugin); } - else + else actor->widget = NULL; actor->time_start_animation = 0; actor->duration_animation = 0; return actor; } -void +void destroy_actor(Actor *actor) { if (actor){ @@ -231,7 +232,7 @@ destroy_actor(Actor *actor) g_free(actor); } } -static gint +static gint path_line(gint x0, gint x1, double t) { // уравниение прямой @@ -241,8 +242,8 @@ void set_actor_scale(Actor *actor, double scalex, double scaley) { hildon_animation_actor_set_scale( - HILDON_ANIMATION_ACTOR(actor->widget), - scalex, + HILDON_ANIMATION_ACTOR(actor->widget), + scalex, scaley ); @@ -259,7 +260,7 @@ set_actor_rotation(Actor *actor, gint axis, double degrees, gint x, gint y, gint z ); } -void +void set_actor_visible(Actor *actor, gboolean visible) { hildon_animation_actor_set_show(HILDON_ANIMATION_ACTOR(actor->widget), visible); @@ -269,9 +270,9 @@ void set_actor_position(Actor *actor, gint x, gint y, gint z, AWallpaperPlugin *desktop_plugin) { //fprintf(stderr, "set actor position %d, %d, %d\n", x, y, z); - hildon_animation_actor_set_position_full(HILDON_ANIMATION_ACTOR (actor->widget), - x-desktop_plugin->priv->xapplet, - y-desktop_plugin->priv->yapplet, + hildon_animation_actor_set_position_full(HILDON_ANIMATION_ACTOR (actor->widget), + x-desktop_plugin->priv->xapplet, + y-desktop_plugin->priv->yapplet, z); } @@ -306,7 +307,7 @@ gchar * read_notification() { gchar *message = ""; gint count = 0; - + fprintf(stderr, "read notification \n"); count = get_notify_count("general_missed"); if (count > 0){ @@ -378,51 +379,51 @@ change_obj(Actor *actor, AWallpaperPlugin *desktop_plugin) } -void +void change_billboard(Actor * actor, AWallpaperPlugin *desktop_plugin) { gint count = 0; Actor *a = NULL; - - //fprintf(stderr, "change_billboard\n"); - + + //fprintf(stderr, "change_billboard\n"); + if (desktop_plugin->priv->scene->notification < time(NULL)){ count = get_notify_count("general_missed"); a = g_ptr_array_index(actor->child, 0); if (count > 0){ - set_actor_visible(a, TRUE); + set_actor_visible(a, TRUE); }else { set_actor_visible(a, FALSE); } count = get_notify_count("general_sms"); a = g_ptr_array_index(actor->child, 3); if (count > 0){ - set_actor_visible(a, TRUE); + set_actor_visible(a, TRUE); }else { set_actor_visible(a, FALSE); } count = get_notify_count("general_chat"); a = g_ptr_array_index(actor->child, 1); if (count > 0){ - set_actor_visible(a, TRUE); + set_actor_visible(a, TRUE); }else { set_actor_visible(a, FALSE); } count = get_notify_count("qgn_list_messagin"); a = g_ptr_array_index(actor->child, 2); if (count > 0){ - set_actor_visible(a, TRUE); + set_actor_visible(a, TRUE); }else { set_actor_visible(a, FALSE); } desktop_plugin->priv->scene->notification = FALSE; } - actor->time_start_animation = time(NULL) + 20; + actor->time_start_animation = time(NULL) + 20; } #if 0 -void +void change_billboard1(Actor * actor, AWallpaperPlugin *desktop_plugin) { GtkWidget *label; @@ -433,7 +434,7 @@ change_billboard1(Actor * actor, AWallpaperPlugin *desktop_plugin) gint call_count=0, sms_count=0, rc=0; GtkListStore *list = NULL; PangoFontDescription *pfd = NULL; - + rc = sqlite3_open("/home/user/.rtcom-eventlogger/el.db", &db); if (rc){ fprintf(stderr, "error open db %d %s\n", rc, sqlite3_errmsg(db)); @@ -474,19 +475,19 @@ change_billboard1(Actor * actor, AWallpaperPlugin *desktop_plugin) gtk_widget_modify_font(GTK_WIDGET(label), NULL); gtk_widget_modify_font(GTK_WIDGET(label), pfd); pango_font_description_free(pfd); - actor->time_start_animation = time(NULL) + 20; + actor->time_start_animation = time(NULL) + 20; } #endif -void +void change_moon(Actor * actor, AWallpaperPlugin *desktop_plugin) { gint phase; char *newfile; gint x0 = 150, - x1 = 650, + x1 = 650, x, y; - struct timeval tvb; + struct timeval tvb; suseconds_t ms; long sec; double t; @@ -499,7 +500,7 @@ change_moon(Actor * actor, AWallpaperPlugin *desktop_plugin) fprintf(stderr, "a=%f, b=%f, c=%f\n", a, b, c); #endif gettimeofday(&tvb, NULL); - + ms = tvb.tv_usec; sec = tvb.tv_sec; @@ -520,7 +521,7 @@ change_moon(Actor * actor, AWallpaperPlugin *desktop_plugin) t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation; if (t <= 1) x = path_line(x0, x1, t); - else + else x = path_line(x1, x0, t-1); y = 0.001920*x*x - 1.536*x + 337.2; //y = a*x*x + b*x + c; @@ -536,12 +537,12 @@ change_moon(Actor * actor, AWallpaperPlugin *desktop_plugin) fprintf(stderr, "destroy moon \n"); destroy_hildon_actor(actor); actor->time_start_animation = 0; - } + } } - + } -void +void change_sun(Actor * actor, AWallpaperPlugin *desktop_plugin) { double alt, azm; @@ -564,28 +565,28 @@ change_sun(Actor * actor, AWallpaperPlugin *desktop_plugin) actor->visible = FALSE; destroy_hildon_actor(actor); actor->time_start_animation = 0; - } + } } - + } -void +void change_tram(Actor * actor, AWallpaperPlugin *desktop_plugin) { gint x0 = -300, y0 = 225, scale0 = 100, - x1 = 800, y1 = 162, scale1 = 130, + x1 = 800, y1 = 162, scale1 = 130, x, y, scale; - struct timeval tvb; + struct timeval tvb; suseconds_t ms; long sec; double t; //fprintf(stderr, "change tram\n"); gettimeofday(&tvb, NULL); - + ms = tvb.tv_usec; sec = tvb.tv_sec; - + if (!actor->visible){ actor->visible = TRUE; if (desktop_plugin->priv->scene->daytime == TIME_NIGHT){ @@ -617,19 +618,19 @@ void change_plane1(Actor *actor, AWallpaperPlugin *desktop_plugin) { gint x0 = 620, y0 = 233, - x1 = 79, y1 = -146, + x1 = 79, y1 = -146, x, y; - struct timeval tvb; + struct timeval tvb; suseconds_t ms; long sec; double t; gettimeofday(&tvb, NULL); - + ms = tvb.tv_usec; sec = tvb.tv_sec; // fprintf(stderr, "1 %f - %d\n", sec+(double)ms/100000, now); - + if (desktop_plugin->priv->scene->daytime != TIME_NIGHT){ if (actor->time_start_animation == 0){ actor->time_start_animation = sec + fast_rnd(180); @@ -649,9 +650,9 @@ change_plane1(Actor *actor, AWallpaperPlugin *desktop_plugin) /* stop animation */ actor->visible = FALSE; destroy_hildon_actor(actor); - if (desktop_plugin->priv->scene->daytime == TIME_NIGHT) + if (desktop_plugin->priv->scene->daytime == TIME_NIGHT) actor->time_start_animation = 0; - else + else actor->time_start_animation = sec + fast_rnd(180); } @@ -661,15 +662,15 @@ void change_plane2(Actor *actor, AWallpaperPlugin *desktop_plugin) { gint x0 = -actor->width, y0 = 45, - x1 = 800, y1 = 20, + x1 = 800, y1 = 20, x, y; - struct timeval tvb; + struct timeval tvb; suseconds_t ms; long sec; double t; gettimeofday(&tvb, NULL); - + ms = tvb.tv_usec; sec = tvb.tv_sec; // fprintf(stderr, "1 %f - %d\n", sec+(double)ms/100000, now); @@ -693,9 +694,9 @@ change_plane2(Actor *actor, AWallpaperPlugin *desktop_plugin) /* stop animation */ actor->visible = FALSE; destroy_hildon_actor(actor); - if (desktop_plugin->priv->scene->daytime == TIME_NIGHT) + if (desktop_plugin->priv->scene->daytime == TIME_NIGHT) actor->time_start_animation = 0; - else + else actor->time_start_animation = sec + fast_rnd(180); } @@ -705,9 +706,9 @@ void change_cloud(Actor *actor, AWallpaperPlugin *desktop_plugin) { gint x0, y0 = 300, scale0 = 100, - x1, y1 = -actor->height, scale1 = 150, + x1, y1 = -actor->height, scale1 = 150, x, y, scale; - struct timeval tvb; + struct timeval tvb; suseconds_t ms; long sec; double t; @@ -715,25 +716,25 @@ change_cloud(Actor *actor, AWallpaperPlugin *desktop_plugin) //fprintf(stderr, "change cloud\n"); gettimeofday(&tvb, NULL); - + ms = tvb.tv_usec; sec = tvb.tv_sec; - + if (!actor->visible){ actor->visible = TRUE; if (desktop_plugin->priv->scene->daytime == TIME_NIGHT){ newfile = g_strdup_printf("%s_dark.png", actor->name); }else{ newfile = g_strdup_printf("%s.png", actor->name); - } + } if (actor->filename) g_free(actor->filename); actor->filename = newfile; - + create_hildon_actor(actor, desktop_plugin); } t = (double)((double)sec+(double)ms/1000000 - actor->time_start_animation) / actor->duration_animation; - + if (desktop_plugin->priv->scene->wind_orientation == 1){ x0 = -actor->width; x1 = 800; @@ -743,7 +744,7 @@ change_cloud(Actor *actor, AWallpaperPlugin *desktop_plugin) x1 = -actor->width; } - x = path_line(x0, x1, t); + x = path_line(x0, x1, t); y = -desktop_plugin->priv->scene->wind_angle * (x - x0) + actor->y; scale = path_line(scale0, scale1, (double)(y - y0)/(y1 - y0)); @@ -769,7 +770,7 @@ change_wind(Actor *actor, AWallpaperPlugin *desktop_plugin) //fprintf(stderr, "change wind orient = %d angle = %f after = %d\n", scene.wind_orientation, scene.wind_angle, actor->time_start_animation-time(NULL)); } -void +void change_window1(Actor * actor, AWallpaperPlugin *desktop_plugin) { gint now = time(NULL); @@ -791,14 +792,14 @@ change_window1(Actor * actor, AWallpaperPlugin *desktop_plugin) if (!actor->visible) actor->visible = TRUE; - else + else actor->visible = FALSE; set_actor_visible(actor, actor->visible); actor->time_start_animation = now + fast_rnd(60) + 10; } -void +void change_signal(Actor * actor, AWallpaperPlugin *desktop_plugin) { gint now = time(NULL); @@ -806,14 +807,14 @@ change_signal(Actor * actor, AWallpaperPlugin *desktop_plugin) a = g_ptr_array_index(actor->child, 0); if (a->visible) a->visible = FALSE; - else + else a->visible = TRUE; set_actor_visible(a, a->visible); - + a = g_ptr_array_index(actor->child, 1); if (a->visible) a->visible = FALSE; - else + else a->visible = TRUE; set_actor_visible(a, a->visible); @@ -827,7 +828,7 @@ change_tape(Actor *actor, AWallpaperPlugin *desktop_plugin) Actor *a; if (!desktop_plugin->priv->rich_animation) return; - + char * accel_filename = "/sys/class/i2c-adapter/i2c-3/3-001d/coord"; //char * accel_filename = "/home/tanya/coord"; @@ -836,7 +837,7 @@ change_tape(Actor *actor, AWallpaperPlugin *desktop_plugin) fd = fopen(accel_filename, "r"); if (fd == NULL){ //fprintf(stderr, "cannot open file\n"); - fd = fopen("/home/user/coord", "r"); + fd = fopen("/home/user/coord", "r"); } rs = fscanf((FILE*)fd, "%i %i %i", &ax, &ay, &az); fclose(fd); @@ -867,17 +868,17 @@ change_tape(Actor *actor, AWallpaperPlugin *desktop_plugin) if (a->scale > 360) a->scale = 0; if (a->scale < 0) a->scale = 360; } - + x = a->x - (float)cos(a->scale*M_PI/180)*a->z; y = a->y - (float)sin(a->scale*M_PI/180)*a->z; //x = round(a->x - (float)cos(a->scale*M_PI/180)*a->z); //y = round(a->y - (float)sin(a->scale*M_PI/180)*a->z); //x = a->x - cos(angle)*a->z; //y = a->y - sin(angle)*a->z; - if ((a->scale > 270 || a->scale < 90) && x < -a->width*cos(a->scale*M_PI/180)){ - x = 800; + if ((a->scale > 270 || a->scale < 90) && x < -a->width*cos(a->scale*M_PI/180)){ + x = 800; y = fast_rnd(480); - } + } if ((a->scale > 90 && a->scale < 270) && x > 800 - a->width*cos(a->scale*M_PI/180)){ x = 0; y = fast_rnd(480); @@ -896,7 +897,38 @@ change_tape(Actor *actor, AWallpaperPlugin *desktop_plugin) a->x = x; a->y = y; } - + +} + +void +change_slideshow(Actor *actor, AWallpaperPlugin *desktop_plugin) +{ + gint num, next, prev, now; + Actor *a; + num = actor->scale; + prev = actor->opacity; + now = time(NULL); + srand(now); + next = rand()%num; + while (num > 1 && next == prev) + next = rand()%num; + + fprintf(stderr, "change slideshow num=%d prev=%d next=%d\n", num, prev, next); + + if (prev > -1){ + //hide prev + fprintf(stderr, "desctory %d\n", prev); + a = g_ptr_array_index(actor->child, prev); + a->visible = FALSE; + destroy_hildon_actor(a); + } + //show next + fprintf(stderr, "show %d\n", next); + a = g_ptr_array_index(actor->child, next); + a->visible = TRUE; + create_hildon_actor(a, desktop_plugin); + actor->opacity = next; + actor->time_start_animation = now + 5; } void @@ -912,7 +944,7 @@ change_layer(Actor * actor, AWallpaperPlugin *desktop_plugin) if (y > 480) y = -480; set_actor_position(a, a->x, y, a->z, desktop_plugin); a->y = y; - + a = g_ptr_array_index(actor->child, 1); y = a->y + speed1; if (y > 480) y = -480; @@ -932,18 +964,18 @@ change_layer(Actor * actor, AWallpaperPlugin *desktop_plugin) a->y = y; } -void +void change_static_actor(Actor * actor, AWallpaperPlugin *desktop_plugin) { gchar *newfile; - newfile = g_strdup_printf("%s%d.png", actor->name, desktop_plugin->priv->scene->daytime); + newfile = g_strdup_printf("%s%d.png", actor->name, desktop_plugin->priv->scene->daytime); if (actor->filename) g_free(actor->filename); actor->filename = newfile; change_hildon_actor(actor, desktop_plugin); } -void +void change_static_actor_with_corner(Actor * actor, AWallpaperPlugin *desktop_plugin) { gchar buffer[2048]; diff --git a/applet/src/livewp-actor.h b/applet/src/livewp-actor.h index 5866f3c..13499e8 100644 --- a/applet/src/livewp-actor.h +++ b/applet/src/livewp-actor.h @@ -1,21 +1,21 @@ /*vim: set sw=4 ts=4 et: */ /* * This file is part of Live Wallpaper (livewp) - * + * * Copyright (C) 2010 Vlad Vasiliev * Copyright (C) 2010 Tanya Makova * for the code - * + * * This software is free software; you can redistribute it and/or * 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 * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA @@ -25,7 +25,7 @@ #ifndef _livewp_actor_h #define _livewp_actor_h 1 -#include "livewp-common.h" +#include "livewp-common.h" #include #include "livewp-rules.h" #include @@ -43,7 +43,7 @@ struct _Actor gint width; gint height; gint scale; - gint opacity; + gint opacity; gboolean visible; void (*func_change)(gpointer, gpointer); time_t time_start_animation; @@ -54,24 +54,24 @@ struct _Actor }; /*******************************************************************************/ -Actor* init_object(AWallpaperPlugin *desktop_plugin, - gchar * name, - gchar * filename, - gint x, - gint y, - gint z, - gint width, - gint height, - gboolean visible, +Actor* init_object(AWallpaperPlugin *desktop_plugin, + gchar * name, + gchar * filename, + gint x, + gint y, + gint z, + gint width, + gint height, + gboolean visible, gboolean load_image, - gint scale, - gint opacity, + gint scale, + gint opacity, void (*pfunc_change)(Actor*), void (*pfunc_probability)(Actor*), GPtrArray *child ); void destroy_hildon_actor(Actor *actor); -void create_hildon_actor_text(Actor *actor, AWallpaperPlugin *desktop_plugin); +void create_hildon_actor_text(Actor *actor, AWallpaperPlugin *desktop_plugin); void create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin); void change_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin); void destroy_actor(Actor *actor); @@ -81,6 +81,7 @@ void set_actor_rotation(Actor *actor, gint axis, double degrees, gint x, gint y, void set_actor_visible(Actor *actor, gboolean visible); void change_obj(Actor * actor, AWallpaperPlugin *desktop_plugin); void change_tape(Actor * actor, AWallpaperPlugin *desktop_plugin); +void change_slideshow(Actor * actor, AWallpaperPlugin *desktop_plugin); void change_billboard(Actor * actor, AWallpaperPlugin *desktop_plugin); void change_moon(Actor * actor, AWallpaperPlugin *desktop_plugin); void change_sun(Actor * actor, AWallpaperPlugin *desktop_plugin); diff --git a/applet/src/livewp-config.c b/applet/src/livewp-config.c index 60b78db..59bd7ec 100644 --- a/applet/src/livewp-config.c +++ b/applet/src/livewp-config.c @@ -1,21 +1,21 @@ /* vim: set sw=4 ts=4 et: */ /* * This file is part of Live Wallpaper (livewp) - * + * * Copyright (C) 2010 Vlad Vasiliev * Copyright (C) 2010 Tanya Makova * for the code - * + * * This software is free software; you can redistribute it and/or * 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 * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA @@ -24,7 +24,7 @@ /*******************************************************************************/ #include "livewp-config.h" /*******************************************************************************/ -gint +gint current_active_view(void){ GConfClient *gconf_client = NULL; gint result = -1; @@ -41,7 +41,7 @@ current_active_view(void){ /*******************************************************************************/ #ifdef APPLICATION -void +void fill_priv(Animation_WallpaperPrivate *priv) { /* Reset data */ @@ -59,7 +59,9 @@ fill_priv(Animation_WallpaperPrivate *priv) priv->scene_func = (gpointer)&init_scene_Matrix; if (!strcmp(priv->theme, "Video")) priv->scene_func = (gpointer)&init_scene_Video; - + if (!strcmp(priv->theme, "Slideshow")) + priv->scene_func = (gpointer)&init_scene_Slideshow; + priv->extheme_list = get_list_exthemes(); GSList *store = priv->extheme_list; while (store){ @@ -80,7 +82,7 @@ fill_priv(Animation_WallpaperPrivate *priv) } #endif /*******************************************************************************/ -gint +gint read_config(Animation_WallpaperPrivate *priv) { GConfClient *gconf_client = NULL; @@ -98,10 +100,10 @@ read_config(Animation_WallpaperPrivate *priv) { str = g_strdup_printf("%s%i", GCONF_KEY_THEME, id); tmp = gconf_client_get_string(gconf_client, str, NULL); - if (str){ + if (str){ g_free(str); str = NULL; - } + } if (tmp){ priv->theme = tmp; }else @@ -109,10 +111,10 @@ read_config(Animation_WallpaperPrivate *priv) { /* get Rich animation default TRUE */ str = g_strdup_printf("%s%i", GCONF_KEY_RANIMATION, id); value = gconf_client_get(gconf_client, str, NULL); - if (str){ + if (str){ g_free(str); str = NULL; - } + } if (value) { priv->rich_animation = gconf_value_get_bool(value); gconf_value_free(value); @@ -121,10 +123,10 @@ read_config(Animation_WallpaperPrivate *priv) { /* get theme additional bool aparametr 1 default TRUE */ str = g_strdup_printf("%s%i", GCONF_KEY_ADDITIONAL_BOOL_1, id); value = gconf_client_get(gconf_client, str, NULL); - if (str){ + if (str){ g_free(str); str = NULL; - } + } if (value) { priv->theme_bool_parametr1 = gconf_value_get_bool(value); gconf_value_free(value); @@ -134,14 +136,14 @@ read_config(Animation_WallpaperPrivate *priv) { /* get theme additional parameter 1 */ str = g_strdup_printf("%s%i", GCONF_KEY_ADDITIONAL_STRING_1 , id); value = gconf_client_get(gconf_client, str, NULL); - if (str){ + if (str){ g_free(str); str = NULL; - } + } if (value) { priv->theme_string_parametr1 = g_strdup(gconf_value_get_string(value)); gconf_value_free(value); - } + } /* get parameter one theme in all view */ priv->one_in_all_view = get_one_in_all_views_from_config(); return 0; @@ -199,7 +201,7 @@ save_config(Animation_WallpaperPrivate *priv) { fprintf(stderr, _("Failed to initialize GConf. Quitting.\n")); return; } - + if (priv->theme){ str = g_strdup_printf("%s%i", GCONF_KEY_THEME, id); gconf_client_set_string(gconf_client, @@ -264,10 +266,10 @@ get_count_themes_from_config(gchar *theme_name){ for (i=1; i<=9; i++){ str = g_strdup_printf("%s%i", GCONF_KEY_THEME, i); value = gconf_client_get_string(gconf_client, str, NULL); - if (str){ + if (str){ g_free(str); str = NULL; - } + } if (value && !strcmp(value, theme_name)){ count++; } diff --git a/applet/src/livewp-config.h b/applet/src/livewp-config.h index 16943fd..b3b2c1d 100644 --- a/applet/src/livewp-config.h +++ b/applet/src/livewp-config.h @@ -1,21 +1,21 @@ /* vim: set sw=4 ts=4 et: */ /* * This file is part of Live Wallpaper (livewp) - * + * * Copyright (C) 2010 Vlad Vasiliev * Copyright (C) 2010 Tanya Makova * for the code - * + * * This software is free software; you can redistribute it and/or * 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 * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA @@ -42,8 +42,9 @@ void init_scene_External(AWallpaperPlugin *desktop_plugin); void init_scene_theme(AWallpaperPlugin *desktop_plugin); void init_scene_Conky(AWallpaperPlugin *desktop_plugin); void init_scene_Flash(AWallpaperPlugin *desktop_plugin); -gint read_config(Animation_WallpaperPrivate *priv); -void save_config(Animation_WallpaperPrivate *priv); +void init_scene_Slideshow(AWallpaperPlugin *desktop_plugin); +gint read_config(Animation_WallpaperPrivate *priv); +void save_config(Animation_WallpaperPrivate *priv); void fill_priv(Animation_WallpaperPrivate *priv); gint current_active_view(void); GSList * get_list_exthemes(void); diff --git a/applet/src/livewp-main.c b/applet/src/livewp-main.c index 84abdda..8482706 100644 --- a/applet/src/livewp-main.c +++ b/applet/src/livewp-main.c @@ -1,21 +1,21 @@ /* vim: set sw=4 ts=4 et: */ /* * This file is part of Live Wallpaper (livewp) - * + * * Copyright (C) 2010 Vlad Vasiliev * Copyright (C) 2010 Tanya Makova * for the code - * + * * This software is free software; you can redistribute it and/or * 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 * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA @@ -37,7 +37,7 @@ gboolean long_timeout (AWallpaperPlugin *desktop_plugin); void conky_visible(AWallpaperPlugin *desktop_plugin); void flash_visible(AWallpaperPlugin *desktop_plugin); -void +void set_live_bg (Display *display, Window xwindow, int mode){ Atom atom; atom = XInternAtom (display, "_HILDON_LIVE_DESKTOP_BACKGROUND", False); @@ -63,7 +63,7 @@ void view_state_changed (Animation_WallpaperPrivate *priv) { fprintf(stderr," VIew %i State %i\n", priv->view, priv->visible); - if (priv->visible){ + if (priv->visible){ /* ToDo make undependent function */ /* For Video */ if (!strcmp(priv->theme,"Video")){ @@ -123,7 +123,7 @@ view_state_changed (Animation_WallpaperPrivate *priv) } /*******************************************************************************/ gboolean -check_alive_event(Animation_WallpaperPrivate *priv) +check_alive_event(Animation_WallpaperPrivate *priv) { if ( time(NULL) - priv->last_alive_event > 10*60) /* If last event later 10 minute */ quit_from_program(priv); @@ -156,7 +156,7 @@ quit_from_program (Animation_WallpaperPrivate *priv) fprintf(stderr,"quit_from_program\n"); if (priv){ livewp_deinitialize_dbus(priv); - if (priv->view_notify != 0) { + if (priv->view_notify != 0) { gconf_client_notify_remove (gconf_client_get_default (), priv->view_notify); priv->view_notify = 0; } @@ -175,7 +175,7 @@ quit_from_program (Animation_WallpaperPrivate *priv) priv->desktop_plugin = NULL; g_free(priv); priv = NULL; - } + } fprintf(stderr,"end of quit_from_program\n"); gtk_main_quit();; } @@ -201,11 +201,11 @@ short_timeout (AWallpaperPlugin *desktop_plugin) tmp = desktop_plugin->priv->scene->actors; while (tmp != NULL){ actor = tmp->data; - if (now >= actor->time_start_animation + if (now >= actor->time_start_animation && actor->time_start_animation > 0 /* && now - actor->time_start_animation <= actor->duration_animation*/){ pfunc = actor->func_change; - if (pfunc){ + if (pfunc){ (*pfunc)(actor, desktop_plugin); stop_flag = FALSE; } @@ -222,8 +222,7 @@ short_timeout (AWallpaperPlugin *desktop_plugin) void run_long_timeout(AWallpaperPlugin *desktop_plugin) { - - gint daytime = get_daytime(); + gint daytime = get_daytime(); GSList * tmp; void (*pfunc)(gpointer, gpointer); time_t now; @@ -244,13 +243,13 @@ run_long_timeout(AWallpaperPlugin *desktop_plugin) tmp = g_slist_next(tmp); } } - + now = time(NULL); //fprintf(stderr, "Now %d\n", now); tmp = desktop_plugin->priv->scene->actors; while (tmp != NULL){ actor = tmp->data; - if (now >= actor->time_start_animation + if (now >= actor->time_start_animation && actor->time_start_animation > 0 && desktop_plugin->priv->short_timer == 0){ /* fprintf(stderr, "start short timer act = %s %d\n", actor->name, now); */ @@ -264,7 +263,7 @@ run_long_timeout(AWallpaperPlugin *desktop_plugin) } tmp = g_slist_next(tmp); } - + } /*******************************************************************************/ gboolean @@ -282,7 +281,7 @@ long_timeout (AWallpaperPlugin *desktop_plugin) gst_object_unref (GST_OBJECT (desktop_plugin->priv->pipeline)); desktop_plugin->priv->pipeline = NULL; } - return TRUE; + return TRUE; } if (desktop_plugin->priv->long_timer == 0 ) @@ -335,22 +334,22 @@ main(int argc, char *argv[]) HildonProgram *app; int view = 1; - - if (argc == 2) + + if (argc == 2) view = atoi(argv[1]); if (view < 1 || view > 9) view = 1; AWallpaperPlugin *desktop_plugin = g_new0 (AWallpaperPlugin, 1); Animation_WallpaperPrivate *priv = g_new0 (Animation_WallpaperPrivate, 1); - desktop_plugin->priv = priv; + desktop_plugin->priv = priv; /* Ininitializing */ hildon_gtk_init (&argc, &argv); app = HILDON_PROGRAM (hildon_program_get_instance()); g_set_application_name (PACKAGE); - + priv->osso = osso_initialize("org.maemo.livewp", VERSION, TRUE, NULL); if(!priv->osso){ fprintf(stderr,"osso_initialize failed\n"); @@ -378,20 +377,20 @@ main(int argc, char *argv[]) /* Check activity of opition "One theme in all views" */ if (priv->one_in_all_view && view >1) - return -1; + return -1; - if (current_active_view() == view && !priv->one_in_all_view) + if (current_active_view() == view && !priv->one_in_all_view) priv->visible = TRUE; - else + else priv->visible = FALSE; create_xwindow(priv); /* Initialize DBUS */ livewp_initialize_dbus(priv); - - priv->view_notify = 0; + + priv->view_notify = 0; /* fprintf(stderr,"VISIBLE %i %i\n",priv->visible, current_active_view()); */ gconf_client_add_dir(gconf_client_get_default (), "/apps/osso/hildon-desktop/views", GCONF_CLIENT_PRELOAD_NONE, NULL); priv->view_notify = gconf_client_notify_add(gconf_client_get_default (),"/apps/osso/hildon-desktop/views/current", @@ -404,10 +403,10 @@ main(int argc, char *argv[]) } init_scene_theme(desktop_plugin); - + priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin); - priv->alive_timer = g_timeout_add(60000*10, (GtkFunction)check_alive_event, priv); /* One per 10 minute */ + priv->alive_timer = g_timeout_add(60000*10, (GtkFunction)check_alive_event, priv); /* One per 10 minute */ gtk_main(); return 0; } diff --git a/applet/src/livewp-scene.c b/applet/src/livewp-scene.c index 04b28de..840003a 100644 --- a/applet/src/livewp-scene.c +++ b/applet/src/livewp-scene.c @@ -1,28 +1,29 @@ /* vim: set sw=4 ts=4 et: */ /* * This file is part of Live Wallpaper (livewp) - * + * * Copyright (C) 2010 Vlad Vasiliev * Copyright (C) 2010 Tanya Makova * for the code - * + * * This software is free software; you can redistribute it and/or * 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 * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ /*******************************************************************************/ -#include "livewp-scene.h" +#include "livewp-scene.h" + /* This code form X11-utils */ Window Window_With_Name( Display *dpy, Window top, char *name) { @@ -60,11 +61,11 @@ Window Window_With_Name( Display *dpy, Window top, char *name) /*******************************************************************************/ -void +void destroy_scene(AWallpaperPlugin *desktop_plugin) { int status = 0; - + if (desktop_plugin->priv->scene){ GSList * tmp = desktop_plugin->priv->scene->actors; while (tmp != NULL){ @@ -92,9 +93,9 @@ destroy_scene(AWallpaperPlugin *desktop_plugin) kill (desktop_plugin->priv->podpid, SIGKILL); } while (TRUE){ - if (wait(&status) == desktop_plugin->priv->podpid) + if (wait(&status) == desktop_plugin->priv->podpid) break; - } + } desktop_plugin->priv->podpid = -1; desktop_plugin->priv->running = FALSE; } @@ -103,17 +104,17 @@ destroy_scene(AWallpaperPlugin *desktop_plugin) 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); + gtk_widget_destroy(desktop_plugin->priv->window); if (desktop_plugin->priv->one_in_all_view && desktop_plugin->priv->view >1) - exit(-1); + exit(-1); create_xwindow(desktop_plugin->priv); init_scene_theme(desktop_plugin); } /*******************************************************************************/ -void +void init_scene_Accel(AWallpaperPlugin *desktop_plugin) { Actor *actor; @@ -124,21 +125,21 @@ init_scene_Accel(AWallpaperPlugin *desktop_plugin) 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, + 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); @@ -151,9 +152,9 @@ init_scene_Accel(AWallpaperPlugin *desktop_plugin) g_free(str); } } - actor = init_object(desktop_plugin, "tape", "", - 0, 800, 5, 800, 170, - FALSE, FALSE, 100, 255, + 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; @@ -162,22 +163,22 @@ init_scene_Accel(AWallpaperPlugin *desktop_plugin) run_long_timeout(desktop_plugin); } /*******************************************************************************/ -void +void parsestring(char *line, char **argv) { - while (*line != '\0') { + while (*line != '\0') { while (*line == ' ' || *line == '\n') *line++ = '\0'; /* replace white spaces with 0 */ *argv++ = line; /* save the argument position */ - while (*line != '\0' && *line != ' ' && - *line != '\n') + while (*line != '\0' && *line != ' ' && + *line != '\n') line++; /* skip the argument until ... */ } *argv = '\0'; /* mark the end of argument list */ } #if 0 -GstBusSyncReply +GstBusSyncReply sync_handler(GstBus *bus, GstMessage *message, AWallpaperPlugin *desktop_plugin){ if (!desktop_plugin->priv->visible) @@ -198,12 +199,12 @@ bus_call (GstBus *bus, GstMessage *msg, AWallpaperPlugin *desktop_plugin) { switch (GST_MESSAGE_TYPE (msg)) { - case GST_MESSAGE_EOS: + 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, + (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"); @@ -213,7 +214,7 @@ bus_call (GstBus *bus, GstMessage *msg, AWallpaperPlugin *desktop_plugin) 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; @@ -243,14 +244,14 @@ init_scene_External(AWallpaperPlugin *desktop_plugin){ Window id_xwindow; if (!desktop_plugin->priv->visible) return; - + 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")); gtk_socket_id = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "gtk_socket_id")); addedstring = g_strdup(g_hash_table_lookup(desktop_plugin->priv->hash_theme, "added_string")); - if (!exec_path) + if (!exec_path) return; if (window_id){ strwin = g_strdup_printf(" %s %i", window_id, (gint)GDK_WINDOW_XID(desktop_plugin->priv->window->window)); @@ -293,16 +294,16 @@ init_scene_External(AWallpaperPlugin *desktop_plugin){ /* 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), + 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), + 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), + 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; @@ -311,37 +312,37 @@ init_scene_External(AWallpaperPlugin *desktop_plugin){ } } /*******************************************************************************/ -gboolean +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, + 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) + + 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, + 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; + GstElement *bin; + GstElement *videosink; gchar *file_plus_uri; @@ -372,95 +373,162 @@ init_scene_Video(AWallpaperPlugin *desktop_plugin) gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (videosink), GDK_DRAWABLE_XID(desktop_plugin->priv->window->window)); if (desktop_plugin->priv->visible){ - g_timeout_add(50, (GSourceFunc)cb_timeout0, desktop_plugin); + 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) +init_scene_Slideshow(AWallpaperPlugin *desktop_plugin) { - Actor *actor; - Scene *scene; - GPtrArray *child; - gint now = time(NULL); - gint y1, y2; - - if (desktop_plugin->priv->rich_animation){ - y1 = -480; - y2 = -480-480; - }else { - y1 = 0; - y2 = -480; - } - - /* fprintf(stderr, "init scene2 \n"); */ - scene = g_new0(Scene, 1); - //scene.daytime = get_daytime(); - scene->actors = NULL; - desktop_plugin->priv->scene = scene; - - actor = init_object(desktop_plugin, "background", "bg.png", - 0, 0, 5, 800, 480, - TRUE, TRUE, 100, 255, - NULL, NULL, NULL); - scene->actors = g_slist_append(scene->actors, actor); - - actor = init_object(desktop_plugin, "symbols", "symbols.png", - 0, 0, 10, 800, 480, - TRUE, TRUE, 100, 255, - NULL, NULL, NULL); - scene->actors = g_slist_append(scene->actors, actor); - - child = g_ptr_array_sized_new(4); - actor = init_object(desktop_plugin, "layer1", "layer1_2.png", - 0, y1, 6, 800, 960, - TRUE, TRUE, 100, 255, - NULL, NULL, NULL); - //actor->time_start_animation = now; - //actor->duration_animation = G_MAXINT; - scene->actors = g_slist_append(scene->actors, actor); - g_ptr_array_add(child, actor); - - actor = init_object(desktop_plugin, "layer1", "layer1_1.png", - 0, y2, 7, 800, 960, - TRUE, TRUE, 100, 255, - NULL, NULL, NULL); - //actor->time_start_animation = now; - //actor->duration_animation = G_MAXINT; - scene->actors = g_slist_append(scene->actors, actor); - g_ptr_array_add(child, actor); - - actor = init_object(desktop_plugin, "layer2", "layer2_2.png", - 0, y1, 8, 800, 960, - TRUE, TRUE, 100, 255, - NULL, NULL, NULL); - //actor->time_start_animation = now; - //actor->duration_animation = G_MAXINT; - scene->actors = g_slist_append(scene->actors, actor); - g_ptr_array_add(child, actor); + gchar *ext, *file, *str; + Dirent *dp; + DIR *dir_fd; + int i; + Actor *actor; + Scene *scene; + GPtrArray *child; + gint now = time(NULL); + GSList *store = NULL; + gint num = 0; + + fprintf(stderr, "init scene Slideshow \n"); + + scene = g_new0(Scene, 1); + scene->actors = NULL; + desktop_plugin->priv->scene = scene; + + dir_fd = opendir(desktop_plugin->priv->theme_string_parametr1); + if(dir_fd){ + while((dp = readdir(dir_fd))){ + if(!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) + continue; + + ext = strrchr(dp->d_name, '.') + 1; /* get file extension */ + if (!ext) continue; + /* lowercase string */ + for(i=0; ext[i]; i++) + ext[i] = tolower(ext[i]); + if (strcmp(ext, "jpg") && strcmp(ext, "png")) + continue; + if(dp->d_type == DT_REG || dp->d_type == DT_LNK){ + str = g_strdup_printf("%s/%s", desktop_plugin->priv->theme_string_parametr1, dp->d_name); + store = g_slist_append(store, str); + fprintf(stderr, "%s\n", str); + num++; + } + } + closedir(dir_fd); + } - actor = init_object(desktop_plugin, "layer2", "layer2_1.png", - 0, y2, 9, 800, 960, - TRUE, TRUE, 100, 255, - NULL, NULL, NULL); - //actor->time_start_animation = now; - //actor->duration_animation = G_MAXINT; - scene->actors = g_slist_append(scene->actors, actor); - g_ptr_array_add(child, actor); + child = g_ptr_array_sized_new(num); + while (store){ + fprintf(stderr, "file=%s\n", store->data); + + actor = init_object(desktop_plugin, "original", store->data, + 0, 0, 5, 800, 480, + FALSE, FALSE, 100, 255, + NULL, NULL, NULL); + scene->actors = g_slist_append(scene->actors, actor); + g_ptr_array_add(child, actor); + store = g_slist_next(store); + } + actor = init_object(desktop_plugin, "images", "", + 0, 0, 5, 800, 480, + FALSE, FALSE, num, -1, + (gpointer)&change_slideshow, NULL, child); + actor->time_start_animation = now; + actor->duration_animation = G_MAXINT; + scene->actors = g_slist_append(scene->actors, actor); + desktop_plugin->priv->rich_animation = TRUE; + run_long_timeout(desktop_plugin); - actor = init_object(desktop_plugin, "layers", "", - 0, y2, 9, 800, 960, - FALSE, FALSE, 100, 255, - (gpointer)&change_layer, NULL, child); - actor->time_start_animation = now; - actor->duration_animation = G_MAXINT; - scene->actors = g_slist_append(scene->actors, actor); +} +/*******************************************************************************/ +void +init_scene_Matrix(AWallpaperPlugin *desktop_plugin) +{ + Actor *actor; + Scene *scene; + GPtrArray *child; + gint now = time(NULL); + gint y1, y2; + + if (desktop_plugin->priv->rich_animation){ + y1 = -480; + y2 = -480-480; + }else { + y1 = 0; + y2 = -480; + } - run_long_timeout(desktop_plugin); + /* fprintf(stderr, "init scene matrix \n"); */ + scene = g_new0(Scene, 1); + //scene.daytime = get_daytime(); + scene->actors = NULL; + desktop_plugin->priv->scene = scene; + + actor = init_object(desktop_plugin, "background", "bg.png", + 0, 0, 5, 800, 480, + TRUE, TRUE, 100, 255, + NULL, NULL, NULL); + scene->actors = g_slist_append(scene->actors, actor); + + actor = init_object(desktop_plugin, "symbols", "symbols.png", + 0, 0, 10, 800, 480, + TRUE, TRUE, 100, 255, + NULL, NULL, NULL); + scene->actors = g_slist_append(scene->actors, actor); + + child = g_ptr_array_sized_new(4); + actor = init_object(desktop_plugin, "layer1", "layer1_2.png", + 0, y1, 6, 800, 960, + TRUE, TRUE, 100, 255, + NULL, NULL, NULL); + //actor->time_start_animation = now; + //actor->duration_animation = G_MAXINT; + scene->actors = g_slist_append(scene->actors, actor); + g_ptr_array_add(child, actor); + + actor = init_object(desktop_plugin, "layer1", "layer1_1.png", + 0, y2, 7, 800, 960, + TRUE, TRUE, 100, 255, + NULL, NULL, NULL); + //actor->time_start_animation = now; + //actor->duration_animation = G_MAXINT; + scene->actors = g_slist_append(scene->actors, actor); + g_ptr_array_add(child, actor); + + actor = init_object(desktop_plugin, "layer2", "layer2_2.png", + 0, y1, 8, 800, 960, + TRUE, TRUE, 100, 255, + NULL, NULL, NULL); + //actor->time_start_animation = now; + //actor->duration_animation = G_MAXINT; + scene->actors = g_slist_append(scene->actors, actor); + g_ptr_array_add(child, actor); + + actor = init_object(desktop_plugin, "layer2", "layer2_1.png", + 0, y2, 9, 800, 960, + TRUE, TRUE, 100, 255, + NULL, NULL, NULL); + //actor->time_start_animation = now; + //actor->duration_animation = G_MAXINT; + scene->actors = g_slist_append(scene->actors, actor); + g_ptr_array_add(child, actor); + + actor = init_object(desktop_plugin, "layers", "", + 0, y2, 9, 800, 960, + FALSE, FALSE, 100, 255, + (gpointer)&change_layer, 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); } /*******************************************************************************/ @@ -473,7 +541,7 @@ init_scene_Modern(AWallpaperPlugin *desktop_plugin) gint now = time(NULL); gint i; gint winds[13][2]; - GPtrArray *child; + GPtrArray *child; /* fprintf(stderr, "init scene \n"); */ scene = g_new0(Scene, 1); @@ -485,91 +553,91 @@ init_scene_Modern(AWallpaperPlugin *desktop_plugin) scene->seed = time(NULL); scene->notification = TRUE; desktop_plugin->priv->scene = scene; - actor = init_object(desktop_plugin, "sky", "sky0.png", - 0, 0, 5, 800, 480, - TRUE , TRUE, 100, 255, + actor = init_object(desktop_plugin, "sky", "sky0.png", + 0, 0, 5, 800, 480, + TRUE , TRUE, 100, 255, (gpointer)&change_static_actor, NULL, NULL); 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, - FALSE, FALSE, 100, 255, + + actor = init_object(desktop_plugin, "sun", "sun.png", + 0, 0, 6, 88, 88, + FALSE, FALSE, 100, 255, (gpointer)&change_sun, NULL, NULL); actor->time_start_animation = now; actor->duration_animation = G_MAXINT; change_sun(actor, desktop_plugin); scene->actors = g_slist_append(scene->actors, actor); - //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50, + //actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50, // TRUE, 100, 255, NULL, NULL); //scene.actors = g_slist_append(scene.actors, actor); - - actor = init_object(desktop_plugin, "cloud1", "cloud1.png", - 0, fast_rnd(300)-97, 7, 150, 97, - FALSE, FALSE, 100, 255, + + actor = init_object(desktop_plugin, "cloud1", "cloud1.png", + 0, fast_rnd(300)-97, 7, 150, 97, + FALSE, FALSE, 100, 255, (gpointer)&change_cloud, NULL, NULL); actor->time_start_animation = now + fast_rnd(20); actor->duration_animation = 3*60; scene->actors = g_slist_append(scene->actors, actor); - - actor = init_object(desktop_plugin, "cloud2", "cloud2.png", - 0, fast_rnd(300)-75, 7, 188, 75, - FALSE, FALSE, 100, 255, + + actor = init_object(desktop_plugin, "cloud2", "cloud2.png", + 0, fast_rnd(300)-75, 7, 188, 75, + FALSE, FALSE, 100, 255, (gpointer)&change_cloud, NULL, NULL); actor->time_start_animation = now + fast_rnd(40)+10; actor->duration_animation = 3*60; scene->actors = g_slist_append(scene->actors, actor); - actor = init_object(desktop_plugin, "cloud4", "cloud4.png", - 0, fast_rnd(300)-75, 7, 150, 75, - FALSE, FALSE, 100, 255, + actor = init_object(desktop_plugin, "cloud4", "cloud4.png", + 0, fast_rnd(300)-75, 7, 150, 75, + FALSE, FALSE, 100, 255, (gpointer)&change_cloud, NULL, NULL); actor->time_start_animation = now + fast_rnd(60) + 20; actor->duration_animation = 5*60; scene->actors = g_slist_append(scene->actors, actor); - actor = init_object(desktop_plugin, "town", "town0.png", - 0, 0, 8, 800, 480, - TRUE, TRUE, 100, 255, + actor = init_object(desktop_plugin, "town", "town0.png", + 0, 0, 8, 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); - actor = init_object(desktop_plugin, "stend", "stend0.png", - 452, 166, 9, 300, 305, - TRUE, TRUE, 100, 255, + actor = init_object(desktop_plugin, "stend", "stend0.png", + 452, 166, 9, 300, 305, + TRUE, TRUE, 100, 255, (gpointer)&change_static_actor, NULL, NULL); change_static_actor(actor, desktop_plugin); scene->actors = g_slist_append(scene->actors, actor); child = g_ptr_array_sized_new(4); - actor = init_object(desktop_plugin, "call", "call.png", - 480, 190, 9, 50, 58, - FALSE, TRUE, 100, 255, + actor = init_object(desktop_plugin, "call", "call.png", + 480, 190, 9, 50, 58, + FALSE, TRUE, 100, 255, NULL, NULL, NULL); scene->actors = g_slist_append(scene->actors, actor); g_ptr_array_add(child, actor); - actor = init_object(desktop_plugin, "chat", "chat.png", - 540, 190, 9, 50, 58, - FALSE, TRUE, 100, 255, + actor = init_object(desktop_plugin, "chat", "chat.png", + 540, 190, 9, 50, 58, + FALSE, TRUE, 100, 255, NULL, NULL, NULL); scene->actors = g_slist_append(scene->actors, actor); g_ptr_array_add(child, actor); - actor = init_object(desktop_plugin, "mail", "mail.png", - 600, 190, 9, 50, 58, - FALSE, TRUE, 100, 255, + actor = init_object(desktop_plugin, "mail", "mail.png", + 600, 190, 9, 50, 58, + FALSE, TRUE, 100, 255, NULL, NULL, NULL); scene->actors = g_slist_append(scene->actors, actor); g_ptr_array_add(child, actor); - - actor = init_object(desktop_plugin, "sms", "sms.png", - 660, 190, 9, 50, 58, - FALSE, TRUE, 100, 255, + + actor = init_object(desktop_plugin, "sms", "sms.png", + 660, 190, 9, 50, 58, + FALSE, TRUE, 100, 255, NULL, NULL, NULL); scene->actors = g_slist_append(scene->actors, actor); g_ptr_array_add(child, actor); @@ -583,31 +651,31 @@ init_scene_Modern(AWallpaperPlugin *desktop_plugin) change_billboard(actor, desktop_plugin); scene->actors = g_slist_append(scene->actors, actor); - actor = init_object(desktop_plugin, "tram", "tram.png", - -300, 225, 10, 350, 210, - FALSE, FALSE, 100, 255, + actor = init_object(desktop_plugin, "tram", "tram.png", + -300, 225, 10, 350, 210, + FALSE, FALSE, 100, 255, (gpointer)&change_tram, NULL, NULL); - actor->time_start_animation = time(NULL) + fast_rnd(10); + actor->time_start_animation = time(NULL) + fast_rnd(10); actor->duration_animation = 60; scene->actors = g_slist_append(scene->actors, actor); - actor = init_object(desktop_plugin, "border", "border0.png", + actor = init_object(desktop_plugin, "border", "border0.png", 0, 480-79, 11, 800, 79, - TRUE, TRUE, 100, 255, + TRUE, TRUE, 100, 255, (gpointer)&change_static_actor_with_corner, NULL, NULL); change_static_actor_with_corner(actor, desktop_plugin); scene->actors = g_slist_append(scene->actors, actor); - - actor = init_object(desktop_plugin, "moon", "moon1.png", - 400, 20, 6, 60, 60, - FALSE, FALSE, 100, 255, + + actor = init_object(desktop_plugin, "moon", "moon1.png", + 400, 20, 6, 60, 60, + FALSE, FALSE, 100, 255, (gpointer)&change_moon, NULL, NULL); change_moon(actor, desktop_plugin); scene->actors = g_slist_append(scene->actors, actor); - actor = init_object(desktop_plugin, "wind", "", - 0, 0, 5, 0, 0, - FALSE, FALSE, 100, 255, + actor = init_object(desktop_plugin, "wind", "", + 0, 0, 5, 0, 0, + FALSE, FALSE, 100, 255, (gpointer)&change_wind, NULL, NULL); change_wind(actor, desktop_plugin); scene->actors = g_slist_append(scene->actors, actor); @@ -625,46 +693,46 @@ init_scene_Modern(AWallpaperPlugin *desktop_plugin) winds[3][0] = 495; winds[3][1] = 190; - + winds[4][0] = 482; winds[4][1] = 201; - + winds[5][0] = 495; winds[5][1] = 210; - + winds[6][0] = 482; winds[6][1] = 222; - + winds[7][0] = 495; winds[7][1] = 221; - + winds[8][0] = 459; winds[8][1] = 203; - + winds[9][0] = 495; winds[9][1] = 241; - + winds[10][0] = 495; winds[10][1] = 252; - + winds[11][0] = 482; winds[11][1] = 273; - + winds[12][0] = 495; winds[12][1] = 303; for (i=0; i<13; i++){ - actor = init_object(desktop_plugin, "window1", "window1.png", - winds[i][0], winds[i][1], 8, 8, 10, - FALSE, FALSE, 100, 255, + actor = init_object(desktop_plugin, "window1", "window1.png", + winds[i][0], winds[i][1], 8, 8, 10, + FALSE, FALSE, 100, 255, (gpointer)&change_window1, NULL, NULL); //change_window1(actor, desktop_plugin); actor->time_start_animation = now + fast_rnd(30); scene->actors = g_slist_append(scene->actors, actor); } - + /* windows in 1-th house */ - + winds[0][0] = 86; winds[0][1] = 321; @@ -676,31 +744,31 @@ init_scene_Modern(AWallpaperPlugin *desktop_plugin) winds[3][0] = 86; winds[3][1] = 286; - + winds[4][0] = 94; winds[4][1] = 232; - + winds[5][0] = 94; winds[5][1] = 243; - + winds[6][0] = 94; winds[6][1] = 265; - + winds[7][0] = 94; winds[7][1] = 331; for (i=0; i<8; i++){ - actor = init_object(desktop_plugin, "window2", "window2.png", - winds[i][0], winds[i][1], 8, 8, 10, - FALSE, FALSE, 100, 255, + actor = init_object(desktop_plugin, "window2", "window2.png", + winds[i][0], winds[i][1], 8, 8, 10, + FALSE, FALSE, 100, 255, (gpointer)&change_window1, NULL, NULL); //change_window1(actor, desktop_plugin); actor->time_start_animation = now + fast_rnd(30); scene->actors = g_slist_append(scene->actors, actor); } - + /* windows in 3-th house */ - + winds[0][0] = 251; winds[0][1] = 162; @@ -712,29 +780,29 @@ init_scene_Modern(AWallpaperPlugin *desktop_plugin) winds[3][0] = 251; winds[3][1] = 289; - + winds[4][0] = 313; winds[4][1] = 173; - + winds[5][0] = 322; winds[5][1] = 160; - + winds[6][0] = 303; winds[6][1] = 217; - + winds[7][0] = 322; winds[7][1] = 224; - + winds[8][0] = 323; winds[8][1] = 217; - + winds[9][0] = 322; winds[9][1] = 288; - + for (i=0; i<10; i++){ - actor = init_object(desktop_plugin, "window3", "window3.png", - winds[i][0], winds[i][1], 8, 8, 10, - FALSE, FALSE, 100, 255, + actor = init_object(desktop_plugin, "window3", "window3.png", + winds[i][0], winds[i][1], 8, 8, 10, + FALSE, FALSE, 100, 255, (gpointer)&change_window1, NULL, NULL); //change_window1(actor, desktop_plugin); actor->time_start_animation = now + fast_rnd(30); @@ -743,7 +811,7 @@ init_scene_Modern(AWallpaperPlugin *desktop_plugin) } /* windows in 5-th house */ - + winds[0][0] = 610; winds[0][1] = 224; @@ -755,20 +823,20 @@ init_scene_Modern(AWallpaperPlugin *desktop_plugin) winds[3][0] = 610; winds[3][1] = 301; - + winds[4][0] = 610; winds[4][1] = 320; - + winds[5][0] = 593; winds[5][1] = 352; - + winds[6][0] = 610; winds[6][1] = 368; - + for (i=0; i<7; i++){ - actor = init_object(desktop_plugin, "window4", "window4.png", - winds[i][0], winds[i][1], 8, 8, 10, - FALSE, FALSE, 100, 255, + actor = init_object(desktop_plugin, "window4", "window4.png", + winds[i][0], winds[i][1], 8, 8, 10, + FALSE, FALSE, 100, 255, (gpointer)&change_window1, NULL, NULL); //change_window1(actor, desktop_plugin); actor->time_start_animation = now + fast_rnd(30); @@ -777,7 +845,7 @@ init_scene_Modern(AWallpaperPlugin *desktop_plugin) } /* windows in 6-th house */ - + winds[0][0] = 717; winds[0][1] = 283; @@ -789,17 +857,17 @@ init_scene_Modern(AWallpaperPlugin *desktop_plugin) winds[3][0] = 717; winds[3][1] = 323; - + winds[4][0] = 698; winds[4][1] = 362; - + winds[5][0] = 698; winds[5][1] = 400; - + for (i=0; i<6; i++){ - actor = init_object(desktop_plugin, "window5", "window5.png", - winds[i][0], winds[i][1], 8, 8, 10, - FALSE, FALSE, 100, 255, + actor = init_object(desktop_plugin, "window5", "window5.png", + winds[i][0], winds[i][1], 8, 8, 10, + FALSE, FALSE, 100, 255, (gpointer)&change_window1, NULL, NULL); //change_window1(actor, desktop_plugin); actor->time_start_animation = now + fast_rnd(30); @@ -808,17 +876,17 @@ init_scene_Modern(AWallpaperPlugin *desktop_plugin) } run_long_timeout(desktop_plugin); -#if 0 +#if 0 anim = g_new0(Animation, 1); anim->count = 1; anim->actor = actor; anim->func_change = &change_tram; anim->func_time = NULL; - anim->timestart = time(NULL); + anim->timestart = time(NULL); anim->timeall = 10; - + scene.dynamic_actors = g_slist_append(scene.dynamic_actors, anim); -#endif +#endif } /*******************************************************************************/ /* Init Berlin Scene */ @@ -828,7 +896,7 @@ init_scene_Berlin(AWallpaperPlugin *desktop_plugin) Actor *actor, *actor1, *actor2; Scene *scene; gint now = time(NULL); - gint i; + gint i; gint winds[13][2]; GPtrArray *child = NULL; @@ -840,16 +908,16 @@ init_scene_Berlin(AWallpaperPlugin *desktop_plugin) /* init value for random */ scene->seed = time(NULL); desktop_plugin->priv->scene = scene; - - actor = init_object(desktop_plugin, "sky", "sky.png", 0, 0, 5, 800, 480, - TRUE, TRUE, 100, 255, + + actor = init_object(desktop_plugin, "sky", "sky.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); - - actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88, - FALSE, FALSE, 100, 255, + + actor = init_object(desktop_plugin, "sun", "sun.png", 0, 0, 6, 88, 88, + FALSE, FALSE, 100, 255, (gpointer)&change_sun, NULL, NULL); actor->time_start_animation = time(NULL); actor->duration_animation = G_MAXINT; @@ -857,86 +925,86 @@ init_scene_Berlin(AWallpaperPlugin *desktop_plugin) scene->actors = g_slist_append(scene->actors, actor); #if 0 - actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50, + actor = init_object(desktop_plugin, "dot", "dot1.png", 0, 0, 11, 50, 50, TRUE, 100, 255, NULL, NULL); scene.actors = g_slist_append(scene.actors, actor); #endif - actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60, - FALSE, FALSE, 100, 255, + actor = init_object(desktop_plugin, "moon", "moon1.png", 400, 15, 6, 60, 60, + FALSE, FALSE, 100, 255, (gpointer)&change_moon, NULL, NULL); change_moon(actor, desktop_plugin); scene->actors = g_slist_append(scene->actors, actor); - - actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97, - FALSE, FALSE, 100, 255, + + actor = init_object(desktop_plugin, "cloud1", "cloud1.png", 0, fast_rnd(300)-97, 7, 150, 97, + FALSE, FALSE, 100, 255, (gpointer)&change_cloud, NULL, NULL); actor->time_start_animation = now + fast_rnd(30) + 10; actor->duration_animation = 3*60; scene->actors = g_slist_append(scene->actors, actor); - - actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75, - FALSE, FALSE, 100, 255, + + actor = init_object(desktop_plugin, "cloud2", "cloud2.png", 0, fast_rnd(300)-75, 7, 188, 75, + FALSE, FALSE, 100, 255, (gpointer)&change_cloud, NULL, NULL); actor->time_start_animation = now + fast_rnd(10); actor->duration_animation = 3*60; scene->actors = g_slist_append(scene->actors, actor); - actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75, - FALSE, FALSE, 100, 255, + actor = init_object(desktop_plugin, "cloud4", "cloud4.png", 0, fast_rnd(300)-75, 7, 150, 75, + FALSE, FALSE, 100, 255, (gpointer)&change_cloud, NULL, NULL); actor->time_start_animation = now + fast_rnd(60) + 20; actor->duration_animation = 5*60; scene->actors = g_slist_append(scene->actors, actor); - - actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50, - FALSE, FALSE, 100, 255, + + actor = init_object(desktop_plugin, "plane2", "plane3.png", 0, 45, 8, 160, 50, + FALSE, FALSE, 100, 255, (gpointer)&change_plane2, NULL, NULL); actor->time_start_animation = now + fast_rnd(40) + 20; actor->duration_animation = 60; scene->actors = g_slist_append(scene->actors, actor); - - actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116, - FALSE, FALSE, 100, 255, + + actor = init_object(desktop_plugin, "plane1", "tu154.png", 620, 233, 9, 300, 116, + FALSE, FALSE, 100, 255, (gpointer)&change_plane1, NULL, NULL); actor->time_start_animation = now + fast_rnd(20); actor->duration_animation = 30; scene->actors = g_slist_append(scene->actors, actor); - actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480, - TRUE, TRUE, 100, 255, + actor = init_object(desktop_plugin, "town", "town.png", 0, 0, 10, 800, 480, + TRUE, TRUE, 100, 255, (gpointer)&change_static_actor_with_corner, NULL, NULL); change_static_actor_with_corner(actor, desktop_plugin); scene->actors = g_slist_append(scene->actors, actor); - actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0, - FALSE, FALSE, 100, 255, + actor = init_object(desktop_plugin, "wind", "", 0, 0, 5, 0, 0, + FALSE, FALSE, 100, 255, (gpointer)&change_wind, NULL, NULL); change_wind(actor, desktop_plugin); scene->actors = g_slist_append(scene->actors, actor); - actor1 = init_object(desktop_plugin, "signal_red", "red.png", - 486, 425, 10, 18, 38, + actor1 = init_object(desktop_plugin, "signal_red", "red.png", + 486, 425, 10, 18, 38, FALSE, TRUE, 100, 255, NULL, NULL, NULL); - //actor->time_start_animation = now + fast_rnd(30) + 10; + //actor->time_start_animation = now + fast_rnd(30) + 10; scene->actors = g_slist_append(scene->actors, actor1); - - actor2 = init_object(desktop_plugin, "signal_green", "green.png", - 486, 425, 10, 18, 38, + + actor2 = init_object(desktop_plugin, "signal_green", "green.png", + 486, 425, 10, 18, 38, TRUE, TRUE, 100, 255, NULL, NULL, NULL); - //actor->time_start_animation = now + fast_rnd(30) + 10; + //actor->time_start_animation = now + fast_rnd(30) + 10; scene->actors = g_slist_append(scene->actors, actor2); child = g_ptr_array_sized_new(2); g_ptr_array_add(child, actor1); g_ptr_array_add(child, actor2); actor = init_object(desktop_plugin, "signal", "", 486, 425, 10, 18, 38, - FALSE, FALSE, 100, 255, + FALSE, FALSE, 100, 255, (gpointer)&change_signal, NULL, child); actor->time_start_animation = now + fast_rnd(30) + 10; scene->actors = g_slist_append(scene->actors, actor); - + winds[0][0] = 389; winds[0][1] = 305; @@ -948,50 +1016,50 @@ init_scene_Berlin(AWallpaperPlugin *desktop_plugin) winds[3][0] = 356; winds[3][1] = 288; - + winds[4][0] = 337; winds[4][1] = 269; - + winds[5][0] = 372; winds[5][1] = 268; - + winds[6][0] = 372; winds[6][1] = 249; - + winds[7][0] = 388; winds[7][1] = 249; - + winds[8][0] = 387; winds[8][1] = 230; - + winds[9][0] = 372; winds[9][1] = 211; - + winds[10][0] = 355; winds[10][1] = 159; - + winds[11][0] = 335; winds[11][1] = 158; - + winds[12][0] = 386; winds[12][1] = 119; - + for (i=0; i<13; i++){ - actor = init_object(desktop_plugin, "window", "window.png", - winds[i][0], winds[i][1], 10, 8, 9, - FALSE, TRUE, 100, 255, + actor = init_object(desktop_plugin, "window", "window.png", + winds[i][0], winds[i][1], 10, 8, 9, + FALSE, TRUE, 100, 255, (gpointer)&change_window1, NULL, NULL); //change_window1(actor, desktop_plugin); actor->time_start_animation = now + fast_rnd(30); scene->actors = g_slist_append(scene->actors, actor); } - + run_long_timeout(desktop_plugin); } /*******************************************************************************/ -void +void init_scene_theme(AWallpaperPlugin *desktop_plugin) { #if 0 @@ -1005,7 +1073,7 @@ init_scene_theme(AWallpaperPlugin *desktop_plugin) void (*func)(gpointer); func = desktop_plugin->priv->scene_func; if (func){ - fprintf(stderr, "Success init_scene_theme\n"); + fprintf(stderr, "Success init_scene_theme %s\n", desktop_plugin->priv->theme); (*func)(desktop_plugin); } } diff --git a/applet/src/livewp-scene.h b/applet/src/livewp-scene.h index 8e30d94..51e67b8 100644 --- a/applet/src/livewp-scene.h +++ b/applet/src/livewp-scene.h @@ -1,20 +1,20 @@ /* * This file is part of Live Wallpaper (livewp) - * + * * Copyright (C) 2010 Vlad Vasiliev * Copyright (C) 2010 Tanya Makova * for the code - * + * * This software is free software; you can redistribute it and/or * 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 * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA @@ -26,13 +26,16 @@ #define _livewp_scene_h 1 #include "livewp-common.h" -#include "livewp-actor.h" +#include "livewp-actor.h" #include #include #include "livewp-rules.h" #include #include #include +#include +#include +typedef struct dirent Dirent; void fill_priv(Animation_WallpaperPrivate *priv); void destroy_scene(AWallpaperPlugin *desktop_plugin); @@ -44,9 +47,10 @@ void init_scene_Berlin(AWallpaperPlugin *desktop_plugin); void init_scene_Matrix(AWallpaperPlugin *desktop_plugin); void init_scene_Accel(AWallpaperPlugin *desktop_plugin); void init_scene_Video(AWallpaperPlugin *desktop_plugin); +void init_scene_Slideshow(AWallpaperPlugin *desktop_plugin); void init_scene_External(AWallpaperPlugin *desktop_plugin); void init_scene_theme(AWallpaperPlugin *desktop_plugin); -void create_hildon_actor_text(Actor *actor, AWallpaperPlugin *desktop_plugin); +void create_hildon_actor_text(Actor *actor, AWallpaperPlugin *desktop_plugin); void set_live_bg (Display *display, Window xwindow, int mode); void create_xwindow (Animation_WallpaperPrivate *priv); #endif diff --git a/applet/src/livewp-settings.c b/applet/src/livewp-settings.c index 30857e1..6bc84fd 100644 --- a/applet/src/livewp-settings.c +++ b/applet/src/livewp-settings.c @@ -239,6 +239,9 @@ changed_value_theme_cb (HildonPickerButton *picker, Animation_WallpaperPrivate * if (!strcmp(choice, _("Flash"))){ additional_parametr_for_theme_flash(vbox, priv); } + if (!strcmp(choice, _("Slideshow"))){ + additional_parametr_for_theme_slideshow(vbox, priv); + } } gtk_widget_show(vbox); @@ -302,7 +305,8 @@ fill_theme_button (Animation_WallpaperPrivate *priv, GtkWidget *button, gchar *c hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Matrix")); hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Accel")); hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Video")); - num = 5; + hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), _("Slideshow")); + num = 6; if (theme){ if (!strcmp(theme, "Berlin")){ hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0); @@ -324,6 +328,10 @@ fill_theme_button (Animation_WallpaperPrivate *priv, GtkWidget *button, gchar *c hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 4); hildon_button_set_value(HILDON_BUTTON(button), _("Video")); } + if (!strcmp(theme, "Slideshow")){ + hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 4); + hildon_button_set_value(HILDON_BUTTON(button), _("Slideshow")); + } } } while (store){ @@ -406,6 +414,10 @@ create_categories_button (Animation_WallpaperPrivate *priv){ hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0); hildon_button_set_value(HILDON_BUTTON(button), "LiveWallpaper"); } + if (!strcmp(theme, "Slideshow")){ + hildon_touch_selector_set_active (HILDON_TOUCH_SELECTOR (selector), 0, 0); + hildon_button_set_value(HILDON_BUTTON(button), "LiveWallpaper"); + } GSList *store = priv->extheme_list; num = 1; while (store){ @@ -463,7 +475,7 @@ create_themes_buttons_hbox(Animation_WallpaperPrivate *priv){ GSList *stlist = NULL; GConfClient *gconf_client = NULL; GConfValue *value = NULL; - guint count_of_view = 1; + guint count_of_view = 1; guint i; @@ -474,7 +486,7 @@ create_themes_buttons_hbox(Animation_WallpaperPrivate *priv){ if (hbox){ gtk_widget_destroy(hbox); } - + hbox = gtk_hbox_new(FALSE, 0); g_object_set_data(G_OBJECT(priv->window), "custom_hbox", hbox); gtk_box_pack_start(GTK_BOX(area_hbox), @@ -506,7 +518,7 @@ create_themes_buttons_hbox(Animation_WallpaperPrivate *priv){ gtk_box_pack_start(GTK_BOX(hbox), theme_button, TRUE, TRUE, 10); gtk_widget_show (theme_button); - } + } } /*******************************************************************************/ void @@ -606,6 +618,24 @@ file_button_clicked(GtkButton *button, Animation_WallpaperPrivate *priv){ } /*******************************************************************************/ void +folder_button_clicked(GtkButton *button, Animation_WallpaperPrivate *priv){ + + GtkWidget *dialog = hildon_file_chooser_dialog_new(GTK_WINDOW (priv->window), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); + + if (priv->theme_string_parametr1) + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), priv->theme_string_parametr1); + + gtk_widget_show_all (GTK_WIDGET (dialog)); + + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) + { + hildon_button_set_value (HILDON_BUTTON(button), gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog))); + } + gtk_widget_destroy (dialog); + +} +/*******************************************************************************/ +void rich_animation_additional_parametr(GtkWidget *vbox, Animation_WallpaperPrivate *priv){ GtkWidget *rich_animation_button; @@ -696,6 +726,29 @@ additional_parametr_for_theme_flash(GtkWidget *vbox, Animation_WallpaperPrivate gtk_widget_show (file_button); } /*******************************************************************************/ +void +additional_parametr_for_theme_slideshow(GtkWidget *vbox, Animation_WallpaperPrivate *priv){ + + GtkWidget *file_button; + GtkWidget *link_button; + GtkWidget *smoothing_button; + GtkWidget *rich_animation_button; + + if (priv->theme_string_parametr1) + file_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT, HILDON_BUTTON_ARRANGEMENT_VERTICAL, + _("Folder with images"), priv->theme_string_parametr1); + else + file_button = hildon_button_new_with_text (HILDON_SIZE_FINGER_HEIGHT,HILDON_BUTTON_ARRANGEMENT_VERTICAL, + _("Folder with images")," "); + + g_signal_connect (file_button, "clicked", G_CALLBACK (folder_button_clicked), priv); + + gtk_box_pack_start(GTK_BOX(vbox), + file_button, TRUE, TRUE, 5); + g_object_set_data(G_OBJECT(priv->window), "filename_button", file_button); + gtk_widget_show (file_button); +} +/*******************************************************************************/ void show_problem_package (GtkWidget *widget, gchar *package_name){ @@ -793,57 +846,7 @@ lw_theme_settings(GtkWidget *button, Animation_WallpaperPrivate *priv) { /* Check theme */ if (hildon_button_get_value(HILDON_BUTTON (theme_button)) && strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), "")){ -#if 0 - /* Check Xsnow program */ - if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Xsnow"))){ - if (access("/usr/bin/xsnow", F_OK) != 0){ - show_problem_package(button, "Xsnow"); - /* if not scuccess exit from wthout saving */ - break; - } - } - /* Check Shermans program */ - if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), "Shermans Aquarium")){ - if (access("/usr/bin/shermans", F_OK) != 0){ - show_problem_package(button,"'Sherman's Aquarium'"); - /* if not scuccess exit from wthout saving */ - break; - } - } - /* Check Conky program */ - if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), "Conky")){ - if (access("/usr/bin/conky", F_OK) != 0){ - show_problem_package(button,"'Conky'"); - /* if not scuccess exit from wthout saving */ - break; - } - } - /* Check Orrery program */ - if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), "Orrery")){ - if (access("/opt/maemo/usr/bin/orrery", F_OK) != 0){ - show_problem_package(button,"'Orrery'"); - /* if not scuccess exit from wthout saving */ - break; - } - } - /* Check CrazyChickens program */ - if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), "CrazyChickens")){ - if (access("/usr/bin/crazychickens", F_OK) != 0){ - show_problem_package(button,"'Crazy Chickens'"); - /* if not scuccess exit from wthout saving */ - break; - } - } - /* Check Colorflood program */ - if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), "Colorflood")){ - if (access("/usr/bin/colorflood", F_OK) != 0){ - show_problem_package(button,"'Colorflood'"); - /* if not scuccess exit from wthout saving */ - break; - } - } -#endif if (priv->theme_string_parametr1){ g_free(priv->theme_string_parametr1); priv->theme_string_parametr1 = NULL; @@ -881,6 +884,15 @@ lw_theme_settings(GtkWidget *button, Animation_WallpaperPrivate *priv) { priv->theme_string_parametr1 = g_strdup((gchar*)hildon_button_get_value (HILDON_BUTTON(button1))); } } + if (!strcmp(hildon_button_get_value(HILDON_BUTTON (theme_button)), _("Slideshow"))){ + priv->theme = g_strdup("Slideshow"); + button1 = g_object_get_data(G_OBJECT(priv->window), "filename_button"); + if (button1){ + if (priv->theme_string_parametr1) + g_free(priv->theme_string_parametr1); + priv->theme_string_parametr1 = g_strdup((gchar*)hildon_button_get_value (HILDON_BUTTON(button1))); + } + } /* Check external themes */ GSList *store = priv->extheme_list; while (store){ @@ -932,7 +944,7 @@ lw_theme_settings(GtkWidget *button, Animation_WallpaperPrivate *priv) { } store = g_slist_next(store); } - + fprintf(stderr, "theme = %s\n", priv->theme); } rich_animation_button = g_object_get_data(G_OBJECT(priv->window), "rich_animation_button");