desktoplib_LTLIBRARIES = liblivewp-home-widget.la
desktoplibdir = $(HILDON_DESKTOP_LIB_DIR)
-liblivewp_home_widget_la_SOURCES = livewp-home-widget.c livewp-home-widget.h livewp-astro.c livewp-astro.h
+liblivewp_home_widget_la_SOURCES = livewp-home-widget.c livewp-home-widget.h livewp-astro.c livewp-astro.h livewp-rules.c livewp-rules.h
liblivewp_home_widget_la_LIBADD = $(EXAMPLE_LIBS)
AM_CFLAGS = -Wall $(EXAMPLE_CFLAGS)
{
double uu, jj, T, k, M, Lo, DL, L, eps, delta, RA, GMST, LMST, H, eqt, azm;
uu = ut(hour, min, zone);
- fprintf(stderr, "%f, %f, %i.%i.%i %i:%i %i uu=%f", lon, lat, year, month, day, hour, min, zone, uu);
jj = jd(year, month, day, uu);
T = jj / 36525;
k = M_PI / 180;
}
double moon_phase(int year, int month, int day)
{
- int yy, mm, dd, k1, k2, k3, lg;
- double agepart, ageday, ge, moonday, jd, moonfill;
+ int lg;
+ double agepart, ge, jd, moonday;
ge = 1721425.5;
moonday = 29.530588853;
if (month <= 2) lg = 0;
#include "livewp-home-widget.h"
#include <libhildondesktop/libhildondesktop.h>
#include <gconf/gconf-client.h>
-#include "livewp-astro.h"
+#include "livewp-rules.h"
#define PLUGIN_NAME "livewp-home-widget.desktop-0"
#define GCONF_KEY_POSITION "/apps/osso/hildon-desktop/applets/%s/position"
GtkWidget* init_object(gchar * name, gint x, gint y, gint z, gint width, gint height)
{
+ Actor a;
GtkWidget *actor;
GdkPixbuf *pixbuf;
GtkWidget *image;
g_object_set_data(G_OBJECT(actor), "posX", x);
g_object_set_data(G_OBJECT(actor), "posY", y);
+
objects_list = g_slist_append(objects_list, G_OBJECT(actor));
+ //objects_list = g_slist_append(objects_list, G_OBJECT(a));
return actor;
}
get_sun_pos(&alt, &azm);
get_sun_screen_pos(alt, azm, &x, &y);
- if (x > 800) x = 700;
- if (y > 480) y = 400;
- actor = init_object("sun", x, y, 1, 88, 88);
+ fprintf(stderr, "init scene alt=%f, azm=%f, x=%d, y=%d", alt, azm, x, y);
+ actor = init_object("sun", x, y, 20, 88, 88);
hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (actor), window);
actor = init_object("sky", 0, 0, 0, 800, 480);
hildon_animation_actor_set_parent (HILDON_ANIMATION_ACTOR (actor), window);
example_label_home_applet_realize (GtkWidget *widget)
{
}
-void get_coord(double * lat, double * lon)
-{
- *lat = 55.166666;
- *lon = 30.166666;
-}
-void get_sun_pos(double * alt, double * azm)
-{
- double lon ,lat;
- time_t timet;
- struct tm nowtime;
- get_coord(&lat, &lon);
- time(&timet);
- localtime_r(&timet, &nowtime);
- //fprintf(stderr, "plugin on timeout %i.%i.%i (%i) %i:%i:%i\n", nowtime.tm_mday, nowtime.tm_mon+1, nowtime.tm_year+1900, abs(nowtime.tm_gmtoff/3600), nowtime.tm_hour, nowtime.tm_min, nowtime.tm_sec);
- fprintf(stderr, "before altitude\n");
- *alt = altitude(lon, lat, nowtime.tm_year+1900, nowtime.tm_mon+1, nowtime.tm_mday, nowtime.tm_hour, nowtime.tm_min, nowtime.tm_gmtoff/3600);
- *alt = *alt / 70;
- *azm = azimuth(lon, lat, nowtime.tm_year+1900, nowtime.tm_mon+1, nowtime.tm_mday, nowtime.tm_hour, nowtime.tm_min, nowtime.tm_gmtoff/3600);
- //если южная широта
- if (lat < 0){
- *azm = 90 + (90 - *azm);
- *azm = fmod(*azm, 360);
- }
- *azm = (*azm - 90) / 180;
- //fprintf(stderr, "alt=%5.6f azm=%5.6f\n", alt, azm);
-
-}
-
void get_sun_screen_pos(double alt, double azm, gint * x, gint * y)
{
gint y0 = 400;// - уровень горизонта
*x = (int)(azm * 800) - 64;
*y = (int)((1 - alt) * y0) - 64;
}
+/*
+void processing(GtkWidget * actor)
+{
+ char * name;
+ gint x, y;
+ double alt, azm;
+ gint daytime = get_daytime();
+ gint moonphase = get_moon_phase();
+ name = g_object_get_data(G_OBJECT(tmp->data), "name");
+ if (name == "sun"){
+ if (daytime != TIME_NIGHT){
+ hildon_animation_actor_set_show(tmp->data, 1);
+ get_sun_pos(&alt, &azm);
+ get_sun_screen_pos(alt, azm, &x, &y);
+ actor_set_position_full(tmp->data, x, y, );
+ }
+ }
+
+
+}*/
static gboolean
plugin_on_timeout (gpointer data)
{
gchar * str;
gint x, y;
-
- double azm, alt;
- get_sun_pos(&alt, &azm);
+ Actor * a;
+ fprintf(stderr, "on timeout\n");
+ //double azm, alt;
+ //get_sun_pos(&alt, &azm);
GSList * tmp = objects_list;
while (tmp != NULL){
+ //processing(tmp->data);
+ /*
str = g_object_get_data(G_OBJECT(tmp->data), "name");
fprintf(stderr, "object: %s\n", str);
if (str == "sun"){
- get_sun_screen_pos(alt, azm, &x, &y);
- actor_set_position_full(tmp->data, x, y, 0);
+ //get_sun_screen_pos(alt, azm, &x, &y);
+ //x = tmp->data
+ actor_set_position_full(tmp->data, x, y, 20);
fprintf(stderr, "x = %i, y = %i\n", x, y);
//g_object_set_data(G_OBJECT(tmp->data), "posX", x);
//g_object_set_data(G_OBJECT(tmp->data), "posY", y);
fprintf(stderr, "x = %d y = %d\n", x, y);
}
+ if (str == "town"){
+ //hildon_animation_actor_set_show(tmp->data, 0);
+ }*/
+ //a = tmp->data;
+ //fprintf(stderr, "--timeout %s\n", a->name);
tmp = g_slist_next(tmp);
}
gtk_container_add (GTK_CONTAINER (desktop_plugin), label);
init_applet_position();
init_scene(desktop_plugin);
- desktop_plugin->timer = g_timeout_add(1000*60*1, plugin_on_timeout, desktop_plugin);
+ //desktop_plugin->timer = g_timeout_add(1000*20, plugin_on_timeout, desktop_plugin);
}
static void
};
+typedef struct {
+ GtkWidget * window;
+ GSList * actors;
+}Scene;
+
+typedef struct {
+ GtkWidget * widget;
+ gchar * name;
+ gint x;
+ gint y;
+ gint z;
+ gint widht;
+ gint height;
+ gboolean visible;
+
+}Actor;
+
GType animation_wallpaper_home_plugin_get_type(void);
G_END_DECLS
--- /dev/null
+/*
+ * 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 Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 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-rules.h"
+
+/*******************************************************************************/
+
+void get_localtime(int * year, int * month, int * day, int * hour, int * min, int * zone)
+{
+ time_t timet;
+ struct tm nt;
+ time(&timet);
+ localtime_r(&timet, &nt);
+ *year = nt.tm_year + 1900;
+ *month = nt.tm_mon + 1;
+ *day = nt.tm_mday;
+ *hour = nt.tm_hour;
+ *min = nt.tm_min;
+ *zone = nt.tm_gmtoff/3600;
+ /*
+ *year = 2010;
+ *month = 3;
+ *day = 24;
+ *hour = 16;
+ *min = 20;
+ *zone = 2;*/
+}
+
+void get_coord(double * lat, double * lon)
+{
+ *lat = 55.166666;
+ *lon = 30.166666;
+}
+
+void get_sun_pos(double * alt, double * azm)
+{
+ int year, month, day, hour, min, zone;
+ double lat, lon;
+ get_localtime(&year, &month, &day, &hour, &min, &zone);
+ get_coord(&lat, &lon);
+ *alt = altitude(lon, lat, year, month, day, hour, min, zone);
+ *alt = *alt / 70; // sun height in percent
+
+ *azm = azimuth(lon, lat, year, month, day, hour, min, zone);
+ //if south latitude
+ if (lat < 0){
+ *azm = 90 + (90 - *azm);
+ *azm = fmod(*azm, 360);
+ }
+ *azm = (*azm - 90) / 180; // sun azimuth in percent
+}
+int get_daytime()
+{
+ double alt, azm;
+ get_sun_pos(&alt, &azm);
+ alt = alt * 100;
+ azm = azm * 100;
+ printf("alt = %f azm=%f\n", alt, azm);
+ if (alt <= -7) return TIME_NIGHT;
+ if (alt > -7 && alt < 7 && azm < 50) return TIME_SUNRISE;
+ if (alt > 7 && alt < azm > 50) return TIME_SUNSET;
+ if (alt >= 7) return TIME_DAY;
+
+}
+int get_moon_phase()
+{
+ int year, month, day, hour, min, zone;
+ double phase;
+ get_localtime(&year, &month, &day, &hour, &min, &zone);
+ phase = moon_phase(year, month, day) * 100;
+ printf("ph = %f\n", phase);
+ if (phase <= 3 || phase >=97) return MOON_NONE;
+ if (phase > 5 && phase <= 25) return MOON_GROWS;
+ if (phase > 25 && phase <= 45) return MOON_GROWSHALF;
+ if (phase > 45 && phase <= 55) return MOON_FULL;
+ if (phase > 55 && phase <= 75) return MOON_DECREASHALF;
+ if (phase > 75 && phase < 97) return MOON_DECREAS;
+}
--- /dev/null
+/*
+ * 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 Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 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
+*/
+/*******************************************************************************/
+#ifndef _livewp_rules_h
+#define _livewp_rules_h 1
+/*******************************************************************************/
+#include <time.h>
+#include "livewp-astro.h"
+/*******************************************************************************/
+#define TIME_DAY 0
+#define TIME_NIGHT 1
+#define TIME_SUNRISE 2
+#define TIME_SUNSET 3
+
+#define MOON_NONE 0
+#define MOON_GROWS 1
+#define MOON_GROWSHALF 2
+#define MOON_FULL 3
+#define MOON_DECREASHALF 4
+#define MOON_DECREAS 5
+
+/*******************************************************************************/
+void get_localtime(int * year, int * month, int * day, int * hour, int * min, int * zone);
+void get_coord(double * lat, double * lon);
+void get_sun_pos(double * alt, double * azm);
+int get_daytime();
+int get_moon_phase();
+/*******************************************************************************/
+#endif