#include <sys/time.h>
#include <stdlib.h>
-#define PLUGIN_NAME "livewp-home-widget.desktop-0"
-#define GCONF_KEY_POSITION "/apps/osso/hildon-desktop/applets/%s/position"
-#define GCONF_KEY_MODIFIED "/apps/osso/hildon-desktop/applets/%s/modified"
-#define GCONF_KEY_VIEW "/apps/osso/hildon-desktop/applets/%s/view"
+#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"
+#define GCONF_KEY_VIEW "/apps/osso/hildon-desktop/applets/livewp-home-widget.desktop-%i/view"
HD_DEFINE_PLUGIN_MODULE (AWallpaperPlugin, animation_wallpaper_plugin, HD_TYPE_HOME_PLUGIN_ITEM)
#define Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE (obj,\
Animation_Wallpaper_TYPE_HOME_PLUGIN,\
Animation_WallpaperPrivate))
-
static void
lw_applet_realize (GtkWidget *widget)
{
- GdkScreen *screen;
+ GdkScreen *screen;
+ gchar * strid;
+ gint id;
+ AWallpaperPlugin *desktop_plugin = widget;
+ char* child_argv[] = {"/usr/bin/livewp", "0", (char *) 0 };
+
+
+ strid = g_strdup(hd_plugin_item_get_plugin_id (HD_PLUGIN_ITEM (widget)));
+ id = strid[strlen(strid)-1] - '0';
+ desktop_plugin->priv->view = id;
+ g_free(strid);
+
+
+ switch (id){
+ case 0: child_argv[1] = "1";
+ break;
+ case 1: child_argv[1] = "2";
+ break;
+ case 2: child_argv[1] = "3";
+ break;
+ 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");
+ }
+#if 0
+ /* Load config */
+ read_config(desktop_plugin->priv);
- screen = gtk_widget_get_screen (widget);
- gtk_widget_set_colormap (widget,
+ init_scene_theme(desktop_plugin);
+
+ desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
+#endif
+ screen = gtk_widget_get_screen (widget);
+ gtk_widget_set_colormap (widget,
gdk_screen_get_rgba_colormap (screen));
- gtk_widget_set_app_paintable (widget,
+ gtk_widget_set_app_paintable (widget,
TRUE);
- GTK_WIDGET_CLASS (animation_wallpaper_plugin_parent_class)->realize (widget);
+ GTK_WIDGET_CLASS (animation_wallpaper_plugin_parent_class)->realize (widget);
}
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)
gchar *modified_key;
gchar *modified;
GError *error = NULL;
+ gint i;
GConfClient *gconf_client = gconf_client_get_default ();
- position_key = g_strdup_printf (GCONF_KEY_POSITION, PLUGIN_NAME);
- position = gconf_client_get_list (gconf_client,
- position_key,
- GCONF_VALUE_INT,
- NULL);
- if (position && position->data && position->next->data){
- *xapplet = GPOINTER_TO_INT (position->data);
- *yapplet = GPOINTER_TO_INT (position->next->data);
- }else{
- position = g_slist_prepend (g_slist_prepend (NULL,
- GINT_TO_POINTER (Ystartposition)),
- GINT_TO_POINTER (Xstartposition));
- gconf_client_set_list (gconf_client,
- position_key,
- GCONF_VALUE_INT,
- position,
- &error);
- *xapplet = Xstartposition;
- *yapplet = Ystartposition;
+ for (i=0;i<4;i++){
+ position_key = g_strdup_printf (GCONF_KEY_POSITION, i);
+ position = gconf_client_get_list (gconf_client,
+ position_key,
+ GCONF_VALUE_INT,
+ NULL);
+ if (position && position->data && position->next->data){
+ *xapplet = GPOINTER_TO_INT (position->data);
+ *yapplet = GPOINTER_TO_INT (position->next->data);
+ }else{
+ position = g_slist_prepend (g_slist_prepend (NULL,
+ GINT_TO_POINTER (Ystartposition)),
+ GINT_TO_POINTER (Xstartposition));
+ gconf_client_set_list (gconf_client,
+ position_key,
+ GCONF_VALUE_INT,
+ position,
+ &error);
+ *xapplet = Xstartposition;
+ *yapplet = Ystartposition;
+ }
+ g_free (position_key);
+ modified = g_strdup_printf ("%i", 0);
+ modified_key = g_strdup_printf (GCONF_KEY_MODIFIED, i);
+ gconf_client_set_string (gconf_client,
+ modified_key,
+ modified,
+ &error);
+ g_free(modified);
+ g_free(modified_key);
+ modified_key = g_strdup_printf (GCONF_KEY_VIEW, i);
+ gconf_client_set_int (gconf_client,
+ modified_key,
+ (i+1),
+ &error);
+ g_free(modified_key);
+
}
- g_free (position_key);
- modified = g_strdup_printf ("%i", 0);
- modified_key = g_strdup_printf (GCONF_KEY_MODIFIED, PLUGIN_NAME);
- gconf_client_set_string (gconf_client,
- modified_key,
- modified,
- &error);
- g_free(modified);
- g_free(modified_key);
gconf_client_clear_cache(gconf_client);
g_object_unref(gconf_client);
}
label = gtk_label_new(NULL);
if (label){
- //g_signal_connect(G_OBJECT(label), "expose_event",
- // G_CALLBACK(expose_event), NULL);
+ //g_signal_connect(G_OBJECT(label), "expose_event", G_CALLBACK(expose_event), NULL);
gtk_container_add (GTK_CONTAINER (ha), label);
}
//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));
+ 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);
actor->width,
actor->height,
NULL);
- /*fprintf(stderr, "create_hildon_actor %s %s\n", actor->name, str);*/
+ /* fprintf(stderr, "create_hildon_actor %s %s\n", actor->name, str); */
if (str)
g_free(str);
if (pixbuf){
//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));
+ 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);
time_t now;
Actor *actor;
-
- //fprintf(stderr, "!!!run long timeout short_timer=%d\n", desktop_plugin->priv->short_timer);
+ 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;
}
now = time(NULL);
- //fprintf(stderr, "Now %d\n", now);
+ fprintf(stderr, "Now %d\n", now);
tmp = desktop_plugin->priv->scene->actors;
while (tmp != NULL){
actor = tmp->data;
}
-static gboolean
+gboolean
long_timeout (AWallpaperPlugin *desktop_plugin)
{
/* fprintf(stderr, "long_timeout %i\n", desktop_plugin->priv->long_timer); */
AWallpaperPlugin *desktop_plugin)
{
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); */
- if (visible){
- desktop_plugin->priv->visible = TRUE;
- if (desktop_plugin->priv->long_timer == 0 ){
- desktop_plugin->priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
- run_long_timeout(desktop_plugin);
- }
- }else{
- desktop_plugin->priv->visible = FALSE;
- if (desktop_plugin->priv->long_timer != 0 ){
- g_source_remove(desktop_plugin->priv->long_timer);
- desktop_plugin->priv->long_timer = 0;
- }
- }
+ fprintf (stderr, "is-on-current-desktop changed. visible: %u", visible);
+ if (priv){
+ switch (priv->view + 1){
+ case 1: if (visible)
+ send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
+ LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW1);
+ else
+ send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
+ LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW1);
+ break;
+ case 2: if (visible)
+ send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
+ LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW2);
+ else
+ send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
+ LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW2);
+ break;
+ case 3: if (visible)
+ send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
+ LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW3);
+ else
+ send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
+ LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW3);
+ break;
+ case 4: if (visible)
+ send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
+ LIVEWP_SIGNAL_PATH, LIVEWP_PLAY_LIVEBG_ON_VIEW4);
+ else
+ send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
+ LIVEWP_SIGNAL_PATH, LIVEWP_PAUSE_LIVEBG_ON_VIEW4);
+ break;
+ }
+ }
+
}
gboolean
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);
+ break;
+ case 2: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
+ LIVEWP_SIGNAL_PATH, LIVEWP_ALIVE_LIVEBG_ON_VIEW2);
+ break;
+ case 3: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
+ LIVEWP_SIGNAL_PATH, LIVEWP_ALIVE_LIVEBG_ON_VIEW3);
+ break;
+ case 4: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
+ LIVEWP_SIGNAL_PATH, LIVEWP_ALIVE_LIVEBG_ON_VIEW4);
+ break;
+ }
+
+ return TRUE;
+}
+
static void
animation_wallpaper_plugin_init (AWallpaperPlugin *desktop_plugin)
{
desktop_plugin->priv = Animation_Wallpaper_HOME_PLUGIN_GET_PRIVATE (desktop_plugin);
priv->osso = osso_initialize(PACKAGE, VERSION, TRUE, NULL);
- /* Load config */
- read_config(priv);
- /* Initialize DBUS */
+ /* Initialize DBUS */
livewp_initialize_dbus(priv);
priv->desktop_plugin = desktop_plugin;
- priv->visible = TRUE;
+ priv->window = desktop_plugin;
+ priv->visible = FALSE;
priv->short_timer = 0;
priv->xapplet = 0;
priv->yapplet = 0;
+ priv->scene = NULL;
+ 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);
//#endif
- priv->theme = g_strdup("Modern");
+ //priv->theme = g_strdup("Accel");
desktop_plugin->priv->main_widget = gtk_fixed_new();
- gtk_widget_set_size_request(desktop_plugin->priv->main_widget, 100, 32);
- desktop_plugin->priv->right_corner = NULL;
- snprintf(buffer, sizeof(buffer) - 1, "%s/%s/%s", THEME_PATH, desktop_plugin->priv->theme, "town0_right_corner.png");
- desktop_plugin->priv->right_corner = gtk_image_new_from_file (buffer);
- if (desktop_plugin->priv->right_corner){
- gtk_fixed_put(GTK_FIXED(desktop_plugin->priv->main_widget), desktop_plugin->priv->right_corner, 0, 0);
- gtk_widget_show (desktop_plugin->priv->right_corner);
- }
- /* Create rich animation event */
- rich_animation = gtk_event_box_new();
- if(rich_animation){
- gtk_widget_set_events(rich_animation, GDK_BUTTON_PRESS_MASK);
- gtk_event_box_set_visible_window(GTK_EVENT_BOX(rich_animation), FALSE);
- gtk_widget_set_size_request(rich_animation, 100, 32);
- gtk_widget_show (rich_animation);
- g_signal_connect(rich_animation, "button-press-event", G_CALLBACK(rich_animation_press), desktop_plugin);
- gtk_fixed_put(GTK_FIXED(desktop_plugin->priv->main_widget), rich_animation, 0, 0);
- }
-/*
- GtkWidget *label = gtk_label_new ("ddddddddddddd");
- gtk_widget_set_size_request(label, 95, 30);
- gtk_widget_show (label);
- gtk_container_add (GTK_CONTAINER (desktop_plugin), label);
- gtk_fixed_put(GTK_FIXED(widget), label, 0, 0);
-*/
- hd_home_plugin_item_set_settings (HD_HOME_PLUGIN_ITEM (desktop_plugin), TRUE);
- g_signal_connect (desktop_plugin, "show-settings",
- G_CALLBACK (show_settings), priv);
+ gtk_widget_set_size_request(desktop_plugin->priv->main_widget, 1, 1);
gtk_widget_show (desktop_plugin->priv->main_widget);
gtk_container_add (GTK_CONTAINER (desktop_plugin), desktop_plugin->priv->main_widget);
init_applet_position(&(priv->xapplet), &(priv->yapplet));
- fprintf(stderr, "!!!theme = %s\n", priv->theme);
- snprintf(str, sizeof(str) - 1, "%s", "init_scene2");
- fprintf(stderr, " str = %s\n", str);
priv->scene = NULL;
-#if 0
- if (!strcmp(priv->theme,"Modern"))
- init_scene_Modern(desktop_plugin);
- else if (!strcmp(priv->theme,"Berlin"))
- init_scene_Berlin(desktop_plugin);
- else if (!strcmp(priv->theme, "Matrix"))
- init_scene_Matrix(desktop_plugin);
-#endif
- init_scene_theme(desktop_plugin);
-
- priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
- /* TODO Move scene to priv */
- //scene.timer_type = LONG_TIMER_TYPE;
g_signal_connect (desktop_plugin, "notify::is-on-current-desktop",
- G_CALLBACK (desktop_plugin_visible_notify), desktop_plugin);
+ G_CALLBACK (desktop_plugin_visible_notify), desktop_plugin);
-
- //sleep(2);
+ priv->alive_timer = g_timeout_add(60000*3, (GtkFunction)send_alive_event, priv); /* One per 3 minute */
}
static void
lw_applet_finalize (GObject *object)
{
+ int status = 0; int wpid;
+fprintf(stderr,"lw_applet_finalize\n");
AWallpaperPlugin *desktop_plugin = Animation_Wallpaper_HOME_PLUGIN (object);
Animation_WallpaperPrivate *priv = desktop_plugin->priv;
+/*
+
+ if (priv){
+ livewp_deinitialize_dbus(priv);
+ fprintf(stderr,"finalaze %i\n", priv->long_timer);
+ if (priv->long_timer){
+ g_source_remove(priv->long_timer);
+ priv->long_timer = 0;
+ }
+ if (priv->short_timer){
+ g_source_remove(priv->short_timer);
+ priv->short_timer = 0;
+ }
+
+ destroy_scene(desktop_plugin);
+ }
+*/
+
+ if (priv){
+ switch (priv->view + 1){
+ case 1: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
+ LIVEWP_SIGNAL_PATH, LIVEWP_STOP_LIVEBG_ON_VIEW1);
+ break;
+ case 2: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
+ LIVEWP_SIGNAL_PATH, LIVEWP_STOP_LIVEBG_ON_VIEW2);
+ break;
+ case 3: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
+ LIVEWP_SIGNAL_PATH, LIVEWP_STOP_LIVEBG_ON_VIEW3);
+ break;
+ case 4: send_dbus_signal (priv, LIVEWP_SIGNAL_INTERFACE,
+ LIVEWP_SIGNAL_PATH, LIVEWP_STOP_LIVEBG_ON_VIEW4);
+ break;
+ }
+ }
+ if(priv->alive_timer > 0)
+ g_source_remove(priv->alive_timer);
livewp_deinitialize_dbus(priv);
- fprintf(stderr,"finalaze %i\n", priv->long_timer);
- if (priv->long_timer){
- g_source_remove(priv->long_timer);
- priv->long_timer = 0;
- }
- if (priv->short_timer){
- g_source_remove(priv->short_timer);
- priv->short_timer = 0;
+ while (TRUE){
+ wpid = wait(&status);
+ if (wpid == priv->pid)
+ break;
}
+}
- destroy_scene(desktop_plugin);
+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);
}
static void
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkObjectClass *gobject_class = GTK_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
/* gobject */
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;
+// widget_class->expose_event = lw_applet_expose_event;
g_type_class_add_private (klass, sizeof (Animation_WallpaperPrivate));
animation_wallpaper_plugin_class_finalize (AWallpaperPluginClass *class) {
}
+Animation_WallpaperPrivate*
+animation_wallpaper_plugin_new (void)
+{
+ return g_object_new (Animation_Wallpaper_TYPE_HOME_PLUGIN , NULL);
+}