aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/datetime/timezones-live.h13
-rw-r--r--src/timezones-live.cpp12
2 files changed, 14 insertions, 11 deletions
diff --git a/include/datetime/timezones-live.h b/include/datetime/timezones-live.h
index 5f2cb3e..286c967 100644
--- a/include/datetime/timezones-live.h
+++ b/include/datetime/timezones-live.h
@@ -20,9 +20,10 @@
#ifndef INDICATOR_DATETIME_LIVE_TIMEZONES_H
#define INDICATOR_DATETIME_LIVE_TIMEZONES_H
-#include <datetime/timezones.h> // base class
-#include <datetime/timezone-file.h> // aggregated
-#include <datetime/timezone-geoclue.h> // aggregated
+#include <datetime/settings.h>
+#include <datetime/timezones.h>
+#include <datetime/timezone-file.h>
+#include <datetime/timezone-geoclue.h>
#include <memory> // shared_ptr<>
@@ -37,16 +38,14 @@ namespace datetime {
class LiveTimezones: public Timezones
{
public:
- LiveTimezones(const std::string& filename);
-
- /** \brief Whether or not to track location by IP address */
- core::Property<bool> geolocation_enabled = core::Property<bool>(false);
+ LiveTimezones(std::shared_ptr<Settings>& settings, const std::string& filename);
private:
void update_geolocation();
void update_timezones();
FileTimezone m_file;
+ std::shared_ptr<Settings> m_settings;
std::shared_ptr<GeoclueTimezone> m_geo;
};
diff --git a/src/timezones-live.cpp b/src/timezones-live.cpp
index dc14021..baac05d 100644
--- a/src/timezones-live.cpp
+++ b/src/timezones-live.cpp
@@ -18,18 +18,20 @@
*/
#include <datetime/timezones-live.h>
+
#include <glib.h>
namespace unity {
namespace indicator {
namespace datetime {
-LiveTimezones::LiveTimezones(const std::string& filename):
- m_file(filename)
+LiveTimezones::LiveTimezones(std::shared_ptr<Settings>& settings, const std::string& filename):
+ m_file(filename),
+ m_settings(settings)
{
m_file.timezone.changed().connect([this](const std::string&){update_timezones();});
- geolocation_enabled.changed().connect([this](bool){update_geolocation();});
+ m_settings->show_detected_location.changed().connect([this](bool){update_geolocation();});
update_geolocation();
update_timezones();
@@ -37,9 +39,11 @@ LiveTimezones::LiveTimezones(const std::string& filename):
void LiveTimezones::update_geolocation()
{
+ // clear the previous pointer, if any
m_geo.reset();
- if(geolocation_enabled.get())
+ // if location detection is enabled, turn on GeoClue
+ if(m_settings->show_detected_location.get())
{
auto geo = new GeoclueTimezone();
geo->timezone.changed().connect([this](const std::string&){update_timezones();});