Porównaj commity

...

42 Commity

Autor SHA1 Wiadomość Data
Zwarf a07e2bedad Fix issues which came in by the merges. Delete unnecessary files 2023-11-13 14:50:04 +01:00
Zwarf e026a09d83 Update README.md 2023-11-13 13:11:50 +00:00
Zwarf 3c60287c0a Merge branch 'more_warnings' into 'main'
Misc improvements (more gcc warnings, fix memory leaks, etc)

See merge request Zwarf/picplanner!7
2023-11-13 12:37:30 +00:00
Zwarf 64dbb31710 Merge branch 'main' into 'more_warnings'
# Conflicts:
#   src/time-picker/time-picker.c
2023-11-13 11:23:10 +00:00
Zwarf d14fa5ce11 Merge branch 'copyright' into 'main'
Include shumate copyright

See merge request Zwarf/picplanner!6
2023-11-13 11:12:42 +00:00
Zwarf 596c64f135 Merge branch 'main' into 'copyright'
# Conflicts:
#   copyright
#   meson.build
2023-11-13 11:12:02 +00:00
Zwarf 3240b50918 Merge branch 'circle' into 'main'
New UI design

See merge request Zwarf/picplanner!8
2023-11-13 10:55:16 +00:00
Zwarf dc7c3df345 Update to Version 0.4.1 2023-11-13 11:50:25 +01:00
Zwarf 425e184d0e possible workaround for lagging GUI? 2023-11-13 01:24:58 +01:00
Zwarf 7bf0f2172c Reduce write setting calls and map draw calls for better performance on touch devices 2023-11-12 11:50:39 +01:00
Zwarf e4eb1ef60a Found this crazy stupid bug which messes with the UI if the gsettings were set wrong 2023-11-12 01:14:43 +01:00
Zwarf 485b75b899 update 2023-11-11 22:29:08 +01:00
Zwarf aae275d9c8 Preparing for merge 2023-08-29 09:50:13 +02:00
Evangelos Ribeiro Tzaras e9670fed22 Include shumate copyright
As the code in src/map/draw-layer.c is mainly taken from shumate,
the copyright from the following files also applies:
- https://gitlab.gnome.org/GNOME/libshumate/-/blob/main/shumate/shumate-path-layer.c
- https://gitlab.gnome.org/GNOME/libshumate/-/blob/main/shumate/shumate-marker-layer.c

As the code in src/map/marker.c is mainly taken from shumate,
the copyright from the following files also applies:
- https://gitlab.gnome.org/GNOME/libshumate/-/blob/main/shumate/shumate-marker.c

The resulting code is (of course) still licensable under GPLv3+,
see https://www.gnu.org/licenses/gpl-faq.html#AllCompatibility
2023-08-19 21:15:14 +02:00
Evangelos Ribeiro Tzaras 7c730f2ea6 Bump meson project version to 0.4.0
We already have a 0.4 tagged.
2023-08-19 21:15:14 +02:00
Zwarf c854def552 Hide unnecessary buttons dependent on the stack page 2023-07-20 17:11:35 +02:00
Zwarf 28619d0a82 Replace wrong button 2023-07-20 13:43:05 +02:00
Zwarf 9bc67c084f Add back button 2023-07-19 22:42:47 +02:00
Zwarf 79bbf19c44 Add change stack signal 2023-07-19 14:06:56 +02:00
Zwarf 1111e7115a Change the design of the overview page to reduce white space. Prepare everything to switch the stack page by button presses at the overview page. 2023-07-19 10:50:10 +02:00
Zwarf 1770546f53 Test AdwPreferencesGroup Style: Seems to big! 2023-07-18 15:53:43 +02:00
Evangelos Ribeiro Tzaras 48fb647e99 calc-milky-way: Prefer g_auto* macros
g_autofree will automatically free variables when they go out of
scope. g_autoptr will do the same, but using the appropriate freefunc
for the given type, e.g. GDateTime -> g_date_time_unref() or
GObject -> g_object_unref().

This automatic cleanup reduces the risk of memory leaks
and allows getting rid of some lines of code.
2023-07-17 20:27:29 +02:00
Evangelos Ribeiro Tzaras 11b4f96592 calc-moon: Prefer g_auto* macros
g_autofree will automatically free variables when they go out of
scope. g_autoptr will do the same, but using the appropriate freefunc
for the given type, e.g. GDateTime -> g_date_time_unref() or
GObject -> g_object_unref().

This automatic cleanup reduces the risk of memory leaks
and allows getting rid of some lines of code.
2023-07-17 20:27:29 +02:00
Evangelos Ribeiro Tzaras a9493dc507 calc-sun: Prefer g_auto* macros
g_autofree will automatically free variables when they go out of
scope. g_autoptr will do the same, but using the appropriate freefunc
for the given type, e.g. GDateTime -> g_date_time_unref() or
GObject -> g_object_unref().

This automatic cleanup reduces the risk of memory leaks
and allows getting rid of some lines of code.
2023-07-17 20:27:29 +02:00
Evangelos Ribeiro Tzaras c86104db9f draw-layer: Use g_clear_pointer instead of emulating it 2023-07-17 20:27:29 +02:00
Evangelos Ribeiro Tzaras a5ebb680f7 milky-way-view: Prefer g_auto* macros
g_autofree will automatically free variables when they go out of
scope. g_autoptr will do the same, but using the appropriate freefunc
for the given type, e.g. GDateTime -> g_date_time_unref() or
GObject -> g_object_unref().

This automatic cleanup reduces the risk of memory leaks
and allows getting rid of some lines of code.
2023-07-17 20:27:29 +02:00
Evangelos Ribeiro Tzaras 1ed1b769b8 moon-view: Prefer g_auto* macros
g_autofree will automatically free variables when they go out of
scope. g_autoptr will do the same, but using the appropriate freefunc
for the given type, e.g. GDateTime -> g_date_time_unref() or
GObject -> g_object_unref().

This automatic cleanup reduces the risk of memory leaks
and allows getting rid of some lines of code.
2023-07-17 20:27:29 +02:00
Evangelos Ribeiro Tzaras 9ec83cc7e3 overview-view: Fix memory leak 2023-07-17 20:27:29 +02:00
Evangelos Ribeiro Tzaras a5545bfe00 overview-view: Prefer g_auto* macros
g_autofree will automatically free variables when they go out of
scope. g_autoptr will do the same, but using the appropriate freefunc
for the given type, e.g. GDateTime -> g_date_time_unref() or
GObject -> g_object_unref().

This automatic cleanup reduces the risk of memory leaks
and allows getting rid of some lines of code.
2023-07-17 20:27:29 +02:00
Evangelos Ribeiro Tzaras 359bbee260 sun-view: Prefer g_auto* macros
g_autofree will automatically free variables when they go out of
scope. g_autoptr will do the same, but using the appropriate freefunc
for the given type, e.g. GDateTime -> g_date_time_unref() or
GObject -> g_object_unref().

This automatic cleanup reduces the risk of memory leaks
and allows getting rid of some lines of code.
2023-07-17 20:27:29 +02:00
Evangelos Ribeiro Tzaras 9665a95248 window: Fix memory leak 2023-07-17 20:05:38 +02:00
Evangelos Ribeiro Tzaras a94043e2ef window: Prefer g_auto* macros
g_autofree will automatically free variables when they go out of
scope. g_autoptr will do the same, but using the appropriate freefunc
for the given type, e.g. GDateTime -> g_date_time_unref() or
GObject -> g_object_unref().

This automatic cleanup reduces the risk of memory leaks
and allows getting rid of some lines of code.
2023-07-17 20:05:38 +02:00
Evangelos Ribeiro Tzaras 3255001a90 time-picker: Prefer g_auto* macros
g_autofree will automatically free variables when they go out of
scope. g_autoptr will do the same, but using the appropriate freefunc
for the given type, e.g. GDateTime -> g_date_time_unref() or
GObject -> g_object_unref().

This automatic cleanup reduces the risk of memory leaks
and allows getting rid of some lines of code.
2023-07-17 19:39:54 +02:00
Evangelos Ribeiro Tzaras 933089cf6f search: Prefer g_auto* macros
g_autofree will automatically free variables when they go out of
scope. g_autoptr will do the same, but using the appropriate freefunc
for the given type, e.g. GDateTime -> g_date_time_unref() or
GObject -> g_object_unref().

This automatic cleanup reduces the risk of memory leaks
and allows getting rid of some lines of code.
2023-07-17 19:39:41 +02:00
Evangelos Ribeiro Tzaras e22102e641 build: Mark private functions as static
Fixes the following error
../src/window/picplanner-window.c:247:1: error: no previous declaration for ‘picplanner_update_date_time’ [-Werror=missing-declarations]
  247 | picplanner_update_date_time (PicplannerWindow *window)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
2023-07-17 19:23:12 +02:00
Evangelos Ribeiro Tzaras 29c660af5e transformations: Prefer atan2() to avoid special cases
This simplifies the code and also avoid the equality check for
floating numbers.

../src/calculations/calculations_transformations.c: In function ‘picplanner_transform_rotational_to_horizontal’:
../src/calculations/calculations_transformations.c:202:14: warning: comparing floating-point with ‘==’ or ‘!=’ is unsafe [-Wfloat-equal]
  202 |   else if (x == 0 && y < 0)
      |              ^~
../src/calculations/calculations_transformations.c:204:14: warning: comparing floating-point with ‘==’ or ‘!=’ is unsafe [-Wfloat-equal]
  204 |   else if (x == 0 && y > 0)
      |              ^~
2023-07-17 19:23:12 +02:00
Evangelos Ribeiro Tzaras 0c627b0e7f build: Conform to strict prototype requirement
-Wstrict-prototypes disallows empty function prototypes and
prefers specifying (void) instead.

Fixes the following type of warning
In file included from ../src/window/sun-page/sun-view.c:20:
../src/window/sun-page/sun-view.h:52:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
   52 | PicplannerSun *picplanner_sun_new ();
      | ^~~~~~~~~~~~~

The .c files also now include (void) to fix old-style definitions warnings
../src/time-picker/time-picker.c: In function ‘time_picker_new’:
../src/time-picker/time-picker.c:236:1: warning: old-style function definition [-Wold-style-definition]
  236 | time_picker_new ()
      | ^~~~~~~~~~~~~~~
2023-07-17 19:23:12 +02:00
Evangelos Ribeiro Tzaras f6b18b2286 draw-layer: Indent 'else' on the same level as 'if'
Fixes raised warnings from -Wmisleading-indentation
2023-07-17 19:23:12 +02:00
Evangelos Ribeiro Tzaras d98027988c build: Don't mix code and declarations
Fixes the warnings raised by -Wdeclaration-after-statement
../src/window/picplanner-window.c: In function ‘picplanner_update_date_time’:
../src/window/picplanner-window.c:290:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  290 |   double time_zone = (double) g_date_time_get_utc_offset (window->date_time)/3600/1000/1000;
      |   ^~~~~~
2023-07-17 19:23:12 +02:00
Evangelos Ribeiro Tzaras 7967767d21 build: Enable additional compiler warnings 2023-07-17 18:03:05 +02:00
Zwarf aec87618ae Change TimeZone to suggested positon 2023-06-19 01:18:59 +02:00
Zwarf 47eae76c0b Design change towards suggestions of GNOME Circle 2023-04-25 15:38:59 +02:00
39 zmienionych plików z 1888 dodań i 802 usunięć

Wyświetl plik

@ -24,3 +24,8 @@ Version 0.4.0:
- Fullscreen map mode is now saved and not reseted after an app restart
- Dependency update
- Switch to GNOME 44 runtime
Version 0.4.1:
- Reduced input lag on touch screens significantly
- Complet UI redesign for a more compact view
- Add French translation

Wyświetl plik

@ -54,9 +54,9 @@ Or download the Flatpak from <a href='https://flathub.org/apps/details/de.zwarf.
## Screenshots Desktop Size, Light Theme
<a href='https://gitlab.com/zwarf/picplanner/-/blob/main/screenshots/picplanner-1.png'><img height='550px' alt='screenshot-large' src='https://gitlab.com/zwarf/picplanner/-/raw/main/screenshots/picplanner-1.png'/></a>
<a href='https://gitlab.com/zwarf/picplanner/-/blob/main/screenshots/picplanner-2.png'><img height='550px' alt='screenshot-large' src='https://gitlab.com/zwarf/picplanner/-/raw/main/screenshots/picplanner-2.png'/></a>
<a href='https://gitlab.com/zwarf/picplanner/-/blob/main/screenshots/picplanner-3.png'><img height='550px' alt='screenshot-large' src='https://gitlab.com/zwarf/picplanner/-/raw/main/screenshots/picplanner-3.png'/></a>
<a href='https://gitlab.com/zwarf/picplanner/-/blob/main/screenshots/picplanner-4.png'><img height='550px' alt='screenshot-large' src='https://gitlab.com/zwarf/picplanner/-/raw/main/screenshots/picplanner-4.png'/></a>
<a href='https://gitlab.com/zwarf/picplanner/-/blob/main/screenshots/picplanner-1.png'><img alt='screenshot-large' src='https://gitlab.com/zwarf/picplanner/-/raw/main/screenshots/picplanner-1.png'/></a>
<a href='https://gitlab.com/zwarf/picplanner/-/blob/main/screenshots/picplanner-2.png'><img alt='screenshot-large' src='https://gitlab.com/zwarf/picplanner/-/raw/main/screenshots/picplanner-2.png'/></a>
<a href='https://gitlab.com/zwarf/picplanner/-/blob/main/screenshots/picplanner-3.png'><img alt='screenshot-large' src='https://gitlab.com/zwarf/picplanner/-/raw/main/screenshots/picplanner-3.png'/></a>
<a href='https://gitlab.com/zwarf/picplanner/-/blob/main/screenshots/picplanner-4.png'><img alt='screenshot-large' src='https://gitlab.com/zwarf/picplanner/-/raw/main/screenshots/picplanner-4.png'/></a>
<a rel="me" href="https://social.anoxinon.de/@zwarf"></a>

Wyświetl plik

