Languages bug fix and adding location services

A bug in the language file caused some random errors during the build process.
By clicking on the location icon on the header bar it is now possible to get the users location (GeoClue).
merge-requests/4/head
Zwarf 2022-09-09 22:51:24 +02:00
rodzic 549cd06253
commit 4408d1db65
8 zmienionych plików z 160 dodań i 22 usunięć

Wyświetl plik

@ -101,6 +101,23 @@
}
]
},
{
"name": "libgeoclue",
"buildsystem": "meson",
"config-opts" : [
"-Denable-backend=false",
"-Dlibgeoclue=true",
"-Dintrospection=true",
"-Dgtk-doc=false"
],
"sources": [
{
"type" : "git",
"url": "https://gitlab.freedesktop.org/geoclue/geoclue.git",
"commit": "10998ca3215fb6d21b5a32fdf78bb5feffaf4c0f"
}
]
},
{
"name" : "picplanner",
"builddir" : true,
@ -108,8 +125,7 @@
"sources" : [
{
"type" : "git",
"url" : "https://gitlab.com/Zwarf/picplanner.git",
"commit" : "9b23b4b20615693383055fe999b27d5756eb7418"
"url" : "~/Projekte/picplanner"
}
]
}

Wyświetl plik

@ -1,7 +1,13 @@
data/de.zwarf.picplanner.desktop.in
data/de.zwarf.picplanner.appdata.xml.in
data/de.zwarf.picplanner.gschema.xml
src/picplanner-window.ui
src/main.c
src/picplanner-window.c
src/window/picplanner-window.ui
src/window/sun-page/sun-view.ui
src/window/moon-page/moon-view.ui
src/window/milky-way-page/milky-way-view.ui
src/window/preferences-dialog/preferences-dialog.ui
src/main.c
src/window/picplanner-window.c
src/window/sun-page/sun-view.c
src/window/moon-page/moon-view.c
src/window/milky-way-page/milky-way-view.c
src/window/preferences-dialog/preferences-dialog.c

Wyświetl plik

@ -1,3 +1,19 @@
# German translation for picplanner.
# Copyright (C) 2022 picplanner COPYRIGHT HOLDER
# This file is distributed under the same license as the picplanner package.
#
# Zwarf <zwarf@mail.de>, 2022.
msgid ""
msgstr ""
"Project-Id-Version: picplanner master\n"
"Report-Msgid-Bugs-To: https://gitlab.com/Zwarf/picplanner/-/issues\n"
"Last-Translator: Zwarf <zwarf@mail.de>\n"
"Language: de\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
# /src/window/picplanner-window.ui
# /src/window/preferences-dialog/preferences-dialog.ui

Wyświetl plik

@ -22,6 +22,7 @@ picplanner_deps = [
dependency('shumate-1.0'),
dependency('geocode-glib-1.0'),
dependency('gweather4'),
dependency('libgeoclue-2.0'),
meson.get_compiler('c').find_library('m', required: false),
]

Wyświetl plik

@ -88,7 +88,7 @@ picplanner_application_activate (GApplication *app)
if (window == NULL)
window = g_object_new (PICPLANNER_TYPE_WINDOW,
"application", app,
"default-width", 650,
"default-width", 900,
"default-height", 800,
NULL);

Wyświetl plik

@ -25,8 +25,7 @@
#include "calculations/calculations_moon.h"
#include "calculations/calculations_milky_way.h"
#include "search/search.h"
#include <libgweather/gweather.h>
#include <glib/gi18n.h>
/*
* The time of no input of map movement that has to pass until a calculation of the positions
@ -34,6 +33,13 @@
*/
#define INPUT_CHANGED_TIMEOUT_LENGTH 100
/*
* Definitions neccessary for GeoClue
*/
static gint timeout = 30; /* seconds */
static GClueAccuracyLevel accuracy_level = GCLUE_ACCURACY_LEVEL_EXACT;
static gint time_threshold;
struct _PicplannerWindow
{
@ -42,17 +48,18 @@ struct _PicplannerWindow
/* 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 *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 *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;
@ -78,6 +85,10 @@ struct _PicplannerWindow
guint input_timeout_id;
gboolean input_new;
/* GeoClue */
GClueSimple *simple;
GClueClient *client;
/* All settings of PicPlanner */
GSettings *settings;
@ -231,6 +242,70 @@ search_location (GtkWidget *self,
}
static gboolean
on_location_timeout (PicplannerWindow *window)
{
g_clear_object (&window->client);
g_clear_object (&window->simple);
return FALSE;
}
static void
set_user_location (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
g_print ("Gathering location information\n");
PicplannerWindow *window = PICPLANNER_WINDOW (user_data);
GError *error = NULL;
window->simple = gclue_simple_new_with_thresholds_finish (res, &error);
if (error == NULL)
{
GClueLocation *location;
location = gclue_simple_get_location (window->simple);
g_print ("\nNew location:\n");
g_print ("Latitude: %f°\nLongitude: %f°\nAccuracy: %f meters\n",
gclue_location_get_latitude (location),
gclue_location_get_longitude (location),
gclue_location_get_accuracy (location));
gtk_spin_button_set_value (GTK_SPIN_BUTTON (window->north_entry),
gclue_location_get_latitude(location));
gtk_spin_button_set_value (GTK_SPIN_BUTTON (window->east_entry),
gclue_location_get_longitude(location));
}
else
{
g_print ("Cannot receive location!\n");
}
on_location_timeout (window);
}
/*
* Get the users location
*/
static void
get_user_location (GtkButton *self,
PicplannerWindow *window)
{
(void) self;
(void) window;
g_print ("Looking for users location...\n");
gclue_simple_new_with_thresholds ("picplanner",
accuracy_level,
time_threshold,
0,
NULL,
set_user_location,
window);
}
/*
* Show the map in fullscreen
*/
@ -682,6 +757,7 @@ picplanner_window_class_init (PicplannerWindowClass *klass)
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);
@ -726,6 +802,15 @@ picplanner_window_init (PicplannerWindow *window)
gtk_spin_button_set_value (GTK_SPIN_BUTTON (window->spin_button_minute),
g_date_time_get_minute (window->date_time));
/*
* Initialize GeoClue
*/
window->simple = NULL;
window->client = NULL;
/*
* Callbacks
*/
g_settings_bind (window->settings, "longitude",
window->east_entry, "value",
@ -800,6 +885,11 @@ picplanner_window_init (PicplannerWindow *window)
G_CALLBACK (stack_changed),
window);
g_signal_connect (G_OBJECT (window->location_button),
"clicked",
G_CALLBACK (get_user_location),
window);
/*
* Initialisation of values needed to detect when a user input ends
*/

Wyświetl plik

@ -20,6 +20,9 @@
#include <gtk/gtk.h>
#include <adwaita.h>
#include <geoclue.h>
#include <glib/gi18n.h>
#include <libgweather/gweather.h>
#include "picplanner-config.h"
#include "picplanner-application.h"

Wyświetl plik

@ -72,6 +72,12 @@
<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>