* 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"
#include <sys/time.h>
#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
#define GCONF_KEY_POSITION "/apps/osso/hildon-desktop/applets/livewp-home-widget.desktop-%i/position"
#define GCONF_KEY_MODIFIED "/apps/osso/hildon-desktop/applets/livewp-home-widget.desktop-%i/modified"
GdkScreen *screen;
gchar * strid;
gint id;
- AWallpaperPlugin *desktop_plugin = widget;
+ AWallpaperPlugin *desktop_plugin = (AWallpaperPlugin *)widget;
char* child_argv[] = {"/usr/bin/livewp", "0", (char *) 0 };
case 3: child_argv[1] = "4";
break;
}
- desktop_plugin->priv->pid = fork();
- if (desktop_plugin->priv->pid == 0){
- execvp("/usr/bin/livewp", child_argv);
- fprintf(stderr,"Problem with new process");
+ desktop_plugin->priv->one_in_all_view = get_one_in_all_views_from_config();
+ /* Check one theme in all view mode */
+ if (!desktop_plugin->priv->one_in_all_view ||
+ (desktop_plugin->priv->one_in_all_view && id == 0)){
+ /* Start a new process */
+ desktop_plugin->priv->pid = fork();
+ if (desktop_plugin->priv->pid == 0){
+ execvp("/usr/bin/livewp", child_argv);
+ fprintf(stderr,"Problem with new process");
+ }
}
- fprintf(stderr,"dssssssddddddddddddddddddd\n");
- desktop_plugin_visible_notify(widget, NULL, desktop_plugin->priv);
-#if 0
- /* Load config */
- read_config(desktop_plugin->priv);
-
- init_scene_theme(desktop_plugin);
-
- desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
-#endif
+
+ desktop_plugin_visible_notify((GObject *)widget, NULL, desktop_plugin);
+
screen = gtk_widget_get_screen (widget);
gtk_widget_set_colormap (widget,
gdk_screen_get_rgba_colormap (screen));
GTK_WIDGET_CLASS (animation_wallpaper_plugin_parent_class)->realize (widget);
}
-
-static gboolean
-lw_applet_expose_event(GtkWidget *widget,
- GdkEventExpose *event)
-{
- cairo_t *cr;
-
- /* Create cairo context */
- cr = gdk_cairo_create (GDK_DRAWABLE (widget->window));
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
-
- /* Draw alpha background */
- cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.0);
- cairo_paint (cr);
-
- /* Free context */
- cairo_destroy (cr);
-
- return GTK_WIDGET_CLASS (animation_wallpaper_plugin_parent_class)->expose_event (widget,
- event);
-}
-
-static gboolean
-expose_event (GtkWidget *widget,GdkEventExpose *event,
- gpointer data)
-{
- cairo_t *cr;
- GdkPixbuf *pixbuf = (GdkPixbuf *) data;
-
- cr = gdk_cairo_create(widget->window);
- if (cr){
- gdk_cairo_region(cr, event->region);
- cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
- gdk_cairo_set_source_pixbuf(cr, pixbuf, 0.0, 0.0);
- cairo_paint(cr);
- cairo_destroy(cr);
- }
- return TRUE;
-}
-
-static void
-realize (GtkWidget *widget)
-{
- GdkScreen *screen;
- screen = gtk_widget_get_screen (widget);
- gtk_widget_set_colormap (widget, gdk_screen_get_rgba_colormap (screen));
-}
/* Set position of widget on desktop */
static void
init_applet_position(gint *xapplet, gint *yapplet)
gconf_client_clear_cache(gconf_client);
g_object_unref(gconf_client);
}
-#if 0
-void
-actor_set_position_full(GtkWidget *actor, gint x, gint y, gint z)
-{
-/* fprintf(stderr, "actor_set_position_full z=%d\n", z); */
- hildon_animation_actor_set_position_full (HILDON_ANIMATION_ACTOR (actor),x-0, y-0, z);
-}
-#endif
-
-void
-destroy_hildon_actor(Actor *actor)
-{
- //fprintf(stderr, "destroy_hildon_actor %s\n",actor->name);
- gtk_widget_destroy(actor->widget);
- actor->widget = NULL;
-}
-
-void
-create_hildon_actor_text(Actor *actor, AWallpaperPlugin *desktop_plugin)
-{
- GtkWidget *ha = NULL;
- GdkPixbuf *pixbuf = NULL;
- GtkWidget *image = NULL;
- GtkWidget *label = NULL;
-
- ha = hildon_animation_actor_new();
- 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 (); */
-
- //g_object_set_data(G_OBJECT(ha), "image", image);
- actor->image = label;
- hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (ha), GTK_WINDOW(desktop_plugin->priv->window));
- actor->widget = ha;
- set_actor_position(actor, actor->x, actor->y, actor->z, desktop_plugin);
- set_actor_scale(actor, (double)actor->scale/100, (double)actor->scale/100);
- set_actor_visible(actor, actor->visible);
-}
-
-
-
-void
-create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin)
-{
- GtkWidget *ha = NULL;
- GdkPixbuf *pixbuf = NULL;
- GtkWidget *image = NULL;
- gchar *str = NULL;
-
- ha = hildon_animation_actor_new();
- 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,
- NULL);
- /* fprintf(stderr, "create_hildon_actor %s %s\n", actor->name, str); */
- if (str)
- g_free(str);
- if (pixbuf){
- image = gtk_image_new_from_pixbuf (pixbuf);
- g_object_unref(G_OBJECT(pixbuf));
- }
- if (image){
- 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 (); */
-
- //g_object_set_data(G_OBJECT(ha), "image", image);
- actor->image = image;
- hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (ha), GTK_WINDOW(desktop_plugin->priv->window));
-
- actor->widget = ha;
- set_actor_position(actor, actor->x, actor->y, actor->z, desktop_plugin);
- set_actor_scale(actor, (double)actor->scale/100, (double)actor->scale/100);
- set_actor_visible(actor, actor->visible);
-}
-
-
-void
-change_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin)
-{
- GtkWidget *image = NULL;
- GdkPixbuf *pixbuf = NULL;
- gchar *str = NULL;
-
- 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,
- NULL);
- if(str)
- g_free(str);
- if (pixbuf){
- image = gtk_image_new_from_pixbuf (pixbuf);
- g_object_unref(G_OBJECT(pixbuf));
- }
- 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);
- }
- //g_object_set_data(G_OBJECT(actor->widget), "image", image);
- actor->image = image;
- gtk_container_add (GTK_CONTAINER (actor->widget), image);
- realize(actor->widget);
- gtk_widget_show_all(actor->widget);
- /* TO DO check it */
- /* gdk_flush (); */
-
-
- }
-
-}
-
-
-static gboolean
-short_timeout (AWallpaperPlugin *desktop_plugin)
-{
- //gint daytime = get_daytime();
- GSList * tmp;
- void (*pfunc)(gpointer, gpointer);
- time_t now;
- Actor *actor;
- gboolean stop_flag = TRUE;
-
-if (!desktop_plugin->priv->visible || !desktop_plugin->priv->rich_animation){
- desktop_plugin->priv->short_timer = 0;
- return FALSE;
- }
-
- now = time(NULL);
- //scene.daytime = daytime;
- /* fprintf(stderr, "Short timer %d\n", now); */
- tmp = desktop_plugin->priv->scene->actors;
- while (tmp != NULL){
- actor = tmp->data;
- 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){
- (*pfunc)(actor, desktop_plugin);
- stop_flag = FALSE;
- }
- }
- tmp = g_slist_next(tmp);
- }
- if (stop_flag){
- desktop_plugin->priv->short_timer = 0;
- return FALSE;
- }else
- return TRUE; /* keep running this event */
-}
-
-void
-run_long_timeout(AWallpaperPlugin *desktop_plugin)
-{
-
- gint daytime = get_daytime();
- GSList * tmp;
- void (*pfunc)(gpointer, gpointer);
- time_t now;
- Actor *actor;
-
- if (!desktop_plugin->priv->scene)
- return;
- /* fprintf(stderr, "!!!run long timeout short_timer=%d\n", desktop_plugin->priv->short_timer); */
- if (desktop_plugin->priv->scene->daytime != daytime){
- desktop_plugin->priv->scene->daytime = daytime;
- tmp = desktop_plugin->priv->scene->actors;
- while (tmp != NULL){
- //change_actor(tmp->data);
- pfunc =((Actor*)tmp->data)->func_change;
- if (pfunc){
- (*pfunc)(tmp->data, 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
- && actor->time_start_animation > 0
- && desktop_plugin->priv->short_timer == 0){
- /* fprintf(stderr, "start short timer act = %s %d\n", actor->name, now); */
- if (desktop_plugin->priv->rich_animation){
- actor->time_start_animation = now;
- desktop_plugin->priv->short_timer = g_timeout_add(SHORT_TIMER, (GtkFunction)short_timeout, desktop_plugin);
- }
- else {
- (*actor->func_change)(actor, desktop_plugin);
- }
- }
- tmp = g_slist_next(tmp);
- }
-
-}
-
-gboolean
-long_timeout (AWallpaperPlugin *desktop_plugin)
-{
- /* fprintf(stderr, "long_timeout %i\n", desktop_plugin->priv->long_timer); */
- if (desktop_plugin->priv->long_timer == 0 )
- return FALSE;
- if (!desktop_plugin->priv->visible){
- if(desktop_plugin->priv->short_timer != 0){
- g_source_remove(desktop_plugin->priv->short_timer);
- desktop_plugin->priv->short_timer = 0;
- }
- desktop_plugin->priv->long_timer = 0;
- return FALSE;
- }
-
-
- run_long_timeout(desktop_plugin);
- return TRUE; /* keep running this event */
-}
void
desktop_plugin_visible_notify (GObject *object,
gboolean visible;
Animation_WallpaperPrivate *priv = desktop_plugin->priv;
g_object_get (object, "is-on-current-desktop", &visible, NULL);
- fprintf (stderr, "is-on-current-desktop changed. visible: %u", visible);
+ fprintf (stderr, "LWP is-on-current-desktop changed. visible: %u", visible);
if (priv){
+ if (priv->one_in_all_view){
+ if (visible)
+ send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
+ LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW1);
+ else{
+ /* start any application on current view */
+ if ((priv->view + 1) == current_active_view())
+ send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
+ LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW1);
+ }
+ return;
+ }
switch (priv->view + 1){
case 1: if (visible)
send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW4);
break;
}
- }
+ }
+
}
gboolean
-rich_animation_press(GtkWidget *widget, GdkEvent *event,
- gpointer user_data){
- fprintf(stderr,"gggggggggggggggggggg2222\n");
- return FALSE;
-}
-
-gboolean
send_alive_event(Animation_WallpaperPrivate *priv)
{
- fprintf(stderr, "send_alive_event\n");
switch (priv->view + 1){
case 1: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
LIVEWP_SIGNAL_PATH, LIVEWP_ALIVE_LIVEBG_ON_VIEW1);
static void
animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
{
- GtkWidget *rich_animation;
- gchar buffer[2048];
- gchar str[128];
//fprintf(stderr, "!!!!!!!plugin init \n");
Animation_WallpaperPrivate *priv = Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
livewp_initialize_dbus(priv);
priv->desktop_plugin = desktop_plugin;
- priv->window = desktop_plugin;
+ priv->window = (GtkWidget *)desktop_plugin;
priv->visible = FALSE;
priv->short_timer = 0;
priv->xapplet = 0;
priv->yapplet = 0;
priv->scene = NULL;
+ priv->pid = 0;
priv->theme = g_strdup("Modern");
-//#if 0
- priv->hash_scene_func = g_hash_table_new(g_str_hash, g_str_equal);
-
- g_hash_table_insert(priv->hash_scene_func, g_strdup("Berlin"), (gpointer)&init_scene_Berlin);
- g_hash_table_insert(priv->hash_scene_func, g_strdup("Modern"), (gpointer)&init_scene_Modern);
- g_hash_table_insert(priv->hash_scene_func, g_strdup("Matrix"), (gpointer)&init_scene_Matrix);
- g_hash_table_insert(priv->hash_scene_func, g_strdup("Accel"), (gpointer)&init_scene_Accel);
- g_hash_table_insert(priv->hash_scene_func, g_strdup("Video"), (gpointer)&init_scene_Video);
- g_hash_table_insert(priv->hash_scene_func, g_strdup("Xsnow"), (gpointer)&init_scene_Video);
-//#endif
//priv->theme = g_strdup("Accel");
desktop_plugin->priv->main_widget = gtk_fixed_new();
destroy_scene(desktop_plugin);
}
*/
-
if (priv){
switch (priv->view + 1){
case 1: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
g_source_remove(priv->alive_timer);
livewp_deinitialize_dbus(priv);
- while (TRUE){
- wpid = wait(&status);
- if (wpid == priv->pid)
- break;
+
+ if (priv->pid >0){
+ while (TRUE){
+ wpid = wait(&status);
+ if (wpid == priv->pid)
+ break;
+ }
}
}
static void
desktop_widget_finalize (GObject *object)
{
- AWallpaperPlugin *desktop_plugin = Animation_Wallpaper_HOME_PLUGIN (object);
- Animation_WallpaperPrivate *priv = desktop_plugin->priv;
-
- /* Call the base class's implementation: */
- G_OBJECT_CLASS (animation_wallpaper_plugin_parent_class)->finalize (object);
+fprintf(stderr,"desktop lw_applet_finalize\n");
+ /* Call the base class's implementation: */
+ G_OBJECT_CLASS (animation_wallpaper_plugin_parent_class)->finalize (object);
}
static void
gobject_class->destroy = (gpointer)lw_applet_finalize;
object_class->finalize = desktop_widget_finalize;
widget_class->realize = lw_applet_realize;
-// widget_class->expose_event = lw_applet_expose_event;
g_type_class_add_private (klass, sizeof (Animation_WallpaperPrivate));