@ -1,18 +1,27 @@
Files: *
Copyright: 2020-2022 Zwarf <zwarf@mail.de>
Copyright:
2020-2023 Zwarf <zwarf@mail.de>
License: GPL-3+
Files: data/icons/pin.svg
data/icons/sun.svg
data/icons/moon-full.svg
data/icons/moon-waning.svg
data/icons/moon-new.svg
data/icons/moon-waxing.svg
data/icons/milky-way-symbolic.svg
data/icons/milky-way-color.svg
Copyright: 2022 Rajdeep Singha <rajdeepsingha@proton.me>
Files:
src/map/draw-layer.*
src/map/marker.*
Copyright:
2008-2009 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
2011-2013 Jiri Techet <techet@gmail.com>
2019 Marcus Lundblad <ml@update.uu.se>
2021 Zwarf <zwarf@mail.de>
License: GPL-3+
Files: data/icons/map-symbolic.svg
Copyright: GNOME
Files:
data/icons/pin.svg
data/icons/sun.svg
data/icons/moon-full.svg
data/icons/moon-waning.svg
data/icons/moon-new.svg
data/icons/moon-waxing.svg
data/icons/milky-way-symbolic.svg
data/icons/milky-way-color.svg
Copyright:
2022 Rajdeep Singha <rajdeepsingha@proton.me>
License: GPL-3+

Wyświetl plik

@ -62,10 +62,5 @@
<summary>Visibility Milky Way</summary>
<description>Changes the visibility of the milky ways current position, rise and set on the map.</description>
</key>
<key name="map-fullscreen" type="b">
<default>false</default>
<summary>Big map mode</summary>
<description>Reduce the amount of information in the Overview tab to enlarge the map.</description>
</key>
</schema>
</schemalist>

Wyświetl plik

@ -68,11 +68,27 @@
<control>touch</control>
</supports>
<recommends>
<control>keyboard</control>
<control>pointing</control>
<control>touch</control>
</recommends>
<requires>
<display_length compare="ge">360</display_length>
</requires>
<releases>
<release version="0.4.1" date="2023-11-13" >
<description>
<p>UI redesign, adding French and better touch support</p>
<ul>
<li>Reduced input lag on touch screens significantly</li>
<li>Complet UI redesign for a more compact view</li>
<li>Add French translation</li>
</ul>
</description>
</release>
<release version="0.4.0" date="2023-04-23" >
<description>
<p>Bug fixes, UI improvements and GNOME 44 runtime</p>

Wyświetl plik

@ -1,2 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 16 16" width="16px"><path d="m 15 2 v 10 l -5 3 l -5 -3 l -5 3 v -10 l 5 -3 l 5 3 z m -10 1 v 8 l 5 3 v -8 z m 0 0" fill="#222222"/></svg>

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 245 B

Wyświetl plik

@ -51,8 +51,4 @@ install_data(
install_data(
'elevation-symbolic.svg',
install_dir: join_paths(get_option('datadir'), 'icons')
)
install_data(
'map-symbolic.svg',
install_dir: join_paths(get_option('datadir'), 'icons')
)

Wyświetl plik

@ -126,7 +126,7 @@
"sources" : [
{
"type" : "git",
"url" : "~/Projekte/picplanner"
"url" : "~/Projekte/picplanner-circle"
}
]
}

Wyświetl plik

@ -1,5 +1,5 @@
project('picplanner', 'c',
version: '0.3.2',
version: '0.4.1',
meson_version: '>= 0.50.0',
default_options: [ 'warning_level=2',
'c_std=gnu11',
@ -16,9 +16,53 @@ configure_file(
output: 'picplanner-config.h',
configuration: config_h,
)
add_project_arguments([
'-I' + meson.build_root(),
], language: 'c')
cc = meson.get_compiler('c')
global_c_args = ['-I' + meson.build_root()]
test_c_args = [
'-Wcast-align',
'-Wdate-time',
'-Wdeclaration-after-statement',
['-Werror=format-security', '-Werror=format=2'],
'-Wendif-labels',
'-Werror=incompatible-pointer-types',
'-Werror=missing-declarations',
'-Werror=overflow',
'-Werror=return-type',
'-Werror=shift-count-overflow',
'-Werror=shift-overflow=2',
'-Wfloat-equal',
'-Wformat-nonliteral',
'-Wformat-security',
'-Winit-self',
'-Wmaybe-uninitialized',
'-Wmisleading-indentation',
'-Wmissing-include-dirs',
'-Wmissing-noreturn',
'-Wnested-externs',
'-Wold-style-definition',
'-Wshadow',
'-Wstrict-prototypes',
'-Wswitch-default',
'-Wno-switch-enum',
'-Wtype-limits',
'-Wunused-function',
'-Wunused-variable',
]
if get_option('buildtype') != 'plain'
test_c_args += '-fstack-protector-strong'
endif
foreach arg: test_c_args
if cc.has_multi_arguments(arg)
global_c_args += arg
endif
endforeach
add_project_arguments(
global_c_args,
language: 'c')
subdir('data')

Wyświetl plik

@ -46,7 +46,7 @@ double
double latitude)
{
double siderial_time;
double *coordinates_milky_way;
g_autofree double *coordinates_milky_way = NULL;
double *coordinates_horizontal_milky_way;
coordinates_milky_way = picplanner_get_coordinates_rotational_milky_way ();
@ -55,8 +55,6 @@ double
latitude,
siderial_time);
g_free (coordinates_milky_way);
return coordinates_horizontal_milky_way;
}
@ -70,22 +68,19 @@ double
double longitude,
double latitude)
{
GDateTime *iteration_time;
double *coordinates_milky_way;
double *array_coordinates_milky_way = malloc (sizeof (double) * 2 * NUM_DATA_POINTS);
for (int i=0; i<NUM_DATA_POINTS; i++)
{
iteration_time = g_date_time_add_minutes (date_time, i*24*60/NUM_DATA_POINTS-12*60);
g_autoptr (GDateTime) iteration_time =
g_date_time_add_minutes (date_time, i*24*60/NUM_DATA_POINTS-12*60);
g_autofree double *coordinates_milky_way =
picplanner_get_coordinates_milky_way (iteration_time,
longitude,
latitude);
coordinates_milky_way = picplanner_get_coordinates_milky_way (iteration_time,
longitude,
latitude);
array_coordinates_milky_way[2*i] = coordinates_milky_way[0];
array_coordinates_milky_way[2*i+1] = coordinates_milky_way[1];
g_free (coordinates_milky_way);
g_date_time_unref (iteration_time);
}
return array_coordinates_milky_way;
@ -166,4 +161,4 @@ char
g_date_time_unref (date_time_disturbance);
return char_no_disturbance;
}
}

Wyświetl plik

@ -21,7 +21,7 @@
double
*picplanner_get_coordinates_rotational_milky_way ();
*picplanner_get_coordinates_rotational_milky_way (void);
double
*picplanner_get_coordinates_milky_way (GDateTime *date_time,

Wyświetl plik

@ -68,8 +68,8 @@ picplanner_get_illumination (GDateTime *date_time)
{
double illumination;
double elongation;
double *coordinates_moon;
double *coordinates_sun;
g_autofree double *coordinates_moon = NULL;
g_autofree double *coordinates_sun = NULL;
double ra_sun, dec_sun, ra_moon, dec_moon;
coordinates_moon = picplanner_get_coordinates_rotational_moon (date_time);
coordinates_sun = picplanner_get_coordinates_rotational_sun (date_time);
@ -82,9 +82,6 @@ picplanner_get_illumination (GDateTime *date_time)
elongation = sin(dec_sun)*sin(dec_moon) + cos(dec_sun)*cos(dec_moon)*cos(ra_sun-ra_moon);
illumination = (1 - elongation)/2;
g_free (coordinates_moon);
g_free (coordinates_sun);
return illumination*100.;
}
@ -95,7 +92,7 @@ double
double latitude)
{
double siderial_time;
double *coordinates_moon;
g_autofree double *coordinates_moon = NULL;
double *coordinates_horizontal_moon;
coordinates_moon = picplanner_get_coordinates_rotational_moon (date_time);
@ -104,7 +101,6 @@ double
latitude,
siderial_time);
g_free (coordinates_moon);
return coordinates_horizontal_moon;
}
@ -115,22 +111,19 @@ double
double longitude,
double latitude)
{
GDateTime *iteration_time;
double *coordinates_moon;
double *array_coordinates_moon = malloc (sizeof (double) * 2 * NUM_DATA_POINTS);
for (int i=0; i<NUM_DATA_POINTS; i++)
{
iteration_time = g_date_time_add_minutes (date_time, i*24*60/NUM_DATA_POINTS-12*60);
g_autoptr (GDateTime) iteration_time =
g_date_time_add_minutes (date_time, i*24*60/NUM_DATA_POINTS-12*60);
g_autofree double *coordinates_moon =
picplanner_get_coordinates_moon (iteration_time,
longitude,
latitude);
coordinates_moon = picplanner_get_coordinates_moon (iteration_time,
longitude,
latitude);
array_coordinates_moon[2*i] = coordinates_moon[0];
array_coordinates_moon[2*i+1] = coordinates_moon[1];
g_free (coordinates_moon);
g_date_time_unref (iteration_time);
}
return array_coordinates_moon;

Wyświetl plik

@ -64,7 +64,7 @@ double
double latitude)
{
double siderial_time;
double *coordinates_sun;
g_autofree double *coordinates_sun = NULL;
double *coordinates_horizontal_sun;
@ -73,7 +73,6 @@ double
coordinates_horizontal_sun = picplanner_transform_rotational_to_horizontal (coordinates_sun,
latitude,
siderial_time);
g_free (coordinates_sun);
return coordinates_horizontal_sun;
}
@ -84,23 +83,18 @@ double
double longitude,
double latitude)
{
GDateTime *iteration_time;
double *coordinates_sun;
double *array_coordinates_sun = malloc (sizeof (double) * 2 * NUM_DATA_POINTS);
for (int i=0; i<NUM_DATA_POINTS; i++)
{
iteration_time = g_date_time_add_minutes (date_time, i*24*60/NUM_DATA_POINTS-12*60);
coordinates_sun = picplanner_get_coordinates_sun (iteration_time,
longitude,
latitude);
GDateTime *iteration_time = g_date_time_add_minutes (date_time, i*24*60/NUM_DATA_POINTS-12*60);
g_autofree double *coordinates_sun =
picplanner_get_coordinates_sun (iteration_time,
longitude,
latitude);
array_coordinates_sun[2*i] = coordinates_sun[0];
array_coordinates_sun[2*i+1] = coordinates_sun[1];
g_free (coordinates_sun);
g_date_time_unref (iteration_time);
}
return array_coordinates_sun;

Wyświetl plik

@ -193,18 +193,7 @@ double
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;
azimuth = atan2 (-y, -x);
elevation = asin (sin (latitude) * sin (declination)
+ cos (latitude) * cos (declination) * cos (time_sidereal - right_ascension));

Wyświetl plik

@ -42,7 +42,7 @@ times_to_time_zone (int day_utc,
int hour_local);
int
*get_time_utc ();
*get_time_utc (void);
int
*utc_time_to_local_time (int *time_utc);

Wyświetl plik

@ -60,9 +60,6 @@ set_user_location (GObject *source_object,
gpointer user_data)
{
(void) source_object;
(void) user_data;
double latitude;
double longitude;
@ -72,6 +69,9 @@ set_user_location (GObject *source_object,
static GClueLocation *location; /* How can one free this? */
(void) source_object;
(void) user_data;
simple = gclue_simple_new_finish (res, &error);
if (error == NULL)
@ -112,4 +112,4 @@ get_user_location (GtkButton *self,
set_user_location,
user_data);
}
}
}

Wyświetl plik

