kopia lustrzana https://gitlab.com/Zwarf/picplanner
Fix wrong usage of classes and code style cleanup
rodzic
697bce1a41
commit
8ee40501dd
|
@ -32,10 +32,13 @@ max_day_in_month (int month,
|
|||
case 2:
|
||||
/* definition of a leap year: Every fourth year is a leap year expect if year%100 is 0 e.g. 1900
|
||||
* but every year where year%400 is 0 is a leap year again e.g. 2000 */
|
||||
if ((year%4==0 && year%100!=0) || year%400==0) {
|
||||
if (year%400==0 ||
|
||||
(year%4==0 && year%100!=0))
|
||||
{
|
||||
max_days = 29;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
max_days = 28;
|
||||
}
|
||||
break;
|
||||
|
@ -57,12 +60,10 @@ times_to_time_zone (int day_utc,
|
|||
}
|
||||
else{
|
||||
if (abs(day_utc-day_local)>1){
|
||||
if (day_utc < day_local){
|
||||
if (day_utc < day_local)
|
||||
day_local = day_utc-1;
|
||||
}
|
||||
else{
|
||||
else
|
||||
day_local = day_utc+1;
|
||||
}
|
||||
}
|
||||
time_zone = 24*(day_local-day_utc)+(hour_local-hour_utc);
|
||||
}
|
||||
|
@ -117,9 +118,7 @@ int
|
|||
int sign = time_utc[5]/abs(time_utc[5]);
|
||||
|
||||
for (int i = 0; i<6; i++)
|
||||
{
|
||||
time_local[i] = time_utc[i];
|
||||
}
|
||||
|
||||
time_local[3] = time_utc[3]+time_utc[5];
|
||||
if (time_local[3] > 24 || time_local[3] < 0)
|
||||
|
@ -151,9 +150,7 @@ int
|
|||
int sign = time_utc[5]/abs(time_utc[5]);
|
||||
|
||||
for (int i = 0; i<6; i++)
|
||||
{
|
||||
time_utc[i] = time_local[i];
|
||||
}
|
||||
|
||||
time_utc[3] = time_local[3] - time_utc[5];
|
||||
if (time_utc[3] > 24 || time_utc[3] < 0)
|
||||
|
@ -257,13 +254,9 @@ time_jd_to_sidereal_time(float longitude,
|
|||
|
||||
/* Julian date at 0 UT at the current date */
|
||||
if (time_jd - (int)time_jd >= 0.5)
|
||||
{
|
||||
jd_sidereal = (int)(time_jd) + 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
jd_sidereal = (int)(time_jd) - 0.5;
|
||||
}
|
||||
|
||||
hours_passed = 24*(time_jd-jd_sidereal);
|
||||
/*g_print("hours_passed %f\n", hours_passed);*/
|
||||
|
@ -329,30 +322,17 @@ float
|
|||
y = cos (declination) * sin (time_sidereal - right_ascension);
|
||||
|
||||
if (x < 0 && y <= 0)
|
||||
{
|
||||
azimuth = atan (y / x);
|
||||
}
|
||||
else if (x < 0 && y > 0)
|
||||
{
|
||||
azimuth = atan (y / x) + 2 * M_PI;
|
||||
}
|
||||
else if (x > 0)
|
||||
{
|
||||
azimuth = atan (y / x) + M_PI;
|
||||
}
|
||||
else if (x == 0 && y < 0)
|
||||
{
|
||||
azimuth = M_PI / 2;
|
||||
}
|
||||
else if (x == 0 && y > 0)
|
||||
{
|
||||
azimuth = -3 * M_PI / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
azimuth = 0;
|
||||
g_print("Error calculating azimuth!");
|
||||
}
|
||||
|
||||
elevation = asin (sin (latitude) * sin (declination)
|
||||
+ cos (latitude) * cos (declination) * cos (time_sidereal - right_ascension));
|
||||
|
|
|
@ -37,51 +37,6 @@ struct _PicplannerWindow
|
|||
G_DEFINE_TYPE (PicplannerWindow, picplanner_window, GTK_TYPE_APPLICATION_WINDOW)
|
||||
|
||||
|
||||
static void
|
||||
overview_realize (GtkWidget *self,
|
||||
gpointer user_data)
|
||||
{
|
||||
(void) self;
|
||||
(void) user_data;
|
||||
g_print ("overview is being realized\n");
|
||||
PicplannerOverview *overview = picplanner_overview_new ();
|
||||
gtk_box_append (GTK_BOX(self), GTK_WIDGET(overview));
|
||||
}
|
||||
|
||||
static void
|
||||
sun_realize (GtkWidget *self,
|
||||
gpointer user_data)
|
||||
{
|
||||
(void) self;
|
||||
(void) user_data;
|
||||
g_print ("sun is being realized\n");
|
||||
PicplannerSun *sun = picplanner_sun_new ();
|
||||
gtk_box_append (GTK_BOX(self), GTK_WIDGET(sun));
|
||||
}
|
||||
|
||||
static void
|
||||
moon_realize (GtkWidget *self,
|
||||
gpointer user_data)
|
||||
{
|
||||
(void) self;
|
||||
(void) user_data;
|
||||
g_print ("moon is being realized\n");
|
||||
PicplannerMoon *moon = picplanner_moon_new ();
|
||||
gtk_box_append (GTK_BOX(self), GTK_WIDGET(moon));
|
||||
}
|
||||
|
||||
static void
|
||||
milky_way_realize (GtkWidget *self,
|
||||
gpointer user_data)
|
||||
{
|
||||
(void) self;
|
||||
(void) user_data;
|
||||
g_print ("milky way is being realized\n");
|
||||
PicplannerMilkyway *milkyway = picplanner_milkyway_new ();
|
||||
gtk_box_append (GTK_BOX(self), GTK_WIDGET(milkyway));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
search_text_changed (GtkWidget *self,
|
||||
gpointer user_data)
|
||||
|
@ -97,16 +52,16 @@ picplanner_window_class_init (PicplannerWindowClass *klass)
|
|||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
g_type_ensure (PICPLANNER_OVERVIEW_TYPE);
|
||||
g_type_ensure (PICPLANNER_SUN_TYPE);
|
||||
g_type_ensure (PICPLANNER_MOON_TYPE);
|
||||
g_type_ensure (PICPLANNER_MILKYWAY_TYPE);
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/de/zwarf/picplanner/picplanner-window.ui");
|
||||
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, header_bar);
|
||||
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, searchbar);
|
||||
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, searchbutton);
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, overview_realize);
|
||||
gtk_widget_class_bind_template_callback (widget_class, sun_realize);
|
||||
gtk_widget_class_bind_template_callback (widget_class, moon_realize);
|
||||
gtk_widget_class_bind_template_callback (widget_class, milky_way_realize);
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, search_text_changed);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,24 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
|
||||
<object class="GtkBox" id="overview_box">
|
||||
<object class="PicplannerOverview" id="overview_box">
|
||||
<property name="orientation">vertical</property>
|
||||
<signal name="realize" handler="overview_realize"/>
|
||||
</object>
|
||||
|
||||
<object class="GtkBox" id="sun_box">
|
||||
<object class="PicplannerSun" id="sun_box">
|
||||
<property name="orientation">vertical</property>
|
||||
<signal name="realize" handler="sun_realize"/>
|
||||
</object>
|
||||
|
||||
<object class="GtkBox" id="moon_box">
|
||||
<object class="PicplannerMoon" id="moon_box">
|
||||
<property name="orientation">vertical</property>
|
||||
<signal name="realize" handler="moon_realize"/>
|
||||
</object>
|
||||
|
||||
<object class="GtkBox" id="milky_way_box">
|
||||
<object class="PicplannerMilkyway" id="milky_way_box">
|
||||
<property name="orientation">vertical</property>
|
||||
<signal name="realize" handler="milky_way_realize"/>
|
||||
</object>
|
||||
|
||||
<template class="PicplannerWindow" parent="GtkApplicationWindow">
|
||||
|
|
Ładowanie…
Reference in New Issue