Outsourced GsweMoonPhaseData to its own sources

This messed up documentation, still checking why
This commit is contained in:
Gergely Polonkai 2013-09-23 00:03:10 +02:00
parent 6e96142160
commit 197f6922c7
10 changed files with 226 additions and 36 deletions

View File

@ -58,7 +58,7 @@ EXTRA_HFILES=
# Header files or dirs to ignore when scanning. Use base file/dir names
# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code
IGNORE_HFILES=swe-glib-private.h gswe-enumtypes.h
IGNORE_HFILES=swe-glib-private.h gswe-enumtypes.h gswe-moon-phase-data-private.h
# Images to copy into HTML directory.
# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png

View File

@ -43,6 +43,18 @@ GsweMomentPrivate
gswe_moment_get_type
</SECTION>
<SECTION>
<FILE>gswe-moon-phase-data</FILE>
gswe_moon_phase_data_set_phase
gswe_moon_phase_data_get_phase
gswe_moon_phase_data_set_illumination
gswe_moon_phase_data_get_illumination
GsweMoonPhaseData
<SUBSECTION Standard>
GSWE_TYPE_MOON_PHASE_DATA
gswe_moon_phase_data_get_type
</SECTION>
<SECTION>
<FILE>gswe-timestamp</FILE>
<TITLE>GsweTimestamp</TITLE>

View File

@ -4,9 +4,10 @@ AM_CPPFLAGS = -DG_LOG_DOMAIN=\"SWE-GLib\" -DLOCALEDIR=\"$(localedir)\" -D__SWE_G
lib_LTLIBRARIES = libswe-glib-1.0.la
INST_H_SRC_FILES = \
swe-glib.h \
gswe-types.h \
gswe-moment.h \
swe-glib.h \
gswe-types.h \
gswe-moon-phase-data.h \
gswe-moment.h \
gswe-timestamp.h
INST_H_BUILT_FILES = \
@ -15,11 +16,12 @@ INST_H_BUILT_FILES = \
gswe_enum_headers = gswe-timestamp.h gswe-types.h
libswe_glib_1_0_la_SOURCES = \
swe-glib.c \
gswe-types.c \
gswe-moment.c \
gswe-timestamp.c \
gswe-enumtypes.c \
swe-glib.c \
gswe-types.c \
gswe-moon-phase-data.c \
gswe-moment.c \
gswe-timestamp.c \
gswe-enumtypes.c \
$(NULL)
libswe_glib_1_0_la_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) -Wall
libswe_glib_1_0_la_LIBADD = $(GLIB_LIBS) $(GOBJECT_LIBS) $(LIBSWE_LIBS)

View File

@ -21,6 +21,8 @@
#include <glib-object.h>
#include "gswe-timestamp.h"
#include "gswe-moon-phase-data.h"
#include "gswe-types.h"
#define GSWE_TYPE_MOMENT (gswe_moment_get_type())
#define GSWE_MOMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GSWE_TYPE_MOMENT, GsweMoment))

View File

@ -0,0 +1,39 @@
/* gswe-moon-phase-data-private.h: Private parts of GsweMoonPhaseData
*
* Copyright © 2013 Gergely Polonkai
*
* SWE-GLib is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* SWE-GLib 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifdef __SWE_GLIB_BUILDING__
#ifndef __SWE_GLIB_GSWE_MOON_PHASE_DATA_PRIVATE_H__
#define __SWE_GLIB_GSWE_MOON_PHASE_DATA_PRIVATE_H__
#include "gswe-moon-phase-data.h"
#include "gswe-types.h"
struct _GsweMoonPhaseData {
/* the actual phase of the Moon */
GsweMoonPhase phase;
/* the illumination percentage of the Moon */
gdouble illumination;
};
GsweMoonPhaseData *gswe_moon_phase_data_copy(GsweMoonPhaseData *moon_phase_data);
#endif /* __SWE_GLIB_GSWE_MOON_PHASE_DATA_PRIVATE_H__ */
#else /* not defined __SWE_GLIB_BUILDING__ */
#error __FILE__ "Can not be included, unless building SWE-GLib"
#endif /* __SWE_GLIB_BUILDING__ */

113
src/gswe-moon-phase-data.c Normal file
View File

