Moon module - a gadget that displays moon phase information for e17

* gadconized
* the default images are the fugly ones from the e16 E-MoonClock
* configuration "works", but isn't persisted properly yet
* i18n is ready to go (Haga-san - feel free to update the ja.po :))


SVN revision: 22601
This commit is contained in:
e-taro 2006-05-14 02:24:55 +00:00 committed by e-taro
commit 85b7b837ab
93 changed files with 3072 additions and 0 deletions

218
ABOUT-NLS Normal file
View File

@ -0,0 +1,218 @@
Notes on the Free Translation Project
*************************************
Free software is going international! The Free Translation Project
is a way to get maintainers of free software, translators, and users all
together, so that will gradually become able to speak many languages.
A few packages already provide translations for their messages.
If you found this `ABOUT-NLS' file inside a distribution, you may
assume that the distributed package does use GNU `gettext' internally,
itself available at your nearest GNU archive site. But you do _not_
need to install GNU `gettext' prior to configuring, installing or using
this package with messages translated.
Installers will find here some useful hints. These notes also
explain how users should proceed for getting the programs to use the
available translations. They tell how people wanting to contribute and
work at translations should contact the appropriate team.
When reporting bugs in the `intl/' directory or bugs which may be
related to internationalization, you should tell about the version of
`gettext' which is used. The information can be found in the
`intl/VERSION' file, in internationalized packages.
Quick configuration advice
==========================
If you want to exploit the full power of internationalization, you
should configure it using
./configure --with-included-gettext
to force usage of internationalizing routines provided within this
package, despite the existence of internationalizing capabilities in the
operating system where this package is being installed. So far, only
the `gettext' implementation in the GNU C library version 2 provides as
many features (such as locale alias, message inheritance, automatic
charset conversion or plural form handling) as the implementation here.
It is also not possible to offer this additional functionality on top
of a `catgets' implementation. Future versions of GNU `gettext' will
very likely convey even more functionality. So it might be a good idea
to change to GNU `gettext' as soon as possible.
So you need _not_ provide this option if you are using GNU libc 2 or
you have installed a recent copy of the GNU gettext package with the
included `libintl'.
INSTALL Matters
===============
Some packages are "localizable" when properly installed; the
programs they contain can be made to speak your own native language.
Most such packages use GNU `gettext'. Other packages have their own
ways to internationalization, predating GNU `gettext'.
By default, this package will be installed to allow translation of
messages. It will automatically detect whether the system already
provides the GNU `gettext' functions. If not, the GNU `gettext' own
library will be used. This library is wholly contained within this
package, usually in the `intl/' subdirectory, so prior installation of
the GNU `gettext' package is _not_ required. Installers may use
special options at configuration time for changing the default
behaviour. The commands:
./configure --with-included-gettext
./configure --disable-nls
will respectively bypass any pre-existing `gettext' to use the
internationalizing routines provided within this package, or else,
_totally_ disable translation of messages.
When you already have GNU `gettext' installed on your system and run
configure without an option for your new package, `configure' will
probably detect the previously built and installed `libintl.a' file and
will decide to use this. This might be not what is desirable. You
should use the more recent version of the GNU `gettext' library. I.e.
if the file `intl/VERSION' shows that the library which comes with this
package is more recent, you should use
./configure --with-included-gettext
to prevent auto-detection.
The configuration process will not test for the `catgets' function
and therefore it will not be used. The reason is that even an
emulation of `gettext' on top of `catgets' could not provide all the
extensions of the GNU `gettext' library.
Internationalized packages have usually many `po/LL.po' files, where
LL gives an ISO 639 two-letter code identifying the language. Unless
translations have been forbidden at `configure' time by using the
`--disable-nls' switch, all available translations are installed
together with the package. However, the environment variable `LINGUAS'
may be set, prior to configuration, to limit the installed set.
`LINGUAS' should then contain a space separated list of two-letter
codes, stating which languages are allowed.
Using This Package
==================
As a user, if your language has been installed for this package, you
only have to set the `LANG' environment variable to the appropriate
`LL_CC' combination. Here `LL' is an ISO 639 two-letter language code,
and `CC' is an ISO 3166 two-letter country code. For example, let's
suppose that you speak German and live in Germany. At the shell
prompt, merely execute `setenv LANG de_DE' (in `csh'),
`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash').
This can be done from your `.login' or `.profile' file, once and for
all.
You might think that the country code specification is redundant.
But in fact, some languages have dialects in different countries. For
example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The
country code serves to distinguish the dialects.
The locale naming convention of `LL_CC', with `LL' denoting the
language and `CC' denoting the country, is the one use on systems based
on GNU libc. On other systems, some variations of this scheme are
used, such as `LL' or `LL_CC.ENCODING'. You can get the list of
locales supported by your system for your country by running the command
`locale -a | grep '^LL''.
Not all programs have translations for all languages. By default, an
English message is shown in place of a nonexistent translation. If you
understand other languages, you can set up a priority list of languages.
This is done through a different environment variable, called
`LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG'
for the purpose of message handling, but you still need to have `LANG'
set to the primary language; this is required by other parts of the
system libraries. For example, some Swedish users who would rather
read translations in German than English for when Swedish is not
available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'.
In the `LANGUAGE' environment variable, but not in the `LANG'
environment variable, `LL_CC' combinations can be abbreviated as `LL'
to denote the language's main dialect. For example, `de' is equivalent
to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT'
(Portuguese as spoken in Portugal) in this context.
Translating Teams
=================
For the Free Translation Project to be a success, we need interested
people who like their own language and write it well, and who are also
able to synergize with other translators speaking the same language.
Each translation team has its own mailing list. The up-to-date list of
teams can be found at the Free Translation Project's homepage,
`http://www.iro.umontreal.ca/contrib/po/HTML/', in the "National teams"
area.
If you'd like to volunteer to _work_ at translating messages, you
should become a member of the translating team for your own language.
The subscribing address is _not_ the same as the list itself, it has
`-request' appended. For example, speakers of Swedish can send a
message to `sv-request@li.org', having this message body:
subscribe
Keep in mind that team members are expected to participate
_actively_ in translations, or at solving translational difficulties,
rather than merely lurking around. If your team does not exist yet and
you want to start one, or if you are unsure about what to do or how to
get started, please write to `translation@iro.umontreal.ca' to reach the
coordinator for all translator teams.
The English team is special. It works at improving and uniformizing
the terminology in use. Proven linguistic skill are praised more than
programming skill, here.
Available Packages
==================
Languages are not equally supported in all packages. The following
matrix shows the current state of internationalization, as of April
2005. The matrix shows, in regard of each package, for which languages
PO files have been submitted to translation coordination, with a
translation percentage of at least 50%.
Ready PO files en fr ja de bg es fi pl pt ru
+-------------------------------+
enlightenment | [] [] [] [] [] [] [] [] [] [] |
Some counters in the preceding matrix are higher than the number of
visible blocks let us expect. This is because a few extra PO files are
used for implementing regional variants of languages, or language
dialects.
For a PO file in the matrix above to be effective, the package to
which it applies should also have been internationalized and
distributed as such by its maintainer. There might be an observable
lag between the mere existence a PO file and its wide availability in a
distribution.
If August 2002 seems to be old, you may fetch a more recent copy of
this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date
matrix with full percentage details can be found at
`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'.
Using `gettext' in new packages
===============================
If you are writing a freely available program and want to
internationalize it you are welcome to use GNU `gettext' in your
package. Of course you have to respect the GNU Library General Public
License which covers the use of the GNU `gettext' library. This means
in particular that even non-free programs can use `libintl' as a shared
library, whereas only free software can use `libintl' as a static
library or use modified versions of `libintl'.
Once the sources are changed appropriately and the setup can handle
to use of `gettext' the only thing missing are the translations. The
Free Translation Project is also available for packages which are not
developed inside the GNU project. Therefore the information given above
applies also for every other Free Software Project. Contact
`translation@iro.umontreal.ca' to make the `.pot' files available to
the translation teams.

1
AUTHORS Normal file
View File

@ -0,0 +1 @@
David Stevenson <david.35472@gmail.com>

28
COPYING Normal file
View File

@ -0,0 +1,28 @@
Copyright (C) 2005-2006 David Stevenson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies of the Software and its Copyright notices. In addition publicly
documented acknowledgment must be given that this software has been used if no
source code of this software is made available publicly. This includes
acknowledgments in either Copyright notices, Manuals, Publicity and Marketing
documents or any documentation provided with any product containing this
software. This License does not apply to any software that links to the
libraries provided by this software (statically or dynamically), but only to
the software provided.
Please see the COPYING-PLAIN for a plain-english explanation of this notice
and it's intent.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

33
COPYING-PLAIN Normal file
View File

@ -0,0 +1,33 @@
Plain English Copyright Notice
This file is not intended to be the actual License. The reason this file
exists is that we here are programmers and engineers. We aren't lawyers. We
provide licenses that we THINK say the right things, but we have our own
intentions at heart. This is a plain-english explanation of what those
intentions are, and if you follow them you will be within the "spirit" of
the license.
The intent is for us to enjoy writing software that is useful to us (the
AUTHORS) and allow others to use it freely and also benefit from the work we
put into making it. We don't want to restrict others using it. They should
not *HAVE* to make the source code of the applications they write that
simply link to these libraries (be that statically or dynamically), or for
them to be limited as to what license they choose to use (be it open, closed
or anything else). But we would like to know you are using these libraries.
We simply would like to know that it has been useful to someone. This is why
we ask for acknowledgement of some sort.
You can do what you want with the source of this software - it doesn't
matter. We still have it here for ourselves and it is open and free to use
and download and play with. It can't be taken away. We don't really mind what
you do with the source to your software. We would simply like to know that
you are using it - especially if it makes it to a commerical product. If you
simply e-mail all the AUTHORS (see COPYING and AUTHORS files) telling us, and
then make sure you include a paragraph or page in the manual for the product
with the copyright notice and state that you used this software, we will be
very happy. If you want to contribute back modifications and fixes you may have
made we will welcome those too with open arms (generally). If you want help
with changes needed, ports needed or features to be added, arrangements can
be easily made with some dialogue.
David Stevenson (david.35472@gmail.com)

26
ChangeLog Normal file
View File

@ -0,0 +1,26 @@
0.2.0 * Gadman -> Gadcon port
0.1.0 * Added configurability
0.0.6
* Fix to work with gcc 4.0. Tested with the following version
gcc (GCC) 4.0.3 20051201 (prerelease) (Debian 4.0.2-5)
gcc 3.3 users shouldn't be effectted.
0.0.5
* more moon.edc tidy up
0.0.4
* moon.edc uses states instead of embryo script calculations
0.0.3
* Add support for internationalization
(not actually required yet, but it's ready for it)
0.0.2
* Tidy up build setup
* Use license safe e16 images
0.0.1
* Initial e16 MoonClock port

21
INSTALL Normal file
View File

@ -0,0 +1,21 @@
COMPILING and INSTALLING:
1) Installing to ~/.e/e/modules (default)
Users wishing to install the module to their home directory should do the following:
$ ./configure
$ make
$ make install
2) Installing to a system directory
System admins can install to a system directory by specifying the appropriate prefix to the configure script. Note that the prefix specified should be the same as that used to install Enlightenment. For example, to install to /usr/local:
$ ./configure --prefix=/usr/local
$ make
Then finally as root:
$ make install

9
Makefile.am Normal file
View File

@ -0,0 +1,9 @@
SUBDIRS = src data po
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess \
config.h.in config.h.in~ config.sub \
configure install-sh ltconfig ltmain.sh \
missing mkinstalldirs stamp-h.in depcomp
EXTRA_DIST = autogen.sh

0
NEWS Normal file
View File

15
README Normal file
View File

@ -0,0 +1,15 @@
Moon Clock module for Enlightenment 0.17.0
See INSTALL for installation instructions.
This module is a port of the e16 E-MoonClock epplet.
The module supplies a gadget that displays information about the current phase of the moon.
The default theme re-uses moon phase images from the e16 E-MoonClock.
The sky image is from the e17 "bling bling" theme.
Moon phase calculation routines are also re-used.
The rest was mainly written by the AUTHORS.
Feel free to send suggestions or problem reports to the AUTHORS
And have fun :)

2
TODO Normal file
View File

@ -0,0 +1,2 @@
TODO items
- southern hemisphere image flip support once / if evas / edje get rotation support

