From 3cd2c8e20343ef4b4efe7a34daba72f9af23205d Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 12 Apr 2016 12:03:36 -0500 Subject: in TimedatedTimezone, take a GDBusConnection argument in the ctor to simplify state management --- src/main.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 0da55a2..bb77c0e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -71,7 +71,7 @@ namespace { // create the live objects auto live_settings = std::make_shared(); - auto live_timezones = std::make_shared(live_settings); + auto live_timezones = std::make_shared(live_settings, timezone_); auto live_clock = std::make_shared(timezone_); // create a full-month planner currently pointing to the current month @@ -132,8 +132,17 @@ main(int /*argc*/, char** /*argv*/) bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); textdomain(GETTEXT_PACKAGE); + // get the system bus + GError* error {}; + auto system_bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &error); + if (error != nullptr) { + g_critical("Unable to get system bus: %s", error->message); + g_clear_error(&error); + return 0; + } + auto engine = create_engine(); - auto timezone_ = std::make_shared(); + auto timezone_ = std::make_shared(system_bus); auto state = create_state(engine, timezone_); auto actions = std::make_shared(state); MenuFactory factory(actions, state); @@ -171,5 +180,6 @@ main(int /*argc*/, char** /*argv*/) g_main_loop_run(loop); g_main_loop_unref(loop); + g_clear_object(&system_bus); return 0; } -- cgit v1.2.3