@ -0,0 +1,113 @@
/* gswe-moon-phase-data.c: Moon phase representation
*
* Copyright © 2013 Gergely Polonkai
*
* SWE-GLib is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* SWE-GLib 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "gswe-types.h"
#include "gswe-moon-phase-data.h"
#include "gswe-moon-phase-data-private.h"
/**
* SECTION:gswe-moon-phase-data
* @short_description: a structure representing the phase of the Moon
* @title: GsweMoonPhaseData
* @stability: Stable
* @include: swe-glib/swe-glib.h
* @see_also: #GsweMoonPhase
*
* #GsweMoonPhaseData is a structure that represents the actual phase of the
* Moon, including its illumination percentage.
*/
G_DEFINE_BOXED_TYPE(GsweMoonPhaseData, gswe_moon_phase_data, (GBoxedCopyFunc)gswe_moon_phase_data_copy, (GBoxedFreeFunc)g_free);
GsweMoonPhaseData *
gswe_moon_phase_data_copy(GsweMoonPhaseData *moon_phase_data)
{
GsweMoonPhaseData *ret = g_new0(struct _GsweMoonPhaseData, 1);
ret->phase = moon_phase_data->phase;
ret->illumination = moon_phase_data->illumination;
return ret;
}
/**
* gswe_moon_phase_data_set_phase:
* @moon_phase_data: a GsweMoonPhaseData
* @phase: the phase to set
*
* Sets the phase of the Moon in the given GsweMoonPhaseData.
*/
void
gswe_moon_phase_data_set_phase(GsweMoonPhaseData *moon_phase_data, GsweMoonPhase phase)
{
if (moon_phase_data) {
moon_phase_data->phase = phase;
}
}
/**
* gswe_moon_phase_data_get_phase:
* @moon_phase_data: a GsweMoonPhaseData
*
* Gets the phase of the Moon in the given GsweMoonPhaseData.
*
* Returns: the Moon phase
*/
GsweMoonPhase
gswe_moon_phase_data_get_phase(GsweMoonPhaseData *moon_phase_data)
{
if (moon_phase_data) {
return moon_phase_data->phase;
} else {
return GSWE_MOON_PHASE_NONE;
}
}
/**
* gswe_moon_phase_data_set_illumination:
* @moon_phase_data: a GsweMoonPhaseData
* @illumination: the illumination to set
*
* Sets the illumination percentage in the given GsweMoonPhaseData.
*/
void
gswe_moon_phase_data_set_illumination(GsweMoonPhaseData *moon_phase_data, gdouble illumination)
{
if (moon_phase_data) {
moon_phase_data->illumination = illumination;
}
}
/**
* gswe_moon_phase_data_get_illumination:
* @moon_phase_data: a GsweMoonPhaseData
*
* Gets the illumination percentage from the given GsweMoonPhaseData.
*
* Returns: the illumination percentage
*/
gdouble
gswe_moon_phase_data_get_illumination(GsweMoonPhaseData *moon_phase_data)
{
if (moon_phase_data) {
return moon_phase_data->illumination;
} else {
return 0.0;
}
}

View File

@ -0,0 +1,48 @@
/* gswe-moon-phase-data.h: Moon phase representation
*
* Copyright © 2013 Gergely Polonkai
*
* SWE-GLib is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* SWE-GLib 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __SWE_GLIB_GSWE_MOON_PHASE_DATA_H__
#define __SWE_GLIB_GSWE_MOON_PHASE_DATA_H__
#include <glib-object.h>
#include "gswe-types.h"
G_BEGIN_DECLS
/**
* GsweMoonPhaseData:
*
* <structname>GsweMoonPhaseData</structname> is an opaque structure whose members
* cannot be accessed directly.
*
* Since: 1.1
*/
typedef struct _GsweMoonPhaseData GsweMoonPhaseData;
void gswe_moon_phase_data_set_phase(GsweMoonPhaseData *moon_phase_data, GsweMoonPhase phase);
GsweMoonPhase gswe_moon_phase_data_get_phase(GsweMoonPhaseData *moon_phase_data);
void gswe_moon_phase_data_set_illumination(GsweMoonPhaseData *moon_phase_data, gdouble illumination);
gdouble gswe_moon_phase_data_get_illumination(GsweMoonPhaseData *moon_phase_data);
GType gswe_moon_phase_data_get_type(void);
#define GSWE_TYPE_MOON_PHASE_DATA (gswe_moon_phase_data_get_type())
G_END_DECLS
#endif /* __SWE_GLIB_GSWE_MOON_PHASE_DATA_H__ */

View File

@ -17,18 +17,6 @@
*/
#include "gswe-types.h"
static GsweMoonPhaseData *
gswe_moon_phase_data_copy(GsweMoonPhaseData *moon_phase_data)
{
GsweMoonPhaseData *ret = g_new0(GsweMoonPhaseData, 1);
ret->phase = moon_phase_data->phase;
ret->illumination = moon_phase_data->illumination;
return ret;
}
G_DEFINE_BOXED_TYPE(GsweMoonPhaseData, gswe_moon_phase_data, (GBoxedCopyFunc)gswe_moon_phase_data_copy, (GBoxedFreeFunc)g_free);
static GswePlanetData *
gswe_planet_data_copy(GswePlanetData *planet_data)

View File

@ -353,21 +353,6 @@ typedef struct {
gboolean middle_axis;
} GsweAntiscionAxisInfo;
/**
* GsweMoonPhaseData:
* @phase: the current phase of the Moon
* @illumination: the portion of the Moon that is currently illuminated
*
* Holds information of a Moon phase.
*/
typedef struct {
GsweMoonPhase phase;
gdouble illumination;
} GsweMoonPhaseData;
GType gswe_moon_phase_data_get_type(void);
#define GSWE_TYPE_MOON_PHASE_DATA (gswe_moon_phase_data_get_type())
/**
* GswePlanetData:
* @planet_id: A GswePlanet, the identifier of the planet

View File

@ -19,6 +19,7 @@
#include "gswe-timestamp.h"
#include "gswe-types.h"
#include "gswe-moon-phase-data-private.h"
extern gchar *gswe_ephe_path;
extern GsweTimestamp *gswe_full_moon_base_date;