27
autogen.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/sh
rm -rf autom4te.cache
rm -f aclocal.m4 ltmain.sh
touch README
echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS -I m4 || exit 1
echo "Running autoheader..." ; autoheader || exit 1
echo "Running autoconf..." ; autoconf || exit 1
echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1
echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1
echo "Generating gettext moon.pot template"; \
xgettext \
--output moon.pot \
--output-dir=po \
--language=C \
--add-location \
--keyword=D_ \
--sort-by-file \
--copyright-holder="David Stevenson" \
--foreign-user \
`find . -name "*.[ch]" -print` || exit 1
if [ -z "$NOCONFIGURE" ]; then
./configure "$@"
fi

129
configure.ac Normal file
View File

@ -0,0 +1,129 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
rm -f config.cache
AC_PREREQ(2.59)
AC_INIT(moon, 0.1.0)
AC_CONFIG_SRCDIR([src/e_mod_main.c])
AC_CONFIG_HEADER([config.h])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE
# Checks for programs.
AC_PROG_CC
if test "$GCC" = "yes"; then
CFLAGS="$CFLAGS -Wall"
fi
AC_PROG_LIBTOOL
ALL_LINGUAS="ja it sv"
AC_SUBST(ALL_LINGUAS)
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION(0.14)
# Checks for libraries.
AC_PATH_GENERIC(eet, 0.9.10, [
AC_SUBST(eet_libs)
AC_SUBST(eet_cflags) ],
AC_MSG_ERROR(Cannot find eet: Is eet-config in path?))
eet_libs=`eet-config --libs`
eet_cflags=`eet-config --cflags`
AC_SUBST(eet_flags)
AC_SUBST(eet_cflags)
AC_PATH_GENERIC(evas, 0.9.9, [
AC_SUBST(evas_libs)
AC_SUBST(evas_cflags) ],
AC_MSG_ERROR(Cannot find evas: Is evas-config in path?))
evas_libs=`evas-config --libs`
evas_cflags=`evas-config --cflags`
AC_SUBST(evas_libs)
AC_SUBST(evas_cflags)
AC_PATH_GENERIC(ecore, 0.9.9, [
AC_SUBST(ecore_libs)
AC_SUBST(ecore_cflags) ],
AC_MSG_ERROR(Cannot find ecore: Is ecore-config in path?))
ecore_libs=`ecore-config --libs`
ecore_cflags=`ecore-config --cflags`
AC_SUBST(ecore_libs)
AC_SUBST(ecore_cflags)
AC_PATH_GENERIC(embryo, 0.5.0, [
AC_SUBST(embryo_libs)
AC_SUBST(embryo_cflags) ],
AC_MSG_ERROR(Cannot find embryo: Is embryo-config in path?))
embryo_libs=`embryo-config --libs`
embryo_cflags=`embryo-config --cflags`
AC_SUBST(embryo_libs)
AC_SUBST(embryo_cflags)
AC_PATH_GENERIC(edje, 0.5.0, [
AC_SUBST(edje_libs)
AC_SUBST(edje_cflags) ],
AC_MSG_ERROR(Cannot find edje: Is edje-config in path?))
edje_libs=`edje-config --libs`
edje_cflags=`edje-config --cflags`
AC_SUBST(edje_libs)
AC_SUBST(edje_cflags)
edje_cc="`$EDJE_CONFIG --prefix`/bin/edje_cc"
AC_ARG_WITH(edje-cc,
[ --with-edje-cc=PATH specify a specific path to edje_cc],
[
v=$withval;
edje_cc=$v
echo " Enlightenment edje_cc explicitly set to "$edje_cc;
],[
edje_cc="`$EDJE_CONFIG --prefix`/bin/edje_cc"
])
AC_SUBST(edje_cc)
AC_PATH_GENERIC(enlightenment, 0.16.999, [
AC_SUBST(e_libs)
AC_SUBST(e_cflags) ],
AC_MSG_ERROR(Cannot find enlightenment: Is enlightenment-config in path?))
e_libs=`enlightenment-config --libs`
e_cflags=`enlightenment-config --cflags`
AC_SUBST(e_libs)
AC_SUBST(e_cflags)
MODULE_ARCH="$host_os-$host_cpu"
AC_SUBST(MODULE_ARCH)
AC_PREFIX_DEFAULT(${HOME}/.e/e)
if test "x$prefix" = "xNONE"; then
prefix=${ac_default_prefix}
datarootdir=${prefix}
moduledir=${prefix}/modules
else
datarootdir=${prefix}/share
moduledir=${prefix}/lib/enlightenment/modules
fi
AC_SUBST(MODULEDIR, "${moduledir}")
localedir=${datarootdir}/locale
AC_SUBST(LOCALEDIR, "${localedir}")
AC_DEFINE_UNQUOTED(LOCALEDIR, "${localedir}", [Module Locale Directory])
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([limits.h string.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_STRUCT_TM
# Checks for library functions.
AC_CHECK_FUNCS([sqrt strdup])
AC_CONFIG_FILES([Makefile
data/Makefile
data/themes/Makefile
data/themes/images/Makefile
po/Makefile
src/Makefile])
AC_OUTPUT

2
data/Makefile.am Normal file
View File

@ -0,0 +1,2 @@
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = themes

34
data/themes/Makefile.am Normal file
View File

@ -0,0 +1,34 @@
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = images
moduledir = @MODULEDIR@
EDJE_CC = @edje_cc@
EDJE_FLAGS = \
-v \
-id $(top_srcdir)/data/themes/images
# data files for the module
filesdir = $(moduledir)/$(PACKAGE)
files_DATA = \
moon.eap \
moon.edj
EXTRA_DIST = \
moon.edc \
icon.edc
moon.edj: Makefile $(EXTRA_DIST)
$(EDJE_CC) $(EDJE_FLAGS) \
$(top_srcdir)/data/themes/moon.edc \
moon.edj
moon.eap: Makefile $(EXTRA_DIST)
$(EDJE_CC) $(EDJE_FLAGS) \
$(top_srcdir)/data/themes/icon.edc \
moon.eap
clean-local:
rm -rf *.edj; rm -rf *.eap

19
data/themes/icon.edc Normal file
View File

@ -0,0 +1,19 @@
images {
image: "moon.png" COMP;
}
collections {
group {
name: "icon";
parts {
part {
name: "image";
mouse_events: 0;
description {
state: "default" 0.0;
aspect: 1.0 1.0;
image.normal: "moon.png";
}
}
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,67 @@
MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = \
moon.png \
e17_ibar_bg_h.png \
e17_ibar_over_h.png \
e17_about_sky3.png \
E-MoonClock-00.png \
E-MoonClock-01.png \
E-MoonClock-02.png \
E-MoonClock-03.png \
E-MoonClock-04.png \
E-MoonClock-05.png \
E-MoonClock-06.png \
E-MoonClock-07.png \
E-MoonClock-08.png \
E-MoonClock-09.png \
E-MoonClock-10.png \
E-MoonClock-11.png \
E-MoonClock-12.png \
E-MoonClock-13.png \
E-MoonClock-14.png \
E-MoonClock-15.png \
E-MoonClock-16.png \
E-MoonClock-17.png \
E-MoonClock-18.png \
E-MoonClock-19.png \
E-MoonClock-20.png \
E-MoonClock-21.png \
E-MoonClock-22.png \
E-MoonClock-23.png \
E-MoonClock-24.png \
E-MoonClock-25.png \
E-MoonClock-26.png \
E-MoonClock-27.png \
E-MoonClock-28.png \
E-MoonClock-29.png \
E-MoonClock-30.png \
E-MoonClock-31.png \
E-MoonClock-32.png \
E-MoonClock-33.png \
E-MoonClock-34.png \
E-MoonClock-35.png \
E-MoonClock-36.png \
E-MoonClock-37.png \
E-MoonClock-38.png \
E-MoonClock-39.png \
E-MoonClock-40.png \
E-MoonClock-41.png \
E-MoonClock-42.png \
E-MoonClock-43.png \
E-MoonClock-44.png \
E-MoonClock-45.png \
E-MoonClock-46.png \
E-MoonClock-47.png \
E-MoonClock-48.png \
E-MoonClock-49.png \
E-MoonClock-50.png \
E-MoonClock-51.png \
E-MoonClock-52.png \
E-MoonClock-53.png \
E-MoonClock-54.png \
E-MoonClock-55.png \
E-MoonClock-56.png \
E-MoonClock-57.png \
E-MoonClock-58.png \
E-MoonClock-59.png

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
data/themes/images/moon.png Normal file

Binary file not shown.

363
data/themes/moon.edc Normal file
View File

@ -0,0 +1,363 @@
#define POLICY_NEVER 0
#define POLICY_ALWAYS 1
#define POLICY_ON_MOUSE_OVER 2
images {
image: "e17_about_sky3.png" LOSSY 70;
image: "E-MoonClock-00.png" COMP;
image: "E-MoonClock-01.png" COMP;
image: "E-MoonClock-02.png" COMP;
image: "E-MoonClock-03.png" COMP;
image: "E-MoonClock-04.png" COMP;
image: "E-MoonClock-05.png" COMP;
image: "E-MoonClock-06.png" COMP;
image: "E-MoonClock-07.png" COMP;
image: "E-MoonClock-08.png" COMP;
image: "E-MoonClock-09.png" COMP;
image: "E-MoonClock-10.png" COMP;
image: "E-MoonClock-11.png" COMP;
image: "E-MoonClock-12.png" COMP;
image: "E-MoonClock-13.png" COMP;
image: "E-MoonClock-14.png" COMP;
image: "E-MoonClock-15.png" COMP;
image: "E-MoonClock-16.png" COMP;
image: "E-MoonClock-17.png" COMP;
image: "E-MoonClock-18.png" COMP;
image: "E-MoonClock-19.png" COMP;
image: "E-MoonClock-20.png" COMP;
image: "E-MoonClock-21.png" COMP;
image: "E-MoonClock-22.png" COMP;
image: "E-MoonClock-23.png" COMP;
image: "E-MoonClock-24.png" COMP;
image: "E-MoonClock-25.png" COMP;
image: "E-MoonClock-26.png" COMP;
image: "E-MoonClock-27.png" COMP;
image: "E-MoonClock-28.png" COMP;
image: "E-MoonClock-29.png" COMP;
image: "E-MoonClock-30.png" COMP;
image: "E-MoonClock-31.png" COMP;
image: "E-MoonClock-32.png" COMP;
image: "E-MoonClock-33.png" COMP;
image: "E-MoonClock-34.png" COMP;
image: "E-MoonClock-35.png" COMP;
image: "E-MoonClock-36.png" COMP;
image: "E-MoonClock-37.png" COMP;
image: "E-MoonClock-38.png" COMP;
image: "E-MoonClock-39.png" COMP;
image: "E-MoonClock-40.png" COMP;
image: "E-MoonClock-41.png" COMP;
image: "E-MoonClock-42.png" COMP;
image: "E-MoonClock-43.png" COMP;
image: "E-MoonClock-44.png" COMP;
image: "E-MoonClock-45.png" COMP;
image: "E-MoonClock-46.png" COMP;
image: "E-MoonClock-47.png" COMP;
image: "E-MoonClock-48.png" COMP;
image: "E-MoonClock-38.png" COMP;
image: "E-MoonClock-49.png" COMP;
image: "E-MoonClock-50.png" COMP;
image: "E-MoonClock-51.png" COMP;
image: "E-MoonClock-52.png" COMP;
image: "E-MoonClock-53.png" COMP;
image: "E-MoonClock-54.png" COMP;
image: "E-MoonClock-55.png" COMP;
image: "E-MoonClock-56.png" COMP;
image: "E-MoonClock-57.png" COMP;
image: "E-MoonClock-58.png" COMP;
image: "E-MoonClock-59.png" COMP;
}
collections {
group {
name: "module/moon/main";
min: 10 10;
max: 256 256;
script {
/* Display phase value policy - ALWAYS, NEVER, ON MOUSE OVER */
public global_show_phase_val;
/* Display cloud animations - ALWAYS, NEVER */
public global_show_cloud_anim;
apply_config(a1, a2, a3)
{
set_int(global_show_phase_val, a1);
if ((a1 == POLICY_NEVER) || (a1 == POLICY_ON_MOUSE_OVER))
run_program(PROGRAM:"phasevalue_out");
else if (a1 == POLICY_ALWAYS)
run_program(PROGRAM:"phasevalue_in");
// a2 is now obselete
a2 = a2 + 1
if (a3 != get_int(global_show_cloud_anim))
{
if (a3 == POLICY_ALWAYS)
{
set_state(PART:"sky", "displayed", 0.0);
run_program(PROGRAM:"anim_sky");
}
else if (a3 == POLICY_NEVER)
{
stop_program(PROGRAM:"anim_sky");
set_state(PART:"sky", "default", 0.0);
}
set_int(global_show_cloud_anim, a3);
}
}
public message(Msg_Type:type, id, ...)
{
if (type == MSG_STRING_FLOAT_SET)
{
/* received moon phase information */
new str[100];
getsarg(2, str, 100);
set_text(PART:"phasevalue", str);
set_state(PART:"moonphase", "default", getfarg(3));
}
else if (type == MSG_INT_SET)
{
/* received configuration settings */
if (numargs() != 5)
return;
apply_config(getarg(2), getarg(3), getarg(4));
}
}
}
parts {
part {
name: "moonphase";
mouse_events: 1; // for POLICY_ON_MOUSE_OVER
description {
state: "default" 0.0;
aspect: 1.0 1.0;
rel1 {
relative: 0.05 0.05;
}
rel2 {
relative: 0.95 0.95;
}
image {
normal: "E-MoonClock-00.png";
}
}
# ifdef PHASE
# undef PHASE
# endif
# define PHASE(NAME) \
description { \
state: "default" (NAME.0 / 60.0); \
inherit: "default" 0.0; \
image { \
normal: "E-MoonClock-"NAME".png"; \
} \
}
PHASE(01)
PHASE(02)
PHASE(03)
PHASE(04)
PHASE(05)
PHASE(06)
PHASE(07)
PHASE(08)
PHASE(09)
PHASE(10)
PHASE(11)
PHASE(12)
PHASE(13)
PHASE(14)
PHASE(15)
PHASE(16)
PHASE(17)
PHASE(18)
PHASE(19)
PHASE(20)
PHASE(21)
PHASE(22)
PHASE(23)
PHASE(24)
PHASE(25)
PHASE(26)
PHASE(27)
PHASE(28)
PHASE(29)
PHASE(30)
PHASE(31)
PHASE(32)
PHASE(33)
PHASE(34)
PHASE(35)
PHASE(36)
PHASE(37)
PHASE(38)
PHASE(39)
PHASE(40)
PHASE(41)
PHASE(42)
PHASE(43)
PHASE(44)
PHASE(45)
PHASE(46)
PHASE(47)
PHASE(48)
PHASE(49)
PHASE(50)
PHASE(51)
PHASE(52)
PHASE(53)
PHASE(54)
PHASE(55)
PHASE(56)
PHASE(57)
PHASE(58)
PHASE(59)
}
part {
name: "sky";
mouse_events: 0;
description {
state: "default" 0.0;
visible: 0;
rel1 {
to: "moonphase";
}
rel2 {
to: "moonphase";
}
image {
normal: "e17_about_sky3.png";
}
fill {
smooth: 0;
size {
relative: 8.53 1.0;
}
}
}
description {
state: "displayed" 0.0;
inherit: "default" 0.0;
visible: 1;
}
description {
state: "drift" 0.0;
inherit: "default" 0.0;
visible: 1;
fill {
origin {
relative: -8.53 0.0;
}
}
}
}
part {
name: "phasevalue";
type: TEXT;
mouse_events: 0;
effect: SHADOW;
description {
state: "default" 0.0;
visible: 1;
min: 12 12;
rel1 {
relative: 0.0 0.0;
offset: 0 1;
to: "moonphase";
}
rel2 {
relative: 1.0 0.20;
to: "moonphase";
}
color: 0 0 0 0;
color3: 0 0 0 0;
text {
text: "Moon Phase";
size: 11;
// min: 1 1;
fit: 1 1;
align: 0.5 0.5;
}
}
description {
state: "displayed" 0.0;
inherit: "default" 0.0;
color: 255 255 255 167;
color3: 0 0 0 32;
}
}
}
programs {
program {
name: "edje_mousein";
signal: "mouse,in";
source: "moonphase";
script
{
new val = get_int(global_show_phase_val);
if (val == POLICY_ON_MOUSE_OVER)
run_program(PROGRAM:"phasevalue_in");
}
}
program {
name: "edje_mouseout";
signal: "mouse,out";
source: "moonphase";
script
{
new val = get_int(global_show_phase_val);
if (val == POLICY_ON_MOUSE_OVER)
run_program(PROGRAM:"phasevalue_out");
}
}
program {
name: "phasevalue_out";
action: STATE_SET "default" 0.0;
transition: LINEAR 0.4;
target: "phasevalue";
}
program {
name: "phasevalue_in";
action: STATE_SET "displayed" 0.0;
transition: SINUSOIDAL 0.4;
target: "phasevalue";
}
program {
name: "anim_sky";
action: STATE_SET "drift" 0.0;
transition: LINEAR 100.0;
target: "sky";
after: "anim_sky_control";
}
program {
name: "anim_sky_control";
action: STATE_SET "displayed" 0.0;
target: "sky";
after: "anim_sky";
/*
signal: "";
source: "";
script
{
new val;
val = get_int(global_show_cloud_anim);
if (val == POLICY_NEVER)
{
stop_program(PROGRAM:"anim_sky");
// uncomment this, and it's segv time
set_state(PART:"sky", "default", 0.0);
}
if (val == POLICY_ALWAYS)
{
set_state(PART:"sky", "displayed", 0.0);
run_program(PROGRAM:"anim_sky");
}
}
*/
}
}
}
}

136
m4/ac_path_generic.m4 Normal file
View File

@ -0,0 +1,136 @@
dnl @synopsis AC_PATH_GENERIC(LIBRARY [, MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
dnl
dnl Runs a LIBRARY-config script and defines LIBRARY_CFLAGS and LIBRARY_LIBS
dnl
dnl The script must support `--cflags' and `--libs' args.
dnl If MINIMUM-VERSION is specified, the script must also support the
dnl `--version' arg.
dnl If the `--with-library-[exec-]prefix' arguments to ./configure are given,
dnl it must also support `--prefix' and `--exec-prefix'.
dnl (In other words, it must be like gtk-config.)
dnl
dnl For example:
dnl
dnl AC_PATH_GENERIC(Foo, 1.0.0)
dnl
dnl would run `foo-config --version' and check that it is at least 1.0.0
dnl
dnl If so, the following would then be defined:
dnl
dnl FOO_CFLAGS to `foo-config --cflags`
dnl FOO_LIBS to `foo-config --libs`
dnl
dnl At present there is no support for additional "MODULES" (see AM_PATH_GTK)
dnl (shamelessly stolen from gtk.m4 and then hacked around a fair amount)
dnl
dnl @author Angus Lees <gusl@cse.unsw.edu.au>
AC_DEFUN([AC_PATH_GENERIC],
[dnl
dnl we're going to need uppercase, lowercase and user-friendly versions of the
dnl string `LIBRARY'
pushdef([UP], translit([$1], [a-z], [A-Z]))dnl
pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl
dnl
dnl Get the cflags and libraries from the LIBRARY-config script
dnl
AC_ARG_WITH(DOWN-prefix,[ --with-]DOWN[-prefix=PFX Prefix where $1 is installed (optional)],
DOWN[]_config_prefix="$withval", DOWN[]_config_prefix="")
AC_ARG_WITH(DOWN-exec-prefix,[ --with-]DOWN[-exec-prefix=PFX Exec prefix where $1 is installed (optional)],
DOWN[]_config_exec_prefix="$withval", DOWN[]_config_exec_prefix="")
if test x$DOWN[]_config_exec_prefix != x ; then
DOWN[]_config_args="$DOWN[]_config_args --exec-prefix=$DOWN[]_config_exec_prefix"
if test x${UP[]_CONFIG+set} != xset ; then
UP[]_CONFIG=$DOWN[]_config_exec_prefix/bin/DOWN-config
fi
fi
if test x$DOWN[]_config_prefix != x ; then
DOWN[]_config_args="$DOWN[]_config_args --prefix=$DOWN[]_config_prefix"
if test x${UP[]_CONFIG+set} != xset ; then
UP[]_CONFIG=$DOWN[]_config_prefix/bin/DOWN-config
fi
fi
AC_PATH_PROG(UP[]_CONFIG, DOWN-config, no)
ifelse([$2], ,
AC_MSG_CHECKING(for $1),
AC_MSG_CHECKING(for $1 - version >= $2)
)
no_[]DOWN=""
if test "$UP[]_CONFIG" = "no" ; then
no_[]DOWN=yes
else
UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args --cflags`"
UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args --libs`"
ifelse([$2], , ,[
DOWN[]_config_major_version=`$UP[]_CONFIG $DOWN[]_config_args \
--version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\1/'`
DOWN[]_config_minor_version=`$UP[]_CONFIG $DOWN[]_config_args \
--version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\2/'`
DOWN[]_config_micro_version=`$UP[]_CONFIG $DOWN[]_config_args \
--version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\3/'`
DOWN[]_wanted_major_version="regexp($2, [\<\([0-9]*\)], [\1])"
DOWN[]_wanted_minor_version="regexp($2, [\<\([0-9]*\)\.\([0-9]*\)], [\2])"
DOWN[]_wanted_micro_version="regexp($2, [\<\([0-9]*\).\([0-9]*\).\([0-9]*\)], [\3])"
# Compare wanted version to what config script returned.
# If I knew what library was being run, i'd probably also compile
# a test program at this point (which also extracted and tested
# the version in some library-specific way)
if test "$DOWN[]_config_major_version" -lt \
"$DOWN[]_wanted_major_version" \
-o \( "$DOWN[]_config_major_version" -eq \
"$DOWN[]_wanted_major_version" \
-a "$DOWN[]_config_minor_version" -lt \
"$DOWN[]_wanted_minor_version" \) \
-o \( "$DOWN[]_config_major_version" -eq \
"$DOWN[]_wanted_major_version" \
-a "$DOWN[]_config_minor_version" -eq \
"$DOWN[]_wanted_minor_version" \
-a "$DOWN[]_config_micro_version" -lt \
"$DOWN[]_wanted_micro_version" \) ; then
# older version found
no_[]DOWN=yes
echo -n "*** An old version of $1 "
echo -n "($DOWN[]_config_major_version"
echo -n ".$DOWN[]_config_minor_version"
echo ".$DOWN[]_config_micro_version) was found."
echo -n "*** You need a version of $1 newer than "
echo -n "$DOWN[]_wanted_major_version"
echo -n ".$DOWN[]_wanted_minor_version"
echo ".$DOWN[]_wanted_micro_version."
echo "***"
echo "*** If you have already installed a sufficiently new version, this error"
echo "*** probably means that the wrong copy of the DOWN-config shell script is"
echo "*** being found. The easiest way to fix this is to remove the old version"
echo "*** of $1, but you can also set the UP[]_CONFIG environment to point to the"
echo "*** correct copy of DOWN-config. (In this case, you will have to"
echo "*** modify your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf"
echo "*** so that the correct libraries are found at run-time)"
fi
])
fi
if test "x$no_[]DOWN" = x ; then
AC_MSG_RESULT(yes)
ifelse([$3], , :, [$3])
else
AC_MSG_RESULT(no)
if test "$UP[]_CONFIG" = "no" ; then
echo "*** The DOWN-config script installed by $1 could not be found"
echo "*** If $1 was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the UP[]_CONFIG environment variable to the"
echo "*** full path to DOWN-config."
fi
UP[]_CFLAGS=""
UP[]_LIBS=""
ifelse([$4], , :, [$4])
fi
AC_SUBST(UP[]_CFLAGS)
AC_SUBST(UP[]_LIBS)
popdef([UP])
popdef([DOWN])
])

28
po/Makefile.am Normal file
View File

@ -0,0 +1,28 @@
MAINTAINERCLEANFILES = Makefile.in $(PACKAGE).pot
MSGFMT = msgfmt
localedir = @LOCALEDIR@
locale_DATA = $(addsuffix .mo,$(ALL_LINGUAS))
EXTRA_DIST = moon.pot $(addsuffix .po,$(ALL_LINGUAS))
%.mo : %.po
$(MSGFMT) -f -o $@ $<
install-localeDATA:
uninstall-localeDATA:
install-data-local:
for L in $(ALL_LINGUAS); do \
$(mkinstalldirs) $(DESTDIR)$(localedir)/$$L/LC_MESSAGES; \
$(INSTALL_DATA) \
$$L.mo $(DESTDIR)$(localedir)/$$L/LC_MESSAGES/$(PACKAGE).mo; \
done
uninstall:
for L in $(ALL_LINGUAS); do \
rm -f $(DESTDIR)$(localedir)/$$L/LC_MESSAGES/$(PACKAGE).mo; \
done
clean-local:
rm -f *.mo

54
po/it.po Normal file
View File

@ -0,0 +1,54 @@
# Italian translation for E17 Moon module.
# This file is put in the public domain.
# Massimo Maiurana <maiurana@inwind.it>, 2006.
#
msgid ""
msgstr ""
"Project-Id-Version: Moon\n"
"PO-Revision-Date: 2006-01-26 20:50+0100\n"
"Last-Translator: Massimo Maiurana <maiurana@inwind.it>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/e_mod_config.c:146
msgid "Moon Configuration"
msgstr "Configurazione modulo Moon"
#: src/e_mod_config.c:203
msgid "Display Settings"
msgstr "Impostazioni di visualizzazione"
#: src/e_mod_config.c:204
msgid "Show Border"
msgstr "Mostra bordo"
#: src/e_mod_config.c:206
msgid "Animated Clouds"
msgstr "Nuvole animate"
#: src/e_mod_config.c:210
msgid "Moon Phase Value"
msgstr "Valore della fase lunare"
#: src/e_mod_config.c:212
msgid "Show always"
msgstr "Mostra sempre"
#: src/e_mod_config.c:214
msgid "Show on mouse over"
msgstr "Mostra al passaggio del mouse"
#: src/e_mod_config.c:216
msgid "Never show"
msgstr "Non mostrare mai"
#: src/e_mod_main.c:86
msgid "Moon Clock Module"
msgstr "Modulo orologio lunare"
#: src/e_mod_main.c:87
msgid "Display current phase of the moon ala e16 E-MoonClock"
msgstr "Mostra l'attuale fase lunare in stile E-MoonClock di e16"

94
po/ja.po Normal file
View File

@ -0,0 +1,94 @@
# Japanese translation for E17 Moon module.
# This file is put in the public domain.
# David Steveson <david35472@gmail.com>, 2006.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2006-02-21 01:05+0900\n"
"PO-Revision-Date: 2006-01-29 22:45+0900\n"
"Last-Translator: David <david35472@gmail.com>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: moon-0.1.0/src/e_mod_config.c:146 src/e_mod_config.c:146
msgid "Moon Configuration"
msgstr "月モジュールの設定"
#: moon-0.1.0/src/e_mod_config.c:203 src/e_mod_config.c:203
msgid "Display Settings"
msgstr "表示設定"
#: moon-0.1.0/src/e_mod_config.c:204 src/e_mod_config.c:204
msgid "Show Border"
msgstr "ボーダーを表示する"
#: moon-0.1.0/src/e_mod_config.c:206 src/e_mod_config.c:206
msgid "Animated Clouds"
msgstr "雲を表示する"
#: moon-0.1.0/src/e_mod_config.c:210 src/e_mod_config.c:210
msgid "Moon Phase Value"
msgstr "月の満ち欠け状態値"
#: moon-0.1.0/src/e_mod_config.c:212 src/e_mod_config.c:212
msgid "Show always"
msgstr "常に表示する"
#: moon-0.1.0/src/e_mod_config.c:214 src/e_mod_config.c:214
msgid "Show on mouse over"
msgstr "マウスがあると表示する"
#: moon-0.1.0/src/e_mod_config.c:216 src/e_mod_config.c:216
msgid "Never show"
msgstr "表示しない"
#: moon-0.1.0/src/e_mod_main.c:86 src/e_mod_main.c:85
msgid "Moon Clock Module"
msgstr "月の相モジュール"
#: moon-0.1.0/src/e_mod_main.c:87 src/e_mod_main.c:88
msgid "Display current phase of the moon ala e16 E-MoonClock"
msgstr "月の満ち欠け状態を表示するモジュール"
#: src/e_mod_main.c:478
msgid "New Moon"
msgstr "新月"
#: src/e_mod_main.c:479
msgid "Waxing Crescent"
msgstr "三日月"
#: src/e_mod_main.c:480
msgid "First Quarter"
msgstr "上弦"
#: src/e_mod_main.c:481
msgid "Waxing Gibbous"
msgstr "凸月"
#: src/e_mod_main.c:482
msgid "Full Moon"
msgstr "満月"
#: src/e_mod_main.c:483
msgid "Waning Gibbous"
msgstr "欠月"
#: src/e_mod_main.c:484
msgid "Last Quarter"
msgstr "下弦"
#: src/e_mod_main.c:485
msgid "Waning Crescent"
msgstr "衰月"
#~ msgid "Moon Phase Calculation Interval"
#~ msgstr "月の満ち欠け状態の計算間隔"
#~ msgid "%1.2f seconds"
#~ msgstr "%1.2f秒"

57
po/sv.po Normal file
View File

@ -0,0 +1,57 @@
# Swedish translation for E17 Moon module.
# This file is put in the public domain.
# Anders Troback <enlightenment@troback.com>, 2006.
#
#
msgid ""
msgstr ""
"Project-Id-Version: Moon\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2006-01-25 22:05+0900\n"
"PO-Revision-Date: 2006-01-28 00:43+0100\n"
"Last-Translator: Anders Troback <enlightenment@troback.com>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/e_mod_config.c:146
msgid "Moon Configuration"
msgstr "Månkonfiguration"
#: src/e_mod_config.c:203
msgid "Display Settings"
msgstr "Visa"
#: src/e_mod_config.c:204
msgid "Show Border"
msgstr "Visa ram"
#: src/e_mod_config.c:206
msgid "Animated Clouds"
msgstr "Animerade moln"
#: src/e_mod_config.c:210
msgid "Moon Phase Value"
msgstr "Månfasvärde"
#: src/e_mod_config.c:212
msgid "Show always"
msgstr "Visa alltid"
#: src/e_mod_config.c:214
msgid "Show on mouse over"
msgstr "Visa när musen är över"
#: src/e_mod_config.c:216
msgid "Never show"
msgstr "Visa aldrig"
#: src/e_mod_main.c:86
msgid "Moon Clock Module"
msgstr "Månklocksmodul"
#: src/e_mod_main.c:87
msgid "Display current phase of the moon ala e16 E-MoonClock"
msgstr "Visa aktuell månfas ala e16 E-MoonClock"

419
src/CalcEphem.c Normal file
View File

@ -0,0 +1,419 @@
#include <math.h>
#include <string.h>
#include "CalcEphem.h"
int DayofYear(int, int, int);
int DayofWeek(int, int, int, char[]);
double kepler(double, double);
double jd(int, int, int, double);
double hour24(double);
double angle2pi(double);
double angle360(double);
void Radec_to_Cart(double, double, Vector *);
int LeapYear(int);
int DayofYear(year, month, day)
int year, month, day;
{
double jd();
return((int)(jd(year, month, day, 0.0) - jd(year, 1, 0, 0.0)));
}
int DayofWeek(year, month, day, dowstr)
int year, month, day;
char dowstr[];
{
double JD, A, Afrac, jd();
int n, iA;
JD = jd(year, month, day, 0.0);
A = (JD + 1.5)/7.0;
iA = (int)A;
Afrac = A - (double)iA;
n = (int)(Afrac*7.0 + 0.5);
switch(n){
case 0:
strcpy(dowstr, "Sunday");
break;
case 1:
strcpy(dowstr, "Monday");
break;
case 2:
strcpy(dowstr, "Tuesday");
break;
case 3:
strcpy(dowstr, "Wednesday");
break;
case 4:
strcpy(dowstr, "Thursday");
break;
case 5:
strcpy(dowstr, "Friday");
break;
case 6:
strcpy(dowstr, "Saturday");
break;
}
return(n);
}
void
CalcEphem(date, UT, c)
long int date; /* integer containing the date (e.g. 960829) */
double UT; /* Universal Time */
CTrans *c; /* structure containing all the relevent coord trans info */
{
int year, month, day;
double TU, TU2, TU3, T0, gmst;
double varep, varpi;
double eccen, epsilon;
double days, M, E, nu, lambnew;
double r0, earth_sun_distance;
double RA, DEC, RA_Moon, DEC_Moon;
double TDT;
double AGE;
double LambdaMoon, BetaMoon, R;
double jd(), hour24(), angle2pi(), angle360(), kepler(), Moon(), NewMoon();
double Ta, Tb, Tc, frac();
double SinGlat, CosGlat, SinGlon, CosGlon, Tau, lmst, x, y, z;
double SinTau, CosTau, SinDec, CosDec;
c->UT = UT;
year = (int)(date/10000);
month = (int)( (date - year*10000)/100 );
day = (int)( date - year*10000 - month*100 );
c->year = year;
c->month = month;
c->day = day;
c->doy = DayofYear(year, month, day);
c->dow = DayofWeek(year, month, day, c->dowstr);
/*
* Compute Greenwich Mean Sidereal Time (gmst)
* The TU here is number of Julian centuries
* since 2000 January 1.5
* From the 1996 astronomical almanac
*/
TU = (jd(year, month, day, 0.0) - 2451545.0)/36525.0;
TU2 = TU*TU;
TU3 = TU2*TU;
T0 = (6.0 + 41.0/60.0 + 50.54841/3600.0) + 8640184.812866/3600.0*TU
+ 0.093104/3600.0*TU2 - 6.2e-6/3600.0*TU3;
T0 = hour24(T0);
c->gmst = hour24(T0 + UT*1.002737909);
/* convert to radians for ease later on */
gmst = c->gmst*15.0*M_PI/180.0;
lmst = 24.0*frac( (c->gmst - c->Glon/15.0) / 24.0 );
/*
*
* Construct Transformation Matrix from GEI to GSE systems
*
*
* First compute:
* mean ecliptic longitude of sun at epoch TU (varep)
* elciptic longitude of perigee at epoch TU (varpi)
* eccentricity of orbit at epoch TU (eccen)
*
* The TU here is the number of Julian centuries since
* 1900 January 0.0 (= 2415020.0)
*/
TDT = UT + 59.0/3600.0;
TU = (jd(year, month, day, TDT) - 2415020.0)/36525.0;
varep = (279.6966778 + 36000.76892*TU + 0.0003025*TU*TU)*RadPerDeg;
varpi = (281.2208444 + 1.719175*TU + 0.000452778*TU*TU)*RadPerDeg;
eccen = 0.01675104 - 0.0000418*TU - 0.000000126*TU*TU;
c->eccentricity = eccen;
/*
* Compute the Obliquity of the Ecliptic at epoch TU
* The TU in this formula is the number of Julian
* centuries since epoch 2000 January 1.5
*/
TU = (jd(year, month, day, TDT) - jd(2000, 1, 1, 12.0))/36525.0;
epsilon = (23.43929167 - 0.013004166*TU - 1.6666667e-7*TU*TU
- 5.0277777778e-7*TU*TU*TU)*RadPerDeg;
c->epsilon = epsilon;
/*
* Compute:
* Number of Days since epoch 1990.0 (days)
* The Mean Anomaly (M)
* The True Anomaly (nu)
* The Eccentric Anomaly via Keplers equation (E)
*
*
*/
days = jd(year, month, day, TDT) - jd(year, month, day, TDT);
M = angle2pi(2.0*M_PI/365.242191*days + varep - varpi);
E = kepler(M, eccen);
nu = 2.0*atan( sqrt((1.0+eccen)/(1.0-eccen))*tan(E/2.0) );
lambnew = angle2pi(nu + varpi);
c->lambda_sun = lambnew;
/*
* Compute distance from earth to the sun
*/
r0 = 1.495985e8; /* in km */
earth_sun_distance = r0*(1-eccen*eccen)/(1.0 + eccen*cos(nu))/6371.2;
c->earth_sun_dist = earth_sun_distance;
/*
* Compute Right Ascension and Declination of the Sun
*/
RA = angle360(atan2(sin(lambnew)*cos(epsilon), cos(lambnew))*180.0/M_PI);
DEC = asin(sin(epsilon)*sin(lambnew))*180.0/M_PI;
c->RA_sun = RA;
c->DEC_sun = DEC;
/*
* Compute Moon Phase and AGE Stuff. The AGE that comes out of Moon()
* is actually the Phase converted to days. Since AGE is actually defined
* to be time since last NewMoon, we need to figure out what the JD of the
* last new moon was. Thats done below....
*/
TU = (jd(year, month, day, TDT) - 2451545.0)/36525.0;
c->MoonPhase = Moon(TU, &LambdaMoon, &BetaMoon, &R, &AGE);
LambdaMoon *= RadPerDeg;
BetaMoon *= RadPerDeg;
RA_Moon = angle360(atan2(sin(LambdaMoon)*cos(epsilon)-tan(BetaMoon)*sin(epsilon), cos(LambdaMoon))*DegPerRad);
DEC_Moon = asin( sin(BetaMoon)*cos(epsilon) + cos(BetaMoon)*sin(epsilon)*sin(LambdaMoon))*DegPerRad;
c->RA_moon = RA_Moon;
c->DEC_moon = DEC_Moon;
/*
* Compute Alt/Az coords
*/
Tau = (15.0*lmst - RA_Moon)*RadPerDeg;
CosGlat = cos(c->Glat*RadPerDeg); SinGlat = sin(c->Glat*RadPerDeg);
CosGlon = cos(c->Glon*RadPerDeg); SinGlon = sin(c->Glon*RadPerDeg);
CosTau = cos(Tau); SinTau = sin(Tau);
SinDec = sin(DEC_Moon*RadPerDeg); CosDec = cos(DEC_Moon*RadPerDeg);
x = CosDec*CosTau*SinGlat - SinDec*CosGlat;
y = CosDec*SinTau;
z = CosDec*CosTau*CosGlat + SinDec*SinGlat;
c->A_moon = DegPerRad*atan2(y, x);
c->h_moon = DegPerRad*asin(z);
c->Visible = (c->h_moon < 0.0) ? 0 : 1;
/*
* Compute accurate AGE of the Moon
*/
Tb = TU - AGE/36525.0; /* should be very close to minimum */
Ta = Tb - 0.4/36525.0;
Tc = Tb + 0.4/36525.0;
c->MoonAge = (TU - NewMoon(Ta, Tb, Tc))*36525.0;
/*
* Compute Earth-Moon distance
*/
c->EarthMoonDistance = R;
}
double kepler(M, e)
double M, e;
{
int n=0;
double E, Eold, eps = 1.0e-8;
E = M + e*sin(M);
do{
Eold = E;
E = Eold + (M-Eold+e*sin(Eold))
/(1.0-e*cos(Eold));
++n;
}while((fabs(E-Eold) > eps) && (n < 100));
return(E);
}
/*
* Compute the Julian Day number for the given date.
* Julian Date is the number of days since noon of Jan 1 4713 B.C.
*/
double jd(ny, nm, nd, UT)
int ny, nm, nd;
double UT;
{
double A, B, C, D, JD, day;
day = nd + UT/24.0;
if ((nm == 1) || (nm == 2)){
ny = ny - 1;
nm = nm + 12;
}
if (((double)ny+nm/12.0+day/365.25)>=(1582.0+10.0/12.0+15.0/365.25)){
A = ((int)(ny / 100.0));
B = 2.0 - A + (int)(A/4.0);
}
else{
B = 0.0;
}
if (ny < 0.0){
C = (int)((365.25*(double)ny) - 0.75);
}
else{
C = (int)(365.25*(double)ny);
}
D = (int)(30.6001*(double)(nm+1));
JD = B + C + D + day + 1720994.5;
return(JD);
}
double hour24(hour)
double hour;
{
int n;
if (hour < 0.0){
n = (int)(hour/24.0) - 1;
return(hour-n*24.0);
}
else if (hour > 24.0){
n = (int)(hour/24.0);
return(hour-n*24.0);
}
else{
return(hour);
}
}
double angle2pi(angle)
double angle;
{
int n;
double a;
a = 2.0*M_PI;
if (angle < 0.0){
n = (int)(angle/a) - 1;
return(angle-n*a);
}
else if (angle > a){
n = (int)(angle/a);
return(angle-n*a);
}
else{
return(angle);
}
}
double angle360(angle)
double angle;
{
int n;
if (angle < 0.0){
n = (int)(angle/360.0) - 1;
return(angle-n*360.0);
}
else if (angle > 360.0){
n = (int)(angle/360.0);
return(angle-n*360.0);
}
else{
return(angle);
}
}
void
Radec_to_Cart(ra, dec, r)
double ra, dec; /* RA and DEC */
Vector *r; /* returns corresponding cartesian unit vector */
{
/*
* Convert ra/dec from degrees to radians
*/
ra *= RadPerDeg;
dec *= RadPerDeg;
/*
* Compute cartesian coordinates (in GEI)
*/
r->x = cos(dec) * cos(ra);
r->y = cos(dec) * sin(ra);
r->z = sin(dec);
}
int LeapYear(year)
int year;
{
if ((year%100 == 0)&&(year%400 != 0)) return(0);
else if (year%4 == 0) return(1);
else return(0);
}

58
src/CalcEphem.h Normal file
View File

@ -0,0 +1,58 @@
#include <stdio.h>
#include <math.h>
#define DegPerRad 57.29577951308232087680
#define RadPerDeg 0.01745329251994329576
#define FALSE 0
#define TRUE 1
typedef struct Vector {
double x;
double y;
double z;
} Vector;
typedef struct Position {
double x;
double y;
double z;
} Position;
typedef struct CTrans {
double UT; /* Universal Time (in decimal hours) */
int year; /* 2 digit year */
int month; /* 2 digit month of year */
int day; /* 2 digit day of month */
int doy; /* 3 digit Day Of Year */
int dow; /* 1 digit day of week */
char dowstr[80]; /* Day of week String (e.g. "Sun") */
double gmst; /* Greenwich Mean Sidereal Time (in radians) */
double eccentricity; /* Eccentricity of Earth-Sun orbit */
double epsilon; /* Obliquity of the ecliptic (in radians) */
double lambda_sun; /* Ecliptic Long. of Sun (in radians) */
double earth_sun_dist; /* Earth-Sun distance (in units of earth radii) */
double RA_sun; /* Right Ascention of Sun (in degrees) */
double DEC_sun; /* Declination of Sun (in degrees) */
Vector Sun; /* direction of Sun in GEI system (unit vector) */
Vector EcPole; /* direction of Ecliptic Pole in GEI system (unit vector) */
double psi; /* Geodipole tilt angle (in radians) */
double Dipole_Gcolat; /* Geographic colat of centered dipole axis (deg.) */
double Dipole_Glon; /* Geographic long. of centered dipole axis (deg.) */
double RA_moon; /* Right Ascention of Moon (in degrees) */
double DEC_moon; /* Declination of Moon (in degrees) */
double MoonPhase; /* The Phase of the Moon (in days) */
double MoonAge; /* Age of Moon in Days */
double EarthMoonDistance; /* Distance between the Earth and Moon (in earth-radii) */
double Glat; /* Geographic Latitude of Observer */
double Glon; /* Geographic Longitude of Observer */
double h_moon; /* Altitude of Moon (in degrees) */
double A_moon; /* Azimuth of Moon (in degrees) */
int Visible; /* Wether or not moon is above horizon */
} CTrans;
void CalcEphem(long int date, double UT, CTrans *c);

23
src/Makefile.am Normal file
View File

@ -0,0 +1,23 @@
MAINTAINERCLEANFILES = Makefile.in
moduledir = @MODULEDIR@
# the module .so file
AM_CPPFLAGS = -I. \
-I$(top_srcdir) \
-I$(includedir) \
@e_cflags@
pkgdir = $(moduledir)/$(PACKAGE)/$(MODULE_ARCH)
pkg_LTLIBRARIES = module.la
module_la_SOURCES = e_mod_main.c \
e_mod_main.h \
e_mod_config.c \
CalcEphem.c \
CalcEphem.h \
Moon.c
module_la_LIBADD = @e_libs@
module_la_LDFLAGS = -module -avoid-version
module_la_DEPENDENCIES = $(top_builddir)/config.h

450
src/Moon.c Normal file
View File

@ -0,0 +1,450 @@
/*
* Calculates Moon's position according to Brown's Lunar Theory...
*/
#include <math.h>
#define DegPerRad 57.29577951308232087680
#define RadPerDeg 0.01745329251994329576
double angle360();
void addthe(double C1, double S1, double C2, double S2, double *C, double *S);
void term(int P, int Q, int R, int S, double *X, double *Y);
void addsol(double COEFFL, double COEFFS, double COEFFG, double COEFFP, int P, int Q, int R, int S);
void addn(double COEFFN, int P, int Q, int R, int S);
double Moon(double T, double *LAMBDA, double *BETA, double *R, double *AGE);
double sine(double);
double frac(double);
double NewMoon(double, double, double);
int MiniMoon(double, double *, double *);
double TwoPi = 6.283185308;
double ARC = 206264.81;
double sine(), frac();
double DLAM, DLAMS;
double DS;
double GAM1C;
double SINPI;
double N;
double CO[14][5], SI[14][5];
void
addthe(double C1, double S1, double C2, double S2, double *C, double *S){
*C = C1*C2 - S1*S2;
*S = S1*C2 + C1*S2;
}
void
term(int P, int Q, int R, int S, double *X, double *Y){
double XX, YY;
int k, I[5];
I[1] = P, I[2] = Q, I[3] = R, I[4] = S, XX = 1.0, YY = 0.0;
for (k=1; k<=4; ++k){
if (I[k] != 0.0){
addthe(XX, YY, CO[6+I[k]][k], SI[6+I[k]][k], &XX, &YY);
}
}
*X = XX;
*Y = YY;
}
void
addsol(double COEFFL, double COEFFS, double COEFFG, double COEFFP, int P, int Q, int R, int S){
double X, Y;
term(P, Q, R, S, &X, &Y);
DLAM += COEFFL*Y;
DS += COEFFS*Y;
GAM1C += COEFFG*X;
SINPI += COEFFP*X;
}
void
addn(double COEFFN, int P, int Q, int R, int S){
double X, Y;
term(P, Q, R, S, &X, &Y);
N += COEFFN*Y;
}
double Moon(double T, double *LAMBDA, double *BETA, double *R, double *AGE){
double T2;
double S1, S2, S3, S4, S5, S6, S7;
double DL0, DL, DD, DGAM, DLS, DF;
double L0, L, LS, F, D;
double ARG=0.0;
double FAC=0.0;
int MAX=0;
int i, j;
double S;
T2 = T*T;
DLAM = 0.0, DS = 0.0, GAM1C = 0.0; SINPI = 3422.7000;
/*
* Long Periodic variations
*/
S1 = sine( 0.19833 + 0.05611*T );
S2 = sine( 0.27869 + 0.04508*T );
S3 = sine( 0.16827 - 0.36903*T );
S4 = sine( 0.34734 - 5.37261*T );
S5 = sine( 0.10498 - 5.37899*T );
S6 = sine( 0.42681 - 0.41855*T );
S7 = sine( 0.14943 - 5.37511*T );
DL0 = 0.84*S1 + 0.31*S2 + 14.27*S3 + 7.26*S4 + 0.28*S5 + 0.24*S6;
DL = 2.94*S1 + 0.31*S2 + 14.27*S3 + 9.34*S4 + 1.12*S5 + 0.83*S6;
DLS = -6.40*S1 - 1.89*S6;
DF = 0.21*S1 + 0.31*S2 + 14.27*S3 - 88.70*S4 - 15.30*S5 + 0.24*S6 - 1.86*S7;
DD = DL0 - DLS;
DGAM = -3332e-9 * sine( 0.59734 - 5.37261*T)
-539e-9 * sine( 0.35498 - 5.37899*T)
-64e-9 * sine( 0.39943 - 5.37511*T);
L0 = TwoPi*frac( 0.60643382 + 1336.85522467*T - 0.00000313*T2 ) + DL0/ARC;
L = TwoPi*frac( 0.37489701 + 1325.55240982*T + 0.00002565*T2 ) + DL/ARC;
LS = TwoPi*frac( 0.99312619 + 99.99735956*T - 0.00000044*T2 ) + DLS/ARC;
F = TwoPi*frac( 0.25909118 + 1342.22782980*T - 0.00000892*T2 ) + DF/ARC;
D = TwoPi*frac( 0.82736186 + 1236.85308708*T - 0.00000397*T2 ) + DD/ARC;
for (i=1; i<=4; ++i){
switch (i){
case 1:
ARG = L, MAX = 4, FAC = 1.000002208;
break;
case 2:
ARG = LS, MAX = 3, FAC = 0.997504612 - 0.002495388*T;
break;
case 3:
ARG = F, MAX = 4, FAC = 1.000002708 + 139.978*DGAM;
break;
case 4:
ARG = D, MAX = 6, FAC = 1.0;
break;
}
CO[6+0][i] = 1.0, CO[6+1][i] = cos(ARG)*FAC;
SI[6+0][i] = 0.0, SI[6+1][i] = sin(ARG)*FAC;
for (j=2; j<=MAX; ++j) addthe(CO[6+j-1][i], SI[6+j-1][i], CO[6+1][i], SI[6+1][i], &CO[6+j][i], &SI[6+j][i]);
for (j=1; j<=MAX; ++j) {
CO[6-j][i] = CO[6+j][i];
SI[6-j][i] = -SI[6+j][i];
}
}
/*
* Solar1
*/
addsol( 13.902, 14.06,-0.001, 0.2607,0, 0, 0, 4);
addsol( 0.403, -4.01,+0.394, 0.0023,0, 0, 0, 3);
addsol( 2369.912, 2373.36,+0.601, 28.2333,0, 0, 0, 2);
addsol( -125.154, -112.79,-0.725, -0.9781,0, 0, 0, 1);
addsol( 1.979, 6.98,-0.445, 0.0433,1, 0, 0, 4);
addsol( 191.953, 192.72,+0.029, 3.0861,1, 0, 0, 2);
addsol( -8.466, -13.51,+0.455, -0.1093,1, 0, 0, 1);
addsol(22639.500,22609.07,+0.079, 186.5398,1, 0, 0, 0);
addsol( 18.609, 3.59,-0.094, 0.0118,1, 0, 0,-1);
addsol(-4586.465,-4578.13,-0.077, 34.3117,1, 0, 0,-2);
addsol( +3.215, 5.44,+0.192, -0.0386,1, 0, 0,-3);
addsol( -38.428, -38.64,+0.001, 0.6008,1, 0, 0,-4);
addsol( -0.393, -1.43,-0.092, 0.0086,1, 0, 0,-6);
addsol( -0.289, -1.59,+0.123, -0.0053,0, 1, 0, 4);
addsol( -24.420, -25.10,+0.040, -0.3000,0, 1, 0, 2);
addsol( 18.023, 17.93,+0.007, 0.1494,0, 1, 0, 1);
addsol( -668.146, -126.98,-1.302, -0.3997,0, 1, 0, 0);
addsol( 0.560, 0.32,-0.001, -0.0037,0, 1, 0,-1);
addsol( -165.145, -165.06,+0.054, 1.9178,0, 1, 0,-2);
addsol( -1.877, -6.46,-0.416, 0.0339,0, 1, 0,-4);
addsol( 0.213, 1.02,-0.074, 0.0054,2, 0, 0, 4);
addsol( 14.387, 14.78,-0.017, 0.2833,2, 0, 0, 2);
addsol( -0.586, -1.20,+0.054, -0.0100,2, 0, 0, 1);
addsol( 769.016, 767.96,+0.107, 10.1657,2, 0, 0, 0);
addsol( +1.750, 2.01,-0.018, 0.0155,2, 0, 0,-1);
addsol( -211.656, -152.53,+5.679, -0.3039,2, 0, 0,-2);
addsol( +1.225, 0.91,-0.030, -0.0088,2, 0, 0,-3);
addsol( -30.773, -34.07,-0.308, 0.3722,2, 0, 0,-4);
addsol( -0.570, -1.40,-0.074, 0.0109,2, 0, 0,-6);
addsol( -2.921, -11.75,+0.787, -0.0484,1, 1, 0, 2);
addsol( +1.267, 1.52,-0.022, 0.0164,1, 1, 0, 1);
addsol( -109.673, -115.18,+0.461, -0.9490,1, 1, 0, 0);
addsol( -205.962, -182.36,+2.056, +1.4437,1, 1, 0,-2);
addsol( 0.233, 0.36, 0.012, -0.0025,1, 1, 0,-3);
addsol( -4.391, -9.66,-0.471, 0.0673,1, 1, 0,-4);
/*
* Solar2
*/
addsol( 0.283, 1.53,-0.111, +0.0060,1,-1, 0,+4);
addsol( 14.577, 31.70,-1.540, +0.2302,1,-1, 0, 2);
addsol( 147.687, 138.76,+0.679, +1.1528,1,-1, 0, 0);
addsol( -1.089, 0.55,+0.021, 0.0 ,1,-1, 0,-1);
addsol( 28.475, 23.59,-0.443, -0.2257,1,-1, 0,-2);
addsol( -0.276, -0.38,-0.006, -0.0036,1,-1, 0,-3);
addsol( 0.636, 2.27,+0.146, -0.0102,1,-1, 0,-4);
addsol( -0.189, -1.68,+0.131, -0.0028,0, 2, 0, 2);
addsol( -7.486, -0.66,-0.037, -0.0086,0, 2, 0, 0);
addsol( -8.096, -16.35,-0.740, 0.0918,0, 2, 0,-2);
addsol( -5.741, -0.04, 0.0 , -0.0009,0, 0, 2, 2);
addsol( 0.255, 0.0 , 0.0 , 0.0 ,0, 0, 2, 1);
addsol( -411.608, -0.20, 0.0 , -0.0124,0, 0, 2, 0);
addsol( 0.584, 0.84, 0.0 , +0.0071,0, 0, 2,-1);
addsol( -55.173, -52.14, 0.0 , -0.1052,0, 0, 2,-2);
addsol( 0.254, 0.25, 0.0 , -0.0017,0, 0, 2,-3);
addsol( +0.025, -1.67, 0.0 , +0.0031,0, 0, 2,-4);
addsol( 1.060, 2.96,-0.166, 0.0243,3, 0, 0,+2);
addsol( 36.124, 50.64,-1.300, 0.6215,3, 0, 0, 0);
addsol( -13.193, -16.40,+0.258, -0.1187,3, 0, 0,-2);
addsol( -1.187, -0.74,+0.042, 0.0074,3, 0, 0,-4);
addsol( -0.293, -0.31,-0.002, 0.0046,3, 0, 0,-6);
addsol( -0.290, -1.45,+0.116, -0.0051,2, 1, 0, 2);
addsol( -7.649, -10.56,+0.259, -0.1038,2, 1, 0, 0);
addsol( -8.627, -7.59,+0.078, -0.0192,2, 1, 0,-2);
addsol( -2.740, -2.54,+0.022, 0.0324,2, 1, 0,-4);
addsol( 1.181, 3.32,-0.212, 0.0213,2,-1, 0,+2);
addsol( 9.703, 11.67,-0.151, 0.1268,2,-1, 0, 0);
addsol( -0.352, -0.37,+0.001, -0.0028,2,-1, 0,-1);
addsol( -2.494, -1.17,-0.003, -0.0017,2,-1, 0,-2);
addsol( 0.360, 0.20,-0.012, -0.0043,2,-1, 0,-4);
addsol( -1.167, -1.25,+0.008, -0.0106,1, 2, 0, 0);
addsol( -7.412, -6.12,+0.117, 0.0484,1, 2, 0,-2);
addsol( -0.311, -0.65,-0.032, 0.0044,1, 2, 0,-4);
addsol( +0.757, 1.82,-0.105, 0.0112,1,-2, 0, 2);
addsol( +2.580, 2.32,+0.027, 0.0196,1,-2, 0, 0);
addsol( +2.533, 2.40,-0.014, -0.0212,1,-2, 0,-2);
addsol( -0.344, -0.57,-0.025, +0.0036,0, 3, 0,-2);
addsol( -0.992, -0.02, 0.0 , 0.0 ,1, 0, 2, 2);
addsol( -45.099, -0.02, 0.0 , -0.0010,1, 0, 2, 0);
addsol( -0.179, -9.52, 0.0 , -0.0833,1, 0, 2,-2);
addsol( -0.301, -0.33, 0.0 , 0.0014,1, 0, 2,-4);
addsol( -6.382, -3.37, 0.0 , -0.0481,1, 0,-2, 2);
addsol( 39.528, 85.13, 0.0 , -0.7136,1, 0,-2, 0);
addsol( 9.366, 0.71, 0.0 , -0.0112,1, 0,-2,-2);
addsol( 0.202, 0.02, 0.0 , 0.0 ,1, 0,-2,-4);
/*
* Solar3
*/
addsol( 0.415, 0.10, 0.0 , 0.0013,0, 1, 2, 0);
addsol( -2.152, -2.26, 0.0 , -0.0066,0, 1, 2,-2);
addsol( -1.440, -1.30, 0.0 , +0.0014,0, 1,-2, 2);
addsol( 0.384, -0.04, 0.0 , 0.0 ,0, 1,-2,-2);
addsol( +1.938, +3.60,-0.145, +0.0401,4, 0, 0, 0);
addsol( -0.952, -1.58,+0.052, -0.0130,4, 0, 0,-2);
addsol( -0.551, -0.94,+0.032, -0.0097,3, 1, 0, 0);
addsol( -0.482, -0.57,+0.005, -0.0045,3, 1, 0,-2);
addsol( 0.681, 0.96,-0.026, 0.0115,3,-1, 0, 0);
addsol( -0.297, -0.27, 0.002, -0.0009,2, 2, 0,-2);
addsol( 0.254, +0.21,-0.003, 0.0 ,2,-2, 0,-2);
addsol( -0.250, -0.22, 0.004, 0.0014,1, 3, 0,-2);
addsol( -3.996, 0.0 , 0.0 , +0.0004,2, 0, 2, 0);
addsol( 0.557, -0.75, 0.0 , -0.0090,2, 0, 2,-2);
addsol( -0.459, -0.38, 0.0 , -0.0053,2, 0,-2, 2);
addsol( -1.298, 0.74, 0.0 , +0.0004,2, 0,-2, 0);
addsol( 0.538, 1.14, 0.0 , -0.0141,2, 0,-2,-2);
addsol( 0.263, 0.02, 0.0 , 0.0 ,1, 1, 2, 0);
addsol( 0.426, +0.07, 0.0 , -0.0006,1, 1,-2,-2);
addsol( -0.304, +0.03, 0.0 , +0.0003,1,-1, 2, 0);
addsol( -0.372, -0.19, 0.0 , -0.0027,1,-1,-2, 2);
addsol( +0.418, 0.0 , 0.0 , 0.0 ,0, 0, 4, 0);
addsol( -0.330, -0.04, 0.0 , 0.0 ,3, 0, 2, 0);
N = 0.0;
addn(-526.069, 0, 0,1,-2); addn( -3.352, 0, 0,1,-4);
addn( +44.297,+1, 0,1,-2); addn( -6.000,+1, 0,1,-4);
addn( +20.599,-1, 0,1, 0); addn( -30.598,-1, 0,1,-2);
addn( -24.649,-2, 0,1, 0); addn( -2.000,-2, 0,1,-2);
addn( -22.571, 0,+1,1,-2); addn( +10.985, 0,-1,1,-2);
DLAM += +0.82*sine( 0.7736 -62.5512*T ) + 0.31*sine( 0.0466 -125.1025*T )
+0.35*sine( 0.5785 -25.1042*T ) + 0.66*sine( 0.4591 +1335.8075*T )
+0.64*sine( 0.3130 -91.5680*T ) + 1.14*sine( 0.1480 +1331.2898*T )
+0.21*sine( 0.5918 +1056.5859*T ) + 0.44*sine( 0.5784 +1322.8595*T )
+0.24*sine( 0.2275 -5.7374*T ) + 0.28*sine( 0.2965 +2.6929*T )
+0.33*sine( 0.3132 +6.3368*T );
*LAMBDA = 360.0*frac( (L0+DLAM/ARC)/TwoPi );
S = F + DS/ARC;
FAC = 1.000002708 + 139.978*DGAM;
*BETA = (FAC*(18518.511 + 1.189 + GAM1C)*sin(S) - 6.24*sin(3*S) + N)/3600.0;
SINPI *= 0.999953253;
*R = ARC/SINPI;
DLAMS = 6893.0 * sin(LS) + 72.0 * sin(2.0*LS);
*AGE = 29.530589*frac((D+(DLAM-DLAMS)/ARC)/TwoPi);
/*
printf("Diff = %f\n", 360.0*frac((D+(DLAM-DLAMS)/ARC)/TwoPi));
*/
/*
* Return the phase.
*/
/*
return( 0.5*(1.0 - cos(D+(DLAM-DLAMS)/ARC)) );
*/
return( *AGE/29.530589 );
}
double sine(double phi){
return( sin(TwoPi*frac(phi)) );
}
double frac(double x){
x -= (int)x;
return( (x<0) ? x+1.0 : x );
}
#define R 0.61803399
#define C 0.38196601
double NewMoon(double ax, double bx, double cx){
double f1, f2, x0, x1, x2, x3, Moon();
double L, B, Rad, AGE, tol=1e-7;
x0 = ax;
x3 = cx;
if (fabs(cx-bx) > fabs(bx-ax)){
x1 = bx;
x2 = bx + C*(cx-bx);
} else {
x2 = bx;
x1 = bx - C*(bx-ax);
}
f1 = Moon(x1, &L, &B, &Rad, &AGE);
f2 = Moon(x2, &L, &B, &Rad, &AGE);
while (fabs(x3-x0) > tol*(fabs(x1)+fabs(x2))){
if (f2 < f1){
x0 = x1;
x1 = x2;
x2 = R*x1+C*x3;
f1 = f2;
f2 = Moon(x2, &L, &B, &Rad, &AGE);
} else {
x3 = x2;
x2 = x1;
x1 = R*x2+C*x0;
f2 = f1;
f1 = Moon(x1, &L, &B, &Rad, &AGE);
}
}
if (f1 < f2){
return(x1);
} else {
return(x2);
}
}
/*
* MINI_MOON: low precision lunar coordinates (approx. 5'/1')
* T : time in Julian centuries since J2000
* ( T=(JD-2451545)/36525 )
* RA : right ascension (in h; equinox of date)
* DEC: declination (in deg; equinox of date)
*
*/
int
MiniMoon(double T, double *RA, double *DEC){
double L0,L,LS,F,D,H,S,N,DL,CB,L_MOON,B_MOON,V,W,X,Y,Z,RHO;
double frac(), cosEPS, sinEPS, P2, ARC;
cosEPS = 0.91748;
sinEPS = 0.39778;
P2 = 6.283185307;
ARC = 206264.8062;
/*
* mean elements of lunar orbit
*/
L0 = frac(0.606433+1336.855225*T); /* mean longitude Moon (in rev) */
L = P2*frac(0.374897+1325.552410*T); /* mean anomaly of the Moon */
LS = P2*frac(0.993133+ 99.997361*T); /* mean anomaly of the Sun */
D = P2*frac(0.827361+1236.853086*T); /* diff. longitude Moon-Sun */
F = P2*frac(0.259086+1342.227825*T); /* mean argument of latitude */
DL = +22640.0*sin(L) - 4586.0*sin(L-2.0*D) + 2370.0*sin(2.0*D) + 769.0*sin(2.0*L)
-668.0*sin(LS)- 412.0*sin(2.0*F) - 212.0*sin(2.0*L-2.0*D) - 206.0*sin(L+LS-2.0*D)
+192.0*sin(L+2.0*D) - 165.0*sin(LS-2.0*D) - 125.0*sin(D) - 110.0*sin(L+LS)
+148.0*sin(L-LS) - 55.0*sin(2.0*F-2.0*D);
S = F + (DL+412.0*sin(2.0*F)+541.0*sin(LS)) / ARC;
H = F-2.0*D;
N = -526.0*sin(H) + 44.0*sin(L+H) - 31.0*sin(-L+H) - 23.0*sin(LS+H)
+ 11.0*sin(-LS+H) -25.0*sin(-2.0*L+F) + 21.0*sin(-L+F);
L_MOON = P2 * frac ( L0 + DL/1296e3 ); /* in rad */
B_MOON = ( 18520.0*sin(S) + N ) / ARC; /* in rad */
/* equatorial coordinates */
CB = cos(B_MOON);
X = CB*cos(L_MOON);
V = CB*sin(L_MOON);
W = sin(B_MOON);
Y = cosEPS*V-sinEPS*W;
Z = sinEPS*V+cosEPS*W;
RHO = sqrt(1.0-Z*Z);
*DEC = (360.0/P2)*atan2(Z, RHO);
*RA = ( 48.0/P2)*atan2(Y, X+RHO);
if (*RA<0.0) *RA += 24.0;
return(0);
}

187
src/e_mod_config.c Normal file
View File

@ -0,0 +1,187 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include <e.h>
#include <e_config.h>
#include <e_config_dialog.h>
#include "e_mod_main.h"
#define POLICY_NO 0
#define POLICY_YES 1
#define POLICY_ON_MOUSE_OVER 2
struct _E_Config_Dialog_Data
{
int show_phase_value;
int value_format;
int show_border;
int show_cloud_anim;
double poll_time;
};
static void *_create_data(E_Config_Dialog *cfd);
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
static E_Config_DD *conf_edd = NULL;
Config *moon_config = NULL;
EAPI int
e_modapi_save(E_Module *module)
{
return e_config_domain_save("module.moon", conf_edd, moon_config);
}
void
moon_config_init()
{
conf_edd = E_CONFIG_DD_NEW("Moon_Config", Config);
E_CONFIG_VAL(conf_edd, Config, show_phase_value, INT);
E_CONFIG_VAL(conf_edd, Config, value_format, INT);
E_CONFIG_VAL(conf_edd, Config, show_border, INT);
E_CONFIG_VAL(conf_edd, Config, show_cloud_anim, INT);
E_CONFIG_VAL(conf_edd, Config, poll_time, DOUBLE);
moon_config = e_config_domain_load("module.moon", conf_edd);
if (!moon_config)
{
moon_config = E_NEW(Config, 1);
moon_config->show_phase_value = POLICY_YES;
moon_config->value_format = VALUE_FMT_NUM;
moon_config->show_border = POLICY_YES;
moon_config->show_cloud_anim = POLICY_NO;
moon_config->poll_time = 60.0;
}
E_CONFIG_LIMIT(moon_config->show_phase_value, POLICY_NO, POLICY_ON_MOUSE_OVER);
E_CONFIG_LIMIT(moon_config->value_format, VALUE_FMT_STR, VALUE_FMT_NUM);
E_CONFIG_LIMIT(moon_config->show_border, POLICY_NO, POLICY_YES);
E_CONFIG_LIMIT(moon_config->show_cloud_anim, POLICY_NO, POLICY_YES);
E_CONFIG_LIMIT(moon_config->poll_time, 0.05, 86400.0);
}
void
moon_config_shutdown()
{
if (moon_config->config_dialog)
{
e_object_del(E_OBJECT(moon_config->config_dialog));
moon_config->config_dialog = NULL;
}
free(moon_config);
moon_config = NULL;
E_CONFIG_DD_FREE(conf_edd);
}
void
moon_config_dialog_show(Evas_Object *o)
{
E_Config_Dialog *cfd;
E_Config_Dialog_View *v;
E_Container *con;
v = E_NEW(E_Config_Dialog_View, 1);
if (v)
{
v->create_cfdata = _create_data;
v->free_cfdata = _free_data;
v->basic.apply_cfdata = _basic_apply_data;
v->basic.create_widgets = _basic_create_widgets;
v->advanced.apply_cfdata = NULL;
v->advanced.create_widgets = NULL;
con = e_container_current_get(e_manager_current_get());
// FIXME - specify icon
cfd = e_config_dialog_new(con, D_("Moon Configuration"), NULL, 0, v, o);
moon_config->config_dialog = cfd;
}
}
/**--CREATE--**/
static void
_fill_data(E_Config_Dialog_Data *cfdata)
{
cfdata->show_phase_value = moon_config->show_phase_value;
cfdata->value_format = moon_config->value_format;
cfdata->show_border = moon_config->show_border;
cfdata->show_cloud_anim = moon_config->show_cloud_anim;
cfdata->poll_time = moon_config->poll_time;
}
static void *
_create_data(E_Config_Dialog *cfd)
{
E_Config_Dialog_Data *cfdata;
cfdata = E_NEW(E_Config_Dialog_Data, 1);
_fill_data(cfdata);
return cfdata;
}
static void
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
/* Free the cfdata */
moon_config->config_dialog = NULL;
free(cfdata);
}
static int
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
moon_config->show_phase_value = cfdata->show_phase_value;
moon_config->value_format = cfdata->value_format;
moon_config->show_border = cfdata->show_border;
moon_config->show_cloud_anim = cfdata->show_cloud_anim;
moon_config->poll_time = cfdata->poll_time;
e_config_save_queue();
moon_reset(cfd->data);
return 1; /* Apply was OK */
}
static Evas_Object *
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
{
Evas_Object *ob, *of, *o;
E_Radio_Group *rg;
o = e_widget_list_add(evas, 0, 0);
of = e_widget_framelist_add(evas, D_("Display Settings"), 0);
ob = e_widget_check_add(evas, D_("Animated Clouds"), &(cfdata->show_cloud_anim));
e_widget_framelist_object_append(of, ob);
e_widget_list_object_append(o, of, 1, 1, 0.5);
of = e_widget_framelist_add(evas, D_("Moon Phase Value"), 0);
rg = e_widget_radio_group_new(&(cfdata->show_phase_value));
ob = e_widget_radio_add(evas, D_("Show always"), POLICY_YES, rg);
e_widget_framelist_object_append(of, ob);
ob = e_widget_radio_add(evas, D_("Show on mouse over"), POLICY_ON_MOUSE_OVER, rg);
e_widget_framelist_object_append(of, ob);
ob = e_widget_radio_add(evas, D_("Never show"), POLICY_NO, rg);
e_widget_framelist_object_append(of, ob);
rg = e_widget_radio_group_new(&(cfdata->value_format));
ob = e_widget_radio_add(evas, D_("Description"), VALUE_FMT_STR, rg);
e_widget_disabled_set(ob, (!cfdata->show_phase_value));
e_widget_framelist_object_append(of, ob);
ob = e_widget_radio_add(evas, D_("Numerical"), VALUE_FMT_NUM, rg);
e_widget_disabled_set(ob, (!cfdata->show_phase_value));
e_widget_framelist_object_append(of, ob);
e_widget_list_object_append(o, of, 1, 1, 0.5);
/*
of = e_widget_framelist_add(evas, D_("Moon Phase Calculation Interval"), 0);
ob = e_widget_slider_add(evas, 1, 0, D_("%1.2f seconds"), 0.05, 120.00, 0.05, 0, &(cfdata->poll_time), NULL, 200);
e_widget_framelist_object_append(of, ob);
e_widget_list_object_append(o, of, 1, 1, 0.5);
*/
return o;
}

525
src/e_mod_main.c Normal file
View File

@ -0,0 +1,525 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include <limits.h>
#include <time.h>
#include <e.h>
#include <e_module.h>
#include "e_mod_main.h"
#include "CalcEphem.h"
/******************************************************************************/
/*
* Gadcon requirements
*/
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, char *name, char *id, char *style);
static void _gc_shutdown(E_Gadcon_Client *gcc);
static void _gc_orient(E_Gadcon_Client *gcc);
static char *_gc_label(void);
static Evas_Object *_gc_icon(Evas *evas);
static const E_Gadcon_Client_Class _gadcon_class =
{
GADCON_CLIENT_CLASS_VERSION,
"moon",
{
_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon
}
};
/******************************************************************************/
/* Moon module privates */
typedef struct _Instance Instance;
typedef struct _Moon_Timer Moon_Timer;
typedef Edje_Message_String_Float_Set Moon_Update_Msg;
typedef Edje_Message_Int_Set Moon_Config_Msg;
struct _Instance
{
E_Gadcon_Client *gcc;
Evas_Object *o_gadget;
};
struct _Moon_Timer
{
Ecore_Timer *timer;
Evas_List *clients;
};
static void _button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _menu_cb_post(void *data, E_Menu *m);
static void _moon_inst_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi);
static void _moon_timer_init();
static void _moon_timer_shutdown();
static void _moon_timer_client_register(Evas_Object *moon);
static void _moon_timer_client_unregister(Evas_Object *moon);
static int _moon_timer_cb_update(void *data);
static Moon_Config_Msg *_moon_config_msg_prepare();
static void _moon_config_msg_send(Evas_Object *o, Moon_Config_Msg *msg);
static void _moon_config_msg_free(Moon_Config_Msg *msg);
static Moon_Update_Msg *_moon_update_msg_prepare();
static void _moon_update_msg_send(Evas_Object *o, Moon_Update_Msg *msg);
static void _moon_update_msg_free(Moon_Update_Msg *msg);
static double _moon_phase_calc();
static char *_moon_display_string_get(Config *conf, double moonphase);
#ifdef DEBUG
static void _moon_face_signal_cb(void *data, Evas_Object *o, const char *sig, const char *src);
static double _test_val;
#endif
/*
* Moon module global data
*/
static Moon_Timer *_moon_timer = NULL;
static E_Module *_module = NULL;
/******************************************************************************/
EAPI E_Module_Api e_modapi =
{
E_MODULE_API_VERSION,
"Moon"
};
EAPI void *
e_modapi_init(E_Module *module)
{
/* Set up module message catalog */
bindtextdomain(PACKAGE, LOCALEDIR);
bind_textdomain_codeset(PACKAGE, "UTF-8");
moon_config_init();
_moon_timer_init();
_module = module;
e_gadcon_provider_register(&_gadcon_class);
return 1; // dummy return to keep the API happy
}
EAPI int
e_modapi_shutdown(E_Module *module)
{
e_gadcon_provider_unregister(&_gadcon_class);
_module = NULL;
_moon_timer_shutdown();
moon_config_shutdown();
return 1;
}
EAPI int
e_modapi_info(E_Module *module)
{
// seems deprecated now, but what the hell...
char buf[4096];
snprintf(buf, sizeof(buf), "%s/moon.eap", e_module_dir_get(module));
module->edje_icon_file = strdup(buf);
return 1;
}
EAPI int
e_modapi_about(E_Module *module)
{
char title[1024];
snprintf(title, sizeof(title), "%s %s", D_("Moon Clock Module"),
PACKAGE_VERSION);
e_module_dialog_show(title,
D_("Display current phase of the moon ala e16 E-MoonClock"));
return 1;
}
static E_Gadcon_Client *
_gc_init(E_Gadcon *gc, char *name, char *id, char *style)
{
Evas_Object *o;
E_Gadcon_Client *gcc;
Instance *inst;
char edje_path[PATH_MAX];
Moon_Update_Msg *umsg;
Moon_Config_Msg *cmsg;
#ifdef DEBUG
printf("----------------------\n");
printf("name is %s\n", name);
printf("id is %s\n", id);
printf("style is %s\n", style);
printf("----------------------\n");
#endif
inst = E_NEW(Instance, 1);
o = edje_object_add(gc->evas);
if (!e_theme_edje_object_set(o, "base/theme/modules/moon",
"module/moon/main"))
{
snprintf(edje_path, sizeof(edje_path), "%s/moon.edj",
e_module_dir_get(_module));
edje_object_file_set(o, edje_path, "module/moon/main");
}
evas_object_show(o);
gcc = e_gadcon_client_new(gc, name, id, style, o);
gcc->data = inst;
inst->gcc = gcc;
inst->o_gadget = o;
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
_button_cb_mouse_down, inst);
/* Configure this instance */
cmsg = _moon_config_msg_prepare();
_moon_config_msg_send(o, cmsg);
_moon_config_msg_free(cmsg);
/* Send this instance the display content */
umsg = _moon_update_msg_prepare();
_moon_update_msg_send(o, umsg);
_moon_update_msg_free(umsg);
/* Register the new moon timed display content updates */
_moon_timer_client_register(o);
return gcc;
}
static void
_gc_shutdown(E_Gadcon_Client *gcc)
{
Instance *inst;
inst = gcc->data;
_moon_timer_client_unregister(inst->o_gadget);
evas_object_del(inst->o_gadget);
free(inst);
}
static void
_gc_orient(E_Gadcon_Client *gcc)
{
Instance *inst;
Evas_Coord w, h;
inst = gcc->data;
e_gadcon_client_aspect_set(gcc, 1, 1);
edje_object_size_min_get(inst->o_gadget, &w, &h);
e_gadcon_client_min_size_set(gcc, w, h);
}
static char *
_gc_label(void)
{
return D_("Moon");
}
static Evas_Object *
_gc_icon(Evas *evas)
{
Evas_Object *o;
char buf[4096];
o = edje_object_add(evas);
snprintf(buf, sizeof(buf), "%s/moon.eap", e_module_dir_get(_module));
edje_object_file_set(o, buf, "icon");
return o;
}
static void
_button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Instance *inst;
Evas_Event_Mouse_Down *ev;
inst = data;
ev = event_info;
if ((ev->button == 3) && (!moon_config->menu))
{
E_Menu *mn;
E_Menu_Item *mi;
int cx, cy, cw, ch;
mn = e_menu_new();
e_menu_post_deactivate_callback_set(mn, _menu_cb_post, inst);
moon_config->menu = mn;
mi = e_menu_item_new(mn); e_menu_item_label_set(mi, _("Configuration"));
e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
e_menu_item_callback_set(mi, _moon_inst_cb_menu_configure, obj);
e_gadcon_client_util_menu_items_append(inst->gcc, mn, 0);
e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon,
&cx, &cy, &cw, &ch);
e_menu_activate_mouse(mn,
e_util_zone_current_get(e_manager_current_get()),
cx + ev->output.x, cy + ev->output.y, 1, 1,
E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button,
EVAS_BUTTON_NONE, ev->timestamp, NULL);
}
}
static void
_menu_cb_post(void *data, E_Menu *m)
{
if (!moon_config->menu) return;
e_object_del(E_OBJECT(moon_config->menu));
moon_config->menu = NULL;
}
static void
_moon_inst_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi)
{
Evas_Object *o;
o = data;
if (!moon_config->menu) return;
if (moon_config->config_dialog) return;
moon_config_dialog_show(o);
}
static void
_moon_timer_init()
{
if (!_moon_timer)
{
_moon_timer = E_NEW(Moon_Timer, 1);
_moon_timer->timer = ecore_timer_add(60.0, _moon_timer_cb_update, NULL);
_moon_timer->clients = NULL;
}
}
static void
_moon_timer_shutdown()
{
ecore_timer_del(_moon_timer->timer);
if (_moon_timer->clients)
printf("Moon module leak on shutdown!\n");
free(_moon_timer);
_moon_timer = NULL;
}
static void
_moon_timer_client_register(Evas_Object *moon)
{
_moon_timer->clients = evas_list_append(_moon_timer->clients, moon);
}
static void
_moon_timer_client_unregister(Evas_Object *moon)
{
_moon_timer->clients = evas_list_remove(_moon_timer->clients, moon);
}
/* Timer event - update all moon objects */
static int
_moon_timer_cb_update(void *data)
{
Moon_Update_Msg *msg;
Evas_List *l;
if (!_moon_timer->clients)
return 1;
msg = _moon_update_msg_prepare();
for (l = _moon_timer->clients; l; l = l->next)
{
Evas_Object *gadget;
gadget = l->data;
_moon_update_msg_send(gadget, msg);
}
_moon_update_msg_free(msg);
return 1;
}
/* Update the specified instance with the latest configuration */
void
moon_reset(Evas_Object *o)
{
Moon_Config_Msg *cmsg;
Moon_Update_Msg *umsg;
cmsg = _moon_config_msg_prepare();
umsg = _moon_update_msg_prepare();
if (o)
{
_moon_config_msg_send(o, cmsg);
_moon_update_msg_send(o, umsg);
}
else
{
// FIXME
printf("Moon module bug: moon_config_reset wants a valid object\n");
}
_moon_config_msg_free(cmsg);
_moon_update_msg_free(umsg);
}
static Moon_Update_Msg *
_moon_update_msg_prepare()
{
Edje_Message_String_Float_Set *msg;
char *str;
msg = E_NEW(Edje_Message_String_Float_Set, 1);
msg->count = 1;
msg->val[0] = _moon_phase_calc();
#ifdef DEBUG
msg->val[0] = _test_val;
_test_val = _test_val + (1.0 / 180.0);
if (_test_val > 1.0)
_test_val = 0.0;
#endif
str = _moon_display_string_get(moon_config, msg->val[0]);
msg->str = str;
return (Moon_Update_Msg *) msg;
}
static void
_moon_update_msg_send(Evas_Object *o, Moon_Update_Msg *msg)
{
edje_object_message_send(o,
EDJE_MESSAGE_STRING_FLOAT_SET,
1,
(Edje_Message_String_Float_Set *) msg);
}
static void
_moon_update_msg_free(Moon_Update_Msg *msg)
{
free(msg->str);
free(msg);
}
static Moon_Config_Msg *
_moon_config_msg_prepare()
{
Edje_Message_Int_Set *msg;
msg = calloc(1,
sizeof(Edje_Message_Int_Set) -
sizeof(int) +
(3 * sizeof(int)));
msg->count = 3;
msg->val[0] = moon_config->show_phase_value;
msg->val[1] = moon_config->show_border; // deprecated
msg->val[2] = moon_config->show_cloud_anim;
return (Moon_Config_Msg *)msg;
}
static void
_moon_config_msg_send(Evas_Object *o, Moon_Config_Msg *msg)
{
edje_object_message_send(o,
EDJE_MESSAGE_INT_SET,
1,
(Edje_Message_Int_Set *) msg);
}
static void
_moon_config_msg_free(Moon_Config_Msg *msg)
{
free(msg);
}
static double
_moon_phase_calc()
{
time_t current_time, date;
struct tm *universal_time;
double UT;
CTrans c;
current_time = time(NULL);
if (current_time == -1) return 0;
/* Get Universal Time */
universal_time = gmtime(&current_time);
/* Date in YYYYMMDD format */
date = (universal_time->tm_year + 1900) * 10000 +
(universal_time->tm_mon + 1) * 100 +
universal_time->tm_mday;
/* UTC representation in decimal hours */
UT = universal_time->tm_hour +
universal_time->tm_min / 60.0 +
universal_time->tm_sec / 3600.0;
CalcEphem(date, UT, &c);
#ifdef DEBUG
printf("date is %f\n", (double) date);
printf("UT is %f\n", (double) UT);
printf("MoonPhase is %f\n", c.MoonPhase);
printf("MoonAge is %f\n", c.MoonAge);
printf("Visible is %d\n", c.Visible);
#endif
if (c.MoonPhase < 0.0)
return 0.0;
if (c.MoonPhase > 1.0)
return 1.0;
return c.MoonPhase;
}
static char *
_moon_display_string_get(Config *conf, double phase)
{
char strbuf[1024];
int value_format;
if (!conf)
value_format = VALUE_FMT_STR;
else
value_format = conf->value_format;
switch (value_format)
{
case VALUE_FMT_NUM:
if (phase <= 0.50)
snprintf(strbuf, sizeof(strbuf), "%.2f%%", phase * 200);
else if (phase > 0.50)
snprintf(strbuf, sizeof(strbuf), "%.2f%%", (0.50 - (phase - 0.50)) * 200);
break;
case VALUE_FMT_STR:
// hmmmmm, something like this...
if (phase < 0.050)
snprintf(strbuf, sizeof(strbuf), "%s", D_("New Moon"));
else if ((phase >= 0.050) && (phase < 0.225))
snprintf(strbuf, sizeof(strbuf), "%s", D_("Waxing Crescent"));
else if ((phase >= 0.225) && (phase < 0.275))
snprintf(strbuf, sizeof(strbuf), "%s", D_("First Quarter"));
else if ((phase >= 0.275) && (phase < 0.475))
snprintf(strbuf, sizeof(strbuf), "%s", D_("Waxing Gibbous"));
else if ((phase >= 0.475) && (phase < 0.525))
snprintf(strbuf, sizeof(strbuf), "%s", D_("Full Moon"));
else if ((phase >= 0.525) && (phase < 0.725))
snprintf(strbuf, sizeof(strbuf), "%s", D_("Waning Gibbous"));
else if ((phase >= 0.725) && (phase < 0.775))
snprintf(strbuf, sizeof(strbuf), "%s", D_("Last Quarter"));
else if (phase >= 0.775)
snprintf(strbuf, sizeof(strbuf), "%s", D_("Waning Crescent"));
break;
}
return strdup(strbuf);
}

47
src/e_mod_main.h Normal file
View File

@ -0,0 +1,47 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#define D_(str) dgettext(PACKAGE, str)
#ifndef E_MOD_MAIN_H
#define E_MOD_MAIN_H
#define VALUE_FMT_STR 0
#define VALUE_FMT_NUM 1
typedef struct _Config Config;
typedef struct _Config_Face Config_Face;
typedef struct _Moon Moon;
typedef struct _Moon_Face Moon_Face;
struct _Config
{
int show_phase_value;
int value_format;
int show_border;
int show_cloud_anim;
double poll_time;
Evas_List *faces;
E_Config_Dialog *config_dialog;
E_Menu *menu;
};
EAPI extern E_Module_Api e_modapi;
EAPI void *e_modapi_init (E_Module *m);
EAPI int e_modapi_shutdown (E_Module *m);
EAPI int e_modapi_info (E_Module *m);
EAPI int e_modapi_about (E_Module *m);
EAPI int e_modapi_save (E_Module *m);
void moon_config_init();
void moon_config_shutdown();
void moon_config_dialog_show(Evas_Object *o);
void moon_reset();
extern Config *moon_config;
#endif