@ -1,5 +1,8 @@
/*
* draw-layer.c
* Copyright (C) 2008-2009 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
* Copyright (C) 2011-2013 Jiri Techet <techet@gmail.com>
* Copyright (C) 2019 Marcus Lundblad <ml@update.uu.se>
* Copyright (C) 2021 Zwarf <zwarf@mail.de>
*
* This program is free software: you can redistribute it and/or modify
@ -116,11 +119,11 @@ picplanner_draw_layer_size_allocate (GtkWidget *widget,
int height,
int baseline)
{
(void) baseline;
PicplannerDrawLayer *self = PICPLANNER_DRAW_LAYER (widget);
GtkAllocation allocation;
GtkWidget *child;
(void) baseline;
for (child = gtk_widget_get_first_child (GTK_WIDGET (self));
child != NULL;
child = gtk_widget_get_next_sibling (child))
@ -143,7 +146,7 @@ picplanner_draw_layer_size_allocate (GtkWidget *widget,
x_offset = 0;
y_offset = (height-width)/2;
}
else
else
{
min_size = height;
x_offset = (width-height)/2;
@ -334,10 +337,10 @@ picplanner_draw_layer_add_node_coordinates (PicplannerDrawLayer *layer,
double x,
double y)
{
g_return_if_fail (PICPLANNER_IS_DRAW_LAYER (layer));
PicplannerDrawLayerPrivate *priv = picplanner_draw_layer_get_instance_private (layer);
g_return_if_fail (PICPLANNER_IS_DRAW_LAYER (layer));
priv->nodes_coordinates = (double *) realloc (priv->nodes_coordinates, sizeof (double) * (priv->nodes_len+1) * 2);
priv->nodes_coordinates[priv->nodes_len*2] = x;
@ -352,10 +355,10 @@ void
picplanner_draw_layer_remove_all (PicplannerDrawLayer *layer)
{
PicplannerDrawLayerPrivate *priv = picplanner_draw_layer_get_instance_private (layer);
GtkWidget *child;
g_return_if_fail (PICPLANNER_IS_DRAW_LAYER (layer));
GtkWidget *child;
child = gtk_widget_get_first_child (GTK_WIDGET (layer));
while (child)
@ -368,8 +371,7 @@ picplanner_draw_layer_remove_all (PicplannerDrawLayer *layer)
child = next;
}
g_free (priv->nodes_coordinates);
priv->nodes_coordinates = NULL;
g_clear_pointer (&priv->nodes_coordinates, g_free);
priv->nodes_len = 0;
gtk_widget_queue_draw (GTK_WIDGET (layer));

Wyświetl plik

@ -1,5 +1,8 @@
/*
* draw-layer.h
* Copyright (C) 2008-2009 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
* Copyright (C) 2011-2013 Jiri Techet <techet@gmail.com>
* Copyright (C) 2019 Marcus Lundblad <ml@update.uu.se>
* Copyright (C) 2021 Zwarf <zwarf@mail.de>
*
* This program is free software: you can redistribute it and/or modify

Wyświetl plik

@ -1,5 +1,8 @@
/*
* marker.c
* Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
* Copyright (C) 2011-2013 Jiri Techet <techet@gmail.com>
* Copyright (C) 2019 Marcus Lundblad <ml@update.uu.se>
* Copyright (C) 2021 Zwarf <zwarf@mail.de>
*
* This program is free software: you can redistribute it and/or modify

Wyświetl plik

@ -1,5 +1,8 @@
/*
* marker.h
* Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
* Copyright (C) 2011-2013 Jiri Techet <techet@gmail.com>
* Copyright (C) 2019 Marcus Lundblad <ml@update.uu.se>
* Copyright (C) 2021 Zwarf <zwarf@mail.de>
*
* This program is free software: you can redistribute it and/or modify

Wyświetl plik

@ -39,7 +39,7 @@ struct _PicplannerApplication
G_DEFINE_TYPE (PicplannerApplication, picplanner_application, ADW_TYPE_APPLICATION)
void
static void
first_run_set_timezone (PicplannerApplication *application)
{
gint64 timezone;
@ -123,8 +123,6 @@ picplanner_application_show_about (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
(void) action;
(void) parameter;
PicplannerApplication *self = PICPLANNER_APPLICATION (user_data);
GtkWindow *window = NULL;
@ -134,7 +132,10 @@ picplanner_application_show_about (GSimpleAction *action,
const gchar *copyright =
"Copyright \xC2\xA9 2020 Zwarf\n\n"
"License Map Data ODBL OpenStreetMap Contributors\nMap Imagery CC-BY-SA 2.0 OpenStreetMap";
g_return_if_fail (PICPLANNER_IS_APPLICATION (self));
(void) action;
(void) parameter;
window = gtk_application_get_active_window (GTK_APPLICATION (self));
@ -142,7 +143,7 @@ picplanner_application_show_about (GSimpleAction *action,
"application-icon", "de.zwarf.picplanner",
"application-name", "PicPlanner",
"developer-name", "Zwarf",
"version", "0.4.0",
"version", "0.4.1",
"website", "https://gitlab.com/Zwarf/picplanner",
"issue-url", "https://gitlab.com/Zwarf/picplanner/-/issues/new",
"copyright", copyright,
@ -162,11 +163,12 @@ picplanner_application_show_preferences (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
(void) action;
(void) parameter;
PicplannerPrefs *prefs;
GtkWindow *window = NULL;
(void) action;
(void) parameter;
window = gtk_application_get_active_window (GTK_APPLICATION (user_data));
prefs = picplanner_prefs_new (PICPLANNER_WINDOW (window));
gtk_window_present (GTK_WINDOW (prefs));
@ -181,10 +183,12 @@ picplanner_inverte_scheme (GSettings *settings,
gchar *key,
gpointer user_data)
{
(void) key;
PicplannerApplication *app = user_data;
AdwStyleManager *manager = adw_application_get_style_manager (ADW_APPLICATION (app));
gboolean invert_scheme = g_settings_get_boolean (settings, "invert-scheme");
(void) key;
if (invert_scheme)
{
if (adw_style_manager_get_dark (manager))
@ -202,19 +206,23 @@ picplanner_inverte_scheme (GSettings *settings,
static void
picplanner_application_init (PicplannerApplication *self)
{
GSimpleAction *quit_action = g_simple_action_new ("quit", NULL);
GSimpleAction *quit_action;
GSimpleAction *about_action;
GSimpleAction *preferences_action;
const char *accels[] = {"<primary>q", NULL};
quit_action = g_simple_action_new ("quit", NULL);
g_signal_connect_swapped (quit_action, "activate", G_CALLBACK (g_application_quit), self);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (quit_action));
GSimpleAction *about_action = g_simple_action_new ("about", NULL);
about_action = g_simple_action_new ("about", NULL);
g_signal_connect (about_action, "activate", G_CALLBACK (picplanner_application_show_about), self);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (about_action));
GSimpleAction *preferences_action = g_simple_action_new ("preferences", NULL);
preferences_action = g_simple_action_new ("preferences", NULL);
g_signal_connect (preferences_action, "activate", G_CALLBACK (picplanner_application_show_preferences), self);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (preferences_action));
const char *accels[] = {"<primary>q", NULL};
gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.quit", accels);
self->settings = g_settings_new ("de.zwarf.picplanner");

Wyświetl plik

@ -20,6 +20,5 @@
<file alias="milky-way-symbolic.svg">../data/icons/milky-way-symbolic.svg</file>
<file alias="azimuth-symbolic.svg">../data/icons/azimuth-symbolic.svg</file>
<file alias="elevation-symbolic.svg">../data/icons/elevation-symbolic.svg</file>
<file alias="map-symbolic.svg">../data/icons/map-symbolic.svg</file>
</gresource>
</gresources>

Wyświetl plik

@ -41,10 +41,13 @@ find_loc_children (GWeatherLocation *location,
{
if (gweather_location_get_level (child) == GWEATHER_LOCATION_CITY)
{
g_autofree char *location_string_merge = NULL;
g_autofree char *location_norm = NULL;
g_autofree char *location_string = NULL;
const char *city = gweather_location_get_name (child);
const char *region = gweather_location_get_name (gweather_location_get_parent (child));
const char *country = gweather_location_get_country_name (child);
char *location_string_merge;
if (gweather_location_get_level (gweather_location_get_parent (child))
== GWEATHER_LOCATION_COUNTRY)
{
@ -58,24 +61,20 @@ find_loc_children (GWeatherLocation *location,
country);
}
char *location_norm = g_utf8_normalize (location_string_merge,
location_norm = g_utf8_normalize (location_string_merge,
strlen (location_string_merge),
G_NORMALIZE_ALL_COMPOSE);
char *location_string = g_utf8_casefold (location_norm, strlen (location_norm));
location_string = g_utf8_casefold (location_norm, strlen (location_norm));
g_free (location_string_merge);
g_free (location_norm);
if (strstr (location_string, search_str))
{
locations[*iteration] = g_object_ref(child);
(*iteration)++;
if (*iteration>=NUM_SEARCH_RESULTS)
{
g_free (location_string);
return TRUE;
}
}
g_free (location_string);
}
else
{

Wyświetl plik

@ -31,6 +31,7 @@ struct _TimePicker
GtkWidget *spin_button_hour;
GtkWidget *spin_button_minute;
GtkWidget *time_button;
};
G_DEFINE_TYPE (TimePicker, time_picker, GTK_TYPE_BOX)
@ -53,10 +54,9 @@ void
time_picker_set_time_zone (TimePicker *time_picker,
double time_zone)
{
char *char_time_zone;
g_autofree char *char_time_zone = NULL;
char_time_zone = g_strdup_printf ("UTC %s%.1f", time_zone>=0 ? "+" : "", time_zone);
gtk_label_set_text (GTK_LABEL (time_picker->label_time_zone), char_time_zone);
g_free (char_time_zone);
}
@ -121,6 +121,17 @@ input_changed (GtkWidget *self,
{
(void) self;
char *time_button_text;
time_button_text = g_strdup_printf ("%02.f:%02.f",
gtk_spin_button_get_value (GTK_SPIN_BUTTON (time_picker->spin_button_hour)),
gtk_spin_button_get_value (GTK_SPIN_BUTTON (time_picker->spin_button_minute)));
gtk_menu_button_set_label (GTK_MENU_BUTTON (time_picker->time_button), time_button_text);
g_free (time_button_text);
g_signal_emit (time_picker,
signal_change,
0, NULL);
@ -135,7 +146,7 @@ static gboolean
time_spin_button_text (GtkSpinButton *self)
{
int value;
char *button_text;
g_autofree char *button_text = NULL;
GtkAdjustment *adjustment;
adjustment = gtk_spin_button_get_adjustment (self);
@ -143,7 +154,6 @@ time_spin_button_text (GtkSpinButton *self)
button_text = g_strdup_printf ("%02d", value);
gtk_editable_set_text (GTK_EDITABLE (self),
button_text);
g_free (button_text);
return TRUE;
}
@ -151,16 +161,16 @@ time_spin_button_text (GtkSpinButton *self)
/*
* Change the text of the button which presents the calender after a date was selected.
* Furthermore the behavior of the popup is controlled.
* TODO: combine with input_changed function
*/
static void
day_selected (GtkCalendar *self,
TimePicker *time_picker)
{
(void) self;
GDateTime *date_selected;
GtkPopover *popover;
char *button_text;
g_autoptr (GDateTime) date_selected = NULL;
g_autofree char *button_text = NULL;
(void) self;
date_selected = gtk_calendar_get_date (GTK_CALENDAR (time_picker->calendar));
/*
@ -173,17 +183,6 @@ day_selected (GtkCalendar *self,
gtk_menu_button_set_label (GTK_MENU_BUTTON (time_picker->calendar_button),
button_text);
/*
* Close Popover after the day was selected
* TODO: Popdown happens automatically if a month is chosen which has less days then
* the day number previously selected.
*/
popover = GTK_POPOVER(time_picker->calendar_popover);
gtk_popover_popdown (popover);
g_free (button_text);
g_date_time_unref (date_selected);
input_changed (GTK_WIDGET (self), time_picker);
}
@ -220,6 +219,7 @@ time_picker_class_init (TimePickerClass *class)
gtk_widget_class_bind_template_child (widget_class, TimePicker, calendar_button);
gtk_widget_class_bind_template_child (widget_class, TimePicker, spin_button_hour);
gtk_widget_class_bind_template_child (widget_class, TimePicker, spin_button_minute);
gtk_widget_class_bind_template_child (widget_class, TimePicker, time_button);
gtk_widget_class_bind_template_callback (widget_class, day_selected);
gtk_widget_class_bind_template_callback (widget_class, time_spin_button_text);
@ -233,7 +233,7 @@ time_picker_class_init (TimePickerClass *class)
}
TimePicker *
time_picker_new ()
time_picker_new (void)
{
return g_object_new (TIME_PICKER_TYPE, NULL);
}
}

Wyświetl plik

@ -48,6 +48,6 @@ int
time_picker_get_minute (TimePicker *time_picker);
TimePicker *time_picker_new ();
TimePicker *time_picker_new (void);
G_END_DECLS

Wyświetl plik

@ -18,6 +18,51 @@
</child>
</object>
<object class="GtkPopover" id="time_popover">
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<child>
<object class="GtkSpinButton" id="spin_button_hour">
<property name="orientation">vertical</property>
<property name="adjustment">h_adjustment</property>
<property name="numeric">false</property>
<property name="wrap">true</property>
<signal name="output" handler="time_spin_button_text"/>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="margin_start">5</property>
<property name="margin_end">5</property>
<property name="label"></property>
</object>
</child>
<child>
<object class="GtkSpinButton" id="spin_button_minute">
<property name="orientation">vertical</property>
<property name="adjustment">m_adjustment</property>
<property name="numeric">false</property>
<property name="wrap">true</property>
<signal name="output" handler="time_spin_button_text"/>
</object>
</child>
</object>
</child>
<child>
<object class="GtkLabel" id="label_time_zone">
<property name="margin_top">7</property>
<property name="margin_bottom">3</property>
<property name="label">UTC: </property>
</object>
</child>
</object>
</child>
</object>
<template class="TimePicker" parent="GtkBox">
<property name="hexpand">True</property>
<property name="halign">fill</property>
@ -27,47 +72,21 @@
<property name="orientation">horizontal</property>
<property name="hexpand">true</property>
<property name="halign">center</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<child>
<object class="GtkMenuButton" id="calendar_button">
<property name="label">01.01.2022</property>
<property name="popover">calendar_popover</property>
<property name="margin-end">25</property>
<property name="vexpand">false</property>
<property name="valign">center</property>
<signal name="realize" handler="day_selected"/>
</object>
</child>
<child>
<object class="GtkSpinButton" id="spin_button_hour">
<property name="orientation">vertical</property>
<property name="adjustment">h_adjustment</property>
<property name="numeric">false</property>
<property name="wrap">true</property>
<signal name="output" handler="time_spin_button_text"/>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="margin_start">5</property>
<property name="margin_end">5</property>
<property name="label"></property>
</object>
</child>
<child>
<object class="GtkSpinButton" id="spin_button_minute">
<property name="orientation">vertical</property>
<property name="adjustment">m_adjustment</property>
<property name="numeric">false</property>
<property name="wrap">true</property>
<signal name="output" handler="time_spin_button_text"/>
</object>
</child>
<child>
<object class="GtkLabel" id="label_time_zone">
<property name="margin_start">20</property>
<property name="label">UTC: </property>
<object class="GtkMenuButton" id="time_button">
<property name="label">12:00</property>
<property name="popover">time_popover</property>
<property name="vexpand">false</property>
<property name="valign">center</property>
</object>
</child>

Wyświetl plik

@ -134,11 +134,10 @@ picplanner_milky_way_set_disturbance (PicplannerMilkyway *milky_way,
double *coordinates_array_moon,
double *coordinates_array_milky_way)
{
char *char_label_disturbance_sun;
char *char_label_disturbance_moon;
char *char_label_no_disturbance;
char *char_label_possibly_no_disturbance;
g_autofree char *char_label_disturbance_sun = NULL;
g_autofree char *char_label_disturbance_moon = NULL;
g_autofree char *char_label_no_disturbance = NULL;
g_autofree char *char_label_possibly_no_disturbance = NULL;
char_label_disturbance_sun = picplanner_get_char_disturbance (date_time_noon,
-18, 360, -360,
@ -171,11 +170,6 @@ picplanner_milky_way_set_disturbance (PicplannerMilkyway *milky_way,
coordinates_array_milky_way);
gtk_label_set_text (GTK_LABEL (milky_way->label_possible_disturbance_sun), char_label_possibly_no_disturbance);
g_free (char_label_disturbance_sun);
g_free (char_label_disturbance_moon);
g_free (char_label_no_disturbance);
g_free (char_label_possibly_no_disturbance);
}
@ -204,7 +198,7 @@ picplanner_milkyway_class_init (PicplannerMilkywayClass *class)
}
PicplannerMilkyway *
picplanner_milkyway_new ()
picplanner_milkyway_new (void)
{
return g_object_new (PICPLANNER_MILKYWAY_TYPE, NULL);
}

