From eb66a909618e42107f42ceacb44365cbf964c331 Mon Sep 17 00:00:00 2001 From: tanya Date: Fri, 30 Apr 2010 15:10:51 +0300 Subject: [PATCH] continued restructuring --- applet/src/livewp-actor.c | 2 -- applet/src/livewp-actor.h | 25 +++++++++++++++++++ applet/src/livewp-common.h | 25 +++---------------- applet/src/livewp-home-widget.c | 51 +++++++-------------------------------- applet/src/livewp-home-widget.h | 7 +++--- applet/src/livewp-rules.c | 13 ++++++++++ applet/src/livewp-rules.h | 3 +++ 7 files changed, 58 insertions(+), 68 deletions(-) diff --git a/applet/src/livewp-actor.c b/applet/src/livewp-actor.c index 1cc6636..cb4e9b0 100644 --- a/applet/src/livewp-actor.c +++ b/applet/src/livewp-actor.c @@ -23,8 +23,6 @@ */ /*******************************************************************************/ #include "livewp-actor.h" -#include -#include "livewp-rules.h" Actor* init_object(AWallpaperPlugin *desktop_plugin, diff --git a/applet/src/livewp-actor.h b/applet/src/livewp-actor.h index c1c715d..3c7fa79 100644 --- a/applet/src/livewp-actor.h +++ b/applet/src/livewp-actor.h @@ -26,8 +26,33 @@ #define _livewp_actor_h 1 #include "livewp-common.h" +#include +#include "livewp-rules.h" +typedef struct _Actor Actor; +struct _Actor +{ + GtkWidget * widget; + GtkWidget * image; + gchar *name; + gchar *filename; + gint x; + gint y; + gint z; + gint width; + gint height; + gint scale; + gint opacity; + gboolean visible; + void (*func_change)(gpointer, gpointer); + time_t time_start_animation; + gint duration_animation; + void (*func_probability)(gpointer); + GPtrArray *child; +}; + +/*******************************************************************************/ Actor* init_object(AWallpaperPlugin *desktop_plugin, gchar * name, gchar * filename, diff --git a/applet/src/livewp-common.h b/applet/src/livewp-common.h index 213777d..9b7fee3 100644 --- a/applet/src/livewp-common.h +++ b/applet/src/livewp-common.h @@ -37,6 +37,10 @@ #define GETTEXT_PACKAGE "livewp" #include +/* Position of plugin on desktop */ +#define Xstartposition 700 +#define Ystartposition 448 + #define THEME_PATH "/usr/share/livewp/theme" #define SHORT_TIMER 75 /* 100 milisecond */ //#define LONG_TIMER 5*60*1000 /* 10 minutes */ @@ -48,7 +52,6 @@ enum { SHORT_TIMER_TYPE, LONG_TIMER_TYPE }; #define TRAM_LEVEL 20 typedef struct _Scene Scene; -typedef struct _Actor Actor; typedef struct _AWallpaperPlugin AWallpaperPlugin; typedef struct _AWallpaperPluginClass AWallpaperPluginClass; typedef struct _Animation_WallpaperPrivate Animation_WallpaperPrivate; @@ -83,26 +86,6 @@ struct _AWallpaperPluginClass }; -struct _Actor -{ - GtkWidget * widget; - gchar *name; - gchar *filename; - gint x; - gint y; - gint z; - gint width; - gint height; - gint scale; - gint opacity; - gboolean visible; - void (*func_change)(gpointer, gpointer); - time_t time_start_animation; - gint duration_animation; - void (*func_probability)(gpointer); - GPtrArray *child; - -}; struct _Scene { diff --git a/applet/src/livewp-home-widget.c b/applet/src/livewp-home-widget.c index fe0b13e..38f2522 100644 --- a/applet/src/livewp-home-widget.c +++ b/applet/src/livewp-home-widget.c @@ -24,7 +24,6 @@ /*******************************************************************************/ #include "livewp-common.h" #include "livewp-home-widget.h" -#include "livewp-actor.h" #include #include "livewp-rules.h" #include @@ -40,12 +39,6 @@ HD_DEFINE_PLUGIN_MODULE (AWallpaperPlugin, animation_wallpaper_plugin, HD_TYPE_H Animation_Wallpaper_TYPE_HOME_PLUGIN,\ Animation_WallpaperPrivate)) -/* Position of plugin on desktop */ -#define Xstartposition 700 -#define Ystartposition 448 - -//gint xapplet = 0, yapplet = 0; - static void lw_applet_realize (GtkWidget *widget) { @@ -151,14 +144,14 @@ 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) @@ -169,23 +162,6 @@ destroy_hildon_actor(Actor *actor) } -gint -rnd(gint max) -{ - srand(time(NULL)); - return rand() % max; -} -gint fast_rnd(gint max) -{ - guint offset = 12923; - guint multiplier = 4079; - - //*seed = *seed * multiplier + offset; - //return (gint)(*seed % max); - guint seed = time(NULL); - return (gint)(seed % max); -} - void create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) { @@ -213,16 +189,14 @@ create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) G_CALLBACK(expose_event), pixbuf); gtk_container_add (GTK_CONTAINER (ha), image); } - //actor_set_position_full(ha, actor->x, actor->y, actor->z); - //hildon_animation_actor_set_scale(HILDON_ANIMATION_ACTOR(ha), (double)actor->scale/100, (double)actor->scale/100); realize(ha); gtk_widget_show_all(ha); - //hildon_animation_actor_set_show (HILDON_ANIMATION_ACTOR(ha), actor->visible); /* TO DO check it */ /* gdk_flush (); */ - g_object_set_data(G_OBJECT(ha), "image", image); + //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)); actor->widget = ha; set_actor_position(actor, actor->x, actor->y, actor->z, desktop_plugin); @@ -254,10 +228,12 @@ change_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) 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")){ - gtk_container_remove(GTK_CONTAINER(actor->widget), g_object_get_data(G_OBJECT(actor->widget), "image")); + //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); + //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); @@ -269,15 +245,6 @@ change_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin) } - - -/* -static gint -get_time(gint t){ - // уравнение изменения времени - return t*1.1; -} -*/ static void destroy_scene(AWallpaperPlugin *desktop_plugin) { diff --git a/applet/src/livewp-home-widget.h b/applet/src/livewp-home-widget.h index 0611a55..02911bd 100644 --- a/applet/src/livewp-home-widget.h +++ b/applet/src/livewp-home-widget.h @@ -25,6 +25,7 @@ #define Animation_Wallpaper_PLUGIN_H #include +#include "livewp-actor.h" G_BEGIN_DECLS @@ -63,15 +64,15 @@ GType animation_wallpaper_plugin_get_type(void); G_END_DECLS void lw_settings(gpointer user_data, gpointer data); -void actor_set_position_full(GtkWidget *actor, gint x, gint y, gint z); +//void actor_set_position_full(GtkWidget *actor, gint x, gint y, gint z); gint read_config(Animation_WallpaperPrivate *priv); void save_config(Animation_WallpaperPrivate *priv); void run_long_timeout(AWallpaperPlugin *desktop_plugin); static void init_scene(AWallpaperPlugin *desktop_plugin); static void init_scene1(AWallpaperPlugin *desktop_plugin); static void init_scene2(AWallpaperPlugin *desktop_plugin); -void set_actor_visible(Actor *actor, gboolean visible); -void set_actor_scale(Actor *actor, double scalex, double scaley); +//void set_actor_visible(Actor *actor, gboolean visible); +//void set_actor_scale(Actor *actor, double scalex, double scaley); void create_hildon_actor(Actor *actor, AWallpaperPlugin *desktop_plugin); void get_sun_screen_pos(double alt, double azm, gint * x, gint * y); void show_settings(GtkWidget *widget, Animation_WallpaperPrivate *priv); diff --git a/applet/src/livewp-rules.c b/applet/src/livewp-rules.c index 545147a..cb1ddd3 100644 --- a/applet/src/livewp-rules.c +++ b/applet/src/livewp-rules.c @@ -146,3 +146,16 @@ int get_moon_phase() return MOON_NONE; } + +gint +fast_rnd(gint max) +{ + guint offset = 12923; + guint multiplier = 4079; + + //*seed = *seed * multiplier + offset; + //return (gint)(*seed % max); + guint seed = time(NULL); + return (gint)(seed % max); +} + diff --git a/applet/src/livewp-rules.h b/applet/src/livewp-rules.h index 38b8d46..c18dc25 100644 --- a/applet/src/livewp-rules.h +++ b/applet/src/livewp-rules.h @@ -26,6 +26,7 @@ /*******************************************************************************/ #include #include "livewp-astro.h" +#include "livewp-common.h" /*******************************************************************************/ #define TIME_DAY 0 #define TIME_NIGHT 3 @@ -47,5 +48,7 @@ int get_daytime(); int get_moon_phase(); time_t get_next_sunrise(); time_t get_next_sunset(); +gint fast_rnd(gint max); + /*******************************************************************************/ #endif -- 1.7.9.5