Fixed some indentation

This commit is contained in:
Gergely Polonkai 2013-07-26 16:46:08 +02:00
parent 82c45bc336
commit 49a752fafa

View File

@ -12,18 +12,18 @@
#define MSPERDAY 86400000 #define MSPERDAY 86400000
typedef enum { typedef enum {
SIGN_ARIES = 1, SIGN_ARIES = 1,
SIGN_TAURUS, SIGN_TAURUS,
SIGN_GEMINI, SIGN_GEMINI,
SIGN_CANCER, SIGN_CANCER,
SIGN_LEO, SIGN_LEO,
SIGN_VIRGO, SIGN_VIRGO,
SIGN_LIBRA, SIGN_LIBRA,
SIGN_SCORPIO, SIGN_SCORPIO,
SIGN_SAGGITARIUS, SIGN_SAGGITARIUS,
SIGN_CAPRICORN, SIGN_CAPRICORN,
SIGN_AQUARIUS, SIGN_AQUARIUS,
SIGN_PISCES SIGN_PISCES
} zodiacSign; } zodiacSign;
typedef enum { typedef enum {
@ -40,7 +40,7 @@ typedef enum {
typedef struct { typedef struct {
moonState phase; moonState phase;
double visiblePercentage; double visiblePercentage;
} moonPhase; } moonPhase;
//RsvgHandle *svgHandle[SE_CHIRON + SIGN_PISCES + 1]; //RsvgHandle *svgHandle[SE_CHIRON + SIGN_PISCES + 1];
@ -48,51 +48,51 @@ typedef struct {
gboolean gboolean
init_graphics(void) init_graphics(void)
{ {
GError *err = NULL; GError *err = NULL;
char *svgFile[SE_CHIRON + SIGN_PISCES + 1]; char *svgFile[SE_CHIRON + SIGN_PISCES + 1];
int i; int i;
memset(&svgFile, 0, sizeof(char *) * SE_CHIRON + SIGN_PISCES + 1); memset(&svgFile, 0, sizeof(char *) * SE_CHIRON + SIGN_PISCES + 1);
svgFile[SE_SUN] = IMAGEDIR "/planet_sun.svg"; svgFile[SE_SUN] = IMAGEDIR "/planet_sun.svg";
svgFile[SE_MERCURY] = IMAGEDIR "/planet_mercury.svg"; svgFile[SE_MERCURY] = IMAGEDIR "/planet_mercury.svg";
svgFile[SE_VENUS] = IMAGEDIR "/planet_venus.svg"; svgFile[SE_VENUS] = IMAGEDIR "/planet_venus.svg";
svgFile[SE_MOON] = IMAGEDIR "/planet_moon.svg"; svgFile[SE_MOON] = IMAGEDIR "/planet_moon.svg";
svgFile[SE_MARS] = IMAGEDIR "/planet_mars.svg"; svgFile[SE_MARS] = IMAGEDIR "/planet_mars.svg";
svgFile[SE_JUPITER] = IMAGEDIR "/planet_jupiter.svg"; svgFile[SE_JUPITER] = IMAGEDIR "/planet_jupiter.svg";
svgFile[SE_SATURN] = IMAGEDIR "/planet_saturn.svg"; svgFile[SE_SATURN] = IMAGEDIR "/planet_saturn.svg";
svgFile[SE_NEPTUNE] = IMAGEDIR "/planet_neptune.svg"; svgFile[SE_NEPTUNE] = IMAGEDIR "/planet_neptune.svg";
svgFile[SE_URANUS] = IMAGEDIR "/planet_uranus.svg"; svgFile[SE_URANUS] = IMAGEDIR "/planet_uranus.svg";
svgFile[SE_PLUTO] = IMAGEDIR "/planet_pluto.svg"; svgFile[SE_PLUTO] = IMAGEDIR "/planet_pluto.svg";
// mean node is used for descending moon node // mean node is used for descending moon node
svgFile[SE_MEAN_NODE] = IMAGEDIR "/planet_desc_node.svg"; svgFile[SE_MEAN_NODE] = IMAGEDIR "/planet_desc_node.svg";
// true node is used for ascending moon node // true node is used for ascending moon node
svgFile[SE_TRUE_NODE] = IMAGEDIR "/planet_asc_node.svg"; svgFile[SE_TRUE_NODE] = IMAGEDIR "/planet_asc_node.svg";
svgFile[SE_CHIRON] = IMAGEDIR "/planet_chiron.svg"; svgFile[SE_CHIRON] = IMAGEDIR "/planet_chiron.svg";
svgFile[SE_CHIRON + SIGN_ARIES] = IMAGEDIR "/sign_aries.svg"; svgFile[SE_CHIRON + SIGN_ARIES] = IMAGEDIR "/sign_aries.svg";
svgFile[SE_CHIRON + SIGN_TAURUS] = IMAGEDIR "/sign_taurus.svg"; svgFile[SE_CHIRON + SIGN_TAURUS] = IMAGEDIR "/sign_taurus.svg";
svgFile[SE_CHIRON + SIGN_GEMINI] = IMAGEDIR "/sign_gemini.svg"; svgFile[SE_CHIRON + SIGN_GEMINI] = IMAGEDIR "/sign_gemini.svg";
svgFile[SE_CHIRON + SIGN_CANCER] = IMAGEDIR "/sign_cancer.svg"; svgFile[SE_CHIRON + SIGN_CANCER] = IMAGEDIR "/sign_cancer.svg";
svgFile[SE_CHIRON + SIGN_LEO] = IMAGEDIR "/sign_leo.svg"; svgFile[SE_CHIRON + SIGN_LEO] = IMAGEDIR "/sign_leo.svg";
svgFile[SE_CHIRON + SIGN_VIRGO] = IMAGEDIR "/sign_virgo.svg"; svgFile[SE_CHIRON + SIGN_VIRGO] = IMAGEDIR "/sign_virgo.svg";
svgFile[SE_CHIRON + SIGN_LIBRA] = IMAGEDIR "/sign_libra.svg"; svgFile[SE_CHIRON + SIGN_LIBRA] = IMAGEDIR "/sign_libra.svg";
svgFile[SE_CHIRON + SIGN_SCORPIO] = IMAGEDIR "/sign_scorpio.svg"; svgFile[SE_CHIRON + SIGN_SCORPIO] = IMAGEDIR "/sign_scorpio.svg";
svgFile[SE_CHIRON + SIGN_SAGGITARIUS] = IMAGEDIR "/sign_saggitarius.svg"; svgFile[SE_CHIRON + SIGN_SAGGITARIUS] = IMAGEDIR "/sign_saggitarius.svg";
svgFile[SE_CHIRON + SIGN_CAPRICORN] = IMAGEDIR "/sign_capricorn.svg"; svgFile[SE_CHIRON + SIGN_CAPRICORN] = IMAGEDIR "/sign_capricorn.svg";
svgFile[SE_CHIRON + SIGN_AQUARIUS] = IMAGEDIR "/sign_aquarius.svg"; svgFile[SE_CHIRON + SIGN_AQUARIUS] = IMAGEDIR "/sign_aquarius.svg";
svgFile[SE_CHIRON + SIGN_PISCES] = IMAGEDIR "/sign_pisces.svg"; svgFile[SE_CHIRON + SIGN_PISCES] = IMAGEDIR "/sign_pisces.svg";
for (i = SE_SUN; i <= SE_CHIRON + SIGN_PISCES; i++) { for (i = SE_SUN; i <= SE_CHIRON + SIGN_PISCES; i++) {
if (svgFile[i] != NULL) { if (svgFile[i] != NULL) {
g_clear_error(&err); g_clear_error(&err);
//if ((svgHandle[i] = rsvg_handle_new_from_file(svgFile[i], &err)) == NULL) { //if ((svgHandle[i] = rsvg_handle_new_from_file(svgFile[i], &err)) == NULL) {
// printf("Unable to load %s: %s\n", svgFile[i], err->message); // printf("Unable to load %s: %s\n", svgFile[i], err->message);
//} //}
} }
} }
return TRUE; return TRUE;
} }
double double
@ -282,72 +282,72 @@ main(int argc, char *argv[])
pos = get_planet_position(SE_MEAN_NODE, te); pos = get_planet_position(SE_MEAN_NODE, te);
printf("North Node: %2.0f (%f)\n", ceilf(pos / 30.0), pos); printf("North Node: %2.0f (%f)\n", ceilf(pos / 30.0), pos);
return OK; return OK;
} }
/* /*
static gboolean static gboolean
draw_clock (ClutterCanvas *canvas, cairo_t *cr, int width, int height) draw_clock (ClutterCanvas *canvas, cairo_t *cr, int width, int height)
{ {
GDateTime *now; GDateTime *now;
float hours, minutes, seconds; float hours, minutes, seconds;
ClutterColor color; ClutterColor color;
int smaller = (width < height) ? width : height; int smaller = (width < height) ? width : height;
// get the current time and compute the angles // get the current time and compute the angles
now = g_date_time_new_now_local(); now = g_date_time_new_now_local();
seconds = g_date_time_get_second(now) * G_PI / 30; seconds = g_date_time_get_second(now) * G_PI / 30;
minutes = g_date_time_get_minute(now) * G_PI / 30; minutes = g_date_time_get_minute(now) * G_PI / 30;
hours = g_date_time_get_hour(now) * G_PI / 6; hours = g_date_time_get_hour(now) * G_PI / 6;
cairo_save(cr); cairo_save(cr);
// clear the contents of the canvas, to avoid painting over the previous frame // clear the contents of the canvas, to avoid painting over the previous frame
cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
cairo_paint(cr); cairo_paint(cr);
cairo_restore(cr); cairo_restore(cr);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER); cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
// scale the modelview to the size of the surface // scale the modelview to the size of the surface
cairo_scale(cr, smaller, smaller); cairo_scale(cr, smaller, smaller);
cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND); cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
cairo_set_line_width(cr, 0.01); cairo_set_line_width(cr, 0.01);
// the black rail that holds the seconds indicator // the black rail that holds the seconds indicator
clutter_cairo_set_source_color(cr, CLUTTER_COLOR_Black); clutter_cairo_set_source_color(cr, CLUTTER_COLOR_Black);
cairo_translate(cr, 0.5, 0.5); cairo_translate(cr, 0.5, 0.5);
cairo_arc(cr, 0, 0, 0.4, 0, G_PI * 2); cairo_arc(cr, 0, 0, 0.4, 0, G_PI * 2);
cairo_stroke(cr); cairo_stroke(cr);
// the seconds indicator // the seconds indicator
color = *CLUTTER_COLOR_White; color = *CLUTTER_COLOR_White;
color.alpha = 128; color.alpha = 128;
clutter_cairo_set_source_color(cr, &color); clutter_cairo_set_source_color(cr, &color);
cairo_move_to(cr, 0, 0); cairo_move_to(cr, 0, 0);
cairo_arc(cr, sinf(seconds) * 0.4, - cosf(seconds) * 0.4, 0.02, 0, G_PI * 2); cairo_arc(cr, sinf(seconds) * 0.4, - cosf(seconds) * 0.4, 0.02, 0, G_PI * 2);
cairo_fill(cr); cairo_fill(cr);
// the minutes hand // the minutes hand
color = *CLUTTER_COLOR_DarkChameleon; color = *CLUTTER_COLOR_DarkChameleon;
color.alpha = 196; color.alpha = 196;
clutter_cairo_set_source_color(cr, &color); clutter_cairo_set_source_color(cr, &color);
cairo_move_to(cr, 0, 0); cairo_move_to(cr, 0, 0);
cairo_line_to(cr, sinf(minutes) * 0.4, - cosf(minutes) * 0.4); cairo_line_to(cr, sinf(minutes) * 0.4, - cosf(minutes) * 0.4);
cairo_stroke(cr); cairo_stroke(cr);
// the hours hand // the hours hand
cairo_move_to(cr, 0, 0); cairo_move_to(cr, 0, 0);
cairo_line_to(cr, sinf(hours) * 0.2, - cosf(hours) * 0.2); cairo_line_to(cr, sinf(hours) * 0.2, - cosf(hours) * 0.2);
cairo_stroke(cr); cairo_stroke(cr);
g_date_time_unref(now); g_date_time_unref(now);
// we're done drawing // we're done drawing
return TRUE; return TRUE;
} }
static guint idle_resize_id; static guint idle_resize_id;
@ -355,180 +355,180 @@ static guint idle_resize_id;
static gboolean static gboolean
idle_resize(gpointer data) idle_resize(gpointer data)
{ {
ClutterActor *actor = data; ClutterActor *actor = data;
float width, height; float width, height;
// match the canvas size to the actor's // match the canvas size to the actor's
clutter_actor_get_size(actor, &width, &height); clutter_actor_get_size(actor, &width, &height);
clutter_canvas_set_size(CLUTTER_CANVAS(clutter_actor_get_content(actor)), ceilf(width), ceilf(height)); clutter_canvas_set_size(CLUTTER_CANVAS(clutter_actor_get_content(actor)), ceilf(width), ceilf(height));
// unset the guard // unset the guard
idle_resize_id = 0; idle_resize_id = 0;
// remove the timeout // remove the timeout
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
} }
static void static void
on_actor_resize(ClutterActor *actor, const ClutterActorBox *allocation, ClutterAllocationFlags flags, gpointer user_data) on_actor_resize(ClutterActor *actor, const ClutterActorBox *allocation, ClutterAllocationFlags flags, gpointer user_data)
{ {
// throttle multiple actor allocations to one canvas resize; we use a guard variable to avoid queueing multiple resize operations // throttle multiple actor allocations to one canvas resize; we use a guard variable to avoid queueing multiple resize operations
if (idle_resize_id == 0) { if (idle_resize_id == 0) {
idle_resize_id = clutter_threads_add_timeout(1000, idle_resize, actor); idle_resize_id = clutter_threads_add_timeout(1000, idle_resize, actor);
} }
} }
int int
gradix_clutter_main(int argc, char *argv[]) gradix_clutter_main(int argc, char *argv[])
{ {
ClutterActor *stage, ClutterActor *stage,
*sign_aries, *sign_aries,
*sign_taurus, *sign_taurus,
*sign_gemini, *sign_gemini,
*sign_cancer, *sign_cancer,
*sign_leo, *sign_leo,
*sign_virgo, *sign_virgo,
*sign_libra, *sign_libra,
*sign_scorpio, *sign_scorpio,
*sign_saggitarius, *sign_saggitarius,
*sign_capricorn, *sign_capricorn,
*sign_aquarius, *sign_aquarius,
*sign_pisces, *sign_pisces,
*actor; *actor;
ClutterContent *canvas; ClutterContent *canvas;
GError *err = NULL; GError *err = NULL;
init_graphics(); init_graphics();
// initialize Clutter // initialize Clutter
if (clutter_init(&argc, &argv) != CLUTTER_INIT_SUCCESS) { if (clutter_init(&argc, &argv) != CLUTTER_INIT_SUCCESS) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }
// create a resizable stage // create a resizable stage
stage = clutter_stage_new(); stage = clutter_stage_new();
clutter_stage_set_title(CLUTTER_STAGE (stage), "GRadix"); clutter_stage_set_title(CLUTTER_STAGE (stage), "GRadix");
clutter_stage_set_user_resizable(CLUTTER_STAGE (stage), TRUE); clutter_stage_set_user_resizable(CLUTTER_STAGE (stage), TRUE);
clutter_actor_set_background_color(stage, CLUTTER_COLOR_LightSkyBlue); clutter_actor_set_background_color(stage, CLUTTER_COLOR_LightSkyBlue);
clutter_actor_set_size(stage, 300, 300); clutter_actor_set_size(stage, 300, 300);
clutter_actor_show(stage); clutter_actor_show(stage);
g_clear_error(&err); g_clear_error(&err);
if ((sign_aries = clutter_texture_new_from_file(IMAGEDIR "/sign_aries.svg", &err)) == NULL) { if ((sign_aries = clutter_texture_new_from_file(IMAGEDIR "/sign_aries.svg", &err)) == NULL) {
printf("%s\n", err->message); printf("%s\n", err->message);
} else { } else {
clutter_actor_add_child(stage, sign_aries); clutter_actor_add_child(stage, sign_aries);
} }
g_clear_error(&err); g_clear_error(&err);
if ((sign_taurus = clutter_texture_new_from_file(IMAGEDIR "/sign_taurus.svg", &err)) == NULL) { if ((sign_taurus = clutter_texture_new_from_file(IMAGEDIR "/sign_taurus.svg", &err)) == NULL) {
printf("%s\n", err->message); printf("%s\n", err->message);
} else { } else {
clutter_actor_add_child(stage, sign_taurus); clutter_actor_add_child(stage, sign_taurus);
} }
g_clear_error(&err); g_clear_error(&err);
if ((sign_gemini = clutter_texture_new_from_file(IMAGEDIR "/sign_gemini.svg", &err)) == NULL) { if ((sign_gemini = clutter_texture_new_from_file(IMAGEDIR "/sign_gemini.svg", &err)) == NULL) {
printf("%s\n", err->message); printf("%s\n", err->message);
} else { } else {
clutter_actor_add_child(stage, sign_gemini); clutter_actor_add_child(stage, sign_gemini);
} }
g_clear_error(&err); g_clear_error(&err);
if ((sign_cancer = clutter_texture_new_from_file(IMAGEDIR "/sign_cancer.svg", &err)) == NULL) { if ((sign_cancer = clutter_texture_new_from_file(IMAGEDIR "/sign_cancer.svg", &err)) == NULL) {
printf("%s\n", err->message); printf("%s\n", err->message);
} else { } else {
clutter_actor_add_child(stage, sign_cancer); clutter_actor_add_child(stage, sign_cancer);
} }
g_clear_error(&err); g_clear_error(&err);
if ((sign_leo = clutter_texture_new_from_file(IMAGEDIR "/sign_leo.svg", &err)) == NULL) { if ((sign_leo = clutter_texture_new_from_file(IMAGEDIR "/sign_leo.svg", &err)) == NULL) {
printf("%s\n", err->message); printf("%s\n", err->message);
} else { } else {
clutter_actor_add_child(stage, sign_leo); clutter_actor_add_child(stage, sign_leo);
} }
g_clear_error(&err); g_clear_error(&err);
if ((sign_virgo = clutter_texture_new_from_file(IMAGEDIR "/sign_virgo.svg", &err)) == NULL) { if ((sign_virgo = clutter_texture_new_from_file(IMAGEDIR "/sign_virgo.svg", &err)) == NULL) {
printf("%s\n", err->message); printf("%s\n", err->message);
} else { } else {
clutter_actor_add_child(stage, sign_virgo); clutter_actor_add_child(stage, sign_virgo);
} }
g_clear_error(&err); g_clear_error(&err);
if ((sign_libra = clutter_texture_new_from_file(IMAGEDIR "/sign_libra.svg", &err)) == NULL) { if ((sign_libra = clutter_texture_new_from_file(IMAGEDIR "/sign_libra.svg", &err)) == NULL) {
printf("%s\n", err->message); printf("%s\n", err->message);
} else { } else {
clutter_actor_add_child(stage, sign_libra); clutter_actor_add_child(stage, sign_libra);
} }
g_clear_error(&err); g_clear_error(&err);
if ((sign_scorpio = clutter_texture_new_from_file(IMAGEDIR "/sign_scorpio.svg", &err)) == NULL) { if ((sign_scorpio = clutter_texture_new_from_file(IMAGEDIR "/sign_scorpio.svg", &err)) == NULL) {
printf("%s\n", err->message); printf("%s\n", err->message);
} else { } else {
clutter_actor_add_child(stage, sign_scorpio); clutter_actor_add_child(stage, sign_scorpio);
} }
g_clear_error(&err); g_clear_error(&err);
if ((sign_saggitarius = clutter_texture_new_from_file(IMAGEDIR "/sign_saggitarius.svg", &err)) == NULL) { if ((sign_saggitarius = clutter_texture_new_from_file(IMAGEDIR "/sign_saggitarius.svg", &err)) == NULL) {
printf("%s\n", err->message); printf("%s\n", err->message);
} else { } else {
clutter_actor_add_child(stage, sign_saggitarius); clutter_actor_add_child(stage, sign_saggitarius);
} }
g_clear_error(&err); g_clear_error(&err);
if ((sign_capricorn = clutter_texture_new_from_file(IMAGEDIR "/sign_capricorn.svg", &err)) == NULL) { if ((sign_capricorn = clutter_texture_new_from_file(IMAGEDIR "/sign_capricorn.svg", &err)) == NULL) {
printf("%s\n", err->message); printf("%s\n", err->message);
} else { } else {
clutter_actor_add_child(stage, sign_capricorn); clutter_actor_add_child(stage, sign_capricorn);
} }
g_clear_error(&err); g_clear_error(&err);
if ((sign_aquarius = clutter_texture_new_from_file(IMAGEDIR "/sign_aquarius.svg", &err)) == NULL) { if ((sign_aquarius = clutter_texture_new_from_file(IMAGEDIR "/sign_aquarius.svg", &err)) == NULL) {
printf("%s\n", err->message); printf("%s\n", err->message);
} else { } else {
clutter_actor_add_child(stage, sign_aquarius); clutter_actor_add_child(stage, sign_aquarius);
} }
g_clear_error(&err); g_clear_error(&err);
if ((sign_pisces = clutter_texture_new_from_file(IMAGEDIR "/sign_pisces.svg", &err)) == NULL) { if ((sign_pisces = clutter_texture_new_from_file(IMAGEDIR "/sign_pisces.svg", &err)) == NULL) {
printf("%s\n", err->message); printf("%s\n", err->message);
} else { } else {
clutter_actor_add_child(stage, sign_pisces); clutter_actor_add_child(stage, sign_pisces);
} }
// our 2D canvas, courtesy of Cairo // our 2D canvas, courtesy of Cairo
//canvas = clutter_canvas_new(); //canvas = clutter_canvas_new();
//clutter_canvas_set_size(CLUTTER_CANVAS (canvas), 300, 300); //clutter_canvas_set_size(CLUTTER_CANVAS (canvas), 300, 300);
//actor = clutter_actor_new(); //actor = clutter_actor_new();
//clutter_actor_set_content(actor, canvas); //clutter_actor_set_content(actor, canvas);
//clutter_actor_set_content_scaling_filters(actor, CLUTTER_SCALING_FILTER_TRILINEAR, CLUTTER_SCALING_FILTER_LINEAR); //clutter_actor_set_content_scaling_filters(actor, CLUTTER_SCALING_FILTER_TRILINEAR, CLUTTER_SCALING_FILTER_LINEAR);
//clutter_actor_add_child(stage, actor); //clutter_actor_add_child(stage, actor);
// the actor now owns the canvas // the actor now owns the canvas
//g_object_unref(canvas); //g_object_unref(canvas);
// bind the size of the actor to that of the stage // bind the size of the actor to that of the stage
//clutter_actor_add_constraint(actor, clutter_bind_constraint_new(stage, CLUTTER_BIND_SIZE, 0)); //clutter_actor_add_constraint(actor, clutter_bind_constraint_new(stage, CLUTTER_BIND_SIZE, 0));
// resize the canvas whenever the actor changes size // resize the canvas whenever the actor changes size
//g_signal_connect(actor, "allocation-changed", G_CALLBACK(on_actor_resize), NULL); //g_signal_connect(actor, "allocation-changed", G_CALLBACK(on_actor_resize), NULL);
// quit on destroy // quit on destroy
g_signal_connect(stage, "destroy", G_CALLBACK(clutter_main_quit), NULL); g_signal_connect(stage, "destroy", G_CALLBACK(clutter_main_quit), NULL);
// connect our drawing code // connect our drawing code
//g_signal_connect(canvas, "draw", G_CALLBACK(draw_clock), NULL); //g_signal_connect(canvas, "draw", G_CALLBACK(draw_clock), NULL);
// invalidate the canvas, so that we can draw before the main loop starts // invalidate the canvas, so that we can draw before the main loop starts
//clutter_content_invalidate(canvas); //clutter_content_invalidate(canvas);
// set up a timer that invalidates the canvas every second // set up a timer that invalidates the canvas every second
//clutter_threads_add_timeout(1000, invalidate_clock, canvas); //clutter_threads_add_timeout(1000, invalidate_clock, canvas);
clutter_main(); clutter_main();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
*/ */