Wyświetl plik

@ -43,6 +43,6 @@ picplanner_milky_way_set_disturbance (PicplannerMilkyway *milky_way,
double *coordinates_array_milky_way);
PicplannerMilkyway *picplanner_milkyway_new ();
PicplannerMilkyway *picplanner_milkyway_new (void);
G_END_DECLS

Wyświetl plik

@ -139,13 +139,12 @@ picplanner_moon_set_illumination_intensity (PicplannerMoon *moon,
double illumination,
char *phase)
{
char *char_label_illumination;
g_autofree char *char_label_illumination = NULL;
char_label_illumination = g_strdup_printf ("%d%%", (int)round(illumination));
gtk_label_set_text (GTK_LABEL (moon->label_illumination), char_label_illumination);
gtk_label_set_text (GTK_LABEL (moon->label_phase), phase);
g_free (char_label_illumination);
}
@ -172,7 +171,7 @@ picplanner_moon_class_init (PicplannerMoonClass *class)
}
PicplannerMoon *
picplanner_moon_new ()
picplanner_moon_new (void)
{
return g_object_new (PICPLANNER_MOON_TYPE, NULL);
}

Wyświetl plik

@ -40,6 +40,6 @@ picplanner_moon_set_illumination_intensity (PicplannerMoon *moon,
char *phase);
PicplannerMoon *picplanner_moon_new ();
PicplannerMoon *picplanner_moon_new (void);
G_END_DECLS

Wyświetl plik

