aboutsummaryrefslogtreecommitdiff
path: root/src/locations-settings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/locations-settings.cpp')
-rw-r--r--src/locations-settings.cpp59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/locations-settings.cpp b/src/locations-settings.cpp
index ed8f998..646a360 100644
--- a/src/locations-settings.cpp
+++ b/src/locations-settings.cpp
@@ -29,16 +29,16 @@ namespace unity {
namespace indicator {
namespace datetime {
-SettingsLocations::SettingsLocations (const std::string& schemaId,
- const std::shared_ptr<Timezones>& timezones):
- timezones_(timezones)
+SettingsLocations::SettingsLocations(const std::string& schemaId,
+ const std::shared_ptr<Timezones>& timezones):
+ m_timezones(timezones)
{
- auto deleter = [&](GSettings* s){g_object_unref(s);};
- settings_ = std::unique_ptr<GSettings,std::function<void(GSettings*)>>(g_settings_new(schemaId.c_str()), deleter);
+ auto deleter = [](GSettings* s){g_object_unref(s);};
+ m_settings = std::unique_ptr<GSettings,std::function<void(GSettings*)>>(g_settings_new(schemaId.c_str()), deleter);
const char * keys[] = { "changed::" SETTINGS_LOCATIONS_S,
"changed::" SETTINGS_SHOW_LOCATIONS_S };
- for (int i=0, n=G_N_ELEMENTS(keys); i<n; i++)
- g_signal_connect_swapped (settings_.get(), keys[i], G_CALLBACK(onSettingsChanged), this);
+ for (const auto& key : keys)
+ g_signal_connect_swapped(m_settings.get(), key, G_CALLBACK(onSettingsChanged), this);
timezones->timezone.changed().connect([this](const std::string&){reload();});
timezones->timezones.changed().connect([this](const std::set<std::string>&){reload();});
@@ -47,7 +47,7 @@ SettingsLocations::SettingsLocations (const std::string& schemaId,
}
void
-SettingsLocations::onSettingsChanged (gpointer gself)
+SettingsLocations::onSettingsChanged(gpointer gself)
{
static_cast<SettingsLocations*>(gself)->reload();
}
@@ -56,48 +56,49 @@ void
SettingsLocations::reload()
{
std::vector<Location> v;
+ auto settings = m_settings.get();
// add the primary timezone first
- std::string zone = timezones_->timezone.get();
+ auto zone = m_timezones->timezone.get();
if (!zone.empty())
{
- gchar * name = get_current_zone_name (zone.c_str(), settings_.get());
- Location l (zone, name);
- v.push_back (l);
- g_free (name);
+ gchar * name = get_current_zone_name(zone.c_str(), settings);
+ Location l(zone, name);
+ v.push_back(l);
+ g_free(name);
}
// add the other detected timezones
- for (const auto& zone : timezones_->timezones.get())
+ for (const auto& zone : m_timezones->timezones.get())
{
- gchar * name = get_current_zone_name (zone.c_str(), settings_.get());
- Location l (zone, name);
- if (std::find (v.begin(), v.end(), l) == v.end())
- v.push_back (l);
- g_free (name);
+ gchar * name = get_current_zone_name(zone.c_str(), settings);
+ Location l(zone, name);
+ if (std::find(v.begin(), v.end(), l) == v.end())
+ v.push_back(l);
+ g_free(name);
}
// maybe add the user-specified locations
- if (g_settings_get_boolean (settings_.get(), SETTINGS_SHOW_LOCATIONS_S))
+ if (g_settings_get_boolean(settings, SETTINGS_SHOW_LOCATIONS_S))
{
- gchar ** user_locations = g_settings_get_strv (settings_.get(), SETTINGS_LOCATIONS_S);
+ gchar ** user_locations = g_settings_get_strv(settings, SETTINGS_LOCATIONS_S);
for (int i=0; user_locations[i]; i++)
{
gchar * zone;
gchar * name;
- split_settings_location (user_locations[i], &zone, &name);
- Location l (zone, name);
- if (std::find (v.begin(), v.end(), l) == v.end())
- v.push_back (l);
- g_free (name);
- g_free (zone);
+ split_settings_location(user_locations[i], &zone, &name);
+ Location l(zone, name);
+ if (std::find(v.begin(), v.end(), l) == v.end())
+ v.push_back(l);
+ g_free(name);
+ g_free(zone);
}
- g_strfreev (user_locations);
+ g_strfreev(user_locations);
}
- locations.set (v);
+ locations.set(v);
}
} // namespace datetime