@ -39,6 +39,10 @@ struct _PicplannerOverview
GtkWidget *switch_moon;
GtkWidget *switch_milky_way;
GtkWidget *switch_to_sun_stack;
GtkWidget *switch_to_moon_stack;
GtkWidget *switch_to_milky_way_stack;
GtkWidget *label_sun_rise;
GtkWidget *label_sun_set;
GtkWidget *label_moon_rise;
@ -82,6 +86,42 @@ struct _PicplannerOverview
G_DEFINE_TYPE (PicplannerOverview, picplanner_overview, GTK_TYPE_BOX)
/*
* Catch all signals from the buttons and emit a signal which can be used by
* picplanner-window to change the stack page.
*/
static guint signal_button_pressed;
static void
change_stack_page (GtkButton *self,
gpointer user_data)
{
int stack_page = 0;
PicplannerOverview *overview = user_data;
if (self == GTK_BUTTON(overview->switch_to_sun_stack))
{
g_print("Button Sun\n");
stack_page = 1;
}
else if (self == GTK_BUTTON(overview->switch_to_moon_stack))
{
g_print("Button Moon\n");
stack_page = 2;
}
else if (self == GTK_BUTTON(overview->switch_to_milky_way_stack))
{
g_print("Button Milky Way\n");
stack_page = 3;
}
g_signal_emit (overview,
signal_button_pressed,
0, stack_page);
}
static gboolean
input_rebounce_reset_signal (gpointer user_data)
{
@ -109,6 +149,9 @@ input_timeout_signal (gpointer user_data)
g_settings_set_double (overview->settings,
"latitude" ,
shumate_location_get_latitude (SHUMATE_LOCATION(overview->viewport)));
g_settings_set_double (overview->settings,
"zoom-level",
shumate_viewport_get_zoom_level (overview->viewport));
g_source_remove (overview->input_timeout_id);
}
overview->input_count = 0;
@ -120,10 +163,10 @@ input_changed (GtkWidget *self,
gpointer user_data,
gpointer data_overview)
{
(void) user_data;
PicplannerOverview *overview;
overview = PICPLANNER_OVERVIEW (data_overview);
(void) user_data;
if (!overview->input_currently)
{
if (!G_IS_SETTINGS(self) && !PICPLANNER_IS_OVERVIEW (self))
@ -135,14 +178,16 @@ input_changed (GtkWidget *self,
input_timeout_signal,
overview);
}
//picplanner_overview_remove_map_content (overview);
// TODO: Remove content asynchronous?
overview->input_count++;
picplanner_overview_remove_map_content (overview);
}
else
{
shumate_location_set_location (SHUMATE_LOCATION (overview->viewport),
g_settings_get_double (overview->settings, "latitude"),
g_settings_get_double (overview->settings, "longitude"));
shumate_viewport_set_zoom_level (overview->viewport, g_settings_get_double (overview->settings, "zoom-level"));
}
}
}
@ -159,14 +204,14 @@ picplanner_overview_set_current_coordinates_sun (PicplannerOverview *overview,
int current_index,
GDateTime *date_time)
{
char *char_elevation_sun;
char *char_azimuth_sun;
char *char_sun_rise;
char *char_sun_set;
g_autofree char *char_elevation_sun = NULL;
g_autofree char *char_azimuth_sun = NULL;
g_autofree char *char_sun_rise = NULL;
g_autofree char *char_sun_set = NULL;
GDateTime *date_time_noon;
GDateTime *date_time_rise;
GDateTime *date_time_set;
g_autoptr (GDateTime) date_time_noon = NULL;
g_autoptr (GDateTime) date_time_rise = NULL;
g_autoptr (GDateTime) date_time_set = NULL;
date_time_noon = g_date_time_new (g_date_time_get_timezone (date_time),
g_date_time_get_year (date_time),
@ -207,14 +252,6 @@ picplanner_overview_set_current_coordinates_sun (PicplannerOverview *overview,
gtk_label_set_text (GTK_LABEL (overview->label_sun_set), char_sun_set);
gtk_label_set_text (GTK_LABEL (overview->label_elevation_sun), char_elevation_sun);
gtk_label_set_text (GTK_LABEL (overview->label_azimuth_sun), char_azimuth_sun);
g_date_time_unref (date_time_rise);
g_date_time_unref (date_time_set);
g_free (char_sun_rise);
g_free (char_sun_set);
g_free (char_elevation_sun);
g_free (char_azimuth_sun);
}
@ -231,14 +268,14 @@ picplanner_overview_set_current_coordinates_moon (PicplannerOverview *overview,
int current_index,
GDateTime *date_time)
{
char *char_elevation_moon;
char *char_azimuth_moon;
char *char_moon_rise;
char *char_moon_set;
g_autofree char *char_elevation_moon = NULL;
g_autofree char *char_azimuth_moon = NULL;
g_autofree char *char_moon_rise = NULL;
g_autofree char *char_moon_set = NULL;
GDateTime *date_time_noon;
GDateTime *date_time_rise;
GDateTime *date_time_set;
g_autoptr (GDateTime) date_time_noon = NULL;
g_autoptr (GDateTime) date_time_rise = NULL;
g_autoptr (GDateTime) date_time_set = NULL;
date_time_noon = g_date_time_new (g_date_time_get_timezone (date_time),
g_date_time_get_year (date_time),
@ -278,15 +315,6 @@ picplanner_overview_set_current_coordinates_moon (PicplannerOverview *overview,
gtk_label_set_text (GTK_LABEL (overview->label_moon_set), char_moon_set);
gtk_label_set_text (GTK_LABEL (overview->label_elevation_moon), char_elevation_moon);
gtk_label_set_text (GTK_LABEL (overview->label_azimuth_moon), char_azimuth_moon);
g_date_time_unref (date_time_rise);
g_date_time_unref (date_time_set);
g_free (char_moon_rise);
g_free (char_moon_set);
g_free (char_elevation_moon);
g_free (char_azimuth_moon);
}
@ -303,14 +331,14 @@ picplanner_overview_set_current_coordinates_milky_way (PicplannerOverview *overv
int current_index,
GDateTime *date_time)
{
char *char_elevation_milky_way;
char *char_azimuth_milky_way;
char *char_milky_way_rise;
char *char_milky_way_set;
g_autofree char *char_elevation_milky_way = NULL;
g_autofree char *char_azimuth_milky_way = NULL;
g_autofree char *char_milky_way_rise = NULL;
g_autofree char *char_milky_way_set = NULL;
GDateTime *date_time_noon;
GDateTime *date_time_rise;
GDateTime *date_time_set;
g_autoptr (GDateTime) date_time_noon = NULL;
g_autoptr (GDateTime) date_time_rise = NULL;
g_autoptr (GDateTime) date_time_set = NULL;
date_time_noon = g_date_time_new (g_date_time_get_timezone (date_time),
g_date_time_get_year (date_time),
@ -350,14 +378,6 @@ picplanner_overview_set_current_coordinates_milky_way (PicplannerOverview *overv
gtk_label_set_text (GTK_LABEL (overview->label_milky_way_set), char_milky_way_set);
gtk_label_set_text (GTK_LABEL (overview->label_elevation_milky_way), char_elevation_milky_way);
gtk_label_set_text (GTK_LABEL (overview->label_azimuth_milky_way), char_azimuth_milky_way);
g_date_time_unref (date_time_rise);
g_date_time_unref (date_time_set);
g_free (char_milky_way_rise);
g_free (char_milky_way_set);
g_free (char_elevation_milky_way);
g_free (char_azimuth_milky_way);
}
@ -604,13 +624,14 @@ shumate_map_metric_imperial_scale (GSettings *settings,
gchar *key,
gpointer user_data)
{
(void) settings;
(void) key;
PicplannerOverview *overview = user_data;
ShumateScale *scale;
gboolean metric;
gboolean imperial;
(void) settings;
(void) key;
scale = shumate_simple_map_get_scale (overview->map);
metric = g_settings_get_boolean (settings, "map-unit-metric");
imperial = g_settings_get_boolean (settings, "map-unit-imperial");
@ -706,14 +727,10 @@ picplanner_overview_init (PicplannerOverview *overview)
"changed::latitude",
G_CALLBACK (input_changed),
overview);
g_settings_bind (overview->settings, "map-fullscreen",
overview->basic_information, "visible",
G_SETTINGS_BIND_INVERT_BOOLEAN);
g_settings_bind (overview->settings, "zoom-level",
overview->viewport, "zoom-level",
G_SETTINGS_BIND_DEFAULT);
g_signal_connect (G_OBJECT (overview->viewport),
"notify::zoom-level",
G_CALLBACK (input_changed),
overview);
g_settings_bind (overview->settings, "sun-visible",
overview->switch_sun, "active",
@ -745,6 +762,23 @@ picplanner_overview_init (PicplannerOverview *overview)
G_CALLBACK (shumate_map_metric_imperial_scale),
overview);
/*
* Register the button presses to switch the few
*/
g_signal_connect (G_OBJECT (overview->switch_to_sun_stack),
"clicked",
G_CALLBACK (change_stack_page),
overview);
g_signal_connect (G_OBJECT (overview->switch_to_moon_stack),
"clicked",
G_CALLBACK (change_stack_page),
overview);
g_signal_connect (G_OBJECT (overview->switch_to_milky_way_stack),
"clicked",
G_CALLBACK (change_stack_page),
overview);
/*
* Initialisation of values needed to detect when a user input ends
@ -769,6 +803,9 @@ picplanner_overview_class_init (PicplannerOverviewClass *class)
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerOverview, switch_sun);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerOverview, switch_moon);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerOverview, switch_milky_way);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerOverview, switch_to_sun_stack);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerOverview, switch_to_moon_stack);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerOverview, switch_to_milky_way_stack);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerOverview, label_sun_rise);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerOverview, label_sun_set);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerOverview, label_moon_rise);
@ -782,10 +819,17 @@ picplanner_overview_class_init (PicplannerOverviewClass *class)
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerOverview, label_azimuth_moon);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerOverview, label_azimuth_milky_way);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerOverview, basic_information);
signal_button_pressed = g_signal_new ("change-stack",
G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL,
G_TYPE_NONE,
1, G_TYPE_INT);
}
PicplannerOverview *
picplanner_overview_new ()
picplanner_overview_new (void)
{
return g_object_new (PICPLANNER_OVERVIEW_TYPE, NULL);
}

Wyświetl plik

@ -27,7 +27,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (PicplannerOverview, picplanner_overview, PICPLANNER, OVERVIEW, GtkBox)
PicplannerOverview
*picplanner_overview_new ();
*picplanner_overview_new (void);
void
picplanner_overview_map_fullscreen (PicplannerOverview *overview,

Wyświetl plik

@ -1,5 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkSwitch" id="sun_switch_button">
<property name="vexpand">false</property>
<property name="hexpand">false</property>
<property name="halign">center</property>
<property name="valign">center</property>
</object>
<object class="GtkSwitch" id="moon_switch_button">
<property name="vexpand">false</property>
<property name="hexpand">false</property>
<property name="halign">center</property>
<property name="valign">center</property>
</object>
<object class="GtkSwitch" id="milky_way_switch_button">
<property name="vexpand">false</property>
<property name="hexpand">false</property>
<property name="halign">center</property>
<property name="valign">center</property>
</object>
<template class="PicplannerOverview" parent="GtkBox">
<child>
@ -18,235 +38,252 @@
<property name="margin-end">12</property>
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwPreferencesRow">
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="AdwPreferencesGroup">
<property name="visible">true</property>
<child>
<object class="GtkGrid">
<property name="hexpand">true</property>
<property name="halign">center</property>
<property name="column-spacing">12</property>
<property name="row-spacing">10</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<object class="AdwPreferencesRow">
<property name="activatable">false</property>
<child>
<object class="GtkCheckButton" id="switch_sun">
<property name="active">true</property>
<layout>
<property name="column">0</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="switch_moon">
<property name="active">true</property>
<layout>
<property name="column">0</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="switch_milky_way">
<property name="active">true</property>
<layout>
<property name="column">0</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Sun</property>
<property name="halign">start</property>
<layout>
<property name="column">1</property>
<property name="row">1</property>
</layout>
<attributes>
<attribute name="weight" value="ultrabold"/>
</attributes>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Moon</property>
<property name="halign">start</property>
<layout>
<property name="column">1</property>
<property name="row">2</property>
</layout>
<attributes>
<attribute name="weight" value="ultrabold"/>
</attributes>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Milky Way</property>
<property name="halign">start</property>
<layout>
<property name="column">1</property>
<property name="row">3</property>
</layout>
<attributes>
<attribute name="weight" value="ultrabold"/>
</attributes>
</object>
</child>
<child>
<object class="GtkImage">
<property name="icon-name">daytime-sunrise-symbolic</property>
<property name="pixel-size">24</property>
<layout>
<property name="column">2</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkImage">
<property name="icon-name">daytime-sunset-symbolic</property>
<property name="pixel-size">24</property>
<layout>
<property name="column">3</property>
<property name="row">0</property>
</layout>
</object>
</child>
<object class="GtkGrid">
<property name="column-homogeneous">false</property>
<property name="hexpand">true</property>
<property name="halign">fill</property>
<property name="column-spacing">10</property>
<property name="row-spacing">10</property>
<property name="margin-start">8</property>
<property name="margin-end">8</property>
<property name="margin-top">8</property>
<property name="margin-bottom">8</property>
<child>
<object class="GtkCheckButton" id="switch_sun">
<property name="active">true</property>
<property name="tooltip-text">Show sun</property>
<layout>
<property name="column">0</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="switch_moon">
<property name="active">true</property>
<property name="tooltip-text">Show moon</property>
<layout>
<property name="column">0</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkCheckButton" id="switch_milky_way">
<property name="active">true</property>
<property name="tooltip-text">Show milky way</property>
<layout>
<property name="column">0</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkButton" id="switch_to_sun_stack">
<property name="label" translatable="yes">Sun</property>
<property name="halign">fill</property>
<property name="hexpand">true</property>
<layout>
<property name="column">1</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkButton" id="switch_to_moon_stack">
<property name="label" translatable="yes">Moon</property>
<property name="halign">fill</property>
<property name="hexpand">true</property>
<layout>
<property name="column">1</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkButton" id="switch_to_milky_way_stack">
<property name="label" translatable="yes">Milky Way</property>
<property name="halign">fill</property>
<property name="hexpand">true</property>
<layout>
<property name="column">1</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkImage">
<property name="icon-name">daytime-sunrise-symbolic</property>
<property name="pixel-size">24</property>
<property name="hexpand">true</property>
<property name="tooltip-text">Rise</property>
<layout>
<property name="column">2</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkImage">
<property name="icon-name">daytime-sunset-symbolic</property>
<property name="pixel-size">24</property>
<property name="hexpand">true</property>
<property name="tooltip-text">Set</property>
<layout>
<property name="column">3</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_sun_rise">
<property name="label">12:00</property>
<layout>
<property name="column">2</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_sun_set">
<property name="label">12:00</property>
<layout>
<property name="column">3</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_moon_rise">
<property name="label">12:00</property>
<layout>
<property name="column">2</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_moon_set">
<property name="label">12:00</property>
<layout>
<property name="column">3</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_milky_way_rise">
<property name="label">12:00</property>
<layout>
<property name="column">2</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_milky_way_set">
<property name="label">12:00</property>
<layout>
<property name="column">3</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkImage">
<property name="icon-name">elevation-symbolic</property>
<property name="icon-size">GTK_ICON_SIZE_LARGE</property>
<layout>
<property name="column">4</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkImage">
<property name="icon-name">azimuth-symbolic</property>
<property name="icon-size">GTK_ICON_SIZE_LARGE</property>
<layout>
<property name="column">5</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_elevation_sun">
<property name="label">0°</property>
<layout>
<property name="column">4</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_elevation_moon">
<property name="label">0°</property>
<layout>
<property name="column">4</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_elevation_milky_way">
<property name="label">0°</property>
<layout>
<property name="column">4</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_azimuth_sun">
<property name="label">0°</property>
<layout>
<property name="column">5</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_azimuth_moon">
<property name="label">0°</property>
<layout>
<property name="column">5</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_azimuth_milky_way">
<property name="label">0°</property>
<layout>
<property name="column">5</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_sun_rise">
<property name="label">12:00</property>
<layout>
<property name="column">2</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_sun_set">
<property name="label">12:00</property>
<layout>
<property name="column">3</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_moon_rise">
<property name="label">12:00</property>
<layout>
<property name="column">2</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_moon_set">
<property name="label">12:00</property>
<layout>
<property name="column">3</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_milky_way_rise">
<property name="label">12:00</property>
<layout>
<property name="column">2</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_milky_way_set">
<property name="label">12:00</property>
<layout>
<property name="column">3</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkImage">
<property name="icon-name">elevation-symbolic</property>
<property name="icon-size">GTK_ICON_SIZE_LARGE</property>
<property name="hexpand">true</property>
<property name="tooltip-text">Elevation</property>
<layout>
<property name="column">4</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkImage">
<property name="icon-name">azimuth-symbolic</property>
<property name="icon-size">GTK_ICON_SIZE_LARGE</property>
<property name="hexpand">true</property>
<property name="tooltip-text">Azimuth</property>
<layout>
<property name="column">5</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_elevation_sun">
<property name="label">0°</property>
<layout>
<property name="column">4</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_elevation_moon">
<property name="label">0°</property>
<layout>
<property name="column">4</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_elevation_milky_way">
<property name="label">0°</property>
<layout>
<property name="column">4</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_azimuth_sun">
<property name="label">0°</property>
<layout>
<property name="column">5</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_azimuth_moon">
<property name="label">0°</property>
<layout>
<property name="column">5</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label_azimuth_milky_way">
<property name="label">0°</property>
<layout>
<property name="column">5</property>
<property name="row">3</property>
</layout>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
@ -258,9 +295,13 @@
<child>
<object class="AdwBin">
<property name="hexpand">true</property>
<property name="halign">fill</property>
<child>
<object class="ShumateSimpleMap" id="map">
<property name="width-request">300</property>
<property name="hexpand">true</property>
<property name="halign">fill</property>
</object>
</child>
</object>

Wyświetl plik

@ -0,0 +1,710 @@
/*
* picplanner-window.c
* Copyright (C) 2021 Zwarf <zwarf@mail.de>
*
* This program 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.
*
* This program 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 program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "window/picplanner-window.h"
#include "window/overview-page/overview-view.h"
#include "window/sun-page/sun-view.h"
#include "window/moon-page/moon-view.h"
#include "window/milky-way-page/milky-way-view.h"
#include "calculations/calculations_sun.h"
#include "calculations/calculations_moon.h"
#include "calculations/calculations_milky_way.h"
#include "time-picker/time-picker.h"
/*
* The time of no input of map movement that has to pass until a calculation of the positions
* of sun, moon or milky way starts.
*/
#define INPUT_CHANGED_TIMEOUT_LENGTH 50
struct _PicplannerWindow
{
GtkApplicationWindow parent_instance;
/* Template widgets */
GtkHeaderBar *header_bar;
GtkWidget *box_main;
GtkWidget *stack; /* Stack containing overview, sun, moon and milky way page */
GtkWidget *search_bar; /* Search bar for the location */
GtkWidget *search_entry; /* The search entry inside the search bar */
GtkWidget *search_button; /* The search button in the header bar so show the search bar */
GtkWidget *map_button; /* The map button in the header bar to show the map fullscreen */
GtkWidget *location_button; /* Button in the header bar to start the GPS search of the device location */
GtkWidget *overview_box; /* The overview page */
GtkWidget *sun_box; /* The sun page */
GtkWidget *moon_box; /* The moon page */
GtkWidget *milky_way_box; /* The milky way page */
GtkWidget *north_entry; /* SpinButton for North coordinates */
GtkWidget *east_entry; /* SpinButton for East coordinates */
GtkWidget *clamp_time_selector;
GtkWidget *overview_page;
GtkWidget *time_picker;
/* Search functionality */
GtkWidget *search_result_box; /* ListBox containing search results */
GtkWidget *search_results_scroll; /* ScrollView containing search_result_box */
GtkWidget *search_result_row[NUM_SEARCH_RESULTS]; /* Row widget for every search result */
GtkWidget *search_result_label[NUM_SEARCH_RESULTS]; /* The label showing the coordinates */
GWeatherLocation *search_result_location[NUM_SEARCH_RESULTS]; /* The location information for every search result */
/* Regulating amount of inputs per time */
gint input_count;
guint input_timeout_id;
gboolean input_new;
/* All settings of PicPlanner */
GSettings *settings;
GDateTime *date_time;
};
G_DEFINE_TYPE (PicplannerWindow, picplanner_window, ADW_TYPE_APPLICATION_WINDOW)
/*
* Function used after the user selects a search result
*/
static void
search_location_chosen (GtkWidget *self,
GtkWidget *row,
gpointer user_data)
{
(void) self;
PicplannerWindow *window = user_data;
double latitude;
double longitude;
double *p_latitude = &latitude;
double *p_longitude = &longitude;
int i;
for (i=0; i<NUM_SEARCH_RESULTS; i++)
{
if (row == window->search_result_row[i])
break;
}
gweather_location_get_coords (GWEATHER_LOCATION (window->search_result_location[i]),
p_latitude,
p_longitude);
gtk_search_bar_set_search_mode (GTK_SEARCH_BAR (window->search_bar),
FALSE);
g_settings_set_double (window->settings, "latitude", latitude);
g_settings_set_double (window->settings, "longitude", longitude);
}
/*
* Function activated after user input into the search entry.
* TODO: Rewrite with dynamic memory? to search.c
* This function is more like a work around and will definitely be changed.
*/
static void
search_location (GtkWidget *self,
gpointer user_data)
{
(void) self;
PicplannerWindow *window = user_data;
const char *search_text = gtk_editable_get_text (GTK_EDITABLE (window->search_entry));
char *search_norm = g_utf8_normalize (search_text, strlen (search_text), G_NORMALIZE_ALL_COMPOSE);
char *search_string = g_utf8_casefold (search_text, strlen (search_norm));
g_autoptr (GWeatherLocation) world = NULL;
world = gweather_location_get_world ();
for (int i=0; i<NUM_SEARCH_RESULTS; i++)
{
if (GWEATHER_IS_LOCATION (window->search_result_location[i]))
g_object_unref (window->search_result_location[i]);
window->search_result_location[i] = NULL;
}
if (!strstr ("", search_string))
{
int iter = 0;
int *iteration = &iter;
double longitude;
double latitude;
double *p_longitude = &longitude;
double *p_latitude = &latitude;
char *char_coordinates;
char *char_subtitle;
gtk_widget_set_visible (window->stack, FALSE);
gtk_widget_set_visible (window->clamp_time_selector, FALSE);
gtk_widget_set_visible (window->search_results_scroll, TRUE);
find_loc_children (world, search_string, window->search_result_location, iteration);
for (int i=0; i<NUM_SEARCH_RESULTS; i++)
{
if (GTK_IS_WIDGET (window->search_result_row[i]))
{
gtk_list_box_remove (GTK_LIST_BOX (window->search_result_box),
window->search_result_row[i]);
}
window->search_result_row[i] = NULL;
if (window->search_result_location[i])
{
window->search_result_row[i] = adw_action_row_new ();
gweather_location_get_coords (window->search_result_location[i],
p_latitude, p_longitude);
char_coordinates = g_strdup_printf ("N: %.04f\nE: %.04f", latitude, longitude);
adw_preferences_row_set_title (ADW_PREFERENCES_ROW (window->search_result_row[i]),
gweather_location_get_name (window->search_result_location[i]));
if (gweather_location_get_level (
gweather_location_get_parent (window->search_result_location[i])) == GWEATHER_LOCATION_COUNTRY ||
gweather_location_get_level (window->search_result_location[i]) == GWEATHER_LOCATION_COUNTRY)
char_subtitle = g_strdup_printf ("%s",
gweather_location_get_country_name (window->search_result_location[i]));
else
char_subtitle = g_strdup_printf ("%s, %s",
gweather_location_get_name (gweather_location_get_parent (window->search_result_location[i])),
gweather_location_get_country_name (window->search_result_location[i]));
adw_action_row_set_subtitle (ADW_ACTION_ROW (window->search_result_row[i]),
char_subtitle);
window->search_result_label[i] = gtk_label_new (char_coordinates);
adw_action_row_add_suffix (ADW_ACTION_ROW (window->search_result_row[i]),
window->search_result_label[i]);
gtk_widget_set_can_focus (window->search_result_row[i], TRUE);
gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (window->search_result_row[i]), TRUE);
gtk_list_box_row_set_selectable (GTK_LIST_BOX_ROW (window->search_result_row[i]), TRUE);
gtk_list_box_append (GTK_LIST_BOX (window->search_result_box),
window->search_result_row[i]);
g_free (char_coordinates);
}
}
}
else
{
gtk_widget_set_visible (window->stack, TRUE);
gtk_widget_set_visible (window->clamp_time_selector, TRUE);
gtk_widget_set_visible (window->search_results_scroll, FALSE);
}
g_free (search_norm);
g_free (search_string);
}
/*
* Hide the map fullscreen button if the active view is not "page1" (overview)
*/
static void
stack_changed (AdwViewStack *self,
gpointer pspec,
PicplannerWindow *window)
{
(void) pspec;
if (!strcmp(adw_view_stack_get_visible_child_name (self),"page1"))
gtk_widget_set_visible (window->map_button, TRUE);
else
gtk_widget_set_visible (window->map_button, FALSE);
}
void
picplanner_set_location (double latitude, double longitude, PicplannerWindow *window)
{
gtk_spin_button_set_value (GTK_SPIN_BUTTON (window->north_entry), latitude);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (window->east_entry), longitude);
}
/*
* Changing the date_time variable after a user input was recognized.
* Afterwards, emit a signal to start the calculations.
*/
void
picplanner_update_date_time (PicplannerWindow *window)
{
int year, month, day, hour, minute;
double latitude, longitude;
GWeatherLocation *loc;
longitude = gtk_spin_button_get_value (GTK_SPIN_BUTTON (window->east_entry));
latitude = gtk_spin_button_get_value (GTK_SPIN_BUTTON (window->north_entry));
loc = gweather_location_new_detached ("Custom Location", NULL, latitude, longitude);
year = time_picker_get_year (TIME_PICKER (window->time_picker));
month = time_picker_get_month (TIME_PICKER (window->time_picker));
day = time_picker_get_day (TIME_PICKER (window->time_picker));
hour = time_picker_get_hour (TIME_PICKER (window->time_picker));
minute = time_picker_get_minute (TIME_PICKER (window->time_picker));
/*
* Save the information into the date_time variable.
* The time zone is either selected automatically or taken from the input spin button in the preference dialog.
*/
if (!g_settings_get_boolean (window->settings, "time-zone-manual"))
{
window->date_time = g_date_time_new (gweather_location_get_timezone (loc),
year, month, day,
hour, minute,
0);
g_settings_set_double (window->settings,
"time-zone",
(double) g_date_time_get_utc_offset (window->date_time)/3600/1000/1000);
}
else
{
window->date_time = g_date_time_new (g_time_zone_new_offset ((int) (g_settings_get_double (window->settings, "time-zone")*3600)),
year, month, day,
hour, minute,
0);
}
double time_zone = (double) g_date_time_get_utc_offset (window->date_time)/3600/1000/1000;
time_picker_set_time_zone (TIME_PICKER (window->time_picker),
time_zone);
}
/*
* Starts the main calculations.
* 1. The necessary information is collected from the inputs.
* 2. The position sun, moon and milky way are calculated.
* 3. The calculated data is handed over to the views which then provide the information to the users.
*/
static void
calculate_positions (PicplannerWindow *window)
{
int current_index;
int phase_moon_index;
double longitude, latitude;
double illumination_moon, illumination_moon_later;
int *rise_upper_set_lower_index_sun;
int *rise_upper_set_index_moon;
int *rise_upper_set_index_milky_way;
int *dark_blue_golden_index;
double *array_coordinates_sun;
double *array_coordinates_moon;
double *array_coordinates_milky_way;
char *phase_moon;
GDateTime *date_time_noon;
GDateTime *date_time_later;
longitude = gtk_spin_button_get_value (GTK_SPIN_BUTTON (window->east_entry));
latitude = gtk_spin_button_get_value (GTK_SPIN_BUTTON (window->north_entry));
picplanner_update_date_time (window);
date_time_noon = g_date_time_new (g_date_time_get_timezone (window->date_time),
g_date_time_get_year (window->date_time),
g_date_time_get_month (window->date_time),
g_date_time_get_day_of_month (window->date_time),
12, 0, 0);
current_index = g_date_time_difference (window->date_time, date_time_noon)/1000/1000/60 * NUM_DATA_POINTS/24/60 + NUM_DATA_POINTS/2;
/*
* Sun
*/
array_coordinates_sun = picplanner_get_array_coordinates_sun (date_time_noon,
longitude,
latitude);
rise_upper_set_lower_index_sun = picplanner_get_index_rise_upper_set_lower (array_coordinates_sun);
dark_blue_golden_index = picplanner_get_index_dark_blue_golden (array_coordinates_sun);
picplanner_overview_set_current_coordinates_sun (PICPLANNER_OVERVIEW (window->overview_box),
array_coordinates_sun,
rise_upper_set_lower_index_sun,
current_index,
window->date_time);
picplanner_sun_set_rise_upper_set (PICPLANNER_SUN (window->sun_box),
date_time_noon,
array_coordinates_sun,
rise_upper_set_lower_index_sun);
picplanner_sun_set_dark_blue_golden (PICPLANNER_SUN (window->sun_box),
date_time_noon,
dark_blue_golden_index);
/*
* Moon
*/
array_coordinates_moon = picplanner_get_array_coordinates_moon (date_time_noon,
longitude,
latitude);
rise_upper_set_index_moon = picplanner_get_index_rise_upper_set_lower (array_coordinates_moon);
picplanner_overview_set_current_coordinates_moon (PICPLANNER_OVERVIEW (window->overview_box),
array_coordinates_moon,
rise_upper_set_index_moon,
current_index,
window->date_time);
picplanner_moon_set_rise_upper_set (PICPLANNER_MOON (window->moon_box),
date_time_noon,
array_coordinates_moon,
rise_upper_set_index_moon);
date_time_later = g_date_time_add_hours (window->date_time, 1);
illumination_moon = picplanner_get_illumination (window->date_time);
illumination_moon_later = picplanner_get_illumination (date_time_later);
if (illumination_moon > 99.5)
{
phase_moon_index = 0;
phase_moon = g_strdup_printf ("Full Moon");
}
else if (illumination_moon_later >= illumination_moon && illumination_moon > 0.5)
{
phase_moon_index = 1;
phase_moon = g_strdup_printf ("Waxing Moon");
}
else if (illumination_moon_later < illumination_moon && illumination_moon > 0.5)
{
phase_moon_index = 2;
phase_moon = g_strdup_printf ("Waning Moon");
}
else
{
phase_moon_index = 3;
phase_moon = g_strdup_printf ("New Moon");
}
picplanner_moon_set_illumination_intensity (PICPLANNER_MOON (window->moon_box),
illumination_moon,
phase_moon);
/*
* Milky Way
*/
array_coordinates_milky_way = picplanner_get_array_coordinates_milky_way (date_time_noon,
longitude,
latitude);
rise_upper_set_index_milky_way = picplanner_get_index_rise_upper_set_lower (array_coordinates_milky_way);
picplanner_overview_set_current_coordinates_milky_way (PICPLANNER_OVERVIEW (window->overview_box),
array_coordinates_milky_way,
rise_upper_set_index_milky_way,
current_index,
window->date_time);
picplanner_milky_way_set_rise_upper_set (PICPLANNER_MILKYWAY (window->milky_way_box),
date_time_noon,
array_coordinates_milky_way,
rise_upper_set_index_milky_way);
picplanner_milky_way_set_disturbance (PICPLANNER_MILKYWAY (window->milky_way_box),
date_time_noon,
array_coordinates_sun,
array_coordinates_moon,
array_coordinates_milky_way);
/*
* Update Shumate Map
*/
picplanner_overview_update_map_center (PICPLANNER_OVERVIEW (window->overview_box));
if (g_settings_get_boolean (window->settings, "sun-visible"))
{
picplanner_overview_update_map_sun (PICPLANNER_OVERVIEW (window->overview_box),
array_coordinates_sun,
current_index,
rise_upper_set_lower_index_sun);
}
if (g_settings_get_boolean (window->settings, "moon-visible"))
{
picplanner_overview_update_map_moon (PICPLANNER_OVERVIEW (window->overview_box),
array_coordinates_moon,
current_index,
rise_upper_set_index_moon,
phase_moon_index);
}
if (g_settings_get_boolean (window->settings, "milky-way-visible"))
{
picplanner_overview_update_map_milky_way (PICPLANNER_OVERVIEW (window->overview_box),
array_coordinates_milky_way,
current_index,
rise_upper_set_index_milky_way);
}
/*
* Free allocated memory
*/
g_free (rise_upper_set_lower_index_sun);
g_free (rise_upper_set_index_moon);
g_free (rise_upper_set_index_milky_way);
g_free (dark_blue_golden_index);
g_free (array_coordinates_sun);
g_free (array_coordinates_moon);
g_free (array_coordinates_milky_way);
g_free (phase_moon);
g_date_time_unref (date_time_noon);
/*
* TODO:
* Free loc?
*/
}
/* input_timeout_signal:
* If the timer has been running out it is checked if the counter was increased during the time
* or not. If it has been increased it is reseted to 0 and the timer continues.
* If no input was detected in the meantime (input_counter==0) a new detection series is
* initialized by setting input_new = TRUE. Furthermore the userinput is saved with
* change_date_time and the timer is deactivated.
*/
static gboolean
input_timeout_signal (gpointer user_data)
{
PicplannerWindow *window = PICPLANNER_WINDOW (user_data);
if (window->input_count == 0)
{
window->input_new = TRUE;
calculate_positions (window);
g_source_remove (window->input_timeout_id);
}
window->input_count = 0;
return TRUE;
}
/*
* input_changed:
* Function to call if the user changes the location or date/time.
* At the beginning input_new is TRUE because a new input starts.
* The input_new variable is set to FALSE if a user input is detected, and a timer is started.
* The input_count is increased from now on by one, every time a user input is detected.
*/
static void
input_changed (GtkWidget *self,
gpointer data_map_move,
gpointer data_window_change)
{
(void) self;
PicplannerWindow *window;
if (PICPLANNER_IS_WINDOW (data_window_change))
window = PICPLANNER_WINDOW (data_window_change);
else
window = PICPLANNER_WINDOW (data_map_move);
if (window->input_new)
{
window->input_new = FALSE;
window->input_timeout_id = g_timeout_add (INPUT_CHANGED_TIMEOUT_LENGTH,
input_timeout_signal,
window);
}
picplanner_overview_update_map_center (PICPLANNER_OVERVIEW (window->overview_box));
window->input_count++;
}
/*
* Remove all children on the map and cause a new input_changed event.
*/
static void
input_changed_remove_content (GtkWidget *self,
gpointer data_map_move,
gpointer data_window_change)
{
(void) self;
PicplannerWindow *window;
if (PICPLANNER_IS_WINDOW (data_window_change))
window = PICPLANNER_WINDOW (data_window_change);
else
window = PICPLANNER_WINDOW (data_map_move);
if (window->input_new)
picplanner_overview_remove_map_content (PICPLANNER_OVERVIEW (window->overview_box));
input_changed (self, data_map_move, window);
}
static void
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);
g_type_ensure (TIME_PICKER_TYPE);
gtk_widget_class_set_template_from_resource (widget_class, "/de/zwarf/picplanner/window/picplanner-window.ui");
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, box_main);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, stack);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, header_bar);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, search_bar);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, search_entry);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, search_button);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, map_button);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, location_button);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, overview_box);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, sun_box);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, moon_box);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, milky_way_box);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, north_entry);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, east_entry);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, search_result_box);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, search_results_scroll);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, clamp_time_selector);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, overview_page);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, time_picker);
gtk_widget_class_bind_template_callback (widget_class, search_location);
}
static void
picplanner_window_init (PicplannerWindow *window)
{
GTimeZone *timezone;
gtk_widget_init_template (GTK_WIDGET (window));
window->settings = g_settings_new ("de.zwarf.picplanner");
timezone = g_time_zone_new_offset (g_settings_get_double (window->settings, "time-zone") * 3600);
window->date_time = g_date_time_new_now (timezone);
time_picker_set_date_time (TIME_PICKER (window->time_picker),
window->date_time);
/*
* Callbacks
*/
g_settings_bind (window->settings, "longitude",
window->east_entry, "value",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (window->settings, "latitude",
window->north_entry, "value",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (window->settings, "map-fullscreen",
window->map_button, "active",
G_SETTINGS_BIND_DEFAULT);
g_object_bind_property (window->search_button, "active",
window->search_bar, "search-mode-enabled",
G_BINDING_BIDIRECTIONAL);
g_signal_connect (G_OBJECT (window->settings),
"changed::latitude",
G_CALLBACK (input_changed),
window);
g_signal_connect (G_OBJECT (window->settings),
"changed::longitude",
G_CALLBACK (input_changed),
window);
g_signal_connect (G_OBJECT (window->settings),
"changed::sun-visible",
G_CALLBACK (input_changed_remove_content),
window);
g_signal_connect (G_OBJECT (window->settings),
"changed::moon-visible",
G_CALLBACK (input_changed_remove_content),
window);
g_signal_connect (G_OBJECT (window->settings),
"changed::milky-way-visible",
G_CALLBACK (input_changed_remove_content),
window);
g_signal_connect (G_OBJECT (window->search_result_box),
"row-activated",
G_CALLBACK (search_location_chosen),
window);
g_signal_connect (G_OBJECT (window->stack),
"notify::visible-child",
G_CALLBACK (stack_changed),
window);
g_signal_connect (G_OBJECT (window->location_button),
"clicked",
G_CALLBACK (get_user_location),
window);
g_signal_connect (G_OBJECT (window->time_picker),
"date_time_changed",
G_CALLBACK (input_changed),
window);
/*
* Initialisation of values needed to detect when a user input ends
*/
window->input_new = true;
window->input_count = 0;
window->input_timeout_id = 0;
/*
* Setup the location searchbar to register keyboard input
*/
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (window->search_bar), GTK_EDITABLE (window->search_entry));
gtk_search_bar_set_key_capture_widget (GTK_SEARCH_BAR (window->search_bar), GTK_WIDGET (window));
/*
* Initial calculation after startup
*/
calculate_positions (window);
}

Wyświetl plik

@ -0,0 +1,294 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="PicplannerOverview" id="overview_box">
<property name="orientation">vertical</property>
</object>
<object class="PicplannerSun" id="sun_box">
<property name="orientation">vertical</property>
</object>
<object class="PicplannerMoon" id="moon_box">
<property name="orientation">vertical</property>
</object>
<object class="PicplannerMilkyway" id="milky_way_box">
<property name="orientation">vertical</property>
</object>
<object class="GtkAdjustment" id="north_adjustment">
<property name="upper">85.0511287798</property>
<property name="lower">-85.0511287798</property>
<property name="step_increment">0.01</property>
<property name="page_increment">1</property>
</object>
<object class="GtkAdjustment" id="east_adjustment">
<property name="upper">180</property>
<property name="lower">-180</property>
<property name="step_increment">0.01</property>
<property name="page_increment">1</property>
</object>
<template class="PicplannerWindow" parent="AdwApplicationWindow">
<property name="vexpand">true</property>
<property name="valign">fill</property>
<property name="content">
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="vexpand">true</property>
<property name="valign">fill</property>
<child>
<object class="AdwHeaderBar" id="header_bar">
<property name="centering_policy">strict</property>
<child type="title">
<object class="AdwViewSwitcherTitle" id="switcher_title">
<property name="hexpand">true</property>
<property name="halign">fill</property>
<property name="stack">stack</property>
<property name="title">PicPlanner</property>
</object>
</child>
<child type="start">
<object class="GtkToggleButton" id="search_button">
<property name="icon-name">edit-find-symbolic</property>
</object>
</child>
<child type="start">
<object class="GtkButton" id="location_button">
<property name="icon-name">find-location-symbolic</property>
</object>
</child>
<child type="start">
<object class="GtkToggleButton" id="map_button">
<property name="icon-name">map-symbolic</property>
</object>
</child>
<child type="end">
<object class="GtkMenuButton">
<property name="icon-name">open-menu-symbolic</property>
<property name="menu-model">primary_menu</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="box_main">
<property name="orientation">vertical</property>
<property name="vexpand">true</property>
<property name="valign">fill</property>
<child>
<object class="GtkSearchBar" id="search_bar">
<property name="visible">true</property>
<property name="can_focus">true</property>
<property name="search-mode-enabled">false</property>
<property name="show-close-button">true</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="hexpand">true</property>
<child>
<object class="GtkSearchEntry" id="search_entry">
<property name="margin-top">2</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="visible">true</property>
<property name="can-focus">true</property>
<property name="placeholder-text" translatable="yes">Search... City, Region, Country</property>
<signal name="search-changed" handler="search_location"/>
</object>
</child>
<child>
<object class="AdwClamp">
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwExpanderRow">
<property name="title" translatable="yes">Coordinates</property>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">North</property>
<child>
<object class="GtkSpinButton" id="north_entry">
<property name="halign">end</property>
<property name="adjustment">north_adjustment</property>
<property name="numeric">false</property>
<property name="wrap">true</property>
<property name="digits">4</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">East</property>
<child>
<object class="GtkSpinButton" id="east_entry">
<property name="halign">end</property>
<property name="adjustment">east_adjustment</property>
<property name="numeric">false</property>
<property name="wrap">true</property>
<property name="digits">4</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow" id="search_results_scroll">
<property name="visible">false</property>
<property name="hexpand">true</property>
<property name="halign">fill</property>
<property name="vexpand">true</property>
<property name="valign">fill</property>
<child>
<object class="AdwBin">
<property name="hexpand">true</property>
<property name="halign">fill</property>
<property name="vexpand">true</property>
<property name="valign">start</property>
<property name="margin-start">15</property>
<property name="margin-end">15</property>
<property name="margin-top">15</property>
<property name="margin-bottom">15</property>
<child>
<object class="GtkListBox" id="search_result_box">
<property name="hexpand">true</property>
<property name="halign">fill</property>
<property name="vexpand">true</property>
<property name="valign">fill</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwClamp" id="clamp_time_selector">
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwPreferencesRow">
<property name="title">Date and Time</property>
<property name="activatable">false</property>
<child>
<object class="TimePicker" id="time_picker">
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwViewStack" id="stack">
<property name="vexpand">true</property>
<property name="valign">fill</property>
<child>
<object class="AdwViewStackPage" id="overview_page">
<property name="name">page1</property>
<property name="title" translatable="yes">Overview</property>
<property name="child">overview_box</property>
<property name="icon-name">emoji-recent-symbolic</property>
</object>
</child>
<child>
<object class="AdwViewStackPage" id="sun_page">
<property name="name">page2</property>
<property name="title" translatable="yes">Sun</property>
<property name="child">sun_box</property>
<property name="icon-name">weather-clear-symbolic</property>
</object>
</child>
<child>
<object class="AdwViewStackPage" id="moon_page">
<property name="name">page3</property>
<property name="title" translatable="yes">Moon</property>
<property name="child">moon_box</property>
<property name="icon-name">weather-clear-night-symbolic</property>
</object>
</child>
<child>
<object class="AdwViewStackPage" id="milky_way_page">
<property name="name">page4</property>
<property name="title" translatable="yes">Milky Way</property>
<property name="child">milky_way_box</property>
<property name="icon-name">milky-way-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwViewSwitcherBar">
<property name="stack">stack</property>
<binding name="reveal">
<lookup name="title-visible">switcher_title</lookup>
</binding>
</object>
</child>
</object>
</child>
</object>
</property>
</template>
<menu id="primary_menu">
<section>
<item>
<attribute name="label" translatable="yes">Preferences</attribute>
<attribute name="action">app.preferences</attribute>
</item>
<item>
<attribute name="label" translatable="yes">About PicPlanner</attribute>
<attribute name="action">app.about</attribute>
</item>
</section>
</menu>
</interface>

Wyświetl plik

@ -45,7 +45,6 @@ struct _PicplannerWindow
GtkWidget *search_bar; /* Search bar for the location */
GtkWidget *search_entry; /* The search entry inside the search bar */
GtkWidget *search_button; /* The search button in the header bar so show the search bar */
GtkWidget *map_button; /* The map button in the header bar to show the map fullscreen */
GtkWidget *location_button; /* Button in the header bar to start the GPS search of the device location */
GtkWidget *overview_box; /* The overview page */
GtkWidget *sun_box; /* The sun page */
@ -53,9 +52,8 @@ struct _PicplannerWindow
GtkWidget *milky_way_box; /* The milky way page */
GtkWidget *north_entry; /* SpinButton for North coordinates */
GtkWidget *east_entry; /* SpinButton for East coordinates */
GtkWidget *clamp_time_selector;
GtkWidget *overview_page;
GtkWidget *time_picker;
GtkWidget *back_button; /* Go back to the overview page */
/* Search functionality */
GtkWidget *search_result_box; /* ListBox containing search results */
@ -77,6 +75,61 @@ struct _PicplannerWindow
G_DEFINE_TYPE (PicplannerWindow, picplanner_window, ADW_TYPE_APPLICATION_WINDOW)
/*
* Change the stack page after a button is pressed in the overview dialog
*/
static void
change_stack_page (GtkWidget *self,
int stack_page,
gpointer user_data)
{
(void) self;
PicplannerWindow *window = user_data;
if (stack_page == 1)
gtk_stack_set_visible_child_name (GTK_STACK(window->stack), "sun");
else if (stack_page == 2)
gtk_stack_set_visible_child_name (GTK_STACK(window->stack), "moon");
else if (stack_page == 3)
gtk_stack_set_visible_child_name (GTK_STACK(window->stack), "milkyway");
}
/*
* Go to overview page when back button is pressed
*/
static void
change_stack_page_back (GtkWidget *self,
gpointer user_data)
{
(void) self;
PicplannerWindow *window = user_data;
gtk_stack_set_visible_child_name (GTK_STACK(window->stack), "overview");
}
/*
* Show or hide the buttons in the header bar dependent on the stack page
*/
static void
stack_page_changed (GObject *self,
GParamSpec *pspec,
gpointer user_data)
{
(void) self;
(void) pspec;
PicplannerWindow *window = user_data;
if (strcmp (gtk_stack_get_visible_child_name (GTK_STACK(window->stack)), "overview") == 0)
{
gtk_widget_set_visible (window->back_button, FALSE);
gtk_widget_set_visible (window->search_button, TRUE);
gtk_widget_set_visible (window->location_button, TRUE);
}
else
{
gtk_widget_set_visible (window->back_button, TRUE);
gtk_widget_set_visible (window->search_button, FALSE);
gtk_widget_set_visible (window->location_button, FALSE);
}
}
/*
* Function used after the user selects a search result
@ -86,14 +139,14 @@ search_location_chosen (GtkWidget *self,
GtkWidget *row,
gpointer user_data)
{
(void) self;
PicplannerWindow *window = user_data;
double latitude;
double longitude;
double *p_latitude = &latitude;
double *p_longitude = &longitude;
int i;
(void) self;
for (i=0; i<NUM_SEARCH_RESULTS; i++)
{
if (row == window->search_result_row[i])
@ -119,16 +172,16 @@ static void
search_location (GtkWidget *self,
gpointer user_data)
{
(void) self;
PicplannerWindow *window = user_data;
const char *search_text = gtk_editable_get_text (GTK_EDITABLE (window->search_entry));
char *search_norm = g_utf8_normalize (search_text, strlen (search_text), G_NORMALIZE_ALL_COMPOSE);
char *search_string = g_utf8_casefold (search_text, strlen (search_norm));
g_autofree char *search_norm = g_utf8_normalize (search_text, strlen (search_text), G_NORMALIZE_ALL_COMPOSE);
g_autofree char *search_string = g_utf8_casefold (search_text, strlen (search_norm));
g_autoptr (GWeatherLocation) world = NULL;
(void) self;
world = gweather_location_get_world ();
for (int i=0; i<NUM_SEARCH_RESULTS; i++)
@ -148,11 +201,10 @@ search_location (GtkWidget *self,
double *p_longitude = &longitude;
double *p_latitude = &latitude;
char *char_coordinates;
char *char_subtitle;
g_autofree char *char_coordinates = NULL;
g_autofree char *char_subtitle = NULL;
gtk_widget_set_visible (window->stack, FALSE);
gtk_widget_set_visible (window->clamp_time_selector, FALSE);
gtk_widget_set_visible (window->search_results_scroll, TRUE);
find_loc_children (world, search_string, window->search_result_location, iteration);
@ -201,8 +253,6 @@ search_location (GtkWidget *self,
gtk_list_box_append (GTK_LIST_BOX (window->search_result_box),
window->search_result_row[i]);
g_free (char_coordinates);
}
}
@ -211,27 +261,8 @@ search_location (GtkWidget *self,
else
{
gtk_widget_set_visible (window->stack, TRUE);
gtk_widget_set_visible (window->clamp_time_selector, TRUE);
gtk_widget_set_visible (window->search_results_scroll, FALSE);
}
g_free (search_norm);
g_free (search_string);
}
/*
* Hide the map fullscreen button if the active view is not "page1" (overview)
*/
static void
stack_changed (AdwViewStack *self,
gpointer pspec,
PicplannerWindow *window)
{
(void) pspec;
if (!strcmp(adw_view_stack_get_visible_child_name (self),"page1"))
gtk_widget_set_visible (window->map_button, TRUE);
else
gtk_widget_set_visible (window->map_button, FALSE);
}
void
@ -246,12 +277,12 @@ picplanner_set_location (double latitude, double longitude, PicplannerWindow *wi
* Changing the date_time variable after a user input was recognized.
* Afterwards, emit a signal to start the calculations.
*/
void
static void
picplanner_update_date_time (PicplannerWindow *window)
{
int year, month, day, hour, minute;
double latitude, longitude;
double latitude, longitude, time_zone;
GWeatherLocation *loc;
longitude = gtk_spin_button_get_value (GTK_SPIN_BUTTON (window->east_entry));
@ -287,7 +318,7 @@ picplanner_update_date_time (PicplannerWindow *window)
0);
}
double time_zone = (double) g_date_time_get_utc_offset (window->date_time)/3600/1000/1000;
time_zone = (double) g_date_time_get_utc_offset (window->date_time)/3600/1000/1000;
time_picker_set_time_zone (TIME_PICKER (window->time_picker),
time_zone);
}
@ -308,19 +339,19 @@ calculate_positions (PicplannerWindow *window)
double longitude, latitude;
double illumination_moon, illumination_moon_later;
int *rise_upper_set_lower_index_sun;
int *rise_upper_set_index_moon;
int *rise_upper_set_index_milky_way;
int *dark_blue_golden_index;
g_autofree int *rise_upper_set_lower_index_sun = NULL;
g_autofree int *rise_upper_set_index_moon = NULL;
g_autofree int *rise_upper_set_index_milky_way = NULL;
g_autofree int *dark_blue_golden_index = NULL;
double *array_coordinates_sun;
double *array_coordinates_moon;
double *array_coordinates_milky_way;
g_autofree double *array_coordinates_sun = NULL;
g_autofree double *array_coordinates_moon = NULL;
g_autofree double *array_coordinates_milky_way = NULL;
char *phase_moon;
g_autofree char *phase_moon = NULL;
GDateTime *date_time_noon;
GDateTime *date_time_later;
g_autoptr (GDateTime) date_time_noon = NULL;
g_autoptr (GDateTime) date_time_later = NULL;
longitude = gtk_spin_button_get_value (GTK_SPIN_BUTTON (window->east_entry));
@ -473,19 +504,6 @@ calculate_positions (PicplannerWindow *window)
rise_upper_set_index_milky_way);
}
/*
* Free allocated memory
*/
g_free (rise_upper_set_lower_index_sun);
g_free (rise_upper_set_index_moon);
g_free (rise_upper_set_index_milky_way);
g_free (dark_blue_golden_index);
g_free (array_coordinates_sun);
g_free (array_coordinates_moon);
g_free (array_coordinates_milky_way);
g_free (phase_moon);
g_date_time_unref (date_time_noon);
/*
* TODO:
* Free loc?
@ -529,9 +547,10 @@ input_changed (GtkWidget *self,
gpointer data_map_move,
gpointer data_window_change)
{
(void) self;
PicplannerWindow *window;
(void) self;
if (PICPLANNER_IS_WINDOW (data_window_change))
window = PICPLANNER_WINDOW (data_window_change);
else
@ -559,9 +578,10 @@ input_changed_remove_content (GtkWidget *self,
gpointer data_map_move,
gpointer data_window_change)
{
(void) self;
PicplannerWindow *window;
(void) self;
if (PICPLANNER_IS_WINDOW (data_window_change))
window = PICPLANNER_WINDOW (data_window_change);
else
@ -586,13 +606,11 @@ picplanner_window_class_init (PicplannerWindowClass *klass)
g_type_ensure (TIME_PICKER_TYPE);
gtk_widget_class_set_template_from_resource (widget_class, "/de/zwarf/picplanner/window/picplanner-window.ui");
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, box_main);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, stack);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, header_bar);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, search_bar);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, search_entry);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, search_button);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, map_button);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, location_button);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, overview_box);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, sun_box);
@ -602,9 +620,8 @@ picplanner_window_class_init (PicplannerWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, east_entry);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, search_result_box);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, search_results_scroll);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, clamp_time_selector);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, overview_page);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, time_picker);
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, back_button);
gtk_widget_class_bind_template_callback (widget_class, search_location);
}
@ -635,10 +652,6 @@ picplanner_window_init (PicplannerWindow *window)
window->north_entry, "value",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind (window->settings, "map-fullscreen",
window->map_button, "active",
G_SETTINGS_BIND_DEFAULT);
g_object_bind_property (window->search_button, "active",
window->search_bar, "search-mode-enabled",
G_BINDING_BIDIRECTIONAL);
@ -674,11 +687,6 @@ picplanner_window_init (PicplannerWindow *window)
G_CALLBACK (search_location_chosen),
window);
g_signal_connect (G_OBJECT (window->stack),
"notify::visible-child",
G_CALLBACK (stack_changed),
window);
g_signal_connect (G_OBJECT (window->location_button),
"clicked",
G_CALLBACK (get_user_location),
@ -689,6 +697,21 @@ picplanner_window_init (PicplannerWindow *window)
G_CALLBACK (input_changed),
window);
g_signal_connect (G_OBJECT (window->overview_box),
"change-stack",
G_CALLBACK (change_stack_page),
window);
g_signal_connect (G_OBJECT (window->back_button),
"clicked",
G_CALLBACK (change_stack_page_back),
window);
g_signal_connect (G_OBJECT (window->stack),
"notify::visible-child-name",
G_CALLBACK (stack_page_changed),
window);
/*
* Initialisation of values needed to detect when a user input ends
*/
@ -696,6 +719,8 @@ picplanner_window_init (PicplannerWindow *window)
window->input_count = 0;
window->input_timeout_id = 0;
stack_page_changed (NULL, NULL, window);
/*
* Setup the location searchbar to register keyboard input

Wyświetl plik

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="PicplannerOverview" id="overview_box">
<property name="orientation">vertical</property>
</object>
@ -32,38 +33,33 @@
<template class="PicplannerWindow" parent="AdwApplicationWindow">
<property name="vexpand">true</property>
<property name="valign">fill</property>
<property name="content">
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="vexpand">true</property>
<property name="valign">fill</property>
<child>
<object class="AdwHeaderBar" id="header_bar">
<property name="centering_policy">strict</property>
<child type="title">
<object class="AdwViewSwitcherTitle" id="switcher_title">
<property name="hexpand">true</property>
<property name="halign">fill</property>
<property name="stack">stack</property>
<property name="title">PicPlanner</property>
<property name="title-widget">
<object class="TimePicker" id="time_picker">
</object>
</property>
<child type="start">
<object class="GtkButton" id="back_button">
<property name="icon-name">go-previous-symbolic</property>
<property name="tooltip-text">Overview</property>
</object>
</child>
<child type="start">
<object class="GtkToggleButton" id="search_button">
<property name="icon-name">edit-find-symbolic</property>
<property name="tooltip-text">Search location</property>
</object>
</child>
<child type="start">
<object class="GtkButton" id="location_button">
<property name="icon-name">find-location-symbolic</property>
</object>
</child>
<child type="start">
<object class="GtkToggleButton" id="map_button">
<property name="icon-name">map-symbolic</property>
<property name="tooltip-text">Locate position</property>
</object>
</child>
<child type="end">
@ -72,84 +68,74 @@
<property name="menu-model">primary_menu</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="box_main">
<property name="orientation">vertical</property>
<property name="vexpand">true</property>
<property name="valign">fill</property>
<object class="GtkSearchBar" id="search_bar">
<property name="visible">true</property>
<property name="can_focus">true</property>
<property name="search-mode-enabled">false</property>
<property name="show-close-button">true</property>
<child>
<object class="GtkSearchBar" id="search_bar">
<property name="visible">true</property>
<property name="can_focus">true</property>
<property name="search-mode-enabled">false</property>
<property name="show-close-button">true</property>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="hexpand">true</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="hexpand">true</property>
<child>
<object class="GtkSearchEntry" id="search_entry">
<property name="margin-top">2</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="visible">true</property>
<property name="can-focus">true</property>
<property name="placeholder-text" translatable="yes">Search... City, Region, Country</property>
<signal name="search-changed" handler="search_location"/>
</object>
</child>
<object class="GtkSearchEntry" id="search_entry">
<property name="margin-top">2</property>
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="visible">true</property>
<property name="can-focus">true</property>
<property name="placeholder-text" translatable="yes">Search... City, Region, Country</property>
<signal name="search-changed" handler="search_location"/>
</object>
</child>
<child>
<object class="AdwClamp">
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<child>
<object class="AdwClamp">
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwPreferencesGroup">
<object class="AdwExpanderRow">
<property name="title" translatable="yes">Coordinates</property>
<child>
<object class="AdwExpanderRow">
<property name="title" translatable="yes">Coordinates</property>
<object class="AdwActionRow">
<property name="title" translatable="yes">North</property>
<child>
<object class="GtkSpinButton" id="north_entry">
<property name="halign">end</property>
<property name="adjustment">north_adjustment</property>
<property name="numeric">false</property>
<property name="wrap">true</property>
<property name="digits">4</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">North</property>
<child>
<object class="GtkSpinButton" id="north_entry">
<property name="halign">end</property>
<property name="adjustment">north_adjustment</property>
<property name="numeric">false</property>
<property name="wrap">true</property>
<property name="digits">4</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">East</property>
<child>
<object class="GtkSpinButton" id="east_entry">
<property name="halign">end</property>
<property name="adjustment">east_adjustment</property>
<property name="numeric">false</property>
<property name="wrap">true</property>
<property name="digits">4</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">East</property>
<child>
<object class="GtkSpinButton" id="east_entry">
<property name="halign">end</property>
<property name="adjustment">east_adjustment</property>
<property name="numeric">false</property>
<property name="wrap">true</property>
<property name="digits">4</property>
</object>
</child>
</object>
</child>
</object>
</child>
@ -157,126 +143,89 @@
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow" id="search_results_scroll">
<property name="visible">false</property>
<property name="hexpand">true</property>
<property name="halign">fill</property>
<property name="vexpand">true</property>
<property name="valign">fill</property>
<child>
<object class="AdwBin">
<property name="hexpand">true</property>
<property name="halign">fill</property>
<property name="vexpand">true</property>
<property name="valign">start</property>
<property name="margin-start">15</property>
<property name="margin-end">15</property>
<property name="margin-top">15</property>
<property name="margin-bottom">15</property>
<child>
<object class="GtkListBox" id="search_result_box">
<property name="hexpand">true</property>
<property name="halign">fill</property>
<property name="vexpand">true</property>
<property name="valign">fill</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwClamp" id="clamp_time_selector">
<property name="margin-top">12</property>
<property name="margin-bottom">12</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwPreferencesRow">
<property name="title">Date and Time</property>
<property name="activatable">false</property>
<child>
<object class="TimePicker" id="time_picker">
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwViewStack" id="stack">
<property name="vexpand">true</property>
<property name="valign">fill</property>
<child>
<object class="AdwViewStackPage" id="overview_page">
<property name="name">page1</property>
<property name="title" translatable="yes">Overview</property>
<property name="child">overview_box</property>
<property name="icon-name">emoji-recent-symbolic</property>
</object>
</child>
<child>
<object class="AdwViewStackPage" id="sun_page">
<property name="name">page2</property>
<property name="title" translatable="yes">Sun</property>
<property name="child">sun_box</property>
<property name="icon-name">weather-clear-symbolic</property>
</object>
</child>
<child>
<object class="AdwViewStackPage" id="moon_page">
<property name="name">page3</property>
<property name="title" translatable="yes">Moon</property>
<property name="child">moon_box</property>
<property name="icon-name">weather-clear-night-symbolic</property>
</object>
</child>
<child>
<object class="AdwViewStackPage" id="milky_way_page">
<property name="name">page4</property>
<property name="title" translatable="yes">Milky Way</property>
<property name="child">milky_way_box</property>
<property name="icon-name">milky-way-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwViewSwitcherBar">
<property name="stack">stack</property>
<binding name="reveal">
<lookup name="title-visible">switcher_title</lookup>
</binding>
</object>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow" id="search_results_scroll">
<property name="visible">false</property>
<property name="hexpand">true</property>
<property name="halign">fill</property>
<property name="vexpand">true</property>
<property name="valign">fill</property>
<child>
<object class="AdwBin">
<property name="hexpand">true</property>
<property name="halign">fill</property>
<property name="vexpand">true</property>
<property name="valign">start</property>
<property name="margin-start">15</property>
<property name="margin-end">15</property>
<property name="margin-top">15</property>
<property name="margin-bottom">15</property>
<child>
<object class="GtkListBox" id="search_result_box">
<property name="hexpand">true</property>
<property name="halign">fill</property>
<property name="vexpand">true</property>
<property name="valign">fill</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkStack" id="stack">
<property name="width-request">360</property>
<child>
<object class="GtkStackPage" id="overview_page">
<property name="name">overview</property>
<property name="title" translatable="yes">Overview</property>
<property name="icon-name">emoji-recent-symbolic</property>
<property name="child">overview_box</property>
</object>
</child>
<child>
<object class="GtkStackPage" id="sun_page">
<property name="name">sun</property>
<property name="title" translatable="yes">Sun</property>
<property name="icon-name">weather-clear-symbolic</property>
<property name="child">sun_box</property>
</object>
</child>
<child>
<object class="GtkStackPage" id="moon_page">
<property name="name">moon</property>
<property name="title" translatable="yes">Moon</property>
<property name="icon-name">weather-clear-night-symbolic</property>
<property name="child">moon_box</property>
</object>
</child>
<child>
<object class="GtkStackPage" id="milky_way_page">
<property name="name">milkyway</property>
<property name="title" translatable="yes">Milky Way</property>
<property name="icon-name">milky-way-symbolic</property>
<property name="child">milky_way_box</property>
</object>
</child>
</object>
</child>
</object>
</property>
</child>
</template>
<menu id="primary_menu">

Wyświetl plik

@ -61,24 +61,24 @@ picplanner_sun_set_rise_upper_set (PicplannerSun *sun,
double *coordinates_array,
int *index_rise_upper_set_lower)
{
char *char_morning_rise_time;
char *char_morning_rise_azimuth;
g_autofree char *char_morning_rise_time = NULL;
g_autofree char *char_morning_rise_azimuth = NULL;
char *char_upper_time;
char *char_upper_azimuth;
char *char_upper_elevation;
g_autofree char *char_upper_time = NULL;
g_autofree char *char_upper_azimuth = NULL;
g_autofree char *char_upper_elevation = NULL;
char *char_lower_time;
char *char_lower_azimuth;
char *char_lower_elevation;
g_autofree char *char_lower_time = NULL;
g_autofree char *char_lower_azimuth = NULL;
g_autofree char *char_lower_elevation = NULL;
char *char_evening_set_time;
char *char_evening_set_azimuth;
g_autofree char *char_evening_set_time = NULL;
g_autofree char *char_evening_set_azimuth = NULL;
GDateTime *date_time_rise;
GDateTime *date_time_upper;
GDateTime *date_time_set;
GDateTime *date_time_lower;
g_autoptr (GDateTime) date_time_rise = NULL;
g_autoptr (GDateTime) date_time_upper = NULL;
g_autoptr (GDateTime) date_time_set = NULL;
g_autoptr (GDateTime) date_time_lower = NULL;
date_time_rise = g_date_time_add_minutes (date_time,
@ -159,26 +159,6 @@ picplanner_sun_set_rise_upper_set (PicplannerSun *sun,
gtk_label_set_text (GTK_LABEL (sun->label_lower_time), char_lower_time);
gtk_label_set_text (GTK_LABEL (sun->label_lower_azimuth), char_lower_azimuth);
gtk_label_set_text (GTK_LABEL (sun->label_lower_elevation), char_lower_elevation);
/*
* Free allocated memory.
*/
g_date_time_unref (date_time_rise);
g_date_time_unref (date_time_upper);
g_date_time_unref (date_time_set);
g_free (char_morning_rise_time);
g_free (char_morning_rise_azimuth);
g_free (char_upper_time);
g_free (char_upper_azimuth);
g_free (char_upper_elevation);
g_free (char_lower_time);
g_free (char_lower_azimuth);
g_free (char_lower_elevation);
g_free (char_evening_set_time);
g_free (char_evening_set_azimuth);
}
@ -191,21 +171,21 @@ picplanner_sun_set_dark_blue_golden (PicplannerSun *sun,
GDateTime *date_time,
int *index_dark_blue_golden)
{
char *char_dark_night_morning;
char *char_blue_hour_morning;
char *char_golden_hour_morning;
GDateTime *dark_night_morning_end;
GDateTime *blue_hour_morning_begin;
GDateTime *blue_hour_golden_hour_morning_switch;
GDateTime *golden_hour_morning_end;
g_autofree char *char_dark_night_morning = NULL;
g_autofree char *char_blue_hour_morning = NULL;
g_autofree char *char_golden_hour_morning = NULL;
g_autoptr (GDateTime) dark_night_morning_end = NULL;
g_autoptr (GDateTime) blue_hour_morning_begin = NULL;
g_autoptr (GDateTime) blue_hour_golden_hour_morning_switch = NULL;
g_autoptr (GDateTime) golden_hour_morning_end = NULL;
char *char_golden_hour_evening;
char *char_blue_hour_evening;
char *char_dark_night_evening;
GDateTime *golden_hour_evening_begin;
GDateTime *golden_hour_blue_hour_evening_switch;
GDateTime *blue_hour_evening_end;
GDateTime *dark_night_evening_begin;
g_autofree char *char_golden_hour_evening = NULL;
g_autofree char *char_blue_hour_evening = NULL;
g_autofree char *char_dark_night_evening = NULL;
g_autoptr (GDateTime) golden_hour_evening_begin = NULL;
g_autoptr (GDateTime) golden_hour_blue_hour_evening_switch = NULL;
g_autoptr (GDateTime) blue_hour_evening_end = NULL;
g_autoptr (GDateTime) dark_night_evening_begin = NULL;
dark_night_morning_end = g_date_time_add_minutes (date_time,
index_dark_blue_golden[0]*24*60/NUM_DATA_POINTS-12*60);
@ -354,26 +334,6 @@ picplanner_sun_set_dark_blue_golden (PicplannerSun *sun,
gtk_label_set_text (GTK_LABEL (sun->label_evening_golden), char_golden_hour_evening);
gtk_label_set_text (GTK_LABEL (sun->label_evening_blue), char_blue_hour_evening);
gtk_label_set_text (GTK_LABEL (sun->label_evening_dark), char_dark_night_evening);
/*
* Free allocated memory.
*/
g_date_time_unref (dark_night_morning_end);
g_date_time_unref (blue_hour_morning_begin);
g_date_time_unref (blue_hour_golden_hour_morning_switch);
g_date_time_unref (golden_hour_morning_end);
g_date_time_unref (golden_hour_evening_begin);
g_date_time_unref (golden_hour_blue_hour_evening_switch);
g_date_time_unref (blue_hour_evening_end);
g_date_time_unref (dark_night_evening_begin);
g_free (char_dark_night_morning);
g_free (char_blue_hour_morning);
g_free (char_golden_hour_morning);
g_free (char_golden_hour_evening);
g_free (char_blue_hour_evening);
g_free (char_dark_night_evening);
}
static void
@ -406,7 +366,7 @@ picplanner_sun_class_init (PicplannerSunClass *class)
}
PicplannerSun *
picplanner_sun_new ()
picplanner_sun_new (void)
{
return g_object_new (PICPLANNER_SUN_TYPE, NULL);
}

Wyświetl plik

@ -49,6 +49,6 @@ picplanner_sun_set_dark_blue_golden (PicplannerSun *sun,
int *index_dark_blue_golden);
PicplannerSun *picplanner_sun_new ();
PicplannerSun *picplanner_sun_new (void);
G_END_DECLS